Skip to contentSkip to conversation

arm: Fix asynchronous aborts (SError exceptions) due to bogus PTEs

PATCH Applied Shanker Donthineni 3 participants 5 messages Mar 29, 2016 – Apr 8, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 arm: Fix asynchronous aborts (SError exceptions) due to bogus PTEs

From: Vikram Sethi <[email protected]>

ARMv8 architecture allows performing prefetch data/instructions from memory locations marked as normal memory. Prefetch does not mean that the data/instruction has to be used/executed in code flow. All PTEs that appear to be valid to MMU must contain valid physical address with proper attributes otherwise MMU table walk might cause imprecise asynchronous aborts.

The way current XEN code is preparing page tables for frametable and xenheap memory can create bogus PTEs. This patch fixes the issue by clearing page table memory before populating EL2 L0/L1 PTEs. Without this patch XEN crashes on Qualcomm Technologies server chips due to asynchronous aborts.

The speculative/prefetch feature explanation is scattered everywhere in ARM specification but below two sections have useful information.

E2.8 Memory types and attributes (ver DDI0487A_h) G4.12.6 External abort on a translation table walk (ver DDI0487A_h)

---
Changes since v2:
Include ARM spec version in commit text.

Changes since v1:
Replace memset() with clear_page()
Edit commit description

 xen/arch/arm/mm.c | 3 +++
 1 file changed, 3 insertions(+)
