yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-i386-Disable-OSPKE-on-CPU-model-definitions.patch

b38b0f
From 766a7ab6a7ebb9e819f6ec9a9b109ec4659388d4 Mon Sep 17 00:00:00 2001
b38b0f
From: Eduardo Habkost <ehabkost@redhat.com>
b38b0f
Date: Thu, 9 May 2019 23:21:08 +0100
b38b0f
Subject: [PATCH 2/2] i386: Disable OSPKE on CPU model definitions
b38b0f
b38b0f
RH-Author: Eduardo Habkost <ehabkost@redhat.com>
b38b0f
Message-id: <20190509232108.25675-3-ehabkost@redhat.com>
b38b0f
Patchwork-id: 87254
b38b0f
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH 2/2] i386: Disable OSPKE on CPU model definitions
b38b0f
Bugzilla: 1561761
b38b0f
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
b38b0f
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
b38b0f
RH-Acked-by: Danilo de Paula <ddepaula@redhat.com>
b38b0f
b38b0f
Currently, the Cascadelake-Server, Icelake-Client, and
b38b0f
Icelake-Server are always generating the following warning:
b38b0f
b38b0f
  qemu-system-x86_64: warning: \
b38b0f
    host doesn't support requested feature: CPUID.07H:ECX [bit 4]
b38b0f
b38b0f
This happens because OSPKE was never returned by
b38b0f
GET_SUPPORTED_CPUID or x86_cpu_get_supported_feature_word().
b38b0f
OSPKE is a runtime flag automatically set by the KVM module or by
b38b0f
TCG code, was always cleared by x86_cpu_filter_features(), and
b38b0f
was not supposed to appear on the CPU model table.
b38b0f
b38b0f
Remove the OSPKE flag from the CPU model table entries, to avoid
b38b0f
the bogus warning and avoid returning invalid feature data on
b38b0f
query-cpu-* QMP commands.  As OSPKE was always cleared by
b38b0f
x86_cpu_filter_features(), this won't have any guest-visible
b38b0f
impact.
b38b0f
b38b0f
Include a test case that should detect the problem if we introduce
b38b0f
a similar bug again.
b38b0f
b38b0f
Fixes: c7a88b52f62b ("i386: Add new model of Cascadelake-Server")
b38b0f
Fixes: 8a11c62da914 ("i386: Add new CPU model Icelake-{Server,Client}")
b38b0f
Cc: Tao Xu <tao3.xu@intel.com>
b38b0f
Cc: Robert Hoo <robert.hu@linux.intel.com>
b38b0f
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
b38b0f
Message-Id: <20190319200515.14999-1-ehabkost@redhat.com>
b38b0f
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
b38b0f
(cherry picked from commit bb4928c7cafe50ab2137a0034e350ef1bfa044d9)
b38b0f
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
b38b0f
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
b38b0f
---
b38b0f
 target/i386/cpu.c               |  4 ++--
b38b0f
 tests/acceptance/cpu_queries.py | 33 +++++++++++++++++++++++++++++++++
b38b0f
 2 files changed, 35 insertions(+), 2 deletions(-)
b38b0f
 create mode 100644 tests/acceptance/cpu_queries.py
b38b0f
b38b0f
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
b38b0f
index c56d7e7..8ff6c38 100644
b38b0f
--- a/target/i386/cpu.c
b38b0f
+++ b/target/i386/cpu.c
b38b0f
@@ -2518,7 +2518,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
b38b0f
             CPUID_7_0_EBX_SMAP | CPUID_7_0_EBX_MPX,
b38b0f
         .features[FEAT_7_0_ECX] =
b38b0f
             CPUID_7_0_ECX_VBMI | CPUID_7_0_ECX_UMIP | CPUID_7_0_ECX_PKU |
b38b0f
-            CPUID_7_0_ECX_OSPKE | CPUID_7_0_ECX_VBMI2 | CPUID_7_0_ECX_GFNI |
b38b0f
+            CPUID_7_0_ECX_VBMI2 | CPUID_7_0_ECX_GFNI |
b38b0f
             CPUID_7_0_ECX_VAES | CPUID_7_0_ECX_VPCLMULQDQ |
b38b0f
             CPUID_7_0_ECX_AVX512VNNI | CPUID_7_0_ECX_AVX512BITALG |
b38b0f
             CPUID_7_0_ECX_AVX512_VPOPCNTDQ,
b38b0f
@@ -2576,7 +2576,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
b38b0f
             CPUID_7_0_EBX_AVX512VL | CPUID_7_0_EBX_CLFLUSHOPT,
b38b0f
         .features[FEAT_7_0_ECX] =
b38b0f
             CPUID_7_0_ECX_VBMI | CPUID_7_0_ECX_UMIP | CPUID_7_0_ECX_PKU |
b38b0f
-            CPUID_7_0_ECX_OSPKE | CPUID_7_0_ECX_VBMI2 | CPUID_7_0_ECX_GFNI |
b38b0f
+            CPUID_7_0_ECX_VBMI2 | CPUID_7_0_ECX_GFNI |
b38b0f
             CPUID_7_0_ECX_VAES | CPUID_7_0_ECX_VPCLMULQDQ |
b38b0f
             CPUID_7_0_ECX_AVX512VNNI | CPUID_7_0_ECX_AVX512BITALG |
b38b0f
             CPUID_7_0_ECX_AVX512_VPOPCNTDQ | CPUID_7_0_ECX_LA57,
b38b0f
diff --git a/tests/acceptance/cpu_queries.py b/tests/acceptance/cpu_queries.py
b38b0f
new file mode 100644
b38b0f
index 0000000..e71edec
b38b0f
--- /dev/null
b38b0f
+++ b/tests/acceptance/cpu_queries.py
b38b0f
@@ -0,0 +1,33 @@
b38b0f
+# Sanity check of query-cpu-* results
b38b0f
+#
b38b0f
+# Copyright (c) 2019 Red Hat, Inc.
b38b0f
+#
b38b0f
+# Author:
b38b0f
+#  Eduardo Habkost <ehabkost@redhat.com>
b38b0f
+#
b38b0f
+# This work is licensed under the terms of the GNU GPL, version 2 or
b38b0f
+# later.  See the COPYING file in the top-level directory.
b38b0f
+
b38b0f
+import logging
b38b0f
+
b38b0f
+from avocado_qemu import Test
b38b0f
+
b38b0f
+class QueryCPUModelExpansion(Test):
b38b0f
+    """
b38b0f
+    Run query-cpu-model-expansion for each CPU model, and validate results
b38b0f
+    """
b38b0f
+
b38b0f
+    def test(self):
b38b0f
+        self.vm.set_machine('none')
b38b0f
+        self.vm.add_args('-S')
b38b0f
+        self.vm.launch()
b38b0f
+
b38b0f
+        cpus = self.vm.command('query-cpu-definitions')
b38b0f
+        for c in cpus:
b38b0f
+            print(repr(c))
b38b0f
+            self.assertNotIn('', c['unavailable-features'], c['name'])
b38b0f
+
b38b0f
+        for c in cpus:
b38b0f
+            model = {'name': c['name']}
b38b0f
+            e = self.vm.command('query-cpu-model-expansion', model=model, type='full')
b38b0f
+            self.assertEquals(e['model']['name'], c['name'])
b38b0f
-- 
b38b0f
1.8.3.1
b38b0f