|
|
9bac43 |
From 7705b73dcfd0a9391bb93b9e26695ecb6dc51139 Mon Sep 17 00:00:00 2001
|
|
|
9bac43 |
From: Wei Huang <wei@redhat.com>
|
|
|
9bac43 |
Date: Wed, 17 Jan 2018 22:13:23 +0100
|
|
|
9bac43 |
Subject: [PATCH 05/21] target-i386: sanitize x86 MSR_PAT loaded from another
|
|
|
9bac43 |
source
|
|
|
9bac43 |
|
|
|
9bac43 |
RH-Author: Wei Huang <wei@redhat.com>
|
|
|
9bac43 |
Message-id: <20180117221323.1008-1-wei@redhat.com>
|
|
|
9bac43 |
Patchwork-id: 78659
|
|
|
9bac43 |
O-Subject: [RHEL-7.5 qemu-kvm-rhev PATCH 1/1] target-i386: sanitize x86 MSR_PAT loaded from another source
|
|
|
9bac43 |
Bugzilla: 1529461
|
|
|
9bac43 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9bac43 |
|
|
|
9bac43 |
The RHEL 7 downstream commit a94f33258 honors guest VM's writes of MSR_PAT
|
|
|
9bac43 |
for SVM machines. But this cause a problem when an x86 VM is migrated from
|
|
|
9bac43 |
an old host, such as RHEL 6.9. This is because older system doesn't save
|
|
|
9bac43 |
the guest's PAT field during migration; Instead 0x0 is saved and migrated.
|
|
|
9bac43 |
At the destination, it will use 0x0 as guest PAT because of a94f33258.
|
|
|
9bac43 |
This causes the guest VM's performance to drop significatly.
|
|
|
9bac43 |
|
|
|
9bac43 |
This patch solves the problem by sanitizing the PAT field. If it is zero,
|
|
|
9bac43 |
we use the default MSR_PAT value (0x0007040600070406ULL) to prevent
|
|
|
9bac43 |
performance drop. This solution should work with different types of
|
|
|
9bac43 |
(old or new) VM sources.
|
|
|
9bac43 |
|
|
|
9bac43 |
Signed-off-by: Wei Huang <wei@redhat.com>
|
|
|
9bac43 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9bac43 |
---
|
|
|
9bac43 |
target/i386/cpu.c | 2 +-
|
|
|
9bac43 |
target/i386/cpu.h | 1 +
|
|
|
9bac43 |
target/i386/machine.c | 3 +++
|
|
|
9bac43 |
3 files changed, 5 insertions(+), 1 deletion(-)
|
|
|
9bac43 |
|
|
|
9bac43 |
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
|
|
|
9bac43 |
index da5a266..81d0b75 100644
|
|
|
9bac43 |
--- a/target/i386/cpu.c
|
|
|
9bac43 |
+++ b/target/i386/cpu.c
|
|
|
9bac43 |
@@ -3678,7 +3678,7 @@ static void x86_cpu_reset(CPUState *s)
|
|
|
9bac43 |
/* All units are in INIT state. */
|
|
|
9bac43 |
env->xstate_bv = 0;
|
|
|
9bac43 |
|
|
|
9bac43 |
- env->pat = 0x0007040600070406ULL;
|
|
|
9bac43 |
+ env->pat = MSR_PAT_DEFAULT;
|
|
|
9bac43 |
env->msr_ia32_misc_enable = MSR_IA32_MISC_ENABLE_DEFAULT;
|
|
|
9bac43 |
|
|
|
9bac43 |
memset(env->dr, 0, sizeof(env->dr));
|
|
|
9bac43 |
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
|
|
|
9bac43 |
index eb77e85..e04579d 100644
|
|
|
9bac43 |
--- a/target/i386/cpu.h
|
|
|
9bac43 |
+++ b/target/i386/cpu.h
|
|
|
9bac43 |
@@ -385,6 +385,7 @@
|
|
|
9bac43 |
#define MSR_MTRRfix4K_F8000 0x26f
|
|
|
9bac43 |
|
|
|
9bac43 |
#define MSR_PAT 0x277
|
|
|
9bac43 |
+#define MSR_PAT_DEFAULT 0x0007040600070406ULL
|
|
|
9bac43 |
|
|
|
9bac43 |
#define MSR_MTRRdefType 0x2ff
|
|
|
9bac43 |
|
|
|
9bac43 |
diff --git a/target/i386/machine.c b/target/i386/machine.c
|
|
|
9bac43 |
index 0212270..9f6ba9a 100644
|
|
|
9bac43 |
--- a/target/i386/machine.c
|
|
|
9bac43 |
+++ b/target/i386/machine.c
|
|
|
9bac43 |
@@ -274,6 +274,9 @@ static int cpu_post_load(void *opaque, int version_id)
|
|
|
9bac43 |
env->hflags &= ~HF_CPL_MASK;
|
|
|
9bac43 |
env->hflags |= (env->segs[R_SS].flags >> DESC_DPL_SHIFT) & HF_CPL_MASK;
|
|
|
9bac43 |
|
|
|
9bac43 |
+ if (!(env->pat))
|
|
|
9bac43 |
+ env->pat = MSR_PAT_DEFAULT;
|
|
|
9bac43 |
+
|
|
|
9bac43 |
env->fpstt = (env->fpus_vmstate >> 11) & 7;
|
|
|
9bac43 |
env->fpus = env->fpus_vmstate & ~0x3800;
|
|
|
9bac43 |
env->fptag_vmstate ^= 0xff;
|
|
|
9bac43 |
--
|
|
|
9bac43 |
1.8.3.1
|
|
|
9bac43 |
|