On 4/11/24 18:15, M Bazz wrote:
On Thu, Apr 11, 2024, 5:55 PM Richard Henderson
<richard.hender...@linaro.org> wrote:

On 4/11/24 14:29, M Bazz wrote:
fixes a longstanding bug which causes a "Nonparity Synchronous Error"
kernel panic while using a debugger on Solaris / SunOS systems. The panic
would occur on the first attempt to single-step the process.

The problem stems from an lda instruction on ASI_USERTXT (8). This asi
was not being resolved correctly by resolve_asi().

Further details can be found in #2281

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2281
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2059
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1609
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1166

Signed-off-by: M Bazz <b...@bazz1.com>
---
   target/sparc/translate.c | 2 ++
   1 file changed, 2 insertions(+)

diff --git a/target/sparc/translate.c b/target/sparc/translate.c
index 319934d9bd..1596005e22 100644
--- a/target/sparc/translate.c
+++ b/target/sparc/translate.c
@@ -3,6 +3,7 @@

      Copyright (C) 2003 Thomas M. Ogrisegg <t...@fnord.at>
      Copyright (C) 2003-2005 Fabrice Bellard
+   Copyright (C) 2024 M Bazz <b...@bazz1.com>

      This library is free software; you can redistribute it and/or
      modify it under the terms of the GNU Lesser General Public
@@ -1159,6 +1160,7 @@ static DisasASI resolve_asi(DisasContext *dc, int asi, 
MemOp memop)
                  || (asi == ASI_USERDATA
                      && (dc->def->features & CPU_FEATURE_CASA))) {
           switch (asi) {
+        case ASI_USERTXT:    /* User text access */
           case ASI_USERDATA:   /* User data access */
               mem_idx = MMU_USER_IDX;
               type = GET_ASI_DIRECT;

I don't believe this is correct, because it operates against the page's "read" 
permissions
instead of "execute" permissions.


r~

Hi Richard,

Thanks for your guidance. It set me in the right direction. Now I
think I've got the right spot.

function `helper_ld_asi` has a block to help load ASI_KERNELTXT, but the
ASI_USERTXT case defaults to sparc_raise_mmu_fault(); I believe this
is the true culprit
source reference:
https://gitlab.com/qemu-project/qemu/-/blob/master/target/sparc/ldst_helper.c?ref_type=heads#L687

The code for the ASI_KERNELTXT seems generic enough to also use for
ASI_USERTXT verbatim.
See v2 patch below. I've done a `make test` -- all passing (3 skips).
OS boots, and the
debuggers are working without issue. What do you think?

Once we arrive at the right solution, I'll finalize the patch.
-bazz


diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c
index e581bb42ac..4f87e44a93 100644
--- a/target/sparc/ldst_helper.c
+++ b/target/sparc/ldst_helper.c
@@ -684,6 +684,7 @@ uint64_t helper_ld_asi(CPUSPARCState *env,
target_ulong addr,
      case ASI_M_DIAGS:   /* Turbosparc DTLB Diagnostic */
      case ASI_M_IODIAG:  /* Turbosparc IOTLB Diagnostic */
          break;
+    case ASI_USERTXT: /* User code access */
      case ASI_KERNELTXT: /* Supervisor code access */
          oi = make_memop_idx(memop, cpu_mmu_index(env_cpu(env), true));

No, this also does not work, because it uses the wrong permissions (kernel instead of user). I have just sent a patch to fix both problems.


r~

Reply via email to