From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60669) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bA0me-0003xf-MX for qemu-devel@nongnu.org; Mon, 06 Jun 2016 16:06:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bA0mc-0006yA-Gi for qemu-devel@nongnu.org; Mon, 06 Jun 2016 16:05:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50533) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bA0mc-0006y3-B4 for qemu-devel@nongnu.org; Mon, 06 Jun 2016 16:05:58 -0400 From: Eduardo Habkost Date: Mon, 6 Jun 2016 17:05:39 -0300 Message-Id: <1465243543-889-3-git-send-email-ehabkost@redhat.com> In-Reply-To: <1465243543-889-1-git-send-email-ehabkost@redhat.com> References: <1465243543-889-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [PATCH v2 2/6] target-i386: Move warning code outside x86_cpu_filter_features() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Jiri Denemark , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Igor Mammedov , libvir-list@redhat.com x86_cpu_filter_features() will be reused by code that shouldn't print any warning. Move the warning code to a new x86_cpu_report_filtered_features() function, and call it from x86_cpu_realizefn(). Signed-off-by: Eduardo Habkost --- target-i386/cpu.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index aaa239a..bd815f3 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -2165,9 +2165,6 @@ static int x86_cpu_filter_features(X86CPU *cpu) env->features[w] &= host_feat; cpu->filtered_features[w] = requested_features & ~env->features[w]; if (cpu->filtered_features[w]) { - if (cpu->check_cpuid || cpu->enforce_cpuid) { - report_unavailable_features(w, cpu->filtered_features[w]); - } rv = 1; } } @@ -2175,6 +2172,15 @@ static int x86_cpu_filter_features(X86CPU *cpu) return rv; } +static void x86_cpu_report_filtered_features(X86CPU *cpu) +{ + FeatureWord w; + + for (w = 0; w < FEATURE_WORDS; w++) { + report_unavailable_features(w, cpu->filtered_features[w]); + } +} + static void x86_cpu_apply_props(X86CPU *cpu, PropValue *props) { PropValue *pv; @@ -2979,12 +2985,16 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) env->cpuid_level = 7; } - if (x86_cpu_filter_features(cpu) && cpu->enforce_cpuid) { - error_setg(&local_err, - kvm_enabled() ? - "Host doesn't support requested features" : - "TCG doesn't support requested features"); - goto out; + if (x86_cpu_filter_features(cpu) && + (cpu->check_cpuid || cpu->enforce_cpuid)) { + x86_cpu_report_filtered_features(cpu); + if (cpu->enforce_cpuid) { + error_setg(&local_err, + kvm_enabled() ? + "Host doesn't support requested features" : + "TCG doesn't support requested features"); + goto out; + } } /* On AMD CPUs, some CPUID[8000_0001].EDX bits must match the bits on -- 2.5.5