From patchwork Tue Dec 20 11:11:18 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: 635452 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2865693pvb; Tue, 20 Dec 2022 03:52:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf7aAKZn64Wxg8sDBRnNYQQca7T6MA2EGfKFECnkLVt9B7GoxPmIcN79sGRx43i0XfK40ZTn X-Received: by 2002:ac8:60b:0:b0:3a6:a86f:33cd with SMTP id d11-20020ac8060b000000b003a6a86f33cdmr56232090qth.51.1671537139813; Tue, 20 Dec 2022 03:52:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671537139; cv=none; d=google.com; s=arc-20160816; b=TtMohicWIkimNQtwIXezy+V0M2VATevChAhh2MQsLJxZjWrp/OTa1kOo4pA5R5ABdR iJexDbTx2Ktix3Zo6iI854jsMfHk16yf0eM0GI5UbcT8XX+XEcPVkYQIhfTll699K0L4 rnSTak/99A3VbD55etfS5KjqEhjCf4HTg9AFMmjgQvQXP8qqMj4NJ/a6foKzxyDLv7ON 1l33su7hj3Ncf1cI2DO1APgPuOWY07BHMaFQgBbKhmRmKupR7FgSr51l2pTY6BFDL9DI ta8Gex5sZkQVTR9SZyM+d++2r3ctlc55rKKNticJ4q3nD4qxn5BA3dVwUqM4Dc7mmIsh 2Lpg== 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=VCqVdn1MR+8q4KNBpfFHWACRBuZ63eQE6lUtevF78ks=; b=ZSiw+QUNfhdl7GQK/ZFz+D/zqqnuAwoqRl55x+6B3e/gsAr/YYB9UoNA/gVcdcsyq6 p1tmg1HrIpttUc+xN4zJ9sampJuwXJibdOZA+lKo2TpklMWprgU4fyxq6npEw77fGvQG 6/3CB2cokgqNDOBZM6Zpdjd7lKks9zGYjPN5uS7nVj7guOJhQqz7BwOue7ZiLi3JDvLH 8exwc8xE7ygYIDUAw1ZLqteJw7jzxU8TMllGAuNf9/2ZBiEFUhhPUKj9YAgJkV1IUQGF cUH/+KhczTiRd+Isj35YlXVKsJLvil8vj2UAZt323nz2WmvvMG2+U7uEA/IiAyTu3uML 6HqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=m9I9n35A; 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 i9-20020a05620a248900b006fb112f50b8si5580246qkn.287.2022.12.20.03.52.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Dec 2022 03:52:19 -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=m9I9n35A; 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 1p7aX9-00043S-7F; Tue, 20 Dec 2022 06:11:43 -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 1p7aX1-0003xo-JZ for qemu-devel@nongnu.org; Tue, 20 Dec 2022 06:11:37 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p7aWz-0003gq-DK for qemu-devel@nongnu.org; Tue, 20 Dec 2022 06:11:35 -0500 Received: by mail-wr1-x42a.google.com with SMTP id y16so11410922wrm.2 for ; Tue, 20 Dec 2022 03:11:32 -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=VCqVdn1MR+8q4KNBpfFHWACRBuZ63eQE6lUtevF78ks=; b=m9I9n35AZ90i95iGax9u7TMEhXh7YAgapljHRhcm9uHC7lNWfexO1qBDhFJ+eT6yAk pb7tjkxt8a9fnvXwhL1OZl3cLsWZ57AZyxLQIiEw7nqPnlw12nq2nAAQ11p+GrHyj89x RbV4SX0JnJIFLo1+fP9WCPCr2m20x8jtQ7bpQQUeDDgeCYwmbtjzERyHVGCUa79+tp78 ZONVI4oYhg0VE5tf5dB8qzcZguYjslbQFR7jGUQfdoYTPNTJqmshERVhOcGcxyeD1gFW Fi3rjU3B2eH3toD1xXNyDBsHMYVL1no2D7+I8rASgT1QhX5n/JkwvBsSGldVntLOqOdc HTPA== 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=VCqVdn1MR+8q4KNBpfFHWACRBuZ63eQE6lUtevF78ks=; b=wyTPTN8lCy/JTyB3us5HexMpqjV6ZM2NLM3qhN3yF92zeeH+GvVPmYTvdkauB2Sku8 yZ6y+Rg1dhroPEIkjJdAcqu10vvnec2HHKhgWAx1w+RbSYiPKbA8EjeHjWVjZIWxTxKb 7X2aSRbN3tjtWChiOzCZ75rOu1iDCNawn8elkbWAD9T0dZkwhHZhMttszCqdWALWm7SG o/auEDqH2IPFY5p7SYTya5xoKFlyNlnOEfa8MhDEpTvoxIFC5LbK5hl5zHtclORMF7FA Lq+dKPvB0XfDvfwNacPb4CCeUGk7Ea7ZSnP+VEpa1qe3hV83MA34SSvWnkpxzd5R6HAo VHRA== X-Gm-Message-State: AFqh2kr5TkdBjZ0tBPFFyOYpAmtzfd1SReOppHTMhu+6q+5zFsGzkNTd ZtQkiBLu0iYdSlFrKnSRdRfxGfdQ11374QJ9xYU= X-Received: by 2002:a5d:4143:0:b0:262:3647:c1b1 with SMTP id c3-20020a5d4143000000b002623647c1b1mr862528wrq.58.1671534691371; Tue, 20 Dec 2022 03:11:31 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id p2-20020adfe602000000b002368f6b56desm14709827wrm.18.2022.12.20.03.11.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 20 Dec 2022 03:11:30 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Greg Kurz , Daniel Henrique Barboza , =?utf-8?q?Philippe_Mathieu?= =?utf-8?q?-Daud=C3=A9?= , Xiaojuan Yang , Aurelien Jarno , Huacai Chen , Aleksandar Rikalo , qemu-arm@nongnu.org, David Gibson , Jiaxun Yang , Markus Armbruster , Song Gao , Richard Henderson Subject: [PATCH RESEND v2 1/5] target/arm: Restrict 'qapi-commands-machine.h' to system emulation Date: Tue, 20 Dec 2022 12:11:18 +0100 Message-Id: <20221220111122.8966-2-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221220111122.8966-1-philmd@linaro.org> References: <20221220111122.8966-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philmd@linaro.org; helo=mail-wr1-x42a.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 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). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- target/arm/helper.c | 29 ----------------------------- target/arm/m_helper.c | 1 - target/arm/monitor.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 30 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index bac2ea62c4..399603b680 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -27,7 +27,6 @@ #include "sysemu/cpu-timers.h" #include "sysemu/kvm.h" #include "qemu/range.h" -#include "qapi/qapi-commands-machine-target.h" #include "qapi/error.h" #include "qemu/guest-random.h" #ifdef CONFIG_TCG @@ -8514,34 +8513,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/m_helper.c b/target/arm/m_helper.c index 355cd4d60a..11008528b5 100644 --- a/target/arm/m_helper.c +++ b/target/arm/m_helper.c @@ -26,7 +26,6 @@ #include "sysemu/cpus.h" #include "sysemu/kvm.h" #include "qemu/range.h" -#include "qapi/qapi-commands-machine-target.h" #include "qapi/error.h" #include "qemu/guest-random.h" #ifdef CONFIG_TCG diff --git a/target/arm/monitor.c b/target/arm/monitor.c index ecdd5ee817..c8fa524002 100644 --- a/target/arm/monitor.c +++ b/target/arm/monitor.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; +} From patchwork Tue Dec 20 11:11:19 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: 635439 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2850918pvb; Tue, 20 Dec 2022 03:14:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf6Inf6Iu6xvh5oUu928a4zwNCMBlashN77xaN0nyxLFX3SiiUAB10VGYGkg3Hj1wbGE/k1y X-Received: by 2002:ac8:45c8:0:b0:3a8:23d4:8d2b with SMTP id e8-20020ac845c8000000b003a823d48d2bmr32035084qto.10.1671534872781; Tue, 20 Dec 2022 03:14:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671534872; cv=none; d=google.com; s=arc-20160816; b=ND+EuQfg2IMr2KpYzSQpu6IB3PbnBy/R0bXYqJwZikWN6XHdLtS3F89MKJ97j6qoIf 8j/169eFSNm7ujbND1RNB03eZKzaE9XXWw9bJt6UKRi0fXC3Kuhe04nT+CKDsMa6ggYC oAv0IH6a3tWOiTY9SE8pQKFFXifBuVu/WBsRlSjkbyYy9sc+zS+FAlOPOiFvoCre4IHg fqr1mwomgxDLhtlMvF1X8PR5wpkqgDs//eXFVVwEQNuClTDJj4fswAeAFgj7L2xAmnPI 5lR+Pbr3X1MSWRjWiLNelip7hSBNUrfYkU+YArtDafgw7nQVtGZr8WfNXLyHrndNYiJB lxYg== 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=bpGlv5Im1QiqXz4tNSw5DXHhllEUKFBTGKynECqClis=; b=hl/d6AWNZDS/jCsfvFMQp7oTbU8FroMKt5bzbBmhzZoB9qeCeurK/Bh+ipzMCaOcJ6 Cr/DMVCQiEWLszvAT/CkzctLQYXmhhhqRWv9aV8ipQnfu2B02CRJnlkIxixBt0voU5h4 JgyLPK8g42+nmwsAJmgJ1p1ka53RcMzg9StxqHjkZiZKAbY8SyS0lp5Adny9JFv53ucr hTMZanopQyuylvcKekuNUXUapvWKUomMheh541MKdeVq1cG3D06LTMo8vw9OMYcxMa8O INv6pjPMTNB8CMXv3YaNCQ/2wcHr2Yh/FZiBgjP8xTSyR2zs3OHc6+KHbMdZm8GS99wU Utdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FKlr0Zk6; 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 n17-20020a05620a223100b006feb5642b82si4704395qkh.242.2022.12.20.03.14.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Dec 2022 03:14:32 -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=FKlr0Zk6; 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 1p7aXB-000464-B8; Tue, 20 Dec 2022 06:11:45 -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 1p7aX7-000425-DM for qemu-devel@nongnu.org; Tue, 20 Dec 2022 06:11:43 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p7aX4-0003hv-NE for qemu-devel@nongnu.org; Tue, 20 Dec 2022 06:11:41 -0500 Received: by mail-wm1-x332.google.com with SMTP id m5-20020a7bca45000000b003d2fbab35c6so8466207wml.4 for ; Tue, 20 Dec 2022 03:11:38 -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=bpGlv5Im1QiqXz4tNSw5DXHhllEUKFBTGKynECqClis=; b=FKlr0Zk6ExK6JcNhOcjuyY+udH7JTVYrpyE4cSm0vyoOg91WOu6KQdyusPNjpxSWk9 XopBqEd0yDsOR4um9wk9SGbsWJTSKugpyQJFC4B11Q3m2sWCwM2whVi8eWx5bu4Wim44 hlcfqoifG6mtcwddkqsrE9JREfw73D50hQ53RI3hEYvCwcIWRyuMgvYlVtHUCTBV09Vw pRsdvkXI3fwEBmFWAuNL+Cy4uCvqIu27bxYy+uuGM7p9LWZdFamWLx5e5i1vREdc+B6A mds56Khd0POMG1Q0wbRTrRyMat8EXsWh2BkGjKegdnoOdRxE3c5lNrrVjyhjnKZiIn1k oLqw== 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=bpGlv5Im1QiqXz4tNSw5DXHhllEUKFBTGKynECqClis=; b=HxRSX76/08LK+ZNDOngMSpJnl8rjao9ksR6NkZ9UuWaZxBuGNNxHdOxpbIx0WqLazl SU4kuqZELgXdveb2WYX1ToBC8lRlvditL4O7wApg4uVSxKjYkot8lWSHvPYGZfMWV4oU dPwfJqR5piRa3LHG9b/ZdXmwkHq6/9JIKayFXY9E7E9t0ywIeEWFNycXYhMCT5amStjI MqDFrAnI4V+4XbHoJy2L/hfnUmemwu1W6j0c5jiHJuTk7i4SZ9y2XH5u4rXCkyyPTl2u xLUMHiVgfb/8X1twnOGAwObx1gv+axPpBnRz3eULMhMC1M4ForOVg1VPacW96TIAFaai Zl4Q== X-Gm-Message-State: ANoB5pnvyu0p6S0SkaLEoYsdVtVV8gSDJB90yabYVYaGU2h0Ff2+P1on IUIN1hi0jHNtj0rAxvx/235eUVzxTDjwN2noYZ4= X-Received: by 2002:a05:600c:20c:b0:3d2:39dc:f50e with SMTP id 12-20020a05600c020c00b003d239dcf50emr17157167wmi.7.1671534696821; Tue, 20 Dec 2022 03:11:36 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id m4-20020a05600c3b0400b003c6b7f5567csm2669421wms.0.2022.12.20.03.11.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 20 Dec 2022 03:11:36 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Greg Kurz , Daniel Henrique Barboza , =?utf-8?q?Philippe_Mathieu?= =?utf-8?q?-Daud=C3=A9?= , Xiaojuan Yang , Aurelien Jarno , Huacai Chen , Aleksandar Rikalo , qemu-arm@nongnu.org, David Gibson , Jiaxun Yang , Markus Armbruster , Song Gao , Richard Henderson Subject: [PATCH RESEND v2 2/5] target/i386: Restrict 'qapi-commands-machine.h' to system emulation Date: Tue, 20 Dec 2022 12:11:19 +0100 Message-Id: <20221220111122.8966-3-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221220111122.8966-1-philmd@linaro.org> References: <20221220111122.8966-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.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 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) { From patchwork Tue Dec 20 11:11:20 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: 635438 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2850860pvb; Tue, 20 Dec 2022 03:14:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf4BhoSP4Go3jbAr/MXRPAetmQbStlEYXZwMVTVHNqRF/PPvfC0HkNe1V3F/ZrHM91NGQfpo X-Received: by 2002:ac8:7117:0:b0:3a8:2adc:1c7a with SMTP id z23-20020ac87117000000b003a82adc1c7amr27289787qto.4.1671534866494; Tue, 20 Dec 2022 03:14:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671534866; cv=none; d=google.com; s=arc-20160816; b=of4SGD/cDL1sxutHbsWHQkaTbOUZhm3/aj4pjVIo+VCDNaj1f4KfGgIzOT3svrPS7v /dGAp+Aotde14Vw9EDdsqlYcriHeB0Ue7ksNwMCfxT7rYG1flAS5MUlsfhSCjeFIHJiV NCzCBGiYa7NG7iFAosItWNuBPz4AnDatZgYF7s/ilD59G19Vu0bCew36RkORwTfwy6B2 wWijMojd3I8spzPmu1MiJMDxk21p0kkpIJmyl4UZlqt6Ig8iDIoFhwUCPkuU8AuFiOSa nrCWsug9KVJFE3lWO3tLIGXudK9pZgtrGtAFW6h8Wp0VT8DMGn9gNkjCm6W5kQzaDezi sVWw== 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=MyQMRgrRRtBuBRaMJJ8Zm89RkSug1TwSfRjxwE6LfEk=; b=xjg2Zkqc8KNjYW+acKrOdzPO8WYgCXOl5ns51RmZnhMpXwbt7kXYSv1lACIwJQ21iQ W2MlhjwEvoXzZXWiVNsqMr3j4NqmcvaaGqDZ9YfWIGgJuv+VX73mgUpuOEC9Oa3ihqAI rQ8WZt8F4vYMNj77U6TN4KPoXMajEqg7RIMgx5jnZnZrlqh3LRvEfl6d8BCKjqvFO9SZ fG7dmms5RenVYZcT2fIh0OTlYw69vVrrmjsTB4Rj6STjaWKYz1Sbmb3XP0pGJS76jJ8a mPQYGQp56Zg+FOWwN93EeKRrzc2lOIRsHEuwQSCvq0q82ZwBXiFDxWbI0kNVaS5cWOEK QQwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Cwj0Jl3r; 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 bs27-20020ac86f1b000000b003a69619d3d1si5231308qtb.372.2022.12.20.03.14.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Dec 2022 03:14:26 -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=Cwj0Jl3r; 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 1p7aXF-00048J-4Q; Tue, 20 Dec 2022 06:11:49 -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 1p7aXD-00047E-B2 for qemu-devel@nongnu.org; Tue, 20 Dec 2022 06:11:47 -0500 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p7aXA-0003il-I9 for qemu-devel@nongnu.org; Tue, 20 Dec 2022 06:11:47 -0500 Received: by mail-wm1-x32c.google.com with SMTP id o15so8406534wmr.4 for ; Tue, 20 Dec 2022 03:11:44 -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=MyQMRgrRRtBuBRaMJJ8Zm89RkSug1TwSfRjxwE6LfEk=; b=Cwj0Jl3rq3QyIy/DuYaQV3mPAyRBWU4A+3ZPP6rkWqiwmD9OW3nvtH0Mi+Hb8n1BCe jcqEPS0R8MPU2Z2l+qU/he7Cc0GRTwRjzgyE4ZFlpOjkzcAB+ehWBFr+Q205zbx9DVLi oKs3V8mbEKu32Y/fq1zwkAl/BorOjKnf5XQAhJQGtHnvPPDAwiMRKh8bhPlLBNZgHF95 LaiyJwxcpg/SjqWJgk+cOfEFjxdR3B0IhiQDmnZtq+ZBdwILq+bdUlM5BN7TgvPcTXRO tkGF24+oIZsju8XUYxDceLiKHXuukC+uvEKJCBIdOuW9luHDlW0ABDo5d9MJE/FT8kfY EPyA== 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=MyQMRgrRRtBuBRaMJJ8Zm89RkSug1TwSfRjxwE6LfEk=; b=v4mO1DNf27rV4zSQMOm6RzvBHhhx8B9fLek5zVVCfVZH2UifZ0uzW+Ey5/Vnv/cZTd CRyNaL4wVwEVbrerqfOD6HqTh/+LrxErnb7SxGuTFRhzxEP5hxp002Ef27Isg8tkoL24 zhKqgJa3V1oP7y7TvaG7nDrOGw0ibip5ZIb0wOkJJFRaDxqysexa0opIDtPudYDgnBVa 7Rjo4lHpxNrig8YH5nZWecADdPxWoslD6hqZBckQ/55M1rBYZmXpmQFNz9t5PDnIlbrx ja4rfwq5eTlG3/B5rS4kwzbs/NQiynnVr2S7c3BpRjWP4MRpshCqf1EaeBrJprfTebZj GC/A== X-Gm-Message-State: ANoB5pmdSOgSOH1GmISC+210gWAIl8+bF4jHHXo1DY4AVVL5d0NDywvT hWuSEUj9SmMqOOmFvv5R/XPF9TL/WYFFwBWrAQQ= X-Received: by 2002:a05:600c:1c81:b0:3d1:e907:17cb with SMTP id k1-20020a05600c1c8100b003d1e90717cbmr34340720wms.1.1671534702873; Tue, 20 Dec 2022 03:11:42 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id p189-20020a1c29c6000000b003c701c12a17sm22181405wmp.12.2022.12.20.03.11.40 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 20 Dec 2022 03:11:42 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Greg Kurz , Daniel Henrique Barboza , =?utf-8?q?Philippe_Mathieu?= =?utf-8?q?-Daud=C3=A9?= , Xiaojuan Yang , Aurelien Jarno , Huacai Chen , Aleksandar Rikalo , qemu-arm@nongnu.org, David Gibson , Jiaxun Yang , Markus Armbruster , Song Gao , Richard Henderson Subject: [PATCH RESEND v2 3/5] target/loongarch: Restrict 'qapi-commands-machine.h' to system emulation Date: Tue, 20 Dec 2022 12:11:20 +0100 Message-Id: <20221220111122.8966-4-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221220111122.8966-1-philmd@linaro.org> References: <20221220111122.8966-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=philmd@linaro.org; helo=mail-wm1-x32c.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 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 'monitor.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/meson.build | 1 + target/loongarch/monitor.c | 37 ++++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 27 deletions(-) create mode 100644 target/loongarch/monitor.c diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index e7b0e12be6..0fb853d915 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" @@ -744,29 +743,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/meson.build b/target/loongarch/meson.build index 6376f9e84b..48a7eb7c40 100644 --- a/target/loongarch/meson.build +++ b/target/loongarch/meson.build @@ -18,6 +18,7 @@ loongarch_tcg_ss.add(zlib) loongarch_softmmu_ss = ss.source_set() loongarch_softmmu_ss.add(files( 'machine.c', + 'monitor.c', 'tlb_helper.c', 'constant_timer.c', 'csr_helper.c', diff --git a/target/loongarch/monitor.c b/target/loongarch/monitor.c new file mode 100644 index 0000000000..6c25957881 --- /dev/null +++ b/target/loongarch/monitor.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; +} From patchwork Tue Dec 20 11:11:21 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: 635441 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2856901pvb; Tue, 20 Dec 2022 03:30:02 -0800 (PST) X-Google-Smtp-Source: AMrXdXtnUjwltMwqZTTrqJS7JYdJplbDrnlcUqUj0dkyrw61KCW7LYHDCWMetAr3C5lBfcRwnr4Q X-Received: by 2002:a05:6214:5e09:b0:4f1:2bc5:de14 with SMTP id li9-20020a0562145e0900b004f12bc5de14mr15752052qvb.9.1671535801918; Tue, 20 Dec 2022 03:30:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671535801; cv=none; d=google.com; s=arc-20160816; b=R6arX70VTTGDZsKFzlR9th29cLbx/Rh/qKO9pYZuU87DBUTuIF8cINFc7U44S0OaxV 8ky7ibvve0NUyTn87OhRx61ywKVCYCvBGc5wahW5HhR4/nS7JXZOiNxSMLo8rav4QcJf A8HMnYxARFiSNK1bvqv4FK2H0IEOGl02i4erqbVzfkZekNq0vTLfR0mimOUb1qaUtbjX PAl9phvccLFCK8m2+D1VpItsCVWu3VhyG6a42ZaiP+UQgAFKp9izUOLLxqigqfeTxehC b/VPYBPzC2gY16WrSniMDtggOWq0O8jVRP3XT1r6LBIURpzKVvmctj7K0I2S2QV/8gO2 bGkg== 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=e1KLjwcpkRpHkyHTd4A9nwCZS64HWEF8CTuzylI9ZoM=; b=TpHTDnw13V3A/QsAypGHdV/+Q5g9z9xllu4YnR8RSPyg2LRLrELq9hqhh8KtnAxxWO NC1jQz4hORuQvHG8/XLm9jw+mzjUD3cCHulc/coGpr7DUJZOczKATpVoYXRd1c/MIHdf deg2LvzIUSPnNAD3USkxAP/e5iOFV2lWhPgaCZp7+pNjhgXpSPYLSECzYpd05lpQurXb SvY2wqWTjYgDpDKkE/R3BSNIQi6MYdePng21j7ypzXbxwYc2jZEp8Sztiwllh1OGEqZd PcHpT4Zt0rwAffnvLUUa/E8I8tYx9EcP0cB6yqTaYPl/hEWc3Kc8mgm4bbriFNbqpVFj lZsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OU5BSyF0; 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 w15-20020a05620a424f00b006fbb4b98a17si5176430qko.222.2022.12.20.03.30.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Dec 2022 03:30:01 -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=OU5BSyF0; 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 1p7aXK-0004DA-ES; Tue, 20 Dec 2022 06:11:54 -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 1p7aXH-00049p-T7 for qemu-devel@nongnu.org; Tue, 20 Dec 2022 06:11:52 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p7aXF-0003gq-OH for qemu-devel@nongnu.org; Tue, 20 Dec 2022 06:11:51 -0500 Received: by mail-wr1-x42a.google.com with SMTP id y16so11411597wrm.2 for ; Tue, 20 Dec 2022 03:11: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=e1KLjwcpkRpHkyHTd4A9nwCZS64HWEF8CTuzylI9ZoM=; b=OU5BSyF04QdnicIifhGADL+Gj7OWykvfKE3UcoqFvYYSFMjqR2IUM/yRNKMXN6sxpn r78EBMvrw0gUCLrT/3KVyldKeU5wfGwL+qhlW6c+7rJnE/EcCn4fruHOWbgpse9w8niN rXr9pCw5R2Ekc4+277RsUUrVNrUw43ll5R4jIgdK7ATHawPwmhlvjckpatAY3pnRZedy Uh+shMiYgZbFHD/PQnmWV7DXfqr5p5jZSDftAj6UXkWJx4D2ZSIykbVbJXlHcmRdWQ7j 7SdKIkhKs5+98gCj8sOqIoaiqz++0URWTwYgCF0ys0ySZk25sY/fij4lKZYUAEXm95VM HUrg== 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=e1KLjwcpkRpHkyHTd4A9nwCZS64HWEF8CTuzylI9ZoM=; b=hRFMyovl6jwAOxpF74OZBoNq2E/Aja4/CD8DWmI4ugTvv89riyvaZZ8jIIli9OisVp Jb+MkisSOkXO3u/tyTI6kFJyoTsXZa/6fYWqL5qk5b9l9LPtoZiemMjQ5VbjOwfK5V7B hbLDcTf/kLGymoNn1DsAgSVcJqn9QWj0e5ef/7NzyWfwKkkwSdT591wnoZ5BBPwNMo5g al+spjiDbkMaOFXN2BZJnt+QeIcYkOy/NBZuvo0VukPbDaKSgJtA3P0mhT6S1xLSO2RT +uMqViu4xvn9lCrrtFFn7kX9MZEePLQ0INRzI4F1U4jR9MPd/tBz2plNX3Qx2CtebE6V 5Oqw== X-Gm-Message-State: AFqh2kpIwT5+kdJZs/Kk3jStVp2EBtXga7ahLO3+gBNvHRg59/hM2AwJ FwxcnKY4yUd5fBRRTPdEaF6LSmfztv7WuXAJU6c= X-Received: by 2002:adf:f6c2:0:b0:242:144:90c4 with SMTP id y2-20020adff6c2000000b00242014490c4mr1053505wrp.28.1671534708756; Tue, 20 Dec 2022 03:11:48 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id az29-20020adfe19d000000b0024246991121sm12422027wrb.116.2022.12.20.03.11.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 20 Dec 2022 03:11:48 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Greg Kurz , Daniel Henrique Barboza , =?utf-8?q?Philippe_Mathieu?= =?utf-8?q?-Daud=C3=A9?= , Xiaojuan Yang , Aurelien Jarno , Huacai Chen , Aleksandar Rikalo , qemu-arm@nongnu.org, David Gibson , Jiaxun Yang , Markus Armbruster , Song Gao , Richard Henderson Subject: [PATCH RESEND v2 4/5] target/mips: Restrict 'qapi-commands-machine.h' to system emulation Date: Tue, 20 Dec 2022 12:11:21 +0100 Message-Id: <20221220111122.8966-5-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221220111122.8966-1-philmd@linaro.org> References: <20221220111122.8966-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philmd@linaro.org; helo=mail-wr1-x42a.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. Extract the QMP functions from cpu.c (which is always compiled) to the new 'sysemu/monitor.c' unit (which is only compiled when system emulation is selected). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- target/mips/cpu.c | 29 ------------------------- target/mips/sysemu/meson.build | 1 + target/mips/sysemu/monitor.c | 39 ++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 29 deletions(-) create mode 100644 target/mips/sysemu/monitor.c diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 7a565466cb..7a37123419 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -32,7 +32,6 @@ #include "hw/qdev-properties.h" #include "hw/qdev-clock.h" #include "semihosting/semihost.h" -#include "qapi/qapi-commands-machine-target.h" #include "fpu_helper.h" const char regnames[32][3] = { @@ -627,34 +626,6 @@ static void mips_cpu_register_types(void) type_init(mips_cpu_register_types) -static void mips_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_MIPS_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_MIPS_CPU, false); - g_slist_foreach(list, mips_cpu_add_definition, &cpu_list); - g_slist_free(list); - - return cpu_list; -} - /* Could be used by generic CPU object */ MIPSCPU *mips_cpu_create_with_clock(const char *cpu_type, Clock *cpu_refclk) { diff --git a/target/mips/sysemu/meson.build b/target/mips/sysemu/meson.build index cefc227582..0e424c9cc6 100644 --- a/target/mips/sysemu/meson.build +++ b/target/mips/sysemu/meson.build @@ -3,5 +3,6 @@ mips_softmmu_ss.add(files( 'cp0.c', 'cp0_timer.c', 'machine.c', + 'monitor.c', 'physaddr.c', )) diff --git a/target/mips/sysemu/monitor.c b/target/mips/sysemu/monitor.c new file mode 100644 index 0000000000..6db4626412 --- /dev/null +++ b/target/mips/sysemu/monitor.c @@ -0,0 +1,39 @@ +/* + * QEMU MIPS CPU (monitor definitions) + * + * SPDX-FileCopyrightText: 2012 SUSE LINUX Products GmbH + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#include "qemu/osdep.h" +#include "qapi/qapi-commands-machine-target.h" +#include "cpu.h" + +static void mips_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_MIPS_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_MIPS_CPU, false); + g_slist_foreach(list, mips_cpu_add_definition, &cpu_list); + g_slist_free(list); + + return cpu_list; +} From patchwork Tue Dec 20 11:11:22 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: 635443 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2859935pvb; Tue, 20 Dec 2022 03:36:59 -0800 (PST) X-Google-Smtp-Source: AA0mqf6VopA1K93zdfpDwjNfHdcbp+iR3UeDcM9A7KfVDJ0D7p0bY/LllrzSAqvtm0ahHutMVUND X-Received: by 2002:a05:622a:11c3:b0:3a7:f424:3ef9 with SMTP id n3-20020a05622a11c300b003a7f4243ef9mr79978337qtk.13.1671536219728; Tue, 20 Dec 2022 03:36:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671536219; cv=none; d=google.com; s=arc-20160816; b=UFMQ/V4S8TobhrqYRaTFxPfUDxDWoZyoFYTu2OR1t5OG8G2WFeupLH523lxp2MPYWl WNb1z2cLYfylsiSLGWlzv5oji0NM01LXxh4HydXcohQiYbPnzs4OUFQ7ynXDNoR34JHq 9C006Yyx9V1OmCiaeEUGMXliT0tRtWDVv9lFf/SI6i9w8WXOxZfvK0cLJQ1Ib5a/4vAV 3eSd2pJNup0lG49DyTKtYrLqVaHuNdmXRLFNTLXLOmT2xFTymKvkpQTLHOZmsm7J8YgQ govd+tNACU7uCvPbyk0rlr2nSu1If9VdHbQRS8o4lzSU0eJ8R5Yu2Ga3y5EvykK1G5Wo U3cg== 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=Tc4icU5uIZDb6KV/spc5EMSSVzOZKwdCLgvhFKNLqtU=; b=zcL2kTeOA0w8B9hBc3hmutTOh+JX6aCxeGitdVxwbMrnWIhrr5X7fPGKKI2B83y1Px Ysgl132X846UedgiLnhmgNSp4i/3Wyat7N+7HuJ2c3nBElCLBRNlLk8QWieEETKihYqy arsTpB4NXraBsFKZUIFVndYmPfC5y0RYCinw79lCRs0HhTiPLtu1C3oQJOEoL4Gu1YBh ZwVUoFd3WGgNNJVtSx8PkIRqm7+N4R0uEN3H0NdMu2gf1YhR5fxUFAS3OorAkgmracSP 46K6jmhwyWsutnmz9PHhQIFocxtIuz7psYkmUTihYvcqQQNdiToRbVgkMWcgchFDI6Hg N30w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jEaPaBFn; 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 q21-20020a37f715000000b006fed662f7cbsi740628qkj.371.2022.12.20.03.36.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Dec 2022 03:36:59 -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=jEaPaBFn; 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 1p7aXe-0004NB-Rk; Tue, 20 Dec 2022 06:12:14 -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 1p7aXP-0004Fq-OC for qemu-devel@nongnu.org; Tue, 20 Dec 2022 06:12:00 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p7aXL-0003q6-VC for qemu-devel@nongnu.org; Tue, 20 Dec 2022 06:11:58 -0500 Received: by mail-wr1-x429.google.com with SMTP id w15so11368632wrl.9 for ; Tue, 20 Dec 2022 03:11: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=Tc4icU5uIZDb6KV/spc5EMSSVzOZKwdCLgvhFKNLqtU=; b=jEaPaBFnMMMTXTAbj0RWIMod/taycHimtJ3KMac21k/WUeS5wzsP7f+eEiiNo6NHk4 b99Icr/ffinJVL62Fqy+N49q9yBwee5uBjsehKbP6ALntLdIPLtcWO6H10Qz/AhASjEL 117tCuUVxXFnd1C+1v9sXf79jXsnRViryfy8oe/8y/NVF5rQN/AWg3Nc2FTmVv+sCul8 pMe7Qc9Xuhp50tFjthMh704EplmVm6CG7/ymY4U34tws99+2oIGEBI1IkenmgvelrUOj Wx8NPExLjGs5DoaDCIds9qDwaS6A6Wq6NCUTE6pvpOtM+yGiwyFI8195LePQUOa6ZeoF cdJg== 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=Tc4icU5uIZDb6KV/spc5EMSSVzOZKwdCLgvhFKNLqtU=; b=i1/8VMmjSXPyNbti3JP70IfnWcZCzCpSHpGqsRVnG+IufX6+EJw9llb2VBJpOXnsi+ VhIsk56qwW8Zi97YCI6bWnaMIcJp18TRyiYwBRYkiBSCg0GbUo7fHRq1zXfzTPeOuVv5 yHtOEtOae6b3KQ9rA9a/maD21A646/28oOpe3FWm1iH1qSXQDJ+Qkd99YFD3FFfL3ZIM 8OaCaGh9HqEZqgy8gxYaPU8M68kIwEs8r5eLuKrjL12hSCCiZe+8ztfoXYizqadVuWc4 koEuM3BJ1ekgIpzXhU+WG03VLQ/a0fSwKEBJB9Imp9Gm6HUeBMH3PHKMRGiluze5SmSe iKhA== X-Gm-Message-State: ANoB5pkM20CGLxEKR5FTZ6B1+t77EfLNQ4avzt5Rwm2Qf1yFR0Zy9qf2 qxWBtvcSyenICkR/lwRkHxMVMFc+CdVoXhmYxKE= X-Received: by 2002:adf:fa4c:0:b0:242:4990:b751 with SMTP id y12-20020adffa4c000000b002424990b751mr29196536wrr.34.1671534714346; Tue, 20 Dec 2022 03:11:54 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id z15-20020a5d4d0f000000b002683695bf97sm578629wrt.58.2022.12.20.03.11.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 20 Dec 2022 03:11:53 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Greg Kurz , Daniel Henrique Barboza , =?utf-8?q?Philippe_Mathieu?= =?utf-8?q?-Daud=C3=A9?= , Xiaojuan Yang , Aurelien Jarno , Huacai Chen , Aleksandar Rikalo , qemu-arm@nongnu.org, David Gibson , Jiaxun Yang , Markus Armbruster , Song Gao , Richard Henderson Subject: [PATCH RESEND v2 5/5] target/ppc: Restrict 'qapi-commands-machine.h' to system emulation Date: Tue, 20 Dec 2022 12:11:22 +0100 Message-Id: <20221220111122.8966-6-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221220111122.8966-1-philmd@linaro.org> References: <20221220111122.8966-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=philmd@linaro.org; helo=mail-wr1-x429.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 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). 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/monitor.c | 50 ++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 52 insertions(+), 48 deletions(-) diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h index 89ff88f28c..6431c520c8 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 cbf0081374..7858cc4c6c 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" @@ -6816,7 +6815,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; @@ -6956,51 +6955,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/monitor.c b/target/ppc/monitor.c index 8250b1304e..36e5b5eff8 100644 --- a/target/ppc/monitor.c +++ b/target/ppc/monitor.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; +}