From patchwork Thu Feb 23 15:55:37 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: 1747024 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=TYYQMbLR; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PMyMz4s7sz2463 for ; Fri, 24 Feb 2023 02:57:35 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVDwp-0005NG-FQ; Thu, 23 Feb 2023 10:55:55 -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 1pVDwo-0005Li-L1 for qemu-devel@nongnu.org; Thu, 23 Feb 2023 10:55:54 -0500 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVDwm-0004Mh-EU for qemu-devel@nongnu.org; Thu, 23 Feb 2023 10:55:54 -0500 Received: by mail-wr1-x431.google.com with SMTP id bt28so4389639wrb.8 for ; Thu, 23 Feb 2023 07:55:49 -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=dgHuNHN3qMWWXeDiMRYq/naUGyoYaGdDKos5q2bM3BM=; b=TYYQMbLRS40IVTx1DA5ZZmCms7kQMzQSPm2CLVjBKTyOAHK74zVOsfscvUmzvYmzJG KW2BqtzQjqqRWXw5BK0Q4owmxdTA8KL5lgzCf66C2gHdo13RhukpFNEJyrXDl6tH4JHG Kx2UgFtuiOqYygGiYdcWGbO+ZtdXexZrL3EIKE8euuLBf+INX+18JWBc7nEys0MUCWD3 0CghHsDQ7FQuHUYTOew4bw8qgXj5GgtWft3n3W6kHI2STRx88vu1v5VarRpFJGJokUMC Z1l0aYJu/mizBHlGH7etRvUbFqSQa7f3y6c4eKG6I7VcNLq2gzDLXPsbRHW2NuQ9oUwl lfkA== 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=dgHuNHN3qMWWXeDiMRYq/naUGyoYaGdDKos5q2bM3BM=; b=CfUrLhqXzPaW6Irv8XG/RkMxzXEZ6OZ03880IgV1tNtXg9z1Gex7KgFiiVc7tE4G49 uWgkwxF4ndS11BXX4JSkRVdy9OiL6ANSgEogtbru70SksfNfd4Es/SN8F95AfwfdUDu3 e6GC8FENy4YrOXd007n3gfMlOdqZdrb42lgxp+fnQtyfc2mrzqG5o6UZvGE1OpWEjM7p LdTcLRDiLaCvj9OU31R8Tu9OsUl1ENx+ji7wbBTP64a/ajlwn0K58Cem8hvCywZrVGBn kY627gUO0qcqqseFHFwXKGaxpxQCrZH70+6hVyjJcwEN3PDqrWOUFY3BI/yNccISubCx OccQ== X-Gm-Message-State: AO0yUKXhlWp3fL7zb/24tku+Wd+dc+kePXeNWg8YUENmZy0M5CHui9/J aRzUPSXyjI/4bwnnm2gBeOrE8w== X-Google-Smtp-Source: AK7set/13U3qP0JWjh6ybTiWDaOZxDxzGmlrUykQf0SQ6ySy/QgfU/CC/TR1g6C/MD5hHiMJtN0tug== X-Received: by 2002:adf:df0b:0:b0:2c5:510b:8f9c with SMTP id y11-20020adfdf0b000000b002c5510b8f9cmr10000377wrl.52.1677167748904; Thu, 23 Feb 2023 07:55:48 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id j16-20020a056000125000b002c5706f7c6dsm7255794wrx.94.2023.02.23.07.55.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 23 Feb 2023 07:55:48 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Markus Armbruster , qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Song Gao , Xiaojuan Yang , Peter Maydell , Greg Kurz , David Gibson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Richard Henderson Subject: [PATCH v4 1/4] target/arm: Restrict 'qapi-commands-machine.h' to system emulation Date: Thu, 23 Feb 2023 16:55:37 +0100 Message-Id: <20230223155540.30370-2-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230223155540.30370-1-philmd@linaro.org> References: <20230223155540.30370-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=philmd@linaro.org; helo=mail-wr1-x431.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.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. Move the QMP functions from helper.c (which is always compiled) to monitor.c (which is only compiled when system-emulation is selected). Rename monitor.c to arm-qmp-cmds.c. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- target/arm/{monitor.c => arm-qmp-cmds.c} | 28 +++++++++++++++++++++++ target/arm/helper.c | 29 ------------------------ target/arm/meson.build | 2 +- 3 files changed, 29 insertions(+), 30 deletions(-) rename target/arm/{monitor.c => arm-qmp-cmds.c} (90%) diff --git a/target/arm/monitor.c b/target/arm/arm-qmp-cmds.c similarity index 90% rename from target/arm/monitor.c rename to target/arm/arm-qmp-cmds.c index ecdd5ee817..c8fa524002 100644 --- a/target/arm/monitor.c +++ b/target/arm/arm-qmp-cmds.c @@ -227,3 +227,31 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type, return expansion_info; } + +static void arm_cpu_add_definition(gpointer data, gpointer user_data) +{ + ObjectClass *oc = data; + CpuDefinitionInfoList **cpu_list = user_data; + CpuDefinitionInfo *info; + const char *typename; + + typename = object_class_get_name(oc); + info = g_malloc0(sizeof(*info)); + info->name = g_strndup(typename, + strlen(typename) - strlen("-" TYPE_ARM_CPU)); + info->q_typename = g_strdup(typename); + + QAPI_LIST_PREPEND(*cpu_list, info); +} + +CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) +{ + CpuDefinitionInfoList *cpu_list = NULL; + GSList *list; + + list = object_class_get_list(TYPE_ARM_CPU, false); + g_slist_foreach(list, arm_cpu_add_definition, &cpu_list); + g_slist_free(list); + + return cpu_list; +} diff --git a/target/arm/helper.c b/target/arm/helper.c index 07d4100365..77eed96761 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -23,7 +23,6 @@ #include "sysemu/cpu-timers.h" #include "sysemu/kvm.h" #include "sysemu/tcg.h" -#include "qapi/qapi-commands-machine-target.h" #include "qapi/error.h" #include "qemu/guest-random.h" #ifdef CONFIG_TCG @@ -9212,34 +9211,6 @@ void arm_cpu_list(void) g_slist_free(list); } -static void arm_cpu_add_definition(gpointer data, gpointer user_data) -{ - ObjectClass *oc = data; - CpuDefinitionInfoList **cpu_list = user_data; - CpuDefinitionInfo *info; - const char *typename; - - typename = object_class_get_name(oc); - info = g_malloc0(sizeof(*info)); - info->name = g_strndup(typename, - strlen(typename) - strlen("-" TYPE_ARM_CPU)); - info->q_typename = g_strdup(typename); - - QAPI_LIST_PREPEND(*cpu_list, info); -} - -CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) -{ - CpuDefinitionInfoList *cpu_list = NULL; - GSList *list; - - list = object_class_get_list(TYPE_ARM_CPU, false); - g_slist_foreach(list, arm_cpu_add_definition, &cpu_list); - g_slist_free(list); - - return cpu_list; -} - /* * Private utility function for define_one_arm_cp_reg_with_opaque(): * add a single reginfo struct to the hash table. diff --git a/target/arm/meson.build b/target/arm/meson.build index 87e911b27f..6d1ac4c471 100644 --- a/target/arm/meson.build +++ b/target/arm/meson.build @@ -59,8 +59,8 @@ arm_softmmu_ss = ss.source_set() arm_softmmu_ss.add(files( 'arch_dump.c', 'arm-powerctl.c', + 'arm-qmp-cmds.c', 'machine.c', - 'monitor.c', 'psci.c', 'ptw.c', )) From patchwork Thu Feb 23 15:55: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: 1747022 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=EjVVFIv2; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PMyMv4xkgz245y for ; Fri, 24 Feb 2023 02:57:31 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVDwt-0005Py-6m; Thu, 23 Feb 2023 10:55:59 -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 1pVDwr-0005PQ-P6 for qemu-devel@nongnu.org; Thu, 23 Feb 2023 10:55:57 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVDwp-0004ND-Ve for qemu-devel@nongnu.org; Thu, 23 Feb 2023 10:55:57 -0500 Received: by mail-wm1-x334.google.com with SMTP id k37so6330613wms.0 for ; Thu, 23 Feb 2023 07:55: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=EjVVFIv2OXrE8yqSVI9DjSKfmt0LAHM75BrT+OuZP3PhrTuz62Wjse51IkrLswrb1c IHst7NlS6LrDmjYV2DzRBs45Q5pTURP9AQA576ycylUkX/Rc6Z2rVFWq5Rb8jlf7Zd+2 GT+4/6Rvgsy8ZbGWt1bfkeediG7KRV/xb8jVeSWzmUHdvmaJJn5uOw5bgjmAmdaKoQXL 9bTtXCFvQRrK7vcnTKyotFO+6NEpWLp1PptUDfYWKClymqznFWgbBi7FWeWiE1k1aNZ+ Gr1NFw8WH5Jp55JB3iIOMZwPnzb/p6tsRYiZjM894Wl3TXQrOOIYiHLss4EMpK8qLXet KW/Q== 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=hR6qvBsi9s1sh3G6gM1LVA9YfixBzcjbQPIFlsB35UKQOT/WOA1pHD2nic4CDN4JQ+ pejeS9mlmm1JrPw4cAy312ZZsNVqqh7Jbpm+SzM08hR3Kxc7psCQvnYWA36OX93OcKSp Jf3g1mYXJuqK4xfxpWGBFFPgQZmGSZn5lAiqdqKZF48ehpLHv0VgwIJY3JzsDHliP4Ju YRR+5FEwi6Lda/OcbEOnXQmBjiLNAnJKHMateF1VDqla4hFcMjQFJTPyz6i745PazT/p QvFUiCPUrlCdWTGTD0M6zEL7+teG3lc2VcovaLPeUa3HB/0I5vzPdNgLb5ro414sXZnH 73yQ== X-Gm-Message-State: AO0yUKXah2zTLFIIWRJHTgbWdCKE3HO0dH4J825cQ7CDyWdX0mcIq8mf BQlPLTVA+3CALOctqadLtFirNg== X-Google-Smtp-Source: AK7set/m1evVfqvFhJYOVspjj/NH7/tO4hqyKVL+z88IV3/eMACp7IDx+JaLIYryNGxHoMUvITlYkw== X-Received: by 2002:a05:600c:3412:b0:3ea:d65e:4b31 with SMTP id y18-20020a05600c341200b003ead65e4b31mr623056wmp.18.1677167754518; Thu, 23 Feb 2023 07:55:54 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id w6-20020adff9c6000000b002c5493a17efsm7356025wrr.25.2023.02.23.07.55.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 23 Feb 2023 07:55:54 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Markus Armbruster , qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Song Gao , Xiaojuan Yang , Peter Maydell , Greg Kurz , David Gibson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Richard Henderson Subject: [PATCH v4 2/4] target/i386: Restrict 'qapi-commands-machine.h' to system emulation Date: Thu, 23 Feb 2023 16:55:38 +0100 Message-Id: <20230223155540.30370-3-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230223155540.30370-1-philmd@linaro.org> References: <20230223155540.30370-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.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) { From patchwork Thu Feb 23 15:55:39 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: 1747015 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=iqCzEfcT; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PMyLp0SGDz245y for ; Fri, 24 Feb 2023 02:56:33 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVDx2-0005Vc-L1; Thu, 23 Feb 2023 10:56:08 -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 1pVDx1-0005Tx-Pu for qemu-devel@nongnu.org; Thu, 23 Feb 2023 10:56:07 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVDwv-0004OF-WD for qemu-devel@nongnu.org; Thu, 23 Feb 2023 10:56:07 -0500 Received: by mail-wm1-x335.google.com with SMTP id l2-20020a05600c1d0200b003e1f6dff952so10973830wms.1 for ; Thu, 23 Feb 2023 07:56:01 -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=I08xnbCAg9THlmYOfaTYm5NT+g+TJhbsT75T9PCPFbc=; b=iqCzEfcTqtj8SbW2sZ2v5aY5W47vSQ2ZGFxXz+kcncFlzHySWdHVIfbvvhs46wUOAo inbAVbX+vFl/OkcApjQ/tKizmHnZY7LqTinODyJSSEYHpc9HckAOSra4tGvozkT2yjT9 FSNfXdXksPLvuL407CTcQm2JeQsCEj82IyXRUiWS7ZOmoG7xEu6rqSCu0qZW3kpacvoy jSvCj/4ShXdfZUgUzVk3KtvBUykYSow3EXkADfzg1tpMD3lypiRsTKvdzgist4gkRtpC BK2h3HfvyvCsBzi2iPZIsddLaiCOX+VJEn6fLtP53Yc7tujx5RTmT/iwFXwjINrzcd+V niZw== 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=I08xnbCAg9THlmYOfaTYm5NT+g+TJhbsT75T9PCPFbc=; b=WDtNp9S6glVVZIUXsHRGe3iE+LIX2rK6sq2rXL/ed06LT8Z589K3HImK0YL7qo39oe B8y8/3F0ovZzMtOyh3XxvTUq3TL4bY9Ug9j11VV+Xc9CQxpKrqWp6ZFIoz9LOES33rUI vD5XeCVDDQfxIXGM67xQdLobvoFQa4TVy0NJgNgY6hdnvXL0XfVklOQtT6xK245Um9QB ZiZHBWCOgxN60p69i9hj2AXC9zP03TaSlBr/RtC2vRo3Avb/LJ8cVDEbJTpTZuryacKc Ih/X3AoRfDOH7xckKMZDd6tmK8w5DfW5qhs3uXle24Qxd24A65Y6D6EzCCb+6hl0aSaK VB5g== X-Gm-Message-State: AO0yUKWNbil5OvEeRW1c8tDwCheFqDNt/OfjdwiMA0nONqnUQHjXXAi0 jXPF06NSj5rMqbVDCQGAdWFfnw== X-Google-Smtp-Source: AK7set/wKxAslnjkZIzkcluc/lGTbsyogMcdJ3kvKxEorYSOmW1mKIHewy8DLXYRESniK/BmcyKb0A== X-Received: by 2002:a05:600c:929:b0:3df:e6bb:768 with SMTP id m41-20020a05600c092900b003dfe6bb0768mr8601117wmp.24.1677167760098; Thu, 23 Feb 2023 07:56:00 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id m6-20020a05600c4f4600b003df245cd853sm14571119wmq.44.2023.02.23.07.55.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 23 Feb 2023 07:55:59 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Markus Armbruster , qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Song Gao , Xiaojuan Yang , Peter Maydell , Greg Kurz , David Gibson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Richard Henderson Subject: [PATCH v4 3/4] target/loongarch: Restrict 'qapi-commands-machine.h' to system emulation Date: Thu, 23 Feb 2023 16:55:39 +0100 Message-Id: <20230223155540.30370-4-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230223155540.30370-1-philmd@linaro.org> References: <20230223155540.30370-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.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. Extract the QMP functions from cpu.c (which is always compiled) to the new 'loongarch-qmp-cmds.c' unit (which is only compiled when system emulation is selected). Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé --- target/loongarch/cpu.c | 27 ------------------- target/loongarch/loongarch-qmp-cmds.c | 37 +++++++++++++++++++++++++++ target/loongarch/meson.build | 1 + 3 files changed, 38 insertions(+), 27 deletions(-) create mode 100644 target/loongarch/loongarch-qmp-cmds.c diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index 290ab4d526..4e845ba29b 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -12,7 +12,6 @@ #include "qemu/module.h" #include "sysemu/qtest.h" #include "exec/exec-all.h" -#include "qapi/qapi-commands-machine-target.h" #include "cpu.h" #include "internals.h" #include "fpu/softfloat-helpers.h" @@ -748,29 +747,3 @@ static const TypeInfo loongarch_cpu_type_infos[] = { }; DEFINE_TYPES(loongarch_cpu_type_infos) - -static void loongarch_cpu_add_definition(gpointer data, gpointer user_data) -{ - ObjectClass *oc = data; - CpuDefinitionInfoList **cpu_list = user_data; - CpuDefinitionInfo *info = g_new0(CpuDefinitionInfo, 1); - const char *typename = object_class_get_name(oc); - - info->name = g_strndup(typename, - strlen(typename) - strlen("-" TYPE_LOONGARCH_CPU)); - info->q_typename = g_strdup(typename); - - QAPI_LIST_PREPEND(*cpu_list, info); -} - -CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) -{ - CpuDefinitionInfoList *cpu_list = NULL; - GSList *list; - - list = object_class_get_list(TYPE_LOONGARCH_CPU, false); - g_slist_foreach(list, loongarch_cpu_add_definition, &cpu_list); - g_slist_free(list); - - return cpu_list; -} diff --git a/target/loongarch/loongarch-qmp-cmds.c b/target/loongarch/loongarch-qmp-cmds.c new file mode 100644 index 0000000000..6c25957881 --- /dev/null +++ b/target/loongarch/loongarch-qmp-cmds.c @@ -0,0 +1,37 @@ +/* + * QEMU LoongArch CPU (monitor definitions) + * + * SPDX-FileCopyrightText: 2021 Loongson Technology Corporation Limited + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qapi/qapi-commands-machine-target.h" +#include "cpu.h" + +static void loongarch_cpu_add_definition(gpointer data, gpointer user_data) +{ + ObjectClass *oc = data; + CpuDefinitionInfoList **cpu_list = user_data; + CpuDefinitionInfo *info = g_new0(CpuDefinitionInfo, 1); + const char *typename = object_class_get_name(oc); + + info->name = g_strndup(typename, + strlen(typename) - strlen("-" TYPE_LOONGARCH_CPU)); + info->q_typename = g_strdup(typename); + + QAPI_LIST_PREPEND(*cpu_list, info); +} + +CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) +{ + CpuDefinitionInfoList *cpu_list = NULL; + GSList *list; + + list = object_class_get_list(TYPE_LOONGARCH_CPU, false); + g_slist_foreach(list, loongarch_cpu_add_definition, &cpu_list); + g_slist_free(list); + + return cpu_list; +} diff --git a/target/loongarch/meson.build b/target/loongarch/meson.build index 690633969f..9293a8ab78 100644 --- a/target/loongarch/meson.build +++ b/target/loongarch/meson.build @@ -16,6 +16,7 @@ loongarch_tcg_ss.add(zlib) loongarch_softmmu_ss = ss.source_set() loongarch_softmmu_ss.add(files( + 'loongarch-qmp-cmds.c', 'machine.c', 'tlb_helper.c', 'constant_timer.c', From patchwork Thu Feb 23 15:55:40 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: 1747016 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=iEtSq7cS; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PMyLy4S8Sz245y for ; Fri, 24 Feb 2023 02:56:42 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVDx5-0005f8-Fi; Thu, 23 Feb 2023 10:56:11 -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 1pVDx2-0005UH-8Z for qemu-devel@nongnu.org; Thu, 23 Feb 2023 10:56:08 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVDx0-0004ND-EW for qemu-devel@nongnu.org; Thu, 23 Feb 2023 10:56:08 -0500 Received: by mail-wm1-x334.google.com with SMTP id k37so6331091wms.0 for ; Thu, 23 Feb 2023 07:56:06 -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=mw+4/3TevhP31o7/JZOL/mpLf299sYsuDsmbmLV40SU=; b=iEtSq7cSqa7WtqGcBrMBg0zzkm59CGtK2L1zLwsyhvhekKxY9ffFumiY9b6lCSuj0L e2fueJmFvPXEh1YPk3UXOcJAoKemJgI+cU/raDDENkoOfIRW9ciX7SjffvQPg2DR7Qu6 SgA0wA14+A346PX+5GokpS/1KCf1bSEi+AzvrDT3zop+YofMD3jCHTwu7GYSW3SfJuHv sXBgJMSBqoEawDVazGmrgO7pmFaxLCPu7stx4KPsb3uWeSt1NNOnqkAhVWbdxLbqa5dH Up3jJcpHxRxYLyg5zBrkCL9tV4an5i7A/FbSMqJTOEhn6qPKg38tAZdRLiN7o1ysZhjc 7TkQ== 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=mw+4/3TevhP31o7/JZOL/mpLf299sYsuDsmbmLV40SU=; b=QPzRNbfb+pzUA3sf0rpQn2nEIQiJaGF5wvplkx6ynDEar9H+xmdduABMkpOIOolcrG yK9YPB1D0jOeSyda25l5qGkOrlHd/V5ofwlEP8U/axwI3XO8K81jsLAfmniXApLLh6Qi cR4GWpBws1xL6afJD1fyiG/MHsSwYCLyZP2POn3cbH2pu0KOnCYpzqwGY0jbxhe0yzy+ ayQczV97HXHwxIGlt/Iri1LApDf4rT4fmkFGDZ4OhsIMHI8z9yIbYEUf/olKARCTmfc0 9M3u+2ptRnG3Ln9DNHklD3hI9aJVQ+PtFj8WCs985uryWXAD8M6y0Fypxpod1HtVTxpI oK2g== X-Gm-Message-State: AO0yUKW+CWO+xJ0axI2molaMLFEhBPEnVbV7+Nj3Z4F+Vt9SBvFsVwCR rEV00mK7lpFyPr+xNhwRGAh1iOLEYUur62lF X-Google-Smtp-Source: AK7set8slqynP/r1KEjWZ1gtq5mpBGAk6pjamfGyYo/vY3qw52vbZhbUaGvF6/pkFrn1Z1AbtTT6Fw== X-Received: by 2002:a05:600c:32a7:b0:3ea:e4bb:4e84 with SMTP id t39-20020a05600c32a700b003eae4bb4e84mr328025wmp.20.1677167765548; Thu, 23 Feb 2023 07:56:05 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id h7-20020a5d6887000000b002c5501a5803sm8689396wru.65.2023.02.23.07.56.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 23 Feb 2023 07:56:05 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Markus Armbruster , qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Song Gao , Xiaojuan Yang , Peter Maydell , Greg Kurz , David Gibson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Richard Henderson Subject: [PATCH v4 4/4] target/ppc: Restrict 'qapi-commands-machine.h' to system emulation Date: Thu, 23 Feb 2023 16:55:40 +0100 Message-Id: <20230223155540.30370-5-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230223155540.30370-1-philmd@linaro.org> References: <20230223155540.30370-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.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. Move the QMP functions from cpu_init.c (which is always compiled) to monitor.c (which is only compiled when system-emulation is selected). Rename monitor.c to arm-qmp-cmds.c. Note ppc_cpu_class_by_name() is used by both file units, so we expose its prototype in "cpu-qom.h". Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Reviewed-by: Cédric Le Goater --- target/ppc/cpu-qom.h | 2 + target/ppc/cpu_init.c | 48 +---------------------- target/ppc/meson.build | 2 +- target/ppc/{monitor.c => ppc-qmp-cmds.c} | 50 +++++++++++++++++++++++- 4 files changed, 53 insertions(+), 49 deletions(-) rename target/ppc/{monitor.c => ppc-qmp-cmds.c} (78%) diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h index 0fbd8b7246..9666f54f65 100644 --- a/target/ppc/cpu-qom.h +++ b/target/ppc/cpu-qom.h @@ -31,6 +31,8 @@ OBJECT_DECLARE_CPU_TYPE(PowerPCCPU, PowerPCCPUClass, POWERPC_CPU) +ObjectClass *ppc_cpu_class_by_name(const char *name); + typedef struct CPUArchState CPUPPCState; typedef struct ppc_tb_t ppc_tb_t; typedef struct ppc_dcr_t ppc_dcr_t; diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index abee71d407..d62ffe8a6f 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -40,7 +40,6 @@ #include "qemu/cutils.h" #include "disas/capstone.h" #include "fpu/softfloat.h" -#include "qapi/qapi-commands-machine-target.h" #include "helper_regs.h" #include "internal.h" @@ -6841,7 +6840,7 @@ static const char *ppc_cpu_lookup_alias(const char *alias) return NULL; } -static ObjectClass *ppc_cpu_class_by_name(const char *name) +ObjectClass *ppc_cpu_class_by_name(const char *name) { char *cpu_model, *typename; ObjectClass *oc; @@ -6981,51 +6980,6 @@ void ppc_cpu_list(void) #endif } -static void ppc_cpu_defs_entry(gpointer data, gpointer user_data) -{ - ObjectClass *oc = data; - CpuDefinitionInfoList **first = user_data; - const char *typename; - CpuDefinitionInfo *info; - - typename = object_class_get_name(oc); - info = g_malloc0(sizeof(*info)); - info->name = g_strndup(typename, - strlen(typename) - strlen(POWERPC_CPU_TYPE_SUFFIX)); - - QAPI_LIST_PREPEND(*first, info); -} - -CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) -{ - CpuDefinitionInfoList *cpu_list = NULL; - GSList *list; - int i; - - list = object_class_get_list(TYPE_POWERPC_CPU, false); - g_slist_foreach(list, ppc_cpu_defs_entry, &cpu_list); - g_slist_free(list); - - for (i = 0; ppc_cpu_aliases[i].alias != NULL; i++) { - PowerPCCPUAlias *alias = &ppc_cpu_aliases[i]; - ObjectClass *oc; - CpuDefinitionInfo *info; - - oc = ppc_cpu_class_by_name(alias->model); - if (oc == NULL) { - continue; - } - - info = g_malloc0(sizeof(*info)); - info->name = g_strdup(alias->alias); - info->q_typename = g_strdup(object_class_get_name(oc)); - - QAPI_LIST_PREPEND(cpu_list, info); - } - - return cpu_list; -} - static void ppc_cpu_set_pc(CPUState *cs, vaddr value) { PowerPCCPU *cpu = POWERPC_CPU(cs); diff --git a/target/ppc/meson.build b/target/ppc/meson.build index 79beaff147..7929de8360 100644 --- a/target/ppc/meson.build +++ b/target/ppc/meson.build @@ -39,7 +39,7 @@ ppc_softmmu_ss.add(files( 'machine.c', 'mmu-hash32.c', 'mmu_common.c', - 'monitor.c', + 'ppc-qmp-cmds.c', )) ppc_softmmu_ss.add(when: 'CONFIG_TCG', if_true: files( 'mmu_helper.c', diff --git a/target/ppc/monitor.c b/target/ppc/ppc-qmp-cmds.c similarity index 78% rename from target/ppc/monitor.c rename to target/ppc/ppc-qmp-cmds.c index 8250b1304e..36e5b5eff8 100644 --- a/target/ppc/monitor.c +++ b/target/ppc/ppc-qmp-cmds.c @@ -1,5 +1,5 @@ /* - * QEMU monitor + * QEMU PPC (monitor definitions) * * Copyright (c) 2003-2004 Fabrice Bellard * @@ -28,6 +28,9 @@ #include "qemu/ctype.h" #include "monitor/hmp-target.h" #include "monitor/hmp.h" +#include "qapi/qapi-commands-machine-target.h" +#include "cpu-models.h" +#include "cpu-qom.h" static target_long monitor_get_ccr(Monitor *mon, const struct MonitorDef *md, int val) @@ -172,3 +175,48 @@ int target_get_monitor_def(CPUState *cs, const char *name, uint64_t *pval) return -EINVAL; } + +static void ppc_cpu_defs_entry(gpointer data, gpointer user_data) +{ + ObjectClass *oc = data; + CpuDefinitionInfoList **first = user_data; + const char *typename; + CpuDefinitionInfo *info; + + typename = object_class_get_name(oc); + info = g_malloc0(sizeof(*info)); + info->name = g_strndup(typename, + strlen(typename) - strlen(POWERPC_CPU_TYPE_SUFFIX)); + + QAPI_LIST_PREPEND(*first, info); +} + +CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) +{ + CpuDefinitionInfoList *cpu_list = NULL; + GSList *list; + int i; + + list = object_class_get_list(TYPE_POWERPC_CPU, false); + g_slist_foreach(list, ppc_cpu_defs_entry, &cpu_list); + g_slist_free(list); + + for (i = 0; ppc_cpu_aliases[i].alias != NULL; i++) { + PowerPCCPUAlias *alias = &ppc_cpu_aliases[i]; + ObjectClass *oc; + CpuDefinitionInfo *info; + + oc = ppc_cpu_class_by_name(alias->model); + if (oc == NULL) { + continue; + } + + info = g_malloc0(sizeof(*info)); + info->name = g_strdup(alias->alias); + info->q_typename = g_strdup(object_class_get_name(oc)); + + QAPI_LIST_PREPEND(cpu_list, info); + } + + return cpu_list; +}