From: kaf24@firebug.cl.cam.ac.uk Date: Tue, 27 Jun 2006 08:54:05 +0000 (+0100) Subject: [HVM][VMX] On a VMEXIT, 'dirty' the DR. Restore DR from vcpu struct, X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~15913^2~31 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=710f23ac8c09807a9a01a82cc226b9df53f82ba8;p=xen.git [HVM][VMX] On a VMEXIT, 'dirty' the DR. Restore DR from vcpu struct, disable DR exiting (i.e., enable guest DR access), set VCPUF_dr_dirtied. Remove "emulated" DR access, which only read and wrote to the debug register values of the context, but not to the actual hardware values themselves. Signed-off-by: George Dunlap --- diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 07792d2918..e40b76ecb5 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -926,55 +926,20 @@ static void vmx_vmexit_do_cpuid(struct cpu_user_regs *regs) CASE_GET_REG_P(R15, r15) #endif -static void vmx_dr_access (unsigned long exit_qualification, struct cpu_user_regs *regs) +static void vmx_dr_access(unsigned long exit_qualification, + struct cpu_user_regs *regs) { - unsigned int reg; - unsigned long *reg_p = 0; struct vcpu *v = current; - unsigned long eip; - __vmread(GUEST_RIP, &eip); + v->arch.hvm_vcpu.flag_dr_dirty = 1; - reg = exit_qualification & DEBUG_REG_ACCESS_NUM; - - HVM_DBG_LOG(DBG_LEVEL_1, - "vmx_dr_access : eip=%lx, reg=%d, exit_qualification = %lx", - eip, reg, exit_qualification); - - switch ( exit_qualification & DEBUG_REG_ACCESS_REG ) { - CASE_GET_REG_P(EAX, eax); - CASE_GET_REG_P(ECX, ecx); - CASE_GET_REG_P(EDX, edx); - CASE_GET_REG_P(EBX, ebx); - CASE_GET_REG_P(EBP, ebp); - CASE_GET_REG_P(ESI, esi); - CASE_GET_REG_P(EDI, edi); - CASE_EXTEND_GET_REG_P; - case REG_ESP: - break; - default: - __hvm_bug(regs); - } + /* We could probably be smarter about this */ + __restore_debug_registers(v); - switch (exit_qualification & DEBUG_REG_ACCESS_TYPE) { - case TYPE_MOV_TO_DR: - /* don't need to check the range */ - if (reg != REG_ESP) - v->arch.guest_context.debugreg[reg] = *reg_p; - else { - unsigned long value; - __vmread(GUEST_RSP, &value); - v->arch.guest_context.debugreg[reg] = value; - } - break; - case TYPE_MOV_FROM_DR: - if (reg != REG_ESP) - *reg_p = v->arch.guest_context.debugreg[reg]; - else { - __vmwrite(GUEST_RSP, v->arch.guest_context.debugreg[reg]); - } - break; - } + /* Allow guest direct access to DR registers */ + v->arch.hvm_vcpu.u.vmx.exec_control &= ~CPU_BASED_MOV_DR_EXITING; + __vmwrite(CPU_BASED_VM_EXEC_CONTROL, + v->arch.hvm_vcpu.u.vmx.exec_control); } /*