Some tlb instructions get the tlb_ps from tlb->misc but the
value may has been initialized to 0,just check the tlb_e skip
the function and check_tlb_ps write a log.
For LoongArch th min tlb_ps is 12(4KB), for TLB code,
the tlb_ps may be 0,this may case UndefinedBehavior
Add a check-tlb_ps fuction to check tlb_ps,
to make sure the tlb_ps is avalablie. we check tlb_ps
when get the tlb_ps from tlb->misc or CSR bits.
1. cpu reset.
set CSR_PWCL.PTBASE and CSR_STLBPS.PS bits a default value
from CSR_PRCFG2;
2. tlb instructions.
some tlb instructions get the tlb_ps from tlb->misc but the
value may has been initialized to 0. we need just check the tlb_e
skip the function and check tlb_ps write a guest log.
3. csrwr instructions.
to make sure CSR_PWCL.PTBASE and CSR_STLBPS.PS bits are avalable,
cheke theses bits and set a default value from CSR_PRCFG2.
v6:
1 clean code. fix code style.
2 rebase and R-b.
V5:
1 Add add chek_ps() function to check tlb_ps with CSR_PRCFG2;
2 Some tlb instuctions, just check tlb_ps, do't rewrite the tlb_ps
bits just write a guest log;
3 remove csrwr crmd helper function and crmd check PWCL and check CSR_STLBPS.just
chcek PWCL and STLBPS when csrwr CSR_PWCL and CSR_STLBPS;
4 set CSR_PWCL.PTBASE and CSR_STLBPS.PS bits a default value
from CSR_PRCFG2 when cpu reset.
V4:
1.Get the default tlb_ps value from env->CSR_PRCFG2.
2.Some tlb instrucions check the tlb_ps such as tlbfill/tlbwr/invtlb.
3.check_tlb_ps()just check CSR_PWCL.PTBASE bits and CSR_STLBPS.PS bits.
don't check all tlb->misc.
v3:
remove some tlb instruction chek MMU on PG model, because on DA model
also can use tlb instructions.
v2:
check-tlb_ps when write CSR_PWCL and CSR_STLBPS;
some tlb instructions check CRMD PG model when clear/read/write the tlb.
link to patch: https://patchew.org/QEMU/20250220012226.2182174-1-gaosong@loongson.cn/
Thanks.
Song Gao
Song Gao (2):
target/loongarch: fix 'make check-functional' failed
target/loongarch: check tlb_ps
target/loongarch/cpu.c | 10 +++-
target/loongarch/cpu_helper.c | 8 ++-
target/loongarch/helper.h | 1 +
target/loongarch/internals.h | 2 +
target/loongarch/tcg/csr_helper.c | 30 +++++++++-
.../tcg/insn_trans/trans_privileged.c.inc | 1 +
target/loongarch/tcg/tlb_helper.c | 55 ++++++++++++++++++-
7 files changed, 99 insertions(+), 8 deletions(-)
--
2.34.1