From patchwork Thu Feb 23 12:43:38 2023 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: 655970 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp313571wrb; Thu, 23 Feb 2023 04:46:07 -0800 (PST) X-Google-Smtp-Source: AK7set9ysT+do4kCgvRfhm/Q1O94b2TgloddDgIyhPbS+Mt38fDVcNgGHFF8nn+yn0zkHMLqZQjv X-Received: by 2002:ac8:5a52:0:b0:3b4:7efb:36a7 with SMTP id o18-20020ac85a52000000b003b47efb36a7mr19797865qta.27.1677156367399; Thu, 23 Feb 2023 04:46:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677156367; cv=none; d=google.com; s=arc-20160816; b=DND/d7SHqaedG7+w71+rUEOpMAp6tgKrGhNx0xorEFi2KIMsPnIe1ACl0pIwcHZIct 4kkqL/OH3VoLB7i3SGhygGXUzM+CykkLHNdXM2x3x91hkbwrsuL1btYnuN+y+RNCHp2Q 4MxxX/edDJAh75QCf4+Mpw8WWFopebFbbPObFJB+nSbZ/ub1JV9hZffH3uHxcvlQgtUs ram/tkh/3UHNzQ9hOmW5mFBQHVQ4IE4qGTjB7eGym/OqkiT15Wj3FtghTet8hfeIl1WV ffITbNENYcVjzkfJYxiURb4fp5d7JoaB6DQcz6kxdaklb1HLWg+haCdgrKUdN1MNnCUq Koaw== 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=UieqvLMYtzXamcR/EnTubGkk6CG/pA9dzjTw8XpqXso=; b=pMazCnmm6mUv3lvphJ1Bc7lPTHDyJSy9BmqfZxId0guFbUe2ZICiOxnAlksciMB8A0 rf2mz0Xi+0dVhchrZNS1u3DRHv5EhwCvkT6D8dRg2w2jv89wc+Z/rOZmxPhm41Wdtzcu 3w+b+3NKyJF10VLeRmL9tVr8xope5Y8p4CLQAOq5pr+rV6razSRnuwpRju1S3JwZ7AZX jfs5r2AaZkeau3mpjFiWzPwPeQb4zmZ/KkOYCIWNPCuv3kl6kjJFQrzcdpRbRFcvms+S 6qneEw31mMO89jMyesXTdrsVlYobY0bZFots9abPywmuqt1WX9gD6eo5hPczfPZPK8NT eBfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JJnuX4dT; 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 b13-20020ac85bcd000000b003bbd8bdb937si7618796qtb.795.2023.02.23.04.46.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Feb 2023 04:46:07 -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=JJnuX4dT; 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 1pVAx4-0007aj-9s; Thu, 23 Feb 2023 07:43:58 -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 1pVAx3-0007aO-Cf for qemu-devel@nongnu.org; Thu, 23 Feb 2023 07:43:57 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVAx1-00032v-Ly for qemu-devel@nongnu.org; Thu, 23 Feb 2023 07:43:57 -0500 Received: by mail-wm1-x32b.google.com with SMTP id m25-20020a7bcb99000000b003e7842b75f2so6309209wmi.3 for ; Thu, 23 Feb 2023 04:43:55 -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=UieqvLMYtzXamcR/EnTubGkk6CG/pA9dzjTw8XpqXso=; b=JJnuX4dTA2N3L180fA0KX5m9j1rbgos4BmjcPIetUoy2apXAg3vVhrkQbsCgYmCr9w ciIMPCKSO1vtAuNqpHkxTttzI7Pap3aIV2gE6MeuZ5uIurX9F2bIxCCAkeJn5LtEqCT1 vhx41Hzx2JEYGcP7E8zSZRKr2YKeLYWTkl9eKqMzUSb6cxz3p3jSaYZoi/3fN9bNQz5W amHDqzIL3dbI7/TOSPyT6X5rM5IMxjaxYXQLPaz1bfuaN1xPSY+g5kTUg3qJdrGN5x/o 2TFOhXXCcVGSXlYMaYd+vwzPO6z5hbas+rSAeLwRk3BBwCCJsE9JpOLC3eDKRYMJ45yq +7Bw== 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=UieqvLMYtzXamcR/EnTubGkk6CG/pA9dzjTw8XpqXso=; b=shaWSAKB7n8440Znipy/tUP+oj3/W6zhkxgTr8k6AHXjWEQRGaUc4rwPg1SnETg+rr IYwKDgA8UBBA8x6yrnurIPI0jxJtXjsgu01e4ZHmgAfzwOukmocNorkkvXBjNSD/iLlo 5hkN3FjcBV8xewBg6VHtnXubxt54G7/BOyd4teSz4Y6ahKtFNRCg5ni1Jivc6oE6HJX1 2avGROm07lq9rx1+IgJWFuYFPmwtOb2qYIoPQUmuidMc/+HnLyruv1h1ivRj9uCQlws8 +2PmHHB7kM9o1CQfa3DuNK+arA3HJ0dCkoB+2tu2KvTc1EqwIWXtyzAAVf5HIQsu3d04 1tkQ== X-Gm-Message-State: AO0yUKUY9zcTOdTxlidSLH7GRIFJExbxqQFVkndHJbmYFjI+nmEPPY1C KWp9fpXwdgDNOFklTiLnhNrHAA== X-Received: by 2002:a05:600c:1da5:b0:3e2:1dac:b071 with SMTP id p37-20020a05600c1da500b003e21dacb071mr10813211wms.13.1677156234252; Thu, 23 Feb 2023 04:43:54 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id d9-20020a056000114900b002c5584d0e3dsm9976086wrx.24.2023.02.23.04.43.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 23 Feb 2023 04:43:53 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Markus Armbruster , qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, David Gibson , Greg Kurz , qemu-arm@nongnu.org, Xiaojuan Yang , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Daniel Henrique Barboza , Song Gao , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PATCH v3 2/4] target/i386: Restrict 'qapi-commands-machine.h' to system emulation Date: Thu, 23 Feb 2023 13:43:38 +0100 Message-Id: <20230223124340.95367-3-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230223124340.95367-1-philmd@linaro.org> References: <20230223124340.95367-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.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=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 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 4d2b8d0444..c8da082b4f 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) {