Skip to content

Commit d97a39d

Browse files
committed
Merge remote-tracking branch 'remotes/ehabkost/tags/x86-next-pull-request' into staging
x86 queue for -rc1 A few fixes that missed -rc0: * CPU model documentation updates (Daniel P. Berrangé) * Fix bogus OSPKE warnings (Eduardo Habkost) * Work around KVM bugs when handing arch_capabilities (Eduardo Habkost) # gpg: Signature made Thu 21 Mar 2019 19:32:02 GMT # gpg: using RSA key 2807936F984DC5A6 # gpg: Good signature from "Eduardo Habkost <[email protected]>" [full] # Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF D1AA 2807 936F 984D C5A6 * remotes/ehabkost/tags/x86-next-pull-request: docs: add note about stibp CPU feature for spectre v2 docs: clarify that spec-ctrl is only needed for Spectre v2 i386: Disable OSPKE on CPU model definitions i386: Make arch_capabilities migratable i386: kvm: Disable arch_capabilities if MSR can't be set Signed-off-by: Peter Maydell <[email protected]>
2 parents c692931 + 21ee478 commit d97a39d

File tree

4 files changed

+69
-8
lines changed

4 files changed

+69
-8
lines changed

docs/qemu-cpu-models.texi

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ support this feature.
158158

159159
@item @code{spec-ctrl}
160160

161-
Required to enable the Spectre (CVE-2017-5753 and CVE-2017-5715) fix,
162-
in cases where retpolines are not sufficient.
161+
Required to enable the Spectre v2 (CVE-2017-5715) fix.
163162

164163
Included by default in Intel CPU models with -IBRS suffix.
165164

@@ -169,6 +168,17 @@ Requires the host CPU microcode to support this feature before it
169168
can be used for guest CPUs.
170169

171170

171+
@item @code{stibp}
172+
173+
Required to enable stronger Spectre v2 (CVE-2017-5715) fixes in some
174+
operating systems.
175+
176+
Must be explicitly turned on for all Intel CPU models.
177+
178+
Requires the host CPU microcode to support this feature before it
179+
can be used for guest CPUs.
180+
181+
172182
@item @code{ssbd}
173183

174184
Required to enable the CVE-2018-3639 fix
@@ -249,8 +259,7 @@ included if using "Host passthrough" or "Host model".
249259

250260
@item @code{ibpb}
251261

252-
Required to enable the Spectre (CVE-2017-5753 and CVE-2017-5715) fix,
253-
in cases where retpolines are not sufficient.
262+
Required to enable the Spectre v2 (CVE-2017-5715) fix.
254263

255264
Included by default in AMD CPU models with -IBPB suffix.
256265

@@ -260,6 +269,17 @@ Requires the host CPU microcode to support this feature before it
260269
can be used for guest CPUs.
261270

262271

272+
@item @code{stibp}
273+
274+
Required to enable stronger Spectre v2 (CVE-2017-5715) fixes in some
275+
operating systems.
276+
277+
Must be explicitly turned on for all AMD CPU models.
278+
279+
Requires the host CPU microcode to support this feature before it
280+
can be used for guest CPUs.
281+
282+
263283
@item @code{virt-ssbd}
264284

265285
Required to enable the CVE-2018-3639 fix

