Skip to contentSkip to conversation

HPPA64-PATCHES-for-8.2

PATCH In review [email protected] 3 participants 7 messages Nov 17, 2023

lore
Share & tools
lore
#1 lore raw

PATCH v2 1/2 target/hppa: Fix 64-bit SHRPD instruction

In reply to [email protected]

From: Helge Deller <[email protected]>

When shifting the two joined 64-bit registers right, shift the upper 64-bit register to the left and the lower 64-bit register to the right before merging them with OR.

---
 target/hppa/translate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/hppa/translate.c +2 -2
index 4a4830c3e3..3ef39b1bd7 100644
@@ -3438,9 +3438,9 @@ static bool trans_shrp_sar(DisasContext *ctx, arg_shrp_sar *a)
             TCGv_i64 n = tcg_temp_new_i64();
 
             tcg_gen_xori_i64(n, cpu_sar, 63);
-            tcg_gen_shl_i64(t, src2, n);
+            tcg_gen_shl_i64(t, src1, n);
             tcg_gen_shli_i64(t, t, 1);
-            tcg_gen_shr_i64(dest, src1, cpu_sar);
+            tcg_gen_shr_i64(dest, src2, cpu_sar);
             tcg_gen_or_i64(dest, dest, t);
         } else {
             TCGv_i64 t = tcg_temp_new_i64();
Signature · 1 line
2.41.0
#3 lore raw

PATCH v2 2/2 disas/hppa: Show hexcode of instruction along with disassembly

In reply to [email protected]

From: Helge Deller <[email protected]>

On hppa many instructions can be expressed by different bytecodes. To be able to debug qemu translation bugs it's therefore necessary to see the currently executed byte codes without the need to lookup the sequence without the full executable.
With this patch the instruction byte code is shown beside the disassembly.

---
 disas/hppa.c | 3 +++
 1 file changed, 3 insertions(+)
disas/hppa.c +3 -0
index dcf9a47f34..38fc05acc4 100644
@@ -1979,6 +1979,9 @@ print_insn_hppa (bfd_vma memaddr, disassemble_info *info)
 	  if (opcode->arch == pa20w)
 	    continue;
 #endif
+	  (*info->fprintf_func) (info->stream, " %02x %02x %02x %02x   ",
+                (insn >> 24) & 0xff, (insn >> 16) & 0xff,
+                (insn >>  8) & 0xff, insn & 0xff);
 	  (*info->fprintf_func) (info->stream, "%s", opcode->name);
 
 	  if (!strchr ("cfCY?-+nHNZFIuv{", opcode->args[0]))
Signature · 1 line
2.41.0
#0 lore raw

v2 cover HPPA64-PATCHES-for-8.2

From: Helge Deller <[email protected]>

Two patches which I'd like to get included for 8.2.

The SHRPD patch fixes a real translation bug which then allows to boot the 64-bit Linux kernels of the Debian-11 and Debian-12 installation CDs.

The second patch adds the instruction byte sequence to the assembly log. This is not an actual bug fix, but it's important since it helps a lot when trying to fix qemu translation bugs on hppa.

v2:
- corrected "upper" and "lower" in commit SHRPD message

Helge Deller (2):
target/hppa: Fix 64-bit SHRPD instruction disas/hppa: Show hexcode of instruction along with disassembly

 disas/hppa.c            | 3 +++
 target/hppa/translate.c | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)
Signature · 1 line
2.41.0
Reviewed-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] target/hppa: Fix 64-bit SHRPD instruction

In reply to [email protected]
Quoted 10 lines · On 11/17/23 02:53, [email protected] wrote:

From: Helge Deller <[email protected]>

When shifting the two joined 64-bit registers right, shift the upper 64-bit register to the left and the lower 64-bit register to the right before merging them with OR.

---
  target/hppa/translate.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

r~

Reviewed-by on v2 2/2
#4 lore raw

Re: [PATCH v2 2/2] disas/hppa: Show hexcode of instruction along with disassembly

In reply to [email protected]
Quoted 18 lines · On 11/17/23 02:53, [email protected] wrote:

