git: 4533fa42ad91 - stable/14 - amd64: Zero-fill AP PCPU pages

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Fri, 20 Oct 2023 16:02:30 UTC
The branch stable/14 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=4533fa42ad912537a15d72068f2cfca46a465521

commit 4533fa42ad912537a15d72068f2cfca46a465521
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-10-16 22:40:21 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-10-20 16:02:05 +0000

    amd64: Zero-fill AP PCPU pages
    
    At least KMSAN relies on zero-initialization of AP PCPU regions, see
    commit 4b136ef259ce.
    
    Prior to commit af1c6d3f3013 these were allocated with allocpages() in
    the amd64 pmap, which always returns zero-initialized memory.
    
    Reviewed by:    kib
    Fixes:          af1c6d3f3013 ("amd64: do not leak pcpu pages")
    MFC after:      3 days
    Sponsored by:   Klara, Inc.
    Sponsored by:   Juniper Networks, Inc.
    Differential Revision:  https://reviews.freebsd.org/D42241
    
    (cherry picked from commit a37e484d049758c70f2d61be0d28a115b6f2f01e)
---
 sys/amd64/amd64/mp_machdep.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c
index ec4501c3aeed..d506ffada4b9 100644
--- a/sys/amd64/amd64/mp_machdep.c
+++ b/sys/amd64/amd64/mp_machdep.c
@@ -300,11 +300,12 @@ amd64_mp_alloc_pcpu(void)
 		m = NULL;
 		if (vm_ndomains > 1) {
 			m = vm_page_alloc_noobj_domain(
-			    acpi_pxm_get_cpu_locality(cpu_apic_ids[cpu]), 0);
+			    acpi_pxm_get_cpu_locality(cpu_apic_ids[cpu]),
+			    VM_ALLOC_ZERO);
 		}
 		if (m == NULL)
 #endif
-			m = vm_page_alloc_noobj(0);
+			m = vm_page_alloc_noobj(VM_ALLOC_ZERO);
 		if (m == NULL)
 			panic("cannot alloc pcpu page for cpu %d", cpu);
 		pmap_qenter((vm_offset_t)&__pcpu[cpu], &m, 1);