Skip to contentSkip to conversation

arm64/mmu: Fix PT_PT table descriptor value and comment

PATCH Superseded Gabriel Quintáns Souto 3 participants 7 messages May 18 – May 19

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64/mmu: Fix PT_PT table descriptor value and comment

PT_PT is used to create table descriptors in create_table_entry_from_paddr. The previous value (0xf7f) and comment incorrectly included attribute fields (nG, SH, AP, NS, ATTR) that only exist in block/page descriptors, not in table descriptors.

Per the ARMv8-A Architecture Reference Manual (DDI0487, Section D8.3.1), table descriptors only define:
- Bits [63:12]: Next-level table address
- Bit [11]: Ignored
- Bit [10]: AF (Access Flag, ARMv8.1+)
- Bits [9:2]: Ignored or reserved for extensions
- Bit [1]: Descriptor type (1 = Table)
- Bit [0]: Valid bit (1 = Valid)

Update to 0x743 with only the relevant bits set:
- Bit [10]: AF (Access Flag, ARMv8.1+)
- Bits [9:8]: Reserved/extension bits
- Bit [6]: SKL (ARMv9)
- Bits [5:2]: Cleared (ignored by hardware)
- Bit [1]: Table descriptor type
- Bit [0]: Valid

Compile-tested and boot-tested in QEMU ARM64 (virt machine, cortex-a57).

---
 xen/arch/arm/arm64/mmu/head.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/arm64/mmu/head.S +1 -1
index d14780ad19..c3cb262e88 100644
@@ -8,7 +8,7 @@
 #include <asm/page.h>
 #include <asm/early_printk.h>
 
-#define PT_PT     0xf7f /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=1 P=1 */
+#define PT_PT     0x743 /* AF=1 RES=11 SKL=1 IGN=0000 T=1 P=1 */
 #define PT_MEM    0xf7d /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=0 P=1 */
 #define PT_MEM_L3 0xf7f /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=1 P=1 */
 #define PT_DEV    0xe71 /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=100 T=0 P=1 */
Signature · 1 line
2.53.0
#1 lore raw
Quoted 34 lines · Gabriel Quintáns Souto

PT_PT is used to create table descriptors in create_table_entry_from_paddr. The previous value (0xf7f) and comment incorrectly included attribute fields (nG, SH, AP, NS, ATTR) that only exist in block/page descriptors, not in table descriptors.

Per the ARMv8-A Architecture Reference Manual (DDI0487, Section D8.3.1), table descriptors only define:
- Bits [63:12]: Next-level table address
- Bit [11]: Ignored
- Bit [10]: AF (Access Flag, ARMv8.1+)
- Bits [9:2]: Ignored or reserved for extensions
- Bit [1]: Descriptor type (1 = Table)
- Bit [0]: Valid bit (1 = Valid)

Update to 0x743 with only the relevant bits set:
- Bit [10]: AF (Access Flag, ARMv8.1+)
- Bits [9:8]: Reserved/extension bits
- Bit [6]: SKL (ARMv9)
- Bits [5:2]: Cleared (ignored by hardware)
- Bit [1]: Table descriptor type
- Bit [0]: Valid

Compile-tested and boot-tested in QEMU ARM64 (virt machine, cortex-a57).

---
 xen/arch/arm/arm64/mmu/head.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/arm64/mmu/head.S +0 -0
index d14780ad19..c3cb262e88 100644

xen/arch/arm/arm64/mmu/head.S line 11

Quoted 5 lines
xen/arch/arm/arm64/mmu/head.S +1 -1
@@ -8,7 +8,7 @@
 #include <asm/page.h>
 #include <asm/early_printk.h>
 
-#define PT_PT     0xf7f /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=1 P=1 */
+#define PT_PT     0x743 /* AF=1 RES=11 SKL=1 IGN=0000 T=1 P=1 */

Looking at ARMv8A ARM M.a, figure D8-12 bits [11:2] of a VMSAv8-64 table descriptor are IGNORED by hardware (see xen/arch/arm/include/asm/lpae.h as well). The change therefore has no functional effect on ARMv8-A hardware Xen runs on.

The arm32 head.S has the identical misleading definition and comment; the ARMv7 LPAE table-descriptor format shares the "ignored in table entries" property. After this patch the two siblings diverge. Update arm32 to match, or leave both alone.

