Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1874007rwr; Fri, 28 Apr 2023 03:06:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Q/SnB04ZlFvCv132s/is7yL6KJMxFNbQ3nUoCvb5r6DcQao04UBRTzU2d2ZKeaxablf0F X-Received: by 2002:a05:6a20:1608:b0:f5:b7c9:57b8 with SMTP id l8-20020a056a20160800b000f5b7c957b8mr6328482pzj.42.1682676394940; Fri, 28 Apr 2023 03:06:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682676394; cv=none; d=google.com; s=arc-20160816; b=fWfmUF+ltw47bZkPLDAHygeHX6QcKjfn/13fkDFsuRFpzfoFIF+gSbMNkhgC3QUvFE PyXGEO+TZ9ycYfhWZC8EFakuQkl7/tdELtxnSNVQOz9UwUtfm8+ziyHund5kWrpn37tI 5PYASB7eC51eGmTRyZIrWKOCttcd22AE31pMSu4BHyQORQ1O0sAWVZJODD18Vc6PiX3H /T0NtpMcYKArTViR//0OBURDVshcGCx1lWbqSMJ+DK/kVBakNigvjOl24JOgG43WXdcl ZvW0qWWmpckMDImG2XenpJ6BlurWY4BOq9scq0TCcxUSfZ0YPVOi1ycr4K/ynGPhgJ49 iipA== 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=qwWqFK68UPptgqSIXoptkzViwsruINWpsr9nlTvGRnk=; b=fmT9aycoWRJLO7dtAVDFgxv5Ut1ou/MRk+IvduYBsUinhSo24OB0iOpTuRvLvwTG3m fAnMWksDTjInWgk7VHFDdpJEwqZyjEHkfaIhg+DT0di5qF1CMpLoyg6hC7hlXF/AIobX Y3ZNoaaVQqx5W+FsxLC7SPuaHILqMXwSexqvML4BLvoy6Vad107JlRdsWll/RqogB3ew 5X1MRAw8nZPM7X8AQLJQhOfH+FZQN3llerZ9uQXOw3moHAvfiYo2z2hPNaicDsbapmit fcCwfZBjGdQFpB3V7EqgYtoGQImoH79JQGUr223+sHKBiiL0whxI63in/ydf0jv25/6z EaDQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bm18-20020a656e92000000b004fba0f483c8si22037796pgb.185.2023.04.28.03.06.21; Fri, 28 Apr 2023 03:06:34 -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 S1345885AbjD1J6s (ORCPT + 99 others); Fri, 28 Apr 2023 05:58:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346021AbjD1J63 (ORCPT ); Fri, 28 Apr 2023 05:58:29 -0400 Received: from out187-24.us.a.mail.aliyun.com (out187-24.us.a.mail.aliyun.com [47.90.187.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D52C6EAC for ; Fri, 28 Apr 2023 02:57:46 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018047206;MF=houwenlong.hwl@antgroup.com;NM=1;PH=DS;RN=14;SR=0;TI=SMTPD_---.STFoGhB_1682675630; Received: from localhost(mailfrom:houwenlong.hwl@antgroup.com fp:SMTPD_---.STFoGhB_1682675630) by smtp.aliyun-inc.com; Fri, 28 Apr 2023 17:53:50 +0800 From: "Hou Wenlong" To: linux-kernel@vger.kernel.org Cc: "Thomas Garnier" , "Lai Jiangshan" , "Kees Cook" , "Hou Wenlong" , "Juergen Gross" , "Boris Ostrovsky" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , , "H. Peter Anvin" , Subject: [PATCH RFC 37/43] x86/xen: Pin up to VSYSCALL_ADDR when vsyscall page is out of fixmap area Date: Fri, 28 Apr 2023 17:51:17 +0800 Message-Id: <13975abd9b8b2e2e1e2efd3be6c341542b08af24.1682673543.git.houwenlong.hwl@antgroup.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 If vsyscall page is moved out of fixmap area, then FIXADDR_TOP would be below vsyscall page. So it should pin up to VSYSCALL_ADDR if vsyscall is enabled. Suggested-by: Lai Jiangshan Signed-off-by: Hou Wenlong Cc: Thomas Garnier Cc: Kees Cook --- 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 a59bc013ee5b..28392f3478a0 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, -- 2.31.1