target/loongarch: Fix helper_lddir() a CID INTEGER_OVERFLOW issue
authorSong Gao <gaosong@loongson.cn>
Wed, 24 Jul 2024 01:58:53 +0000 (09:58 +0800)
committerSong Gao <gaosong@loongson.cn>
Wed, 24 Jul 2024 08:52:18 +0000 (16:52 +0800)
When the lddir level is 4 and the base is a HugePage, we may try to put value 4
into a field in the TLBENTRY that is only 2 bits wide.

Fixes: Coverity CID 1547717
Fixes: 9c70db9a43388 ("target/loongarch: Fix tlb huge page loading issue")
Signed-off-by: Song Gao <gaosong@loongson.cn>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20240724015853.1317396-1-gaosong@loongson.cn>

target/loongarch/tcg/tlb_helper.c

index d6331f9b0bbabd578401cfcb25a8433ace930265..97f38fc391338ba4b76115b142fa76d89e45cd62 100644 (file)
@@ -525,6 +525,7 @@ target_ulong helper_lddir(CPULoongArchState *env, target_ulong base,
         if (unlikely(level == 4)) {
             qemu_log_mask(LOG_GUEST_ERROR,
                           "Attempted use of level 4 huge page\n");
+            return base;
         }
 
         if (FIELD_EX64(base, TLBENTRY, LEVEL)) {