From nobody Mon Apr 29 09:30:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555977475; cv=none; d=zoho.com; s=zohoarc; b=I9qBM5OWFcjye3uxzuJ/A5Lc9z8b/uanwgX7ivsV5lHPYjPy43vHITTxPyjuLA346wZTsNi1bjvljF/Mexkk/6kLANkW+mMccqoxdl/6+Rdxq1HtrYXt98xKZ4QbnLVjKdO24Luik3GMIfHhF+Dy5dRTwx3ObZmGjGafCWSXZP0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555977475; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=zJvsR6BASTA3vaK2bTueTdTx8VVa5CZA/OLY+fdvqDw=; b=WDjdl4F8vkrEK+bAh2PYOEzN5ExgBDGJgQT6o6nHXiRbYYOyWIAz9yj73LDnU+hTmun3m3DMkf24QehvVUgVXpK4wAqOwUEVu3EaP1rIsCS2n3ilh8llek+hg4/t1O+74mKux1SmY+hpQlE7FJ/XIMj49bRWUA74nPZZv7nlk8E= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555977475593172.55468362933198; Mon, 22 Apr 2019 16:57:55 -0700 (PDT) Received: from localhost ([127.0.0.1]:45765 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIioq-0006sa-H4 for importer@patchew.org; Mon, 22 Apr 2019 19:57:52 -0400 Received: from eggs.gnu.org ([209.51.188.92]:44654) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIimm-00058J-0I for qemu-devel@nongnu.org; Mon, 22 Apr 2019 19:55:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hIif5-0005hx-LU for qemu-devel@nongnu.org; Mon, 22 Apr 2019 19:47:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49898) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hIif5-0005hg-Fg for qemu-devel@nongnu.org; Mon, 22 Apr 2019 19:47:47 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A8ED130842AC; Mon, 22 Apr 2019 23:47:46 +0000 (UTC) Received: from localhost (ovpn-116-9.gru2.redhat.com [10.97.116.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B0CA5D9CA; Mon, 22 Apr 2019 23:47:46 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Mon, 22 Apr 2019 20:47:41 -0300 Message-Id: <20190422234742.15780-2-ehabkost@redhat.com> In-Reply-To: <20190422234742.15780-1-ehabkost@redhat.com> References: <20190422234742.15780-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Mon, 22 Apr 2019 23:47:46 +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 1/2] i386: x86_cpu_list_feature_names() 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: Paolo Bonzini , Jiri Denemark , Richard Henderson , Eduardo Habkost , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Extract feature name listing code from x86_cpu_class_check_missing_features(). It will be reused to return information about CPU filtered features at runtime. Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index d6bb57d210..23e55a9ef2 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3619,6 +3619,27 @@ static void x86_cpu_parse_featurestr(const char *typ= ename, char *features, static void x86_cpu_expand_features(X86CPU *cpu, Error **errp); static int x86_cpu_filter_features(X86CPU *cpu); =20 +/* Build a list with the name of all features on a feature word array */ +static void x86_cpu_list_feature_names(FeatureWordArray features, + strList **feat_names) +{ + FeatureWord w; + strList **next =3D feat_names; + + for (w =3D 0; w < FEATURE_WORDS; w++) { + uint32_t filtered =3D features[w]; + int i; + for (i =3D 0; i < 32; i++) { + if (filtered & (1UL << i)) { + strList *new =3D g_new0(strList, 1); + new->value =3D g_strdup(x86_cpu_feature_name(w, i)); + *next =3D new; + next =3D &new->next; + } + } + } +} + /* Check for missing features that may prevent the CPU class from * running using the current machine and accelerator. */ @@ -3626,7 +3647,6 @@ static void x86_cpu_class_check_missing_features(X86C= PUClass *xcc, strList **missing_feats) { X86CPU *xc; - FeatureWord w; Error *err =3D NULL; strList **next =3D missing_feats; =20 @@ -3653,18 +3673,7 @@ static void x86_cpu_class_check_missing_features(X86= CPUClass *xcc, =20 x86_cpu_filter_features(xc); =20 - for (w =3D 0; w < FEATURE_WORDS; w++) { - uint32_t filtered =3D xc->filtered_features[w]; - int i; - for (i =3D 0; i < 32; i++) { - if (filtered & (1UL << i)) { - strList *new =3D g_new0(strList, 1); - new->value =3D g_strdup(x86_cpu_feature_name(w, i)); - *next =3D new; - next =3D &new->next; - } - } - } + x86_cpu_list_feature_names(xc->filtered_features, next); =20 object_unref(OBJECT(xc)); } --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Mon Apr 29 09:30:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555977466; cv=none; d=zoho.com; s=zohoarc; b=QuweequQ2ome2YPVXeG7BWAAEs0VN52C0j41s8eduHbkKjb6+os6tH8n/MYTClKejDWjaqNuffw7XLuEy2pqxeLwLe9JFsnlvgqTg5bKcOEaE7Z64c+la53G2LE14tS+udqT0VRNQ21cvKr8fn8JnQg/b23CuuIV0D8wzVSu2ko= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555977466; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=+BBB9m27acMg/XTGWLStil7N0zqt9X0gOo3+5CY6dss=; b=goYZKDqm0oZNpp04AQZmmCD6i9bpqEh/qDVB2zP7o5yMX16a6E5n89Hog22Lh3fpbhvy8hQ02OfrAiKUyxzuo8j+qywehiSq/IXl470ldtH8Xbz850P7KDwlWLgrnElHF7Gvvamly6OWrdp96yd+ut5Ex9R7nCPWm5JiaRvfDwE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15559774668511014.9769032023271; Mon, 22 Apr 2019 16:57:46 -0700 (PDT) Received: from localhost ([127.0.0.1]:45763 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIiof-0006iw-F0 for importer@patchew.org; Mon, 22 Apr 2019 19:57:41 -0400 Received: from eggs.gnu.org ([209.51.188.92]:44654) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIimi-00058J-9N for qemu-devel@nongnu.org; Mon, 22 Apr 2019 19:55:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hIifB-0005jO-L5 for qemu-devel@nongnu.org; Mon, 22 Apr 2019 19:47:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59610) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hIif9-0005ih-N9 for qemu-devel@nongnu.org; Mon, 22 Apr 2019 19:47:51 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 957297CDEA; Mon, 22 Apr 2019 23:47:50 +0000 (UTC) Received: from localhost (ovpn-116-9.gru2.redhat.com [10.97.116.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D0B51062224; Mon, 22 Apr 2019 23:47:48 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Mon, 22 Apr 2019 20:47:42 -0300 Message-Id: <20190422234742.15780-3-ehabkost@redhat.com> In-Reply-To: <20190422234742.15780-1-ehabkost@redhat.com> References: <20190422234742.15780-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 22 Apr 2019 23:47:50 +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 2/2] i386: "unavailable-features" QOM property 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: Paolo Bonzini , Jiri Denemark , Richard Henderson , Eduardo Habkost , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a "unavailable-features" QOM property to X86CPU objects that have the same semantics of "unavailable-features" on query-cpu-definitions. The new property has the same goal of "filtered-features", but is generic enough to let any kind of CPU feature to be listed there without relying on low level details like CPUID leaves or MSR numbers. Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 23e55a9ef2..042d09a1bb 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3640,6 +3640,17 @@ static void x86_cpu_list_feature_names(FeatureWordAr= ray features, } } =20 +static void x86_cpu_get_unavailable_features(Object *obj, Visitor *v, + const char *name, void *opaqu= e, + Error **errp) +{ + X86CPU *xc =3D X86_CPU(obj); + strList *result =3D NULL; + + x86_cpu_list_feature_names(xc->filtered_features, &result); + visit_type_strList(v, "unavailable-features", &result, errp); +} + /* Check for missing features that may prevent the CPU class from * running using the current machine and accelerator. */ @@ -5580,6 +5591,15 @@ static void x86_cpu_initfn(Object *obj) object_property_add(obj, "filtered-features", "X86CPUFeatureWordInfo", x86_cpu_get_feature_words, NULL, NULL, (void *)cpu->filtered_features, NULL); + /* + * The "unavailable-features" property has the same semantics as + * CpuDefinitionInfo.unavailable-features on the "query-cpu-definition= s" + * QMP command: they list the features that would have prevented the + * CPU from running if the "enforce" flag was set. + */ + object_property_add(obj, "unavailable-features", "strList", + x86_cpu_get_unavailable_features, + NULL, NULL, NULL, &error_abort); =20 object_property_add(obj, "crash-information", "GuestPanicInformation", x86_cpu_get_crash_info_qom, NULL, NULL, NULL, NULL= ); --=20 2.18.0.rc1.1.g3f1ff2140