Skip to contentSkip to conversation

target-arm: fix TTBCR write masking

PATCH In review Sergey Fedorov 2 participants 3 messages Dec 10, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target-arm: fix TTBCR write masking

Current implementation is not accurate according to ARMv7-AR reference manual. See "B4.1.153 TTBCR, Translation Table Base Control Register, VMSA | TTBCR format when using the Long-descriptor translation table format". When LPAE feature is supported, EAE, bit[31] selects translation descriptor format and, therefore, TTBCR format.

---
 target-arm/helper.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target-arm/helper.c +1 -1
index 3445813..8b1ddce 100644
@@ -1173,7 +1173,7 @@ static int vmsa_ttbcr_raw_write(CPUARMState *env, const ARMCPRegInfo *ri,
 {
     int maskshift = extract32(value, 0, 3);
 
-    if (arm_feature(env, ARM_FEATURE_LPAE)) {
+    if (arm_feature(env, ARM_FEATURE_LPAE) && (value & (1 << 31))) {
         value &= ~((7 << 19) | (3 << 14) | (0xf << 3));
     } else {
         value &= 7;
Signature · 1 line
1.7.9.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Sergey Fedorov

Current implementation is not accurate according to ARMv7-AR reference manual. See "B4.1.153 TTBCR, Translation Table Base Control Register, VMSA | TTBCR format when using the Long-descriptor translation table format". When LPAE feature is supported, EAE, bit[31] selects translation descriptor format and, therefore, TTBCR format.

Yeah, when I wrote that I was relying on the fact that all the valid bits in a short-format descriptor are also valid in the long-format mask, so correct guest software won't care (the other bits are UNK/SBZP). However the implementation side of UNK/SBZP requires us to treat the bits as RAZ/WI, so this patch is correct.

thanks
-- PMM

#2 lore raw

This patch is a prerequisite for the following up TrustZone support patches.

Thanks.

Best regards,
Sergey Fedorov

Quoted 20 lines · Peter Maydell
Quoted 7 lines · Sergey Fedorov

Current implementation is not accurate according to ARMv7-AR reference manual. See "B4.1.153 TTBCR, Translation Table Base Control Register, VMSA | TTBCR format when using the Long-descriptor translation table format". When LPAE feature is supported, EAE, bit[31] selects translation descriptor format and, therefore, TTBCR format.

Yeah, when I wrote that I was relying on the fact that all the valid bits in a short-format descriptor are also valid in the long-format mask, so correct guest software won't care (the other bits are UNK/SBZP). However the implementation side of UNK/SBZP requires us to treat the bits as RAZ/WI, so this patch is correct.

thanks
-- PMM