From patchwork Mon Oct 10 16:58:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 9369761 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1100C607FD for ; Mon, 10 Oct 2016 16:59:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F265D2998E for ; Mon, 10 Oct 2016 16:59:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E7070299EA; Mon, 10 Oct 2016 16:59:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D3F802998E for ; Mon, 10 Oct 2016 16:58:58 +0000 (UTC) Received: from localhost ([::1]:51540 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btduk-0007nn-3c for patchwork-qemu-devel@patchwork.kernel.org; Mon, 10 Oct 2016 12:58:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58645) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btduM-0007lm-84 for qemu-devel@nongnu.org; Mon, 10 Oct 2016 12:58:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1btduI-0007az-22 for qemu-devel@nongnu.org; Mon, 10 Oct 2016 12:58:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49652) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btduH-0007aR-OT for qemu-devel@nongnu.org; Mon, 10 Oct 2016 12:58:29 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 07EAE19D241; Mon, 10 Oct 2016 16:58:28 +0000 (UTC) Received: from localhost (ovpn-116-203.phx2.redhat.com [10.3.116.203]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9AGwQrF001538; Mon, 10 Oct 2016 12:58:27 -0400 Date: Mon, 10 Oct 2016 13:58:25 -0300 From: Eduardo Habkost To: Igor Mammedov Message-ID: <20161010165825.GD22870@thinpad.lan.raisama.net> References: <1475872142-3986-1-git-send-email-ehabkost@redhat.com> <1475872142-3986-3-git-send-email-ehabkost@redhat.com> <20161010142532.6ee864b8@nial.brq.redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20161010142532.6ee864b8@nial.brq.redhat.com> X-Fnord: you can see the fnord User-Agent: Mutt/1.7.0 (2016-08-17) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 10 Oct 2016 16:58:28 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] fixup! target-i386: x86_cpu_load_features() function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: libvir-list@redhat.com, qemu-devel@nongnu.org, Markus Armbruster , dahi@linux.vnet.ibm.com, Paolo Bonzini , Jiri Denemark , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Oct 10, 2016 at 02:25:32PM +0200, Igor Mammedov wrote: > On Fri, 7 Oct 2016 17:29:01 -0300 > Eduardo Habkost wrote: > > > When probing for CPU model information, we need to reuse the code > > that initializes CPUID fields, but not the remaining side-effects > > of x86_cpu_realizefn(). Move that code to a separate function > > that can be reused later. > > > > Signed-off-by: Eduardo Habkost > > --- > > Changes v5 -> v6: > > * Move x86_cpu_filter_features() outside x86_cpu_load_features(), > > as the CPU model querying API won't run > > x86_cpu_filter_features() on most cases > > > > > Changes v4 -> v5: > > * Fix typo on x86_cpu_load_features() comment > > Reported-by: Paolo Bonzini > > > > Changes series v3 -> v4: > > * New patch added to series > > --- > > target-i386/cpu.c | 67 +++++++++++++++++++++++++++++++++++-------------------- > > 1 file changed, 43 insertions(+), 24 deletions(-) > > > > diff --git a/target-i386/cpu.c b/target-i386/cpu.c > > index 1e8127b..23cc19b 100644 > > --- a/target-i386/cpu.c > > +++ b/target-i386/cpu.c > > @@ -2993,34 +2993,13 @@ static void x86_cpu_enable_xsave_components(X86CPU *cpu) > > env->features[FEAT_XSAVE_COMP_HI] = mask >> 32; > > } > > > > -#define IS_INTEL_CPU(env) ((env)->cpuid_vendor1 == CPUID_VENDOR_INTEL_1 && \ > > - (env)->cpuid_vendor2 == CPUID_VENDOR_INTEL_2 && \ > > - (env)->cpuid_vendor3 == CPUID_VENDOR_INTEL_3) > > -#define IS_AMD_CPU(env) ((env)->cpuid_vendor1 == CPUID_VENDOR_AMD_1 && \ > > - (env)->cpuid_vendor2 == CPUID_VENDOR_AMD_2 && \ > > - (env)->cpuid_vendor3 == CPUID_VENDOR_AMD_3) > > -static void x86_cpu_realizefn(DeviceState *dev, Error **errp) > > +/* Load CPUID data based on configured features */ > > +static void x86_cpu_load_features(X86CPU *cpu, Error **errp) > > { > > - CPUState *cs = CPU(dev); > > - X86CPU *cpu = X86_CPU(dev); > > - X86CPUClass *xcc = X86_CPU_GET_CLASS(dev); > > CPUX86State *env = &cpu->env; > > - Error *local_err = NULL; > > - static bool ht_warned; > > FeatureWord w; > > GList *l; > > - > > - if (xcc->kvm_required && !kvm_enabled()) { > > - char *name = x86_cpu_class_get_model_name(xcc); > > - error_setg(&local_err, "CPU model '%s' requires KVM", name); > > - g_free(name); > > - goto out; > > - } > > - > > - if (cpu->apic_id == UNASSIGNED_APIC_ID) { > > - error_setg(errp, "apic-id property was not initialized properly"); > > - return; > > - } > > + Error *local_err = NULL; > > > > /*TODO: cpu->host_features incorrectly overwrites features > > * set using "feat=on|off". Once we fix this, we can convert > > @@ -3086,6 +3065,46 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) > > env->cpuid_xlevel2 = env->cpuid_min_xlevel2; > > } > > > > +out: > > + if (local_err != NULL) { > > + error_propagate(errp, local_err); > > + } > > +} > > + > > +#define IS_INTEL_CPU(env) ((env)->cpuid_vendor1 == CPUID_VENDOR_INTEL_1 && \ > > + (env)->cpuid_vendor2 == CPUID_VENDOR_INTEL_2 && \ > > + (env)->cpuid_vendor3 == CPUID_VENDOR_INTEL_3) > > +#define IS_AMD_CPU(env) ((env)->cpuid_vendor1 == CPUID_VENDOR_AMD_1 && \ > > + (env)->cpuid_vendor2 == CPUID_VENDOR_AMD_2 && \ > > + (env)->cpuid_vendor3 == CPUID_VENDOR_AMD_3) > > +static void x86_cpu_realizefn(DeviceState *dev, Error **errp) > > +{ > > + CPUState *cs = CPU(dev); > > + X86CPU *cpu = X86_CPU(dev); > > + X86CPUClass *xcc = X86_CPU_GET_CLASS(dev); > > + CPUX86State *env = &cpu->env; > > + Error *local_err = NULL; > > + static bool ht_warned; > > + > > + if (xcc->kvm_required && !kvm_enabled()) { > > + char *name = x86_cpu_class_get_model_name(xcc); > > + error_setg(&local_err, "CPU model '%s' requires KVM", name); > > + g_free(name); > > + goto out; > > + } > > + > > + if (cpu->apic_id == UNASSIGNED_APIC_ID) { > > + error_setg(errp, "apic-id property was not initialized properly"); > > + return; > > + } > > + > > + x86_cpu_load_features(cpu, &local_err); > > + if (local_err) { > > + goto out; > > + } > > + > > + x86_cpu_filter_features(cpu); > that makes 2 invocations of ^^ inside realize, > see followup line vvvv Oops, leftover from v5. Thanks for spotting that! Fixup below. Signed-off-by: Eduardo Habkost Reviewed-by: Igor Mammedov --- target-i386/cpu.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 23cc19b..4294746 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -3103,8 +3103,6 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) goto out; } - x86_cpu_filter_features(cpu); - if (x86_cpu_filter_features(cpu) && (cpu->check_cpuid || cpu->enforce_cpuid)) { x86_cpu_report_filtered_features(cpu);