If the goal is "only relevant bits set", the minimum is 0x3 (T=1 P=1). 0x403 if you want AF as future-proofing for FEAT_HAFT (ARMv9 I believe).

~Michal

#2 lore raw

PATCH v2 1/1 arm: Fix PT_PT table descriptor value and comment

Per ARMv7-A/ARMv8-A ARM, bits [11:2] of table descriptors are ignored by hardware. The original comment incorrectly described block/page descriptor fields (nG, SH, AP, NS, ATTR) which do not exist in the table descriptor format.

Set PT_PT to 0x403:
- Bit 0 (P): Valid bit (required)
- Bit 1 (T): Table descriptor type (required)
- Bit 10 (AF): Access flag (future-proof for FEAT_HAFT)

Hardware ignores bits [11:2] but setting AF prepares for ARMv9's FEAT_HAFT. Using 0x403 rather than minimal 0x3 provides forward compatibility while avoiding unnecessary reserved bits.

This updates both arm32 and arm64 for consistency.

---
Changes in v2:
- Apply fix to both arm32 and arm64
- Use 0x403 instead of 0x743

---
 xen/arch/arm/arm32/mmu/head.S | 2 +-
 xen/arch/arm/arm64/mmu/head.S | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
xen/arch/arm/arm32/mmu/head.S +1 -1
index 5032e6c075..cab7be0621 100644
@@ -8,7 +8,7 @@
 #include <asm/page.h>
 #include <asm/early_printk.h>
 
-#define PT_PT     0xf7f /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=1 P=1 */
+#define PT_PT     0x403 /* AF=1 T=1 P=1 (bits [11:2] ignored in table descriptors) */
 #define PT_MEM    0xf7d /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=0 P=1 */
 #define PT_MEM_L3 0xf7f /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=1 P=1 */
 #define PT_DEV    0xe71 /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=100 T=0 P=1 */
xen/arch/arm/arm64/mmu/head.S +1 -1
index c3cb262e88..375d703d9b 100644
@@ -8,7 +8,7 @@
 #include <asm/page.h>
 #include <asm/early_printk.h>
 
-#define PT_PT     0x743 /* AF=1 RES=11 SKL=1 IGN=0000 T=1 P=1 */
+#define PT_PT     0x403 /* AF=1 T=1 P=1 (bits [11:2] ignored in table descriptors) */
 #define PT_MEM    0xf7d /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=0 P=1 */
 #define PT_MEM_L3 0xf7f /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=1 P=1 */
 #define PT_DEV    0xe71 /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=100 T=0 P=1 */
Signature · 1 line
2.54.0
#3 lore raw

Re: [PATCH v2] arm: Fix PT_PT table descriptor value and comment

Quoted 1 line · Gabriel Quintáns Souto

Per ARMv7-A/ARMv8-A ARM, bits [11:2] of table descriptors are ignored by hardware. The original comment incorrectly described block/page descriptor fields (nG, SH, AP, NS, ATTR) which do not

Please trim lines to 80 chars

exist in the table descriptor format.

Quoted 5 lines

Set PT_PT to 0x403:
- Bit 0 (P): Valid bit (required)
- Bit 1 (T): Table descriptor type (required)
- Bit 10 (AF): Access flag (future-proof for FEAT_HAFT)

There's no FEAT_HAFT on AArch32, bit 10 is purely ignored, so why setting it also for arm32? On arm32 it should be 0x3. On arm64, thinking more about it, setting AF for table descriptor would make sense only if we enable HAFT in TCR which we don't. Therefore, for consistency you should use 0x3 for both arm32 and arm64.

Quoted 21 lines

Hardware ignores bits [11:2] but setting AF prepares for ARMv9's FEAT_HAFT. Using 0x403 rather than minimal 0x3 provides forward compatibility while avoiding unnecessary reserved bits.

This updates both arm32 and arm64 for consistency.

---
Changes in v2:
- Apply fix to both arm32 and arm64
- Use 0x403 instead of 0x743

---
 xen/arch/arm/arm32/mmu/head.S | 2 +-
 xen/arch/arm/arm64/mmu/head.S | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
