diff mbox series

[PULL,32/52] exec-all: Widen TranslationBlock pc and cs_base to 64-bits

Message ID 20230605201548.1596865-33-richard.henderson@linaro.org
State New
Headers show
Series [PULL,01/52] tcg/ppc: Remove TARGET_LONG_BITS, TCG_TYPE_TL | expand

Commit Message

Richard Henderson June 5, 2023, 8:15 p.m. UTC
This makes TranslationBlock agnostic to the address size of the guest.
Use vaddr for pc, since that's always a virtual address.
Use uint64_t for cs_base, since usage varies between guests.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/exec/exec-all.h | 4 ++--
 accel/tcg/cpu-exec.c    | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

Comments

Peter Maydell July 11, 2023, 4:42 p.m. UTC | #1
On Mon, 5 Jun 2023 at 21:27, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> This makes TranslationBlock agnostic to the address size of the guest.
> Use vaddr for pc, since that's always a virtual address.
> Use uint64_t for cs_base, since usage varies between guests.

> index 60ca9e229e..1cf4f1fa22 100644
> --- a/accel/tcg/cpu-exec.c
> +++ b/accel/tcg/cpu-exec.c
> @@ -297,7 +297,7 @@ static void log_cpu_exec(target_ulong pc, CPUState *cpu,
>  {
>      if (qemu_log_in_addr_range(pc)) {
>          qemu_log_mask(CPU_LOG_EXEC,
> -                      "Trace %d: %p [" TARGET_FMT_lx
> +                      "Trace %d: %p [%08" PRIx64
>                        "/" TARGET_FMT_lx "/%08x/%08x] %s\n",
>                        cpu->cpu_index, tb->tc.ptr, tb->cs_base, pc,
>                        tb->flags, tb->cflags, lookup_symbol(pc));

TARGET_FMT_lx zero-pads appropriately to the size of
target_ulong, which is what cs_base used to be.
Now we have an explicit %08, which will sometimes
be too small for cs_base if the guest really uses all
64 bits of it. Is that intentional ?

thanks
-- PMM
diff mbox series

Patch

diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index ec0902c532..dec17b1e62 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -516,7 +516,7 @@  struct TranslationBlock {
      * Unwind information is taken as offsets from the page, to be
      * deposited into the "current" PC.
      */
-    target_ulong pc;
+    vaddr pc;
 
     /*
      * Target-specific data associated with the TranslationBlock, e.g.:
@@ -525,7 +525,7 @@  struct TranslationBlock {
      * s390x: instruction data for EXECUTE,
      * sparc: the next pc of the instruction queue (for delay slots).
      */
-    target_ulong cs_base;
+    uint64_t cs_base;
 
     uint32_t flags; /* flags defining in which context the code was generated */
     uint32_t cflags;    /* compile flags */
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 60ca9e229e..1cf4f1fa22 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -297,7 +297,7 @@  static void log_cpu_exec(target_ulong pc, CPUState *cpu,
 {
     if (qemu_log_in_addr_range(pc)) {
         qemu_log_mask(CPU_LOG_EXEC,
-                      "Trace %d: %p [" TARGET_FMT_lx
+                      "Trace %d: %p [%08" PRIx64
                       "/" TARGET_FMT_lx "/%08x/%08x] %s\n",
                       cpu->cpu_index, tb->tc.ptr, tb->cs_base, pc,
                       tb->flags, tb->cflags, lookup_symbol(pc));