target/arm: Use the max page size in a 2-stage ptw
PATCH 1/1 target/arm: Use the max page size in a 2-stage ptw
We had only been reporting the stage2 page size. This causes problems if stage1 is using a larger page size (16k, 2M, etc), but stage2 is using a smaller page size, because cputlb does not set large_page_{addr,mask} properly.
Fix by using the max of the two page sizes.
---
Hi Mark, I think this will fix the issue that you mentioned on Monday. It certainly appears to fit the bill vs the described symptoms.
This is based on my ptw.c rewrite, full tree at
https://gitlab.com/rth7680/qemu/-/tree/tgt-arm-rme
Based-on: [email protected] ("[PATCH v2 00/66] target/arm: Implement FEAT_HAFDBS")
r~
--- target/arm/ptw.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
target/arm/ptw.c +10 -1
@@ -2509,7 +2509,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, target_ulong address, ARMMMUFaultInfo *fi) {hwaddr ipa; -int s1_prot; +int s1_prot, s1_lgpgsz;bool ret;bool ipa_secure;ARMCacheAttrs cacheattrs1;
@@ -2550,6 +2550,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, target_ulong address,* prot and cacheattrs later. */ s1_prot = result->f.prot; + s1_lgpgsz = result->f.lg_page_size; cacheattrs1 = result->cacheattrs;memset (result,0 ,sizeof (*result));
@@ -2565,6 +2566,14 @@ static bool get_phys_addr_twostage(CPUARMState *env, target_ulong address,return ret; } +/* +* Use the maximum of the S1 & S2 page size, so that invalidation +* of pages > TARGET_PAGE_SIZE works correctly. +*/ +if (result->f.lg_page_size < s1_lgpgsz) { + result->f.lg_page_size = s1_lgpgsz; + } +/* Combine the S1 and S2 cache attributes. */ hcr =arm_hcr_el2_eff_secstate (env, is_secure);if (hcr &HCR_DC ) {
Signature · 1 line
2.34.1
[ Fix Marc's email address ]
Quoted 65 lines · Richard Henderson
We had only been reporting the stage2 page size. This causes problems if stage1 is using a larger page size (16k, 2M, etc), but stage2 is using a smaller page size, because cputlb does not set large_page_{addr,mask} properly.
Fix by using the max of the two page sizes.
Reported-by Marc Zyngier <[email protected]>Signed-off-by Richard Henderson <[email protected]>---
Hi Mark, I think this will fix the issue that you mentioned on Monday. It certainly appears to fit the bill vs the described symptoms.
This is based on my
ptw.crewrite, full tree athttps://gitlab.com/rth7680/qemu/-/tree/tgt-arm-rmeBased-on: [email protected] ("[PATCH v2 00/66] target/arm: Implement
FEAT_HAFDBS")r~
--- target/arm/ptw.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)target/arm/ptw.c +10
-1@@ -2509,7 +2509,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, target_ulong address, ARMMMUFaultInfo *fi) {hwaddr ipa; -int s1_prot; +int s1_prot, s1_lgpgsz;bool ret;bool ipa_secure;ARMCacheAttrs cacheattrs1;@@ -2550,6 +2550,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, target_ulong address,* prot and cacheattrs later. */ s1_prot = result->f.prot; + s1_lgpgsz = result->f.lg_page_size; cacheattrs1 = result->cacheattrs;memset (result,0 ,sizeof (*result));@@ -2565,6 +2566,14 @@ static bool get_phys_addr_twostage(CPUARMState *env, target_ulong address,return ret; } +/* +* Use the maximum of the S1 & S2 page size, so that invalidation +* of pages > TARGET_PAGE_SIZE works correctly. +*/ +if (result->f.lg_page_size < s1_lgpgsz) { + result->f.lg_page_size = s1_lgpgsz; + } +/* Combine the S1 and S2 cache attributes. */ hcr =arm_hcr_el2_eff_secstate (env, is_secure);if (hcr &HCR_DC ) {
Quoted 2 lines · Zenghui Yu
[ Fix Marc's email address ]
Ah, many thanks Zenghui! I was wondering whether my discussion with Richard had any result. As it turns out, it had an almost immediate result!
Quoted 10 lines · Richard Henderson
Quoted 8 lines
We had only been reporting the stage2 page size. This causes problems if stage1 is using a larger page size (16k, 2M, etc), but stage2 is using a smaller page size, because cputlb does not set large_page_{addr,mask} properly.
Fix by using the max of the two page sizes.
Reported-by Marc Zyngier <[email protected]>
This is no longer a thing (and hasn't been for over 3 years! ;-). [email protected] is the canonical address.
Quoted 6 lines
Quoted 6 lines
Signed-off-by Richard Henderson <[email protected]>---
Hi Mark, I think this will fix the issue that you mentioned on Monday. It certainly appears to fit the bill vs the described symptoms.
Quoted 6 lines
Quoted 6 lines
This is based on my
ptw.crewrite, full tree athttps://gitlab.com/rth7680/qemu/-/tree/tgt-arm-rmeBased-on: [email protected] ("[PATCH v2 00/66] target/arm: Implement
FEAT_HAFDBS")
Thanks Richard. I'll try and give it a spin shortly.
Cheers,
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.