ia64/xen-unstable

changeset 16482:4d6f92fa1014

vmx realmode: Emulate writes to control registers.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Nov 26 17:55:23 2007 +0000 (2007-11-26)
parents f676c0dacbb9
children f9a43c6b5be1
files xen/arch/x86/hvm/vmx/realmode.c
line diff
     1.1 --- a/xen/arch/x86/hvm/vmx/realmode.c	Mon Nov 26 17:54:54 2007 +0000
     1.2 +++ b/xen/arch/x86/hvm/vmx/realmode.c	Mon Nov 26 17:55:23 2007 +0000
     1.3 @@ -338,6 +338,36 @@ realmode_read_cr(
     1.4      return X86EMUL_OKAY;
     1.5  }
     1.6  
     1.7 +static int
     1.8 +realmode_write_cr(
     1.9 +    unsigned int reg,
    1.10 +    unsigned long val,
    1.11 +    struct x86_emulate_ctxt *ctxt)
    1.12 +{
    1.13 +    switch ( reg )
    1.14 +    {
    1.15 +    case 0:
    1.16 +        if ( !hvm_set_cr0(val) )
    1.17 +            return X86EMUL_UNHANDLEABLE;
    1.18 +        break;
    1.19 +    case 2:
    1.20 +        current->arch.hvm_vcpu.guest_cr[2] = val;
    1.21 +        break;
    1.22 +    case 3:
    1.23 +        if ( !hvm_set_cr3(val) )
    1.24 +            return X86EMUL_UNHANDLEABLE;
    1.25 +        break;
    1.26 +    case 4:
    1.27 +        if ( !hvm_set_cr4(val) )
    1.28 +            return X86EMUL_UNHANDLEABLE;
    1.29 +        break;
    1.30 +    default:
    1.31 +        return X86EMUL_UNHANDLEABLE;
    1.32 +    }
    1.33 +
    1.34 +    return X86EMUL_OKAY;
    1.35 +}
    1.36 +
    1.37  static int realmode_write_rflags(
    1.38      unsigned long val,
    1.39      struct x86_emulate_ctxt *ctxt)
    1.40 @@ -412,6 +442,7 @@ static struct x86_emulate_ops realmode_e
    1.41      .read_io       = realmode_read_io,
    1.42      .write_io      = realmode_write_io,
    1.43      .read_cr       = realmode_read_cr,
    1.44 +    .write_cr      = realmode_write_cr,
    1.45      .write_rflags  = realmode_write_rflags,
    1.46      .wbinvd        = realmode_wbinvd,
    1.47      .cpuid         = realmode_cpuid,