cryptospore / rpms / qemu-kvm

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