git: 380736a95d3d - stable/13 - amd64 pmap: Pre-set PG_M on 2MB KASAN shadow map entries

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Wed, 03 Nov 2021 13:15:29 UTC
The branch stable/13 has been updated by markj:

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

commit 380736a95d3d6d5bec929936b08a0d998a660e39
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2021-08-10 20:23:42 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2021-11-02 22:17:58 +0000

    amd64 pmap: Pre-set PG_M on 2MB KASAN shadow map entries
    
    Also remove a redundant assertion in pmap_kasan_enter().
    
    Reviewed by:    alc, kib
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit 4fd450a87df015fe85cadfac0e22c73e3c878d24)
---
 sys/amd64/amd64/pmap.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
index 62bc1bb22e96..a1f3a5cdc650 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -11340,7 +11340,7 @@ pmap_kasan_enter(vm_offset_t va)
 		m = pmap_kasan_enter_alloc_2m();
 		if (m != NULL) {
 			*pde = (pd_entry_t)(VM_PAGE_TO_PHYS(m) | X86_PG_RW |
-			    X86_PG_PS | X86_PG_V | pg_nx);
+			    X86_PG_PS | X86_PG_V | X86_PG_A | X86_PG_M | pg_nx);
 		} else {
 			m = pmap_kasan_enter_alloc_4k();
 			*pde = (pd_entry_t)(VM_PAGE_TO_PHYS(m) | X86_PG_RW |
@@ -11352,8 +11352,6 @@ pmap_kasan_enter(vm_offset_t va)
 	pte = pmap_pde_to_pte(pde, va);
 	if ((*pte & X86_PG_V) != 0)
 		return;
-	KASSERT((*pte & X86_PG_V) == 0,
-	    ("%s: shadow address %#lx is already mapped", __func__, va));
 	m = pmap_kasan_enter_alloc_4k();
 	*pte = (pt_entry_t)(VM_PAGE_TO_PHYS(m) | X86_PG_RW | X86_PG_V |
 	    X86_PG_M | X86_PG_A | pg_nx);