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

[Xen-devel] [PATCH 12/15] xen: x86: reset EPC when guest got suspended.



EPC is destroyed when power state goes to S3-S5. Emulate this behavior.

A new function s3_suspend is added to hvm_function_table for this purpose.

Signed-off-by: Kai Huang <kai.huang@xxxxxxxxxxxxxxx>
---
 xen/arch/x86/hvm/hvm.c        | 3 +++
 xen/arch/x86/hvm/vmx/vmx.c    | 7 +++++++
 xen/include/asm-x86/hvm/hvm.h | 3 +++
 3 files changed, 13 insertions(+)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 70ddc81d44..1021cd7307 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -3858,6 +3858,9 @@ static void hvm_s3_suspend(struct domain *d)
 
     hvm_vcpu_reset_state(d->vcpu[0], 0xf000, 0xfff0);
 
+    if ( hvm_funcs.s3_suspend )
+        hvm_funcs.s3_suspend(d);
+
     domain_unlock(d);
 }
 
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index d0c43ea0c8..98c346178e 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -2290,6 +2290,12 @@ static bool vmx_get_pending_event(struct vcpu *v, struct 
x86_event *info)
     return true;
 }
 
+static void vmx_s3_suspend(struct domain *d)
+{
+    if ( domain_has_sgx(d) )
+        hvm_reset_epc(d, false);
+}
+
 static struct hvm_function_table __initdata vmx_function_table = {
     .name                 = "VMX",
     .cpu_up_prepare       = vmx_cpu_up_prepare,
@@ -2360,6 +2366,7 @@ static struct hvm_function_table __initdata 
vmx_function_table = {
         .max_ratio = VMX_TSC_MULTIPLIER_MAX,
         .setup     = vmx_setup_tsc_scaling,
     },
+    .s3_suspend = vmx_s3_suspend,
 };
 
 /* Handle VT-d posted-interrupt when VCPU is blocked. */
diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h
index b687e03dce..244b6566f2 100644
--- a/xen/include/asm-x86/hvm/hvm.h
+++ b/xen/include/asm-x86/hvm/hvm.h
@@ -226,6 +226,9 @@ struct hvm_function_table {
         /* Architecture function to setup TSC scaling ratio */
         void (*setup)(struct vcpu *v);
     } tsc_scaling;
+
+    /* Domain S3 suspend */
+    void (*s3_suspend)(struct domain *d);
 };
 
 extern struct hvm_function_table hvm_funcs;
-- 
2.11.0


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

 


Rackspace

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