[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 09/14] x86: Clear MTRRs on vCPU reset
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 09/14] x86: Clear MTRRs on vCPU reset |
Date: |
Thu, 28 Aug 2014 16:09:08 +0200 |
From: Alex Williamson <address@hidden>
The SDM specifies (June 2014 Vol3 11.11.5):
On a hardware reset, the P6 and more recent processors clear the
valid flags in variable-range MTRRs and clear the E flag in the
IA32_MTRR_DEF_TYPE MSR to disable all MTRRs. All other bits in the
MTRRs are undefined.
We currently do none of that, so whatever MTRR settings you had prior
to reset is what you have after reset. Usually this doesn't matter
because KVM often ignores the guest mappings and uses write-back
anyway. However, if you have an assigned device and an IOMMU that
allows NoSnoop for that device, KVM defers to the guest memory
mappings which are now stale after reset. The result is that OVMF
rebooting on such a configuration takes a full minute to LZMA
decompress the firmware volume, a process that is nearly instant on
the initial boot.
Signed-off-by: Alex Williamson <address@hidden>
Reviewed-by: Laszlo Ersek <address@hidden>
Cc: address@hidden
Signed-off-by: Paolo Bonzini <address@hidden>
---
target-i386/cpu.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 217500c..52e335f 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -2588,6 +2588,16 @@ static void x86_cpu_reset(CPUState *s)
env->xcr0 = 1;
+ /*
+ * SDM 11.11.5 requires:
+ * - IA32_MTRR_DEF_TYPE MSR.E = 0
+ * - IA32_MTRR_PHYSMASKn.V = 0
+ * All other bits are undefined. For simplification, zero it all.
+ */
+ env->mtrr_deftype = 0;
+ memset(env->mtrr_var, 0, sizeof(env->mtrr_var));
+ memset(env->mtrr_fixed, 0, sizeof(env->mtrr_fixed));
+
#if !defined(CONFIG_USER_ONLY)
/* We hard-wire the BSP to the first CPU. */
if (s->cpu_index == 0) {
--
1.8.3.1
- [Qemu-devel] [PULL 00/14] KVM changes for 2014-08-28, Paolo Bonzini, 2014/08/28
- [Qemu-devel] [PULL 02/14] cpus: Define callback for QEMU "nmi" command, Paolo Bonzini, 2014/08/28
- [Qemu-devel] [PULL 03/14] s390x: Convert QEMUMachine to MachineClass, Paolo Bonzini, 2014/08/28
- [Qemu-devel] [PULL 04/14] s390x: Migrate to new NMI interface, Paolo Bonzini, 2014/08/28
- [Qemu-devel] [PULL 01/14] kvm: run cpu state synchronization on target vcpu thread, Paolo Bonzini, 2014/08/28
- [Qemu-devel] [PULL 05/14] spapr: Add support for new NMI interface, Paolo Bonzini, 2014/08/28
- [Qemu-devel] [PULL 06/14] target-i386: Don't forbid NX bit on PAE PDEs and PTEs, Paolo Bonzini, 2014/08/28
- [Qemu-devel] [PULL 07/14] x86: Use common variable range MTRR counts, Paolo Bonzini, 2014/08/28
- [Qemu-devel] [PULL 09/14] x86: Clear MTRRs on vCPU reset,
Paolo Bonzini <=
- [Qemu-devel] [PULL 08/14] x86: kvm: Add MTRR support for kvm_get|put_msrs(), Paolo Bonzini, 2014/08/28
- [Qemu-devel] [PULL 11/14] vl: process -object after other backend options, Paolo Bonzini, 2014/08/28
- [Qemu-devel] [PULL 10/14] checkpatch.pl: adjust typedef definition to QEMU coding style, Paolo Bonzini, 2014/08/28
- [Qemu-devel] [PULL 12/14] target-i386: Add "mpx" CPU feature name, Paolo Bonzini, 2014/08/28
- [Qemu-devel] [PULL 13/14] target-i386: Add "tsc_adjust" CPU feature name, Paolo Bonzini, 2014/08/28
- [Qemu-devel] [PULL 14/14] mc146818rtc: reinitialize irq_reinject_on_ack_count on reset, Paolo Bonzini, 2014/08/28
- Re: [Qemu-devel] [PULL 00/14] KVM changes for 2014-08-28, Peter Maydell, 2014/08/28