WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-3.2-testing] vmx realmode: Emulate MSR accesses.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-3.2-testing] vmx realmode: Emulate MSR accesses.
From: "Xen patchbot-3.2-testing" <patchbot-3.2-testing@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 07 Feb 2008 01:20:31 -0800
Delivery-date: Thu, 07 Feb 2008 01:20:47 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# 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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-3.2-testing] vmx realmode: Emulate MSR accesses., Xen patchbot-3.2-testing <=