qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Edmondson <david.edmondson@oracle.com>
To: qemu-devel@nongnu.org
Cc: Laurent Vivier <lvivier@redhat.com>,
	Thomas Huth <thuth@redhat.com>,
	Eduardo Habkost <ehabkost@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Richard Henderson <richard.henderson@linaro.org>,
	David Edmondson <david.edmondson@oracle.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Joao Martins <joao.m.martins@oracle.com>
Subject: [RFC PATCH 2/2] target/i386: Add "-cpu +kvm-no-defaults"
Date: Tue, 19 Jan 2021 14:22:07 +0000	[thread overview]
Message-ID: <20210119142207.3443123-3-david.edmondson@oracle.com> (raw)
In-Reply-To: <20210119142207.3443123-1-david.edmondson@oracle.com>

From: Joao Martins <joao.m.martins@oracle.com>

When enabling reporting to the guest that the hypervisor is KVM via
"+kvm", we also enable all of the known KVM features that are
supported by the host kernel. A new "kvm-no-defaults" option for -cpu
defeats this, enabling KVM reporting but *not* enabling any specific
KVM features. Those features can be enabled one-by-one using existing
feature flags, such as kvmclock, kvm-pv-eoi, etc.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: David Edmondson <david.edmondson@oracle.com>
---
 target/i386/cpu.c | 5 +++++
 target/i386/cpu.h | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 13f58ef183..4f1e807815 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -6398,6 +6398,10 @@ static void x86_cpu_expand_features(X86CPU *cpu, Error **errp)
     int i;
     GList *l;
 
+    if (kvm_enabled() && cpu->kvm_no_defaults) {
+        env->features[FEAT_KVM] = 0;
+    }
+
     for (l = plus_features; l; l = l->next) {
         const char *prop = l->data;
         if (!object_property_set_bool(OBJECT(cpu), prop, true, errp)) {
@@ -7269,6 +7273,7 @@ static Property x86_cpu_properties[] = {
     DEFINE_PROP_BOOL("cpuid-0xb", X86CPU, enable_cpuid_0xb, true),
     DEFINE_PROP_BOOL("lmce", X86CPU, enable_lmce, false),
     DEFINE_PROP_BOOL("l3-cache", X86CPU, enable_l3_cache, true),
+    DEFINE_PROP_BOOL("kvm-no-defaults", X86CPU, kvm_no_defaults, false),
     DEFINE_PROP_BOOL("kvm-no-smi-migration", X86CPU, kvm_no_smi_migration,
                      false),
     DEFINE_PROP_BOOL("vmware-cpuid-freq", X86CPU, vmware_cpuid_freq, true),
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index d23a5b340a..f76af4a771 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1744,6 +1744,9 @@ struct X86CPU {
     /* if set, limit maximum value for phys_bits when host_phys_bits is true */
     uint8_t host_phys_bits_limit;
 
+    /* Don't automatically enable all of the discovered KVM features. */
+    bool kvm_no_defaults;
+
     /* Stop SMI delivery for migration compatibility with old machines */
     bool kvm_no_smi_migration;
 
-- 
2.29.2



  parent reply	other threads:[~2021-01-19 14:34 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-19 14:22 [RFC PATCH 0/2] x86 CPU feature +/- fiddling and +kvm-no-defaults David Edmondson
2021-01-19 14:22 ` [RFC PATCH 1/2] hw/i386: -cpu model, -feature, +feature should enable feature David Edmondson
2021-01-19 15:20   ` [RFC PATCH 1/2] hw/i386: -cpu model,-feature,+feature " Eduardo Habkost
2021-01-19 16:27     ` [External] : " David Edmondson
2021-01-19 16:30       ` Eduardo Habkost
2021-01-20  9:59         ` Igor Mammedov
2021-01-20 10:08           ` David Edmondson
2021-01-20 10:08         ` [External] : " Daniel P. Berrangé
2021-01-20 10:17           ` David Edmondson
2021-01-20 16:18             ` Eduardo Habkost
2021-01-20 19:21               ` Igor Mammedov
2021-01-20 20:12                 ` [PATCH] docs/system: Deprecate `-cpu ...,+feature,-feature` syntax Eduardo Habkost
2021-01-20 20:19                   ` [PATCH] docs/system: Deprecate `-cpu ..., +feature, -feature` syntax David Edmondson
2021-01-21  9:39                   ` [PATCH] docs/system: Deprecate `-cpu ...,+feature,-feature` syntax Daniel P. Berrangé
2021-01-27  0:14                     ` John Snow
2021-01-21 10:25                   ` Igor Mammedov
2021-01-19 14:22 ` David Edmondson [this message]
2021-01-19 16:28 ` [RFC PATCH 0/2] x86 CPU feature +/- fiddling and +kvm-no-defaults Daniel P. Berrangé
2021-01-19 16:35   ` Eduardo Habkost
2021-01-19 16:41     ` Daniel P. Berrangé
2021-01-20 10:01       ` Igor Mammedov

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=20210119142207.3443123-3-david.edmondson@oracle.com \
    --to=david.edmondson@oracle.com \
    --cc=ehabkost@redhat.com \
    --cc=joao.m.martins@oracle.com \
    --cc=lvivier@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=thuth@redhat.com \
    /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).