From nobody Wed Nov 5 10:57:28 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1534441748308802.2238393736549; Thu, 16 Aug 2018 10:49:08 -0700 (PDT) Received: from localhost ([::1]:57470 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqMOK-0000FV-0E for importer@patchew.org; Thu, 16 Aug 2018 13:49:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53079) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqMMT-0007kM-32 for qemu-devel@nongnu.org; Thu, 16 Aug 2018 13:47:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fqMMS-000678-FG for qemu-devel@nongnu.org; Thu, 16 Aug 2018 13:47:05 -0400 Received: from mail-lf1-x142.google.com ([2a00:1450:4864:20::142]:33092) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fqMMS-00066m-6N; Thu, 16 Aug 2018 13:47:04 -0400 Received: by mail-lf1-x142.google.com with SMTP id u14-v6so4039851lfu.0; Thu, 16 Aug 2018 10:47:04 -0700 (PDT) Received: from octofox.cadence.com (jcmvbkbc-1-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:1fa::2]) by smtp.gmail.com with ESMTPSA id q65-v6sm5206268lfb.80.2018.08.16.10.47.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Aug 2018 10:47:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=A17x4c2H8FbLrEL0Fq8AJTxVIV1BnmtFmk176WoD9ko=; b=PPU9bgjOYl1mU2/w61nnWY4+2Chf9zn0V7jfNX05nrslmF375taAuxwl5UFq89J0di JyD6Ew1GNRHqjNeRJ8sZ5KPZrPPnLe4AMSv5obFK5mA8yEoLsdqD5JPYCdF4JSSzZBa1 P0yi78JBN1ulqf1R+cJJGJU66es9tPsrNCTBoahRWfMsYfU0SgvWfA+4HF4u98oK0k2V ETBWlcnKWXFVCRfoZZVajMB7/RXYIsB814rPDIOV0/XuPOvMiba02vHibGx00U4Xfcoy E9tlXQYlCpoADBISfVhwfpCNnFUB+QIqY3SyFP/65LOed9h3O93M7ih6pqg9OPN8trZ3 arNw== 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; bh=A17x4c2H8FbLrEL0Fq8AJTxVIV1BnmtFmk176WoD9ko=; b=Bo3IGUtImgCMbsaKYgY5s2GsMT/OF2cOPzMw/+HR81HVPxRj115FWhqAGazpS/irhY 1qNA68xBR3r2prOsL8bARyRh8WbNlc32jGSz2tH1sTCShA9DHxPdqFhK35/pkTqE56gG DSHDLmVdH9Z1hfbAuKW+CSRgR9tfX9xpi/qcAYjM0hyM6R5htAlPQYUAdqT1WrRv+xrW 69Sm5Fc+9uVwDKxSho1kW39CED2VXUmCLzZ3DIekOBtjMcLCwlAGxRsnfeDNUVFvHUt+ DBpDFMC3wDtSKcUIrPaK7/zjKHUAU0H4ONSb91DuQ8YLrROoP1DR9t6TP6AaOsvvQ31E 124g== X-Gm-Message-State: AOUpUlFEaYU2AD8l+OreVTEW4z+ZNtavgnqKzBhfNRzZmufTAIduIw3x ST0xUUvMfAsDVswSgnt4Gfy32S3d X-Google-Smtp-Source: AA+uWPwR9rWQRgifexFHPvStAmM7DDhYgFSJsth3vIqh7fQUvxR8+PLKlBaEh8UhDv1Aa1U3U5LscA== X-Received: by 2002:a19:548e:: with SMTP id b14-v6mr19405966lfl.10.1534441622762; Thu, 16 Aug 2018 10:47:02 -0700 (PDT) From: Max Filippov To: qemu-devel@nongnu.org Date: Thu, 16 Aug 2018 10:46:44 -0700 Message-Id: <20180816174645.30364-2-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180816174645.30364-1-jcmvbkbc@gmail.com> References: <20180816174645.30364-1-jcmvbkbc@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::142 Subject: [Qemu-devel] [PATCH 1/2] target/xtensa: fix gdbstub register counts X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Max Filippov , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This fixes communication with gdb in the presence of type-5 (TIE state mapped on user registers) and type-7 (special case of masked registers) registers in the xtensa core config. Cc: qemu-stable@nongnu.org Signed-off-by: Max Filippov --- target/xtensa/helper.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/target/xtensa/helper.c b/target/xtensa/helper.c index c9a613270036..efb3cef12813 100644 --- a/target/xtensa/helper.c +++ b/target/xtensa/helper.c @@ -100,7 +100,9 @@ void xtensa_finalize_config(XtensaConfig *config) unsigned n_core_regs =3D 0; =20 for (i =3D 0; config->gdb_regmap.reg[i].targno >=3D 0; ++i) { - if (config->gdb_regmap.reg[i].type !=3D 6) { + if (config->gdb_regmap.reg[i].type !=3D 5 && + config->gdb_regmap.reg[i].type !=3D 6 && + config->gdb_regmap.reg[i].type !=3D 7) { ++n_regs; if ((config->gdb_regmap.reg[i].flags & 0x1) =3D=3D 0) { ++n_core_regs; --=20 2.11.0 From nobody Wed Nov 5 10:57:28 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1534441748637421.91804971224155; Thu, 16 Aug 2018 10:49:08 -0700 (PDT) Received: from localhost ([::1]:57471 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqMOR-0000Ly-Cu for importer@patchew.org; Thu, 16 Aug 2018 13:49:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53114) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqMMV-0007mQ-T1 for qemu-devel@nongnu.org; Thu, 16 Aug 2018 13:47:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fqMMV-000680-0v for qemu-devel@nongnu.org; Thu, 16 Aug 2018 13:47:07 -0400 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]:40540) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fqMMU-00067d-Kl for qemu-devel@nongnu.org; Thu, 16 Aug 2018 13:47:06 -0400 Received: by mail-lj1-x232.google.com with SMTP id j19-v6so4336557ljc.7 for ; Thu, 16 Aug 2018 10:47:06 -0700 (PDT) Received: from octofox.cadence.com (jcmvbkbc-1-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:1fa::2]) by smtp.gmail.com with ESMTPSA id q65-v6sm5206268lfb.80.2018.08.16.10.47.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Aug 2018 10:47:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=16Ho0gDmnXgpOwF9sQYYAPU7Yasvyq0TQ0U0LDztN7k=; b=RMn2R/BhGNVHanlxZGGYqh2df+5VLf+0Dm95NiguTTw/mc8aTpXzxCKD3usGsuETMB bpHcBzpHh6Sbug16CBKnq2jjpZ8ht48NSgLEttDlMoYxZ1rBLh7eQFqj0O1+I+K/MTQ0 4QKOE3ni/r7cgDSd0QV+B53x9Mem3vRbCuDWHamL4xqu8SFBfceLKRS2UzXNcl3OvP2W SXz+HjvVZwJxgkWQgkjji2ZWI5IfFd5n6ZbB9h12vUC3fDnWcKLy69h+GI7Ul/jr3AjY +S6tpuJ8+iIiPgJOma+JpojDaEIFhd4otmsUYCLR/AqExWjFc8t76QNisK6Lhm1tyff6 hmsg== 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; bh=16Ho0gDmnXgpOwF9sQYYAPU7Yasvyq0TQ0U0LDztN7k=; b=RodX+CMWEqCwSv9PuYUNNQiMHrpn9fa2okTbFJBnGShL/5v5bFnhvgDRst9QfHuVu4 9CYmCrGS6TGhFWGgdYQWu8bRTH8dqPl7XGRJ7cagTaPVpSsPZuHNkJsT5WUtzYrvmFfI AP5WNdw1brRQlyi+DwhJlfsUSF915YJIyaZ9t35O1Tks+2w7ZfGUnyfMixEh93Z681iS AwEw1xiRtqzGIP+Qupkti9VY7lvq3wq0jUDHXCDR2R5w7oSekrXqt9046x5CVk/jHIDN DN9VUXRzkbxtHH0ZL/2Z6PFazXrSfVz1OvLPkVvSdTsgFnxtxW6SpOWPiPsj7P4/QpWy R8WQ== X-Gm-Message-State: AOUpUlHOr1govsUVOtxx6SIOE3tianiU9IFj5/JqrH5Fw4AOoVrE0ODs 3b+uQ0V558mg+F4jGZv8KL+xDzL0 X-Google-Smtp-Source: AA+uWPwK36MuA4eic8S0jNRcTKLLuqMuKeFa6Frhd6jtO7j/72PUPrvVdwGBPpqOZ4pWh/lJoOpixw== X-Received: by 2002:a2e:8743:: with SMTP id q3-v6mr5432201ljj.139.1534441625141; Thu, 16 Aug 2018 10:47:05 -0700 (PDT) From: Max Filippov To: qemu-devel@nongnu.org Date: Thu, 16 Aug 2018 10:46:45 -0700 Message-Id: <20180816174645.30364-3-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180816174645.30364-1-jcmvbkbc@gmail.com> References: <20180816174645.30364-1-jcmvbkbc@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::232 Subject: [Qemu-devel] [PATCH 2/2] target/xtensa: clean up gdbstub register handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Max Filippov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" - move register counting to xtensa/gdbstub.c - add symbolic names for register types and flags from GDB and use them in register counting and access functions. Signed-off-by: Max Filippov --- target/xtensa/cpu.h | 2 ++ target/xtensa/gdbstub.c | 60 +++++++++++++++++++++++++++++++++++++++------= ---- target/xtensa/helper.c | 12 +--------- 3 files changed, 51 insertions(+), 23 deletions(-) diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h index 51b455146494..7472cf3ca32a 100644 --- a/target/xtensa/cpu.h +++ b/target/xtensa/cpu.h @@ -503,6 +503,8 @@ void xtensa_cpu_do_unassigned_access(CPUState *cpu, hwa= ddr addr, void xtensa_cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf, int flags); hwaddr xtensa_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); +void xtensa_count_regs(const XtensaConfig *config, + unsigned *n_regs, unsigned *n_core_regs); int xtensa_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); int xtensa_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void xtensa_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, diff --git a/target/xtensa/gdbstub.c b/target/xtensa/gdbstub.c index a8ea98d03fb8..615065b932e2 100644 --- a/target/xtensa/gdbstub.c +++ b/target/xtensa/gdbstub.c @@ -23,6 +23,42 @@ #include "exec/gdbstub.h" #include "qemu/log.h" =20 +enum { + xtRegisterTypeArRegfile =3D 1, /* Register File ar0..arXX. */ + xtRegisterTypeSpecialReg, /* CPU states, such as PS, Booleans, (rsr)= . */ + xtRegisterTypeUserReg, /* User defined registers (rur). */ + xtRegisterTypeTieRegfile, /* User define register files. */ + xtRegisterTypeTieState, /* TIE States (mapped on user regs). */ + xtRegisterTypeMapped, /* Mapped on Special Registers. */ + xtRegisterTypeUnmapped, /* Special case of masked registers. */ + xtRegisterTypeWindow, /* Live window registers (a0..a15). */ + xtRegisterTypeVirtual, /* PC, FP. */ + xtRegisterTypeUnknown +}; + +#define XTENSA_REGISTER_FLAGS_PRIVILEGED 0x0001 +#define XTENSA_REGISTER_FLAGS_READABLE 0x0002 +#define XTENSA_REGISTER_FLAGS_WRITABLE 0x0004 +#define XTENSA_REGISTER_FLAGS_VOLATILE 0x0008 + +void xtensa_count_regs(const XtensaConfig *config, + unsigned *n_regs, unsigned *n_core_regs) +{ + unsigned i; + + for (i =3D 0; config->gdb_regmap.reg[i].targno >=3D 0; ++i) { + if (config->gdb_regmap.reg[i].type !=3D xtRegisterTypeTieState && + config->gdb_regmap.reg[i].type !=3D xtRegisterTypeMapped && + config->gdb_regmap.reg[i].type !=3D xtRegisterTypeUnmapped) { + ++n_regs; + if ((config->gdb_regmap.reg[i].flags & + XTENSA_REGISTER_FLAGS_PRIVILEGED) =3D=3D 0) { + ++n_core_regs; + } + } + } +} + int xtensa_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) { XtensaCPU *cpu =3D XTENSA_CPU(cs); @@ -40,21 +76,21 @@ int xtensa_cpu_gdb_read_register(CPUState *cs, uint8_t = *mem_buf, int n) } =20 switch (reg->type) { - case 9: /*pc*/ + case xtRegisterTypeVirtual: /*pc*/ return gdb_get_reg32(mem_buf, env->pc); =20 - case 1: /*ar*/ + case xtRegisterTypeArRegfile: /*ar*/ xtensa_sync_phys_from_window(env); return gdb_get_reg32(mem_buf, env->phys_regs[(reg->targno & 0xff) % env->config->nareg]= ); =20 - case 2: /*SR*/ + case xtRegisterTypeSpecialReg: /*SR*/ return gdb_get_reg32(mem_buf, env->sregs[reg->targno & 0xff]); =20 - case 3: /*UR*/ + case xtRegisterTypeUserReg: /*UR*/ return gdb_get_reg32(mem_buf, env->uregs[reg->targno & 0xff]); =20 - case 4: /*f*/ + case xtRegisterTypeTieRegfile: /*f*/ i =3D reg->targno & 0x0f; switch (reg->size) { case 4: @@ -69,7 +105,7 @@ int xtensa_cpu_gdb_read_register(CPUState *cs, uint8_t *= mem_buf, int n) return reg->size; } =20 - case 8: /*a*/ + case xtRegisterTypeWindow: /*a*/ return gdb_get_reg32(mem_buf, env->regs[reg->targno & 0x0f]); =20 default: @@ -99,24 +135,24 @@ int xtensa_cpu_gdb_write_register(CPUState *cs, uint8_= t *mem_buf, int n) tmp =3D ldl_p(mem_buf); =20 switch (reg->type) { - case 9: /*pc*/ + case xtRegisterTypeVirtual: /*pc*/ env->pc =3D tmp; break; =20 - case 1: /*ar*/ + case xtRegisterTypeArRegfile: /*ar*/ env->phys_regs[(reg->targno & 0xff) % env->config->nareg] =3D tmp; xtensa_sync_window_from_phys(env); break; =20 - case 2: /*SR*/ + case xtRegisterTypeSpecialReg: /*SR*/ env->sregs[reg->targno & 0xff] =3D tmp; break; =20 - case 3: /*UR*/ + case xtRegisterTypeUserReg: /*UR*/ env->uregs[reg->targno & 0xff] =3D tmp; break; =20 - case 4: /*f*/ + case xtRegisterTypeTieRegfile: /*f*/ switch (reg->size) { case 4: env->fregs[reg->targno & 0x0f].f32[FP_F32_LOW] =3D make_float3= 2(tmp); @@ -130,7 +166,7 @@ int xtensa_cpu_gdb_write_register(CPUState *cs, uint8_t= *mem_buf, int n) return reg->size; } =20 - case 8: /*a*/ + case xtRegisterTypeWindow: /*a*/ env->regs[reg->targno & 0x0f] =3D tmp; break; =20 diff --git a/target/xtensa/helper.c b/target/xtensa/helper.c index efb3cef12813..f74636f67854 100644 --- a/target/xtensa/helper.c +++ b/target/xtensa/helper.c @@ -95,20 +95,10 @@ void xtensa_finalize_config(XtensaConfig *config) =20 if (config->gdb_regmap.num_regs =3D=3D 0 || config->gdb_regmap.num_core_regs =3D=3D 0) { - unsigned i; unsigned n_regs =3D 0; unsigned n_core_regs =3D 0; =20 - for (i =3D 0; config->gdb_regmap.reg[i].targno >=3D 0; ++i) { - if (config->gdb_regmap.reg[i].type !=3D 5 && - config->gdb_regmap.reg[i].type !=3D 6 && - config->gdb_regmap.reg[i].type !=3D 7) { - ++n_regs; - if ((config->gdb_regmap.reg[i].flags & 0x1) =3D=3D 0) { - ++n_core_regs; - } - } - } + xtensa_count_regs(config, &n_regs, &n_core_regs); if (config->gdb_regmap.num_regs =3D=3D 0) { config->gdb_regmap.num_regs =3D n_regs; } --=20 2.11.0