From patchwork Thu Feb 23 12:43: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: 655968 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp313167wrb; Thu, 23 Feb 2023 04:45:10 -0800 (PST) X-Google-Smtp-Source: AK7set+DUe7+NYIZ9j3O3uHqJLxsu8BnvfaMlfxjizJarJ1xxKmTcUpMYwumDnYRCA+UDXa3XJEa X-Received: by 2002:a05:622a:1647:b0:3b6:3a12:2bf9 with SMTP id y7-20020a05622a164700b003b63a122bf9mr8173150qtj.2.1677156310067; Thu, 23 Feb 2023 04:45:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677156310; cv=none; d=google.com; s=arc-20160816; b=Ygcfo1R+iC8H+WpqAgMJFHK7aTd+BHA5SSmugVjrOiY/LI9Ctl0Q/+IZrrfZdn3bDD KavC3d/L1RSXzZSPbhE3oF1/2TjkazphEQc4j6nQ3APbvZYMnyNTwpIoOB/HknbrUWou 8qBEd6254CLM6Am5DK61agxaqoY3zh3wqw43gEoNChOUfCIuFiTu+omxkC+k6h91at1z Iuj6G+sNp8ZaKVkMuVF7rvUSkUAWs5CKbhBrsrnhfWcTiyyMj4NsFI8cDubxp5Xuw56N /RRTGn0FIjp6FkhU79OLPdlniy/Xv4KFe+yBdT46esH4KgcgCpIw+Yeo4jNydo/fnoZb iTdw== 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=kk8+WybWrT+4XbLQ/Ff9Tr3FqtmYJrKEElH7cekw4R0=; b=NWHkLOQgdLYBTKLUP5TbC7AEKR+YgquF6QFLaomvQevtcMCbqab3K5ElAje0lIWDjT 1hMEPLKIHe2ywWrbsg2GY0iUIegletFZIBOxbEaxdq9lBk1tXtctdog//TtILQ3A8q6W fEMmU8hn2MQpbwa+uRslVbOzmwNj5pDy9I/kKXJ4A5p7P0kG0wsOx286Bd/j924jZRQA tGaXCzAvi4NtpSf+0PIj191i3EoOfmvyQyLT+elBStZ1FoyPQ8FSJdOf3NlBgM4iZBW3 T/LQVP8nd1mhHuPs0+m1qtUUUwTxr8ZNLs02NYNBjoA61z5chnxNwdvXdyV83mty5LDH x4oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a2qMwwko; 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 a20-20020a05622a02d400b003ab78a0b43asi2653107qtx.14.2023.02.23.04.45.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Feb 2023 04:45:10 -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=a2qMwwko; 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 1pVAx0-0007ZD-Uh; Thu, 23 Feb 2023 07:43: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 1pVAwz-0007Ym-Gk for qemu-devel@nongnu.org; Thu, 23 Feb 2023 07:43:53 -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 1pVAwv-00031o-Ua for qemu-devel@nongnu.org; Thu, 23 Feb 2023 07:43:53 -0500 Received: by mail-wr1-x431.google.com with SMTP id q16so234165wrw.2 for ; Thu, 23 Feb 2023 04:43: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=kk8+WybWrT+4XbLQ/Ff9Tr3FqtmYJrKEElH7cekw4R0=; b=a2qMwwkoCD5+cQfHxOYFVbIYvYsjXNsQEhoN1F/q7QPnU9kK2nycXp+NxlCAHhAQxL t9it53jvpJrdaPk8+azlsvTXGn9cvLfQPqOLeOCPaQrH2656p1VnGLcGxKTft0nAKELp EsNQb88k71slbvwGKck5p9rsAS+U0mdLn4EOIdHUMdKn8i5LtJpyp+WW5303MvD7D85n nYqTzX5Cew03VdMvW7M6eST136jy8PK5SGel8JtKErWOsaD1HJXizSoUrmeqpburzuwD NMT52TdM5UdAlNhnuMHcr6TAxzinV2RWWhsH6PZErtwtRrpo8oGRVz0jrlcwCxMvx9Bx B4bg== 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=kk8+WybWrT+4XbLQ/Ff9Tr3FqtmYJrKEElH7cekw4R0=; b=JBZosXhwm3EZ6IfbO/b5qtEHIj7gOeBQST9lncqkUP9uMTe0PRirmBXv0B0/cwrMY+ +mPTkfDy/jJds7a6fcsdtNQMu/+EsQkGA0Pr+HZSuDYYT5NnauQm2H3QRrG1iBl/Af+W cMm5N1+/D1TTJCqlAn8xMDwg7ufzLCzu7ZZgvvajAZD77GWkw32IbK5o9TARk2e6RL1l 2D8Y5Cr0oZMOvBIS5wGK8HoXU9m62opzeLvGy+t9EzdYjSTCgrBuMT5CVZfTEFhaBCF0 xszHMzqffdqY7/Kb/OJV7oAS7mtuXcTjgHON5kt7k8J0LtFv5Vp1dnOblnqUjaS9Mt/b osQQ== X-Gm-Message-State: AO0yUKXFoQUP9rwYhAtLVWdW629QqJUioIHTyfoHq1kAzzJ5GDbrE+2O MUa/fc3jL97d4VazQ6pJTWF74Q== X-Received: by 2002:adf:e941:0:b0:2c7:be8:4873 with SMTP id m1-20020adfe941000000b002c70be84873mr4810717wrn.58.1677156228444; Thu, 23 Feb 2023 04:43:48 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id bl1-20020adfe241000000b002c54d8b89efsm10883913wrb.26.2023.02.23.04.43.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 23 Feb 2023 04:43:47 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Markus Armbruster , qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, David Gibson , Greg Kurz , qemu-arm@nongnu.org, Xiaojuan Yang , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Daniel Henrique Barboza , Song Gao , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PATCH v3 1/4] target/arm: Restrict 'qapi-commands-machine.h' to system emulation Date: Thu, 23 Feb 2023 13:43:37 +0100 Message-Id: <20230223124340.95367-2-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230223124340.95367-1-philmd@linaro.org> References: <20230223124340.95367-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::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+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 arm-qmp-cmds.c (which is only compiled when system-emulation is selected). 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 12:43:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 655970 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp313571wrb; Thu, 23 Feb 2023 04:46:07 -0800 (PST) X-Google-Smtp-Source: AK7set9ysT+do4kCgvRfhm/Q1O94b2TgloddDgIyhPbS+Mt38fDVcNgGHFF8nn+yn0zkHMLqZQjv X-Received: by 2002:ac8:5a52:0:b0:3b4:7efb:36a7 with SMTP id o18-20020ac85a52000000b003b47efb36a7mr19797865qta.27.1677156367399; Thu, 23 Feb 2023 04:46:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677156367; cv=none; d=google.com; s=arc-20160816; b=DND/d7SHqaedG7+w71+rUEOpMAp6tgKrGhNx0xorEFi2KIMsPnIe1ACl0pIwcHZIct 4kkqL/OH3VoLB7i3SGhygGXUzM+CykkLHNdXM2x3x91hkbwrsuL1btYnuN+y+RNCHp2Q 4MxxX/edDJAh75QCf4+Mpw8WWFopebFbbPObFJB+nSbZ/ub1JV9hZffH3uHxcvlQgtUs ram/tkh/3UHNzQ9hOmW5mFBQHVQ4IE4qGTjB7eGym/OqkiT15Wj3FtghTet8hfeIl1WV ffITbNENYcVjzkfJYxiURb4fp5d7JoaB6DQcz6kxdaklb1HLWg+haCdgrKUdN1MNnCUq Koaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UieqvLMYtzXamcR/EnTubGkk6CG/pA9dzjTw8XpqXso=; b=pMazCnmm6mUv3lvphJ1Bc7lPTHDyJSy9BmqfZxId0guFbUe2ZICiOxnAlksciMB8A0 rf2mz0Xi+0dVhchrZNS1u3DRHv5EhwCvkT6D8dRg2w2jv89wc+Z/rOZmxPhm41Wdtzcu 3w+b+3NKyJF10VLeRmL9tVr8xope5Y8p4CLQAOq5pr+rV6razSRnuwpRju1S3JwZ7AZX jfs5r2AaZkeau3mpjFiWzPwPeQb4zmZ/KkOYCIWNPCuv3kl6kjJFQrzcdpRbRFcvms+S 6qneEw31mMO89jMyesXTdrsVlYobY0bZFots9abPywmuqt1WX9gD6eo5hPczfPZPK8NT eBfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JJnuX4dT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b13-20020ac85bcd000000b003bbd8bdb937si7618796qtb.795.2023.02.23.04.46.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Feb 2023 04:46:07 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JJnuX4dT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVAx4-0007aj-9s; Thu, 23 Feb 2023 07:43:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVAx3-0007aO-Cf for qemu-devel@nongnu.org; Thu, 23 Feb 2023 07:43:57 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVAx1-00032v-Ly for qemu-devel@nongnu.org; Thu, 23 Feb 2023 07:43:57 -0500 Received: by mail-wm1-x32b.google.com with SMTP id m25-20020a7bcb99000000b003e7842b75f2so6309209wmi.3 for ; Thu, 23 Feb 2023 04:43:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UieqvLMYtzXamcR/EnTubGkk6CG/pA9dzjTw8XpqXso=; b=JJnuX4dTA2N3L180fA0KX5m9j1rbgos4BmjcPIetUoy2apXAg3vVhrkQbsCgYmCr9w ciIMPCKSO1vtAuNqpHkxTttzI7Pap3aIV2gE6MeuZ5uIurX9F2bIxCCAkeJn5LtEqCT1 vhx41Hzx2JEYGcP7E8zSZRKr2YKeLYWTkl9eKqMzUSb6cxz3p3jSaYZoi/3fN9bNQz5W amHDqzIL3dbI7/TOSPyT6X5rM5IMxjaxYXQLPaz1bfuaN1xPSY+g5kTUg3qJdrGN5x/o 2TFOhXXCcVGSXlYMaYd+vwzPO6z5hbas+rSAeLwRk3BBwCCJsE9JpOLC3eDKRYMJ45yq +7Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UieqvLMYtzXamcR/EnTubGkk6CG/pA9dzjTw8XpqXso=; b=shaWSAKB7n8440Znipy/tUP+oj3/W6zhkxgTr8k6AHXjWEQRGaUc4rwPg1SnETg+rr IYwKDgA8UBBA8x6yrnurIPI0jxJtXjsgu01e4ZHmgAfzwOukmocNorkkvXBjNSD/iLlo 5hkN3FjcBV8xewBg6VHtnXubxt54G7/BOyd4teSz4Y6ahKtFNRCg5ni1Jivc6oE6HJX1 2avGROm07lq9rx1+IgJWFuYFPmwtOb2qYIoPQUmuidMc/+HnLyruv1h1ivRj9uCQlws8 +2PmHHB7kM9o1CQfa3DuNK+arA3HJ0dCkoB+2tu2KvTc1EqwIWXtyzAAVf5HIQsu3d04 1tkQ== X-Gm-Message-State: AO0yUKUY9zcTOdTxlidSLH7GRIFJExbxqQFVkndHJbmYFjI+nmEPPY1C KWp9fpXwdgDNOFklTiLnhNrHAA== X-Received: by 2002:a05:600c:1da5:b0:3e2:1dac:b071 with SMTP id p37-20020a05600c1da500b003e21dacb071mr10813211wms.13.1677156234252; Thu, 23 Feb 2023 04:43:54 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id d9-20020a056000114900b002c5584d0e3dsm9976086wrx.24.2023.02.23.04.43.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 23 Feb 2023 04:43:53 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Markus Armbruster , qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, David Gibson , Greg Kurz , qemu-arm@nongnu.org, Xiaojuan Yang , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Daniel Henrique Barboza , Song Gao , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PATCH v3 2/4] target/i386: Restrict 'qapi-commands-machine.h' to system emulation Date: Thu, 23 Feb 2023 13:43:38 +0100 Message-Id: <20230223124340.95367-3-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230223124340.95367-1-philmd@linaro.org> References: <20230223124340.95367-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Since commit a0e61807a3 ("qapi: Remove QMP events and commands from user-mode builds") we don't generate the "qapi-commands-machine.h" header in a user-emulation-only build. Guard qmp_query_cpu_definitions() within CONFIG_USER_ONLY; move x86_cpu_class_check_missing_features() closer since it is only used by this QMP command handler. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- target/i386/cpu.c | 74 +++++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 4d2b8d0444..c8da082b4f 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -31,11 +31,11 @@ #include "qapi/error.h" #include "qapi/qapi-visit-machine.h" #include "qapi/qmp/qerror.h" -#include "qapi/qapi-commands-machine-target.h" #include "standard-headers/asm-x86/kvm_para.h" #include "hw/qdev-properties.h" #include "hw/i386/topology.h" #ifndef CONFIG_USER_ONLY +#include "qapi/qapi-commands-machine-target.h" #include "exec/address-spaces.h" #include "hw/boards.h" #include "hw/i386/sgx-epc.h" @@ -4713,40 +4713,6 @@ static void x86_cpu_get_unavailable_features(Object *obj, Visitor *v, visit_type_strList(v, "unavailable-features", &result, errp); } -/* Check for missing features that may prevent the CPU class from - * running using the current machine and accelerator. - */ -static void x86_cpu_class_check_missing_features(X86CPUClass *xcc, - strList **list) -{ - strList **tail = list; - X86CPU *xc; - Error *err = NULL; - - if (xcc->host_cpuid_required && !accel_uses_host_cpuid()) { - QAPI_LIST_APPEND(tail, g_strdup("kvm")); - return; - } - - xc = X86_CPU(object_new_with_class(OBJECT_CLASS(xcc))); - - x86_cpu_expand_features(xc, &err); - if (err) { - /* Errors at x86_cpu_expand_features should never happen, - * but in case it does, just report the model as not - * runnable at all using the "type" property. - */ - QAPI_LIST_APPEND(tail, g_strdup("type")); - error_free(err); - } - - x86_cpu_filter_features(xc, false); - - x86_cpu_list_feature_names(xc->filtered_features, tail); - - object_unref(OBJECT(xc)); -} - /* Print all cpuid feature names in featureset */ static void listflags(GList *features) @@ -4875,6 +4841,42 @@ void x86_cpu_list(void) g_list_free(names); } +#ifndef CONFIG_USER_ONLY + +/* Check for missing features that may prevent the CPU class from + * running using the current machine and accelerator. + */ +static void x86_cpu_class_check_missing_features(X86CPUClass *xcc, + strList **list) +{ + strList **tail = list; + X86CPU *xc; + Error *err = NULL; + + if (xcc->host_cpuid_required && !accel_uses_host_cpuid()) { + QAPI_LIST_APPEND(tail, g_strdup("kvm")); + return; + } + + xc = X86_CPU(object_new_with_class(OBJECT_CLASS(xcc))); + + x86_cpu_expand_features(xc, &err); + if (err) { + /* Errors at x86_cpu_expand_features should never happen, + * but in case it does, just report the model as not + * runnable at all using the "type" property. + */ + QAPI_LIST_APPEND(tail, g_strdup("type")); + error_free(err); + } + + x86_cpu_filter_features(xc, false); + + x86_cpu_list_feature_names(xc->filtered_features, tail); + + object_unref(OBJECT(xc)); +} + static void x86_cpu_definition_entry(gpointer data, gpointer user_data) { ObjectClass *oc = data; @@ -4915,6 +4917,8 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) return cpu_list; } +#endif /* !CONFIG_USER_ONLY */ + uint64_t x86_cpu_get_supported_feature_word(FeatureWord w, bool migratable_only) { From patchwork Thu Feb 23 12:43: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: 655969 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp313513wrb; Thu, 23 Feb 2023 04:45:59 -0800 (PST) X-Google-Smtp-Source: AK7set9Q/fe9mCUKKwvg21Vosx7+IbXDU/oOnQlzKuwLhxTrHNQdp6biC4RLH5upuMLjVhvTVaqC X-Received: by 2002:a05:622a:5d4:b0:3bd:718:daea with SMTP id d20-20020a05622a05d400b003bd0718daeamr19592797qtb.28.1677156359349; Thu, 23 Feb 2023 04:45:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677156359; cv=none; d=google.com; s=arc-20160816; b=GbPZgsSlRmZYMbFEE9rrKOgw0XDQwHGINaZmXYNpVaG3xB+B5INbMr6g7gblVo/0rF zN6PsJOW/G1doG4sQL1JIeZ1CMczyoLAsSP0ZzdnoV1lRPuAnEgrsXcfUl8r5lpw3+uA JqtxoSn/OrrpI0g0DpRu4R5KiydBCLSAMlloBEHAB2I2ixCKd2XRwKDXRRvYPhHXcfhS Yc2CN/7YYCWHbKchRbUFdte8ArUvWmXSKeF+qx7+wKxnuJsTgMEUBj5zFRsaa9kI4gwt Undeg4sthN2+mMns8l8kYfwLHcnBS/fOXDdfkYlVqJsV47BsybuOk4HKmNrKK1mBlR5/ IdZw== 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=k0k3YaD196s7IoVbwQsB4O8AuR6esyLbrwlewHL7j90=; b=KpLMwiAd0A03+CqX6YTP+V52GMTR0n5qIo3GSG8ic8g7HpWO37aSSIm0+O/rrexgO7 hbyx4WXWb29OkyQeNpBHVQpv0Go11xbr01aasIadH4FowcAMMvsTd9XUvPlP+ZFowKB5 umc5oovvspJXmb7jBajHe6Lx6kWHmXe5+vHunhqXckBklS7yrhNyZ+iXAxuMW42AoHzI M/KlWSn4OV/XemYZTr6RiuY0K8Ui2rynH5ixR52Dzs8d6ycfTQiJM0YGnWzlzU/TrjQ7 cWWaBI+Lxtoz+cft6ePN+wb7MDNtKUjx3g2eN8zzQ0iuOT5IuJ1eZLSC+FW4wQ1gsmwE 2wfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sRoy4p+f; 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 e10-20020a05620a014a00b0071932b16aedsi16610711qkn.722.2023.02.23.04.45.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Feb 2023 04:45: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=sRoy4p+f; 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 1pVAxA-0007cz-Nm; Thu, 23 Feb 2023 07:44:04 -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 1pVAx8-0007cJ-Rt for qemu-devel@nongnu.org; Thu, 23 Feb 2023 07:44:02 -0500 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVAx7-00033d-5i for qemu-devel@nongnu.org; Thu, 23 Feb 2023 07:44:02 -0500 Received: by mail-wm1-x32d.google.com with SMTP id j3so6794312wms.2 for ; Thu, 23 Feb 2023 04:44:00 -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=k0k3YaD196s7IoVbwQsB4O8AuR6esyLbrwlewHL7j90=; b=sRoy4p+fHrQvJXNyKOSy93/cUpgZ/obx9agK+QvDmloGvU6kBNDM98yuJDk3+A0cq2 J3ctaK6Leg5E4dWPNUxSwU9Ibxp9sZHJcxw/i171wZxGNg1xxvQpt9KInSiJgtVecjQJ dZv75yIBH35s1YYI9bvKI1RXOfApVZp2oWUAHigN+aLYUm72dxesjyfSv0GxPir2HC+2 +JPT4GdH0eJ2vSGV03geqhZ1MYi3oAUhMCzVTEKNYtVPvHd26xjy+2rWGv4jmowG0BfB zXZeex51uiQFaZ+qBkQn6Op1nqPtDffswmqLB+GsuPbRNiHnm8XY8hKTavDVZpJIyI7v iqAw== 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=k0k3YaD196s7IoVbwQsB4O8AuR6esyLbrwlewHL7j90=; b=rj7zwGknSUIZ+Qq8pqoriNFj3R9c5outTl3c+xUCdTzd6zYHfS9ZZC6hNVbMoN5a0M x/AarXefM0uxpYfZMTtcGQCweXxAI0qLm82Rfe1Rr96nhpqsdPb0QUWluJBQN7iogxBN veySfoCDtwo9N0TwXz7Jd4HZHqs6/rswdbanSd5lBTZUBzA9euOO2SxwL6E6UHYaVFRd 2WdoCdSl3pUBoeBA5+RUOUn0jXdKQIJNRL183HV/XLBhwSfJNR/gJihTS4lG6jqt4zXK eMyiv4wW6K/vpEs+fqp86NR8M+j3eyXDCloCH7oi/tpTvtaG2662xjcEnqk0U5XT/GrR JsrA== X-Gm-Message-State: AO0yUKUyqP9ViLVUuCaj/yV9wEmmBX5v38YVYgJqLwG0TxFTXhsfPN2D LrEAI7Q11rp/uZ0Lmjj8Xnbvkw== X-Received: by 2002:a05:600c:1818:b0:3e8:96d9:579f with SMTP id n24-20020a05600c181800b003e896d9579fmr5312579wmp.40.1677156239870; Thu, 23 Feb 2023 04:43:59 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id r1-20020adfdc81000000b002c5503a8d21sm7954749wrj.70.2023.02.23.04.43.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 23 Feb 2023 04:43:59 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Markus Armbruster , qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, David Gibson , Greg Kurz , qemu-arm@nongnu.org, Xiaojuan Yang , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Daniel Henrique Barboza , Song Gao , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PATCH v3 3/4] target/loongarch: Restrict 'qapi-commands-machine.h' to system emulation Date: Thu, 23 Feb 2023 13:43:39 +0100 Message-Id: <20230223124340.95367-4-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230223124340.95367-1-philmd@linaro.org> References: <20230223124340.95367-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.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/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 12:43: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: 655967 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp313157wrb; Thu, 23 Feb 2023 04:45:09 -0800 (PST) X-Google-Smtp-Source: AK7set/kb35tzKmLHmXScfbWOzf5/u4b5wrR7vdOpyhSk3Ia5rfZE8uMbrTXZMa6NuGTdizYqhpM X-Received: by 2002:a05:6214:e8d:b0:56e:af8a:a872 with SMTP id hf13-20020a0562140e8d00b0056eaf8aa872mr22821451qvb.11.1677156309216; Thu, 23 Feb 2023 04:45:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677156309; cv=none; d=google.com; s=arc-20160816; b=W7NcsAnx94XGNLqiOs7ed8nv0dXjyD7EGydcC7ppoKzqbgTZvbNjmlphJHOWIrvDBj SdW40d8FIx0BZ3n+fGzJg2EGZdqt4URtpVnrfEuvIaOKY/kKxuAWLBywmwZif9xLlw+H 9MMleLesiDJ4JliV1QcJHhmJyc82L8P/vf65dF+zO5qqm+uqEDidgmymrfohKeappFLU l9yPqj9aWLhmDG2D0+yGCAbsZUftZ70SdYgMH5/93/fDmoixor4o4MZI1x0UuqAnJ/Ep tApQzBokHL9LnVzyTcOkl2MfTWTkPQdzpOlSTZn+xBiLx8oE2LcSO8/BW75SatxbGTgt xW0g== 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=qtEwrwiZiBlfPqk1KEi8MCm+IMA1ZynfZmqmAy1Ob7k=; b=mpYr8ZrXhLQLzvHeIOrpqBpnqv4IoJK2zR54KEeimw/2Fpo574iMzsuCvHdeuNxKy7 P24lnOzFYEO9VvPEem435aUlE8tzhUF9DNxUasx/QoI7UgNGVIHEUxgcUtEI7MBn8mf7 tQuf1SzW7wsjGS0IUkNF0J8Tik7Q5g7H/FS/xZ3wX6RsGqQaQvnX01FPKbHUVaY/uhVd jouuhLHaEBZ1RcbzIU6T9bp0jGZ4nq1E7DGcxT/Jra3NPFNi5csPsKwWNSQTJrZ1/Ls/ N6qI4mW8M8m+Jtrrf5hNrIN1jzGSABNsCStWlK7gsIVRpuElq2yQ06O+UhSyzS4mS2jg ETQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zzyI2Ait; 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 v21-20020a05620a0f1500b0071be54da3basi5774794qkl.292.2023.02.23.04.45.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Feb 2023 04:45:09 -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=zzyI2Ait; 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 1pVAxG-0007gu-TY; Thu, 23 Feb 2023 07:44:10 -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 1pVAxE-0007fG-FC for qemu-devel@nongnu.org; Thu, 23 Feb 2023 07:44:08 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVAxC-00031n-DY for qemu-devel@nongnu.org; Thu, 23 Feb 2023 07:44:07 -0500 Received: by mail-wr1-x42e.google.com with SMTP id l1so10300358wry.10 for ; Thu, 23 Feb 2023 04:44:05 -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=qtEwrwiZiBlfPqk1KEi8MCm+IMA1ZynfZmqmAy1Ob7k=; b=zzyI2Ait5ebup8A2+GYN3I4d5GlhPEHdZPopQDcUJbQKK8g86fuh7afmTPzl8M6eVY ysN+2eL5hoGcqTTYS9MX+nSXqNTbs+XOELBfUkZjzrm6BNaP1dgbGwy8T1D1Ov+J7j7e 6iSWsodIZ9uaL657YyJHsi5ZSWXylutgEhITlnVig1rqx9mRekiKTjVaNdVU6LqC5OSH /Q5M+JyUcKyrDhYBUvLJzcT3d0HdPZREKArqEm0EX11LSZJLP3i29BtufHi0kIB0w6U+ /lyrHDnVcNwUpgLSCM3EHeN5+x9efb110bhspCXH531QEgk1y81adlDNdDVG9w550k7d AhOg== 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=qtEwrwiZiBlfPqk1KEi8MCm+IMA1ZynfZmqmAy1Ob7k=; b=x1GwDIghpavHfVXwE/Po0TB8APiJ3HaV4/tv3TAuQgrV8uA7UlAqsLP0us2QhvkWyp 1HaQwKSXLKAgJkBdX8TlByvlpryUKOx/a65t15988NU233e6muypEJtusHmsBA6tWSBE JLoahtk/0gJ6A19qX5xDU9Cb9Tpw/O5Ol0MhuX6KCQaO2KHWDKS98ekF1n3fRX0iiLta BzLZVhSzbgqL2cG9JKKnZqNengLLsDpSe+tGU/I5OpG8Ee5CDL7uQV8n+2rr12gduVsL daMLOocV79SQsaOVoU1HTt91DSMg2Am4A8FD+PK3yOrPGvsPcPA4FF/6bqlgzrXgzoDc VnvQ== X-Gm-Message-State: AO0yUKWAUQI5sWT/zeL5Lua1+koZyxHXEQT6VGNmckmy82W/EYeRxnwo RcqMB3+fdMq5N8z05JfGCTzR0Q== X-Received: by 2002:adf:dece:0:b0:2c5:544b:8e64 with SMTP id i14-20020adfdece000000b002c5544b8e64mr10153121wrn.71.1677156245518; Thu, 23 Feb 2023 04:44:05 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id s17-20020a5d4ed1000000b002c4084d3472sm6961029wrv.58.2023.02.23.04.44.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 23 Feb 2023 04:44:05 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Markus Armbruster , qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, David Gibson , Greg Kurz , qemu-arm@nongnu.org, Xiaojuan Yang , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Daniel Henrique Barboza , Song Gao , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PATCH v3 4/4] target/ppc: Restrict 'qapi-commands-machine.h' to system emulation Date: Thu, 23 Feb 2023 13:43:40 +0100 Message-Id: <20230223124340.95367-5-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230223124340.95367-1-philmd@linaro.org> References: <20230223124340.95367-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=philmd@linaro.org; helo=mail-wr1-x42e.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. 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/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; +}