[xen-unstable] vmx realmode: Emulate writes to control registers.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[xen-unstable] vmx realmode: Emulate writes to control registers.

Xen patchbot-unstable
# HG changeset patch
# User Keir Fraser <[hidden email]>
# Date 1196099723 0
# Node ID 4d6f92fa1014101fff9f01bb3998ca57b139c9b5
# Parent  f676c0dacbb95c69ad5a3e18ed0ea242a52366f7
vmx realmode: Emulate writes to control registers.
Signed-off-by: Keir Fraser <[hidden email]>
---
 xen/arch/x86/hvm/vmx/realmode.c |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+)

diff -r f676c0dacbb9 -r 4d6f92fa1014 xen/arch/x86/hvm/vmx/realmode.c
--- a/xen/arch/x86/hvm/vmx/realmode.c Mon Nov 26 17:54:54 2007 +0000
+++ b/xen/arch/x86/hvm/vmx/realmode.c Mon Nov 26 17:55:23 2007 +0000
@@ -338,6 +338,36 @@ realmode_read_cr(
     return X86EMUL_OKAY;
 }
 
+static int
+realmode_write_cr(
+    unsigned int reg,
+    unsigned long val,
+    struct x86_emulate_ctxt *ctxt)
+{
+    switch ( reg )
+    {
+    case 0:
+        if ( !hvm_set_cr0(val) )
+            return X86EMUL_UNHANDLEABLE;
+        break;
+    case 2:
+        current->arch.hvm_vcpu.guest_cr[2] = val;
+        break;
+    case 3:
+        if ( !hvm_set_cr3(val) )
+            return X86EMUL_UNHANDLEABLE;
+        break;
+    case 4:
+        if ( !hvm_set_cr4(val) )
+            return X86EMUL_UNHANDLEABLE;
+        break;
+    default:
+        return X86EMUL_UNHANDLEABLE;
+    }
+
+    return X86EMUL_OKAY;
+}
+
 static int realmode_write_rflags(
     unsigned long val,
     struct x86_emulate_ctxt *ctxt)
@@ -412,6 +442,7 @@ static struct x86_emulate_ops realmode_e
     .read_io       = realmode_read_io,
     .write_io      = realmode_write_io,
     .read_cr       = realmode_read_cr,
+    .write_cr      = realmode_write_cr,
     .write_rflags  = realmode_write_rflags,
     .wbinvd        = realmode_wbinvd,
     .cpuid         = realmode_cpuid,

_______________________________________________
Xen-changelog mailing list
[hidden email]
http://lists.xensource.com/xen-changelog