From patchwork Thu Mar 2 07:06:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 658118 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp3913378wrb; Wed, 1 Mar 2023 23:07:37 -0800 (PST) X-Google-Smtp-Source: AK7set/HqbsawTuEPjpBFQPUo7sCLUNOlvn4Ym8hjlUj/kDSBW7ncCPWPYfOS9sTRUePzw9pJ8xY X-Received: by 2002:a05:622a:115:b0:3b6:2f0d:1925 with SMTP id u21-20020a05622a011500b003b62f0d1925mr16236409qtw.64.1677740857518; Wed, 01 Mar 2023 23:07:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677740857; cv=none; d=google.com; s=arc-20160816; b=QWXTCALfz6T2k6t20r7WM+c9A+Li8hvEqSSMBym8pRuZcMTL710jz431KbDcn5v7Dd kmYJhR2W4HrwLj8vJsSu35o3Owf/lPGLe5I3kFjLvpqqpFFmkc2XdGLFOt1iuEBgFc5E +FgwAIkUqrx04uXdRTVzdboV7pWi6AOMZyinP2RdTp8XsBgqgWN+f/8S5tRIuGVTlinh ZZ1yEKbxtHvYmJbr2F4l1uteqKN5Q1IArv+uFksuRHa5nVXIETYiA2Qwj3bU2OZx7QiM 772UJxuhQ/fXIgmkOcCIHFhj2thszm9ysXqadM3+lm66NVHK7cuTlnX+12MKlBFB+mk5 jyIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7DUkvCHWMbAxRC85L+fGwovCF77gB87XXBtw4uBMXwc=; b=i9YmggawTHHOwNeJsvSntUe0PjtqlUrlkwNYPwisymQZOLIu4Nn0SYqoi08dfwmQON UmRanwRvvkzbPLfHLg8AZM870c29Y4GWfwr10Gtv824n3Seb75LSJlH7RbgcJpKreO27 LyZjiirKlWSWcE/o0x6cCzCTY1HJtg1/n0MQkLb50b13NeY9qaoVeVtb5HxBsZo69DgV 8AF6forbBFZSjvCWSWGHbFmGk2DDYX5NPSuttujtuOhRTJSYwDU60l0WEmK0UOnBzRI5 gHMKDRSm6+iAzImUlqaXT2+YWC1dRaukAVpy6OK/uWte3j/e20Juv4MHHEWNiIpfyozn U9tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QO4R14HZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y10-20020a05622a120a00b003a816004c41si13688989qtx.89.2023.03.01.23.07.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Mar 2023 23:07:37 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QO4R14HZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXd23-0002qC-JL; Thu, 02 Mar 2023 02:07:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pXd1v-0002gP-Tt for qemu-devel@nongnu.org; Thu, 02 Mar 2023 02:07:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pXd1s-0005Sc-HF for qemu-devel@nongnu.org; Thu, 02 Mar 2023 02:07:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677740823; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7DUkvCHWMbAxRC85L+fGwovCF77gB87XXBtw4uBMXwc=; b=QO4R14HZPPDEOcQrIKgGJtYt9jnZNB+lqEoChLAPjGcWawuOeSer6rpWzr0vaXauQKAJBo rAAvPj/bEjM7B/Qfo0fRmz6MslhcwELV9t6JaIZHlh5/l8KMTN/s1h5vQM7F8N9Naj1OEz LnNt/d7pgLhBZMHnY7S6aXtDPzxq+38= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-18-PLk8ul2_Ohapqs62oNvOzQ-1; Thu, 02 Mar 2023 02:07:01 -0500 X-MC-Unique: PLk8ul2_Ohapqs62oNvOzQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5A5D4101AA63; Thu, 2 Mar 2023 07:07:01 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3102A400EA93; Thu, 2 Mar 2023 07:07:01 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 0E1F621E6A25; Thu, 2 Mar 2023 08:07:00 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PULL 3/5] target/i386: Restrict 'qapi-commands-machine.h' to system emulation Date: Thu, 2 Mar 2023 08:06:58 +0100 Message-Id: <20230302070700.2998086-4-armbru@redhat.com> In-Reply-To: <20230302070700.2998086-1-armbru@redhat.com> References: <20230302070700.2998086-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé Since commit a0e61807a3 ("qapi: Remove QMP events and commands from user-mode builds") we don't generate the "qapi-commands-machine.h" header in a user-emulation-only build. Guard qmp_query_cpu_definitions() within CONFIG_USER_ONLY; move x86_cpu_class_check_missing_features() closer since it is only used by this QMP command handler. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20230223155540.30370-3-philmd@linaro.org> Signed-off-by: Markus Armbruster --- target/i386/cpu.c | 74 +++++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 4bad3d41d3..4d508624e1 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -31,11 +31,11 @@ #include "qapi/error.h" #include "qapi/qapi-visit-machine.h" #include "qapi/qmp/qerror.h" -#include "qapi/qapi-commands-machine-target.h" #include "standard-headers/asm-x86/kvm_para.h" #include "hw/qdev-properties.h" #include "hw/i386/topology.h" #ifndef CONFIG_USER_ONLY +#include "qapi/qapi-commands-machine-target.h" #include "exec/address-spaces.h" #include "hw/boards.h" #include "hw/i386/sgx-epc.h" @@ -4843,40 +4843,6 @@ static void x86_cpu_get_unavailable_features(Object *obj, Visitor *v, 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. - */ -static void x86_cpu_class_check_missing_features(X86CPUClass *xcc, - strList **list) -{ - strList **tail = list; - X86CPU *xc; - Error *err = NULL; - - if (xcc->host_cpuid_required && !accel_uses_host_cpuid()) { - QAPI_LIST_APPEND(tail, g_strdup("kvm")); - return; - } - - xc = X86_CPU(object_new_with_class(OBJECT_CLASS(xcc))); - - x86_cpu_expand_features(xc, &err); - if (err) { - /* Errors at x86_cpu_expand_features should never happen, - * but in case it does, just report the model as not - * runnable at all using the "type" property. - */ - QAPI_LIST_APPEND(tail, g_strdup("type")); - error_free(err); - } - - x86_cpu_filter_features(xc, false); - - x86_cpu_list_feature_names(xc->filtered_features, tail); - - object_unref(OBJECT(xc)); -} - /* Print all cpuid feature names in featureset */ static void listflags(GList *features) @@ -5005,6 +4971,42 @@ void x86_cpu_list(void) g_list_free(names); } +#ifndef CONFIG_USER_ONLY + +/* Check for missing features that may prevent the CPU class from + * running using the current machine and accelerator. + */ +static void x86_cpu_class_check_missing_features(X86CPUClass *xcc, + strList **list) +{ + strList **tail = list; + X86CPU *xc; + Error *err = NULL; + + if (xcc->host_cpuid_required && !accel_uses_host_cpuid()) { + QAPI_LIST_APPEND(tail, g_strdup("kvm")); + return; + } + + xc = X86_CPU(object_new_with_class(OBJECT_CLASS(xcc))); + + x86_cpu_expand_features(xc, &err); + if (err) { + /* Errors at x86_cpu_expand_features should never happen, + * but in case it does, just report the model as not + * runnable at all using the "type" property. + */ + QAPI_LIST_APPEND(tail, g_strdup("type")); + error_free(err); + } + + x86_cpu_filter_features(xc, false); + + x86_cpu_list_feature_names(xc->filtered_features, tail); + + object_unref(OBJECT(xc)); +} + static void x86_cpu_definition_entry(gpointer data, gpointer user_data) { ObjectClass *oc = data; @@ -5045,6 +5047,8 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) return cpu_list; } +#endif /* !CONFIG_USER_ONLY */ + uint64_t x86_cpu_get_supported_feature_word(FeatureWord w, bool migratable_only) {