From nobody Sun Feb 8 21:27:30 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=quarantine dis=quarantine) header.from=antgroup.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 168413885322162.96665129376322; Mon, 15 May 2023 01:20:53 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.534602.831756 (Exim 4.92) (envelope-from ) id 1pyTRV-0000rc-IH; Mon, 15 May 2023 08:20:29 +0000 Received: by outflank-mailman (output) from mailman id 534602.831756; Mon, 15 May 2023 08:20:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pyTRV-0000rV-DT; Mon, 15 May 2023 08:20:29 +0000 Received: by outflank-mailman (input) for mailman id 534602; Mon, 15 May 2023 08:20:28 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pyTRU-0000r2-BN for xen-devel@lists.xenproject.org; Mon, 15 May 2023 08:20:28 +0000 Received: from out0-203.mail.aliyun.com (out0-203.mail.aliyun.com [140.205.0.203]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 55f924de-f2f9-11ed-8611-37d641c3527e; Mon, 15 May 2023 10:20:23 +0200 (CEST) Received: from localhost(mailfrom:houwenlong.hwl@antgroup.com fp:SMTPD_---.T2DpdRe_1684138815) by smtp.aliyun-inc.com; Mon, 15 May 2023 16:20:16 +0800 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 55f924de-f2f9-11ed-8611-37d641c3527e X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018047187;MF=houwenlong.hwl@antgroup.com;NM=1;PH=DS;RN=21;SR=0;TI=SMTPD_---.T2DpdRe_1684138815; From: "Hou Wenlong" To: linux-kernel@vger.kernel.org Cc: "Lai Jiangshan" , "Hou Wenlong" , "Andy Lutomirski" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , , "H. Peter Anvin" , "Juergen Gross" , "=?UTF-8?B?U3JpdmF0c2EgUy4gQmhhdCAoVk13YXJlKQ==?=" , "Alexey Makhalov" , "VMware PV-Drivers Reviewers" , "Boris Ostrovsky" , "Suren Baghdasaryan" , "Andrew Morton" , "=?UTF-8?B?TWlrZSBSYXBvcG9ydCAoSUJNKQ==?=" , "Kirill A. Shutemov" , , Subject: [PATCH RFC 1/4] x86/vsyscall: Don't use set_fixmap() to map vsyscall page Date: Mon, 15 May 2023 16:19:32 +0800 Message-Id: <7453c8b3b3b273e45c2541d09b950ffc4a97189d.1684137557.git.houwenlong.hwl@antgroup.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1684138854403100002 Content-Type: text/plain; charset="utf-8" In order to unify FIXADDR_TOP for x86 and allow the fixmap area to be movable, the vsyscall page should be mapped individually. However, for XENPV guests, the vsyscall page needs to be mapped into the user pagetable as well. Therefore, a new PVMMU operation is introduced to assist in mapping the vsyscall page. Suggested-by: Lai Jiangshan Signed-off-by: Hou Wenlong --- arch/x86/entry/vsyscall/vsyscall_64.c | 3 +-- arch/x86/include/asm/paravirt.h | 7 +++++++ arch/x86/include/asm/paravirt_types.h | 4 ++++ arch/x86/include/asm/vsyscall.h | 13 +++++++++++++ arch/x86/kernel/paravirt.c | 4 ++++ arch/x86/xen/mmu_pv.c | 20 ++++++++++++++------ 6 files changed, 43 insertions(+), 8 deletions(-) diff --git a/arch/x86/entry/vsyscall/vsyscall_64.c b/arch/x86/entry/vsyscal= l/vsyscall_64.c index e0ca8120aea8..4373460ebbde 100644 --- a/arch/x86/entry/vsyscall/vsyscall_64.c +++ b/arch/x86/entry/vsyscall/vsyscall_64.c @@ -385,8 +385,7 @@ void __init map_vsyscall(void) * page. */ if (vsyscall_mode =3D=3D EMULATE) { - __set_fixmap(VSYSCALL_PAGE, physaddr_vsyscall, - PAGE_KERNEL_VVAR); + __set_vsyscall_page(physaddr_vsyscall, PAGE_KERNEL_VVAR); set_vsyscall_pgtable_user_bits(swapper_pg_dir); } =20 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravir= t.h index b49778664d2b..c9543d383df0 100644 --- a/arch/x86/include/asm/paravirt.h +++ b/arch/x86/include/asm/paravirt.h @@ -576,6 +576,13 @@ static inline void __set_fixmap(unsigned /* enum fixed= _addresses */ idx, { pv_ops.mmu.set_fixmap(idx, phys, flags); } + +#ifdef CONFIG_X86_VSYSCALL_EMULATION +static inline void __set_vsyscall_page(phys_addr_t phys, pgprot_t flags) +{ + pv_ops.mmu.set_vsyscall_page(phys, flags); +} +#endif #endif =20 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS) diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/p= aravirt_types.h index 4acbcddddc29..2dc9397e064d 100644 --- a/arch/x86/include/asm/paravirt_types.h +++ b/arch/x86/include/asm/paravirt_types.h @@ -224,6 +224,10 @@ struct pv_mmu_ops { an mfn. We can tell which is which from the index. */ void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx, phys_addr_t phys, pgprot_t flags); + +#ifdef CONFIG_X86_VSYSCALL_EMULATION + void (*set_vsyscall_page)(phys_addr_t phys, pgprot_t flags); +#endif #endif } __no_randomize_layout; =20 diff --git a/arch/x86/include/asm/vsyscall.h b/arch/x86/include/asm/vsyscal= l.h index ab60a71a8dcb..73691fc60924 100644 --- a/arch/x86/include/asm/vsyscall.h +++ b/arch/x86/include/asm/vsyscall.h @@ -2,6 +2,7 @@ #ifndef _ASM_X86_VSYSCALL_H #define _ASM_X86_VSYSCALL_H =20 +#include #include #include =20 @@ -15,6 +16,18 @@ extern void set_vsyscall_pgtable_user_bits(pgd_t *root); */ extern bool emulate_vsyscall(unsigned long error_code, struct pt_regs *regs, unsigned long address); +static inline void native_set_vsyscall_page(phys_addr_t phys, pgprot_t fla= gs) +{ + pgprot_val(flags) &=3D __default_kernel_pte_mask; + set_pte_vaddr(VSYSCALL_ADDR, pfn_pte(phys >> PAGE_SHIFT, flags)); +} + +#ifndef CONFIG_PARAVIRT_XXL +#define __set_vsyscall_page native_set_vsyscall_page +#else +#include +#endif + #else static inline void map_vsyscall(void) {} static inline bool emulate_vsyscall(unsigned long error_code, diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c index ac10b46c5832..13c81402f377 100644 --- a/arch/x86/kernel/paravirt.c +++ b/arch/x86/kernel/paravirt.c @@ -33,6 +33,7 @@ #include #include #include +#include =20 /* * nop stub, which must not clobber anything *including the stack* to @@ -357,6 +358,9 @@ struct paravirt_patch_template pv_ops =3D { }, =20 .mmu.set_fixmap =3D native_set_fixmap, +#ifdef CONFIG_X86_VSYSCALL_EMULATION + .mmu.set_vsyscall_page =3D native_set_vsyscall_page, +#endif #endif /* CONFIG_PARAVIRT_XXL */ =20 #if defined(CONFIG_PARAVIRT_SPINLOCKS) diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c index b3b8d289b9ab..c42c60faa3bb 100644 --- a/arch/x86/xen/mmu_pv.c +++ b/arch/x86/xen/mmu_pv.c @@ -59,6 +59,7 @@ =20 #include #include +#include #include #include #include @@ -2020,9 +2021,6 @@ static void xen_set_fixmap(unsigned idx, phys_addr_t = phys, pgprot_t prot) =20 switch (idx) { case FIX_BTMAP_END ... FIX_BTMAP_BEGIN: -#ifdef CONFIG_X86_VSYSCALL_EMULATION - case VSYSCALL_PAGE: -#endif /* All local page mappings */ pte =3D pfn_pte(phys, prot); break; @@ -2058,14 +2056,21 @@ static void xen_set_fixmap(unsigned idx, phys_addr_= t phys, pgprot_t prot) vaddr =3D __fix_to_virt(idx); if (HYPERVISOR_update_va_mapping(vaddr, pte, UVMF_INVLPG)) BUG(); +} =20 #ifdef CONFIG_X86_VSYSCALL_EMULATION +static void xen_set_vsyscall_page(phys_addr_t phys, pgprot_t prot) +{ + pte_t pte =3D pfn_pte(phys >> PAGE_SHIFT, prot); + + if (HYPERVISOR_update_va_mapping(VSYSCALL_ADDR, pte, UVMF_INVLPG)) + BUG(); + /* Replicate changes to map the vsyscall page into the user pagetable vsyscall mapping. */ - if (idx =3D=3D VSYSCALL_PAGE) - set_pte_vaddr_pud(level3_user_vsyscall, vaddr, pte); -#endif + set_pte_vaddr_pud(level3_user_vsyscall, VSYSCALL_ADDR, pte); } +#endif =20 static void __init xen_post_allocator_init(void) { @@ -2156,6 +2161,9 @@ static const typeof(pv_ops) xen_mmu_ops __initconst = =3D { }, =20 .set_fixmap =3D xen_set_fixmap, +#ifdef CONFIG_X86_VSYSCALL_EMULATION + .set_vsyscall_page =3D xen_set_vsyscall_page, +#endif }, }; =20 --=20 2.31.1 From nobody Sun Feb 8 21:27:30 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=quarantine dis=quarantine) header.from=antgroup.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1684138853337396.478254193629; Mon, 15 May 2023 01:20:53 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.534603.831765 (Exim 4.92) (envelope-from ) id 1pyTRX-00018L-P9; Mon, 15 May 2023 08:20:31 +0000 Received: by outflank-mailman (output) from mailman id 534603.831765; Mon, 15 May 2023 08:20:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pyTRX-00018C-LU; Mon, 15 May 2023 08:20:31 +0000 Received: by outflank-mailman (input) for mailman id 534603; Mon, 15 May 2023 08:20:30 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pyTRW-0000Zb-O6 for xen-devel@lists.xenproject.org; Mon, 15 May 2023 08:20:30 +0000 Received: from out0-207.mail.aliyun.com (out0-207.mail.aliyun.com [140.205.0.207]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 591fb455-f2f9-11ed-b229-6b7b168915f2; Mon, 15 May 2023 10:20:29 +0200 (CEST) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 591fb455-f2f9-11ed-b229-6b7b168915f2 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; 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 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1684138854374100001 Content-Type: text/plain; charset="utf-8" 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); } =20 +#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 *p= 4d, * 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, =20 /* The limit is the last byte to be touched */ limit--; - BUG_ON(limit >=3D FIXADDR_TOP); + BUG_ON(limit >=3D __KERNEL_MAP_TOP); =20 /* * 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); } =20 static void xen_unpin_page(struct mm_struct *mm, struct page *page, --=20 2.31.1 From nobody Sun Feb 8 21:27:30 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 59CC5C7EE22 for ; Mon, 15 May 2023 08:24:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235813AbjEOIYU (ORCPT ); Mon, 15 May 2023 04:24:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232048AbjEOIWL (ORCPT ); Mon, 15 May 2023 04:22:11 -0400 Received: from out0-194.mail.aliyun.com (out0-194.mail.aliyun.com [140.205.0.194]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAAD410DF for ; Mon, 15 May 2023 01:20:32 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R891e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018047204;MF=houwenlong.hwl@antgroup.com;NM=1;PH=DS;RN=19;SR=0;TI=SMTPD_---.T2GMf1Y_1684138824; Received: from localhost(mailfrom:houwenlong.hwl@antgroup.com fp:SMTPD_---.T2GMf1Y_1684138824) by smtp.aliyun-inc.com; Mon, 15 May 2023 16:20:25 +0800 From: "Hou Wenlong" To: linux-kernel@vger.kernel.org Cc: "Lai Jiangshan" , "Hou Wenlong" , "Andy Lutomirski" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , , "H. Peter Anvin" , "Peter Zijlstra" , "Suren Baghdasaryan" , "Andrew Morton" , "=?UTF-8?B?TWlrZSBSYXBvcG9ydCAoSUJNKQ==?=" , "Kirill A. Shutemov" , "David Woodhouse" , "Usama Arif" , "Josh Poimboeuf" , "Brian Gerst" Subject: [PATCH RFC 3/4] x86/fixmap: Move vsyscall page out of fixmap area Date: Mon, 15 May 2023 16:19:34 +0800 Message-Id: <1d982a2883cd807668fad9575ea1c285ae7c272b.1684137557.git.houwenlong.hwl@antgroup.com> 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, the vsyscall page could be moved out of fixmap area. Suggested-by: Lai Jiangshan Signed-off-by: Hou Wenlong --- 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 a5df3e994f04..8a0714bc52db 100644 --- a/arch/x86/kernel/head_64.S +++ b/arch/x86/kernel/head_64.S @@ -639,15 +639,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 e4399983c50c..988478e7ef1f 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -23,7 +23,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 From nobody Sun Feb 8 21:27:30 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 B4AC1C77B7D for ; Mon, 15 May 2023 08:24:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237371AbjEOIYW (ORCPT ); Mon, 15 May 2023 04:24:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229820AbjEOIWP (ORCPT ); Mon, 15 May 2023 04:22:15 -0400 Received: from out0-217.mail.aliyun.com (out0-217.mail.aliyun.com [140.205.0.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E005A10E7 for ; Mon, 15 May 2023 01:20:39 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018047192;MF=houwenlong.hwl@antgroup.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---.T2DpdaM_1684138832; Received: from localhost(mailfrom:houwenlong.hwl@antgroup.com fp:SMTPD_---.T2DpdaM_1684138832) by smtp.aliyun-inc.com; Mon, 15 May 2023 16:20:33 +0800 From: "Hou Wenlong" To: linux-kernel@vger.kernel.org Cc: "Lai Jiangshan" , "Hou Wenlong" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , , "H. Peter Anvin" , "Andy Lutomirski" , "Peter Zijlstra" , "Juergen Gross" , "Anshuman Khandual" , "Mike Rapoport" , "Josh Poimboeuf" , "Pasha Tatashin" Subject: [PATCH RFC 4/4] x86/fixmap: Unify FIXADDR_TOP Date: Mon, 15 May 2023 16:19:35 +0800 Message-Id: <681844dc69a3b746e92a685b706595bff7613481.1684137557.git.houwenlong.hwl@antgroup.com> 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" Since FIXADDR_TOP is unrelated to the vsyscall page now, it can be declared as a variable for x86_64, thereby unifying it for x86. Suggested-by: Lai Jiangshan Signed-off-by: Hou Wenlong --- arch/x86/include/asm/fixmap.h | 13 ------------- arch/x86/kernel/head64.c | 1 - arch/x86/mm/dump_pagetables.c | 3 ++- arch/x86/mm/ioremap.c | 5 ++--- arch/x86/mm/pgtable.c | 13 +++++++++++++ arch/x86/mm/pgtable_32.c | 3 --- 6 files changed, 17 insertions(+), 21 deletions(-) diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h index eeb152ad9682..9433109e4853 100644 --- a/arch/x86/include/asm/fixmap.h +++ b/arch/x86/include/asm/fixmap.h @@ -40,21 +40,8 @@ #include #endif =20 -/* - * We can't declare FIXADDR_TOP as variable for x86_64 because vsyscall - * uses fixmaps that relies on FIXADDR_TOP for proper address calculation. - * Because of this, FIXADDR_TOP x86 integration was left as later work. - */ -#ifdef CONFIG_X86_32 -/* - * Leave one empty page between vmalloc'ed areas and - * the start of the fixmap. - */ extern unsigned long __FIXADDR_TOP; #define FIXADDR_TOP ((unsigned long)__FIXADDR_TOP) -#else -#define FIXADDR_TOP (0xffffffffff600000UL - PAGE_SIZE) -#endif =20 /* * Here we define all the compile-time 'special' virtual diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c index 49f7629b17f7..34fc86e81872 100644 --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel/head64.c @@ -485,7 +485,6 @@ asmlinkage __visible void __init __noreturn x86_64_star= t_kernel(char * real_mode BUILD_BUG_ON(!(MODULES_VADDR > __START_KERNEL)); MAYBE_BUILD_BUG_ON(!(((MODULES_END - 1) & PGDIR_MASK) =3D=3D (__START_KERNEL & PGDIR_MASK))); - BUILD_BUG_ON(__fix_to_virt(__end_of_fixed_addresses) <=3D MODULES_END); =20 cr4_init_shadow(); =20 diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c index e1b599ecbbc2..df1a708a038a 100644 --- a/arch/x86/mm/dump_pagetables.c +++ b/arch/x86/mm/dump_pagetables.c @@ -104,7 +104,7 @@ static struct addr_marker address_markers[] =3D { [HIGH_KERNEL_NR] =3D { __START_KERNEL_map, "High Kernel Mapping" }, [MODULES_VADDR_NR] =3D { MODULES_VADDR, "Modules" }, [MODULES_END_NR] =3D { MODULES_END, "End Modules" }, - [FIXADDR_START_NR] =3D { FIXADDR_START, "Fixmap Area" }, + [FIXADDR_START_NR] =3D { 0UL, "Fixmap Area" }, [END_OF_SPACE_NR] =3D { -1, NULL } }; =20 @@ -453,6 +453,7 @@ static int __init pt_dump_init(void) address_markers[KASAN_SHADOW_START_NR].start_address =3D KASAN_SHADOW_STA= RT; address_markers[KASAN_SHADOW_END_NR].start_address =3D KASAN_SHADOW_END; #endif + address_markers[FIXADDR_START_NR].start_address =3D FIXADDR_START; #endif #ifdef CONFIG_X86_32 address_markers[VMALLOC_START_NR].start_address =3D VMALLOC_START; diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c index aa7d279321ea..44f9c6781c15 100644 --- a/arch/x86/mm/ioremap.c +++ b/arch/x86/mm/ioremap.c @@ -879,10 +879,9 @@ void __init early_ioremap_init(void) pmd_t *pmd; =20 #ifdef CONFIG_X86_64 - BUILD_BUG_ON((fix_to_virt(0) + PAGE_SIZE) & ((1 << PMD_SHIFT) - 1)); -#else - WARN_ON((fix_to_virt(0) + PAGE_SIZE) & ((1 << PMD_SHIFT) - 1)); + BUG_ON(__fix_to_virt(__end_of_fixed_addresses) <=3D MODULES_END); #endif + WARN_ON((fix_to_virt(0) + PAGE_SIZE) & ((1 << PMD_SHIFT) - 1)); =20 early_ioremap_setup(); =20 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c index e4f499eb0f29..2d73db9c7cbc 100644 --- a/arch/x86/mm/pgtable.c +++ b/arch/x86/mm/pgtable.c @@ -627,6 +627,19 @@ pmd_t pmdp_invalidate_ad(struct vm_area_struct *vma, u= nsigned long address, } #endif =20 +#ifdef CONFIG_X86_32 +/* + * Leave one empty page between vmalloc'ed areas and + * the start of the fixmap. + */ +#define __FIXADDR_TOP_BASE 0xfffff000 +#else +#define __FIXADDR_TOP_BASE (0xffffffffff600000UL - PAGE_SIZE) +#endif + +unsigned long __FIXADDR_TOP =3D __FIXADDR_TOP_BASE; +EXPORT_SYMBOL(__FIXADDR_TOP); + /** * reserve_top_address - reserves a hole in the top of kernel address space * @reserve - size of hole to reserve diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c index c234634e26ba..2b9a00976fee 100644 --- a/arch/x86/mm/pgtable_32.c +++ b/arch/x86/mm/pgtable_32.c @@ -65,9 +65,6 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval) flush_tlb_one_kernel(vaddr); } =20 -unsigned long __FIXADDR_TOP =3D 0xfffff000; -EXPORT_SYMBOL(__FIXADDR_TOP); - /* * vmalloc=3Dsize forces the vmalloc area to be exactly 'size' * bytes. This can be used to increase (or decrease) the --=20 2.31.1