git: 33a625b1d6cd - releng/13.1 - arm64: pmap: Mask VA operand in TLBI instructions

From: D Scott Phillips <scottph_at_FreeBSD.org>
Date: Wed, 30 Mar 2022 21:04:39 UTC
The branch releng/13.1 has been updated by scottph:

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

commit 33a625b1d6cd54695e82bcb4379a88d09b3b4ada
Author:     D Scott Phillips <scottph@FreeBSD.org>
AuthorDate: 2022-03-25 16:04:11 +0000
Commit:     D Scott Phillips <scottph@FreeBSD.org>
CommitDate: 2022-03-30 20:51:37 +0000

    arm64: pmap: Mask VA operand in TLBI instructions
    
    Bits 43:0 of the TLBI operand are bits 55:12 of the VA.  Leaving
    bits 63:55 of the VA in bits 51:44 of the operand might wind up
    setting the TTL field (47:44) and accidentally restricting which
    translation levels are flushed in the TLB.
    
    Approved by:    re (gjb)
    Reviewed By:    andrew
    MFC after:      3 days
    Sponsored by:   Ampere Computing
    Differential Revision:  https://reviews.freebsd.org/D34664
    
    (cherry picked from commit a693a30038278b1ccd3e67b98d76e259ca1b405d)
    (cherry picked from commit 2c013d142b146ed42d0fe6458ee8a394161ad370)
---
 sys/arm64/arm64/pmap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c
index 26e62c9e3cbb..0183dde11847 100644
--- a/sys/arm64/arm64/pmap.c
+++ b/sys/arm64/arm64/pmap.c
@@ -361,7 +361,8 @@ void (*pmap_invalidate_vpipt_icache)(void);
 #define	COOKIE_TO_EPOCH(cookie)		((int)((u_long)(cookie) >> 32))
 
 #define	TLBI_VA_SHIFT			12
-#define	TLBI_VA(addr)			((addr) >> TLBI_VA_SHIFT)
+#define	TLBI_VA_MASK			((1ul << 44) - 1)
+#define	TLBI_VA(addr)			(((addr) >> TLBI_VA_SHIFT) & TLBI_VA_MASK)
 #define	TLBI_VA_L3_INCR			(L3_SIZE >> TLBI_VA_SHIFT)
 
 static int superpages_enabled = 1;