In previous patches, we have provided the ability to synchronize
SErrors in exception entries. But we haven't synchronized SErrors
while returning to guest and doing context switch.

So we still have two risks:
1. Slipping hypervisor SErrors to guest. For example, hypervisor
   triggers a SError while returning to guest, but this SError may be
   delivered after entering guest. In "DIVERSE" option, this SError
   would be routed back to guest and panic the guest. But actually,
   we should crash the whole system due to this hypervisor SError.
2. Slipping previous guest SErrors to the next guest. In "FORWARD"
   option, if hypervisor triggers a SError while context switching.
   This SError may be delivered after switching to next vCPU. In this
   case, this SError will be forwarded to next vCPU and may panic
   an incorrect guest.

So we have have to introduce this helper to synchronize SErrors while
returning to guest and doing context switch.

This function should be used out of trap.c in later patch of this
series. We have to export this helper in header file.

Signed-off-by: Wei Chen <wei.c...@arm.com>
Reviewed-by: Stefano Stabellini <sstabell...@kernel.org>
---
v1->v2:
1. Update commit message to explain why we introduce this helper.
2. Remove static for this helper.
3. Add Stefano's Reviewed-by tag.
---
 xen/arch/arm/traps.c            | 9 +++++++++
 xen/include/asm-arm/processor.h | 2 ++
 2 files changed, 11 insertions(+)

diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index f454fb5..55d85ed 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -2881,6 +2881,15 @@ asmlinkage void do_trap_hypervisor(struct cpu_user_regs 
*regs)
     }
 }
 
+void synchronize_serror(void)
+{
+    /* Synchronize against in-flight ld/st. */
+    dsb(sy);
+
+    /* A single instruction exception window */
+    isb();
+}
+
 asmlinkage void do_trap_hyp_serror(struct cpu_user_regs *regs)
 {
     enter_hypervisor_head(regs);
diff --git a/xen/include/asm-arm/processor.h b/xen/include/asm-arm/processor.h
index ead6ad3..3ebbe57 100644
--- a/xen/include/asm-arm/processor.h
+++ b/xen/include/asm-arm/processor.h
@@ -721,6 +721,8 @@ void abort_guest_exit_end(void);
     ( (unsigned long)abort_guest_exit_end == (r)->pc ) \
 )
 
+void synchronize_serror(void);
+
 #endif /* __ASSEMBLY__ */
 #endif /* __ASM_ARM_PROCESSOR_H */
 /*
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

Reply via email to