]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
target/mips: fix TLB huge page check to use 64-bit shift
authorDenis Rastyogin <gerben@altlinux.org>
Thu, 14 Aug 2025 10:48:32 +0000 (13:48 +0300)
committerPhilippe Mathieu-Daudé <philmd@linaro.org>
Tue, 2 Sep 2025 15:57:05 +0000 (17:57 +0200)
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.

Signed-off-by: Denis Rastyogin <gerben@altlinux.org>
Message-ID: <20250814104914.13101-1-gerben@altlinux.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
target/mips/tcg/system/tlb_helper.c

index eccaf3624cb3d8151402185591df96af10cc6ece..1e8901556d660af7d150c6c1e97f1cc54d00d0ce 100644 (file)
@@ -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);