arm: Fix asynchronous aborts (SError exceptions) due to bogus PTEs
PATCH v2 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
G4.12.6 External abort on a translation table walk
---
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
@@ -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
Hi Julien,
Do you have any other comments to be addressed?
Quoted 52 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
G4.12.6 External abort on a translation table walkSigned-off-by Vikram Sethi <[email protected]>Signed-off-by Shanker Donthineni <[email protected]>---
Changes since v1:
Replacememset()withclear_page()
Edit commit descriptionxen/arch/arm/mm.c | 3 +++ 1 file changed, 3 insertions(+)xen/arch/arm/mm.c +3
-0@@ -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
(CC some ARM folks)
Quoted 1 line · Shanker Donthineni
Hi Julien,
Hello Shanker,
Sorry for the late answer.
Quoted 1 line
Do you have any other comments to be addressed?
I have a question regarding the implication for what you wrote in the commit.
As far as I understand, any speculative table walk might cause an imprecise asynchronous abort. So if a guest is using page tables that contain garbage, it would be possible to receive an SError. Am I right?
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 5 lines
Quoted 5 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
G4.12.6 External abort on a translation table walk
As said on an earlier version of this patch, please mention the version of the spec when you quote it.
Quoted 24 lines
Quoted 24 lines
Signed-off-by Vikram Sethi <[email protected]>Signed-off-by Shanker Donthineni <[email protected]>---
Changes since v1:
Replacememset()withclear_page()
Edit commit descriptionxen/arch/arm/mm.c | 3 +++ 1 file changed, 3 insertions(+)xen/arch/arm/mm.c +2
-0@@ -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);
Quoted 9 lines
xen/arch/arm/mm.c void __init setup_frametable_mappings(paddr_t ps, paddr_t pe) · line 781
Quoted 8 lines
xen/arch/arm/mm.c +1
-0@@ -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);
Regards,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 7 lines · Julien Grall
(CC some ARM folks)
Quoted 1 line · Shanker Donthineni
Hi Julien,
Hello Shanker,
Quoted 8 lines
Sorry for the late answer.
Quoted 1 line
Do you have any other comments to be addressed?
I have a question regarding the implication for what you wrote in the commit.
As far as I understand, any speculative table walk might cause an imprecise asynchronous abort. So if a guest is using page tables that contain garbage, it would be possible to receive an SError. Am I right?
Yes, you are right (applies to EL1 TTBR0/TTBR1, EL2 TTBR0/TTBR1 and EL3 TTBR0 tables).
Quoted 17 lines
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 5 lines
Quoted 5 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
G4.12.6 External abort on a translation table walkAs said on an earlier version of this patch, please mention the version of the spec when you quote it.
Sure, should I post V3 patch mentioning ARM spec version?
Quoted 36 lines
Quoted 24 lines
Quoted 24 lines
Signed-off-by Vikram Sethi <[email protected]>Signed-off-by Shanker Donthineni <[email protected]>---
Changes since v1:
Replacememset()withclear_page()
Edit commit descriptionxen/arch/arm/mm.c | 3 +++ 1 file changed, 3 insertions(+)xen/arch/arm/mm.c +2
-0@@ -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);Quoted 9 lines
xen/arch/arm/mm.c void __init setup_frametable_mappings(paddr_t ps, paddr_t pe) · line 781
Quoted 8 lines
xen/arch/arm/mm.c +1
-0@@ -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);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
Quoted 39 lines · Shanker Donthineni
Quoted 7 lines · Julien Grall
(CC some ARM folks)
Quoted 1 line · Shanker Donthineni
Hi Julien,
Hello Shanker,
Quoted 8 lines
Sorry for the late answer.
Quoted 1 line
Do you have any other comments to be addressed?
I have a question regarding the implication for what you wrote in the commit.
As far as I understand, any speculative table walk might cause an imprecise asynchronous abort. So if a guest is using page tables that contain garbage, it would be possible to receive an SError. Am I right?
Yes, you are right (applies to EL1 TTBR0/TTBR1, EL2 TTBR0/TTBR1 and EL3 TTBR0 tables).
Quoted 20 lines
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 2 lines
Quoted 2 lines
E2.8 Memory types and attributes
G4.12.6 External abort on a translation table walkAs said on an earlier version of this patch, please mention the version of the spec when you quote it.
Sure, should I post V3 patch mentioning ARM spec version?
Yes, please.
Quoted 33 lines
Quoted 33 lines
Quoted 32 lines
Quoted 31 lines
Signed-off-by Vikram Sethi <[email protected]>Signed-off-by Shanker Donthineni <[email protected]>---
Changes since v1:
Replacememset()withclear_page()
Edit commit descriptionxen/arch/arm/mm.c | 3 +++ 1 file changed, 3 insertions(+)xen/arch/arm/mm.c +3
-0@@ -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);
Quoted 8 lines
Quoted 2 lines
Regards,
Signature · 3 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