debuggers.hg

changeset 21137:0bbf5454cd14

hvm: merge efer check

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Apr 01 09:47:49 2010 +0100 (2010-04-01)
parents e5e1e1532b97
children 537451477469
files xen/arch/x86/hvm/hvm.c
line diff
     1.1 --- a/xen/arch/x86/hvm/hvm.c	Wed Mar 31 10:21:19 2010 +0100
     1.2 +++ b/xen/arch/x86/hvm/hvm.c	Thu Apr 01 09:47:49 2010 +0100
     1.3 @@ -583,6 +583,16 @@ static int hvm_save_cpu_ctxt(struct doma
     1.4      return 0;
     1.5  }
     1.6  
     1.7 +static bool_t hvm_efer_valid(uint64_t value, uint64_t efer_validbits)
     1.8 +{
     1.9 +    return !((value & ~efer_validbits) ||
    1.10 +             ((sizeof(long) != 8) && (value & EFER_LME)) ||
    1.11 +             (!cpu_has_nx && (value & EFER_NX)) ||
    1.12 +             (!cpu_has_syscall && (value & EFER_SCE)) ||
    1.13 +             (!cpu_has_ffxsr && (value & EFER_FFXSE)) ||
    1.14 +             ((value & (EFER_LME|EFER_LMA)) == EFER_LMA));
    1.15 +}
    1.16 +
    1.17  static int hvm_load_cpu_ctxt(struct domain *d, hvm_domain_context_t *h)
    1.18  {
    1.19      int vcpuid, rc;
    1.20 @@ -629,13 +639,8 @@ static int hvm_load_cpu_ctxt(struct doma
    1.21          return -EINVAL;
    1.22      }
    1.23  
    1.24 -    if ( (ctxt.msr_efer & ~(EFER_FFXSE | EFER_LME | EFER_LMA |
    1.25 -                            EFER_NX | EFER_SCE)) ||
    1.26 -         ((sizeof(long) != 8) && (ctxt.msr_efer & EFER_LME)) ||
    1.27 -         (!cpu_has_nx && (ctxt.msr_efer & EFER_NX)) ||
    1.28 -         (!cpu_has_syscall && (ctxt.msr_efer & EFER_SCE)) ||
    1.29 -         (!cpu_has_ffxsr && (ctxt.msr_efer & EFER_FFXSE)) ||
    1.30 -         ((ctxt.msr_efer & (EFER_LME|EFER_LMA)) == EFER_LMA) )
    1.31 +    if ( !hvm_efer_valid(
    1.32 +        ctxt.msr_efer, EFER_FFXSE | EFER_LME | EFER_LMA | EFER_NX | EFER_SCE) )
    1.33      {
    1.34          gdprintk(XENLOG_ERR, "HVM restore: bad EFER 0x%"PRIx64"\n",
    1.35                   ctxt.msr_efer);
    1.36 @@ -984,11 +989,7 @@ int hvm_set_efer(uint64_t value)
    1.37  
    1.38      value &= ~EFER_LMA;
    1.39  
    1.40 -    if ( (value & ~(EFER_FFXSE | EFER_LME | EFER_NX | EFER_SCE)) ||
    1.41 -         ((sizeof(long) != 8) && (value & EFER_LME)) ||
    1.42 -         (!cpu_has_nx && (value & EFER_NX)) ||
    1.43 -         (!cpu_has_syscall && (value & EFER_SCE)) ||
    1.44 -         (!cpu_has_ffxsr && (value & EFER_FFXSE)) )
    1.45 +    if ( !hvm_efer_valid(value, EFER_FFXSE | EFER_LME | EFER_NX | EFER_SCE) )
    1.46      {
    1.47          gdprintk(XENLOG_WARNING, "Trying to set reserved bit in "
    1.48                   "EFER: %"PRIx64"\n", value);