From patchwork Mon May 15 08:19:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hou Wenlong X-Patchwork-Id: 93965 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp6757178vqo; Mon, 15 May 2023 01:28:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4s+5e/WUUz+my8tD60WM9FUkxnC13rCTB16IpMLDnNHNgi2bE6GxpSDV+PXmqvndi9JqKf X-Received: by 2002:a05:6a21:7891:b0:101:73a9:1680 with SMTP id bf17-20020a056a21789100b0010173a91680mr27350282pzc.8.1684139291897; Mon, 15 May 2023 01:28:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684139291; cv=none; d=google.com; s=arc-20160816; b=STHc8tP7ZDnpXWD9nsu5RVQMuwNpwYDCtLAGCRt60jX8/eQyM4JwcNufU9Jn3Bg0vG Jo4TZCggooS+w9hiomHTlDwOHpGku5QT1js/EeYwJ37KGIc0Q0Y0rW3ZAWzYVymF4qG2 HMTTQkK4Lkewku0EJhVmDhFKvbkxmPurxzDGRFEbBRXp/SPr2DshS2RhHgIHkvhVPvCR Vekdd5ctcDn7okKbLYu43Hc1SOLbTeqazrv6WRCzxVnQGjr65LO9piaRe6dlWqgi2Vxj yyCzUaHV6XR2HiZrpNMHV0COdLx4ID86WbWlMfdZZxbcFGiNPpURBQ2T5yCV9W7l/WND 8dKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=SYB5nrbpX20wJmmtE8Nyqwb9hyizIIOdW60TWaSoJxs=; b=A9X/BtnjdYre4RR395xiCn2s9dMIiiZwcatQON/F1Hptd1g5o8cmCwyZe/130rFwes wuikmGF1ZH5H2Xml4EJQ1O371/yNsRpVada5dbp5kNcjEzTC07eyFv/sUEtJoQNrztQA N/i1sWaqVBleIDQevde9mi0ghrvGrz8HT+XLlcyO49Ht7qPmtwVFfke4vAD1yqE9Xj/J YQNE/KsgTMpw/w8UpFPlsSgxzsSllxHJAOssGcw2drAcHXa5cglWL8s4jkc8cLCA0Rb/ HiS7D0FpAun6zSkD9Z3iyzgpIanQuIvCH7rVViUVbk5oEh65A2JNG+/+FpbPY9JRdpSS BWeA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d129-20020a633687000000b00525030ba5acsi16048966pga.279.2023.05.15.01.27.59; Mon, 15 May 2023 01:28:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235181AbjEOIYQ (ORCPT + 99 others); Mon, 15 May 2023 04:24:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231829AbjEOIWL (ORCPT ); Mon, 15 May 2023 04:22:11 -0400 Received: from out0-222.mail.aliyun.com (out0-222.mail.aliyun.com [140.205.0.222]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AC2310D7 for ; Mon, 15 May 2023 01:20:28 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R621e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018047194;MF=houwenlong.hwl@antgroup.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---.T2G7nz7_1684138818; Received: from localhost(mailfrom:houwenlong.hwl@antgroup.com fp:SMTPD_---.T2G7nz7_1684138818) by smtp.aliyun-inc.com; Mon, 15 May 2023 16:20:19 +0800 From: "Hou Wenlong" To: linux-kernel@vger.kernel.org Cc: "Lai Jiangshan" , "Hou Wenlong" , "Juergen Gross" , "Boris Ostrovsky" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , , "H. Peter Anvin" , Subject: [PATCH RFC 2/4] x86/xen: Pin up to VSYSCALL_ADDR when vsyscall page is out of fixmap area Date: Mon, 15 May 2023 16:19:33 +0800 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765948042082699947?= X-GMAIL-MSGID: =?utf-8?q?1765948042082699947?= If the vsyscall page is moved out of the fixmap area, then FIXADDR_TOP would be below the vsyscall page. Therefore, it should be pinned up to VSYSCALL_ADDR if vsyscall is enabled. Suggested-by: Lai Jiangshan Signed-off-by: Hou Wenlong --- arch/x86/xen/mmu_pv.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c index c42c60faa3bb..c1f298c31e64 100644 --- a/arch/x86/xen/mmu_pv.c +++ b/arch/x86/xen/mmu_pv.c @@ -587,6 +587,12 @@ static void xen_p4d_walk(struct mm_struct *mm, p4d_t *p4d, xen_pud_walk(mm, pud, func, last, limit); } +#ifdef CONFIG_X86_VSYSCALL_EMULATION +#define __KERNEL_MAP_TOP (VSYSCALL_ADDR + PAGE_SIZE) +#else +#define __KERNEL_MAP_TOP FIXADDR_TOP +#endif + /* * (Yet another) pagetable walker. This one is intended for pinning a * pagetable. This means that it walks a pagetable and calls the @@ -594,7 +600,7 @@ static void xen_p4d_walk(struct mm_struct *mm, p4d_t *p4d, * at every level. It walks the entire pagetable, but it only bothers * pinning pte pages which are below limit. In the normal case this * will be STACK_TOP_MAX, but at boot we need to pin up to - * FIXADDR_TOP. + * __KERNEL_MAP_TOP. * * We must skip the Xen hole in the middle of the address space, just after * the big x86-64 virtual hole. @@ -609,7 +615,7 @@ static void __xen_pgd_walk(struct mm_struct *mm, pgd_t *pgd, /* The limit is the last byte to be touched */ limit--; - BUG_ON(limit >= FIXADDR_TOP); + BUG_ON(limit >= __KERNEL_MAP_TOP); /* * 64-bit has a great big hole in the middle of the address @@ -797,7 +803,7 @@ static void __init xen_after_bootmem(void) #ifdef CONFIG_X86_VSYSCALL_EMULATION SetPagePinned(virt_to_page(level3_user_vsyscall)); #endif - xen_pgd_walk(&init_mm, xen_mark_pinned, FIXADDR_TOP); + xen_pgd_walk(&init_mm, xen_mark_pinned, __KERNEL_MAP_TOP); } static void xen_unpin_page(struct mm_struct *mm, struct page *page,