From patchwork Sat Nov 30 08:45:57 2019 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: 11267901 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BA7CF15AB for ; Sat, 30 Nov 2019 08:56:14 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 901BD20675 for ; Sat, 30 Nov 2019 08:56:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ohfsDp7o" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 901BD20675 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:38748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iayY1-0006Ia-Ch for patchwork-qemu-devel@patchwork.kernel.org; Sat, 30 Nov 2019 03:56:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57788) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iayOV-00033h-76 for qemu-devel@nongnu.org; Sat, 30 Nov 2019 03:46:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iayOT-0003P4-9J for qemu-devel@nongnu.org; Sat, 30 Nov 2019 03:46:23 -0500 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:46698) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iayOR-0003MC-C5 for qemu-devel@nongnu.org; Sat, 30 Nov 2019 03:46:19 -0500 Received: by mail-wr1-x444.google.com with SMTP id z7so34318726wrl.13 for ; Sat, 30 Nov 2019 00:46:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1HpaLHcELOKuPjtThJu7f56C+AUGyKN1UycOs1q17Gw=; b=ohfsDp7oH+isHeWTHhCa41Z1yD2VjW8mL5nIRyYP1kufJOvnATIHJGlqFoG4A8bAXh 55QvNOpfvV+JwjU0fEc4/CNlCTF/FQdqWE0v6wiwb5H+mHC5wpCmL4sH9J+hbq3Yac9o FPJ6OQaPvM/bxtlO0vbvsNCa6tn0rLplxTJc1q7zSkJ5YpFsvpZst0r5PXNTybv5y2KX O01Ujcm9ffQ7mA2+t5KSkxW9M+p7lKo+A9AOKUXwMeP3GAbi6Vn7b+zV5+HHi1o3y0GF 5/FvSJ38R8l/8lIE/YAP+aYlTtiFmZ68Jl8vPGbaJQix0Dh5P0B0DPczTz9259MDy9yl F89w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1HpaLHcELOKuPjtThJu7f56C+AUGyKN1UycOs1q17Gw=; b=qFadTO4NgRMqvz2p/1I8wf1mNBNAS3xarp2jUdNYyldCuC3bM40x1sRQvxcjOqDArX Jj5+Fr8V2YJEL1VTWw6sFtZeZUKN6X/+oDCAdltaMsByn27n1ip898rm4/h2l47pzyX8 gMCPYcktJwzh4BU5ews0UKoeITJjcCSLeMwyGPRCTv7UjfjBDI38ZAhkrq/E5qYZiijC 0M+6g/Rl+08vH1ZtyOqQ19Fe7wNmbe5ndx2ohR6JW1HnYAADXyAwDEHSueiQbEYGzCm7 uaiH0bfluWcSPwIaBUBxWFwcDpq1HTh4p3pVWnfgjibau/Vc7ZeRq2a641grsVSrCk6j uR+A== X-Gm-Message-State: APjAAAUCoStvMOrRjuXWCvm2i/FvClPPifXe49lcsv6xiwPJ0R8KK+SG wFLN0IuqBqGQ4U0QlQErU7k1Iw== X-Google-Smtp-Source: APXvYqwXBgMGBoBFC8X6gRd7NmRuXVyCliXpgMmqz2c1O7kt+Dg74VRS1nGfZWbPag6J25hpYkBWcA== X-Received: by 2002:adf:f0c4:: with SMTP id x4mr56518164wro.217.1575103577157; Sat, 30 Nov 2019 00:46:17 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id k1sm31399663wrp.29.2019.11.30.00.46.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Nov 2019 00:46:13 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 4838D1FF98; Sat, 30 Nov 2019 08:46:05 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 09/14] target/arm: prepare for multiple dynamic XMLs Date: Sat, 30 Nov 2019 08:45:57 +0000 Message-Id: <20191130084602.10818-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191130084602.10818-1-alex.bennee@linaro.org> References: <20191130084602.10818-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: damien.hedde@greensocs.com, Peter Maydell , luis.machado@linaro.org, richard.henderson@linaro.org, "open list:ARM TCG CPUs" , alan.hayward@arm.com, =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" We will want to generate similar dynamic XML for gdbstub support of SVE registers (the upstream doesn't use XML). To that end lightly rename a few things to make the distinction. Signed-off-by: Alex BennĂ©e Reviewed-by: Richard Henderson --- target/arm/cpu.h | 20 +++++++++++++------- target/arm/gdbstub.c | 30 +++++++++++++++--------------- target/arm/helper.c | 4 ++-- 3 files changed, 30 insertions(+), 24 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index cf16f915c82..a31c7a36d6b 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -128,14 +128,20 @@ enum { /** * DynamicGDBXMLInfo: * @desc: Contains the XML descriptions. - * @num_cpregs: Number of the Coprocessor registers seen by GDB. - * @cpregs_keys: Array that contains the corresponding Key of - * a given cpreg with the same order of the cpreg in the XML description. + * @num: Number of the registers in this XML seen by GDB. + * @data: A union with data specific to the set of registers + * @cpregs_keys: Array that contains the corresponding Key of + * a given cpreg with the same order of the cpreg + * in the XML description. */ typedef struct DynamicGDBXMLInfo { char *desc; - int num_cpregs; - uint32_t *cpregs_keys; + int num; + union { + struct { + uint32_t *keys; + } cpregs; + } data; } DynamicGDBXMLInfo; /* CPU state for each instance of a generic timer (in cp15 c14) */ @@ -748,7 +754,7 @@ struct ARMCPU { uint64_t *cpreg_vmstate_values; int32_t cpreg_vmstate_array_len; - DynamicGDBXMLInfo dyn_xml; + DynamicGDBXMLInfo dyn_sysreg_xml; /* Timers used by the generic (architected) timer */ QEMUTimer *gt_timer[NUM_GTIMERS]; @@ -955,7 +961,7 @@ int arm_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); /* Dynamically generates for gdb stub an XML description of the sysregs from * the cp_regs hashtable. Returns the registered sysregs number. */ -int arm_gen_dynamic_xml(CPUState *cpu); +int arm_gen_dynamic_sysreg_xml(CPUState *cpu); /* Returns the dynamically generated XML for the gdb stub. * Returns a pointer to the XML contents for the specified XML file or NULL diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index 4557775d245..1f68ab98c3b 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -106,15 +106,15 @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) return 0; } -static void arm_gen_one_xml_reg_tag(GString *s, DynamicGDBXMLInfo *dyn_xml, - ARMCPRegInfo *ri, uint32_t ri_key, - int bitsize) +static void arm_gen_one_xml_sysreg_tag(GString *s, DynamicGDBXMLInfo *dyn_xml, + ARMCPRegInfo *ri, uint32_t ri_key, + int bitsize) { g_string_append_printf(s, "name); g_string_append_printf(s, " bitsize=\"%d\"", bitsize); g_string_append_printf(s, " group=\"cp_regs\"/>"); - dyn_xml->num_cpregs++; - dyn_xml->cpregs_keys[dyn_xml->num_cpregs - 1] = ri_key; + dyn_xml->data.cpregs.keys[dyn_xml->num] = ri_key; + dyn_xml->num++; } static void arm_register_sysreg_for_xml(gpointer key, gpointer value, @@ -126,12 +126,12 @@ static void arm_register_sysreg_for_xml(gpointer key, gpointer value, GString *s = param->s; ARMCPU *cpu = ARM_CPU(param->cs); CPUARMState *env = &cpu->env; - DynamicGDBXMLInfo *dyn_xml = &cpu->dyn_xml; + DynamicGDBXMLInfo *dyn_xml = &cpu->dyn_sysreg_xml; if (!(ri->type & (ARM_CP_NO_RAW | ARM_CP_NO_GDB))) { if (arm_feature(env, ARM_FEATURE_AARCH64)) { if (ri->state == ARM_CP_STATE_AA64) { - arm_gen_one_xml_reg_tag(s , dyn_xml, ri, ri_key, 64); + arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 64); } } else { if (ri->state == ARM_CP_STATE_AA32) { @@ -140,30 +140,30 @@ static void arm_register_sysreg_for_xml(gpointer key, gpointer value, return; } if (ri->type & ARM_CP_64BIT) { - arm_gen_one_xml_reg_tag(s , dyn_xml, ri, ri_key, 64); + arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 64); } else { - arm_gen_one_xml_reg_tag(s , dyn_xml, ri, ri_key, 32); + arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 32); } } } } } -int arm_gen_dynamic_xml(CPUState *cs) +int arm_gen_dynamic_sysreg_xml(CPUState *cs) { ARMCPU *cpu = ARM_CPU(cs); GString *s = g_string_new(NULL); RegisterSysregXmlParam param = {cs, s}; - cpu->dyn_xml.num_cpregs = 0; - cpu->dyn_xml.cpregs_keys = g_new(uint32_t, g_hash_table_size(cpu->cp_regs)); + cpu->dyn_sysreg_xml.num = 0; + cpu->dyn_sysreg_xml.data.cpregs.keys = g_new(uint32_t, g_hash_table_size(cpu->cp_regs)); g_string_printf(s, ""); g_string_append_printf(s, ""); g_string_append_printf(s, ""); g_hash_table_foreach(cpu->cp_regs, arm_register_sysreg_for_xml, ¶m); g_string_append_printf(s, ""); - cpu->dyn_xml.desc = g_string_free(s, false); - return cpu->dyn_xml.num_cpregs; + cpu->dyn_sysreg_xml.desc = g_string_free(s, false); + return cpu->dyn_sysreg_xml.num; } const char *arm_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname) @@ -171,7 +171,7 @@ const char *arm_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname) ARMCPU *cpu = ARM_CPU(cs); if (strcmp(xmlname, "system-registers.xml") == 0) { - return cpu->dyn_xml.desc; + return cpu->dyn_sysreg_xml.desc; } return NULL; } diff --git a/target/arm/helper.c b/target/arm/helper.c index 6476245e789..4bf133e2f42 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -207,7 +207,7 @@ static int arm_gdb_get_sysreg(CPUARMState *env, GByteArray *buf, int reg) const ARMCPRegInfo *ri; uint32_t key; - key = cpu->dyn_xml.cpregs_keys[reg]; + key = cpu->dyn_sysreg_xml.data.cpregs.keys[reg]; ri = get_arm_cp_reginfo(cpu->cp_regs, key); if (ri) { if (cpreg_field_is_64bit(ri)) { @@ -6995,7 +6995,7 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) 19, "arm-vfp.xml", 0); } gdb_register_coprocessor(cs, arm_gdb_get_sysreg, arm_gdb_set_sysreg, - arm_gen_dynamic_xml(cs), + arm_gen_dynamic_sysreg_xml(cs), "system-registers.xml", 0); }