Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/ehabkost/tags/x86-next-pull-req…
Browse files Browse the repository at this point in the history
…uest' 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 <ehabkost@redhat.com>" [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 <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed Mar 22, 2019
2 parents c692931 + 21ee478 commit d97a39d
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 8 deletions.
28 changes: 24 additions & 4 deletions docs/qemu-cpu-models.texi
Expand Up @@ -158,8 +158,7 @@ support this feature.

@item @code{spec-ctrl}

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

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

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


@item @code{stibp}

Required to enable stronger Spectre v2 (CVE-2017-5715) fixes in some
operating systems.

Must be explicitly turned on for all Intel CPU models.

Requires the host CPU microcode to support this feature before it
can be used for guest CPUs.


@item @code{ssbd}

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

@item @code{ibpb}

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

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

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


@item @code{stibp}

Required to enable stronger Spectre v2 (CVE-2017-5715) fixes in some
operating systems.

Must be explicitly turned on for all AMD CPU models.

Requires the host CPU microcode to support this feature before it
can be used for guest CPUs.


@item @code{virt-ssbd}

Required to enable the CVE-2018-3639 fix
Expand Down
7 changes: 3 additions & 4 deletions target/i386/cpu.c
Expand Up @@ -1089,7 +1089,6 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
.reg = R_EDX,
},
.tcg_features = TCG_7_0_EDX_FEATURES,
.unmigratable_flags = CPUID_7_0_EDX_ARCH_CAPABILITIES,
},
[FEAT_8000_0007_EDX] = {
.type = CPUID_FEATURE_WORD,
Expand Down Expand Up @@ -2533,7 +2532,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
CPUID_7_0_EBX_AVX512BW | CPUID_7_0_EBX_AVX512CD |
CPUID_7_0_EBX_AVX512VL | CPUID_7_0_EBX_CLFLUSHOPT,
.features[FEAT_7_0_ECX] =
CPUID_7_0_ECX_PKU | CPUID_7_0_ECX_OSPKE |
CPUID_7_0_ECX_PKU |
CPUID_7_0_ECX_AVX512VNNI,
.features[FEAT_7_0_EDX] =
CPUID_7_0_EDX_SPEC_CTRL | CPUID_7_0_EDX_SPEC_CTRL_SSBD,
Expand Down Expand Up @@ -2586,7 +2585,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
CPUID_7_0_EBX_SMAP,
.features[FEAT_7_0_ECX] =
CPUID_7_0_ECX_VBMI | CPUID_7_0_ECX_UMIP | CPUID_7_0_ECX_PKU |
CPUID_7_0_ECX_OSPKE | CPUID_7_0_ECX_VBMI2 | CPUID_7_0_ECX_GFNI |
CPUID_7_0_ECX_VBMI2 | CPUID_7_0_ECX_GFNI |
CPUID_7_0_ECX_VAES | CPUID_7_0_ECX_VPCLMULQDQ |
CPUID_7_0_ECX_AVX512VNNI | CPUID_7_0_ECX_AVX512BITALG |
CPUID_7_0_ECX_AVX512_VPOPCNTDQ,
Expand Down Expand Up @@ -2644,7 +2643,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
CPUID_7_0_EBX_AVX512VL | CPUID_7_0_EBX_CLFLUSHOPT,
.features[FEAT_7_0_ECX] =
CPUID_7_0_ECX_VBMI | CPUID_7_0_ECX_UMIP | CPUID_7_0_ECX_PKU |
CPUID_7_0_ECX_OSPKE | CPUID_7_0_ECX_VBMI2 | CPUID_7_0_ECX_GFNI |
CPUID_7_0_ECX_VBMI2 | CPUID_7_0_ECX_GFNI |
CPUID_7_0_ECX_VAES | CPUID_7_0_ECX_VPCLMULQDQ |
CPUID_7_0_ECX_AVX512VNNI | CPUID_7_0_ECX_AVX512BITALG |
CPUID_7_0_ECX_AVX512_VPOPCNTDQ | CPUID_7_0_ECX_LA57,
Expand Down
9 changes: 9 additions & 0 deletions target/i386/kvm.c
Expand Up @@ -389,6 +389,15 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
if (host_tsx_blacklisted()) {
ret &= ~(CPUID_7_0_EBX_RTM | CPUID_7_0_EBX_HLE);
}
} else if (function == 7 && index == 0 && reg == R_EDX) {
/*
* Linux v4.17-v4.20 incorrectly return ARCH_CAPABILITIES on SVM hosts.
* We can detect the bug by checking if MSR_IA32_ARCH_CAPABILITIES is
* returned by KVM_GET_MSR_INDEX_LIST.
*/
if (!has_msr_arch_capabs) {
ret &= ~CPUID_7_0_EDX_ARCH_CAPABILITIES;
}
} else if (function == 0x80000001 && reg == R_ECX) {
/*
* It's safe to enable TOPOEXT even if it's not returned by
Expand Down
33 changes: 33 additions & 0 deletions tests/acceptance/cpu_queries.py
@@ -0,0 +1,33 @@
# Sanity check of query-cpu-* results
#
# Copyright (c) 2019 Red Hat, Inc.
#
# Author:
# Eduardo Habkost <ehabkost@redhat.com>
#
# This work is licensed under the terms of the GNU GPL, version 2 or
# later. See the COPYING file in the top-level directory.

import logging

from avocado_qemu import Test

class QueryCPUModelExpansion(Test):
"""
Run query-cpu-model-expansion for each CPU model, and validate results
"""

def test(self):
self.vm.set_machine('none')
self.vm.add_args('-S')
self.vm.launch()

cpus = self.vm.command('query-cpu-definitions')
for c in cpus:
print(repr(c))
self.assertNotIn('', c['unavailable-features'], c['name'])

for c in cpus:
model = {'name': c['name']}
e = self.vm.command('query-cpu-model-expansion', model=model, type='full')
self.assertEquals(e['model']['name'], c['name'])

0 comments on commit d97a39d

Please sign in to comment.