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

[Xen-devel] [V0 PATCH] SVM: set/unset TF flag for single_step



Noticed on AMD (cpu family : 16, model : 2), that SVM does not honor
arch.hvm_vcpu.single_step flag.

When arch.hvm_vcpu.single_step is set on VMX, it sets MTF. Since there
is no MTF equivalent on AMD, it must set EFLAGS.TF.

Also strangely, when SVM VMEXIT_EXCEPTION_DB occurs, the TF flag is
not cleared. This patch addresses that too.

Signed-off-by: Mukesh Rathor <mukesh.rathor@xxxxxxxxxx>
---
 xen/arch/x86/hvm/svm/intr.c | 6 ++++++
 xen/arch/x86/hvm/svm/svm.c  | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/xen/arch/x86/hvm/svm/intr.c b/xen/arch/x86/hvm/svm/intr.c
index 023151a..28d2c6d 100644
--- a/xen/arch/x86/hvm/svm/intr.c
+++ b/xen/arch/x86/hvm/svm/intr.c
@@ -139,6 +139,12 @@ void svm_intr_assist(void)
     struct hvm_intack intack;
     enum hvm_intblk intblk;
 
+    if ( unlikely(v->arch.hvm_vcpu.single_step) )
+    {
+        guest_cpu_user_regs()->eflags |= X86_EFLAGS_TF;
+        return;
+    }
+
     /* Crank the handle on interrupt state. */
     pt_update_irq(v);
 
diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
index 76616ac..8addb94 100644
--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -2350,6 +2350,8 @@ void svm_vmexit_handler(struct cpu_user_regs *regs)
     case VMEXIT_EXCEPTION_DB:
         if ( !v->domain->debugger_attached )
             goto exit_and_crash;
+        else
+            regs->eflags &= ~X86_EFLAGS_TF;
         domain_pause_for_debugger();
         break;
 
-- 
1.8.3.1


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


 


Rackspace

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