From nobody Fri Apr 4 05:57:41 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1742408662; cv=none; d=zohomail.com; s=zohoarc; b=iMRty6cpcd6umw8cjdQiRjhl/8nP4upqlQ503uavgqBOAg7DgZxqPYjzabmHtR+EmpxqY5G0OgdIqZ/vqcER1dEMI6+Zmg81BO8EIIqP5ScD6XCsjbZMo9Z9WAz7fa3+/4OPVK6HiOsoGn7IQSPZyBezEr2BT343Woz5wJzuSEg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742408662; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3IgWp4WCaXbcrtv8Yoastsvt3hmlgscQMXb34UR5gEk=; b=bFhuHH7RrjU12JaHYAyMbNQVtYD94DHT/dF2RPeIEwlroDbz/CEgQz2fhfw5qGugz//aTp91/z0CKpsVLvYv/GsxlX/jZZMOCgzTvH298e4yRa6z45EWQtMIbHXJV4zVFiNlgb/Uwj6LOC+iCIyE5BwTSEj9UVGqPeZjKrakaDo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742408662734129.73574613118217; Wed, 19 Mar 2025 11:24:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuy4O-0000JQ-8U; Wed, 19 Mar 2025 14:23:12 -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 1tuy4I-00009v-I9 for qemu-devel@nongnu.org; Wed, 19 Mar 2025 14:23:06 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tuy4C-0006N0-26 for qemu-devel@nongnu.org; Wed, 19 Mar 2025 14:23:06 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-43cf680d351so6823315e9.0 for ; Wed, 19 Mar 2025 11:22:59 -0700 (PDT) Received: from draig.lan ([185.126.160.109]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43d43f376d3sm26330865e9.4.2025.03.19.11.22.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Mar 2025 11:22:56 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 908D45FAC7; Wed, 19 Mar 2025 18:22:55 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1742408578; x=1743013378; 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=3IgWp4WCaXbcrtv8Yoastsvt3hmlgscQMXb34UR5gEk=; b=bkNHF12uX7+66nWTN+Vy4utk31odQ9g7IboA5KsO75ntncqsQD4vI68Ygm/qLJj+Uz hl8vGfa7usXp0+lC2qCyLqFLb9SDIOrpz91ECaPntM4wdziFGu+TSEVd1UP6g/Fdfosn 29DCwzSGasm2HekaMmqShQGhJKSaiN/AoIzJi2U/dt3WWFPYQtiWyOraQ7aLi3w/kUsK CyT0Ol8g+jpriGH24FcJjsf7gBI8BT4pUTeu/pxkjp3Vd1sBujPkc7ZTH18CmkdJu0DK 9HmIzN2+i+9ag3jajBxe3sPXzaHWoDaZbpDwCz9KrTlw8kh8Y5HtXCzGTHLuigYvpWtk +png== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742408578; x=1743013378; 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=3IgWp4WCaXbcrtv8Yoastsvt3hmlgscQMXb34UR5gEk=; b=fG/APSxypBbe3UTcHfkd1SQ1Tc48/XyditvLpTUeG6eb+ZpuoASCMJgsB0tPQ1P0oz xy0UtjRKRR4wyrYzH6RGNBUClA0iwxmENwXiFqgyaXG2NRRXRmUl6gzYDxxjbCkYB3Fx yQaTbxNU+/CQdPdu1xUgCRnd7ti84Sf9V+moEAUYGNWsaYcokEo7HhXZVIwRbum6FhYs 3ZvB172uJRlYMMwhP6jHq0qTJ1dt/A70JMdj0w+8ig52DLCBS1/u3g49PQ6ZyzccIMfV vNKXZNx4i2QI3BQCUkcEMy55nQqGyhiBJp2c3IhasTvBUAJhRAlqU7h7j9x5qCmkgfAj 10Kw== X-Gm-Message-State: AOJu0YxYo4+k5ycD2Lq9GhWpdAYUsGsDmAMrCypvS5DeKTur04JS4fhM Hr9ydsH/xP6RfCxh/r/NnQLfOLLVFChuyiXDqkS2x9tlxhRyjKOFHzQdcA6yjZ8= X-Gm-Gg: ASbGncuYytOT/Xo8tQFysipjpdf6ALGgvAaypek+SqEzCEaKeb6lE4jYqCKcEGw89F0 fZmlBrFW48/rWFi+55djbC9Cj9YEQJYsvDEYJhmf7U0Q+D6Mn1HvsDnUQJPDjc9EN47K2MV4wLG HeESoRgE2vbRZ03XgxrulcLvCvsivZe5CsAMWSgPZDYBmDr7jYcPKV9O6PLL+9MKuoik3ukUuPr XSv9jqMc0cGNrBvHIJN5Dfsc3Oenz09fP01PrDRbDVzDKx0pG69J5jUSQgS/c1qPXqc75P32cGB hDYFoWwfN3Id8i55LVq7L5/DaB+MX/Qcurzl888rfGDMoZ8= X-Google-Smtp-Source: AGHT+IHInZiHFKhcsVP4Td6oIgZNdEkttHm93MlPVGH9No0cSuMWiwNAfQA6b8KETHcZLP9ag/cEfQ== X-Received: by 2002:a5d:5f4c:0:b0:391:b93:c971 with SMTP id ffacd0b85a97d-39979586d6fmr572712f8f.20.1742408578086; Wed, 19 Mar 2025 11:22:58 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , Juan Quintela , Ilya Leoshkevich , Thomas Huth , Akihiko Odaki , qemu-ppc@nongnu.org, David Gibson , qemu-s390x@nongnu.org, Wainer dos Santos Moschetta , Peter Xu , Markus Armbruster , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Daniel Henrique Barboza , David Hildenbrand , Yonggang Luo , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , Beraldo Leal , qemu-arm@nongnu.org, Greg Kurz , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Nicholas Piggin , Paolo Bonzini , "Edgar E. Iglesias" Subject: [PATCH 04/10] target/arm: convert 64 bit gdbstub to new helper Date: Wed, 19 Mar 2025 18:22:49 +0000 Message-Id: <20250319182255.3096731-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250319182255.3096731-1-alex.bennee@linaro.org> References: <20250319182255.3096731-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x331.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1742408664097019100 For some of the helpers we need a temporary variable to copy from although we could add some helpers to return pointers into env in those cases if we wanted to. Signed-off-by: Alex Benn=C3=A9e --- target/arm/gdbstub64.c | 53 ++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index 1a4dbec567..793332af31 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -20,7 +20,7 @@ #include "qemu/log.h" #include "cpu.h" #include "internals.h" -#include "gdbstub/helpers.h" +#include "gdbstub/registers.h" #include "gdbstub/commands.h" #include "tcg/mte_helper.h" #if defined(CONFIG_USER_ONLY) && defined(CONFIG_LINUX) @@ -35,15 +35,16 @@ int aarch64_cpu_gdb_read_register(CPUState *cs, GByteAr= ray *mem_buf, int n) =20 if (n < 31) { /* Core integer register. */ - return gdb_get_reg64(mem_buf, env->xregs[n]); + return gdb_get_register_value(MO_TEUO, mem_buf, (uint8_t *) &env->= xregs[n]); } switch (n) { case 31: - return gdb_get_reg64(mem_buf, env->xregs[31]); + return gdb_get_register_value(MO_TEUO, mem_buf, (uint8_t *) &env->= xregs[31]); case 32: - return gdb_get_reg64(mem_buf, env->pc); + return gdb_get_register_value(MO_TEUO, mem_buf, (uint8_t *) &env->= pc); case 33: - return gdb_get_reg32(mem_buf, pstate_read(env)); + uint32_t pstate =3D pstate_read(env); + return gdb_get_register_value(MO_TEUL, mem_buf, (uint8_t *) &pstat= e); } /* Unknown register. */ return 0; @@ -82,23 +83,27 @@ int aarch64_gdb_get_fpu_reg(CPUState *cs, GByteArray *b= uf, int reg) { ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; + uint32_t fpr; =20 switch (reg) { case 0 ... 31: { /* 128 bit FP register - quads are in LE order */ uint64_t *q =3D aa64_vfp_qreg(env, reg); - return gdb_get_reg128(buf, q[1], q[0]); + return gdb_get_register_value(MO_TEUO, buf, (uint8_t *) q); } case 32: /* FPSR */ - return gdb_get_reg32(buf, vfp_get_fpsr(env)); + fpr =3D vfp_get_fpsr(env); + break; case 33: /* FPCR */ - return gdb_get_reg32(buf, vfp_get_fpcr(env)); + fpr =3D vfp_get_fpcr(env); + break; default: return 0; } + return gdb_get_register_value(MO_TEUL, buf, (uint8_t *) &fpr); } =20 int aarch64_gdb_set_fpu_reg(CPUState *cs, uint8_t *buf, int reg) @@ -132,30 +137,37 @@ int aarch64_gdb_get_sve_reg(CPUState *cs, GByteArray = *buf, int reg) { ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; + uint32_t fpr; =20 switch (reg) { /* The first 32 registers are the zregs */ case 0 ... 31: { int vq, len =3D 0; + ARMVectorReg *zreg =3D &env->vfp.zregs[reg]; + for (vq =3D 0; vq < cpu->sve_max_vq; vq++) { - len +=3D gdb_get_reg128(buf, - env->vfp.zregs[reg].d[vq * 2 + 1], - env->vfp.zregs[reg].d[vq * 2]); + len +=3D gdb_get_register_value(MO_TEUQ, buf, + (uint8_t *) &zreg->d[vq * 2 + 1]= ); + len +=3D gdb_get_register_value(MO_TEUQ, buf, + (uint8_t *) &zreg->d[vq * 2]); } return len; } case 32: - return gdb_get_reg32(buf, vfp_get_fpsr(env)); + fpr =3D vfp_get_fpsr(env); + return gdb_get_register_value(MO_TEUL, buf, (uint8_t *) &fpr); case 33: - return gdb_get_reg32(buf, vfp_get_fpcr(env)); + fpr =3D vfp_get_fpcr(env); + return gdb_get_register_value(MO_TEUL, buf, (uint8_t *) &fpr); /* then 16 predicates and the ffr */ case 34 ... 50: { int preg =3D reg - 34; int vq, len =3D 0; for (vq =3D 0; vq < cpu->sve_max_vq; vq =3D vq + 4) { - len +=3D gdb_get_reg64(buf, env->vfp.pregs[preg].p[vq / 4]); + len +=3D gdb_get_register_value(MO_TEUQ, buf, + (uint8_t *) &env->vfp.pregs[preg= ].p[vq / 4]); } return len; } @@ -165,8 +177,8 @@ int aarch64_gdb_get_sve_reg(CPUState *cs, GByteArray *b= uf, int reg) * We report in Vector Granules (VG) which is 64bit in a Z reg * while the ZCR works in Vector Quads (VQ) which is 128bit chunks. */ - int vq =3D sve_vqm1_for_el(env, arm_current_el(env)) + 1; - return gdb_get_reg64(buf, vq * 2); + uint64_t vq =3D (sve_vqm1_for_el(env, arm_current_el(env)) + 1) * = 2; + return gdb_get_register_value(MO_TEUL, buf, (uint8_t *) &vq); } default: /* gdbstub asked for something out our range */ @@ -248,10 +260,11 @@ int aarch64_gdb_get_pauth_reg(CPUState *cs, GByteArra= y *buf, int reg) bool is_data =3D !(reg & 1); bool is_high =3D reg & 2; ARMMMUIdx mmu_idx =3D arm_stage1_mmu_idx(env); - ARMVAParameters param; + ARMVAParameters param =3D aa64_va_parameters(env, -is_high, mm= u_idx, + is_data, false); + uint64_t pauth_mask =3D pauth_ptr_mask(param); =20 - param =3D aa64_va_parameters(env, -is_high, mmu_idx, is_data, = false); - return gdb_get_reg64(buf, pauth_ptr_mask(param)); + return gdb_get_register_value(MO_TEUQ, buf, (uint8_t *) &pauth= _mask); } default: return 0; @@ -399,7 +412,7 @@ int aarch64_gdb_get_tag_ctl_reg(CPUState *cs, GByteArra= y *buf, int reg) =20 tcf0 =3D extract64(env->cp15.sctlr_el[1], 38, 2); =20 - return gdb_get_reg64(buf, tcf0); + return gdb_get_register_value(MO_TEUQ, buf, (uint8_t *) &tcf0); } =20 int aarch64_gdb_set_tag_ctl_reg(CPUState *cs, uint8_t *buf, int reg) --=20 2.39.5