git: c8a523690b1a - main - i386: Avoid calling kmem_alloc_contig(M_NEVERFREED)

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Tue, 15 Jul 2025 12:53:06 UTC
The branch main has been updated by markj:

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

commit c8a523690b1a904344662c5834b713e5fc9e9aad
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-07-15 00:19:51 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-07-15 12:52:14 +0000

    i386: Avoid calling kmem_alloc_contig(M_NEVERFREED)
    
    vm_page_alloc_contig* don't handle VM_ALLOC_NOFREE.  After commit
    07297aee35f2 ("vm_page: update comments and KASSERT()s concerning page allocation"),
    pmap_pdpt_allocf() triggers one of the added assertions, since pdptzone
    is a NOFREE zone.
    
    Simply clear the flag when allocating a slab.  It is not worth trying to
    implement support for the NOFREE allocator here.
    
    Reported by:    Jenkins
    Reviewed by:    alc, kib
    Differential Revision:  https://reviews.freebsd.org/D51311
---
 sys/i386/i386/pmap.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c
index 5065b7e61ee8..b44f5e08bbcf 100644
--- a/sys/i386/i386/pmap.c
+++ b/sys/i386/i386/pmap.c
@@ -876,14 +876,16 @@ __CONCAT(PMTYPE, init_pat)(void)
 
 #ifdef PMAP_PAE_COMP
 static void *
-pmap_pdpt_allocf(uma_zone_t zone, vm_size_t bytes, int domain, uint8_t *flags,
-    int wait)
+pmap_pdpt_allocf(uma_zone_t zone, vm_size_t bytes, int domain, uint8_t *sflagsp,
+    int flags)
 {
 
 	/* Inform UMA that this allocator uses kernel_map/object. */
-	*flags = UMA_SLAB_KERNEL;
+	*sflagsp = UMA_SLAB_KERNEL;
+	/* contig allocations cannot be NEVERFREED */
+	flags &= ~M_NEVERFREED;
 	return ((void *)kmem_alloc_contig_domainset(DOMAINSET_FIXED(domain),
-	    bytes, wait, 0x0ULL, 0xffffffffULL, 1, 0, VM_MEMATTR_DEFAULT));
+	    bytes, flags, 0x0ULL, 0xffffffffULL, 1, 0, VM_MEMATTR_DEFAULT));
 }
 #endif