ia64/xen-unstable

changeset 8446:829517be689f

Modify CR0 access emulation -- return physical CR0 (except
for TS) and allow only the same physical flags to be written
back to CR0 by a guest.

Add write-to-CR4 emulation, but check that the write does not
modify any CR4 flags.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Dec 23 16:42:46 2005 +0100 (2005-12-23)
parents 87e5ac90a8df
children 5fa0c70663f1
files xen/arch/x86/traps.c
line diff
     1.1 --- a/xen/arch/x86/traps.c	Fri Dec 23 09:12:41 2005 +0000
     1.2 +++ b/xen/arch/x86/traps.c	Fri Dec 23 16:42:46 2005 +0100
     1.3 @@ -885,7 +885,8 @@ static int emulate_privileged_op(struct 
     1.4          switch ( modrm_reg )
     1.5          {
     1.6          case 0: /* Read CR0 */
     1.7 -            *reg = v->arch.guest_context.ctrlreg[0];
     1.8 +            *reg = (read_cr0() & ~X86_CR0_TS) |
     1.9 +                v->arch.guest_context.ctrlreg[0];
    1.10              break;
    1.11  
    1.12          case 2: /* Read CR2 */
    1.13 @@ -927,6 +928,11 @@ static int emulate_privileged_op(struct 
    1.14          switch ( modrm_reg )
    1.15          {
    1.16          case 0: /* Write CR0 */
    1.17 +            if ( (*reg ^ read_cr0()) & ~X86_CR0_TS )
    1.18 +            {
    1.19 +                DPRINTK("Attempt to change unmodifiable CR0 flags.\n");
    1.20 +                goto fail;
    1.21 +            }
    1.22              (void)do_fpu_taskswitch(!!(*reg & X86_CR0_TS));
    1.23              break;
    1.24  
    1.25 @@ -941,6 +947,14 @@ static int emulate_privileged_op(struct 
    1.26              UNLOCK_BIGLOCK(v->domain);
    1.27              break;
    1.28  
    1.29 +        case 4:
    1.30 +            if ( *reg != (read_cr4() & ~(X86_CR4_PGE|X86_CR4_PSE)) )
    1.31 +            {
    1.32 +                DPRINTK("Attempt to change CR4 flags.\n");
    1.33 +                goto fail;
    1.34 +            }
    1.35 +            break;
    1.36 +
    1.37          default:
    1.38              goto fail;
    1.39          }