From: Helge Deller <[email protected]>

On hppa many instructions can be expressed by different bytecodes. To be able to debug qemu translation bugs it's therefore necessary to see the currently executed byte codes without the need to lookup the sequence without the full executable.
With this patch the instruction byte code is shown beside the disassembly.

---
  disas/hppa.c | 3 +++
  1 file changed, 3 insertions(+)
disas/hppa.c +0 -0
index dcf9a47f34..38fc05acc4 100644

disas/hppa.c print_insn_hppa (bfd_vma memaddr, disassemble_info *info) · line 1987

Quoted 9 lines
disas/hppa.c +3 -0
@@ -1979,6 +1979,9 @@ print_insn_hppa (bfd_vma memaddr, disassemble_info *info)
  	  if (opcode->arch == pa20w)
  	    continue;
  #endif
+	  (*info->fprintf_func) (info->stream, " %02x %02x %02x %02x   ",
+                (insn >> 24) & 0xff, (insn >> 16) & 0xff,
+                (insn >>  8) & 0xff, insn & 0xff);
  	  (*info->fprintf_func) (info->stream, "%s", opcode->name);
 
  	  if (!strchr ("cfCY?-+nHNZFIuv{", opcode->args[0]))

A possible improvement is to push this outside of the search loop and then change

     }

- (*info->fprintf_func) (info->stream, "#%8x", insn);
+ info->fprintf_func(info->stream, "<unknown>"); return sizeof (insn);

so the byte decode is shared with the rare case of garbage in the insn stream.

r~

#5 lore raw

Re: [PATCH v2 2/2] disas/hppa: Show hexcode of instruction along with disassembly

* Richard Henderson <[email protected]>:

Quoted 37 lines · On 11/17/23 02:53, [email protected] wrote:
Quoted 18 lines

From: Helge Deller <[email protected]>

On hppa many instructions can be expressed by different bytecodes. To be able to debug qemu translation bugs it's therefore necessary to see the currently executed byte codes without the need to lookup the sequence without the full executable.
With this patch the instruction byte code is shown beside the disassembly.

---
  disas/hppa.c | 3 +++
  1 file changed, 3 insertions(+)
disas/hppa.c +0 -0
index dcf9a47f34..38fc05acc4 100644

disas/hppa.c print_insn_hppa (bfd_vma memaddr, disassemble_info *info) · line 1986

Quoted 8 lines
disas/hppa.c +3 -0
@@ -1979,6 +1979,9 @@ print_insn_hppa (bfd_vma memaddr, disassemble_info *info)
  	  if (opcode->arch == pa20w)
  	    continue;
  #endif
+	  (*info->fprintf_func) (info->stream, " %02x %02x %02x %02x   ",
+                (insn >> 24) & 0xff, (insn >> 16) & 0xff,
+                (insn >>  8) & 0xff, insn & 0xff);
  	  (*info->fprintf_func) (info->stream, "%s", opcode->name);
  	  if (!strchr ("cfCY?-+nHNZFIuv{", opcode->args[0]))

A possible improvement is to push this outside of the search loop and then change

     }
(quoted diff) +1 -1
-  (*info->fprintf_func) (info->stream, "#%8x", insn);
+  info->fprintf_func(info->stream, "<unknown>");
   return sizeof (insn);
Quoted 1 line

so the byte decode is shared with the rare case of garbage in the insn stream.

Like below?

From: Helge Deller <[email protected]>
Subject: [PATCH] disas/hppa: Show hexcode of instruction along with
disassembly

On hppa many instructions can be expressed by different bytecodes. To be able to debug qemu translation bugs it's therefore necessary to see the currently executed byte codes without the need to lookup the sequence without the full executable.
With this patch the instruction byte code is shown beside the disassembly.

disas/hppa.c +5 -1
index dcf9a47f34..cce4f4aa37 100644
@@ -1968,6 +1968,10 @@ print_insn_hppa (bfd_vma memaddr, disassemble_info *info)
 
   insn = bfd_getb32 (buffer);
 
