[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 09 of 20] Emulation of guest VMCLEAR
# HG changeset patch # User Eddie Dong <eddie.dong@xxxxxxxxx> # Date 1307003600 -28800 # Node ID 35cc736e8a75a0a349790871232f8761ceae41be # Parent 54332433d873777e57e6ac47ee841a2a96c2f543 Emulation of guest VMCLEAR Signed-off-by: Qing He <qing.he@xxxxxxxxx> Signed-off-by: Eddie Dong <eddie.dong@xxxxxxxxx> diff -r 54332433d873 -r 35cc736e8a75 xen/arch/x86/hvm/vmx/vmx.c --- a/xen/arch/x86/hvm/vmx/vmx.c Thu Jun 02 16:33:20 2011 +0800 +++ b/xen/arch/x86/hvm/vmx/vmx.c Thu Jun 02 16:33:20 2011 +0800 @@ -2444,6 +2444,11 @@ asmlinkage void vmx_vmexit_handler(struc update_guest_eip(); break; + case EXIT_REASON_VMCLEAR: + if ( nvmx_handle_vmclear(regs) == X86EMUL_OKAY ) + update_guest_eip(); + break; + case EXIT_REASON_VMPTRLD: if ( nvmx_handle_vmptrld(regs) == X86EMUL_OKAY ) update_guest_eip(); @@ -2456,7 +2461,6 @@ asmlinkage void vmx_vmexit_handler(struc case EXIT_REASON_MWAIT_INSTRUCTION: case EXIT_REASON_MONITOR_INSTRUCTION: - case EXIT_REASON_VMCLEAR: case EXIT_REASON_VMLAUNCH: case EXIT_REASON_VMREAD: case EXIT_REASON_VMRESUME: diff -r 54332433d873 -r 35cc736e8a75 xen/arch/x86/hvm/vmx/vvmx.c --- a/xen/arch/x86/hvm/vmx/vvmx.c Thu Jun 02 16:33:20 2011 +0800 +++ b/xen/arch/x86/hvm/vmx/vvmx.c Thu Jun 02 16:33:20 2011 +0800 @@ -356,6 +356,14 @@ static void vmreturn(struct cpu_user_reg regs->eflags = eflags; } +static void __clear_current_vvmcs(struct vcpu *v) +{ + struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v); + + if ( nvcpu->nv_n2vmcx ) + __vmpclear(virt_to_maddr(nvcpu->nv_n2vmcx)); +} + static void __map_io_bitmap(struct vcpu *v, u64 vmcs_reg) { struct nestedvmx *nvmx = &vcpu_2_nvmx(v); @@ -391,6 +399,26 @@ static inline void map_io_bitmap_all(str __map_io_bitmap (v, IO_BITMAP_B); } +static void nvmx_purge_vvmcs(struct vcpu *v) +{ + struct nestedvmx *nvmx = &vcpu_2_nvmx(v); + struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v); + + __clear_current_vvmcs(v); + if ( nvcpu->nv_vvmcxaddr != VMCX_EADDR ) + unmap_domain_page_global(nvcpu->nv_vvmcx); + nvcpu->nv_vvmcx == NULL; + nvcpu->nv_vvmcxaddr = VMCX_EADDR; + if ( nvmx->iobitmap[0] ) { + unmap_domain_page_global(nvmx->iobitmap[0]); + nvmx->iobitmap[0] = NULL; + } + if ( nvmx->iobitmap[1] ) { + unmap_domain_page_global(nvmx->iobitmap[1]); + nvmx->iobitmap[1] = NULL; + } +} + /* * VMX instructions handling */ @@ -439,6 +467,7 @@ int nvmx_handle_vmxoff(struct cpu_user_r if ( rc != X86EMUL_OKAY ) return rc; + nvmx_purge_vvmcs(v); nvmx->vmxon_region_pa = 0; vmreturn(regs, VMSUCCEED); @@ -465,6 +494,9 @@ int nvmx_handle_vmptrld(struct cpu_user_ goto out; } + if ( nvcpu->nv_vvmcxaddr != gpa ) + nvmx_purge_vvmcs(v); + if ( nvcpu->nv_vvmcxaddr == VMCX_EADDR ) { mfn = mfn_x(gfn_to_mfn(p2m_get_hostp2m(v->domain), @@ -502,3 +534,37 @@ int nvmx_handle_vmptrst(struct cpu_user_ return X86EMUL_OKAY; } +int nvmx_handle_vmclear(struct cpu_user_regs *regs) +{ + struct vcpu *v = current; + struct vmx_inst_decoded decode; + struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v); + unsigned long gpa = 0; + int rc; + + rc = decode_vmx_inst(regs, &decode, &gpa, 0); + if ( rc != X86EMUL_OKAY ) + return rc; + + if ( gpa & 0xfff ) + { + vmreturn(regs, VMFAIL_INVALID); + goto out; + } + + if ( gpa != nvcpu->nv_vvmcxaddr && nvcpu->nv_vvmcxaddr != VMCX_EADDR ) + { + gdprintk(XENLOG_WARNING, + "vmclear gpa %lx not the same with current vmcs %lx\n", + gpa, nvcpu->nv_vvmcxaddr); + vmreturn(regs, VMSUCCEED); + goto out; + } + nvmx_purge_vvmcs(v); + + vmreturn(regs, VMSUCCEED); + +out: + return X86EMUL_OKAY; +} + diff -r 54332433d873 -r 35cc736e8a75 xen/include/asm-x86/hvm/vmx/vvmx.h --- a/xen/include/asm-x86/hvm/vmx/vvmx.h Thu Jun 02 16:33:20 2011 +0800 +++ b/xen/include/asm-x86/hvm/vmx/vvmx.h Thu Jun 02 16:33:20 2011 +0800 @@ -155,6 +155,7 @@ void __set_vvmcs(void *vvmcs, u32 vmcs_e void nvmx_destroy_vmcs(struct vcpu *v); int nvmx_handle_vmptrld(struct cpu_user_regs *regs); int nvmx_handle_vmptrst(struct cpu_user_regs *regs); +int nvmx_handle_vmclear(struct cpu_user_regs *regs); #endif /* __ASM_X86_HVM_VVMX_H__ */ _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |