From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51633) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wsg84-0002tM-8s for qemu-devel@nongnu.org; Thu, 05 Jun 2014 18:27:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wsg7w-0003Iu-Ph for qemu-devel@nongnu.org; Thu, 05 Jun 2014 18:27:24 -0400 Received: from cantor2.suse.de ([195.135.220.15]:53898 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wsg7w-0003Ia-F7 for qemu-devel@nongnu.org; Thu, 05 Jun 2014 18:27:16 -0400 Message-ID: <5390EEC2.1060103@suse.de> Date: Fri, 06 Jun 2014 00:27:14 +0200 From: Alexander Graf MIME-Version: 1.0 References: <1401984741-26882-1-git-send-email-ehabkost@redhat.com> <1401984741-26882-3-git-send-email-ehabkost@redhat.com> <20140605195746.GH15000@otherpad.lan.raisama.net> In-Reply-To: <20140605195746.GH15000@otherpad.lan.raisama.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC 2/2 v2] target-i386: Add "x-allow-emulation" X86CPU property List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost , qemu-devel@nongnu.org Cc: Michael Mueller , kvm@vger.kernel.org, "Michael S. Tsirkin" , Christian Borntraeger , "Gabriel L. Somlo" , Borislav Petkov , "Jason J. Herne" , Paolo Bonzini , =?ISO-8859-1?Q?Andreas_F=E4rber?= On 05.06.14 21:57, Eduardo Habkost wrote: > 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. > > Use "x-" prefix on the property name, to document that it is not > supposed to be supported forever, and intended for developers who want > to test GET_EMULATED_CPUID. > > Signed-off-by: Eduardo Habkost ack if you do s/emulation/experimental/g throughout the patch :). Alex > --- > Changes v1 -> v2: > * Rename property to x-allow-emulation > --- > 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..cf6ab59 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("x-allow-emulation", X86CPU, allow_emulation, true), > DEFINE_PROP_END_OF_LIST() > }; >