From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [RFC 2/2] target-i386: Add "allow-emulation" X86CPU property
Date: Thu, 5 Jun 2014 13:12:21 -0300 [thread overview]
Message-ID: <1401984741-26882-3-git-send-email-ehabkost@redhat.com> (raw)
In-Reply-To: <1401984741-26882-1-git-send-email-ehabkost@redhat.com>
The new option will allow slow emulated features (the ones returned by
GET_EMULATED_CPUID) to be enabled. We don't want to allow them to be
enabled by accident, so they will be enabled only if emulation is
explicitly allowed by the user.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
target-i386/cpu-qom.h | 3 +++
target-i386/cpu.c | 18 ++++++++++++++----
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/target-i386/cpu-qom.h b/target-i386/cpu-qom.h
index 385b81f..831f7bf 100644
--- a/target-i386/cpu-qom.h
+++ b/target-i386/cpu-qom.h
@@ -74,6 +74,8 @@ typedef struct X86CPUClass {
* @migratable: If set, only migratable flags will be accepted when "enforce"
* mode is used, and only migratable flags will be included in the "host"
* CPU model.
+ * @allow_emulation: If set, accelerator-specific code will allow emulated
+ * features to be enabled.
*
* An x86 CPU.
*/
@@ -91,6 +93,7 @@ typedef struct X86CPU {
bool check_cpuid;
bool enforce_cpuid;
bool migratable;
+ bool allow_emulation;
/* if true the CPUID code directly forward host cache leaves to the guest */
bool cache_info_passthrough;
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 1395473..568d82a 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1280,7 +1280,8 @@ static void host_x86_cpu_class_init(ObjectClass *oc, void *data)
}
static uint32_t x86_cpu_get_supported_feature_word(FeatureWord w,
- bool migratable_only);
+ bool migratable_only,
+ bool allow_emulation);
static void host_x86_cpu_initfn(Object *obj)
{
@@ -1297,7 +1298,8 @@ static void host_x86_cpu_initfn(Object *obj)
for (w = 0; w < FEATURE_WORDS; w++) {
env->features[w] =
- x86_cpu_get_supported_feature_word(w, cpu->migratable);
+ x86_cpu_get_supported_feature_word(w, cpu->migratable,
+ cpu->allow_emulation);
}
object_property_set_bool(OBJECT(cpu), true, "pmu", &error_abort);
}
@@ -1887,7 +1889,8 @@ CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
}
static uint32_t x86_cpu_get_supported_feature_word(FeatureWord w,
- bool migratable_only)
+ bool migratable_only,
+ bool allow_emulation)
{
FeatureWordInfo *wi = &feature_word_info[w];
uint32_t r;
@@ -1896,6 +1899,11 @@ static uint32_t x86_cpu_get_supported_feature_word(FeatureWord w,
r = kvm_arch_get_supported_cpuid(kvm_state, wi->cpuid_eax,
wi->cpuid_ecx,
wi->cpuid_reg);
+ if (allow_emulation) {
+ r |= kvm_arch_get_emulated_cpuid(kvm_state, wi->cpuid_eax,
+ wi->cpuid_ecx,
+ wi->cpuid_reg);
+ }
} else if (tcg_enabled()) {
r = wi->tcg_features;
} else {
@@ -1920,7 +1928,8 @@ static int x86_cpu_filter_features(X86CPU *cpu)
for (w = 0; w < FEATURE_WORDS; w++) {
uint32_t host_feat =
- x86_cpu_get_supported_feature_word(w, cpu->migratable);
+ x86_cpu_get_supported_feature_word(w, cpu->migratable,
+ cpu->allow_emulation);
uint32_t requested_features = env->features[w];
env->features[w] &= host_feat;
cpu->filtered_features[w] = requested_features & ~env->features[w];
@@ -2854,6 +2863,7 @@ static Property x86_cpu_properties[] = {
DEFINE_PROP_BOOL("hv-time", X86CPU, hyperv_time, false),
DEFINE_PROP_BOOL("check", X86CPU, check_cpuid, false),
DEFINE_PROP_BOOL("enforce", X86CPU, enforce_cpuid, false),
+ DEFINE_PROP_BOOL("allow-emulation", X86CPU, allow_emulation, true),
DEFINE_PROP_END_OF_LIST()
};
--
1.9.0
next prev parent reply other threads:[~2014-06-05 16:13 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-05 16:12 [Qemu-devel] [RFC 0/2] GET_EMULATED_CPUID support with "allow-emulation" option Eduardo Habkost
2014-06-05 16:12 ` [Qemu-devel] [RFC 1/2] kvm: Implement kvm_arch_get_emulated_cpuid() Eduardo Habkost
2014-06-05 16:12 ` Eduardo Habkost [this message]
2014-06-05 19:57 ` [Qemu-devel] [RFC 2/2 v2] target-i386: Add "x-allow-emulation" X86CPU property Eduardo Habkost
2014-06-05 22:27 ` Alexander Graf
2014-06-05 16:24 ` [Qemu-devel] [RFC 0/2] GET_EMULATED_CPUID support with "allow-emulation" option Alexander Graf
2014-06-05 16:26 ` Paolo Bonzini
2014-06-05 16:40 ` Alexander Graf
2014-06-05 16:44 ` Paolo Bonzini
2014-06-05 16:45 ` Alexander Graf
2014-06-05 16:52 ` Paolo Bonzini
2014-06-05 16:54 ` Alexander Graf
2014-06-05 16:57 ` Paolo Bonzini
2014-06-05 17:19 ` Eduardo Habkost
2014-06-05 17:39 ` Paolo Bonzini
2014-06-05 18:02 ` Eduardo Habkost
2014-06-05 19:12 ` Eduardo Habkost
2014-06-05 19:24 ` Borislav Petkov
2014-06-05 19:45 ` Eric Blake
2014-06-05 19:52 ` Eduardo Habkost
2014-06-05 16:58 ` Alexander Graf
2014-06-05 17:48 ` Eduardo Habkost
2014-06-05 22:24 ` Alexander Graf
2014-06-06 1:21 ` Borislav Petkov
2014-06-06 2:37 ` Eduardo Habkost
2014-06-06 11:16 ` Alexander Graf
2014-06-06 18:38 ` Eduardo Habkost
2014-06-05 17:17 ` Eduardo Habkost
2014-06-05 17:38 ` Paolo Bonzini
2014-06-05 17:52 ` Eduardo Habkost
2014-06-05 17:34 ` Eduardo Habkost
2014-06-06 13:29 ` gleb
2014-06-05 18:11 ` 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=1401984741-26882-3-git-send-email-ehabkost@redhat.com \
--to=ehabkost@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).