All of lore.kernel.org
 help / color / mirror / Atom feed
From: deller@kernel.org
To: qemu-devel@nongnu.org
Cc: "Soumyajyotii Ssarkar" <soumyajyotisarkar23@gmail.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Helge Deller" <deller@gmx.de>,
	"Sven Schnelle" <svens@stackframe.org>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Fam Zheng" <fam@euphon.net>
Subject: [PULL 12/12] target/hppa: add 64 bit support to gdbstub
Date: Tue, 23 Dec 2025 16:50:31 +0100	[thread overview]
Message-ID: <20251223155031.7110-13-deller@kernel.org> (raw)
In-Reply-To: <20251223155031.7110-1-deller@kernel.org>

From: Sven Schnelle <svens@stackframe.org>

Signed-off-by: Sven Schnelle <svens@stackframe.org>
Reviewed-by: Helge Deller <deller@gmx.de>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Helge Deller <deller@gmx.de>
---
 target/hppa/gdbstub.c | 62 ++++++++++++++++++++++++++++---------------
 1 file changed, 41 insertions(+), 21 deletions(-)

diff --git a/target/hppa/gdbstub.c b/target/hppa/gdbstub.c
index 0daa52f7af..777f4a48b9 100644
--- a/target/hppa/gdbstub.c
+++ b/target/hppa/gdbstub.c
@@ -21,16 +21,25 @@
 #include "cpu.h"
 #include "gdbstub/helpers.h"
 
-/*
- * GDB 15 only supports PA1.0 via the remote protocol, and ignores
- * any provided xml.  Which means that any attempt to provide more
- * data results in "Remote 'g' packet reply is too long".
- */
+static int hppa_num_regs(CPUHPPAState *env)
+{
+    return hppa_is_pa20(env) ? 96 : 128;
+}
+
+static int hppa_reg_size(CPUHPPAState *env)
+{
+    return hppa_is_pa20(env) ? 8 : 4;
+}
 
 int hppa_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
 {
-    CPUHPPAState *env = cpu_env(cs);
-    uint32_t val;
+    HPPACPU *cpu = HPPA_CPU(cs);
+    CPUHPPAState *env = &cpu->env;
+    target_ulong val;
+
+    if (n >= hppa_num_regs(env)) {
+        return 0;
+    }
 
     switch (n) {
     case 0:
@@ -133,24 +142,35 @@ int hppa_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
         val = env->cr[30];
         break;
     case 64 ... 127:
-        val = extract64(env->fr[(n - 64) / 2], (n & 1 ? 0 : 32), 32);
-        break;
-    default:
-        if (n < 128) {
-            val = 0;
+        if (hppa_is_pa20(env)) {
+            val = env->fr[n - 64];
         } else {
-            return 0;
+            val = extract64(env->fr[(n - 64) / 2], (n & 1 ? 0 : 32), 32);
         }
         break;
+    default:
+        val = 0;
+        break;
     }
 
-    return gdb_get_reg32(mem_buf, val);
+    if (hppa_is_pa20(env)) {
+        return gdb_get_reg64(mem_buf, val);
+    } else {
+        return gdb_get_reg32(mem_buf, val);
+    }
 }
 
 int hppa_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
 {
-    CPUHPPAState *env = cpu_env(cs);
-    uint32_t val = ldl_p(mem_buf);
+    HPPACPU *cpu = HPPA_CPU(cs);
+    CPUHPPAState *env = &cpu->env;
+    target_ulong val;
+
+    if (n >= hppa_num_regs(env)) {
+        return 0;
+    }
+
+    val = ldn_p(mem_buf, hppa_reg_size(env));
 
     switch (n) {
     case 0:
@@ -267,16 +287,16 @@ int hppa_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
         cpu_hppa_loaded_fr0(env);
         break;
     case 65 ... 127:
-        {
+        if (hppa_is_pa20(env)) {
+            env->fr[n - 64] = val;
+        } else {
             uint64_t *fr = &env->fr[(n - 64) / 2];
             *fr = deposit64(*fr, (n & 1 ? 0 : 32), 32, val);
         }
         break;
     default:
-        if (n >= 128) {
-            return 0;
-        }
         break;
     }
-    return 4;
+
+    return hppa_reg_size(env);
 }
-- 
2.52.0



  parent reply	other threads:[~2025-12-23 15:52 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-23 15:50 [PULL 00/12] Hppa updates qemu v11 patches deller
2025-12-23 15:50 ` [PULL 02/12] scsi: ncr710: Add null pointer checks deller
2025-12-23 15:50 ` [PULL 03/12] scsi: ncr710: Fix use after free in command_complete deller
2025-12-23 15:50 ` [PULL 04/12] scsi: ncr710: Fix interrupt related register handing deller
2025-12-23 15:50 ` [PULL 05/12] scsi: ncr710: Fix DMA State machine and flow control deller
2025-12-23 15:50 ` [PULL 06/12] scsi: ncr710: Fix table indirect addressing endianness deller
2025-12-23 15:50 ` [PULL 07/12] scsi: ncr710: Mark command complete in status phase and fix disconnect deller
2025-12-23 15:50 ` [PULL 08/12] scsi: ncr710: Add LUN scanning deller
2025-12-23 15:50 ` [PULL 09/12] scsi: ncr710: Simplify disconnect handling deller
2025-12-23 15:50 ` [PULL 10/12] scsi: ncr710: Fix DSA register deller
2025-12-23 15:50 ` [PULL 11/12] scsi: ncr710: Fix CTEST FIFO status deller
2025-12-23 15:50 ` deller [this message]
2026-03-10  6:15   ` [PULL 12/12] target/hppa: add 64 bit support to gdbstub Philippe Mathieu-Daudé
2026-03-10  6:45     ` Sven Schnelle
2026-03-10  7:06       ` Sven Schnelle
2026-03-10 10:54         ` Philippe Mathieu-Daudé
2026-03-10 16:49           ` Sven Schnelle
2025-12-28 22:08 ` [PULL 00/12] Hppa updates qemu v11 patches Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251223155031.7110-13-deller@kernel.org \
    --to=deller@kernel.org \
    --cc=deller@gmx.de \
    --cc=fam@euphon.net \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=soumyajyotisarkar23@gmail.com \
    --cc=svens@stackframe.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.