[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 1/9] target/i386: Restrict X86CPUFeatureWord to X86 targets
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v4 1/9] target/i386: Restrict X86CPUFeatureWord to X86 targets |
Date: |
Thu, 10 Sep 2020 17:22:17 +0200 |
Move out x86-specific structures from generic machine code.
Since x86_cpu_initfn() register various CPU properties that
should not be available in user-mode (tsc/stepping/kvm/...),
add a stub to satisfy the linker.
Since only qemu-system-FOO and qemu-storage-daemon provide
QMP monitors, assert the stub function is never called.
Acked-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
qapi/machine-target.json | 45 ++++++++++++++++++++++++++++++++++++++
qapi/machine.json | 42 -----------------------------------
target/i386/cpu.c | 2 +-
target/i386/machine-stub.c | 23 +++++++++++++++++++
target/i386/meson.build | 1 +
5 files changed, 70 insertions(+), 43 deletions(-)
create mode 100644 target/i386/machine-stub.c
diff --git a/qapi/machine-target.json b/qapi/machine-target.json
index 698850cc78d..b4d769a53b9 100644
--- a/qapi/machine-target.json
+++ b/qapi/machine-target.json
@@ -4,6 +4,51 @@
# This work is licensed under the terms of the GNU GPL, version 2 or later.
# See the COPYING file in the top-level directory.
+##
+# @X86CPURegister32:
+#
+# A X86 32-bit register
+#
+# Since: 1.5
+##
+{ 'enum': 'X86CPURegister32',
+ 'data': [ 'EAX', 'EBX', 'ECX', 'EDX', 'ESP', 'EBP', 'ESI', 'EDI' ],
+ 'if': 'defined(TARGET_I386)' }
+
+##
+# @X86CPUFeatureWordInfo:
+#
+# Information about a X86 CPU feature word
+#
+# @cpuid-input-eax: Input EAX value for CPUID instruction for that feature word
+#
+# @cpuid-input-ecx: Input ECX value for CPUID instruction for that
+# feature word
+#
+# @cpuid-register: Output register containing the feature bits
+#
+# @features: value of output register, containing the feature bits
+#
+# Since: 1.5
+##
+{ 'struct': 'X86CPUFeatureWordInfo',
+ 'data': { 'cpuid-input-eax': 'int',
+ '*cpuid-input-ecx': 'int',
+ 'cpuid-register': 'X86CPURegister32',
+ 'features': 'int' },
+ 'if': 'defined(TARGET_I386)' }
+
+##
+# @DummyForceArrays:
+#
+# Not used by QMP; hack to let us use X86CPUFeatureWordInfoList internally
+#
+# Since: 2.5
+##
+{ 'struct': 'DummyForceArrays',
+ 'data': { 'unused': ['X86CPUFeatureWordInfo'] },
+ 'if': 'defined(TARGET_I386)' }
+
##
# @CpuModelInfo:
#
diff --git a/qapi/machine.json b/qapi/machine.json
index 0ac1880e4a4..47e9c0b1831 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -516,48 +516,6 @@
'dst': 'uint16',
'val': 'uint8' }}
-##
-# @X86CPURegister32:
-#
-# A X86 32-bit register
-#
-# Since: 1.5
-##
-{ 'enum': 'X86CPURegister32',
- 'data': [ 'EAX', 'EBX', 'ECX', 'EDX', 'ESP', 'EBP', 'ESI', 'EDI' ] }
-
-##
-# @X86CPUFeatureWordInfo:
-#
-# Information about a X86 CPU feature word
-#
-# @cpuid-input-eax: Input EAX value for CPUID instruction for that feature word
-#
-# @cpuid-input-ecx: Input ECX value for CPUID instruction for that
-# feature word
-#
-# @cpuid-register: Output register containing the feature bits
-#
-# @features: value of output register, containing the feature bits
-#
-# Since: 1.5
-##
-{ 'struct': 'X86CPUFeatureWordInfo',
- 'data': { 'cpuid-input-eax': 'int',
- '*cpuid-input-ecx': 'int',
- 'cpuid-register': 'X86CPURegister32',
- 'features': 'int' } }
-
-##
-# @DummyForceArrays:
-#
-# Not used by QMP; hack to let us use X86CPUFeatureWordInfoList internally
-#
-# Since: 2.5
-##
-{ 'struct': 'DummyForceArrays',
- 'data': { 'unused': ['X86CPUFeatureWordInfo'] } }
-
##
# @NumaCpuOptions:
#
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 49d89585288..7ea1302734f 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -38,7 +38,7 @@
#include "qemu/option.h"
#include "qemu/config-file.h"
#include "qapi/error.h"
-#include "qapi/qapi-visit-machine.h"
+#include "qapi/qapi-visit-machine-target.h"
#include "qapi/qapi-visit-run-state.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qerror.h"
diff --git a/target/i386/machine-stub.c b/target/i386/machine-stub.c
new file mode 100644
index 00000000000..683916b5d55
--- /dev/null
+++ b/target/i386/machine-stub.c
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * QAPI x86 CPU features stub
+ *
+ * Copyright (c) 2020 Red Hat, Inc.
+ *
+ * Author:
+ * Philippe Mathieu-Daudé <philmd@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.
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "qapi/qapi-visit-machine-target.h"
+
+bool visit_type_X86CPUFeatureWordInfoList(Visitor *v, const char *name,
+ X86CPUFeatureWordInfoList **obj,
+ Error **errp)
+{
+ g_assert_not_reached();
+}
diff --git a/target/i386/meson.build b/target/i386/meson.build
index e0b71ade56c..07d4e8c2109 100644
--- a/target/i386/meson.build
+++ b/target/i386/meson.build
@@ -20,6 +20,7 @@ i386_ss.add(when: 'CONFIG_TCG', if_true: files(
'translate.c'), if_false: files('tcg-stub.c'))
i386_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c'))
i386_ss.add(when: 'CONFIG_SEV', if_true: files('sev.c'), if_false:
files('sev-stub.c'))
+i386_ss.add(when: 'CONFIG_SOFTMMU', if_false: files('machine-stub.c'))
i386_softmmu_ss = ss.source_set()
i386_softmmu_ss.add(files(
--
2.26.2
- [PATCH v4 0/9] user-mode: Prune build dependencies (part 2), Philippe Mathieu-Daudé, 2020/09/10
- [PATCH v4 1/9] target/i386: Restrict X86CPUFeatureWord to X86 targets,
Philippe Mathieu-Daudé <=
- [PATCH v4 2/9] qapi: Restrict LostTickPolicy enum to machine code, Philippe Mathieu-Daudé, 2020/09/10
- [PATCH v4 3/9] qapi: Correct balloon documentation, Philippe Mathieu-Daudé, 2020/09/10
- [PATCH v4 4/9] qapi: Restrict balloon-related commands to machine code, Philippe Mathieu-Daudé, 2020/09/10
- [PATCH v4 5/9] qapi: Restrict query-vm-generation-id command to machine code, Philippe Mathieu-Daudé, 2020/09/10
- [PATCH v4 6/9] qapi: Restrict query-uuid command to machine code, Philippe Mathieu-Daudé, 2020/09/10
- [PATCH v4 7/9] qapi: Restrict device memory commands to machine code, Philippe Mathieu-Daudé, 2020/09/10
- [PATCH v4 8/9] qapi: Extract ACPI commands to 'acpi.json', Philippe Mathieu-Daudé, 2020/09/10
- [PATCH v4 9/9] qapi: Extract PCI commands to 'pci.json', Philippe Mathieu-Daudé, 2020/09/10
- Re: [PATCH v4 0/9] user-mode: Prune build dependencies (part 2), no-reply, 2020/09/10
- Re: [PATCH v4 0/9] user-mode: Prune build dependencies (part 2), Paolo Bonzini, 2020/09/12