Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 26 Apr 2026 08:03:36 +0000
From:      Michael Tuexen <tuexen@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Cc:        Timo =?utf-8?Q?V=C3=B6lker?= <timo.voelker@fh-muenster.de>
Subject:   git: 09bcf5a57a13 - stable/15 - arm64/pmap: fix pmap_is_valid_memattr()
Message-ID:  <69edc6d8.26dbe.41a93a9e@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/15 has been updated by tuexen:

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

commit 09bcf5a57a138313e8330483b3e9335f9fdd5308
Author:     Timo Völker <timo.voelker@fh-muenster.de>
AuthorDate: 2026-03-02 17:59:45 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2026-04-26 07:58:59 +0000

    arm64/pmap: fix pmap_is_valid_memattr()
    
    The function pmap_is_valid_memattr(pmap, mode) checks whether the
    given variable mode is between the two constant values
    VM_MEMATTR_DEVICE and VM_MEMATTR_WRITE_THROUGH.
    After the code for this function was written, the value of
    VM_MEMATTR_DEVICE changed from 0 to 4. Since VM_MEMATTR_WRITE_THROUGH
    is still 3, the condition is always false.
    This patch changes the condition to check whether mode is equal to any
    of the VM_MEMATTR* constants.
    
    Reviewed by:            andrew, tuexen
    Differential Revision:  https://reviews.freebsd.org/D55534
    Event:                  Wiesbaden Hackathon 2026
    
    (cherry picked from commit 0272359ada144aa540c28fefaf996afa30dc0aa5)
---
 sys/arm64/arm64/pmap.c | 2 +-
 sys/arm64/include/vm.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c
index cae46f7c2f1e..678030f827dd 100644
--- a/sys/arm64/arm64/pmap.c
+++ b/sys/arm64/arm64/pmap.c
@@ -9627,7 +9627,7 @@ bool
 pmap_is_valid_memattr(pmap_t pmap __unused, vm_memattr_t mode)
 {
 
-	return (mode >= VM_MEMATTR_DEVICE && mode <= VM_MEMATTR_WRITE_THROUGH);
+	return (mode >= 0 && mode < VM_MEMATTR_END);
 }
 
 static void *
diff --git a/sys/arm64/include/vm.h b/sys/arm64/include/vm.h
index 342143c57246..e03e615bb841 100644
--- a/sys/arm64/include/vm.h
+++ b/sys/arm64/include/vm.h
@@ -33,6 +33,7 @@
 #define	VM_MEMATTR_WRITE_BACK		2
 #define	VM_MEMATTR_WRITE_THROUGH	3
 #define	VM_MEMATTR_DEVICE_nGnRE		4
+#define	VM_MEMATTR_END			(VM_MEMATTR_DEVICE_nGnRE + 1)
 
 #define	VM_MEMATTR_DEVICE		VM_MEMATTR_DEVICE_nGnRE
 #define	VM_MEMATTR_DEVICE_NP		VM_MEMATTR_DEVICE_nGnRnE


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69edc6d8.26dbe.41a93a9e>