[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-3.2-testing] vmx realmode: Emulate MSR accesses.
# HG changeset patch # User Keir Fraser <keir.fraser@xxxxxxxxxx> # Date 1202291759 0 # Node ID 12c2fba8e6419b2cc847b60ecca8ae7fae66fee4 # Parent 985bae80b6d7aa87e589e59b376f52a5000eaa64 vmx realmode: Emulate MSR accesses. Signed-off-by: Nitin A Kamble <nitin.a.kamble@xxxxxxxxx> Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx> xen-unstable changeset: 16949:0d70e01c0012a0830334e99ad6e5c4ddac36329a xen-unstable date: Thu Jan 31 09:33:26 2008 +0000 Fix x86/64 Xen build. Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx> xen-unstable changeset: 16954:938446025b5b8fd8719f9796fd556a0e811bdca6 xen-unstable date: Thu Jan 31 11:05:14 2008 +0000 --- xen/arch/x86/hvm/vmx/realmode.c | 51 ++++++++++++++++++++++++++++++++++++++ xen/arch/x86/hvm/vmx/vmx.c | 8 ++--- xen/include/asm-x86/hvm/vmx/vmx.h | 2 + 3 files changed, 57 insertions(+), 4 deletions(-) diff -r 985bae80b6d7 -r 12c2fba8e641 xen/arch/x86/hvm/vmx/realmode.c --- a/xen/arch/x86/hvm/vmx/realmode.c Wed Feb 06 09:54:39 2008 +0000 +++ b/xen/arch/x86/hvm/vmx/realmode.c Wed Feb 06 09:55:59 2008 +0000 @@ -410,6 +410,55 @@ realmode_write_cr( return X86EMUL_OKAY; } +static int +realmode_read_msr( + unsigned long reg, + uint64_t *val, + struct x86_emulate_ctxt *ctxt) +{ + struct cpu_user_regs _regs; + + _regs.ecx = (uint32_t)reg; + + if ( !vmx_msr_read_intercept(&_regs) ) + { + struct realmode_emulate_ctxt *rm_ctxt = + container_of(ctxt, struct realmode_emulate_ctxt, ctxt); + rm_ctxt->exn_vector = (uint8_t)__vmread(VM_ENTRY_INTR_INFO); + rm_ctxt->exn_insn_len = 0; + __vmwrite(VM_ENTRY_INTR_INFO, 0); + return X86EMUL_EXCEPTION; + } + + *val = ((uint64_t)(uint32_t)_regs.edx << 32) || (uint32_t)_regs.eax; + return X86EMUL_OKAY; +} + +static int +realmode_write_msr( + unsigned long reg, + uint64_t val, + struct x86_emulate_ctxt *ctxt) +{ + struct cpu_user_regs _regs; + + _regs.edx = (uint32_t)(val >> 32); + _regs.eax = (uint32_t)val; + _regs.ecx = (uint32_t)reg; + + if ( !vmx_msr_write_intercept(&_regs) ) + { + struct realmode_emulate_ctxt *rm_ctxt = + container_of(ctxt, struct realmode_emulate_ctxt, ctxt); + rm_ctxt->exn_vector = (uint8_t)__vmread(VM_ENTRY_INTR_INFO); + rm_ctxt->exn_insn_len = 0; + __vmwrite(VM_ENTRY_INTR_INFO, 0); + return X86EMUL_EXCEPTION; + } + + return X86EMUL_OKAY; +} + static int realmode_write_rflags( unsigned long val, struct x86_emulate_ctxt *ctxt) @@ -495,6 +544,8 @@ static struct x86_emulate_ops realmode_e .write_io = realmode_write_io, .read_cr = realmode_read_cr, .write_cr = realmode_write_cr, + .read_msr = realmode_read_msr, + .write_msr = realmode_write_msr, .write_rflags = realmode_write_rflags, .wbinvd = realmode_wbinvd, .cpuid = realmode_cpuid, diff -r 985bae80b6d7 -r 12c2fba8e641 xen/arch/x86/hvm/vmx/vmx.c --- a/xen/arch/x86/hvm/vmx/vmx.c Wed Feb 06 09:54:39 2008 +0000 +++ b/xen/arch/x86/hvm/vmx/vmx.c Wed Feb 06 09:55:59 2008 +0000 @@ -2305,7 +2305,7 @@ static int is_last_branch_msr(u32 ecx) return 0; } -static int vmx_do_msr_read(struct cpu_user_regs *regs) +int vmx_msr_read_intercept(struct cpu_user_regs *regs) { u64 msr_content = 0; u32 ecx = regs->ecx, eax, edx; @@ -2489,7 +2489,7 @@ extern bool_t mtrr_def_type_msr_set(stru extern bool_t mtrr_def_type_msr_set(struct mtrr_state *v, u64 msr_content); extern bool_t pat_msr_set(u64 *pat, u64 msr); -static int vmx_do_msr_write(struct cpu_user_regs *regs) +int vmx_msr_write_intercept(struct cpu_user_regs *regs) { u32 ecx = regs->ecx; u64 msr_content; @@ -2925,12 +2925,12 @@ asmlinkage void vmx_vmexit_handler(struc break; case EXIT_REASON_MSR_READ: inst_len = __get_instruction_length(); /* Safe: RDMSR */ - if ( vmx_do_msr_read(regs) ) + if ( vmx_msr_read_intercept(regs) ) __update_guest_eip(inst_len); break; case EXIT_REASON_MSR_WRITE: inst_len = __get_instruction_length(); /* Safe: WRMSR */ - if ( vmx_do_msr_write(regs) ) + if ( vmx_msr_write_intercept(regs) ) __update_guest_eip(inst_len); break; diff -r 985bae80b6d7 -r 12c2fba8e641 xen/include/asm-x86/hvm/vmx/vmx.h --- a/xen/include/asm-x86/hvm/vmx/vmx.h Wed Feb 06 09:54:39 2008 +0000 +++ b/xen/include/asm-x86/hvm/vmx/vmx.h Wed Feb 06 09:55:59 2008 +0000 @@ -37,6 +37,8 @@ void vmx_cpuid_intercept( void vmx_cpuid_intercept( unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx); +int vmx_msr_read_intercept(struct cpu_user_regs *regs); +int vmx_msr_write_intercept(struct cpu_user_regs *regs); void vmx_wbinvd_intercept(void); void vmx_realmode(struct cpu_user_regs *regs); int vmx_realmode_io_complete(void); _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |