在2024年12月23日十二月 下午12:52,Philippe Mathieu-Daudé写道:
> On 23/12/24 00:40, Jiaxun Yang wrote:
>> As per manual, the source of PGD CSR is relevant to highest bit of
>> BADV. In LoongArch32, all CSRs are 32 bits only, thus we should check
>> bit 31 of BADV to determine PGDH/PGDL for LoongArch32.
>> 
>> Signed-off-by: Jiaxun Yang <jiaxun.y...@flygoat.com>
>> ---
>>   target/loongarch/tcg/csr_helper.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/target/loongarch/tcg/csr_helper.c 
>> b/target/loongarch/tcg/csr_helper.c
>> index 
>> 15f94caefabc7722263fa46e948e21de37b4203c..ca8100eedfb37fd3b45b3de0c0fc0fad599c4685
>>  100644
>> --- a/target/loongarch/tcg/csr_helper.c
>> +++ b/target/loongarch/tcg/csr_helper.c
>> @@ -26,7 +26,7 @@ target_ulong helper_csrrd_pgd(CPULoongArchState *env)
>>           v = env->CSR_BADV;
>>       }
>>   
>> -    if ((v >> 63) & 0x1) {
>> +    if (v >> (is_la64(env) ? 63 : 31) & 0x1) {
>
> Alternatively:
>
>         if (extract64(v, TARGET_LONG_BITS - 1, 1)) {
>
>>           v = env->CSR_PGDH;
>>       } else {
>>           v = env->CSR_PGDL;
>>

To support 32bit CPU on 64bit builds we still need to check is_ia64 at runtime 
:-(

Will use extract64 instead.

-- 
- Jiaxun

Reply via email to