From nobody Thu Feb 12 04:51:36 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D49DCC77B61 for ; Fri, 28 Apr 2023 09:55:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345908AbjD1Jzr (ORCPT ); Fri, 28 Apr 2023 05:55:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345882AbjD1JzS (ORCPT ); Fri, 28 Apr 2023 05:55:18 -0400 Received: from out0-212.mail.aliyun.com (out0-212.mail.aliyun.com [140.205.0.212]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93F86559A for ; Fri, 28 Apr 2023 02:54:58 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R501e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018047207;MF=houwenlong.hwl@antgroup.com;NM=1;PH=DS;RN=21;SR=0;TI=SMTPD_---.STFoGiO_1682675636; Received: from localhost(mailfrom:houwenlong.hwl@antgroup.com fp:SMTPD_---.STFoGiO_1682675636) by smtp.aliyun-inc.com; Fri, 28 Apr 2023 17:53:57 +0800 From: "Hou Wenlong" To: linux-kernel@vger.kernel.org Cc: "Thomas Garnier" , "Lai Jiangshan" , "Kees Cook" , "Hou Wenlong" , "Andy Lutomirski" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , , "H. Peter Anvin" , "Peter Zijlstra" , "Andrew Morton" , "=?UTF-8?B?TWlrZSBSYXBvcG9ydCAoSUJNKQ==?=" , "Liam R. Howlett" , "Suren Baghdasaryan" , "Kirill A. Shutemov" , "David Woodhouse" , "Brian Gerst" , "Josh Poimboeuf" Subject: [PATCH RFC 38/43] x86/fixmap: Move vsyscall page out of fixmap area Date: Fri, 28 Apr 2023 17:51:18 +0800 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" After mapping vsyscall page individually, vsyscall page could be moved out of fixmap area. Suggested-by: Lai Jiangshan Signed-off-by: Hou Wenlong Cc: Thomas Garnier Cc: Kees Cook --- arch/x86/entry/vsyscall/vsyscall_64.c | 4 ---- arch/x86/include/asm/fixmap.h | 17 +++++------------ arch/x86/kernel/head_64.S | 6 +++--- arch/x86/mm/fault.c | 1 - arch/x86/mm/init_64.c | 2 +- 5 files changed, 9 insertions(+), 21 deletions(-) diff --git a/arch/x86/entry/vsyscall/vsyscall_64.c b/arch/x86/entry/vsyscal= l/vsyscall_64.c index 4373460ebbde..f469f8dc36d4 100644 --- a/arch/x86/entry/vsyscall/vsyscall_64.c +++ b/arch/x86/entry/vsyscall/vsyscall_64.c @@ -35,7 +35,6 @@ =20 #include #include -#include #include #include =20 @@ -391,7 +390,4 @@ void __init map_vsyscall(void) =20 if (vsyscall_mode =3D=3D XONLY) vm_flags_init(&gate_vma, VM_EXEC); - - BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_PAGE) !=3D - (unsigned long)VSYSCALL_ADDR); } diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h index d0dcefb5cc59..eeb152ad9682 100644 --- a/arch/x86/include/asm/fixmap.h +++ b/arch/x86/include/asm/fixmap.h @@ -23,13 +23,13 @@ * covered fully. */ #ifndef CONFIG_DEBUG_KMAP_LOCAL_FORCE_MAP -# define FIXMAP_PMD_NUM 2 +# define FIXMAP_PMD_NUM 1 #else # define KM_PMDS (KM_MAX_IDX * ((CONFIG_NR_CPUS + 511) / 512)) -# define FIXMAP_PMD_NUM (KM_PMDS + 2) +# define FIXMAP_PMD_NUM (KM_PMDS + 1) #endif -/* fixmap starts downwards from the 507th entry in level2_fixmap_pgt */ -#define FIXMAP_PMD_TOP 507 +/* fixmap starts downwards from the 506th entry in level2_fixmap_pgt */ +#define FIXMAP_PMD_TOP 506 =20 #ifndef __ASSEMBLY__ #include @@ -38,8 +38,6 @@ #include #ifdef CONFIG_X86_32 #include -#else -#include #endif =20 /* @@ -55,8 +53,7 @@ extern unsigned long __FIXADDR_TOP; #define FIXADDR_TOP ((unsigned long)__FIXADDR_TOP) #else -#define FIXADDR_TOP (round_up(VSYSCALL_ADDR + PAGE_SIZE, 1<> PAGE_SHIFT, -#endif #endif FIX_DBGP_BASE, FIX_EARLYCON_MEM_BASE, diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S index 94c5defec8cc..19cb2852238b 100644 --- a/arch/x86/kernel/head_64.S +++ b/arch/x86/kernel/head_64.S @@ -659,15 +659,15 @@ SYM_DATA_START_PAGE_ALIGNED(level2_kernel_pgt) SYM_DATA_END(level2_kernel_pgt) =20 SYM_DATA_START_PAGE_ALIGNED(level2_fixmap_pgt) - .fill (512 - 4 - FIXMAP_PMD_NUM),8,0 + .fill (512 - 5 - FIXMAP_PMD_NUM),8,0 pgtno =3D 0 .rept (FIXMAP_PMD_NUM) .quad level1_fixmap_pgt + (pgtno << PAGE_SHIFT) - __START_KERNEL_map \ + _PAGE_TABLE_NOENC; pgtno =3D pgtno + 1 .endr - /* 6 MB reserved space + a 2MB hole */ - .fill 4,8,0 + /* 2MB (with 4KB vsyscall page inside) + 6 MB reserved space + a 2MB hole= */ + .fill 5,8,0 SYM_DATA_END(level2_fixmap_pgt) =20 SYM_DATA_START_PAGE_ALIGNED(level1_fixmap_pgt) diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 7beb0ba6b2ec..548c0803d9f4 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -22,7 +22,6 @@ =20 #include /* boot_cpu_has, ... */ #include /* dotraplinkage, ... */ -#include /* VSYSCALL_ADDR */ #include /* emulate_vsyscall */ #include /* struct vm86 */ #include /* vma_pkey() */ diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index a190aae8ceaf..b7fd05a1ba1d 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include #include --=20 2.31.1