Skip to contentSkip to conversation

target/mips: fix TLB huge page check to use 64-bit shift

PATCH New [email protected] 1 participant 1 message Aug 14, 2025

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 target/mips: fix TLB huge page check to use 64-bit shift

From: Denis Rastyogin <[email protected]>

Use extract64(entry, psn, 1) instead of (entry & (1 << psn)) to avoid undefined behavior for shifts by 32–63 and to make bit extraction intent explicit.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

---
 target/mips/tcg/system/tlb_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/mips/tcg/system/tlb_helper.c +1 -1
index eccaf3624c..1e8901556d 100644
@@ -652,7 +652,7 @@ static int walk_directory(CPUMIPSState *env, uint64_t *vaddr,
         return 0;
     }
 
-    if ((entry & (1 << psn)) && hugepg) {
+    if (extract64(entry, psn, 1) && hugepg) {
         *huge_page = true;
         *hgpg_directory_hit = true;
         entry = get_tlb_entry_layout(env, entry, leaf_mop, pf_ptew);
Signature · 1 line
2.42.2