target/i386/cpu.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,6 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
10891089
.reg = R_EDX,
10901090
},
10911091
.tcg_features = TCG_7_0_EDX_FEATURES,
1092-
.unmigratable_flags = CPUID_7_0_EDX_ARCH_CAPABILITIES,
10931092
},
10941093
[FEAT_8000_0007_EDX] = {
10951094
.type = CPUID_FEATURE_WORD,
@@ -2533,7 +2532,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
25332532
CPUID_7_0_EBX_AVX512BW | CPUID_7_0_EBX_AVX512CD |
25342533
CPUID_7_0_EBX_AVX512VL | CPUID_7_0_EBX_CLFLUSHOPT,
25352534
.features[FEAT_7_0_ECX] =
2536-
CPUID_7_0_ECX_PKU | CPUID_7_0_ECX_OSPKE |
2535+
CPUID_7_0_ECX_PKU |
25372536
CPUID_7_0_ECX_AVX512VNNI,
25382537
.features[FEAT_7_0_EDX] =
25392538
CPUID_7_0_EDX_SPEC_CTRL | CPUID_7_0_EDX_SPEC_CTRL_SSBD,
@@ -2586,7 +2585,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
25862585
CPUID_7_0_EBX_SMAP,
25872586
.features[FEAT_7_0_ECX] =
25882587
CPUID_7_0_ECX_VBMI | CPUID_7_0_ECX_UMIP | CPUID_7_0_ECX_PKU |
2589-
CPUID_7_0_ECX_OSPKE | CPUID_7_0_ECX_VBMI2 | CPUID_7_0_ECX_GFNI |
2588+
CPUID_7_0_ECX_VBMI2 | CPUID_7_0_ECX_GFNI |
25902589
CPUID_7_0_ECX_VAES | CPUID_7_0_ECX_VPCLMULQDQ |
25912590
CPUID_7_0_ECX_AVX512VNNI | CPUID_7_0_ECX_AVX512BITALG |
25922591
CPUID_7_0_ECX_AVX512_VPOPCNTDQ,
@@ -2644,7 +2643,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
26442643
CPUID_7_0_EBX_AVX512VL | CPUID_7_0_EBX_CLFLUSHOPT,
26452644
.features[FEAT_7_0_ECX] =
26462645
CPUID_7_0_ECX_VBMI | CPUID_7_0_ECX_UMIP | CPUID_7_0_ECX_PKU |
2647-
CPUID_7_0_ECX_OSPKE | CPUID_7_0_ECX_VBMI2 | CPUID_7_0_ECX_GFNI |
2646+
CPUID_7_0_ECX_VBMI2 | CPUID_7_0_ECX_GFNI |
26482647
CPUID_7_0_ECX_VAES | CPUID_7_0_ECX_VPCLMULQDQ |
26492648
CPUID_7_0_ECX_AVX512VNNI | CPUID_7_0_ECX_AVX512BITALG |
26502649
CPUID_7_0_ECX_AVX512_VPOPCNTDQ | CPUID_7_0_ECX_LA57,

target/i386/kvm.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,15 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
389389
if (host_tsx_blacklisted()) {
390390
ret &= ~(CPUID_7_0_EBX_RTM | CPUID_7_0_EBX_HLE);
391391
}
392+
} else if (function == 7 && index == 0 && reg == R_EDX) {
393+
/*
394+
* Linux v4.17-v4.20 incorrectly return ARCH_CAPABILITIES on SVM hosts.
395+
* We can detect the bug by checking if MSR_IA32_ARCH_CAPABILITIES is
396+
* returned by KVM_GET_MSR_INDEX_LIST.
397+
*/
398+
if (!has_msr_arch_capabs) {
399+
ret &= ~CPUID_7_0_EDX_ARCH_CAPABILITIES;
400+
}
392401
} else if (function == 0x80000001 && reg == R_ECX) {
393402
/*
394403
* It's safe to enable TOPOEXT even if it's not returned by

tests/acceptance/cpu_queries.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Sanity check of query-cpu-* results
2+
#
3+
# Copyright (c) 2019 Red Hat, Inc.
4+
#
5+
# Author:
6+
# Eduardo Habkost <[email protected]>
7+
#
8+
# This work is licensed under the terms of the GNU GPL, version 2 or
9+
# later. See the COPYING file in the top-level directory.
10+
11+
import logging
12+
13+
from avocado_qemu import Test
14+
15+
class QueryCPUModelExpansion(Test):
16+
"""
17+
Run query-cpu-model-expansion for each CPU model, and validate results
18+
"""
19+
20+
def test(self):
21+
self.vm.set_machine('none')
22+
self.vm.add_args('-S')
23+
self.vm.launch()
24+
25+
cpus = self.vm.command('query-cpu-definitions')
26+
for c in cpus:
27+
print(repr(c))
28+
self.assertNotIn('', c['unavailable-features'], c['name'])
29+
30+
for c in cpus:
31+
model = {'name': c['name']}
32+
e = self.vm.command('query-cpu-model-expansion', model=model, type='full')
33+
self.assertEquals(e['model']['name'], c['name'])

0 commit comments

Comments
 (0)