[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] xen/arm: Introduce a virtual abort injection helper



commit a79065a4ce4d346341f7678ba9d105407a81334c
Author:     Wei Chen <Wei.Chen@xxxxxxx>
AuthorDate: Wed Apr 5 17:09:08 2017 +0800
Commit:     Stefano Stabellini <sstabellini@xxxxxxxxxx>
CommitDate: Wed Apr 5 12:12:17 2017 -0700

    xen/arm: Introduce a virtual abort injection helper
    
    When guest triggers async aborts, in most platform, such aborts
    will be routed to hypervisor. But we don't want the hypervisor
    to handle such aborts, so we have to route such aborts back to
    the guest.
    
    This helper is using the HCR_EL2.VSE (HCR.VA for aarch32) bit to
    route such aborts back to the guest. After updating HCR_EL2.VSE bit
    in vCPU context, we write the value to HCR_EL2 immediately. In this
    case we don't need to move the restoration of HCR_EL2 to other place,
    and it worked regardless of whether we get preempted.
    
    If the guest PC had been advanced by SVC/HVC/SMC instructions before
    we caught the SError in hypervisor, we have to adjust the guest PC to
    exact address while the SError generated.
    
    About HSR_EC_SVC32/64, even thought we don't trap SVC32/64 today,
    we would like them to be handled here. This would be useful when
    VM introspection will gain support of SVC32/64 trapping.
    
    After updating HCR_EL2.VSE bit of vCPU HCR_EL2, write the value
    to HCR_EL2 immediately. In this case we don't need to move the
    restoration of HCR_EL2 to leave_hypervisor_tail, and it worked
    regardless of whether we get preempted.
    
    This helper will be used by the later patches in this series, we
    use #if 0 to disable it in this patch temporarily to remove the
    warning message of unused function from compiler.
    
    Signed-off-by: Wei Chen <Wei.Chen@xxxxxxx>
    Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
    Reviewed-by: Julien Grall <julien.grall@xxxxxxx>
---
 xen/arch/arm/traps.c            | 33 +++++++++++++++++++++++++++++++++
 xen/include/asm-arm/processor.h |  1 +
 2 files changed, 34 insertions(+)

diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index 35ca0ed..a24d986 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -639,6 +639,39 @@ static void inject_dabt_exception(struct cpu_user_regs 
*regs,
 #endif
 }
 
+#if 0
+/* Inject a virtual Abort/SError into the guest. */
+static void inject_vabt_exception(struct cpu_user_regs *regs)
+{
+    const union hsr hsr = { .bits = regs->hsr };
+
+    /*
+     * SVC/HVC/SMC already have an adjusted PC (See ARM ARM DDI 0487A.j
+     * D1.10.1 for more details), which we need to correct in order to
+     * return to after having injected the SError.
+     */
+    switch ( hsr.ec )
+    {
+    case HSR_EC_SVC32:
+    case HSR_EC_HVC32:
+    case HSR_EC_SMC32:
+#ifdef CONFIG_ARM_64
+    case HSR_EC_SVC64:
+    case HSR_EC_HVC64:
+    case HSR_EC_SMC64:
+#endif
+        regs->pc -= hsr.len ? 4 : 2;
+        break;
+
+    default:
+        break;
+    }
+
+    current->arch.hcr_el2 |= HCR_VA;
+    WRITE_SYSREG(current->arch.hcr_el2, HCR_EL2);
+}
+#endif
+
 struct reg_ctxt {
     /* Guest-side state */
     uint32_t sctlr_el1;
diff --git a/xen/include/asm-arm/processor.h b/xen/include/asm-arm/processor.h
index 4b6338b..d7b0711 100644
--- a/xen/include/asm-arm/processor.h
+++ b/xen/include/asm-arm/processor.h
@@ -252,6 +252,7 @@
 #define HSR_EC_HVC32                0x12
 #define HSR_EC_SMC32                0x13
 #ifdef CONFIG_ARM_64
+#define HSR_EC_SVC64                0x15
 #define HSR_EC_HVC64                0x16
 #define HSR_EC_SMC64                0x17
 #define HSR_EC_SYSREG               0x18
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.