Skip to contentSkip to conversation

xen/arm64: Fix incorrect memory region size in TCR2_EL2

PATCH Superseded Shanker Donthineni 2 participants 4 messages Mar 10, 2016 – Mar 14, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/arm64: Fix incorrect memory region size in TCR2_EL2

The maximum and minimum values for T0SZ depend on level of translation as per AArch64 Virtual Memory System Architecture. The current code sets T0SZ to zero in TCR2_EL2 which is not valid and also might see unexpected behavior on some CPUs.

This patch sets T0SZ to (64-48)bits since XEN uses all 4 levels to cover 48bit (256TB) virtual address space.

---
 xen/arch/arm/arm64/head.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/arm64/head.S +1 -1
index 19fa2bb..28ee404 100644
@@ -343,7 +343,7 @@ skip_bss:
          * PT walks use Inner-Shareable accesses,
          * PT walks are write-back, write-allocate in both cache levels,
          * Full 64-bit address space goes through this table. */
-        ldr   x0, =(TCR_RES1|TCR_SH0_IS|TCR_ORGN0_WBWA|TCR_IRGN0_WBWA|TCR_T0SZ(0))
+        ldr   x0, =(TCR_RES1|TCR_SH0_IS|TCR_ORGN0_WBWA|TCR_IRGN0_WBWA|TCR_T0SZ(64-48))
         /* ID_AA64MMFR0_EL1[3:0] (PARange) corresponds to TCR_EL2[18:16] (PS) */
         mrs   x1, ID_AA64MMFR0_EL1
         bfi   x0, x1, #16, #3
Signature · 9 lines
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc. 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
a Linux Foundation Collaborative Project


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#1 lore raw

Hi Shanker,

Quoted 3 lines · Shanker Donthineni

The maximum and minimum values for T0SZ depend on level of translation as per AArch64 Virtual Memory System Architecture. The current code sets T0SZ to zero in TCR2_EL2 which is not

s/TCR2_EL2/TCR_EL2/

Quoted 1 line

valid and also might see unexpected behavior on some CPUs.

Can you provide more details?

I looked at the specification, programming the field T0SZ to 0 is valid (see D4-1463 ARM DDI 0487A.b):

"For a stage 1 translation
The minimum TxSZ value is 16. If TxSZ is programmed to a value smaller than 16 then the implementation behaves as if the field were programmed to 16 for all purposes other than reading back the value of the field."

Quoted 13 lines

This patch sets T0SZ to (64-48)bits since XEN uses all 4 levels to cover 48bit (256TB) virtual address space.

---
  xen/arch/arm/arm64/head.S | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/arm64/head.S +0 -0
index 19fa2bb..28ee404 100644

xen/arch/arm/arm64/head.S skip_bss: · line 345

Quoted 3 lines
xen/arch/arm/arm64/head.S +0 -0
@@ -343,7 +343,7 @@ skip_bss:
           * PT walks use Inner-Shareable accesses,
           * PT walks are write-back, write-allocate in both cache levels,
           * Full 64-bit address space goes through this table. */

This comment is no longer valid with your changes. Please update it.

xen/arch/arm/arm64/head.S skip_bss: · line 349

Quoted 6 lines
xen/arch/arm/arm64/head.S +1 -1
-        ldr   x0, =(TCR_RES1|TCR_SH0_IS|TCR_ORGN0_WBWA|TCR_IRGN0_WBWA|TCR_T0SZ(0))
+        ldr   x0, =(TCR_RES1|TCR_SH0_IS|TCR_ORGN0_WBWA|TCR_IRGN0_WBWA|TCR_T0SZ(64-48))
          /* ID_AA64MMFR0_EL1[3:0] (PARange) corresponds to TCR_EL2[18:16] (PS) */
          mrs   x1, ID_AA64MMFR0_EL1
          bfi   x0, x1, #16, #3

Regards,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#2 lore raw

HI Jullen,

Quoted 9 lines · Julien Grall

Hi Shanker,

Quoted 3 lines · Shanker Donthineni

The maximum and minimum values for T0SZ depend on level of translation as per AArch64 Virtual Memory System Architecture. The current code sets T0SZ to zero in TCR2_EL2 which is not

s/TCR2_EL2/TCR_EL2/

Sorry for typo, I will fix in next patch

Quoted 4 lines
Quoted 1 line

valid and also might see unexpected behavior on some CPUs.

Can you provide more details?

