thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
05bba0
From 2f6d988d14532616d1f1f476b438b4e3295329f1 Mon Sep 17 00:00:00 2001
05bba0
From: Alex Williamson <alex.williamson@redhat.com>
05bba0
Date: Fri, 10 Apr 2015 16:45:59 +0200
05bba0
Subject: [PATCH 13/14] x86: Clear MTRRs on vCPU reset
05bba0
05bba0
Message-id: <20150410164559.16166.37319.stgit@gimli.home>
05bba0
Patchwork-id: 64799
05bba0
O-Subject: [RHEL7.2 qemu-kvm PATCH 3/3] x86: Clear MTRRs on vCPU reset
05bba0
Bugzilla: 1210510
05bba0
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
05bba0
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
05bba0
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
05bba0
05bba0
Upstream: 9db2efd95e13330075bff027cd682a063d725332
05bba0
05bba0
The SDM specifies (June 2014 Vol3 11.11.5):
05bba0
05bba0
    On a hardware reset, the P6 and more recent processors clear the
05bba0
    valid flags in variable-range MTRRs and clear the E flag in the
05bba0
    IA32_MTRR_DEF_TYPE MSR to disable all MTRRs. All other bits in the
05bba0
    MTRRs are undefined.
05bba0
05bba0
We currently do none of that, so whatever MTRR settings you had prior
05bba0
to reset is what you have after reset.  Usually this doesn't matter
05bba0
because KVM often ignores the guest mappings and uses write-back
05bba0
anyway.  However, if you have an assigned device and an IOMMU that
05bba0
allows NoSnoop for that device, KVM defers to the guest memory
05bba0
mappings which are now stale after reset.  The result is that OVMF
05bba0
rebooting on such a configuration takes a full minute to LZMA
05bba0
decompress the firmware volume, a process that is nearly instant on
05bba0
the initial boot.
05bba0
05bba0
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
05bba0
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
05bba0
Cc: qemu-stable@nongnu.org
05bba0
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
05bba0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
05bba0
---
05bba0
 target-i386/cpu.c | 10 ++++++++++
05bba0
 1 file changed, 10 insertions(+)
05bba0
05bba0
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
05bba0
index 1507530..b76719d 100644
05bba0
--- a/target-i386/cpu.c
05bba0
+++ b/target-i386/cpu.c
05bba0
@@ -2398,6 +2398,16 @@ static void x86_cpu_reset(CPUState *s)
05bba0
     cpu_breakpoint_remove_all(env, BP_CPU);
05bba0
     cpu_watchpoint_remove_all(env, BP_CPU);
05bba0
 
05bba0
+    /*
05bba0
+     * SDM 11.11.5 requires:
05bba0
+     *  - IA32_MTRR_DEF_TYPE MSR.E = 0
05bba0
+     *  - IA32_MTRR_PHYSMASKn.V = 0
05bba0
+     * All other bits are undefined.  For simplification, zero it all.
05bba0
+     */
05bba0
+    env->mtrr_deftype = 0;
05bba0
+    memset(env->mtrr_var, 0, sizeof(env->mtrr_var));
05bba0
+    memset(env->mtrr_fixed, 0, sizeof(env->mtrr_fixed));
05bba0
+
05bba0
 #if !defined(CONFIG_USER_ONLY)
05bba0
     /* We hard-wire the BSP to the first CPU. */
05bba0
     if (s->cpu_index == 0) {
05bba0
-- 
05bba0
1.8.3.1
05bba0