xen/arch/arm/mm.c +3 -0
index 81f9e2e..3fda8f3 100644
@@ -730,6 +730,8 @@ void __init setup_xenheap_mappings(unsigned long base_mfn,
         else
         {
             unsigned long first_mfn = alloc_boot_pages(1, 1);
+
+            clear_page(mfn_to_virt(first_mfn));
             pte = mfn_to_xen_entry(first_mfn, WRITEALLOC);
             pte.pt.table = 1;
             write_pte(p, pte);
@@ -773,6 +775,7 @@ void __init setup_frametable_mappings(paddr_t ps, paddr_t pe)
     second = mfn_to_virt(second_base);
     for ( i = 0; i < nr_second; i++ )
     {
+        clear_page(mfn_to_virt(second_base + i));
         pte = mfn_to_xen_entry(second_base + i, WRITEALLOC);
         pte.pt.table = 1;
         write_pte(&xen_first[first_table_offset(FRAMETABLE_VIRT_START)+i], pte);
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 Stefano/Julien,

Any other comments to be addressed? Please propose an alternative solution to fix the problem if this patch changes are not appropriate.

Quoted 55 lines · Shanker Donthineni

From: Vikram Sethi <[email protected]>

ARMv8 architecture allows performing prefetch data/instructions from memory locations marked as normal memory. Prefetch does not mean that the data/instruction has to be used/executed in code flow. All PTEs that appear to be valid to MMU must contain valid physical address with proper attributes otherwise MMU table walk might cause imprecise asynchronous aborts.

The way current XEN code is preparing page tables for frametable and xenheap memory can create bogus PTEs. This patch fixes the issue by clearing page table memory before populating EL2 L0/L1 PTEs. Without this patch XEN crashes on Qualcomm Technologies server chips due to asynchronous aborts.

The speculative/prefetch feature explanation is scattered everywhere in ARM specification but below two sections have useful information.

E2.8 Memory types and attributes (ver DDI0487A_h) G4.12.6 External abort on a translation table walk (ver DDI0487A_h)

---
Changes since v2:
Include ARM spec version in commit text.

Changes since v1:
Replace memset() with clear_page()
Edit commit description

 xen/arch/arm/mm.c | 3 +++
 1 file changed, 3 insertions(+)
xen/arch/arm/mm.c +3 -0
index 81f9e2e..3fda8f3 100644
@@ -730,6 +730,8 @@ void __init setup_xenheap_mappings(unsigned long base_mfn,
         else
         {
             unsigned long first_mfn = alloc_boot_pages(1, 1);
+
+            clear_page(mfn_to_virt(first_mfn));
             pte = mfn_to_xen_entry(first_mfn, WRITEALLOC);
             pte.pt.table = 1;
             write_pte(p, pte);
@@ -773,6 +775,7 @@ void __init setup_frametable_mappings(paddr_t ps, paddr_t pe)
     second = mfn_to_virt(second_base);
     for ( i = 0; i < nr_second; i++ )
     {
+        clear_page(mfn_to_virt(second_base + i));
         pte = mfn_to_xen_entry(second_base + i, WRITEALLOC);
         pte.pt.table = 1;
         write_pte(&xen_first[first_table_offset(FRAMETABLE_VIRT_START)+i], pte);
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
#2 lore raw
In reply to Shanker Donthineni

Hi Julien/Stefano,

Any other comments to be addressed? Please propose an alternative solution to fix the problem if this patch changes are not appropriate.

Quoted 55 lines · Shanker Donthineni

From: Vikram Sethi <[email protected]>

ARMv8 architecture allows performing prefetch data/instructions from memory locations marked as normal memory. Prefetch does not mean that the data/instruction has to be used/executed in code flow. All PTEs that appear to be valid to MMU must contain valid physical address with proper attributes otherwise MMU table walk might cause imprecise asynchronous aborts.

The way current XEN code is preparing page tables for frametable and xenheap memory can create bogus PTEs. This patch fixes the issue by clearing page table memory before populating EL2 L0/L1 PTEs. Without this patch XEN crashes on Qualcomm Technologies server chips due to asynchronous aborts.

The speculative/prefetch feature explanation is scattered everywhere in ARM specification but below two sections have useful information.

E2.8 Memory types and attributes (ver DDI0487A_h) G4.12.6 External abort on a translation table walk (ver DDI0487A_h)

---
Changes since v2:
Include ARM spec version in commit text.

Changes since v1:
Replace memset() with clear_page()
Edit commit description

 xen/arch/arm/mm.c | 3 +++
 1 file changed, 3 insertions(+)
xen/arch/arm/mm.c +3 -0
index 81f9e2e..3fda8f3 100644
@@ -730,6 +730,8 @@ void __init setup_xenheap_mappings(unsigned long base_mfn,
         else
         {
             unsigned long first_mfn = alloc_boot_pages(1, 1);
+
+            clear_page(mfn_to_virt(first_mfn));
             pte = mfn_to_xen_entry(first_mfn, WRITEALLOC);
             pte.pt.table = 1;
             write_pte(p, pte);
@@ -773,6 +775,7 @@ void __init setup_frametable_mappings(paddr_t ps, paddr_t pe)
     second = mfn_to_virt(second_base);
     for ( i = 0; i < nr_second; i++ )
     {
+        clear_page(mfn_to_virt(second_base + i));
         pte = mfn_to_xen_entry(second_base + i, WRITEALLOC);
         pte.pt.table = 1;
         write_pte(&xen_first[first_table_offset(FRAMETABLE_VIRT_START)+i], pte);
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
Acked-by
#3 lore raw
Quoted 1 line · Shanker Donthineni

Hi Julien/Stefano,

Hi Shanker,

Quoted 3 lines

Any other comments to be addressed? Please propose an alternative solution to fix the problem if this patch changes are not appropriate.

All the comments have been addressed.

Quoted 17 lines · Shanker Donthineni
Quoted 15 lines

From: Vikram Sethi <[email protected]>

ARMv8 architecture allows performing prefetch data/instructions from memory locations marked as normal memory. Prefetch does not mean that the data/instruction has to be used/executed in code flow. All PTEs that appear to be valid to MMU must contain valid physical address with proper attributes otherwise MMU table walk might cause imprecise asynchronous aborts.

The way current XEN code is preparing page tables for frametable and xenheap memory can create bogus PTEs. This patch fixes the issue by clearing page table memory before populating EL2 L0/L1 PTEs. Without this patch XEN crashes on Qualcomm Technologies server chips due to asynchronous aborts.

Quoted 8 lines
Quoted 8 lines

The speculative/prefetch feature explanation is scattered everywhere in ARM specification but below two sections have useful information.

E2.8 Memory types and attributes (ver DDI0487A_h) G4.12.6 External abort on a translation table walk (ver DDI0487A_h)

Regards,

Signature · 6 lines
Julien Grall

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

Hi Julien/Stefano,

Hi Shanker,

Quoted 3 lines

Any other comments to be addressed? Please propose an alternative solution to fix the problem if this patch changes are not appropriate.

All the comments have been addressed.

Quoted 20 lines · Shanker Donthineni
Quoted 18 lines

From: Vikram Sethi <[email protected]>

ARMv8 architecture allows performing prefetch data/instructions from memory locations marked as normal memory. Prefetch does not mean that the data/instruction has to be used/executed in code flow. All PTEs that appear to be valid to MMU must contain valid physical address with proper attributes otherwise MMU table walk might cause imprecise asynchronous aborts.

The way current XEN code is preparing page tables for frametable and xenheap memory can create bogus PTEs. This patch fixes the issue by clearing page table memory before populating EL2 L0/L1 PTEs. Without this patch XEN crashes on Qualcomm Technologies server chips due to asynchronous aborts.

The speculative/prefetch feature explanation is scattered everywhere in ARM specification but below two sections have useful information.

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

E2.8 Memory types and attributes (ver DDI0487A_h) G4.12.6 External abort on a translation table walk (ver DDI0487A_h)

Applied.

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