xen/arch/arm/arm32/mmu/head.S +0 -0
index 5032e6c075..cab7be0621 100644

xen/arch/arm/arm32/mmu/head.S line 11

Quoted 5 lines
xen/arch/arm/arm32/mmu/head.S +1 -1
@@ -8,7 +8,7 @@
 #include <asm/page.h>
 #include <asm/early_printk.h>
 
-#define PT_PT     0xf7f /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=1 P=1 */
+#define PT_PT     0x403 /* AF=1 T=1 P=1 (bits [11:2] ignored in table descriptors) */

Don't exceed 80 chars line length. Also, you don't need to provide reasoning here for ignored bits.

~Michal

#4 lore raw

PATCH v3 1/1 arm: Fix PT_PT table descriptor value and comment

Per ARMv7-A/ARMv8-A ARM, bits [11:2] of table descriptors are ignored by hardware. The original comment incorrectly described block/page descriptor fields which are not present in table descriptors.

Use the minimal valid encoding for table descriptors by setting PT_PT to 0x3.

This updates both arm32 and arm64 for consistency.

---
Changes in v3:
- Use 0x3 instead of 0x403

Changes in v2:
- Apply fix to both arm32 and arm64
- Use 0x403 instead of 0x743

---
 xen/arch/arm/arm32/mmu/head.S | 2 +-
 xen/arch/arm/arm64/mmu/head.S | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
xen/arch/arm/arm32/mmu/head.S +1 -1
index cab7be0621..3731322f7e 100644
@@ -8,7 +8,7 @@
 #include <asm/page.h>
 #include <asm/early_printk.h>
 
-#define PT_PT     0x403 /* AF=1 T=1 P=1 (bits [11:2] ignored in table descriptors) */
+#define PT_PT     0x3   /* T=1 P=1 */
 #define PT_MEM    0xf7d /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=0 P=1 */
 #define PT_MEM_L3 0xf7f /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=1 P=1 */
 #define PT_DEV    0xe71 /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=100 T=0 P=1 */
xen/arch/arm/arm64/mmu/head.S +1 -1
index 375d703d9b..8e514d2114 100644
@@ -8,7 +8,7 @@
 #include <asm/page.h>
 #include <asm/early_printk.h>
 
-#define PT_PT     0x403 /* AF=1 T=1 P=1 (bits [11:2] ignored in table descriptors) */
+#define PT_PT     0x3   /* T=1 P=1 */
 #define PT_MEM    0xf7d /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=0 P=1 */
 #define PT_MEM_L3 0xf7f /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=1 P=1 */
 #define PT_DEV    0xe71 /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=100 T=0 P=1 */
Signature · 1 line
2.54.0
Reviewed-by on v3 1/1
#5 lore raw

Re: [PATCH v3] arm: Fix PT_PT table descriptor value and comment

Quoted 11 lines · Gabriel Quintáns Souto

Per ARMv7-A/ARMv8-A ARM, bits [11:2] of table descriptors are ignored by hardware. The original comment incorrectly described block/page descriptor fields which are not present in table descriptors.

Use the minimal valid encoding for table descriptors by setting PT_PT to 0x3.

This updates both arm32 and arm64 for consistency.

~Michal

Reviewed-by on v3 1/1
#6 lore raw

Re: [PATCH v3] arm: Fix PT_PT table descriptor value and comment

In reply to Gabriel Quintáns Souto

Hi Gabriel,

For the future, when sending a new version, please create a new thread rather than in reply to the latest response.

Quoted 4 lines · Gabriel Quintáns Souto

Per ARMv7-A/ARMv8-A ARM, bits [11:2] of table descriptors are ignored by hardware. The original comment incorrectly described block/page descriptor fields which are not present in table descriptors.

Do you have more details why this change? Is this to strictly follow the Arm Arm?

In the ideal situation we should have the page table descriptors consistent between the assembly and the C version (see mfn_to_xen_entry()). They were diverging before and this is still diverging. If we are concerned about setting AF here, then we ought to modify the C versions as well.

It could be done separately though.

Quoted 6 lines

Use the minimal valid encoding for table descriptors by setting PT_PT to 0x3.

This updates both arm32 and arm64 for consistency.

Quoted 1 line

Cheers,

Signature · 1 line
Julien Grall