[PATCH v3 10/12] target/loongarch: Invalid tlb entry in invalidate_tlb()

Bibo Mao posted 12 patches 3 days, 5 hours ago
Maintainers: Song Gao <gaosong@loongson.cn>
There is a newer version of this series
[PATCH v3 10/12] target/loongarch: Invalid tlb entry in invalidate_tlb()
Posted by Bibo Mao 3 days, 5 hours ago
Invalid tlb entry in function invalidate_tlb(), and its usage is
simple and easy to use.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
 target/loongarch/tcg/tlb_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/loongarch/tcg/tlb_helper.c b/target/loongarch/tcg/tlb_helper.c
index c074c956a2..ee40684a18 100644
--- a/target/loongarch/tcg/tlb_helper.c
+++ b/target/loongarch/tcg/tlb_helper.c
@@ -161,6 +161,7 @@ static void invalidate_tlb(CPULoongArchState *env, int index)
         return;
     }
     invalidate_tlb_entry(env, index);
+    tlb->tlb_misc = FIELD_DP64(tlb->tlb_misc, TLB_MISC, E, 0);
 }
 
 static void fill_tlb_entry(CPULoongArchState *env, LoongArchTLB *tlb)
@@ -340,7 +341,6 @@ void helper_tlbwr(CPULoongArchState *env)
     old = env->tlb + index;
     if (FIELD_EX64(env->CSR_TLBIDX, CSR_TLBIDX, NE)) {
         invalidate_tlb(env, index);
-        old->tlb_misc = FIELD_DP64(old->tlb_misc, TLB_MISC, E, 0);
         return;
     }
 
-- 
2.39.3
Re: [PATCH v3 10/12] target/loongarch: Invalid tlb entry in invalidate_tlb()
Posted by Richard Henderson 3 days, 1 hour ago
On 9/3/25 10:48, Bibo Mao wrote:
> Invalid tlb entry in function invalidate_tlb(), and its usage is
> simple and easy to use.
> 
> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
> ---
>   target/loongarch/tcg/tlb_helper.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/target/loongarch/tcg/tlb_helper.c b/target/loongarch/tcg/tlb_helper.c
> index c074c956a2..ee40684a18 100644
> --- a/target/loongarch/tcg/tlb_helper.c
> +++ b/target/loongarch/tcg/tlb_helper.c
> @@ -161,6 +161,7 @@ static void invalidate_tlb(CPULoongArchState *env, int index)
>           return;
>       }
>       invalidate_tlb_entry(env, index);
> +    tlb->tlb_misc = FIELD_DP64(tlb->tlb_misc, TLB_MISC, E, 0);
>   }

Why not move it all the way down into invalidate_elf_entry, after we've checked that E != 0?


r~

>   
>   static void fill_tlb_entry(CPULoongArchState *env, LoongArchTLB *tlb)
> @@ -340,7 +341,6 @@ void helper_tlbwr(CPULoongArchState *env)
>       old = env->tlb + index;
>       if (FIELD_EX64(env->CSR_TLBIDX, CSR_TLBIDX, NE)) {
>           invalidate_tlb(env, index);
> -        old->tlb_misc = FIELD_DP64(old->tlb_misc, TLB_MISC, E, 0);
>           return;
>       }
>
Re: [PATCH v3 10/12] target/loongarch: Invalid tlb entry in invalidate_tlb()
Posted by Bibo Mao 2 days, 4 hours ago

On 2025/9/3 下午9:00, Richard Henderson wrote:
> On 9/3/25 10:48, Bibo Mao wrote:
>> Invalid tlb entry in function invalidate_tlb(), and its usage is
>> simple and easy to use.
>>
>> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
>> ---
>>   target/loongarch/tcg/tlb_helper.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/target/loongarch/tcg/tlb_helper.c 
>> b/target/loongarch/tcg/tlb_helper.c
>> index c074c956a2..ee40684a18 100644
>> --- a/target/loongarch/tcg/tlb_helper.c
>> +++ b/target/loongarch/tcg/tlb_helper.c
>> @@ -161,6 +161,7 @@ static void invalidate_tlb(CPULoongArchState *env, 
>> int index)
>>           return;
>>       }
>>       invalidate_tlb_entry(env, index);
>> +    tlb->tlb_misc = FIELD_DP64(tlb->tlb_misc, TLB_MISC, E, 0);
>>   }
> 
> Why not move it all the way down into invalidate_elf_entry, after we've 
> checked that E != 0?
Both are ok for me. invalidate_tlb_entry() is only called by 
invalidate_tlb().

Will do in this way.

Regards
Bibo Mao
> 
> 
> r~
> 
>>   static void fill_tlb_entry(CPULoongArchState *env, LoongArchTLB *tlb)
>> @@ -340,7 +341,6 @@ void helper_tlbwr(CPULoongArchState *env)
>>       old = env->tlb + index;
>>       if (FIELD_EX64(env->CSR_TLBIDX, CSR_TLBIDX, NE)) {
>>           invalidate_tlb(env, index);
>> -        old->tlb_misc = FIELD_DP64(old->tlb_misc, TLB_MISC, E, 0);
>>           return;
>>       }