From patchwork Fri Nov 3 19:59:39 2023 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: 740713 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp8811wrr; Fri, 3 Nov 2023 13:03:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG87JFZnhQm5tAAOnV1+4ZCHpGB+IfG/e+ttyCNAWp3CEgUDPmW36NQ+wfOnkwXLfM07sOM X-Received: by 2002:a05:622a:1889:b0:412:206b:92e6 with SMTP id v9-20020a05622a188900b00412206b92e6mr27404410qtc.16.1699041811323; Fri, 03 Nov 2023 13:03:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699041811; cv=none; d=google.com; s=arc-20160816; b=w4VLsBM9/NlfoOJYvy6JGhqLz4tgBHZvltI2hM3CkwbLXXlByBo4onA/s4EjfFvAH9 g+45r/6jW6dTXDSizIgF+OsBJDmFZmgFbXZQBnKEbr12fajkOsU+8XtGr9MtgvPQEc9z dulXJpLcOKOOSYuNeoXKLjfKtaKKY0V1uMP8ZwqohMjzOoXY+cveEtNOlOsAEiIzqoLd G5LVH5xGNF8Pu1favVSkaGM+pnGXzCxMrlYMxwYspFGudb3slUp719pkZ5T3RcCzbdZL gmFipS4D2JLndlhHB4lFDf4eKxQHEOXjHavGQfWZ0QOlgZFfZa7r6Uv+Xf/NZBnqFVHh +xQQ== 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=3UyTA5dTrQvBJFOCjN13w0HZMzwuuddj/H79AztA+uQ=; fh=+DJyABPrPOszaX8covAxj8Yhupz9POTwrYeebio0HgM=; b=cDWGHdPMpdzCMh0e0ct++StXGDV+9flttHjLf4z+BtHjPGRPEsv0Q4ND4TauS7K6ET hgg4TajZUuGqNWe8nCZxvxCnlF79KywNW+MyblGjVQbRUJFcGp/hs9re5UWIRjAmromB 3YGLsN/DIHQDqSbBpsAokRWn3BgJHoBa1m8bhMLnYMHa7l9wcopaWqcY6B/awNe18B5J IDApir7N0ALuhdJqqXpjmeuGX7IznGLRe0TSkG3yikBqn1j0lm/xBA7tyfLzkyy0YL6+ p52NH+XSJjGKpzFdVLrKWhxT2JpA1IAxdEkCxMZ6vKnby3O5IKb7NJM0WB1ylQKFPo/k YG4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mww7gUgO; 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 i19-20020ac85e53000000b00405533726dbsi1967420qtx.150.2023.11.03.13.03.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:03:31 -0700 (PDT) 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=mww7gUgO; 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 1qz0MZ-0001Bf-Jd; Fri, 03 Nov 2023 16:01:51 -0400 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 1qz0LG-0008Hq-9P for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:32 -0400 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 1qz0L2-0005cj-D9 for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:00:29 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4081ccf69dcso21150315e9.0 for ; Fri, 03 Nov 2023 13:00:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041609; x=1699646409; 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=3UyTA5dTrQvBJFOCjN13w0HZMzwuuddj/H79AztA+uQ=; b=mww7gUgOyHdVCbjP3vcFYVs36ETybl1Ci1hDFmZYiLaV8nQ6kEhGZR6/VEVo4IJcaQ l+jMy+gs0Djns9vML9+x+WvYRbn+uz0u1um6PuuWX43QNko/BdgDAGklLPIZb8XKRKHj k+OeigBtSQrCA+honaLzVCjNEynZBAIMGHOT8O5onoK8zgYZARHqYPQcwJ5QldGpgGGd TipngmjqikQyc9Sk1UgMlh6getOQ3eyVJYy/Lopfh0zntO+7frX6M/wL6g/Or6otlT8x FBWR5HrXlAgL2+HEnXWsXnLrGrXQTm/SHEavQH1fTGKw1yCuA85H/OZvMIB4HssdGETl drfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041609; x=1699646409; 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=3UyTA5dTrQvBJFOCjN13w0HZMzwuuddj/H79AztA+uQ=; b=wFM0tCuoyqclsHIsmGubmxc2Dy/mzh4M8WNXOuLC1PwiO52jFbrlpno/cSvO9omeXq TvJFUwQyvu0O58ARCio9VpRNTtGTOnqw4To7DcRpbPvbQSVrO1vKsxf5gnz0Oq6YFuh2 rCFznPGIpXLDj6USEIE1p5f2HKHbbuEf4AgHcHE7du2w9AnU7YFbsrK/r4uSmt/Vq2jA JjzxziHUNNfKUCd1zDOymbsNF0ifzJxYlcaP+ZYH2QgNftenxaijp5vdh6YTds8NDUMS GcwHw/zvtQSmScUOaNseYJpNrD/1eRnJPNFP6STcR18pEXNuasp7Rij7a+xU2Q4nrL0P jxqQ== X-Gm-Message-State: AOJu0Yy+T+7RzuH5g5iBuFrpe1EWy+NhPb5faA+G4SKKavhQzKHrohkP KaUyzW7crD+XevHZmGM4+qpj2Q== X-Received: by 2002:adf:f309:0:b0:32f:7d50:62f8 with SMTP id i9-20020adff309000000b0032f7d5062f8mr3477316wro.3.1699041609574; Fri, 03 Nov 2023 13:00:09 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id h16-20020a05600004d000b0032dbf99bf4fsm2658778wri.89.2023.11.03.13.00.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:00:07 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id DBB06656E5; Fri, 3 Nov 2023 19:59:57 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik , Akihiko Odaki Subject: [PATCH 12/29] target/ppc: Use GDBFeature for dynamic XML Date: Fri, 3 Nov 2023 19:59:39 +0000 Message-Id: <20231103195956.1998255-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-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, RCVD_IN_DNSWL_NONE=-0.0001, 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: <20231025093128.33116-6-akihiko.odaki@daynix.com> Signed-off-by: Alex Bennée --- target/ppc/cpu-qom.h | 4 ++-- target/ppc/cpu.h | 1 - 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 be33786bd8..8d5ebba5d3 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" #include "qom/object.h" @@ -186,8 +187,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; diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 30392ebeee..848062bc9f 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1384,7 +1384,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 40fe14a6c2..a0178c3ce8 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 ec5731e5d6..e3be3dbd10 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 }