From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Igor Mammedov <imammedo@redhat.com>
Subject: [Qemu-devel] [PATCH 6/7] pc: Use compat_props to control KVM defaults compatibility
Date: Fri, 6 Oct 2017 18:52:43 -0300 [thread overview]
Message-ID: <20171006215244.27104-7-ehabkost@redhat.com> (raw)
In-Reply-To: <20171006215244.27104-1-ehabkost@redhat.com>
Replace the kvm_auto_* global variables with QOM properties
controlled by MachineClass::compat_props.
This will help us eliminate the pc_compat_*() function chain in
the future.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
include/hw/i386/pc.h | 8 ++++++++
target/i386/cpu.h | 17 +++++++++--------
hw/i386/pc_piix.c | 7 ++++---
target/i386/cpu.c | 18 ++++++++++--------
4 files changed, 31 insertions(+), 19 deletions(-)
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 087d184ef5..d2742dd0bc 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -753,6 +753,10 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
.driver = "core2duo" "-" TYPE_X86_CPU,\
.property = "vmx",\
.value = "on",\
+ },{\
+ .driver = TYPE_X86_CPU,\
+ .property = "x-kvm-auto-disable-svm",\
+ .value = "off",\
},
#define PC_COMPAT_2_0 \
@@ -831,6 +835,10 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
.driver = "hpet",\
.property = HPET_INTCAP,\
.value = stringify(4),\
+ },{\
+ .driver = TYPE_X86_CPU,\
+ .property = "x-kvm-auto-enable-x2apic",\
+ .value = "off",\
},
#define PC_COMPAT_1_6 \
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 0184f98241..7e5bf86921 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1267,6 +1267,15 @@ struct X86CPU {
/* Stop SMI delivery for migration compatibility with old machines */
bool kvm_no_smi_migration;
+ /* KVM automatically disables SVM if not explicitly enabled by user */
+ bool kvm_auto_disable_svm;
+
+ /* KVM automatically enables x2apic if not explicitly disabled by user */
+ bool kvm_auto_enable_x2apic;
+
+ /* KVM automatically enables kvm-pv-eoi if not explicitly disabled by user */
+ bool kvm_auto_enable_pv_eoi;
+
/* Number of physical address bits supported */
uint32_t phys_bits;
@@ -1700,14 +1709,6 @@ void apic_handle_tpr_access_report(DeviceState *d, target_ulong ip,
TPRAccess access);
-/*
- * Compat globals to control features automatically enabled/disabled by KVM.
- * TODO: convert them to X86CPU fields set by MachineClass::compat_props
- */
-extern bool kvm_auto_disable_svm;
-extern bool kvm_auto_enable_x2apic;
-extern bool kvm_auto_enable_pv_eoi;
-
/* mpx_helper.c */
void cpu_sync_bndcs_hflags(CPUX86State *env);
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 3e466b3896..e0ce633876 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -328,7 +328,6 @@ static void pc_compat_2_2(MachineState *machine)
static void pc_compat_2_1(MachineState *machine)
{
pc_compat_2_2(machine);
- kvm_auto_disable_svm = false;
}
static void pc_compat_2_0(MachineState *machine)
@@ -339,7 +338,6 @@ static void pc_compat_2_0(MachineState *machine)
static void pc_compat_1_7(MachineState *machine)
{
pc_compat_2_0(machine);
- kvm_auto_enable_x2apic = false;
}
static void pc_compat_1_6(MachineState *machine)
@@ -367,7 +365,6 @@ static void pc_compat_1_3(MachineState *machine)
static void pc_compat_1_2(MachineState *machine)
{
pc_compat_1_3(machine);
- kvm_auto_enable_pv_eoi = false;
}
/* PC compat function for pc-0.10 to pc-0.13 */
@@ -705,6 +702,10 @@ DEFINE_I440FX_MACHINE(v1_3, "pc-1.3", pc_compat_1_3,
.driver = "VGA",\
.property = "mmio",\
.value = "off",\
+ },{\
+ .driver = TYPE_X86_CPU,\
+ .property = "x-kvm-auto-enable-pv-eoi",\
+ .value = "off",\
},
static void pc_i440fx_1_2_machine_options(MachineClass *m)
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 83e234cef4..2160738a37 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -1583,10 +1583,6 @@ static PropValue kvm_default_props[] = {
{ NULL, NULL },
};
-bool kvm_auto_disable_svm = true;
-bool kvm_auto_enable_x2apic = true;
-bool kvm_auto_enable_pv_eoi = true;
-
/* TCG-specific defaults that override all CPU models when using TCG
*/
static PropValue tcg_default_props[] = {
@@ -3502,20 +3498,20 @@ static void x86_cpu_expand_features(X86CPU *cpu, Error **errp)
* defaults, so we check xcc->cpu_def here.
*/
if (xcc->cpu_def && kvm_enabled()) {
- /* KVM-specific defaults that depend on compatibility globals: */
+ /* KVM-specific defaults that depend on compatibility properties: */
if (!kvm_irqchip_in_kernel()) {
x86_cpu_expand_feature(cpu, FEAT_1_ECX, CPUID_EXT_X2APIC, 0);
- } else if (kvm_auto_enable_x2apic) {
+ } else if (cpu->kvm_auto_enable_x2apic) {
x86_cpu_expand_feature(cpu, FEAT_1_ECX, CPUID_EXT_X2APIC,
CPUID_EXT_X2APIC);
}
- if (kvm_auto_disable_svm) {
+ if (cpu->kvm_auto_disable_svm) {
x86_cpu_expand_feature(cpu, FEAT_8000_0001_ECX, CPUID_EXT3_SVM, 0);
}
- if (kvm_auto_enable_pv_eoi) {
+ if (cpu->kvm_auto_enable_pv_eoi) {
x86_cpu_expand_feature(cpu, FEAT_KVM, (1 << KVM_FEATURE_PV_EOI),
(1 << KVM_FEATURE_PV_EOI));
}
@@ -4162,6 +4158,12 @@ static Property x86_cpu_properties[] = {
DEFINE_PROP_BOOL("l3-cache", X86CPU, enable_l3_cache, true),
DEFINE_PROP_BOOL("kvm-no-smi-migration", X86CPU, kvm_no_smi_migration,
false),
+ DEFINE_PROP_BOOL("x-kvm-auto-disable-svm",
+ X86CPU, kvm_auto_disable_svm, true),
+ DEFINE_PROP_BOOL("x-kvm-auto-enable-x2apic",
+ X86CPU, kvm_auto_enable_x2apic, true),
+ DEFINE_PROP_BOOL("x-kvm-auto-enable-pv-eoi",
+ X86CPU, kvm_auto_enable_pv_eoi, true),
DEFINE_PROP_BOOL("vmware-cpuid-freq", X86CPU, vmware_cpuid_freq, true),
DEFINE_PROP_BOOL("tcg-cpuid", X86CPU, expose_tcg, true),
--
2.13.6
next prev parent reply other threads:[~2017-10-06 21:53 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-06 21:52 [Qemu-devel] [PATCH 0/7] x86: Rework KVM-defaults compat code, enable kvm_pv_unhalt by default Eduardo Habkost
2017-10-06 21:52 ` [Qemu-devel] [PATCH 1/7] qemu-doc: Document minimum kernel version for KVM in x86_64 Eduardo Habkost
2017-10-09 13:40 ` Paolo Bonzini
2017-10-10 15:33 ` Eduardo Habkost
2017-10-06 21:52 ` [Qemu-devel] [PATCH 2/7] target/i386: x86_cpu_expand_feature() helper Eduardo Habkost
2017-10-06 21:52 ` [Qemu-devel] [PATCH 3/7] target/i386: Use global variables to control KVM defaults Eduardo Habkost
2017-10-06 21:52 ` [Qemu-devel] [PATCH 4/7] kvm: Define KVM_FEAT_* even if CONFIG_KVM is not defined Eduardo Habkost
2017-10-06 21:52 ` [Qemu-devel] [PATCH 5/7] target/i386: Handle kvm_auto_* compat in x86_cpu_expand_features() Eduardo Habkost
2017-10-06 21:52 ` Eduardo Habkost [this message]
2017-10-06 21:52 ` [Qemu-devel] [PATCH 7/7] target/i386: Enable kvm_pv_unhalt by default Eduardo Habkost
2017-10-09 14:40 ` Paolo Bonzini
2017-10-09 14:43 ` Alexander Graf
2017-10-09 13:39 ` [Qemu-devel] [PATCH 0/7] x86: Rework KVM-defaults compat code, enable " Paolo Bonzini
2017-10-09 15:15 ` Waiman Long
2017-10-09 15:47 ` Paolo Bonzini
2017-10-10 15:50 ` Eduardo Habkost
2017-10-10 18:07 ` Waiman Long
2017-10-10 19:41 ` Eduardo Habkost
2017-10-11 20:19 ` Waiman Long
2017-10-13 19:01 ` Eduardo Habkost
2017-10-13 20:58 ` Waiman Long
2017-10-13 23:56 ` Eduardo Habkost
2017-11-07 11:21 ` [Qemu-devel] [libvirt] " Paolo Bonzini
2017-11-08 20:07 ` Eduardo Habkost
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171006215244.27104-7-ehabkost@redhat.com \
--to=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).