From patchwork Mon Dec 19 21:22:29 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: 635131 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2567666pvb; Mon, 19 Dec 2022 13:23:29 -0800 (PST) X-Google-Smtp-Source: AMrXdXv9gy3SR1RCDeuimKVcezFv5LY1HSC3i8FQhikvshqIKiJ225zhGTwMKyBRAngZdgrdifSM X-Received: by 2002:ac8:6bd7:0:b0:3a7:e4ad:5499 with SMTP id b23-20020ac86bd7000000b003a7e4ad5499mr91165qtt.32.1671485009125; Mon, 19 Dec 2022 13:23:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671485009; cv=none; d=google.com; s=arc-20160816; b=KqTBXtZ5gOBYAo0zxfiVvDexB7QPex4uM47MWbf6owTzWnepQGLaIkJneGv3SG1HEE LUEiz+35dP1Oz946dOpVYClejlSmlLwTZYk8HO6Zi1oF+0vuvfyOtxkTaGReIh477VrO PNtzqvbQbt+YOLLmPij3ir4WHnsNciA+3tcBzZYXwO8DQXrDI03leajnQIoBUbuoZjg3 FHcjW6Cm48I3z/d3KiZP/qWAmho6ne8h2j90+IaaJsLpTQQeYbEMDBGmYk8OAXpYNcza 477hLolHbZvHAUrR0aAVVZQ2gfbLTO8WtgP15C9YzbpQSil5yWD8S/MkmJ3DgfG/xrL4 MpWA== 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=0uIKK9n031FmXLwSkaw/d2xgek2T5GaFmmJOvQiTkDo=; b=rPmTzmP3xb/4siWUg6wjswrtfqwQZHdqSzBRlv0yNMHqLCEvRwr/3XRXCe7r0/znc9 7iHZmKabzUR1H1qsaEkCfJsdtJ4SiL4Gss7YG4tf1nHe8nlflsgqSNLpI1q9QrVdFmbF ezWeEhiF+JmSlScE56EJI/eUQh+3pOghs22a95HO42UO0HzZNaDy81NW0nnaLkHI5fLF LvRy3pkF1fs33cpaZZu7mNopWekDo1Ie9mMEgRZeR3EMfuRAM8o3ITAoGRS0WHszBS6C p2KzY5Y8e9+gqHtFVekN+LxLN9FDG1tgYDwdi8XdZq/e14yQtQ7TuN7XV6w4NuF/7l7J FuCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qNjElSm2; 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 cc23-20020a05622a411700b003a7ed301979si4571534qtb.625.2022.12.19.13.23.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 19 Dec 2022 13:23:29 -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=qNjElSm2; 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 1p7Nan-0000jq-RS; Mon, 19 Dec 2022 16:22:38 -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 1p7Nam-0000jc-Rm for qemu-devel@nongnu.org; Mon, 19 Dec 2022 16:22:36 -0500 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p7Nal-0007nu-45 for qemu-devel@nongnu.org; Mon, 19 Dec 2022 16:22:36 -0500 Received: by mail-ed1-x52d.google.com with SMTP id c66so14810986edf.5 for ; Mon, 19 Dec 2022 13:22:34 -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=0uIKK9n031FmXLwSkaw/d2xgek2T5GaFmmJOvQiTkDo=; b=qNjElSm2lGWVH0Nlna7yVvNiVHUznq8iRBVetgBPyMaw/jzqCmPN8GojwqM0Kiuit3 aAmWzfy2T9uJWjx17Y3oTTptxkQxd+g/DYkuC4eX+XTTB6DH9raTOmXh7N+RRZ80Zyfa c8Xt5ozDcwCjUfxHj5dZvEWgGGT79QXcTzijZx+mLMW3leyRA5JWTfl+WMZE8kD051Yg S+xHUKcBK4rpqcL81zPv7kj2NVGmTgs0JXqHpwO5z1b7lwsehalRqWrnqTnPwOU4EPoD vN0RxMAUlJIQbR1M9ARpEG8vQhqKyUvyCTiKl6vAooggAN1ewYZswUbU0qc/hBv0EhW+ 46iQ== 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=0uIKK9n031FmXLwSkaw/d2xgek2T5GaFmmJOvQiTkDo=; b=zSy4BfWrkOAEPr/ZUg6+U4lN5+/fibGo+oZGUSrwdImW5sqithKcBdicW64Dbqp4i1 TYCnpW0ldjVP/+Lps6Q6EHNIg1fiTdU8AIWqkEW2kw0Yyz5RVKxkDKw/M85+/QrSlx0A JJ4RX28JOg9Ni1wwu8UL5/2kFl+KgAe4HzWFxxrUI2x2n8bc28RuxY/mJCXxXJg1cNY5 H/jmes1X+SjYbUC2IMz6HUVYAGwQyMjVX+HAFjxC3rDvcb/cm0/1cXNr8QcZDnwA/u/7 iIqvO2/A+nsGXYtElnLHisONfqmPtsj4mjk0+qVOhSnMDbi2VPJyq9ZrZd+jC7SSL01p qt2g== X-Gm-Message-State: ANoB5pnTEuTf+cVkMbk+4pbSP9hBR0nEQEJJ1wuOVcGA8DhQV01vfBpb hdyzwnMIPx4XqLnKib4jv8EX1XQewSMc7jP3Fqo= X-Received: by 2002:a05:6402:1f85:b0:467:b851:6066 with SMTP id c5-20020a0564021f8500b00467b8516066mr57880728edc.6.1671484952711; Mon, 19 Dec 2022 13:22:32 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id u9-20020aa7d549000000b004642b35f89esm4842015edr.9.2022.12.19.13.22.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 19 Dec 2022 13:22:31 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Markus Armbruster , Philippe Mathieu-Daude Subject: [PATCH 5/4] target/i386: Restrict 'qapi-commands-machine.h' to system emulation Date: Mon, 19 Dec 2022 22:22:29 +0100 Message-Id: <20221219212229.72052-1-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219211034.70491-1-philmd@linaro.org> References: <20221219211034.70491-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52d; envelope-from=philmd@linaro.org; helo=mail-ed1-x52d.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 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) {