From patchwork Fri Feb 23 16:21:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 775147 Delivered-To: patch@linaro.org Received: by 2002:adf:a356:0:b0:33b:4db1:f5b3 with SMTP id d22csp437470wrb; Fri, 23 Feb 2024 08:43:17 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWVLaQ++zG0bdBK67okgP+ufiTJAwgJzSb+H29HXrDODe3VfPAqZtLEi66sTRiqPMdy65GVdfHMsNIQr9IoeTR5 X-Google-Smtp-Source: AGHT+IFewBPcYhfDPqV4pHADIVoR4YBaNgo8Yp5lvc8QQPg7RIymyDpnabfGxrqch/muvN98b7GN X-Received: by 2002:ac8:580e:0:b0:42c:7c1c:b133 with SMTP id g14-20020ac8580e000000b0042c7c1cb133mr357850qtg.5.1708706597066; Fri, 23 Feb 2024 08:43:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708706597; cv=none; d=google.com; s=arc-20160816; b=uioP4lZxrrxFgScyyCnLi0H6PaNt8YiKAzRmUUojPkd7D5YqncBysM4FyYTdrcRbZg r3wg0S/tBBHpHoCc70MBmu7os6SBYbw9vP1pEMdwzeuiLXJ5O7es9XqPNIwZXGotmOwt DGEwYIFtLUN3PdOoR0XYk4TjpTFvdaHO+qSD78w2gbgv81EARilTjgnukfehLoVnk+nI pYfbglCjM0uEoDgjn9F0jQIpgD/JUEwqkOxbHbHQeFmdQ8mEfJP8BjvCUUpJrsa7tu7X vzm9X1dyNysS38zcqsqJ7J6TN97qZh7i6J8ZimhxJteIEMU21KAn9NQbXn6koKXqSLpB aKIQ== 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=E8QhIidXtm1KWUMz6R6/HNvg/qk4Sel77EmOGwDTHnU=; fh=2IXDtwkhE3u9iDHwRQ543d03t9X1toYDqf9u6DZTCZM=; b=Njzi8vvw2jCWwBDn2851BCa2c+YrMdVUs5CuEss4CKFUy/sbTqqfoAOyWysUkuo5MT 8K/QxZsiHVtDfXRgE7uIUMLN3GlV4PvL+albsAoQt154y+6noGsAG+Y3D22okEcfPqnN R1Wh3slJwhragNSx2h1GZo5BHbDzI+BClcy4PT7bAdPZBrbAa54fXnxYE3nvkqqLQUgv Kzw81SAnSOeYOOXYxOafsWfhfLPgkZpneodn9Kd2ZTfne8BOZH4pgWXRtGayZYM4FoNm bP8N956Mj4Obc9MyOczUMJBGutujBOoBDPUS1RmjMwbfzT8WkL9DJy9ZuyuQCgmkMgFK 17zg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TzmtFulp; 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 g8-20020ac84688000000b0042e5a7f2efasi2544249qto.420.2024.02.23.08.43.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 23 Feb 2024 08:43:17 -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=TzmtFulp; 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 1rdYdJ-0003hN-UM; Fri, 23 Feb 2024 11:42: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 1rdYJd-00043Q-9M for qemu-devel@nongnu.org; Fri, 23 Feb 2024 11:22:26 -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 1rdYJJ-00063E-8f for qemu-devel@nongnu.org; Fri, 23 Feb 2024 11:22:22 -0500 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-41297dc236eso2313895e9.2 for ; Fri, 23 Feb 2024 08:22:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708705323; x=1709310123; darn=nongnu.org; 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=E8QhIidXtm1KWUMz6R6/HNvg/qk4Sel77EmOGwDTHnU=; b=TzmtFulpNLuTt5Ffb7HeJP5QlkgsRwP2LUWPefHurHcgLm6hDg7ihCT2I8IbgaPOpp dMIFf4Z5SOci9pE/dBh7Y8egttZ3Wh/bQRdCnBchw7GLCqzYeiGuEx024IlLV6uNj2is RZG/nv3MfpcEl6Etcw4O+xjRC7EOGuTO8SjTn+sQ5O1pH7nEdUtylCTYCB4lVG+CCEyo aeZLQLMclQVRue75IH+G2rWZGYaE/GL4UlMP64GDZmh3Cc8xhb4tpfx2coa3Z/dtUsK9 gvh2b1nV8be/DwEVNL7V95rYa6U6zk3jtfdi7n+kiaRlwo/hPLc1QbAOYRZmCpOk4t9n BY/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708705323; x=1709310123; 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=E8QhIidXtm1KWUMz6R6/HNvg/qk4Sel77EmOGwDTHnU=; b=GC0ctKg88RFqfSAyME3e1ymd24i/i36mr/sFDxr++kpTKAR+eRMFSOt1NaEZw9dBv1 crDISkX9gkUVnE+P58Saw8+zX0XDTN3IauEX+JnxQog2qTzK787SMoP6JEa28A2rY7PZ 1/QNQD88WMjchNETdee98ixOoYdIMkN6KjJp8URDIGsY2soxU3uMTAJB/0voEhMGzsud gCZlDY1WCL7l3smQHYIO55/sTsU4whcR555VKuRxZ8nZHDsz5EuwWsgMjZAzsigB/aBP Uvs+1n7lDsk8LO49hiUAEFT1fvlU05idrTlx9+l41L9wchIMf/KKS+7Nu3HYRkCgroNH L0bA== X-Gm-Message-State: AOJu0YwrgqV4lnc3xoqGJ4iBtzbzIZsnIHbsLgXZ0n3Pf7sNzIzOfUmC 5Fmq64In1bNK464DDmYWOFBFDVu2hV24eCxpslBDPWcjAVjNYMcWzDMzYt5tsSA= X-Received: by 2002:adf:fd87:0:b0:33d:b2d7:6264 with SMTP id d7-20020adffd87000000b0033db2d76264mr170159wrr.51.1708705323687; Fri, 23 Feb 2024 08:22:03 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id bt19-20020a056000081300b0033d1f25b798sm3474276wrb.82.2024.02.23.08.22.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 08:22:03 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id CD2CB5F928; Fri, 23 Feb 2024 16:22:02 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Song Gao , qemu-s390x@nongnu.org, Liu Zhiwei , Pierrick Bouvier , Thomas Huth , Daniel Henrique Barboza , Bin Meng , Yanan Wang , Laurent Vivier , qemu-ppc@nongnu.org, David Hildenbrand , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Ilya Leoshkevich , Cleber Rosa , Nicholas Piggin , Marcel Apfelbaum , Eduardo Habkost , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Alexandre Iooss , Peter Maydell , =?utf-8?q?Alex_Benn=C3=A9e?= , Daniel Henrique Barboza , qemu-arm@nongnu.org, qemu-riscv@nongnu.org, Palmer Dabbelt , Mahmoud Mandour , John Snow , Weiwei Li , Alistair Francis , Yoshinori Sato , Brian Cain , Paolo Bonzini , "Edgar E. Iglesias" , Michael Rolnik , Akihiko Odaki Subject: [PATCH v2 04/27] target/ppc: Use GDBFeature for dynamic XML Date: Fri, 23 Feb 2024 16:21:39 +0000 Message-Id: <20240223162202.1936541-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240223162202.1936541-1-alex.bennee@linaro.org> References: <20240223162202.1936541-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=alex.bennee@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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Akihiko Odaki In preparation for a change to use GDBFeature as a parameter of gdb_register_coprocessor(), convert the internal representation of dynamic feature from plain XML to GDBFeature. Signed-off-by: Akihiko Odaki Reviewed-by: Richard Henderson Message-Id: <20240103173349.398526-28-alex.bennee@linaro.org> Message-Id: <20231213-gdb-v17-2-777047380591@daynix.com> Signed-off-by: Alex Bennée --- target/ppc/cpu-qom.h | 1 + target/ppc/cpu.h | 4 +--- target/ppc/cpu_init.c | 4 ---- target/ppc/gdbstub.c | 51 ++++++++++++++++--------------------------- 4 files changed, 21 insertions(+), 39 deletions(-) diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h index 0241609efef..8247fa23367 100644 --- a/target/ppc/cpu-qom.h +++ b/target/ppc/cpu-qom.h @@ -20,6 +20,7 @@ #ifndef QEMU_PPC_CPU_QOM_H #define QEMU_PPC_CPU_QOM_H +#include "exec/gdbstub.h" #include "hw/core/cpu.h" #ifdef TARGET_PPC64 diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index a44de22ca4a..200652e2c87 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1471,8 +1471,7 @@ struct PowerPCCPUClass { int bfd_mach; uint32_t l1_dcache_size, l1_icache_size; #ifndef CONFIG_USER_ONLY - unsigned int gdb_num_sprs; - const char *gdb_spr_xml; + GDBFeature gdb_spr; #endif const PPCHash64Options *hash64_opts; struct ppc_radix_page_info *radix_page_info; @@ -1525,7 +1524,6 @@ int ppc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); int ppc_cpu_gdb_write_register_apple(CPUState *cpu, uint8_t *buf, int reg); #ifndef CONFIG_USER_ONLY hwaddr ppc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -void ppc_gdb_gen_spr_xml(PowerPCCPU *cpu); const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const char *xml_name); #endif int ppc64_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 9931372a08a..4f6903d3f16 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -6682,10 +6682,6 @@ static void init_ppc_proc(PowerPCCPU *cpu) /* PowerPC implementation specific initialisations (SPRs, timers, ...) */ (*pcc->init_proc)(env); -#if !defined(CONFIG_USER_ONLY) - ppc_gdb_gen_spr_xml(cpu); -#endif - /* MSR bits & flags consistency checks */ if (env->msr_mask & (1 << 25)) { switch (env->flags & (POWERPC_FLAG_SPE | POWERPC_FLAG_VRE)) { diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c index ec5731e5d67..e3be3dbd109 100644 --- a/target/ppc/gdbstub.c +++ b/target/ppc/gdbstub.c @@ -300,15 +300,23 @@ int ppc_cpu_gdb_write_register_apple(CPUState *cs, uint8_t *mem_buf, int n) } #ifndef CONFIG_USER_ONLY -void ppc_gdb_gen_spr_xml(PowerPCCPU *cpu) +static void gdb_gen_spr_feature(CPUState *cs) { - PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); + PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cs); + PowerPCCPU *cpu = POWERPC_CPU(cs); CPUPPCState *env = &cpu->env; - GString *xml; - char *spr_name; + GDBFeatureBuilder builder; unsigned int num_regs = 0; int i; + if (pcc->gdb_spr.xml) { + return; + } + + gdb_feature_builder_init(&builder, &pcc->gdb_spr, + "org.qemu.power.spr", "power-spr.xml", + cs->gdb_num_regs); + for (i = 0; i < ARRAY_SIZE(env->spr_cb); i++) { ppc_spr_t *spr = &env->spr_cb[i]; @@ -326,35 +334,13 @@ void ppc_gdb_gen_spr_xml(PowerPCCPU *cpu) */ spr->gdb_id = num_regs; num_regs++; - } - - if (pcc->gdb_spr_xml) { - return; - } - xml = g_string_new(""); - g_string_append(xml, ""); - g_string_append(xml, ""); - - for (i = 0; i < ARRAY_SIZE(env->spr_cb); i++) { - ppc_spr_t *spr = &env->spr_cb[i]; - - if (!spr->name) { - continue; - } - - spr_name = g_ascii_strdown(spr->name, -1); - g_string_append_printf(xml, ""); + gdb_feature_builder_append_reg(&builder, g_ascii_strdown(spr->name, -1), + TARGET_LONG_BITS, num_regs, + "int", "spr"); } - g_string_append(xml, ""); - - pcc->gdb_num_sprs = num_regs; - pcc->gdb_spr_xml = g_string_free(xml, false); + gdb_feature_builder_end(&builder); } const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const char *xml_name) @@ -362,7 +348,7 @@ const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const char *xml_name) PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cs); if (strcmp(xml_name, "power-spr.xml") == 0) { - return pcc->gdb_spr_xml; + return pcc->gdb_spr.xml; } return NULL; } @@ -599,7 +585,8 @@ void ppc_gdb_init(CPUState *cs, PowerPCCPUClass *pcc) 32, "power-vsx.xml", 0); } #ifndef CONFIG_USER_ONLY + gdb_gen_spr_feature(cs); gdb_register_coprocessor(cs, gdb_get_spr_reg, gdb_set_spr_reg, - pcc->gdb_num_sprs, "power-spr.xml", 0); + pcc->gdb_spr.num_regs, "power-spr.xml", 0); #endif }