From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39693) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vlnbm-0002ie-12 for qemu-devel@nongnu.org; Wed, 27 Nov 2013 17:29:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vlnbf-0007gh-Mm for qemu-devel@nongnu.org; Wed, 27 Nov 2013 17:29:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47950) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vlnbf-0007gb-EA for qemu-devel@nongnu.org; Wed, 27 Nov 2013 17:29:15 -0500 From: Igor Mammedov Date: Wed, 27 Nov 2013 23:28:53 +0100 Message-Id: <1385591336-2755-14-git-send-email-imammedo@redhat.com> In-Reply-To: <1385591336-2755-1-git-send-email-imammedo@redhat.com> References: <1385591336-2755-1-git-send-email-imammedo@redhat.com> Subject: [Qemu-devel] [PATCH 13/16] target-i386: use static properties in check_features_against_host() to print CPUID feature names List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: afaerber@suse.de Signed-off-by: Igor Mammedov --- target-i386/cpu.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 1503e9a..5c3455f 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -1119,24 +1119,6 @@ static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def) #endif /* CONFIG_KVM */ } -static int unavailable_host_feature(FeatureWordInfo *f, uint32_t mask) -{ - int i; - - for (i = 0; i < 32; ++i) - if (1 << i & mask) { - const char *reg = get_register_name_32(f->cpuid_reg); - assert(reg); - fprintf(stderr, "warning: host doesn't support requested feature: " - "CPUID.%02XH:%s%s%s [bit %d]\n", - f->cpuid_eax, reg, - f->feat_names[i] ? "." : "", - f->feat_names[i] ? f->feat_names[i] : "", i); - break; - } - return 0; -} - /* Check if all requested cpu flags are making their way to the guest * * Returns 0 if all flags are supported by the host, non-zero otherwise. @@ -1175,6 +1157,7 @@ static int kvm_check_features_against_host(X86CPU *cpu) &host_def.features[FEAT_KVM], FEAT_KVM }, }; + const DeviceClass *dc = DEVICE_CLASS(object_get_class(OBJECT(cpu))); assert(kvm_enabled()); @@ -1182,10 +1165,22 @@ static int kvm_check_features_against_host(X86CPU *cpu) for (rv = 0, i = 0; i < ARRAY_SIZE(ft); ++i) { FeatureWord w = ft[i].feat_word; FeatureWordInfo *wi = &feature_word_info[w]; + int offset = (char *)&((X86CPU *)0)->env.features[w] - (char *)0; for (mask = 1; mask; mask <<= 1) { if (*ft[i].guest_feat & mask && !(*ft[i].host_feat & mask)) { - unavailable_host_feature(wi, mask); + int bitnr = ffsl(mask) - 1; + const Property *prop = qdev_prop_find_bit(dc, offset, bitnr); + const char *name = prop ? prop->name : NULL; + const char *reg = get_register_name_32(wi->cpuid_reg); + + assert(reg); + fprintf(stderr, "warning: host doesn't support requested" + "feature: CPUID.%02XH:%s%s%s [bit %d]\n", + wi->cpuid_eax, + reg, name ? "." : "", + name ? name : "", + bitnr); rv = 1; } } -- 1.8.3.1