diff mbox series

target/loongarch: Fix helper_lddir() a CID INTEGER_OVERFLOW issue

Message ID 20240724015853.1317396-1-gaosong@loongson.cn
State New
Headers show
Series target/loongarch: Fix helper_lddir() a CID INTEGER_OVERFLOW issue | expand

Commit Message

Song Gao July 24, 2024, 1:58 a.m. UTC
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>
---
 target/loongarch/tcg/tlb_helper.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Richard Henderson July 24, 2024, 2:59 a.m. UTC | #1
On 7/24/24 11:58, Song Gao wrote:
> 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>
> ---
>   target/loongarch/tcg/tlb_helper.c | 1 +
>   1 file changed, 1 insertion(+)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
Michael Tokarev July 26, 2024, 10:12 a.m. UTC | #2
24.07.2024 04:58, Song Gao wrote:
> 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>
> ---
>   target/loongarch/tcg/tlb_helper.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/target/loongarch/tcg/tlb_helper.c b/target/loongarch/tcg/tlb_helper.c
> index d6331f9b0b..97f38fc391 100644
> --- a/target/loongarch/tcg/tlb_helper.c
> +++ b/target/loongarch/tcg/tlb_helper.c
> @@ -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)) {


Is it qemu-stable material (for 9.0.x series)?

Thanks,

/mjt
Philippe Mathieu-Daudé July 26, 2024, 3:11 p.m. UTC | #3
On 26/7/24 12:12, Michael Tokarev wrote:
> 24.07.2024 04:58, Song Gao wrote:
>> 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>
>> ---
>>   target/loongarch/tcg/tlb_helper.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/target/loongarch/tcg/tlb_helper.c 
>> b/target/loongarch/tcg/tlb_helper.c
>> index d6331f9b0b..97f38fc391 100644
>> --- a/target/loongarch/tcg/tlb_helper.c
>> +++ b/target/loongarch/tcg/tlb_helper.c
>> @@ -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)) {
> 
> 
> Is it qemu-stable material (for 9.0.x series)?

If this applies cleanly, then yes.
diff mbox series

Patch

diff --git a/target/loongarch/tcg/tlb_helper.c b/target/loongarch/tcg/tlb_helper.c
index d6331f9b0b..97f38fc391 100644
--- a/target/loongarch/tcg/tlb_helper.c
+++ b/target/loongarch/tcg/tlb_helper.c
@@ -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)) {