From patchwork Thu Feb 23 15:55:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 655977 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp408630wrb; Thu, 23 Feb 2023 07:57:34 -0800 (PST) X-Google-Smtp-Source: AK7set+AWa29lX2nmB5VcCLj+MoRvvOf10FQSc+0ilPx/9IoE5idxJQ2NTlHZFzUWRABh6MDrFqL X-Received: by 2002:ac8:598e:0:b0:3b8:588c:40e9 with SMTP id e14-20020ac8598e000000b003b8588c40e9mr22231381qte.19.1677167854179; Thu, 23 Feb 2023 07:57:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677167854; cv=none; d=google.com; s=arc-20160816; b=Y5yltvGo+uzzNSngcouCx0w3RYiPGMvxlQb0dCiwa80q3/708ETnmjZGREo8D4k9Z+ I0W9IXwvBL4iu7XnUvs3sE7SWQKVxIjR1bZdMewa8GuIYFKHE+HOGzwH83dXlv0iw0Zf G/g5tOFDPadkwSkfGTg3LVcgcslkG/tavbTWbHZgSnLM3x9dKFFch+vZdHvGIPGCTTwC euY7hcnj5HLqJmmDC/pwXB+t9WoasyHv1e7wo9LoIyq0BZHU9jsqtmUxms6550IBjooC Wt/mB2PLmCK+g2l5EAIQmGdniYByOGP8cYKFYbd9Rdk0xyiQ0vof5zceKnckyD1wvPui q4JQ== 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=dgHuNHN3qMWWXeDiMRYq/naUGyoYaGdDKos5q2bM3BM=; b=r5f3gsWRksdQRzChvgvTTOZrPDua1AIeCoHVWwQmB1ea22hVJz3jzBfLc5C3Ufuv+F OAZuv/dmacmIJ/dfl/0He8NGWROGV7xGSEKjNV2A0h1mB9GkzesMPBgPxeA4MnJ2HrnO wIfliFNJjs/DAvc8efp9ZsTPtfPJIUxYwg2g/VeAwgsXX4j3KjvSI9CAbl8RRbebZ24X wNc9UoJNCqNPWIaQZZxGrqSl86Jfi3C7if+SGNrVqGwAfZ75dbJkRm8cXnDAfrffoCIO DVaj2BR3eo5a/mAeYvI/UmHkAeEHFy+TqzLAQpy6/211TQFnX81iOr3fW3F9cJueau/0 KOJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TYYQMbLR; 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 q7-20020a05622a04c700b003bd111d451asi5835150qtx.704.2023.02.23.07.57.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Feb 2023 07:57:34 -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=TYYQMbLR; 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 1pVDwp-0005NG-FQ; Thu, 23 Feb 2023 10:55:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVDwo-0005Li-L1 for qemu-devel@nongnu.org; Thu, 23 Feb 2023 10:55:54 -0500 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVDwm-0004Mh-EU for qemu-devel@nongnu.org; Thu, 23 Feb 2023 10:55:54 -0500 Received: by mail-wr1-x431.google.com with SMTP id bt28so4389639wrb.8 for ; Thu, 23 Feb 2023 07:55:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dgHuNHN3qMWWXeDiMRYq/naUGyoYaGdDKos5q2bM3BM=; b=TYYQMbLRS40IVTx1DA5ZZmCms7kQMzQSPm2CLVjBKTyOAHK74zVOsfscvUmzvYmzJG KW2BqtzQjqqRWXw5BK0Q4owmxdTA8KL5lgzCf66C2gHdo13RhukpFNEJyrXDl6tH4JHG Kx2UgFtuiOqYygGiYdcWGbO+ZtdXexZrL3EIKE8euuLBf+INX+18JWBc7nEys0MUCWD3 0CghHsDQ7FQuHUYTOew4bw8qgXj5GgtWft3n3W6kHI2STRx88vu1v5VarRpFJGJokUMC Z1l0aYJu/mizBHlGH7etRvUbFqSQa7f3y6c4eKG6I7VcNLq2gzDLXPsbRHW2NuQ9oUwl lfkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dgHuNHN3qMWWXeDiMRYq/naUGyoYaGdDKos5q2bM3BM=; b=CfUrLhqXzPaW6Irv8XG/RkMxzXEZ6OZ03880IgV1tNtXg9z1Gex7KgFiiVc7tE4G49 uWgkwxF4ndS11BXX4JSkRVdy9OiL6ANSgEogtbru70SksfNfd4Es/SN8F95AfwfdUDu3 e6GC8FENy4YrOXd007n3gfMlOdqZdrb42lgxp+fnQtyfc2mrzqG5o6UZvGE1OpWEjM7p LdTcLRDiLaCvj9OU31R8Tu9OsUl1ENx+ji7wbBTP64a/ajlwn0K58Cem8hvCywZrVGBn kY627gUO0qcqqseFHFwXKGaxpxQCrZH70+6hVyjJcwEN3PDqrWOUFY3BI/yNccISubCx OccQ== X-Gm-Message-State: AO0yUKXhlWp3fL7zb/24tku+Wd+dc+kePXeNWg8YUENmZy0M5CHui9/J aRzUPSXyjI/4bwnnm2gBeOrE8w== X-Received: by 2002:adf:df0b:0:b0:2c5:510b:8f9c with SMTP id y11-20020adfdf0b000000b002c5510b8f9cmr10000377wrl.52.1677167748904; Thu, 23 Feb 2023 07:55:48 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id j16-20020a056000125000b002c5706f7c6dsm7255794wrx.94.2023.02.23.07.55.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 23 Feb 2023 07:55:48 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Markus Armbruster , qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Song Gao , Xiaojuan Yang , Peter Maydell , Greg Kurz , David Gibson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Richard Henderson Subject: [PATCH v4 1/4] target/arm: Restrict 'qapi-commands-machine.h' to system emulation Date: Thu, 23 Feb 2023 16:55:37 +0100 Message-Id: <20230223155540.30370-2-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230223155540.30370-1-philmd@linaro.org> References: <20230223155540.30370-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=philmd@linaro.org; helo=mail-wr1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+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). Rename monitor.c to arm-qmp-cmds.c. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- target/arm/{monitor.c => arm-qmp-cmds.c} | 28 +++++++++++++++++++++++ target/arm/helper.c | 29 ------------------------ target/arm/meson.build | 2 +- 3 files changed, 29 insertions(+), 30 deletions(-) rename target/arm/{monitor.c => arm-qmp-cmds.c} (90%) diff --git a/target/arm/monitor.c b/target/arm/arm-qmp-cmds.c similarity index 90% rename from target/arm/monitor.c rename to target/arm/arm-qmp-cmds.c index ecdd5ee817..c8fa524002 100644 --- a/target/arm/monitor.c +++ b/target/arm/arm-qmp-cmds.c @@ -227,3 +227,31 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type, return expansion_info; } + +static void arm_cpu_add_definition(gpointer data, gpointer user_data) +{ + ObjectClass *oc = data; + CpuDefinitionInfoList **cpu_list = user_data; + CpuDefinitionInfo *info; + const char *typename; + + typename = object_class_get_name(oc); + info = g_malloc0(sizeof(*info)); + info->name = g_strndup(typename, + strlen(typename) - strlen("-" TYPE_ARM_CPU)); + info->q_typename = g_strdup(typename); + + QAPI_LIST_PREPEND(*cpu_list, info); +} + +CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) +{ + CpuDefinitionInfoList *cpu_list = NULL; + GSList *list; + + list = object_class_get_list(TYPE_ARM_CPU, false); + g_slist_foreach(list, arm_cpu_add_definition, &cpu_list); + g_slist_free(list); + + return cpu_list; +} diff --git a/target/arm/helper.c b/target/arm/helper.c index 07d4100365..77eed96761 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -23,7 +23,6 @@ #include "sysemu/cpu-timers.h" #include "sysemu/kvm.h" #include "sysemu/tcg.h" -#include "qapi/qapi-commands-machine-target.h" #include "qapi/error.h" #include "qemu/guest-random.h" #ifdef CONFIG_TCG @@ -9212,34 +9211,6 @@ void arm_cpu_list(void) g_slist_free(list); } -static void arm_cpu_add_definition(gpointer data, gpointer user_data) -{ - ObjectClass *oc = data; - CpuDefinitionInfoList **cpu_list = user_data; - CpuDefinitionInfo *info; - const char *typename; - - typename = object_class_get_name(oc); - info = g_malloc0(sizeof(*info)); - info->name = g_strndup(typename, - strlen(typename) - strlen("-" TYPE_ARM_CPU)); - info->q_typename = g_strdup(typename); - - QAPI_LIST_PREPEND(*cpu_list, info); -} - -CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) -{ - CpuDefinitionInfoList *cpu_list = NULL; - GSList *list; - - list = object_class_get_list(TYPE_ARM_CPU, false); - g_slist_foreach(list, arm_cpu_add_definition, &cpu_list); - g_slist_free(list); - - return cpu_list; -} - /* * Private utility function for define_one_arm_cp_reg_with_opaque(): * add a single reginfo struct to the hash table. diff --git a/target/arm/meson.build b/target/arm/meson.build index 87e911b27f..6d1ac4c471 100644 --- a/target/arm/meson.build +++ b/target/arm/meson.build @@ -59,8 +59,8 @@ arm_softmmu_ss = ss.source_set() arm_softmmu_ss.add(files( 'arch_dump.c', 'arm-powerctl.c', + 'arm-qmp-cmds.c', 'machine.c', - 'monitor.c', 'psci.c', 'ptw.c', )) From patchwork Thu Feb 23 15:55:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 655975 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp408596wrb; Thu, 23 Feb 2023 07:57:30 -0800 (PST) X-Google-Smtp-Source: AK7set/nL1RSARr/UaVBxY4a6K0U1EB3BDdvVgcaLxh5dN8Zr5Ac5oSLkArGV/TVzvdBcHa0Kb1G X-Received: by 2002:ac8:59cc:0:b0:3b7:ed2c:fbb7 with SMTP id f12-20020ac859cc000000b003b7ed2cfbb7mr23077127qtf.0.1677167850185; Thu, 23 Feb 2023 07:57:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677167850; cv=none; d=google.com; s=arc-20160816; b=Nr6C8KNYFXWZ1Rvz9eOHk7GzIVlizQJrXCgn+p6xizIfdG3rgvJbFq961ttNzz5j1a irPzlTv/Ja4NvGKLm4jW2CYQoXqk17P4LymHZDdHla2rZ8ytKRhatTHwDQMVoN7ad6B6 6w0ZvVFqA//+2OYYFHTTPwSN4iHLvH21XyhdXB1ilFMuqH/r+eTzzZhjcQeqtVErBXrF OnCQFQ9U91Zc7IarQD80FUhAOIoMm863tng5jgW/8ULVSA9Zk6P7H1Cl5NXkVdLBNPHn 8lFlnuMpXZnb1OkK1MVCgDKbCT0PeAE0mzE6eFf0xqCIZDIuOBUiV1tbsojEpAHf6BZn PulQ== 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=Vws4C4p5EtHtCTlMeAwaN35sM07LZ5bnfDcfOspSAiPcKViXTDsVAVDOwjahPKTDR9 AFfnU2iM5CEA85kXoBXOWPy4TWxipAIY8hPpyW+X91Z1bTp31/dsOfKZUpsuuS0OiUWL h8sC88tHPkdho1qI6S0Fn0F4AR+kB8u387g233nDBqLIULKBzASHkrN5NbjKR6q0L8oh cV7Ut6MjASktFKOhL8Vu85tn9pouVKZ9+jrRnVB6UKr9p/IO+sUA3QzgvzfNzTYYyxEY 0ytTq8OJRkKiswdxXcZQMUxclt1vUNkMShd5MXqqUWK0xmBOoELpj7rZSOvmhrFKFV99 pdAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EjVVFIv2; 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 o6-20020a05622a044600b003bb73ea08a8si4571930qtx.637.2023.02.23.07.57.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Feb 2023 07:57:30 -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=EjVVFIv2; 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 1pVDwt-0005Py-6m; Thu, 23 Feb 2023 10:55:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVDwr-0005PQ-P6 for qemu-devel@nongnu.org; Thu, 23 Feb 2023 10:55:57 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVDwp-0004ND-Ve for qemu-devel@nongnu.org; Thu, 23 Feb 2023 10:55:57 -0500 Received: by mail-wm1-x334.google.com with SMTP id k37so6330613wms.0 for ; Thu, 23 Feb 2023 07:55:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UieqvLMYtzXamcR/EnTubGkk6CG/pA9dzjTw8XpqXso=; b=EjVVFIv2OXrE8yqSVI9DjSKfmt0LAHM75BrT+OuZP3PhrTuz62Wjse51IkrLswrb1c IHst7NlS6LrDmjYV2DzRBs45Q5pTURP9AQA576ycylUkX/Rc6Z2rVFWq5Rb8jlf7Zd+2 GT+4/6Rvgsy8ZbGWt1bfkeediG7KRV/xb8jVeSWzmUHdvmaJJn5uOw5bgjmAmdaKoQXL 9bTtXCFvQRrK7vcnTKyotFO+6NEpWLp1PptUDfYWKClymqznFWgbBi7FWeWiE1k1aNZ+ Gr1NFw8WH5Jp55JB3iIOMZwPnzb/p6tsRYiZjM894Wl3TXQrOOIYiHLss4EMpK8qLXet KW/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UieqvLMYtzXamcR/EnTubGkk6CG/pA9dzjTw8XpqXso=; b=hR6qvBsi9s1sh3G6gM1LVA9YfixBzcjbQPIFlsB35UKQOT/WOA1pHD2nic4CDN4JQ+ pejeS9mlmm1JrPw4cAy312ZZsNVqqh7Jbpm+SzM08hR3Kxc7psCQvnYWA36OX93OcKSp Jf3g1mYXJuqK4xfxpWGBFFPgQZmGSZn5lAiqdqKZF48ehpLHv0VgwIJY3JzsDHliP4Ju YRR+5FEwi6Lda/OcbEOnXQmBjiLNAnJKHMateF1VDqla4hFcMjQFJTPyz6i745PazT/p QvFUiCPUrlCdWTGTD0M6zEL7+teG3lc2VcovaLPeUa3HB/0I5vzPdNgLb5ro414sXZnH 73yQ== X-Gm-Message-State: AO0yUKXah2zTLFIIWRJHTgbWdCKE3HO0dH4J825cQ7CDyWdX0mcIq8mf BQlPLTVA+3CALOctqadLtFirNg== X-Received: by 2002:a05:600c:3412:b0:3ea:d65e:4b31 with SMTP id y18-20020a05600c341200b003ead65e4b31mr623056wmp.18.1677167754518; Thu, 23 Feb 2023 07:55:54 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id w6-20020adff9c6000000b002c5493a17efsm7356025wrr.25.2023.02.23.07.55.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 23 Feb 2023 07:55:54 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Markus Armbruster , qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Song Gao , Xiaojuan Yang , Peter Maydell , Greg Kurz , David Gibson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Richard Henderson Subject: [PATCH v4 2/4] target/i386: Restrict 'qapi-commands-machine.h' to system emulation Date: Thu, 23 Feb 2023 16:55:38 +0100 Message-Id: <20230223155540.30370-3-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230223155540.30370-1-philmd@linaro.org> References: <20230223155540.30370-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+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 15:55:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 655972 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp408247wrb; Thu, 23 Feb 2023 07:56:32 -0800 (PST) X-Google-Smtp-Source: AK7set8Bd63BKlMZfsVWObY7dh8YlLLKUQ3cmyL7HpnOfAXMgot7uvT+iCJxstJWkjHMwbK3AEaB X-Received: by 2002:a05:622a:1183:b0:3b9:bc8c:c1fe with SMTP id m3-20020a05622a118300b003b9bc8cc1femr19288331qtk.9.1677167792464; Thu, 23 Feb 2023 07:56:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677167792; cv=none; d=google.com; s=arc-20160816; b=XjoiO2KK8McrUwv3vWH0qYBp+PRnWxcQg2CzCWd6jfZilGyw8i+HSY7Ss6GeGF+Z+U gRNQi8xQl9dDOlxNis5Bt+DH60tRgIyRRgnaxbkbtYbdp7ITMq2V20ILP9O9bDBb7HWj 5WwTfHRVm586PCQZ+l4LTfpK88xjAstazYlAlmQfdLh+9DcV3nFLde5xAg5pH590Fkre TM9kFVgNi3qfGFiXBrC7I7PsF+X6RSbQEZ3/bm5ZdcThXiSvhdQenzD3v+UWJm1Pz8Aj XuF8n/IAH8EpiIatGMFRvmEv44/6jLwDxp0boaGH4kIkXho2240BFsdenIZMQcMYJCgo TaaA== 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=I08xnbCAg9THlmYOfaTYm5NT+g+TJhbsT75T9PCPFbc=; b=BM67VAEXAZmpNfGQxLk044SR4N9U4BIIUxZm59kj293T6tL6a/VcToMPBFWr1sk1Bs i955GiJRf8zFI+xwyfdB2e11x588et5B0NBGr9Z3NSks1zjbWRUXyQNXV5JnjYhz5MGS y/Vs+1/8QnBNu+bsccT6CrAmNs7XScAgSWWehF/tsk0vfnnlv58/LVv1GICdnCEVsiox 6Ckpovwae6mJlrrn+IobPAOo50sk6pyLvxopTHtDgdC2tJZqteaPnZy3qxvRdFta+bKZ mR82B03ZhykuPEbn6AfZ00P4CpWXJmH9ZrEIqBLxYTknGSW3zD7aFSRgoGHuyslQPvIi 5Q2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iqCzEfcT; 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 x22-20020a05620a0b5600b0073b9e5fb99esi5243118qkg.105.2023.02.23.07.56.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Feb 2023 07:56: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=iqCzEfcT; 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 1pVDx2-0005Vc-L1; Thu, 23 Feb 2023 10:56:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVDx1-0005Tx-Pu for qemu-devel@nongnu.org; Thu, 23 Feb 2023 10:56:07 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVDwv-0004OF-WD for qemu-devel@nongnu.org; Thu, 23 Feb 2023 10:56:07 -0500 Received: by mail-wm1-x335.google.com with SMTP id l2-20020a05600c1d0200b003e1f6dff952so10973830wms.1 for ; Thu, 23 Feb 2023 07:56:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=I08xnbCAg9THlmYOfaTYm5NT+g+TJhbsT75T9PCPFbc=; b=iqCzEfcTqtj8SbW2sZ2v5aY5W47vSQ2ZGFxXz+kcncFlzHySWdHVIfbvvhs46wUOAo inbAVbX+vFl/OkcApjQ/tKizmHnZY7LqTinODyJSSEYHpc9HckAOSra4tGvozkT2yjT9 FSNfXdXksPLvuL407CTcQm2JeQsCEj82IyXRUiWS7ZOmoG7xEu6rqSCu0qZW3kpacvoy jSvCj/4ShXdfZUgUzVk3KtvBUykYSow3EXkADfzg1tpMD3lypiRsTKvdzgist4gkRtpC BK2h3HfvyvCsBzi2iPZIsddLaiCOX+VJEn6fLtP53Yc7tujx5RTmT/iwFXwjINrzcd+V niZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I08xnbCAg9THlmYOfaTYm5NT+g+TJhbsT75T9PCPFbc=; b=WDtNp9S6glVVZIUXsHRGe3iE+LIX2rK6sq2rXL/ed06LT8Z589K3HImK0YL7qo39oe B8y8/3F0ovZzMtOyh3XxvTUq3TL4bY9Ug9j11VV+Xc9CQxpKrqWp6ZFIoz9LOES33rUI vD5XeCVDDQfxIXGM67xQdLobvoFQa4TVy0NJgNgY6hdnvXL0XfVklOQtT6xK245Um9QB ZiZHBWCOgxN60p69i9hj2AXC9zP03TaSlBr/RtC2vRo3Avb/LJ8cVDEbJTpTZuryacKc Ih/X3AoRfDOH7xckKMZDd6tmK8w5DfW5qhs3uXle24Qxd24A65Y6D6EzCCb+6hl0aSaK VB5g== X-Gm-Message-State: AO0yUKWNbil5OvEeRW1c8tDwCheFqDNt/OfjdwiMA0nONqnUQHjXXAi0 jXPF06NSj5rMqbVDCQGAdWFfnw== X-Received: by 2002:a05:600c:929:b0:3df:e6bb:768 with SMTP id m41-20020a05600c092900b003dfe6bb0768mr8601117wmp.24.1677167760098; Thu, 23 Feb 2023 07:56:00 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id m6-20020a05600c4f4600b003df245cd853sm14571119wmq.44.2023.02.23.07.55.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 23 Feb 2023 07:55:59 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Markus Armbruster , qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Song Gao , Xiaojuan Yang , Peter Maydell , Greg Kurz , David Gibson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Richard Henderson Subject: [PATCH v4 3/4] target/loongarch: Restrict 'qapi-commands-machine.h' to system emulation Date: Thu, 23 Feb 2023 16:55:39 +0100 Message-Id: <20230223155540.30370-4-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230223155540.30370-1-philmd@linaro.org> References: <20230223155540.30370-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+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 'loongarch-qmp-cmds.c' unit (which is only compiled when system emulation is selected). Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé --- target/loongarch/cpu.c | 27 ------------------- target/loongarch/loongarch-qmp-cmds.c | 37 +++++++++++++++++++++++++++ target/loongarch/meson.build | 1 + 3 files changed, 38 insertions(+), 27 deletions(-) create mode 100644 target/loongarch/loongarch-qmp-cmds.c diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index 290ab4d526..4e845ba29b 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -12,7 +12,6 @@ #include "qemu/module.h" #include "sysemu/qtest.h" #include "exec/exec-all.h" -#include "qapi/qapi-commands-machine-target.h" #include "cpu.h" #include "internals.h" #include "fpu/softfloat-helpers.h" @@ -748,29 +747,3 @@ static const TypeInfo loongarch_cpu_type_infos[] = { }; DEFINE_TYPES(loongarch_cpu_type_infos) - -static void loongarch_cpu_add_definition(gpointer data, gpointer user_data) -{ - ObjectClass *oc = data; - CpuDefinitionInfoList **cpu_list = user_data; - CpuDefinitionInfo *info = g_new0(CpuDefinitionInfo, 1); - const char *typename = object_class_get_name(oc); - - info->name = g_strndup(typename, - strlen(typename) - strlen("-" TYPE_LOONGARCH_CPU)); - info->q_typename = g_strdup(typename); - - QAPI_LIST_PREPEND(*cpu_list, info); -} - -CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) -{ - CpuDefinitionInfoList *cpu_list = NULL; - GSList *list; - - list = object_class_get_list(TYPE_LOONGARCH_CPU, false); - g_slist_foreach(list, loongarch_cpu_add_definition, &cpu_list); - g_slist_free(list); - - return cpu_list; -} diff --git a/target/loongarch/loongarch-qmp-cmds.c b/target/loongarch/loongarch-qmp-cmds.c new file mode 100644 index 0000000000..6c25957881 --- /dev/null +++ b/target/loongarch/loongarch-qmp-cmds.c @@ -0,0 +1,37 @@ +/* + * QEMU LoongArch CPU (monitor definitions) + * + * SPDX-FileCopyrightText: 2021 Loongson Technology Corporation Limited + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qapi/qapi-commands-machine-target.h" +#include "cpu.h" + +static void loongarch_cpu_add_definition(gpointer data, gpointer user_data) +{ + ObjectClass *oc = data; + CpuDefinitionInfoList **cpu_list = user_data; + CpuDefinitionInfo *info = g_new0(CpuDefinitionInfo, 1); + const char *typename = object_class_get_name(oc); + + info->name = g_strndup(typename, + strlen(typename) - strlen("-" TYPE_LOONGARCH_CPU)); + info->q_typename = g_strdup(typename); + + QAPI_LIST_PREPEND(*cpu_list, info); +} + +CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) +{ + CpuDefinitionInfoList *cpu_list = NULL; + GSList *list; + + list = object_class_get_list(TYPE_LOONGARCH_CPU, false); + g_slist_foreach(list, loongarch_cpu_add_definition, &cpu_list); + g_slist_free(list); + + return cpu_list; +} diff --git a/target/loongarch/meson.build b/target/loongarch/meson.build index 690633969f..9293a8ab78 100644 --- a/target/loongarch/meson.build +++ b/target/loongarch/meson.build @@ -16,6 +16,7 @@ loongarch_tcg_ss.add(zlib) loongarch_softmmu_ss = ss.source_set() loongarch_softmmu_ss.add(files( + 'loongarch-qmp-cmds.c', 'machine.c', 'tlb_helper.c', 'constant_timer.c', From patchwork Thu Feb 23 15:55:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 655973 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp408289wrb; Thu, 23 Feb 2023 07:56:41 -0800 (PST) X-Google-Smtp-Source: AK7set/XBVfLSh8g7FdUFIy+RLJDaFYygOGOtcb9N1wMAjji36twhBnWLqqBuXFSOmAAuyvY2f9K X-Received: by 2002:a05:6214:202d:b0:56e:9f19:71f9 with SMTP id 13-20020a056214202d00b0056e9f1971f9mr25712447qvf.17.1677167801083; Thu, 23 Feb 2023 07:56:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677167801; cv=none; d=google.com; s=arc-20160816; b=AUbMoJByLWNyo37IQSDkVQj68JOti1OB34X8XkFGboAWZs07yLuBjrzePfXf0BD2EP Mg1B3bLY4croF2zMj8JU/iA2vWmPOw4nr8l3tHVz3iL9qTvrLgxnwO/HoMdds4aK6PtV 0uItZRR6rJJPFiGqSsI978TNLGUvXoVo9HTPmkvjI/rldCF2FyvklvBzcmV0PxUb7AfM PI8U135ceckEJkzMouu6M1HBBwhJQzK2NAAwdCH6TybkQkJaYX9N2Jch3KY3P1p+5bcj djNYavUXlSgGP/ou9ngmSS2gZKDTpyTrvXpoL/sQVoq/gYWO62uxP9dQ5GUcGtzVRsbf qIqw== 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=mw+4/3TevhP31o7/JZOL/mpLf299sYsuDsmbmLV40SU=; b=mCG0S1KLp+C9EvHfBMa/RNz1Wm4zRJQTYTn9+Rov9E92EMty1gZ69o5dE2QwgWKoo3 7ygm0//8TK0Km/zV1dimd/m1MHPAWlQYrpgBM/eUGbTZ08I+Q8CxJM0OnVe7QJ7wrD25 amfheZcBN7DqSkCm93InQB0ZKJIaUYls6lFL6n17gU/vuQQEjDxoQXLfV/XMjqCo6bJD snI2xeGdGOJ365G58Be8KVxAuoYr3kG6spXEMkz3knH5HIfmcvwWciz27DdszTfDB9xt 9bQfvRKldRyknqNbpB0rVP+cDU1yYbOp8ERYGU5ZHfiGQSUKwTyL6s/JXHejYuLcv/6y sz5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iEtSq7cS; 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 l12-20020a0ce08c000000b0056ed12c0f13si2171684qvk.374.2023.02.23.07.56.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Feb 2023 07:56:41 -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=iEtSq7cS; 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 1pVDx5-0005f8-Fi; Thu, 23 Feb 2023 10:56:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVDx2-0005UH-8Z for qemu-devel@nongnu.org; Thu, 23 Feb 2023 10:56:08 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVDx0-0004ND-EW for qemu-devel@nongnu.org; Thu, 23 Feb 2023 10:56:08 -0500 Received: by mail-wm1-x334.google.com with SMTP id k37so6331091wms.0 for ; Thu, 23 Feb 2023 07:56:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mw+4/3TevhP31o7/JZOL/mpLf299sYsuDsmbmLV40SU=; b=iEtSq7cSqa7WtqGcBrMBg0zzkm59CGtK2L1zLwsyhvhekKxY9ffFumiY9b6lCSuj0L e2fueJmFvPXEh1YPk3UXOcJAoKemJgI+cU/raDDENkoOfIRW9ciX7SjffvQPg2DR7Qu6 SgA0wA14+A346PX+5GokpS/1KCf1bSEi+AzvrDT3zop+YofMD3jCHTwu7GYSW3SfJuHv sXBgJMSBqoEawDVazGmrgO7pmFaxLCPu7stx4KPsb3uWeSt1NNOnqkAhVWbdxLbqa5dH Up3jJcpHxRxYLyg5zBrkCL9tV4an5i7A/FbSMqJTOEhn6qPKg38tAZdRLiN7o1ysZhjc 7TkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mw+4/3TevhP31o7/JZOL/mpLf299sYsuDsmbmLV40SU=; b=QPzRNbfb+pzUA3sf0rpQn2nEIQiJaGF5wvplkx6ynDEar9H+xmdduABMkpOIOolcrG yK9YPB1D0jOeSyda25l5qGkOrlHd/V5ofwlEP8U/axwI3XO8K81jsLAfmniXApLLh6Qi cR4GWpBws1xL6afJD1fyiG/MHsSwYCLyZP2POn3cbH2pu0KOnCYpzqwGY0jbxhe0yzy+ ayQczV97HXHwxIGlt/Iri1LApDf4rT4fmkFGDZ4OhsIMHI8z9yIbYEUf/olKARCTmfc0 9M3u+2ptRnG3Ln9DNHklD3hI9aJVQ+PtFj8WCs985uryWXAD8M6y0Fypxpod1HtVTxpI oK2g== X-Gm-Message-State: AO0yUKW+CWO+xJ0axI2molaMLFEhBPEnVbV7+Nj3Z4F+Vt9SBvFsVwCR rEV00mK7lpFyPr+xNhwRGAh1iOLEYUur62lF X-Received: by 2002:a05:600c:32a7:b0:3ea:e4bb:4e84 with SMTP id t39-20020a05600c32a700b003eae4bb4e84mr328025wmp.20.1677167765548; Thu, 23 Feb 2023 07:56:05 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id h7-20020a5d6887000000b002c5501a5803sm8689396wru.65.2023.02.23.07.56.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 23 Feb 2023 07:56:05 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Markus Armbruster , qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Song Gao , Xiaojuan Yang , Peter Maydell , Greg Kurz , David Gibson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Richard Henderson Subject: [PATCH v4 4/4] target/ppc: Restrict 'qapi-commands-machine.h' to system emulation Date: Thu, 23 Feb 2023 16:55:40 +0100 Message-Id: <20230223155540.30370-5-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230223155540.30370-1-philmd@linaro.org> References: <20230223155540.30370-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+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). Rename monitor.c to arm-qmp-cmds.c. Note ppc_cpu_class_by_name() is used by both file units, so we expose its prototype in "cpu-qom.h". Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Reviewed-by: Cédric Le Goater --- target/ppc/cpu-qom.h | 2 + target/ppc/cpu_init.c | 48 +---------------------- target/ppc/meson.build | 2 +- target/ppc/{monitor.c => ppc-qmp-cmds.c} | 50 +++++++++++++++++++++++- 4 files changed, 53 insertions(+), 49 deletions(-) rename target/ppc/{monitor.c => ppc-qmp-cmds.c} (78%) diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h index 0fbd8b7246..9666f54f65 100644 --- a/target/ppc/cpu-qom.h +++ b/target/ppc/cpu-qom.h @@ -31,6 +31,8 @@ OBJECT_DECLARE_CPU_TYPE(PowerPCCPU, PowerPCCPUClass, POWERPC_CPU) +ObjectClass *ppc_cpu_class_by_name(const char *name); + typedef struct CPUArchState CPUPPCState; typedef struct ppc_tb_t ppc_tb_t; typedef struct ppc_dcr_t ppc_dcr_t; diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index abee71d407..d62ffe8a6f 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -40,7 +40,6 @@ #include "qemu/cutils.h" #include "disas/capstone.h" #include "fpu/softfloat.h" -#include "qapi/qapi-commands-machine-target.h" #include "helper_regs.h" #include "internal.h" @@ -6841,7 +6840,7 @@ static const char *ppc_cpu_lookup_alias(const char *alias) return NULL; } -static ObjectClass *ppc_cpu_class_by_name(const char *name) +ObjectClass *ppc_cpu_class_by_name(const char *name) { char *cpu_model, *typename; ObjectClass *oc; @@ -6981,51 +6980,6 @@ void ppc_cpu_list(void) #endif } -static void ppc_cpu_defs_entry(gpointer data, gpointer user_data) -{ - ObjectClass *oc = data; - CpuDefinitionInfoList **first = user_data; - const char *typename; - CpuDefinitionInfo *info; - - typename = object_class_get_name(oc); - info = g_malloc0(sizeof(*info)); - info->name = g_strndup(typename, - strlen(typename) - strlen(POWERPC_CPU_TYPE_SUFFIX)); - - QAPI_LIST_PREPEND(*first, info); -} - -CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) -{ - CpuDefinitionInfoList *cpu_list = NULL; - GSList *list; - int i; - - list = object_class_get_list(TYPE_POWERPC_CPU, false); - g_slist_foreach(list, ppc_cpu_defs_entry, &cpu_list); - g_slist_free(list); - - for (i = 0; ppc_cpu_aliases[i].alias != NULL; i++) { - PowerPCCPUAlias *alias = &ppc_cpu_aliases[i]; - ObjectClass *oc; - CpuDefinitionInfo *info; - - oc = ppc_cpu_class_by_name(alias->model); - if (oc == NULL) { - continue; - } - - info = g_malloc0(sizeof(*info)); - info->name = g_strdup(alias->alias); - info->q_typename = g_strdup(object_class_get_name(oc)); - - QAPI_LIST_PREPEND(cpu_list, info); - } - - return cpu_list; -} - static void ppc_cpu_set_pc(CPUState *cs, vaddr value) { PowerPCCPU *cpu = POWERPC_CPU(cs); diff --git a/target/ppc/meson.build b/target/ppc/meson.build index 79beaff147..7929de8360 100644 --- a/target/ppc/meson.build +++ b/target/ppc/meson.build @@ -39,7 +39,7 @@ ppc_softmmu_ss.add(files( 'machine.c', 'mmu-hash32.c', 'mmu_common.c', - 'monitor.c', + 'ppc-qmp-cmds.c', )) ppc_softmmu_ss.add(when: 'CONFIG_TCG', if_true: files( 'mmu_helper.c', diff --git a/target/ppc/monitor.c b/target/ppc/ppc-qmp-cmds.c similarity index 78% rename from target/ppc/monitor.c rename to target/ppc/ppc-qmp-cmds.c index 8250b1304e..36e5b5eff8 100644 --- a/target/ppc/monitor.c +++ b/target/ppc/ppc-qmp-cmds.c @@ -1,5 +1,5 @@ /* - * QEMU monitor + * QEMU PPC (monitor definitions) * * Copyright (c) 2003-2004 Fabrice Bellard * @@ -28,6 +28,9 @@ #include "qemu/ctype.h" #include "monitor/hmp-target.h" #include "monitor/hmp.h" +#include "qapi/qapi-commands-machine-target.h" +#include "cpu-models.h" +#include "cpu-qom.h" static target_long monitor_get_ccr(Monitor *mon, const struct MonitorDef *md, int val) @@ -172,3 +175,48 @@ int target_get_monitor_def(CPUState *cs, const char *name, uint64_t *pval) return -EINVAL; } + +static void ppc_cpu_defs_entry(gpointer data, gpointer user_data) +{ + ObjectClass *oc = data; + CpuDefinitionInfoList **first = user_data; + const char *typename; + CpuDefinitionInfo *info; + + typename = object_class_get_name(oc); + info = g_malloc0(sizeof(*info)); + info->name = g_strndup(typename, + strlen(typename) - strlen(POWERPC_CPU_TYPE_SUFFIX)); + + QAPI_LIST_PREPEND(*first, info); +} + +CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) +{ + CpuDefinitionInfoList *cpu_list = NULL; + GSList *list; + int i; + + list = object_class_get_list(TYPE_POWERPC_CPU, false); + g_slist_foreach(list, ppc_cpu_defs_entry, &cpu_list); + g_slist_free(list); + + for (i = 0; ppc_cpu_aliases[i].alias != NULL; i++) { + PowerPCCPUAlias *alias = &ppc_cpu_aliases[i]; + ObjectClass *oc; + CpuDefinitionInfo *info; + + oc = ppc_cpu_class_by_name(alias->model); + if (oc == NULL) { + continue; + } + + info = g_malloc0(sizeof(*info)); + info->name = g_strdup(alias->alias); + info->q_typename = g_strdup(object_class_get_name(oc)); + + QAPI_LIST_PREPEND(cpu_list, info); + } + + return cpu_list; +}