We are not able to boot XEN on Qualcomm platforms and CPU hung after after executing this line of ASM code.

Quoted 8 lines

I looked at the specification, programming the field T0SZ to 0 is valid (see D4-1463 ARM DDI 0487A.b):

"For a stage 1 translation
The minimum TxSZ value is 16. If TxSZ is programmed to a value smaller than 16 then the implementation behaves as if the field were programmed to 16 for all purposes other than reading back the value of the field."

The behavior of T0SZ=0 is described in ARM spec (DDI0487A_h, page 1752). Still I think setting the T0SZ to 48bit is the right fix similar to LINUX KVM64 EL2 code.

For a stage 1 translation
The minimum TxSZ value is 16. If TxSZ is programmed to a value smaller than 16 then it is IMPLEMENTATION DEFINED whether:

• The implementation behaves as if the field were programmed to 16 for all purposes other than reading back the value of the field.

• Any use of the TxSZ value generates a stage 1 Level 0 Translation fault.

Quoted 8 lines
Quoted 8 lines

This patch sets T0SZ to (64-48)bits since XEN uses all 4 levels to cover 48bit (256TB) virtual address space.

---
  xen/arch/arm/arm64/head.S | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 11 lines

xen/arch/arm/arm64/head.S skip_bss: · line 345

Quoted 8 lines
xen/arch/arm/arm64/head.S +0 -0
index 19fa2bb..28ee404 100644
@@ -343,7 +343,7 @@ skip_bss:
           * PT walks use Inner-Shareable accesses,
           * PT walks are write-back, write-allocate in both cache levels,
           * Full 64-bit address space goes through this table. */

This comment is no longer valid with your changes. Please update it.

Sure, I will change to 48bit virtual address space.

Quoted 9 lines

xen/arch/arm/arm64/head.S skip_bss: · line 349

Quoted 6 lines
xen/arch/arm/arm64/head.S +1 -1
-        ldr   x0, =(TCR_RES1|TCR_SH0_IS|TCR_ORGN0_WBWA|TCR_IRGN0_WBWA|TCR_T0SZ(0))
+        ldr   x0, =(TCR_RES1|TCR_SH0_IS|TCR_ORGN0_WBWA|TCR_IRGN0_WBWA|TCR_T0SZ(64-48))
          /* ID_AA64MMFR0_EL1[3:0] (PARange) corresponds to TCR_EL2[18:16] (PS) */
          mrs   x1, ID_AA64MMFR0_EL1
          bfi   x0, x1, #16, #3

Regards,

Signature · 9 lines
Shanker Donthineni
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#3 lore raw
Quoted 1 line · Shanker Donthineni

HI Jullen,

Hi Shanker,

Quoted 33 lines · Julien Grall
Quoted 9 lines

Hi Shanker,

Quoted 3 lines · Shanker Donthineni

The maximum and minimum values for T0SZ depend on level of translation as per AArch64 Virtual Memory System Architecture. The current code sets T0SZ to zero in TCR2_EL2 which is not

s/TCR2_EL2/TCR_EL2/

Sorry for typo, I will fix in next patch

Quoted 4 lines
Quoted 1 line

valid and also might see unexpected behavior on some CPUs.

Can you provide more details?

We are not able to boot XEN on Qualcomm platforms and CPU hung after after executing this line of ASM code.

Quoted 8 lines

I looked at the specification, programming the field T0SZ to 0 is valid (see D4-1463 ARM DDI 0487A.b):

"For a stage 1 translation
The minimum TxSZ value is 16. If TxSZ is programmed to a value smaller than 16 then the implementation behaves as if the field were programmed to 16 for all purposes other than reading back the value of the field."

The behavior of T0SZ=0 is described in ARM spec (DDI0487A_h, page 1752). Still I think setting the T0SZ to 48bit is the right fix similar to LINUX KVM64 EL2 code.

Quoted 8 lines

For a stage 1 translation
The minimum TxSZ value is 16. If TxSZ is programmed to a value smaller than 16 then it is IMPLEMENTATION DEFINED whether:

• The implementation behaves as if the field were programmed to 16 for all purposes other than reading back the value of the field.

• Any use of the TxSZ value generates a stage 1 Level 0 Translation fault.

Sorry, I was looking at an older version of the ARM ARM where only a single possible behavior was described. So this change looks valid to me.

Can you please mention the version and the section of the spec in the commit message?

Regards,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel