在 2025/3/19 上午12:23, Peter Maydell 写道:
On Fri, 7 Mar 2025 at 02:42, Song Gao <gaos...@loongson.cn> wrote:
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_ps
skip the function and 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.
Signed-off-by: Song Gao <gaos...@loongson.cn>
Reviewed-by: Bibo Mao <maob...@loongson.cn>
Message-Id: <20250305063311.830674-3-gaos...@loongson.cn>
Hi; Coverity points out what looks like an error in this commit
(CID 1593475):
+bool check_ps(CPULoongArchState *env, int tlb_ps)
+{
+ if (tlb_ps > 64) {
+ return false;
+ }
+ return BIT_ULL(tlb_ps) & (env->CSR_PRCFG2);
BIT_ULL(64) isn't valid, as it would be off the end of a
64-bit value. Should the check be for "tlb_ps >= 64" ?
yes, I had send a patch to fix.
thanks.
Song Gao
+}
thanks
-- PMM