From 83e081b8ab32dd990b4e4ccc7bf8a1a416fc51c2 Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Mon, 19 Jun 2017 13:18:52 +0200 Subject: [PATCH] cpu_x86: Properly disable unknown CPU features CPU features unknown to a hypervisor will not be present in dataDisabled even though the features won't naturally be enabled because. Thus any features we asked for which are not in dataEnabled should be considered disabled. Signed-off-by: Jiri Denemark --- src/cpu/cpu_x86.c | 9 +- tests/cputest.c | 1 + ...6_64-cpuid-Core-i7-5600U-arat-disabled.xml | 5 + ...86_64-cpuid-Core-i7-5600U-arat-enabled.xml | 8 + .../x86_64-cpuid-Core-i7-5600U-arat-guest.xml | 29 +++ .../x86_64-cpuid-Core-i7-5600U-arat-host.xml | 30 +++ .../x86_64-cpuid-Core-i7-5600U-arat-json.xml | 14 ++ .../x86_64-cpuid-Core-i7-5600U-arat.json | 202 ++++++++++++++++++ .../x86_64-cpuid-Core-i7-5600U-arat.xml | 41 ++++ 9 files changed, 335 insertions(+), 4 deletions(-) create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-disabled.xml create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-enabled.xml create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-guest.xml create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-host.xml create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-json.xml create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat.json create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat.xml diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 53359ff9b6..2864454211 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -2664,12 +2664,11 @@ virCPUx86UpdateLive(virCPUDefPtr cpu, x86DataCopy(&disabled, &dataDisabled->data.x86) < 0) goto cleanup; - x86DataSubtract(&enabled, &model->data); - for (i = 0; i < map->nfeatures; i++) { virCPUx86FeaturePtr feature = map->features[i]; - if (x86DataIsSubset(&enabled, &feature->data)) { + if (x86DataIsSubset(&enabled, &feature->data) && + !x86DataIsSubset(&model->data, &feature->data)) { VIR_DEBUG("Feature '%s' enabled by the hypervisor", feature->name); if (cpu->check == VIR_CPU_CHECK_FULL) virBufferAsprintf(&bufAdded, "%s,", feature->name); @@ -2678,7 +2677,9 @@ virCPUx86UpdateLive(virCPUDefPtr cpu, goto cleanup; } - if (x86DataIsSubset(&disabled, &feature->data)) { + if (x86DataIsSubset(&disabled, &feature->data) || + (x86DataIsSubset(&model->data, &feature->data) && + !x86DataIsSubset(&enabled, &feature->data))) { VIR_DEBUG("Feature '%s' disabled by the hypervisor", feature->name); if (cpu->check == VIR_CPU_CHECK_FULL) virBufferAsprintf(&bufRemoved, "%s,", feature->name); diff --git a/tests/cputest.c b/tests/cputest.c index 89c645e648..ebcade6bed 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -991,6 +991,7 @@ mymain(void) DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i7-4600U", true); DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i7-4510U", true); DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i7-5600U", true); + DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i7-5600U-arat", true); DO_TEST_CPUID(VIR_ARCH_X86_64, "Core2-E6850", true); DO_TEST_CPUID(VIR_ARCH_X86_64, "Core2-Q9500", false); DO_TEST_CPUID(VIR_ARCH_X86_64, "FX-8150", false); diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-disabled.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-disabled.xml new file mode 100644 index 0000000000..4a0477f788 --- /dev/null +++ b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-disabled.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-enabled.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-enabled.xml new file mode 100644 index 0000000000..5cffacef59 --- /dev/null +++ b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-enabled.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-guest.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-guest.xml new file mode 100644 index 0000000000..877895cf15 --- /dev/null +++ b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-guest.xml @@ -0,0 +1,29 @@ + + Broadwell + Intel + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-host.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-host.xml new file mode 100644 index 0000000000..9b24941e0e --- /dev/null +++ b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-host.xml @@ -0,0 +1,30 @@ + + x86_64 + Broadwell + Intel + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-json.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-json.xml new file mode 100644 index 0000000000..4f253fc08a --- /dev/null +++ b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat-json.xml @@ -0,0 +1,14 @@ + + Broadwell + Intel + + + + + + + + + + + diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat.json b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat.json new file mode 100644 index 0000000000..f2aa7f3185 --- /dev/null +++ b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat.json @@ -0,0 +1,202 @@ +{ + "return": { + "model": { + "name": "base", + "props": { + "pfthreshold": false, + "pku": false, + "rtm": true, + "tsc_adjust": true, + "tsc-deadline": true, + "xstore-en": false, + "tsc-scale": false, + "sse": true, + "smap": true, + "stepping": 4, + "tce": false, + "kvm_steal_time": true, + "smep": true, + "rdpid": false, + "xcrypt": false, + "sse4_2": true, + "monitor": false, + "sse4_1": true, + "kvm-mmu": false, + "flushbyasid": false, + "kvm-steal-time": true, + "lm": true, + "tsc": true, + "adx": true, + "fxsr": true, + "sha-ni": false, + "tm": false, + "pclmuldq": true, + "xgetbv1": false, + "xstore": false, + "vmcb_clean": false, + "vme": true, + "vendor": "GenuineIntel", + "ffxsr": false, + "de": true, + "avx512f": false, + "pse": true, + "ds-cpl": false, + "tbm": false, + "ia64": false, + "phe-en": false, + "f16c": true, + "ds": false, + "mpx": false, + "tsc-adjust": true, + "aes": true, + "avx2": true, + "pbe": false, + "cx16": true, + "ds_cpl": false, + "movbe": true, + "perfctr-nb": false, + "nrip_save": false, + "kvm_mmu": false, + "ospke": false, + "avx512ifma": false, + "vmx": true, + "sep": true, + "xsaveopt": true, + "sse4a": false, + "avx512dq": false, + "i64": true, + "avx512-4vnniw": false, + "xsave": true, + "erms": true, + "hle": true, + "nodeid_msr": false, + "est": false, + "svm_lock": false, + "xop": false, + "model-id": "Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz", + "abm": true, + "avx512er": false, + "sse4.1": true, + "sse4.2": true, + "pause-filter": false, + "lahf-lm": true, + "kvm-nopiodelay": true, + "cmp_legacy": false, + "acpi": false, + "fma4": false, + "popcnt": true, + "mmx": true, + "osxsave": false, + "pcommit": false, + "avx512pf": false, + "clwb": false, + "dca": false, + "pdcm": false, + "xcrypt-en": false, + "3dnow": false, + "invtsc": false, + "tm2": false, + "hypervisor": true, + "kvmclock-stable-bit": true, + "fxsr-opt": false, + "pcid": true, + "sse4-1": true, + "sse4-2": true, + "avx512-vpopcntdq": false, + "avx512-4fmaps": false, + "pause_filter": false, + "svm-lock": false, + "rdrand": true, + "nrip-save": false, + "avx512vl": false, + "x2apic": true, + "kvmclock": true, + "pge": true, + "family": 6, + "dtes64": false, + "xd": true, + "kvm_pv_eoi": true, + "ace2": false, + "kvm_pv_unhalt": true, + "xtpr": false, + "perfctr_nb": false, + "avx512bw": false, + "nx": true, + "lwp": false, + "msr": true, + "ace2-en": false, + "decodeassists": false, + "perfctr-core": false, + "pn": false, + "fma": true, + "nodeid-msr": false, + "kvm_asyncpf": true, + "clflush": true, + "cx8": true, + "mce": true, + "avx512cd": false, + "cr8legacy": false, + "mca": true, + "pni": true, + "rdseed": true, + "apic": true, + "fsgsbase": true, + "cmp-legacy": false, + "kvm-pv-unhalt": true, + "rdtscp": true, + "mmxext": false, + "cid": false, + "ssse3": true, + "extapic": false, + "pse36": true, + "mtrr": true, + "ibs": false, + "la57": false, + "avx": true, + "syscall": true, + "umip": false, + "invpcid": true, + "avx512vbmi": false, + "kvm-asyncpf": true, + "vmcb-clean": false, + "pmm": false, + "cmov": true, + "perfctr_core": false, + "misalignsse": false, + "clflushopt": false, + "pat": true, + "lbrv": false, + "3dnowprefetch": true, + "fpu": true, + "pae": true, + "wdt": false, + "tsc_scale": false, + "skinit": false, + "fxsr_opt": false, + "kvm_nopiodelay": true, + "pmm-en": false, + "phe": false, + "3dnowext": false, + "osvw": false, + "ht": false, + "pdpe1gb": true, + "kvm-pv-eoi": true, + "npt": false, + "xsavec": false, + "lahf_lm": true, + "pclmulqdq": true, + "svm": false, + "sse3": true, + "sse2": true, + "ss": true, + "topoext": false, + "smx": false, + "bmi1": true, + "bmi2": true, + "xsaves": false, + "model": 61 + } + } + }, + "id": "model-expansion" +} diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat.xml new file mode 100644 index 0000000000..ecb4a6e15c --- /dev/null +++ b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-arat.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +