2018-02-23 02:52:34 +01:00
|
|
|
From 4e5e2c853977dc27ddab5937e55d181e7f1b5d2a Mon Sep 17 00:00:00 2001
|
2018-02-22 23:01:24 +01:00
|
|
|
From: Bruce Rogers <brogers@suse.com>
|
|
|
|
Date: Thu, 22 Feb 2018 04:48:07 -0700
|
|
|
|
Subject: [PATCH] i386: Compensate for KVM SPEC_CTRL feature availability bug
|
|
|
|
|
|
|
|
As we move away from the quick and dirty qemu solution for
|
|
|
|
Spectre v2, it was found that KVM wasn't reporting the SPEC_CTRL
|
|
|
|
feature when it in fact was present due to microcode update.
|
|
|
|
This patch compensates for that bug by checking for the feature
|
|
|
|
in QEMU code (like the quick and dirty solution did), instead of
|
|
|
|
simply relying on KVM for that information.
|
|
|
|
[BR: BSC#1082276]
|
|
|
|
|
|
|
|
Signed-off-by: Bruce Rogers <brogers@suse.com>
|
|
|
|
---
|
|
|
|
target/i386/cpu.c | 8 ++++++++
|
|
|
|
1 file changed, 8 insertions(+)
|
|
|
|
|
|
|
|
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
|
|
|
|
index a7e27f3bbf..5c34175f3f 100644
|
|
|
|
--- a/target/i386/cpu.c
|
|
|
|
+++ b/target/i386/cpu.c
|
|
|
|
@@ -2824,6 +2824,14 @@ static uint32_t x86_cpu_get_supported_feature_word(FeatureWord w,
|
|
|
|
r = kvm_arch_get_supported_cpuid(kvm_state, wi->cpuid_eax,
|
|
|
|
wi->cpuid_ecx,
|
|
|
|
wi->cpuid_reg);
|
|
|
|
+ // BUG!!! We need to compensate for a KVM bug where it doesn't
|
|
|
|
+ // correctly report support for IBRS (bsc#1082276)
|
|
|
|
+ if (w == FEAT_7_0_EDX) {
|
|
|
|
+ uint32_t edx;
|
|
|
|
+ host_cpuid(7, 0, NULL, NULL, NULL, &edx);
|
|
|
|
+#define CPUID_7_0_EDX_PRED_CMD (1U << 27)
|
|
|
|
+ r |= edx & (CPUID_7_0_EDX_SPEC_CTRL | CPUID_7_0_EDX_PRED_CMD);
|
|
|
|
+ }
|
|
|
|
} else if (tcg_enabled()) {
|
|
|
|
r = wi->tcg_features;
|
|
|
|
} else {
|