Skip to contentSkip to conversation

arm/traps: fix bug in dump_guest_s1_walk L1 page table offset computation

PATCH In review Jonathan Daugherty 2 participants 4 messages Jul 19, 2016 – Jul 20, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 arm/traps: fix bug in dump_guest_s1_walk L1 page table offset computation

The dump_guest_s1_walk function was incorrectly using the top 10 bits of the virtual address to select the L1 page table index. The correct amount is 12 bits, resulting in a shift of 20 bits rather than 22.

For more details, see the ARMv7-A ARM, section B3.5, "Short-descriptor translation table format."

---
 xen/arch/arm/traps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/traps.c +1 -1
index a2eb1da..0c10c4d 100644
@@ -2346,7 +2346,7 @@ void dump_guest_s1_walk(struct domain *d, vaddr_t addr)
     }
     first = map_domain_page(mfn);
 
-    offset = addr >> (12+10);
+    offset = addr >> (12+8);
     printk("1ST[0x%"PRIx32"] (0x%"PRIpaddr") = 0x%08"PRIx32"\n",
            offset, pfn_to_paddr(mfn_x(mfn)), first[offset]);
     if ( !(first[offset] & 0x1) ||
Signature · 7 lines
2.9.2


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

PATCH 2/2 arm/traps: fix bug in dump_guest_s1_walk handling of level 2 page tables

dump_guest_s1_walk intends to walk to level 2 page table entries but was failing to do so because of a check that caused level 2 page table descriptors to be ignored. This change fixes the check so that level 2 page table walks occur as intended by ignoring descriptors unless their low two bits match the expected sequence [0,1].

For more information, see the ARMv7-A ARM, section B3.5.

---
 xen/arch/arm/traps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/traps.c +1 -1
index 0c10c4d..dfb1949 100644
@@ -2350,7 +2350,7 @@ void dump_guest_s1_walk(struct domain *d, vaddr_t addr)
     printk("1ST[0x%"PRIx32"] (0x%"PRIpaddr") = 0x%08"PRIx32"\n",
            offset, pfn_to_paddr(mfn_x(mfn)), first[offset]);
     if ( !(first[offset] & 0x1) ||
-         !(first[offset] & 0x2) )
+          (first[offset] & 0x2) )
         goto done;
 
     mfn = p2m_lookup(d, _gfn(paddr_to_pfn(first[offset])), NULL);
Signature · 7 lines
2.9.2


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] arm/traps: fix bug in dump_guest_s1_walk handling of level 2 page tables

Quoted 7 lines · Jonathan Daugherty

dump_guest_s1_walk intends to walk to level 2 page table entries but was failing to do so because of a check that caused level 2 page table descriptors to be ignored. This change fixes the check so that level 2 page table walks occur as intended by ignoring descriptors unless their low two bits match the expected sequence [0,1].

For more information, see the ARMv7-A ARM, section B3.5.

NIT: Could you specify the version of the spec (i.e something similar to ARM DDI 0406C.c)?

Also, to be precise the section would be B3.5.1.

Quoted 2 lines

Regards,

Quoted 18 lines
---
 xen/arch/arm/traps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/traps.c +1 -1
index 0c10c4d..dfb1949 100644
@@ -2350,7 +2350,7 @@ void dump_guest_s1_walk(struct domain *d, vaddr_t addr)
     printk("1ST[0x%"PRIx32"] (0x%"PRIpaddr") = 0x%08"PRIx32"\n",
            offset, pfn_to_paddr(mfn_x(mfn)), first[offset]);
     if ( !(first[offset] & 0x1) ||
-         !(first[offset] & 0x2) )
+          (first[offset] & 0x2) )
         goto done;
 
     mfn = p2m_lookup(d, _gfn(paddr_to_pfn(first[offset])), NULL);
Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v1 1/2
#3 lore raw
In reply to Jonathan Daugherty

Hi Jonathan,

Thank you for sending the bug fix.

Quoted 5 lines · Jonathan Daugherty

The dump_guest_s1_walk function was incorrectly using the top 10 bits of the virtual address to select the L1 page table index. The correct amount is 12 bits, resulting in a shift of 20 bits rather than 22.

For more details, see the ARMv7-A ARM, section B3.5, "Short-descriptor

NIT: Could you specify the version of the spec (i.e something similar to ARM DDI 0406C.c)?

Quoted 3 lines

translation table format."

With the suggestion above:

Regards,

Quoted 18 lines
---
 xen/arch/arm/traps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/traps.c +1 -1
index a2eb1da..0c10c4d 100644
@@ -2346,7 +2346,7 @@ void dump_guest_s1_walk(struct domain *d, vaddr_t addr)
     }
     first = map_domain_page(mfn);
 
-    offset = addr >> (12+10);
+    offset = addr >> (12+8);
     printk("1ST[0x%"PRIx32"] (0x%"PRIpaddr") = 0x%08"PRIx32"\n",
            offset, pfn_to_paddr(mfn_x(mfn)), first[offset]);
     if ( !(first[offset] & 0x1) ||
Signature · 6 lines
Julien Grall

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