ia64/xen-unstable

changeset 19430:0477f9061c8a

x86: Build fixes and cleanups after Intel MCA changes.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Mar 20 17:42:46 2009 +0000 (2009-03-20)
parents 891af2c54155
children 0b13d9787622
files xen/arch/x86/cpu/mcheck/mce_intel.c xen/arch/x86/traps.c
line diff
     1.1 --- a/xen/arch/x86/cpu/mcheck/mce_intel.c	Fri Mar 20 17:25:29 2009 +0000
     1.2 +++ b/xen/arch/x86/cpu/mcheck/mce_intel.c	Fri Mar 20 17:42:46 2009 +0000
     1.3 @@ -256,7 +256,7 @@ static int fill_vmsr_data(int cpu, struc
     1.4          d->arch.vmca_msrs.nr_injection++;
     1.5  
     1.6          printk(KERN_DEBUG "MCE: Found error @[CPU%d BANK%d "
     1.7 -                "status %lx addr %lx domid %d]\n ",
     1.8 +                "status %"PRIx64" addr %"PRIx64" domid %d]\n ",
     1.9                  entry->cpu, mc_bank->mc_bank,
    1.10                  mc_bank->mc_status, mc_bank->mc_addr, mc_bank->mc_domid);
    1.11      }
    1.12 @@ -292,7 +292,7 @@ static int mce_actions(void) {
    1.13          if (mic == NULL) {
    1.14              printk(KERN_ERR "MCE: get local buffer entry failed\n ");
    1.15              ret = -1;
    1.16 -       	    goto end;
    1.17 +            goto end;
    1.18          }
    1.19  
    1.20          mc_global = (struct mcinfo_global *)mic;
    1.21 @@ -819,94 +819,97 @@ int intel_mce_wrmsr(u32 msr, u32 lo, u32
    1.22      struct domain *d = current->domain;
    1.23      struct bank_entry *entry = NULL;
    1.24      uint64_t value = (u64)hi << 32 | lo;
    1.25 -    int ret = 0;
    1.26 +    int ret = 1;
    1.27  
    1.28      spin_lock(&mce_locks);
    1.29      switch(msr)
    1.30      {
    1.31 -        case MSR_IA32_MCG_CTL:
    1.32 -            if (value != (u64)~0x0 && value != 0x0) {
    1.33 -                printk(KERN_ERR "MCE: value writen to MCG_CTL"
    1.34 -                    "should be all 0s or 1s\n");
    1.35 -                ret = -1;
    1.36 -                break;
    1.37 -            }
    1.38 -            if (!d || is_idle_domain(d)) {
    1.39 -                printk(KERN_ERR "MCE: wrmsr not in DOM context, skip\n");
    1.40 -                break;
    1.41 -            }
    1.42 -            d->arch.vmca_msrs.mcg_ctl = value;
    1.43 +    case MSR_IA32_MCG_CTL:
    1.44 +        if (value != (u64)~0x0 && value != 0x0) {
    1.45 +            gdprintk(XENLOG_WARNING, "MCE: value writen to MCG_CTL"
    1.46 +                     "should be all 0s or 1s\n");
    1.47 +            ret = -1;
    1.48              break;
    1.49 -        case MSR_IA32_MCG_STATUS:
    1.50 -            if (!d || is_idle_domain(d)) {
    1.51 -                printk(KERN_ERR "MCE: wrmsr not in DOM context, skip\n");
    1.52 -                break;
    1.53 -            }
    1.54 -            d->arch.vmca_msrs.mcg_status = value;
    1.55 -            printk(KERN_DEBUG "MCE: wrmsr MCG_CTL %lx\n", value);
    1.56 +        }
    1.57 +        if (!d || is_idle_domain(d)) {
    1.58 +            gdprintk(XENLOG_WARNING, "MCE: wrmsr not in DOM context, skip\n");
    1.59              break;
    1.60 -        case MSR_IA32_MC0_CTL2:
    1.61 -        case MSR_IA32_MC1_CTL2:
    1.62 -        case MSR_IA32_MC2_CTL2:
    1.63 -        case MSR_IA32_MC3_CTL2:
    1.64 -        case MSR_IA32_MC4_CTL2:
    1.65 -        case MSR_IA32_MC5_CTL2:
    1.66 -        case MSR_IA32_MC6_CTL2:
    1.67 -        case MSR_IA32_MC7_CTL2:
    1.68 -        case MSR_IA32_MC8_CTL2:
    1.69 -            printk(KERN_ERR "We have disabled CMCI capability, "
    1.70 -                    "Guest should not write this MSR!\n");
    1.71 +        }
    1.72 +        d->arch.vmca_msrs.mcg_ctl = value;
    1.73 +        break;
    1.74 +    case MSR_IA32_MCG_STATUS:
    1.75 +        if (!d || is_idle_domain(d)) {
    1.76 +            gdprintk(XENLOG_WARNING, "MCE: wrmsr not in DOM context, skip\n");
    1.77              break;
    1.78 -        case MSR_IA32_MC0_CTL:
    1.79 -        case MSR_IA32_MC1_CTL:
    1.80 -        case MSR_IA32_MC2_CTL:
    1.81 -        case MSR_IA32_MC3_CTL:
    1.82 -        case MSR_IA32_MC4_CTL:
    1.83 -        case MSR_IA32_MC5_CTL:
    1.84 -        case MSR_IA32_MC6_CTL:
    1.85 -        case MSR_IA32_MC7_CTL:
    1.86 -        case MSR_IA32_MC8_CTL:
    1.87 -            if (value != (u64)~0x0 && value != 0x0) {
    1.88 -                printk(KERN_ERR "MCE: value writen to MCi_CTL"
    1.89 -                    "should be all 0s or 1s\n");
    1.90 -                ret = -1;
    1.91 -                break;
    1.92 -            }
    1.93 -            if (!d || is_idle_domain(d)) {
    1.94 -                printk(KERN_ERR "MCE: wrmsr not in DOM context, skip\n");
    1.95 -                break;
    1.96 -            }
    1.97 -            d->arch.vmca_msrs.mci_ctl[(msr - MSR_IA32_MC0_CTL)/4] = value;
    1.98 +        }
    1.99 +        d->arch.vmca_msrs.mcg_status = value;
   1.100 +        gdprintk(XENLOG_DEBUG, "MCE: wrmsr MCG_CTL %"PRIx64"\n", value);
   1.101 +        break;
   1.102 +    case MSR_IA32_MC0_CTL2:
   1.103 +    case MSR_IA32_MC1_CTL2:
   1.104 +    case MSR_IA32_MC2_CTL2:
   1.105 +    case MSR_IA32_MC3_CTL2:
   1.106 +    case MSR_IA32_MC4_CTL2:
   1.107 +    case MSR_IA32_MC5_CTL2:
   1.108 +    case MSR_IA32_MC6_CTL2:
   1.109 +    case MSR_IA32_MC7_CTL2:
   1.110 +    case MSR_IA32_MC8_CTL2:
   1.111 +        gdprintk(XENLOG_WARNING, "We have disabled CMCI capability, "
   1.112 +                 "Guest should not write this MSR!\n");
   1.113 +        break;
   1.114 +    case MSR_IA32_MC0_CTL:
   1.115 +    case MSR_IA32_MC1_CTL:
   1.116 +    case MSR_IA32_MC2_CTL:
   1.117 +    case MSR_IA32_MC3_CTL:
   1.118 +    case MSR_IA32_MC4_CTL:
   1.119 +    case MSR_IA32_MC5_CTL:
   1.120 +    case MSR_IA32_MC6_CTL:
   1.121 +    case MSR_IA32_MC7_CTL:
   1.122 +    case MSR_IA32_MC8_CTL:
   1.123 +        if (value != (u64)~0x0 && value != 0x0) {
   1.124 +            gdprintk(XENLOG_WARNING, "MCE: value writen to MCi_CTL"
   1.125 +                     "should be all 0s or 1s\n");
   1.126 +            ret = -1;
   1.127 +            break;
   1.128 +        }
   1.129 +        if (!d || is_idle_domain(d)) {
   1.130 +            gdprintk(XENLOG_WARNING, "MCE: wrmsr not in DOM context, skip\n");
   1.131              break;
   1.132 -        case MSR_IA32_MC0_STATUS:
   1.133 -        case MSR_IA32_MC1_STATUS:
   1.134 -        case MSR_IA32_MC2_STATUS:
   1.135 -        case MSR_IA32_MC3_STATUS:
   1.136 -        case MSR_IA32_MC4_STATUS:
   1.137 -        case MSR_IA32_MC5_STATUS:
   1.138 -        case MSR_IA32_MC6_STATUS:
   1.139 -        case MSR_IA32_MC7_STATUS:
   1.140 -        case MSR_IA32_MC8_STATUS:
   1.141 -            if (!d || is_idle_domain(d)) {
   1.142 -                /* Just skip */
   1.143 -                printk(KERN_ERR "mce wrmsr: not in domain context!\n");
   1.144 -                break;
   1.145 +        }
   1.146 +        d->arch.vmca_msrs.mci_ctl[(msr - MSR_IA32_MC0_CTL)/4] = value;
   1.147 +        break;
   1.148 +    case MSR_IA32_MC0_STATUS:
   1.149 +    case MSR_IA32_MC1_STATUS:
   1.150 +    case MSR_IA32_MC2_STATUS:
   1.151 +    case MSR_IA32_MC3_STATUS:
   1.152 +    case MSR_IA32_MC4_STATUS:
   1.153 +    case MSR_IA32_MC5_STATUS:
   1.154 +    case MSR_IA32_MC6_STATUS:
   1.155 +    case MSR_IA32_MC7_STATUS:
   1.156 +    case MSR_IA32_MC8_STATUS:
   1.157 +        if (!d || is_idle_domain(d)) {
   1.158 +            /* Just skip */
   1.159 +            gdprintk(XENLOG_WARNING, "mce wrmsr: not in domain context!\n");
   1.160 +            break;
   1.161 +        }
   1.162 +        /* Give the first entry of the list, it corresponds to current
   1.163 +         * vMCE# injection. When vMCE# is finished processing by the
   1.164 +         * the guest, this node will be deleted.
   1.165 +         * Only error bank is written. Non-error bank simply return.
   1.166 +         */
   1.167 +        if ( !list_empty(&d->arch.vmca_msrs.impact_header) ) {
   1.168 +            entry = list_entry(d->arch.vmca_msrs.impact_header.next,
   1.169 +                               struct bank_entry, list);
   1.170 +            if ( entry->bank == (msr - MSR_IA32_MC0_STATUS)/4 ) {
   1.171 +                entry->mci_status = value;
   1.172              }
   1.173 -            /* Give the first entry of the list, it corresponds to current
   1.174 -             * vMCE# injection. When vMCE# is finished processing by the
   1.175 -             * the guest, this node will be deleted.
   1.176 -             * Only error bank is written. Non-error bank simply return.
   1.177 -             */
   1.178 -            if ( !list_empty(&d->arch.vmca_msrs.impact_header) ) {
   1.179 -                entry = list_entry(d->arch.vmca_msrs.impact_header.next,
   1.180 -                    struct bank_entry, list);
   1.181 -                if ( entry->bank == (msr - MSR_IA32_MC0_STATUS)/4 ) {
   1.182 -                    entry->mci_status = value;
   1.183 -                }
   1.184 -                printk(KERN_DEBUG "MCE: wmrsr mci_status in vMCE# context\n");
   1.185 -            }
   1.186 -            printk(KERN_DEBUG "MCE: wrmsr mci_status val:%lx\n", value);
   1.187 -            break;
   1.188 +            gdprintk(XENLOG_DEBUG, "MCE: wmrsr mci_status in vMCE# context\n");
   1.189 +        }
   1.190 +        gdprintk(XENLOG_DEBUG, "MCE: wrmsr mci_status val:%"PRIx64"\n", value);
   1.191 +        break;
   1.192 +    default:
   1.193 +        ret = 0;
   1.194 +        break;
   1.195      }
   1.196      spin_unlock(&mce_locks);
   1.197      return ret;
   1.198 @@ -915,154 +918,155 @@ int intel_mce_wrmsr(u32 msr, u32 lo, u32
   1.199  int intel_mce_rdmsr(u32 msr, u32 *lo, u32 *hi)
   1.200  {
   1.201      struct domain *d = current->domain;
   1.202 -    int ret = 0;
   1.203 +    int ret = 1;
   1.204      struct bank_entry *entry = NULL;
   1.205  
   1.206      *lo = *hi = 0x0;
   1.207      spin_lock(&mce_locks);
   1.208      switch(msr)
   1.209      {
   1.210 -        case MSR_IA32_MCG_STATUS:
   1.211 -            if (!d || is_idle_domain(d)) {
   1.212 -                printk(KERN_ERR "MCE: rdmsr not in domain context!\n");
   1.213 -                *lo = *hi = 0x0;
   1.214 -                break;
   1.215 -            }
   1.216 -            *lo = (u32)d->arch.vmca_msrs.mcg_status;
   1.217 -            *hi = (u32)(d->arch.vmca_msrs.mcg_status >> 32);
   1.218 -            printk(KERN_DEBUG "MCE: rd MCG_STATUS lo %x hi %x\n", *lo, *hi);
   1.219 +    case MSR_IA32_MCG_STATUS:
   1.220 +        if (!d || is_idle_domain(d)) {
   1.221 +            gdprintk(XENLOG_WARNING, "MCE: rdmsr not in domain context!\n");
   1.222 +            *lo = *hi = 0x0;
   1.223              break;
   1.224 -        case MSR_IA32_MCG_CAP:
   1.225 -            if (!d || is_idle_domain(d)) {
   1.226 -                printk(KERN_ERR "MCE: rdmsr not in domain context!\n");
   1.227 -                *lo = *hi = 0x0;
   1.228 -                break;
   1.229 -            }
   1.230 -            *lo = (u32)d->arch.vmca_msrs.mcg_cap;
   1.231 -            *hi = (u32)(d->arch.vmca_msrs.mcg_cap >> 32);
   1.232 -            printk(KERN_DEBUG "MCE: rdmsr MCG_CAP lo %x hi %x\n", *lo, *hi);
   1.233 +        }
   1.234 +        *lo = (u32)d->arch.vmca_msrs.mcg_status;
   1.235 +        *hi = (u32)(d->arch.vmca_msrs.mcg_status >> 32);
   1.236 +        gdprintk(XENLOG_DEBUG, "MCE: rd MCG_STATUS lo %x hi %x\n", *lo, *hi);
   1.237 +        break;
   1.238 +    case MSR_IA32_MCG_CAP:
   1.239 +        if (!d || is_idle_domain(d)) {
   1.240 +            gdprintk(XENLOG_WARNING, "MCE: rdmsr not in domain context!\n");
   1.241 +            *lo = *hi = 0x0;
   1.242              break;
   1.243 -        case MSR_IA32_MCG_CTL:
   1.244 -            if (!d || is_idle_domain(d)) {
   1.245 -                printk(KERN_ERR "MCE: rdmsr not in domain context!\n");
   1.246 -                *lo = *hi = 0x0;
   1.247 -                break;
   1.248 -            }
   1.249 -            *lo = (u32)d->arch.vmca_msrs.mcg_ctl;
   1.250 -            *hi = (u32)(d->arch.vmca_msrs.mcg_ctl >> 32);
   1.251 -            printk(KERN_DEBUG "MCE: rdmsr MCG_CTL lo %x hi %x\n", *lo, *hi);
   1.252 +        }
   1.253 +        *lo = (u32)d->arch.vmca_msrs.mcg_cap;
   1.254 +        *hi = (u32)(d->arch.vmca_msrs.mcg_cap >> 32);
   1.255 +        gdprintk(XENLOG_DEBUG, "MCE: rdmsr MCG_CAP lo %x hi %x\n", *lo, *hi);
   1.256 +        break;
   1.257 +    case MSR_IA32_MCG_CTL:
   1.258 +        if (!d || is_idle_domain(d)) {
   1.259 +            gdprintk(XENLOG_WARNING, "MCE: rdmsr not in domain context!\n");
   1.260 +            *lo = *hi = 0x0;
   1.261              break;
   1.262 -        case MSR_IA32_MC0_CTL2:
   1.263 -        case MSR_IA32_MC1_CTL2:
   1.264 -        case MSR_IA32_MC2_CTL2:
   1.265 -        case MSR_IA32_MC3_CTL2:
   1.266 -        case MSR_IA32_MC4_CTL2:
   1.267 -        case MSR_IA32_MC5_CTL2:
   1.268 -        case MSR_IA32_MC6_CTL2:
   1.269 -        case MSR_IA32_MC7_CTL2:
   1.270 -        case MSR_IA32_MC8_CTL2:
   1.271 -            printk(KERN_WARNING "We have disabled CMCI capability, "
   1.272 -                    "Guest should not read this MSR!\n");
   1.273 -            break;
   1.274 -        case MSR_IA32_MC0_CTL:
   1.275 -        case MSR_IA32_MC1_CTL:
   1.276 -        case MSR_IA32_MC2_CTL:
   1.277 -        case MSR_IA32_MC3_CTL:
   1.278 -        case MSR_IA32_MC4_CTL:
   1.279 -        case MSR_IA32_MC5_CTL:
   1.280 -        case MSR_IA32_MC6_CTL:
   1.281 -        case MSR_IA32_MC7_CTL:
   1.282 -        case MSR_IA32_MC8_CTL:
   1.283 -            if (!d || is_idle_domain(d)) {
   1.284 -                printk(KERN_ERR "MCE: rdmsr not in domain context!\n");
   1.285 -                *lo = *hi = 0x0;
   1.286 -                break;
   1.287 -            }
   1.288 -            *lo = (u32)d->arch.vmca_msrs.mci_ctl[(msr - MSR_IA32_MC0_CTL)/4];
   1.289 -            *hi =
   1.290 -                (u32)(d->arch.vmca_msrs.mci_ctl[(msr - MSR_IA32_MC0_CTL)/4]
   1.291 -                    >> 32);
   1.292 -            printk(KERN_DEBUG "MCE: rdmsr MCi_CTL lo %x hi %x\n", *lo, *hi);
   1.293 +        }
   1.294 +        *lo = (u32)d->arch.vmca_msrs.mcg_ctl;
   1.295 +        *hi = (u32)(d->arch.vmca_msrs.mcg_ctl >> 32);
   1.296 +        gdprintk(XENLOG_DEBUG, "MCE: rdmsr MCG_CTL lo %x hi %x\n", *lo, *hi);
   1.297 +        break;
   1.298 +    case MSR_IA32_MC0_CTL2:
   1.299 +    case MSR_IA32_MC1_CTL2:
   1.300 +    case MSR_IA32_MC2_CTL2:
   1.301 +    case MSR_IA32_MC3_CTL2:
   1.302 +    case MSR_IA32_MC4_CTL2:
   1.303 +    case MSR_IA32_MC5_CTL2:
   1.304 +    case MSR_IA32_MC6_CTL2:
   1.305 +    case MSR_IA32_MC7_CTL2:
   1.306 +    case MSR_IA32_MC8_CTL2:
   1.307 +        gdprintk(XENLOG_WARNING, "We have disabled CMCI capability, "
   1.308 +                 "Guest should not read this MSR!\n");
   1.309 +        break;
   1.310 +    case MSR_IA32_MC0_CTL:
   1.311 +    case MSR_IA32_MC1_CTL:
   1.312 +    case MSR_IA32_MC2_CTL:
   1.313 +    case MSR_IA32_MC3_CTL:
   1.314 +    case MSR_IA32_MC4_CTL:
   1.315 +    case MSR_IA32_MC5_CTL:
   1.316 +    case MSR_IA32_MC6_CTL:
   1.317 +    case MSR_IA32_MC7_CTL:
   1.318 +    case MSR_IA32_MC8_CTL:
   1.319 +        if (!d || is_idle_domain(d)) {
   1.320 +            gdprintk(XENLOG_WARNING, "MCE: rdmsr not in domain context!\n");
   1.321 +            *lo = *hi = 0x0;
   1.322              break;
   1.323 -        case MSR_IA32_MC0_STATUS:
   1.324 -        case MSR_IA32_MC1_STATUS:
   1.325 -        case MSR_IA32_MC2_STATUS:
   1.326 -        case MSR_IA32_MC3_STATUS:
   1.327 -        case MSR_IA32_MC4_STATUS:
   1.328 -        case MSR_IA32_MC5_STATUS:
   1.329 -        case MSR_IA32_MC6_STATUS:
   1.330 -        case MSR_IA32_MC7_STATUS:
   1.331 -        case MSR_IA32_MC8_STATUS:
   1.332 -            /* Only error bank is read. Non-error bank simply return */
   1.333 -            *lo = *hi = 0x0;
   1.334 -            printk(KERN_DEBUG "MCE: rdmsr mci_status\n");
   1.335 -            if (!d || is_idle_domain(d)) {
   1.336 -                printk(KERN_ERR "mce_rdmsr: not in domain context!\n");
   1.337 -                break;
   1.338 -            }
   1.339 -            if (!list_empty(&d->arch.vmca_msrs.impact_header)) {
   1.340 -                entry = list_entry(d->arch.vmca_msrs.impact_header.next,
   1.341 -                    struct bank_entry, list);
   1.342 -                if ( entry->bank == (msr - MSR_IA32_MC0_STATUS)/4 ) {
   1.343 -                    *lo = entry->mci_status;
   1.344 -                    *hi = entry->mci_status >> 32;
   1.345 -                    printk(KERN_DEBUG "MCE: rdmsr MCi_STATUS in vmCE# context "
   1.346 -                        "lo %x hi %x\n", *lo, *hi);
   1.347 -                }
   1.348 -            }
   1.349 +        }
   1.350 +        *lo = (u32)d->arch.vmca_msrs.mci_ctl[(msr - MSR_IA32_MC0_CTL)/4];
   1.351 +        *hi =
   1.352 +            (u32)(d->arch.vmca_msrs.mci_ctl[(msr - MSR_IA32_MC0_CTL)/4]
   1.353 +                  >> 32);
   1.354 +        gdprintk(XENLOG_DEBUG, "MCE: rdmsr MCi_CTL lo %x hi %x\n", *lo, *hi);
   1.355 +        break;
   1.356 +    case MSR_IA32_MC0_STATUS:
   1.357 +    case MSR_IA32_MC1_STATUS:
   1.358 +    case MSR_IA32_MC2_STATUS:
   1.359 +    case MSR_IA32_MC3_STATUS:
   1.360 +    case MSR_IA32_MC4_STATUS:
   1.361 +    case MSR_IA32_MC5_STATUS:
   1.362 +    case MSR_IA32_MC6_STATUS:
   1.363 +    case MSR_IA32_MC7_STATUS:
   1.364 +    case MSR_IA32_MC8_STATUS:
   1.365 +        /* Only error bank is read. Non-error bank simply return */
   1.366 +        *lo = *hi = 0x0;
   1.367 +        gdprintk(XENLOG_DEBUG, "MCE: rdmsr mci_status\n");
   1.368 +        if (!d || is_idle_domain(d)) {
   1.369 +            gdprintk(XENLOG_WARNING, "mce_rdmsr: not in domain context!\n");
   1.370              break;
   1.371 -        case MSR_IA32_MC0_ADDR:
   1.372 -        case MSR_IA32_MC1_ADDR:
   1.373 -        case MSR_IA32_MC2_ADDR:
   1.374 -        case MSR_IA32_MC3_ADDR:
   1.375 -        case MSR_IA32_MC4_ADDR:
   1.376 -        case MSR_IA32_MC5_ADDR:
   1.377 -        case MSR_IA32_MC6_ADDR:
   1.378 -        case MSR_IA32_MC7_ADDR:
   1.379 -        case MSR_IA32_MC8_ADDR:
   1.380 -            *lo = *hi = 0x0;
   1.381 -            if (!d || is_idle_domain(d)) {
   1.382 -                printk(KERN_ERR "mce_rdmsr: not in domain context!\n");
   1.383 -                break;
   1.384 +        }
   1.385 +        if (!list_empty(&d->arch.vmca_msrs.impact_header)) {
   1.386 +            entry = list_entry(d->arch.vmca_msrs.impact_header.next,
   1.387 +                               struct bank_entry, list);
   1.388 +            if ( entry->bank == (msr - MSR_IA32_MC0_STATUS)/4 ) {
   1.389 +                *lo = entry->mci_status;
   1.390 +                *hi = entry->mci_status >> 32;
   1.391 +                gdprintk(XENLOG_DEBUG, "MCE: rdmsr MCi_STATUS in vmCE# context "
   1.392 +                         "lo %x hi %x\n", *lo, *hi);
   1.393              }
   1.394 -            if (!list_empty(&d->arch.vmca_msrs.impact_header)) {
   1.395 -                entry = list_entry(d->arch.vmca_msrs.impact_header.next,
   1.396 -                    struct bank_entry, list);
   1.397 -                if ( entry->bank == (msr - MSR_IA32_MC0_ADDR)/4 ) {
   1.398 -                    *lo = entry->mci_addr;
   1.399 -                    *hi = entry->mci_addr >> 32;
   1.400 -                    printk(KERN_DEBUG "MCE: rdmsr MCi_ADDR in vMCE# context "
   1.401 -                        "lo %x hi %x\n", *lo, *hi);
   1.402 -                }
   1.403 -            }
   1.404 +        }
   1.405 +        break;
   1.406 +    case MSR_IA32_MC0_ADDR:
   1.407 +    case MSR_IA32_MC1_ADDR:
   1.408 +    case MSR_IA32_MC2_ADDR:
   1.409 +    case MSR_IA32_MC3_ADDR:
   1.410 +    case MSR_IA32_MC4_ADDR:
   1.411 +    case MSR_IA32_MC5_ADDR:
   1.412 +    case MSR_IA32_MC6_ADDR:
   1.413 +    case MSR_IA32_MC7_ADDR:
   1.414 +    case MSR_IA32_MC8_ADDR:
   1.415 +        *lo = *hi = 0x0;
   1.416 +        if (!d || is_idle_domain(d)) {
   1.417 +            gdprintk(XENLOG_WARNING, "mce_rdmsr: not in domain context!\n");
   1.418              break;
   1.419 -        case MSR_IA32_MC0_MISC:
   1.420 -        case MSR_IA32_MC1_MISC:
   1.421 -        case MSR_IA32_MC2_MISC:
   1.422 -        case MSR_IA32_MC3_MISC:
   1.423 -        case MSR_IA32_MC4_MISC:
   1.424 -        case MSR_IA32_MC5_MISC:
   1.425 -        case MSR_IA32_MC6_MISC:
   1.426 -        case MSR_IA32_MC7_MISC:
   1.427 -        case MSR_IA32_MC8_MISC:
   1.428 -            *lo = *hi = 0x0;
   1.429 -            if (!d || is_idle_domain(d)) {
   1.430 -                printk(KERN_ERR "MCE: rdmsr not in domain context!\n");
   1.431 -                break;
   1.432 +        }
   1.433 +        if (!list_empty(&d->arch.vmca_msrs.impact_header)) {
   1.434 +            entry = list_entry(d->arch.vmca_msrs.impact_header.next,
   1.435 +                               struct bank_entry, list);
   1.436 +            if ( entry->bank == (msr - MSR_IA32_MC0_ADDR)/4 ) {
   1.437 +                *lo = entry->mci_addr;
   1.438 +                *hi = entry->mci_addr >> 32;
   1.439 +                gdprintk(XENLOG_DEBUG, "MCE: rdmsr MCi_ADDR in vMCE# context "
   1.440 +                         "lo %x hi %x\n", *lo, *hi);
   1.441              }
   1.442 -            if (!list_empty(&d->arch.vmca_msrs.impact_header)) {
   1.443 -                entry = list_entry(d->arch.vmca_msrs.impact_header.next,
   1.444 -                    struct bank_entry, list);
   1.445 -                if ( entry->bank == (msr - MSR_IA32_MC0_MISC)/4 ) {
   1.446 -                    *lo = entry->mci_misc;
   1.447 -                    *hi = entry->mci_misc >> 32;
   1.448 -                    printk(KERN_DEBUG "MCE: rdmsr MCi_MISC in vMCE# context "
   1.449 -                        " lo %x hi %x\n", *lo, *hi);
   1.450 -                }
   1.451 +        }
   1.452 +        break;
   1.453 +    case MSR_IA32_MC0_MISC:
   1.454 +    case MSR_IA32_MC1_MISC:
   1.455 +    case MSR_IA32_MC2_MISC:
   1.456 +    case MSR_IA32_MC3_MISC:
   1.457 +    case MSR_IA32_MC4_MISC:
   1.458 +    case MSR_IA32_MC5_MISC:
   1.459 +    case MSR_IA32_MC6_MISC:
   1.460 +    case MSR_IA32_MC7_MISC:
   1.461 +    case MSR_IA32_MC8_MISC:
   1.462 +        *lo = *hi = 0x0;
   1.463 +        if (!d || is_idle_domain(d)) {
   1.464 +            gdprintk(XENLOG_WARNING, "MCE: rdmsr not in domain context!\n");
   1.465 +            break;
   1.466 +        }
   1.467 +        if (!list_empty(&d->arch.vmca_msrs.impact_header)) {
   1.468 +            entry = list_entry(d->arch.vmca_msrs.impact_header.next,
   1.469 +                               struct bank_entry, list);
   1.470 +            if ( entry->bank == (msr - MSR_IA32_MC0_MISC)/4 ) {
   1.471 +                *lo = entry->mci_misc;
   1.472 +                *hi = entry->mci_misc >> 32;
   1.473 +                gdprintk(XENLOG_DEBUG, "MCE: rdmsr MCi_MISC in vMCE# context "
   1.474 +                         " lo %x hi %x\n", *lo, *hi);
   1.475              }
   1.476 -            break;
   1.477 -        default:
   1.478 -            break;
   1.479 +        }
   1.480 +        break;
   1.481 +    default:
   1.482 +        ret = 0;
   1.483 +        break;
   1.484      }
   1.485      spin_unlock(&mce_locks);
   1.486      return ret;
     2.1 --- a/xen/arch/x86/traps.c	Fri Mar 20 17:25:29 2009 +0000
     2.2 +++ b/xen/arch/x86/traps.c	Fri Mar 20 17:42:46 2009 +0000
     2.3 @@ -2208,13 +2208,13 @@ static int emulate_privileged_op(struct 
     2.4          default:
     2.5              if ( wrmsr_hypervisor_regs(regs->ecx, eax, edx) )
     2.6                  break;
     2.7 -            if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) {
     2.8 -                if ( intel_mce_wrmsr(regs->ecx, eax, edx) != 0) {
     2.9 -                    gdprintk(XENLOG_ERR, "MCE: vMCE MSRS(%lx) Write"
    2.10 -                        " (%x:%x) Fails! ", regs->ecx, edx, eax);
    2.11 +            if ( boot_cpu_data.x86_vendor == X86_VENDOR_INTEL )
    2.12 +            {
    2.13 +                int rc = intel_mce_wrmsr(regs->ecx, eax, edx);
    2.14 +                if ( rc == -1 )
    2.15                      goto fail;
    2.16 -                }
    2.17 -                break;
    2.18 +                if ( rc == 0 )
    2.19 +                    break;
    2.20              }
    2.21  
    2.22              if ( (rdmsr_safe(regs->ecx, l, h) != 0) ||
    2.23 @@ -2301,9 +2301,13 @@ static int emulate_privileged_op(struct 
    2.24              if ( rdmsr_safe(regs->ecx, regs->eax, regs->edx) )
    2.25                  goto fail;
    2.26  
    2.27 -            if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) {
    2.28 -                if ( intel_mce_rdmsr(regs->ecx, &eax, &edx) != 0)
    2.29 -                    printk(KERN_ERR "MCE: Not MCE MSRs %lx\n", regs->ecx);
    2.30 +            if ( boot_cpu_data.x86_vendor == X86_VENDOR_INTEL )
    2.31 +            {
    2.32 +                int rc = intel_mce_rdmsr(regs->ecx, &eax, &edx);
    2.33 +                if ( rc == -1 )
    2.34 +                    goto fail;
    2.35 +                if ( rc == 0 )
    2.36 +                    break;
    2.37              }
    2.38  
    2.39              break;