From patchwork Tue Dec 20 11:03:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 635437 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2847637pvb; Tue, 20 Dec 2022 03:06:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf4+yfYturRgLgReIIk6AshkmnOvSwtTg/P5clhl5ThB9/WncIKSsL3mg/Yt7f6GBJSM6C4z X-Received: by 2002:a05:622a:408a:b0:3a8:1947:3e38 with SMTP id cg10-20020a05622a408a00b003a819473e38mr54918558qtb.31.1671534417644; Tue, 20 Dec 2022 03:06:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671534417; cv=none; d=google.com; s=arc-20160816; b=iI/+wF4DPGE+a4xCbnrII/QDLUM03L8aBJ5uFm00qNvx9BG/RBZHXOqQyx2EyCYTSr 5igshuyGErGGsOfxr8fUoEUC2aCz75FETgwfsE9EBcjtLjZ4qVg2M+OD69kXmeDoFbxK /svZsH76xEhjnNuvcGzc+hu700bIF9ZE0EoqTAAJJohBR8cvN+rF0jF1IDVMNzd64c5u YLkT62KYWuv/Tt9JF7aubC9m81XaTetXdL7Srmch8P2heMjsSF5sXAkU+T4rHU0zpvfQ mrHRBbJL5RzU85DSkingJG5O/KL0VAqV/ybGlvXHQbRoKg1F+H+aWRbzzyQ8efrV0okH n7fQ== 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=N/h6l6Dt4LtktYJzyaWdIUhcMQmq+IUjXoUtOmfFZYU=; b=in8qlbrLDpOpdaT6lcURZ+s/yAdDs6pme8KHrF6q5XBwkx0lmLdTq8R8YO09Gsj4fV lvl18dw55Zv9afRT/4vdJStxmRidmuwFE576YVXrDryj9o1iPEAwNShUlk46ILeOV0hu razRnzTGKNgeNHJ4MjTLeDSeltwToWlM+sv8TdImqkITjrdIKAOVlAzk1sm8ClthhX7Q bR9mYlzuKNviZiuaRhYwAKqCkJZ30QjxM14Vjec3J5Dy706BjulcNtLyIVGT44Kdyt+q BC87IwSbUtFJ22Rv/UTB7FuMOK+fdl4Y+jxJPYyWrXZPVygD8wTa47SniQOUYk7e4437 Z/Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B1Y6gzfn; 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=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t74-20020a37aa4d000000b006feb9d4e1efsi2816554qke.254.2022.12.20.03.06.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Dec 2022 03:06:57 -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=@linaro.org header.s=google header.b=B1Y6gzfn; 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=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7aPG-0000hu-N7; Tue, 20 Dec 2022 06:03:34 -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 1p7aPC-0000eH-52 for qemu-devel@nongnu.org; Tue, 20 Dec 2022 06:03:30 -0500 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p7aP9-0002JA-N8 for qemu-devel@nongnu.org; Tue, 20 Dec 2022 06:03:29 -0500 Received: by mail-wr1-x42f.google.com with SMTP id w15so11347841wrl.9 for ; Tue, 20 Dec 2022 03:03:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=N/h6l6Dt4LtktYJzyaWdIUhcMQmq+IUjXoUtOmfFZYU=; b=B1Y6gzfnRX2slGZn1yrWt62YpN3fgoftDdBks09/8a1Bqux/jGxPx722o07OrXZ1KY egg+6Byaq9uTn0vnN21lMNx3hm9iaUx1DiSSiTdPc77kqA0y6O6uxOdn6YTBCldLklvz +1Ci9Quaz3moHMRPHyYd4heuuwtpoKsdv7zVkjDqKdqrF7X1Xd6mXG/lQN7VEvkLC+x4 n9lSyV4wNg9w2+cTxncCDxkI90goyDgZ32Lsc/IaMo7sJKioGSr8DVyTdxCgZtkaisKO F1aX7qFd3Yb43PkY/fWXuAuKMvOV5OeuGOML1jyV/huDCRIvPmjIaJPA32HMiF2HRLtA jgIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=N/h6l6Dt4LtktYJzyaWdIUhcMQmq+IUjXoUtOmfFZYU=; b=WYHc/oUk7JNxTUUAaVSAVnGMlUhoEVLvs/n0f6oHxfZMJtJHwMDQ7YgEdTp6rGZNZk j7AwtpSKvbuk4AaKWB6g85xu1CboDbIEcjM1zq5sJBVQnLgXwz7pZof8MRkQ0NXVmoQ0 z1XHchMZ80NL1+HxRxGs+L7VV2B6lhObcp1ZlIg/Jcz3Eyvu4lFFBseYuZsrrCMLBtRn n7dBATHhIFJD45JEehgkparGvhYbHXc0sZ4z1/1Ib+F8V9sk+foSk1LBS9StcBNXbSUM QUwruA2GzH2Z9/JmhcNw7Ul4EX5eXsJ+vrN29G7kpB6JP+TYaXfc11q7gutiK9aQCdpt z3lQ== X-Gm-Message-State: AFqh2kpu/s4r4e6ntjlgxErgDyNRUXKoQ/5toDt5HKY5fkHRjeieBJtL xNIa7unEQW3I56ljsX96n481mMHtDCgoDQGu5cE= X-Received: by 2002:a05:6000:1c13:b0:263:56a0:4fde with SMTP id ba19-20020a0560001c1300b0026356a04fdemr3719696wrb.14.1671534205962; Tue, 20 Dec 2022 03:03:25 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id az29-20020adfe19d000000b0024246991121sm12402834wrb.116.2022.12.20.03.03.24 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 20 Dec 2022 03:03:25 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Xiaojuan Yang , Daniel Henrique Barboza , =?utf-8?q?Philippe_Mathieu?= =?utf-8?q?-Daud=C3=A9?= , Greg Kurz , =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-ppc@nongnu.org, Peter Maydell , Aurelien Jarno , Song Gao , Jiaxun Yang , David Gibson , Huacai Chen , Aleksandar Rikalo , qemu-arm@nongnu.org, Markus Armbruster , Richard Henderson Subject: [PATCH v2 2/5] target/i386: Restrict 'qapi-commands-machine.h' to system emulation Date: Tue, 20 Dec 2022 12:03:07 +0100 Message-Id: <20221220110310.8656-3-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221220110310.8656-1-philmd@linaro.org> References: <20221220110310.8656-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=philmd@linaro.org; helo=mail-wr1-x42f.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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-Daude 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 --- 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 ae502f0bfe..435980dd3a 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" @@ -4713,40 +4713,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) @@ -4875,6 +4841,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; @@ -4915,6 +4917,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) {