All of lore.kernel.org
 help / color / mirror / Atom feed
From: matheus.ferst@eldorado.org.br
To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org
Cc: richard.henderson@linaro.org, laurent@vivier.eu, groug@kaod.org,
	Lucas Mateus Castro <lucas.araujo@eldorado.org.br>,
	Matheus Ferst <matheus.ferst@eldorado.org.br>,
	david@gibson.dropbear.id.au
Subject: [PATCH 3/4] linux-user: Fix XER access in ppc version of elf_core_copy_regs
Date: Thu, 14 Oct 2021 19:32:33 -0300	[thread overview]
Message-ID: <20211014223234.127012-4-matheus.ferst@eldorado.org.br> (raw)
In-Reply-To: <20211014223234.127012-1-matheus.ferst@eldorado.org.br>

From: Matheus Ferst <matheus.ferst@eldorado.org.br>

env->xer doesn't hold some bits of XER, like OV and CA. To write the
complete register in the core dump we should read XER value with
cpu_read_xer.

Reported-by: Lucas Mateus Castro (alqotel) <lucas.araujo@eldorado.org.br>
Fixes: da91a00f191f ("target-ppc: Split out SO, OV, CA fields from XER")
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
---
 linux-user/elfload.c | 2 +-
 target/ppc/cpu.c     | 2 +-
 target/ppc/cpu.h     | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 01e9a833fb..e760786a98 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -896,7 +896,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUPPCState *en
     (*regs)[33] = tswapreg(env->msr);
     (*regs)[35] = tswapreg(env->ctr);
     (*regs)[36] = tswapreg(env->lr);
-    (*regs)[37] = tswapreg(env->xer);
+    (*regs)[37] = tswapreg(cpu_read_xer(env));
 
     for (i = 0; i < ARRAY_SIZE(env->crf); i++) {
         ccr |= env->crf[i] << (32 - ((i + 1) * 4));
diff --git a/target/ppc/cpu.c b/target/ppc/cpu.c
index 7ad9bd6044..f933d9f2bd 100644
--- a/target/ppc/cpu.c
+++ b/target/ppc/cpu.c
@@ -27,7 +27,7 @@
 #include "helper_regs.h"
 #include "sysemu/tcg.h"
 
-target_ulong cpu_read_xer(CPUPPCState *env)
+target_ulong cpu_read_xer(const CPUPPCState *env)
 {
     if (is_isa300(env)) {
         return env->xer | (env->so << XER_SO) |
diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
index 500205229c..67a143941f 100644
--- a/target/ppc/cpu.h
+++ b/target/ppc/cpu.h
@@ -2418,7 +2418,7 @@ enum {
 /*****************************************************************************/
 
 #define is_isa300(ctx) (!!(ctx->insns_flags2 & PPC2_ISA300))
-target_ulong cpu_read_xer(CPUPPCState *env);
+target_ulong cpu_read_xer(const CPUPPCState *env);
 void cpu_write_xer(CPUPPCState *env, target_ulong xer);
 
 /*
-- 
2.25.1



  parent reply	other threads:[~2021-10-14 22:38 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-14 22:32 [PATCH 0/4] Fix incorrect accesses to XER matheus.ferst
2021-10-14 22:32 ` [PATCH 1/4] linux-user/ppc: Fix XER access in save/restore_user_regs matheus.ferst
2021-10-14 23:43   ` Richard Henderson
2021-10-15 14:54     ` Matheus K. Ferst
2021-10-15 18:24       ` Richard Henderson
2021-10-15  0:30   ` David Gibson
2021-10-14 22:32 ` [PATCH 2/4] target/ppc: Fix XER access in gdbstub matheus.ferst
2021-10-14 23:43   ` Richard Henderson
2021-10-15  0:31   ` David Gibson
2021-10-14 22:32 ` matheus.ferst [this message]
2021-10-14 23:44   ` [PATCH 3/4] linux-user: Fix XER access in ppc version of elf_core_copy_regs Richard Henderson
2021-10-14 22:32 ` [PATCH 4/4] target/ppc: Fix XER access in monitor matheus.ferst
2021-10-14 23:45   ` 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=20211014223234.127012-4-matheus.ferst@eldorado.org.br \
    --to=matheus.ferst@eldorado.org.br \
    --cc=david@gibson.dropbear.id.au \
    --cc=groug@kaod.org \
    --cc=laurent@vivier.eu \
    --cc=lucas.araujo@eldorado.org.br \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=richard.henderson@linaro.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.