From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WketN-0008NR-En for qemu-devel@nongnu.org; Wed, 14 May 2014 15:31:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WketH-000193-9r for qemu-devel@nongnu.org; Wed, 14 May 2014 15:31:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:2999) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WketG-00018x-NY for qemu-devel@nongnu.org; Wed, 14 May 2014 15:30:59 -0400 From: Eduardo Habkost Date: Wed, 14 May 2014 16:29:54 -0300 Message-Id: <1400095810-27684-3-git-send-email-ehabkost@redhat.com> In-Reply-To: <1400095810-27684-1-git-send-email-ehabkost@redhat.com> References: <1400095810-27684-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [PATCH RESEND v4 02/18] target-i386: Simplify reporting of unavailable features List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, =?UTF-8?q?Andreas=20F=C3=A4rber?= Instead of checking and calling unavailable_host_feature() once for each bit, simply call the function (now renamed to report_unavailable_features()) once for each feature word. Signed-off-by: Eduardo Habkost --- Changes v1 -> v2: * Rebase to latest qom-cpu (commit 90c5d39c) Changes v2 -> v3: * Trivial rebase after QEMU 2.0 (onto commit 2d03b49) --- target-i386/cpu.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 694348e..3c4f327 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -1236,11 +1236,11 @@ static const TypeInfo host_x86_cpu_type_info = { #endif -static int unavailable_host_feature(FeatureWordInfo *f, uint32_t mask) +static int report_unavailable_features(FeatureWordInfo *f, uint32_t mask) { int i; - for (i = 0; i < 32; ++i) + for (i = 0; i < 32; ++i) { if (1 << i & mask) { const char *reg = get_register_name_32(f->cpuid_reg); assert(reg); @@ -1249,8 +1249,8 @@ static int unavailable_host_feature(FeatureWordInfo *f, uint32_t mask) f->cpuid_eax, reg, f->feat_names[i] ? "." : "", f->feat_names[i] ? f->feat_names[i] : "", i); - break; } + } return 0; } @@ -1274,12 +1274,10 @@ static int kvm_check_features_against_host(KVMState *s, X86CPU *cpu) uint32_t host_feat = kvm_arch_get_supported_cpuid(s, wi->cpuid_eax, wi->cpuid_ecx, wi->cpuid_reg); - uint32_t mask; - for (mask = 1; mask; mask <<= 1) { - if (guest_feat & mask && !(host_feat & mask)) { - unavailable_host_feature(wi, mask); - rv = 1; - } + uint32_t unavailable_features = guest_feat & ~host_feat; + if (unavailable_features) { + report_unavailable_features(wi, unavailable_features); + rv = 1; } } return rv; -- 1.9.0