+  info->fprintf_func(info->stream, " %02x %02x %02x %02x   ",
+                (insn >> 24) & 0xff, (insn >> 16) & 0xff,
+                (insn >>  8) & 0xff, insn & 0xff);
+
   for (i = 0; i < NUMOPCODES; ++i)
     {
       const struct pa_opcode *opcode = &pa_opcodes[i];
@@ -2826,6 +2830,6 @@ print_insn_hppa (bfd_vma memaddr, disassemble_info *info)
 	  return sizeof (insn);
 	}
     }
-  (*info->fprintf_func) (info->stream, "#%8x", insn);
+  info->fprintf_func(info->stream, "<unknown>");
   return sizeof (insn);
 }
#6 lore raw

Re: [PATCH v2 2/2] disas/hppa: Show hexcode of instruction along with disassembly

Quoted 33 lines · Helge Deller

* Richard Henderson <[email protected]>:

Quoted 32 lines · On 11/17/23 02:53, [email protected] wrote:
Quoted 18 lines

From: Helge Deller <[email protected]>

On hppa many instructions can be expressed by different bytecodes. To be able to debug qemu translation bugs it's therefore necessary to see the currently executed byte codes without the need to lookup the sequence without the full executable.
With this patch the instruction byte code is shown beside the disassembly.

---
   disas/hppa.c | 3 +++
   1 file changed, 3 insertions(+)
disas/hppa.c +0 -0
index dcf9a47f34..38fc05acc4 100644

disas/hppa.c print_insn_hppa (bfd_vma memaddr, disassemble_info *info) · line 1986

Quoted 8 lines
disas/hppa.c +3 -0
@@ -1979,6 +1979,9 @@ print_insn_hppa (bfd_vma memaddr, disassemble_info *info)
   	  if (opcode->arch == pa20w)
   	    continue;
   #endif
+	  (*info->fprintf_func) (info->stream, " %02x %02x %02x %02x   ",
+                (insn >> 24) & 0xff, (insn >> 16) & 0xff,
+                (insn >>  8) & 0xff, insn & 0xff);
   	  (*info->fprintf_func) (info->stream, "%s", opcode->name);
   	  if (!strchr ("cfCY?-+nHNZFIuv{", opcode->args[0]))

A possible improvement is to push this outside of the search loop and then change

Quoted 8 lines
Quoted 6 lines
      }
disas/hppa.c +1 -1
-  (*info->fprintf_func) (info->stream, "#%8x", insn);
+  info->fprintf_func(info->stream, "<unknown>");
    return sizeof (insn);

so the byte decode is shared with the rare case of garbage in the insn stream.

Like below?

Yes, perfect, thanks.

r~

Quoted 36 lines

From: Helge Deller <[email protected]>
Subject: [PATCH] disas/hppa: Show hexcode of instruction along with
disassembly

On hppa many instructions can be expressed by different bytecodes. To be able to debug qemu translation bugs it's therefore necessary to see the currently executed byte codes without the need to lookup the sequence without the full executable.
With this patch the instruction byte code is shown beside the disassembly.

disas/hppa.c +5 -1
index dcf9a47f34..cce4f4aa37 100644
@@ -1968,6 +1968,10 @@ print_insn_hppa (bfd_vma memaddr, disassemble_info *info)
 
    insn = bfd_getb32 (buffer);
 
+  info->fprintf_func(info->stream, " %02x %02x %02x %02x   ",
+                (insn >> 24) & 0xff, (insn >> 16) & 0xff,
+                (insn >>  8) & 0xff, insn & 0xff);
+
    for (i = 0; i < NUMOPCODES; ++i)
      {
        const struct pa_opcode *opcode = &pa_opcodes[i];
@@ -2826,6 +2830,6 @@ print_insn_hppa (bfd_vma memaddr, disassemble_info *info)
  	  return sizeof (insn);
  	}
      }
-  (*info->fprintf_func) (info->stream, "#%8x", insn);
+  info->fprintf_func(info->stream, "<unknown>");
    return sizeof (insn);
  }