git: 36f7e87007da - main - amd64: Mark the BSP as a small core

From: R. Christian McDonald <rcm_at_FreeBSD.org>
Date: Mon, 23 Nov 2026 14:26:22 UTC
The branch main has been updated by rcm:

URL: https://cgit.FreeBSD.org/src/commit/?id=36f7e87007da16b8f45b65b923b854eef50d9894

commit 36f7e87007da16b8f45b65b923b854eef50d9894
Author:     R. Christian McDonald <rcm@FreeBSD.org>
AuthorDate: 2026-11-23 14:22:59 +0000
Commit:     R. Christian McDonald <rcm@FreeBSD.org>
CommitDate: 2026-11-23 14:22:59 +0000

    amd64: Mark the BSP as a small core
    
    cpu_init_small_core() records in the pcpu area that a CPU is an Intel
    small (Atom) core, and that it needs the workaround for INVLPG not
    flushing global TLB entries when PCID is enabled.  hammer_time() calls
    it for the BSP before the BSP has a pcpu area: the temporary one is
    zeroed and installed only later, and pmap_bootstrap() then replaces it
    with the final one, zeroed again.  The BSP therefore never has
    pc_small_core or pc_pcid_invlpg_workaround set, while the APs, which
    call it from initializecpu(), do.
    
    On a hybrid machine the BSP is normally a large core and nothing is
    missing.  On a machine with small cores only, such as an Atom C1110 or
    x7809C, the BSP is one of them, and its invalidations of kernel
    mappings in pmap_invlpg(), pmap_invalidate_range() and the shootdown
    handler go without the workaround.
    
    Do it in amd64_bsp_pcpu_init1() instead, which runs for both of the
    BSP's pcpu areas once %gs points at them.  The PCID features and
    tunables it depends on are still evaluated first.
    
    Reviewed by:            kib, markj
    Fixes:                  a2c08eba43a2 ("amd64: be more precise when...")
    MFC after:              1 week
    Sponsored by:           Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D61804
---
 sys/amd64/amd64/machdep.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c
index 04204fa74c11..a9d4144ace48 100644
--- a/sys/amd64/amd64/machdep.c
+++ b/sys/amd64/amd64/machdep.c
@@ -1247,6 +1247,7 @@ amd64_bsp_pcpu_init1(struct pcpu *pc)
 	PCPU_SET(gs32p, &gdt[GUGS32_SEL]);
 	PCPU_SET(ucr3_load_mask, PMAP_UCR3_NOMASK);
 	PCPU_SET(smp_tlb_gen, 1);
+	cpu_init_small_core();
 }
 
 void
@@ -1399,13 +1400,8 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
 		pmap_pcid_enabled = 0;
 	invpcid_works = (cpu_stdext_feature & CPUID_STDEXT_INVPCID) != 0;
 
-	/*
-	 * Now we can do small core initialization, after the PCID
-	 * CPU features and user knobs are evaluated.
-	 */
 	TUNABLE_INT_FETCH("vm.pmap.pcid_invlpg_workaround",
 	    &pmap_pcid_invlpg_workaround_uena);
-	cpu_init_small_core();
 
 	if ((cpu_feature2 & CPUID2_XSAVE) != 0) {
 		use_xsave = 1;