Skip to contentSkip to conversation

x86/svm: adjust VM entry/exit code

PATCH New Jan Beulich 1 participant 1 message May 14, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/svm: adjust VM entry/exit code

Move saving of rAX into assembly code, to match its restoration. Simplify assembly code, at once reducing the delta between 32- and 64-bit variants. Eliminate save_svm_cpu_user_regs() - as on VMX all consumers are required to call hvm_store_cpu_guest_regs().

xen/arch/x86/hvm/svm/svm.c +1 -20
Index: 2007-05-14/xen/arch/x86/hvm/svm/svm.c
===================================================================
@@ -747,28 +747,10 @@ static void svm_init_hypercall_page(stru
     *(u16 *)(hypercall_page + (__HYPERVISOR_iret * 32)) = 0x0b0f; /* ud2 */
 }
 
-static void save_svm_cpu_user_regs(struct vcpu *v, struct cpu_user_regs *ctxt)
-{
-    struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
-
-    ctxt->eax = vmcb->rax;
-    ctxt->ss = vmcb->ss.sel;
-    ctxt->esp = vmcb->rsp;
-    ctxt->eflags = vmcb->rflags;
-    ctxt->cs = vmcb->cs.sel;
-    ctxt->eip = vmcb->rip;
-    
-    ctxt->gs = vmcb->gs.sel;
-    ctxt->fs = vmcb->fs.sel;
-    ctxt->es = vmcb->es.sel;
-    ctxt->ds = vmcb->ds.sel;
-}
-
 static void svm_load_cpu_guest_regs(struct vcpu *v, struct cpu_user_regs *regs)
 {
     struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
     
-    vmcb->rax      = regs->eax;
     vmcb->ss.sel   = regs->ss;
     vmcb->rsp      = regs->esp;   
     vmcb->rflags   = regs->eflags | 2UL;
@@ -1408,7 +1390,7 @@ static void svm_io_instruction(struct vc
 
     /* Copy current guest state into io instruction state structure. */
     memcpy(regs, guest_cpu_user_regs(), HVM_CONTEXT_STACK_BYTES);
-    hvm_store_cpu_guest_regs(v, regs, NULL);
+    svm_store_cpu_guest_regs(v, regs, NULL);
 
     info.bytes = vmcb->exitinfo1;
 
@@ -2236,7 +2218,6 @@ asmlinkage void svm_vmexit_handler(struc
     int inst_len, rc;
 
     exit_reason = vmcb->exitcode;
-    save_svm_cpu_user_regs(v, regs);
 
     HVMTRACE_2D(VMEXIT, v, vmcb->rip, exit_reason);
 
xen/arch/x86/hvm/svm/x86_32/exits.S +28 -32

107 lines not on this page · raw message

xen/arch/x86/hvm/svm/x86_64/exits.S +19 -29

94 lines not on this page · raw message