Skip to contentSkip to conversation

target/s390x: Prohibit target_ulong and TARGET_PAGE_SIZE uses

PATCH Superseded Philippe Mathieu-Daudé 3 participants 42 messages Jan 7 – Feb 5 Arm/Amlogic Meson SoC support

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover target/s390x: Prohibit target_ulong and TARGET_PAGE_SIZE uses

- Restrict WatchPoint API to TCG
- Replace target_ulong uses by vaddr / hwaddr / uint64_t
- Remove the single TARGET_PAGE_SIZE
- Remove CONFIG_KVM from headers
- Compiles objects as target_common_system_arch, effectively forbidding further target_ulong / TARGET_PAGE_SIZE uses.

Philippe Mathieu-Daudé (18):
target/s390x: Restrict WatchPoint API to TCG
target/s390x: Use address_space_ldl_be() in read_table_entry() target/s390x: Use vaddr for $pc in get_next_pc() target/s390x: Replace target_ulong -> uint64_t in gdb_write_register() target/s390x: Remove unused 'gdbstub/helpers.h' header in helper.c target/s390x: Replace target_ulong -> hwaddr in get_phys_page_debug() target/s390x: Pass vaddr/hwaddr types to mmu_translate_asce() target/s390x: Use hwaddr in mmu_real2abs()
target/s390x: Pass hwaddr to mmu_handle_skey() target/s390x: Replace target_ulong -> vaddr in get_phys_addr_debug() target/s390x: Use hwaddr in translate_pages() target/s390x: Pass vaddr/hwaddr types to mmu_translate*() target/s390x: Introduce CHSC_MAX_REQ_LEN definition target/s390x: Simplify S390_ADAPTER_SUPPRESSIBLE definition target/s390x: Un-inline s390_is_pv()
target/s390x: Un-inline KVM Protected Virtualization stubs target/s390x: Add more unreachable KVM stubs
target/s390x: Build system units in common source set

 include/hw/s390x/css.h         |   2 +
 target/s390x/cpu.h             |   6 --
 target/s390x/kvm/pv.h          |  51 +---------
 target/s390x/s390x-internal.h  |  16 ++--
 target/s390x/tcg/tcg_s390x.h   |   5 +
 target/s390x/cpu.c             |  30 +++---
 target/s390x/gdbstub.c         |   2 +-
 target/s390x/helper.c          |  49 +---------
 target/s390x/ioinst.c          |   5 +-
 target/s390x/kvm/kvm.c         |   2 +
 target/s390x/kvm/pv.c          |  18 ++++
 target/s390x/kvm/stubs.c       | 170 ++++++++++++++++++++++++++++++++-
 target/s390x/mmu_helper.c      |  33 +++----
 target/s390x/tcg/debug.c       |  85 +++++++++++++++++
 target/s390x/tcg/excp_helper.c |  35 +------
 target/s390x/tcg/translate.c   |   5 +-
 target/s390x/meson.build       |   5 +-
 target/s390x/tcg/meson.build   |   3 +
 18 files changed, 340 insertions(+), 182 deletions(-)
 create mode 100644 target/s390x/tcg/debug.c
Signature · 1 line
2.52.0
#1 lore raw

PATCH 1/18 target/s390x: Restrict WatchPoint API to TCG

By inverting the 'tcg_enabled()' check in s390_cpu_set_psw() we can let the compiler elide the s390_cpu_recompute_watchpoints() call when TCG is not available. Move this function -- along with s390x_cpu_debug_excp_handler() which was introduced in the same commit 311918b979c ("target-s390x: PER storage-alteration event support") -- to a TCG specific file to avoid compiling dead code on KVM. This restricts the WatchPoint API calls to TCG.

---
 target/s390x/s390x-internal.h  |  2 -
 target/s390x/tcg/tcg_s390x.h   |  5 ++
 target/s390x/cpu.c             | 30 ++++++------
 target/s390x/helper.c          | 38 ---------------
 target/s390x/tcg/debug.c       | 85 ++++++++++++++++++++++++++++++++++
 target/s390x/tcg/excp_helper.c | 32 -------------
 target/s390x/tcg/meson.build   |  3 ++
 7 files changed, 108 insertions(+), 87 deletions(-)
 create mode 100644 target/s390x/tcg/debug.c
target/s390x/s390x-internal.h +0 -2
index 9691366ec91..a4b54dc441c 100644
@@ -259,7 +259,6 @@ ObjectClass *s390_cpu_class_by_name(const char *name);
 
 
 /* excp_helper.c */
-void s390x_cpu_debug_excp_handler(CPUState *cs);
 void s390_cpu_do_interrupt(CPUState *cpu);
 bool s390_cpu_exec_interrupt(CPUState *cpu, int int_req);
 
@@ -317,7 +316,6 @@ void s390_cpu_gdb_init(CPUState *cs);
 void s390_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
 void do_restart_interrupt(CPUS390XState *env);
 #ifndef CONFIG_USER_ONLY
-void s390_cpu_recompute_watchpoints(CPUState *cs);
 void s390x_tod_timer(void *opaque);
 void s390x_cpu_timer(void *opaque);
 void s390_handle_wait(S390CPU *cpu);
target/s390x/tcg/tcg_s390x.h +5 -0
index 78558912f99..7c8aede80d2 100644
@@ -21,4 +21,9 @@ G_NORETURN void tcg_s390_data_exception(CPUS390XState *env, uint32_t dxc,
 G_NORETURN void tcg_s390_vector_exception(CPUS390XState *env, uint32_t vxc,
                                           uintptr_t ra);
 
+#ifndef CONFIG_USER_ONLY
+void s390_cpu_recompute_watchpoints(CPUState *cs);
+void s390x_cpu_debug_excp_handler(CPUState *cs);
+#endif
+
 #endif /* TCG_S390X_H */
target/s390x/cpu.c +15 -15
index 6c4198eb1b1..f68b288e364 100644
@@ -40,6 +40,7 @@
 #include "system/reset.h"
 #endif
 #include "hw/s390x/cpu-topology.h"
+#include "tcg/tcg_s390x.h"
 
 #define CR0_RESET       0xE0UL
 #define CR14_RESET      0xC2000000UL;
@@ -74,26 +75,25 @@ void s390_cpu_set_psw(CPUS390XState *env, uint64_t mask, uint64_t addr)
     env->psw.mask = mask;
 
     /* KVM will handle all WAITs and trigger a WAIT exit on disabled_wait */
-    if (!tcg_enabled()) {
-        return;
-    }
-    env->cc_op = (mask >> 44) & 3;
+    if (tcg_enabled()) {
+        env->cc_op = (mask >> 44) & 3;
 
 #ifndef CONFIG_USER_ONLY
-    if (is_early_exception_psw(mask, addr)) {
-        env->int_pgm_ilen = 0;
-        trigger_pgm_exception(env, PGM_SPECIFICATION);
-        return;
-    }
+        if (is_early_exception_psw(mask, addr)) {
+            env->int_pgm_ilen = 0;
+            trigger_pgm_exception(env, PGM_SPECIFICATION);
+            return;
+        }
 
-    if ((old_mask ^ mask) & PSW_MASK_PER) {
-        s390_cpu_recompute_watchpoints(env_cpu(env));
-    }
+        if ((old_mask ^ mask) & PSW_MASK_PER) {
+            s390_cpu_recompute_watchpoints(env_cpu(env));
+        }
 
-    if (mask & PSW_MASK_WAIT) {
-        s390_handle_wait(env_archcpu(env));
-    }
+        if (mask & PSW_MASK_WAIT) {
+            s390_handle_wait(env_archcpu(env));
+        }
 #endif
+    }
 }
 
 uint64_t s390_cpu_get_psw_mask(CPUS390XState *env)
target/s390x/helper.c +0 -38
index 184428c6d9d..8d1e03f6768 100644
@@ -143,41 +143,3 @@ void do_restart_interrupt(CPUS390XState *env)
 
     s390_cpu_set_psw(env, mask, addr);
 }
-
-void s390_cpu_recompute_watchpoints(CPUState *cs)
-{
-    const int wp_flags = BP_CPU | BP_MEM_WRITE | BP_STOP_BEFORE_ACCESS;
-    CPUS390XState *env = cpu_env(cs);
-
-    /* We are called when the watchpoints have changed. First
-       remove them all.  */
-    cpu_watchpoint_remove_all(cs, BP_CPU);
-
-    /* Return if PER is not enabled */
-    if (!(env->psw.mask & PSW_MASK_PER)) {
-        return;
-    }
-
-    /* Return if storage-alteration event is not enabled.  */
-    if (!(env->cregs[9] & PER_CR9_EVENT_STORE)) {
-        return;
-    }
-
-    if (env->cregs[10] == 0 && env->cregs[11] == -1LL) {
-        /* We can't create a watchoint spanning the whole memory range, so
-           split it in two parts.   */
-        cpu_watchpoint_insert(cs, 0, 1ULL << 63, wp_flags, NULL);
-        cpu_watchpoint_insert(cs, 1ULL << 63, 1ULL << 63, wp_flags, NULL);
-    } else if (env->cregs[10] > env->cregs[11]) {
-        /* The address range loops, create two watchpoints.  */
-        cpu_watchpoint_insert(cs, env->cregs[10], -env->cregs[10],
-                              wp_flags, NULL);
-        cpu_watchpoint_insert(cs, 0, env->cregs[11] + 1, wp_flags, NULL);
-
-    } else {
-        /* Default case, create a single watchpoint.  */
-        cpu_watchpoint_insert(cs, env->cregs[10],
-                              env->cregs[11] - env->cregs[10] + 1,
-                              wp_flags, NULL);
-    }
-}
target/s390x/tcg/debug.c new file +85 -0

85 lines not on this page · raw message

target/s390x/tcg/excp_helper.c +0 -32
index d4a096f5998..019eb4fba1f 100644
@@ -24,7 +24,6 @@
 #include "exec/helper-proto.h"
 #include "exec/cputlb.h"
 #include "exec/target_page.h"
-#include "exec/watchpoint.h"
 #include "s390x-internal.h"
 #include "tcg_s390x.h"
 #ifndef CONFIG_USER_ONLY
@@ -607,37 +606,6 @@ bool s390_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
     return false;
 }
 
-void s390x_cpu_debug_excp_handler(CPUState *cs)
-{
-    CPUS390XState *env = cpu_env(cs);
-    CPUWatchpoint *wp_hit = cs->watchpoint_hit;
-
-    if (wp_hit && wp_hit->flags & BP_CPU) {
-        /* FIXME: When the storage-alteration-space control bit is set,
-           the exception should only be triggered if the memory access
-           is done using an address space with the storage-alteration-event
-           bit set.  We have no way to detect that with the current
-           watchpoint code.  */
-        cs->watchpoint_hit = NULL;
-
-        env->per_address = env->psw.addr;
-        env->per_perc_atmid |= PER_CODE_EVENT_STORE | get_per_atmid(env);
-        /* FIXME: We currently no way to detect the address space used
-           to trigger the watchpoint.  For now just consider it is the
-           current default ASC. This turn to be true except when MVCP
-           and MVCS instrutions are not used.  */
-        env->per_perc_atmid |= env->psw.mask & (PSW_MASK_ASC) >> 46;
-
-        /*
-         * Remove all watchpoints to re-execute the code.  A PER exception
-         * will be triggered, it will call s390_cpu_set_psw which will
-         * recompute the watchpoints.
-         */
-        cpu_watchpoint_remove_all(cs, BP_CPU);
-        cpu_loop_exit_noexc(cs);
-    }
-}
-
 void s390x_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
                                    MMUAccessType access_type,
                                    int mmu_idx, uintptr_t retaddr)
target/s390x/tcg/meson.build +3 -0
index ee4e8fec77c..515cb8b473d 100644
@@ -12,3 +12,6 @@ s390x_ss.add(when: 'CONFIG_TCG', if_true: files(
   'vec_int_helper.c',
   'vec_string_helper.c',
 ))
+s390x_system_ss.add(when: 'CONFIG_TCG', if_true: files(
+  'debug.c',
+))
Signature · 1 line
2.52.0
Reviewed-by on v1 1/18
#2 lore raw

Re: [PATCH 01/18] target/s390x: Restrict WatchPoint API to TCG

Quoted 18 lines · Philippe Mathieu-Daudé

By inverting the 'tcg_enabled()' check in s390_cpu_set_psw() we can let the compiler elide the s390_cpu_recompute_watchpoints() call when TCG is not available. Move this function -- along with s390x_cpu_debug_excp_handler() which was introduced in the same commit 311918b979c ("target-s390x: PER storage-alteration event support") -- to a TCG specific file to avoid compiling dead code on KVM. This restricts the WatchPoint API calls to TCG.

---
  target/s390x/s390x-internal.h  |  2 -
  target/s390x/tcg/tcg_s390x.h   |  5 ++
  target/s390x/cpu.c             | 30 ++++++------
  target/s390x/helper.c          | 38 ---------------
  target/s390x/tcg/debug.c       | 85 ++++++++++++++++++++++++++++++++++
  target/s390x/tcg/excp_helper.c | 32 -------------
  target/s390x/tcg/meson.build   |  3 ++
  7 files changed, 108 insertions(+), 87 deletions(-)
Quoted 1 line

create mode 100644 target/s390x/tcg/debug.c

#3 lore raw

PATCH 2/18 target/s390x: Use address_space_ldl_be() in read_table_entry()

In reply to Philippe Mathieu-Daudé

Keep address_space_read/write() API to access blob of memory. When the access size is known, use the address_space_ld/st() API which can directly swap endianness.

---
 target/s390x/mmu_helper.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
target/s390x/mmu_helper.c +4 -7
index 026502a3e40..9ee1d778876 100644
@@ -108,6 +108,7 @@ static inline bool read_table_entry(CPUS390XState *env, hwaddr gaddr,
                                     uint64_t *entry)
 {
     CPUState *cs = env_cpu(env);
+    MemTxResult ret;
 
     /*
      * According to the PoP, these table addresses are "unpredictably real
@@ -116,13 +117,9 @@ static inline bool read_table_entry(CPUS390XState *env, hwaddr gaddr,
      *
      * We treat them as absolute addresses and don't wrap them.
      */
-    if (unlikely(address_space_read(cs->as, gaddr, MEMTXATTRS_UNSPECIFIED,
-                                    entry, sizeof(*entry)) !=
-                 MEMTX_OK)) {
-        return false;
-    }
-    *entry = be64_to_cpu(*entry);
-    return true;
+    *entry = address_space_ldl_be(cs->as, gaddr, MEMTXATTRS_UNSPECIFIED, &ret);
+
+    return ret == MEMTX_OK;
 }
 
 static int mmu_translate_asce(CPUS390XState *env, target_ulong vaddr,
Signature · 1 line
2.52.0
Reviewed-by on v1 2/18
#4 lore raw

Re: [PATCH 02/18] target/s390x: Use address_space_ldl_be() in read_table_entry()

Quoted 1 line · Philippe Mathieu-Daudé

Keep address_space_read/write() API to access blob of memory.

Maybe rather: "address_space_read/write() is meant for accessing random amount of memory blobs"? ... the "Keep" initially confused me here, since you don't keep it in this patch.

Quoted 7 lines

When the access size is known, use the address_space_ld/st() API which can directly swap endianness.

---
  target/s390x/mmu_helper.c | 11 ++++-------
  1 file changed, 4 insertions(+), 7 deletions(-)

Anyway:

#5 lore raw

Re: [PATCH 02/18] target/s390x: Use address_space_ldl_be() in read_table_entry()

In reply to Philippe Mathieu-Daudé
Quoted 26 lines · Philippe Mathieu-Daudé

Keep address_space_read/write() API to access blob of memory. When the access size is known, use the address_space_ld/st() API which can directly swap endianness.

---
  target/s390x/mmu_helper.c | 11 ++++-------
  1 file changed, 4 insertions(+), 7 deletions(-)
target/s390x/mmu_helper.c +1 -1
index 026502a3e40..9ee1d778876 100644
@@ -108,6 +108,7 @@ static inline bool read_table_entry(CPUS390XState *env, hwaddr gaddr,
                                      uint64_t *entry)
  {
      CPUState *cs = env_cpu(env);
+    MemTxResult ret;
 
      /*
       * According to the PoP, these table addresses are "unpredictably real
@@ -116,13 +117,9 @@ static inline bool read_table_entry(CPUS390XState *env, hwaddr gaddr,
       *
       * We treat them as absolute addresses and don't wrap them.
       */
-    if (unlikely(address_space_read(cs->as, gaddr, MEMTXATTRS_UNSPECIFIED,

target/s390x/mmu_helper.c static inline bool read_table_entry(CPUS390XState *env, hwaddr gaddr, · line 123

Quoted 10 lines
target/s390x/mmu_helper.c +3 -6
-                                    entry, sizeof(*entry)) !=
-                 MEMTX_OK)) {
-        return false;
-    }
-    *entry = be64_to_cpu(*entry);
-    return true;
+    *entry = address_space_ldl_be(cs->as, gaddr, MEMTXATTRS_UNSPECIFIED, &ret);
+
+    return ret == MEMTX_OK;
  }

Hi Philippe,

this patch seems to break "make check-functional-s390x" ... looks like there is a bug somewhere, please have a look!

Thanks,
Thomas

#6 lore raw

Re: [PATCH 02/18] target/s390x: Use address_space_ldl_be() in read_table_entry()

Quoted 43 lines · Thomas Huth
Quoted 38 lines · Philippe Mathieu-Daudé

Keep address_space_read/write() API to access blob of memory. When the access size is known, use the address_space_ld/st() API which can directly swap endianness.

---
  target/s390x/mmu_helper.c | 11 ++++-------

  1 file changed, 4 insertions(+), 7 deletions(-)
target/s390x/mmu_helper.c +4 -7
index 026502a3e40..9ee1d778876 100644
@@ -108,6 +108,7 @@ static inline bool read_table_entry(CPUS390XState 
 *env, hwaddr gaddr,
                                       uint64_t *entry)
   {
       CPUState *cs = env_cpu(env);
+    MemTxResult ret;
       /*
        * According to the PoP, these table addresses are "unpredictably real
@@ -116,13 +117,9 @@ static inline bool read_table_entry(CPUS390XState 
 *env, hwaddr gaddr,
        *
        * We treat them as absolute addresses and don't wrap them.
        */
-    if (unlikely(address_space_read(cs->as, gaddr, 
 MEMTXATTRS_UNSPECIFIED,
-                                    entry, sizeof(*entry)) !=
-                 MEMTX_OK)) {
-        return false;
-    }
-    *entry = be64_to_cpu(*entry);
-    return true;
+    *entry = address_space_ldl_be(cs->as, gaddr, 
 MEMTXATTRS_UNSPECIFIED, &ret);
+
+    return ret == MEMTX_OK;
Quoted 1 line

  }

 Hi Philippe,

Quoted 1 line

this patch seems to break "make check-functional-s390x" ... looks like there is a bug somewhere, please have a look!

Oops, address_space_ldQ_be.

#7 lore raw

PATCH 3/18 target/s390x: Use vaddr for $pc in get_next_pc()

In reply to Philippe Mathieu-Daudé

DisasContextBase::pc_next is of vaddr type.
Since translator_lduw_end() returns a uint16_t,
also use that type for clarity.

---
 target/s390x/tcg/translate.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
target/s390x/tcg/translate.c +2 -3
index e38607ee18c..540c5a569c0 100644
@@ -6405,10 +6405,9 @@ static void s390x_tr_insn_start(DisasContextBase *dcbase, CPUState *cs)
     tcg_gen_insn_start(dc->base.pc_next, dc->cc_op, 0);
 }
 
-static target_ulong get_next_pc(CPUS390XState *env, DisasContext *s,
-                                uint64_t pc)
+static vaddr get_next_pc(CPUS390XState *env, DisasContext *s, vaddr pc)
 {
-    uint64_t insn = translator_lduw_end(env, &s->base, pc, MO_BE);
+    uint16_t insn = translator_lduw_end(env, &s->base, pc, MO_BE);
 
     return pc + get_ilen((insn >> 8) & 0xff);
 }
Signature · 1 line
2.52.0
Reviewed-by on v1 3/18
#8 lore raw

Re: [PATCH 03/18] target/s390x: Use vaddr for $pc in get_next_pc()

Quoted 16 lines · Philippe Mathieu-Daudé

DisasContextBase::pc_next is of vaddr type.
Since translator_lduw_end() returns a uint16_t,
also use that type for clarity.

---
  target/s390x/tcg/translate.c | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)
target/s390x/tcg/translate.c +0 -0
index e38607ee18c..540c5a569c0 100644
@@ -6405,10 +6405,9 @@ static void s390x_tr_insn_start(DisasContextBase *dcbase, CPUState *cs)
      tcg_gen_insn_start(dc->base.pc_next, dc->cc_op, 0);
  }

target/s390x/tcg/translate.c static void s390x_tr_insn_start(DisasContextBase *dcbase, CPUState *cs) · line 6413

Quoted 10 lines
target/s390x/tcg/translate.c +2 -3
 
-static target_ulong get_next_pc(CPUS390XState *env, DisasContext *s,
-                                uint64_t pc)
+static vaddr get_next_pc(CPUS390XState *env, DisasContext *s, vaddr pc)
  {
-    uint64_t insn = translator_lduw_end(env, &s->base, pc, MO_BE);
+    uint16_t insn = translator_lduw_end(env, &s->base, pc, MO_BE);
 
      return pc + get_ilen((insn >> 8) & 0xff);
  }
#9 lore raw

PATCH 4/18 target/s390x: Replace target_ulong -> uint64_t in gdb_write_register()

In reply to Philippe Mathieu-Daudé

On s390x target_ulong expands to uint64_t. Besides, ldq_be_p() returns a uint64_t type. Use that instead.

---
 target/s390x/gdbstub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/s390x/gdbstub.c +1 -1
index d1f02ea5ce4..9ae715add4d 100644
@@ -46,7 +46,7 @@ int s390_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
 int s390_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
 {
     CPUS390XState *env = cpu_env(cs);
-    target_ulong tmpl = ldq_be_p(mem_buf);
+    uint64_t tmpl = ldq_be_p(mem_buf);
 
     switch (n) {
     case S390_PSWM_REGNUM:
Signature · 1 line
2.52.0
Reviewed-by on v1 4/18
#10 lore raw

Re: [PATCH 04/18] target/s390x: Replace target_ulong -> uint64_t in gdb_write_register()

Quoted 13 lines · Philippe Mathieu-Daudé

On s390x target_ulong expands to uint64_t. Besides, ldq_be_p() returns a uint64_t type. Use that instead.

---
  target/s390x/gdbstub.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
target/s390x/gdbstub.c +0 -0
index d1f02ea5ce4..9ae715add4d 100644

target/s390x/gdbstub.c int s390_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) · line 52

Quoted 8 lines
target/s390x/gdbstub.c +1 -1
@@ -46,7 +46,7 @@ int s390_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
  int s390_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
  {
      CPUS390XState *env = cpu_env(cs);
-    target_ulong tmpl = ldq_be_p(mem_buf);
+    uint64_t tmpl = ldq_be_p(mem_buf);
 
      switch (n) {
      case S390_PSWM_REGNUM:
#11 lore raw

PATCH 5/18 target/s390x: Remove unused 'gdbstub/helpers.h' header in helper.c

In reply to Philippe Mathieu-Daudé
---
 target/s390x/helper.c | 1 -
 1 file changed, 1 deletion(-)
target/s390x/helper.c +0 -1
index 8d1e03f6768..a6c89ed0af3 100644
@@ -21,7 +21,6 @@
 #include "qemu/osdep.h"
 #include "cpu.h"
 #include "s390x-internal.h"
-#include "gdbstub/helpers.h"
 #include "qemu/timer.h"
 #include "hw/s390x/ioinst.h"
 #include "system/hw_accel.h"
Signature · 1 line
2.52.0
#12 lore raw

Re: [PATCH 05/18] target/s390x: Remove unused 'gdbstub/helpers.h' header in helper.c

On 7/1/26 14:07, Philippe Mathieu-Daudé wrote:

Updated description:

"gdbstub/helpers.h" uses target-specific symbols, but we don't need it, so remove it.

Quoted 17 lines
---
  target/s390x/helper.c | 1 -
  1 file changed, 1 deletion(-)
target/s390x/helper.c +0 -1
index 8d1e03f6768..a6c89ed0af3 100644
@@ -21,7 +21,6 @@
  #include "qemu/osdep.h"
  #include "cpu.h"
  #include "s390x-internal.h"
-#include "gdbstub/helpers.h"
  #include "qemu/timer.h"
  #include "hw/s390x/ioinst.h"
  #include "system/hw_accel.h"
Reviewed-by
#13 lore raw

Re: [PATCH 05/18] target/s390x: Remove unused 'gdbstub/helpers.h' header in helper.c

Quoted 12 lines · Philippe Mathieu-Daudé

On 7/1/26 14:07, Philippe Mathieu-Daudé wrote:

Updated description:

    "gdbstub/helpers.h" uses target-specific symbols, but we don't need it, so remove it.

Quoted 5 lines

---
  target/s390x/helper.c | 1 -

  1 file changed, 1 deletion(-)
Quoted 13 lines

target/s390x/helper.c line 26

Quoted 12 lines
target/s390x/helper.c +0 -1
index 8d1e03f6768..a6c89ed0af3 100644
@@ -21,7 +21,6 @@
   #include "qemu/osdep.h"
   #include "cpu.h"
   #include "s390x-internal.h"
-#include "gdbstub/helpers.h"
   #include "qemu/timer.h"
   #include "hw/s390x/ioinst.h"
   #include "system/hw_accel.h"

r~

Tested-by on v1 5/18
#14 lore raw

Re: [PATCH 05/18] target/s390x: Remove unused 'gdbstub/helpers.h' header in helper.c

In reply to Philippe Mathieu-Daudé
Quoted 10 lines · Philippe Mathieu-Daudé
---
  target/s390x/helper.c | 1 -
  1 file changed, 1 deletion(-)
target/s390x/helper.c +0 -0
index 8d1e03f6768..a6c89ed0af3 100644

target/s390x/helper.c line 26

Quoted 7 lines
target/s390x/helper.c +0 -1
@@ -21,7 +21,6 @@
  #include "qemu/osdep.h"
  #include "cpu.h"
  #include "s390x-internal.h"
-#include "gdbstub/helpers.h"
  #include "qemu/timer.h"
  #include "hw/s390x/ioinst.h"
  #include "system/hw_accel.h"
#15 lore raw

PATCH 6/18 target/s390x: Replace target_ulong -> hwaddr in get_phys_page_debug()

In reply to Philippe Mathieu-Daudé

mmu_translate() fills a hwaddr type.

---
 target/s390x/helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/s390x/helper.c +1 -1
index a6c89ed0af3..59e1fd0c4fe 100644
@@ -43,7 +43,7 @@ hwaddr s390_cpu_get_phys_page_debug(CPUState *cs, vaddr vaddr)
 {
     S390CPU *cpu = S390_CPU(cs);
     CPUS390XState *env = &cpu->env;
-    target_ulong raddr;
+    hwaddr raddr;
     int prot;
     uint64_t asc = env->psw.mask & PSW_MASK_ASC;
     uint64_t tec;
Signature · 1 line
2.52.0
#16 lore raw

Re: [PATCH 06/18] target/s390x: Replace target_ulong -> hwaddr in get_phys_page_debug()

Quoted 1 line · Philippe Mathieu-Daudé

mmu_translate() fills a hwaddr type.

Does this depend on another patch series again? Currently mmu_translate is still defined like this:

int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc,
target_ulong *raddr, int *flags, uint64_t *tec)

i.e. the "raddr" parameter is still a target_ulong pointer.

Thomas

Quoted 18 lines
---
  target/s390x/helper.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
target/s390x/helper.c +1 -1
index a6c89ed0af3..59e1fd0c4fe 100644
@@ -43,7 +43,7 @@ hwaddr s390_cpu_get_phys_page_debug(CPUState *cs, vaddr vaddr)
  {
      S390CPU *cpu = S390_CPU(cs);
      CPUS390XState *env = &cpu->env;
-    target_ulong raddr;
+    hwaddr raddr;
      int prot;
      uint64_t asc = env->psw.mask & PSW_MASK_ASC;
      uint64_t tec;
#17 lore raw

Re: [PATCH 06/18] target/s390x: Replace target_ulong -> hwaddr in get_phys_page_debug()

Quoted 4 lines · Thomas Huth
Quoted 1 line · Philippe Mathieu-Daudé

mmu_translate() fills a hwaddr type.

Does this depend on another patch series again?

I was not expecting dependencies but indeed I'm based on top of a branch of 272 patches waiting to be merged, so I might have missed something.

Quoted 6 lines

Currently mmu_translate is still defined like this:

int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc,
                  target_ulong *raddr, int *flags, uint64_t *tec)

i.e. the "raddr" parameter is still a target_ulong pointer.

I tried to arrange patches for incremental changes and bisectability, but might have failed. That'll be simpler with your "change all of these in mmu_helper.c in one go." suggestion from next patch.

Quoted 24 lines

 Thomas

Quoted 19 lines

---
  target/s390x/helper.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
target/s390x/helper.c +1 -1
index a6c89ed0af3..59e1fd0c4fe 100644
@@ -43,7 +43,7 @@ hwaddr s390_cpu_get_phys_page_debug(CPUState *cs, 
 vaddr vaddr)
   {
       S390CPU *cpu = S390_CPU(cs);
       CPUS390XState *env = &cpu->env;
-    target_ulong raddr;
+    hwaddr raddr;
       int prot;
       uint64_t asc = env->psw.mask & PSW_MASK_ASC;

      uint64_t tec;

#18 lore raw

PATCH 7/18 target/s390x: Pass vaddr/hwaddr types to mmu_translate_asce()

In reply to Philippe Mathieu-Daudé

mmu_translate_asce() translates virtual address to physical one.

---
 target/s390x/mmu_helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/s390x/mmu_helper.c +2 -2
index 9ee1d778876..ccb53e99ebd 100644
@@ -122,8 +122,8 @@ static inline bool read_table_entry(CPUS390XState *env, hwaddr gaddr,
     return ret == MEMTX_OK;
 }
 
-static int mmu_translate_asce(CPUS390XState *env, target_ulong vaddr,
-                              uint64_t asc, uint64_t asce, target_ulong *raddr,
+static int mmu_translate_asce(CPUS390XState *env, vaddr vaddr,
+                              uint64_t asc, uint64_t asce, hwaddr *raddr,
                               int *flags)
 {
     const bool edat1 = (env->cregs[0] & CR0_EDAT) &&
Signature · 1 line
2.52.0
#19 lore raw

Re: [PATCH 07/18] target/s390x: Pass vaddr/hwaddr types to mmu_translate_asce()

Quoted 12 lines · Philippe Mathieu-Daudé

mmu_translate_asce() translates virtual address to physical one.

---
  target/s390x/mmu_helper.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
target/s390x/mmu_helper.c +0 -0
index 9ee1d778876..ccb53e99ebd 100644

target/s390x/mmu_helper.c static inline bool read_table_entry(CPUS390XState *env, hwaddr gaddr, · line 127

Quoted 8 lines
target/s390x/mmu_helper.c +2 -2
@@ -122,8 +122,8 @@ static inline bool read_table_entry(CPUS390XState *env, hwaddr gaddr,
      return ret == MEMTX_OK;
  }
 
-static int mmu_translate_asce(CPUS390XState *env, target_ulong vaddr,
-                              uint64_t asc, uint64_t asce, target_ulong *raddr,
+static int mmu_translate_asce(CPUS390XState *env, vaddr vaddr,
+                              uint64_t asc, uint64_t asce, hwaddr *raddr,
                                int *flags)

I'm ok with the change to vaddr, but with regards to raddr, I think you should rather change all of these in mmu_helper.c in one go. Otherwise this is a mix of hwaddr pointers and target_ulong pointers while the change is going on, and that is rather bad.

Thomas

#20 lore raw

PATCH 8/18 target/s390x: Use hwaddr in mmu_real2abs()

In reply to Philippe Mathieu-Daudé

On S/390, absolute addresses are physical ones.

Since mmu_real2abs() is defined in mmu_helper.c, move its prototype declaration below the 'mmu_helper.c' comment.

---
 target/s390x/s390x-internal.h | 5 +++--
 target/s390x/mmu_helper.c     | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)
target/s390x/s390x-internal.h +3 -2
index a4b54dc441c..dfc95702c51 100644
@@ -10,6 +10,7 @@
 #ifndef S390X_INTERNAL_H
 #define S390X_INTERNAL_H
 
+#include "exec/hwaddr.h"
 #include "cpu.h"
 #include "fpu/softfloat.h"
 
@@ -367,13 +368,13 @@ void ioinst_handle_sal(S390CPU *cpu, uint64_t reg1, uintptr_t ra);
 
 
 /* mem_helper.c */
-target_ulong mmu_real2abs(CPUS390XState *env, target_ulong raddr);
 void probe_write_access(CPUS390XState *env, uint64_t addr, uint64_t len,
                         uintptr_t ra);
 
 
 /* mmu_helper.c */
-bool mmu_absolute_addr_valid(target_ulong addr, bool is_write);
+hwaddr mmu_real2abs(CPUS390XState *env, hwaddr raddr);
+bool mmu_absolute_addr_valid(hwaddr addr, bool is_write);
 /* Special access mode only valid for mmu_translate() */
 #define MMU_S390_LRA        -1
 int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc,
target/s390x/mmu_helper.c +2 -2
index ccb53e99ebd..b73d902b05a 100644
@@ -86,7 +86,7 @@ static bool lowprot_enabled(const CPUS390XState *env, uint64_t asc)
  * Translate real address to absolute (= physical)
  * address by taking care of the prefix mapping.
  */
-target_ulong mmu_real2abs(CPUS390XState *env, target_ulong raddr)
+hwaddr mmu_real2abs(CPUS390XState *env, hwaddr raddr)
 {
     if (raddr < 0x2000) {
         return raddr + env->psa;    /* Map the lowcore. */
@@ -96,7 +96,7 @@ target_ulong mmu_real2abs(CPUS390XState *env, target_ulong raddr)
     return raddr;
 }
 
-bool mmu_absolute_addr_valid(target_ulong addr, bool is_write)
+bool mmu_absolute_addr_valid(hwaddr addr, bool is_write)
 {
     return address_space_access_valid(&address_space_memory,
                                       addr & TARGET_PAGE_MASK,
Signature · 1 line
2.52.0
#21 lore raw

PATCH 9/18 target/s390x: Pass hwaddr to mmu_handle_skey()

In reply to Philippe Mathieu-Daudé

mmu_handle_skey() takes a physical address, then aligns it to the page size to pass a guest physical page number to the methods defined in "hw/s390x/storage-keys.h" API.

---
 target/s390x/mmu_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/s390x/mmu_helper.c +1 -1
index b73d902b05a..5a613b33150 100644
@@ -296,7 +296,7 @@ static int mmu_translate_asce(CPUS390XState *env, vaddr vaddr,
     return 0;
 }
 
-static void mmu_handle_skey(target_ulong addr, int rw, int *flags)
+static void mmu_handle_skey(hwaddr addr, int rw, int *flags)
 {
     static S390SKeysClass *skeyclass;
     static S390SKeysState *ss;
Signature · 1 line
2.52.0
#22 lore raw

PATCH 10/18 target/s390x: Replace target_ulong -> vaddr in get_phys_addr_debug()

In reply to Philippe Mathieu-Daudé

cpu_get_phys_page_debug() takes a vaddr argument. Rename the @vaddr argument to avoid confusing the compiler.

---
 target/s390x/helper.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
target/s390x/helper.c +4 -4
index 59e1fd0c4fe..f124b16d1b3 100644
@@ -68,14 +68,14 @@ hwaddr s390_cpu_get_phys_page_debug(CPUState *cs, vaddr vaddr)
     return raddr;
 }
 
-hwaddr s390_cpu_get_phys_addr_debug(CPUState *cs, vaddr vaddr)
+hwaddr s390_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
 {
     hwaddr phys_addr;
-    target_ulong page;
+    vaddr page;
 
-    page = vaddr & TARGET_PAGE_MASK;
+    page = addr & TARGET_PAGE_MASK;
     phys_addr = cpu_get_phys_page_debug(cs, page);
-    phys_addr += (vaddr & ~TARGET_PAGE_MASK);
+    phys_addr += (addr & ~TARGET_PAGE_MASK);
 
     return phys_addr;
 }
Signature · 1 line
2.52.0
#23 lore raw

Re: [PATCH 10/18] target/s390x: Replace target_ulong -> vaddr in get_phys_addr_debug()

Quoted 13 lines · Philippe Mathieu-Daudé

cpu_get_phys_page_debug() takes a vaddr argument. Rename the @vaddr argument to avoid confusing the compiler.

---
  target/s390x/helper.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
target/s390x/helper.c +0 -0
index 59e1fd0c4fe..f124b16d1b3 100644

target/s390x/helper.c hwaddr s390_cpu_get_phys_page_debug(CPUState *cs, vaddr vaddr) · line 71

Quoted 5 lines
target/s390x/helper.c +1 -1
@@ -68,14 +68,14 @@ hwaddr s390_cpu_get_phys_page_debug(CPUState *cs, vaddr vaddr)
      return raddr;
  }
 
-hwaddr s390_cpu_get_phys_addr_debug(CPUState *cs, vaddr vaddr)
+hwaddr s390_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)

I'd maybe rather go with "v_addr" or "virt_addr" to avoid confusion with physical addresses here.

Thomas

#24 lore raw

PATCH 11/18 target/s390x: Use hwaddr in translate_pages()

In reply to Philippe Mathieu-Daudé

translate_pages() returns absolute addresses, which are physcal ones.

---
 target/s390x/mmu_helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/s390x/mmu_helper.c +2 -2
index 5a613b33150..abf8da28ea5 100644
@@ -472,7 +472,7 @@ nodat:
  * the MEMOP interface.
  */
 static int translate_pages(S390CPU *cpu, vaddr addr, int nr_pages,
-                           target_ulong *pages, bool is_write, uint64_t *tec)
+                           hwaddr *pages, bool is_write, uint64_t *tec)
 {
     uint64_t asc = cpu->env.psw.mask & PSW_MASK_ASC;
     CPUS390XState *env = &cpu->env;
@@ -523,7 +523,7 @@ int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, uint8_t ar, void *hostbuf,
 {
     const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED;
     int currlen, nr_pages, i;
-    target_ulong *pages;
+    hwaddr *pages;
     uint64_t tec;
     int ret;
 
Signature · 1 line
2.52.0
#25 lore raw

PATCH 12/18 target/s390x: Pass vaddr/hwaddr types to mmu_translate*()

In reply to Philippe Mathieu-Daudé

mmu_translate() and mmu_translate_real() translate virtual addresses to physical ones.

---
 target/s390x/s390x-internal.h  | 9 +++++----
 target/s390x/mmu_helper.c      | 8 ++++----
 target/s390x/tcg/excp_helper.c | 3 ++-
 3 files changed, 11 insertions(+), 9 deletions(-)
target/s390x/s390x-internal.h +5 -4
index dfc95702c51..790cd688762 100644
@@ -11,6 +11,7 @@
 #define S390X_INTERNAL_H
 
 #include "exec/hwaddr.h"
+#include "exec/vaddr.h"
 #include "cpu.h"
 #include "fpu/softfloat.h"
 
@@ -377,10 +378,10 @@ hwaddr mmu_real2abs(CPUS390XState *env, hwaddr raddr);
 bool mmu_absolute_addr_valid(hwaddr addr, bool is_write);
 /* Special access mode only valid for mmu_translate() */
 #define MMU_S390_LRA        -1
-int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc,
-                  target_ulong *raddr, int *flags, uint64_t *tec);
-int mmu_translate_real(CPUS390XState *env, target_ulong raddr, int rw,
-                       target_ulong *addr, int *flags, uint64_t *tec);
+int mmu_translate(CPUS390XState *env, vaddr vaddr, int rw, uint64_t asc,
+                  hwaddr *raddr, int *flags, uint64_t *tec);
+int mmu_translate_real(CPUS390XState *env, vaddr raddr, int rw,
+                       hwaddr *addr, int *flags, uint64_t *tec);
 
 
 /* misc_helper.c */
target/s390x/mmu_helper.c +4 -4
index abf8da28ea5..9295a9d8dae 100644
@@ -381,8 +381,8 @@ static void mmu_handle_skey(hwaddr addr, int rw, int *flags)
  *               there is an exception to raise
  * @return       0 = success, != 0, the exception to raise
  */
-int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc,
-                  target_ulong *raddr, int *flags, uint64_t *tec)
+int mmu_translate(CPUS390XState *env, vaddr vaddr, int rw, uint64_t asc,
+                  hwaddr *raddr, int *flags, uint64_t *tec)
 {
     uint64_t asce;
     int r;
@@ -584,8 +584,8 @@ void s390_cpu_virt_mem_handle_exc(S390CPU *cpu, uintptr_t ra)
  * @param flags  the PAGE_READ/WRITE/EXEC flags are stored to this pointer
  * @return       0 = success, != 0, the exception to raise
  */
-int mmu_translate_real(CPUS390XState *env, target_ulong raddr, int rw,
-                       target_ulong *addr, int *flags, uint64_t *tec)
+int mmu_translate_real(CPUS390XState *env, vaddr raddr, int rw,
+                       hwaddr *addr, int *flags, uint64_t *tec)
 {
     const bool lowprot_enabled = env->cregs[0] & CR0_LOWPROT;
 
target/s390x/tcg/excp_helper.c +2 -1
index 019eb4fba1f..41b0017d767 100644
@@ -147,7 +147,8 @@ bool s390_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
                        bool probe, uintptr_t retaddr)
 {
     CPUS390XState *env = cpu_env(cs);
-    target_ulong vaddr, raddr;
+    vaddr vaddr;
+    hwaddr raddr;
     uint64_t asc, tec;
     int prot, excp;
 
Signature · 1 line
2.52.0
#26 lore raw

PATCH 13/18 target/s390x: Introduce CHSC_MAX_REQ_LEN definition

In reply to Philippe Mathieu-Daudé

Since commit 166f1bb7968 ("s390x/ioinst: Rework memory access in CHSC instruction") the access is no more tied to the page size. Define CHSC_MAX_REQ_LEN to better express the relation with the length of the Channel Subsystem Call request.

---
 target/s390x/ioinst.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
target/s390x/ioinst.c +3 -2
index 2320dd4c122..d07773d14a3 100644
@@ -398,6 +398,7 @@ typedef struct ChscResp {
     char data[];
 } QEMU_PACKED ChscResp;
 
+#define CHSC_MAX_REQ_LEN  0x1000
 #define CHSC_MIN_RESP_LEN 0x0008
 
 #define CHSC_SCPD 0x0002
@@ -660,7 +661,7 @@ void ioinst_handle_chsc(S390CPU *cpu, uint32_t ipb, uintptr_t ra)
     uint16_t len;
     uint16_t command;
     CPUS390XState *env = &cpu->env;
-    uint8_t buf[TARGET_PAGE_SIZE];
+    uint8_t buf[CHSC_MAX_REQ_LEN];
 
     trace_ioinst("chsc");
     reg = (ipb >> 20) & 0x00f;
@@ -690,7 +691,7 @@ void ioinst_handle_chsc(S390CPU *cpu, uint32_t ipb, uintptr_t ra)
         s390_program_interrupt(env, PGM_OPERAND, ra);
         return;
     }
-    memset((char *)req + len, 0, TARGET_PAGE_SIZE - len);
+    memset((char *)req + len, 0, CHSC_MAX_REQ_LEN - len);
     res = (void *)((char *)req + len);
     command = be16_to_cpu(req->command);
     trace_ioinst_chsc_cmd(command, len);
Signature · 1 line
2.52.0
#27 lore raw

Re: [PATCH 13/18] target/s390x: Introduce CHSC_MAX_REQ_LEN definition

Quoted 32 lines · Philippe Mathieu-Daudé

Since commit 166f1bb7968 ("s390x/ioinst: Rework memory access in CHSC instruction") the access is no more tied to the page size. Define CHSC_MAX_REQ_LEN to better express the relation with the length of the Channel Subsystem Call request.

---
  target/s390x/ioinst.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
target/s390x/ioinst.c +2 -1
index 2320dd4c122..d07773d14a3 100644
@@ -398,6 +398,7 @@ typedef struct ChscResp {
      char data[];
  } QEMU_PACKED ChscResp;
 
+#define CHSC_MAX_REQ_LEN  0x1000
  #define CHSC_MIN_RESP_LEN 0x0008
 
  #define CHSC_SCPD 0x0002
@@ -660,7 +661,7 @@ void ioinst_handle_chsc(S390CPU *cpu, uint32_t ipb, uintptr_t ra)
      uint16_t len;
      uint16_t command;
      CPUS390XState *env = &cpu->env;
-    uint8_t buf[TARGET_PAGE_SIZE];
+    uint8_t buf[CHSC_MAX_REQ_LEN];
 
      trace_ioinst("chsc");
      reg = (ipb >> 20) & 0x00f;

target/s390x/ioinst.c void ioinst_handle_chsc(S390CPU *cpu, uint32_t ipb, uintptr_t ra) · line 697

Quoted 8 lines
target/s390x/ioinst.c +1 -1
@@ -690,7 +691,7 @@ void ioinst_handle_chsc(S390CPU *cpu, uint32_t ipb, uintptr_t ra)
          s390_program_interrupt(env, PGM_OPERAND, ra);
          return;
      }
-    memset((char *)req + len, 0, TARGET_PAGE_SIZE - len);
+    memset((char *)req + len, 0, CHSC_MAX_REQ_LEN - len);
      res = (void *)((char *)req + len);
      command = be16_to_cpu(req->command);
      trace_ioinst_chsc_cmd(command, len);

Sorry, I don't quite get it, there are still dozends of others TARGET_PAGE_SIZE usages in target/s390x/, what's the advantage of removing that one here?

Thomas

#28 lore raw

Re: [PATCH 13/18] target/s390x: Introduce CHSC_MAX_REQ_LEN definition

Quoted 34 lines · Thomas Huth
Quoted 33 lines · Philippe Mathieu-Daudé

Since commit 166f1bb7968 ("s390x/ioinst: Rework memory access in CHSC instruction") the access is no more tied to the page size. Define CHSC_MAX_REQ_LEN to better express the relation with the length of the Channel Subsystem Call request.

---
  target/s390x/ioinst.c | 5 +++--

  1 file changed, 3 insertions(+), 2 deletions(-)
target/s390x/ioinst.c +2 -1
index 2320dd4c122..d07773d14a3 100644
@@ -398,6 +398,7 @@ typedef struct ChscResp {
       char data[];
   } QEMU_PACKED ChscResp;
+#define CHSC_MAX_REQ_LEN  0x1000
   #define CHSC_MIN_RESP_LEN 0x0008
   #define CHSC_SCPD 0x0002
@@ -660,7 +661,7 @@ void ioinst_handle_chsc(S390CPU *cpu, uint32_t 
 ipb, uintptr_t ra)
       uint16_t len;
       uint16_t command;
       CPUS390XState *env = &cpu->env;
-    uint8_t buf[TARGET_PAGE_SIZE];
+    uint8_t buf[CHSC_MAX_REQ_LEN];
       trace_ioinst("chsc");
       reg = (ipb >> 20) & 0x00f;
@@ -690,7 +691,7 @@ void ioinst_handle_chsc(S390CPU *cpu, uint32_t 
 ipb, uintptr_t ra)
           s390_program_interrupt(env, PGM_OPERAND, ra);
           return;
Quoted 8 lines
Quoted 6 lines
target/s390x/ioinst.c +1 -1
       }
-    memset((char *)req + len, 0, TARGET_PAGE_SIZE - len);
+    memset((char *)req + len, 0, CHSC_MAX_REQ_LEN - len);
       res = (void *)((char *)req + len);
       command = be16_to_cpu(req->command);

      trace_ioinst_chsc_cmd(command, len);

Sorry, I don't quite get it, there are still dozends of others TARGET_PAGE_SIZE usages in target/s390x/, what's the advantage of removing that one here?

The other ones are also used by user emulation so need more care. This series addresses all system-only files. I neglected to mention that in the cover :(

But if you think this is better to review all target/s390x/ conversion in one go, I can wait until I finish the rest.

#29 lore raw

Re: [PATCH 13/18] target/s390x: Introduce CHSC_MAX_REQ_LEN definition

Quoted 35 lines · Philippe Mathieu-Daudé
Quoted 34 lines · Thomas Huth
Quoted 33 lines · Philippe Mathieu-Daudé

Since commit 166f1bb7968 ("s390x/ioinst: Rework memory access in CHSC instruction") the access is no more tied to the page size. Define CHSC_MAX_REQ_LEN to better express the relation with the length of the Channel Subsystem Call request.

---
  target/s390x/ioinst.c | 5 +++--

  1 file changed, 3 insertions(+), 2 deletions(-)
target/s390x/ioinst.c +2 -1
index 2320dd4c122..d07773d14a3 100644
@@ -398,6 +398,7 @@ typedef struct ChscResp {
       char data[];
   } QEMU_PACKED ChscResp;
+#define CHSC_MAX_REQ_LEN  0x1000
   #define CHSC_MIN_RESP_LEN 0x0008
   #define CHSC_SCPD 0x0002
@@ -660,7 +661,7 @@ void ioinst_handle_chsc(S390CPU *cpu, uint32_t 
 ipb, uintptr_t ra)
       uint16_t len;
       uint16_t command;
       CPUS390XState *env = &cpu->env;
-    uint8_t buf[TARGET_PAGE_SIZE];
+    uint8_t buf[CHSC_MAX_REQ_LEN];
       trace_ioinst("chsc");
       reg = (ipb >> 20) & 0x00f;
@@ -690,7 +691,7 @@ void ioinst_handle_chsc(S390CPU *cpu, uint32_t 
 ipb, uintptr_t ra)
           s390_program_interrupt(env, PGM_OPERAND, ra);
           return;
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
target/s390x/ioinst.c +1 -1
       }
-    memset((char *)req + len, 0, TARGET_PAGE_SIZE - len);
+    memset((char *)req + len, 0, CHSC_MAX_REQ_LEN - len);
       res = (void *)((char *)req + len);
       command = be16_to_cpu(req->command);

      trace_ioinst_chsc_cmd(command, len);

Sorry, I don't quite get it, there are still dozends of others TARGET_PAGE_SIZE usages in target/s390x/, what's the advantage of removing that one here?

The other ones are really related to the s390x page size.

This one seems to use TARGET_PAGE_SIZE as an optimization.

Quoted 7 lines

The other ones are also used by user emulation so need more care. This series addresses all system-only files. I neglected to mention that in the cover :(

But if you think this is better to review all target/s390x/ conversion in one go, I can wait until I finish the rest.

#30 lore raw

Re: [PATCH 13/18] target/s390x: Introduce CHSC_MAX_REQ_LEN definition

Quoted 45 lines · Philippe Mathieu-Daudé
Quoted 35 lines · Philippe Mathieu-Daudé
Quoted 34 lines · Thomas Huth
Quoted 33 lines · Philippe Mathieu-Daudé

Since commit 166f1bb7968 ("s390x/ioinst: Rework memory access in CHSC instruction") the access is no more tied to the page size. Define CHSC_MAX_REQ_LEN to better express the relation with the length of the Channel Subsystem Call request.

---
  target/s390x/ioinst.c | 5 +++--

  1 file changed, 3 insertions(+), 2 deletions(-)
target/s390x/ioinst.c +2 -1
index 2320dd4c122..d07773d14a3 100644
@@ -398,6 +398,7 @@ typedef struct ChscResp {
       char data[];
   } QEMU_PACKED ChscResp;
+#define CHSC_MAX_REQ_LEN  0x1000
   #define CHSC_MIN_RESP_LEN 0x0008
   #define CHSC_SCPD 0x0002
@@ -660,7 +661,7 @@ void ioinst_handle_chsc(S390CPU *cpu, uint32_t 
 ipb, uintptr_t ra)
       uint16_t len;
       uint16_t command;
       CPUS390XState *env = &cpu->env;
-    uint8_t buf[TARGET_PAGE_SIZE];
+    uint8_t buf[CHSC_MAX_REQ_LEN];
       trace_ioinst("chsc");
       reg = (ipb >> 20) & 0x00f;
@@ -690,7 +691,7 @@ void ioinst_handle_chsc(S390CPU *cpu, uint32_t 
 ipb, uintptr_t ra)
           s390_program_interrupt(env, PGM_OPERAND, ra);
           return;
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
target/s390x/ioinst.c +1 -1
       }
-    memset((char *)req + len, 0, TARGET_PAGE_SIZE - len);
+    memset((char *)req + len, 0, CHSC_MAX_REQ_LEN - len);
       res = (void *)((char *)req + len);
       command = be16_to_cpu(req->command);

      trace_ioinst_chsc_cmd(command, len);

Sorry, I don't quite get it, there are still dozends of others TARGET_PAGE_SIZE usages in target/s390x/, what's the advantage of removing that one here?

Quoted 3 lines

The other ones are really related to the s390x page size.

This one seems to use TARGET_PAGE_SIZE as an optimization.

Also, making this file common, we get the page size at runtime, and that triggers:

../../target/s390x/ioinst.c:663:17: error: variable length array used [-Werror,-Wvla]

  663 |     uint8_t buf[TARGET_PAGE_SIZE];
      |                 ^~~~~~~~~~~~~~~~
include/exec/target_page.h:42:30: note: expanded from macro 'TARGET_PAGE_SIZE'
   42 | # define TARGET_PAGE_SIZE    (-(int)TARGET_PAGE_MASK)
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~

include/exec/target_page.h:40:49: note: expanded from macro 'TARGET_PAGE_MASK'
40 | # define TARGET_PAGE_MASK ((TARGET_PAGE_TYPE)target_page.mask)
| ^
include/exec/target_page.h:32:29: note: declared here
32 | extern const TargetPageBits target_page;
| ^
1 error generated.

I'll drop this patch and let someone with proper s390x knowledge post a proper fix when this will become a blocking issue, but today it isn't.

Quoted 9 lines
Quoted 8 lines

The other ones are also used by user emulation so need more care. This series addresses all system-only files. I neglected to mention that in the cover :(

But if you think this is better to review all target/s390x/ conversion in one go, I can wait until I finish the rest.

#31 lore raw

Re: [PATCH 13/18] target/s390x: Introduce CHSC_MAX_REQ_LEN definition

Quoted 48 lines · Philippe Mathieu-Daudé
Quoted 47 lines · Philippe Mathieu-Daudé
Quoted 35 lines · Philippe Mathieu-Daudé
Quoted 34 lines · Thomas Huth
Quoted 33 lines · Philippe Mathieu-Daudé

Since commit 166f1bb7968 ("s390x/ioinst: Rework memory access in CHSC instruction") the access is no more tied to the page size. Define CHSC_MAX_REQ_LEN to better express the relation with the length of the Channel Subsystem Call request.

---
  target/s390x/ioinst.c | 5 +++--

  1 file changed, 3 insertions(+), 2 deletions(-)
target/s390x/ioinst.c +2 -1
index 2320dd4c122..d07773d14a3 100644
@@ -398,6 +398,7 @@ typedef struct ChscResp {
       char data[];
   } QEMU_PACKED ChscResp;
+#define CHSC_MAX_REQ_LEN  0x1000
   #define CHSC_MIN_RESP_LEN 0x0008
   #define CHSC_SCPD 0x0002
@@ -660,7 +661,7 @@ void ioinst_handle_chsc(S390CPU *cpu, uint32_t ipb, 
 uintptr_t ra)
       uint16_t len;
       uint16_t command;
       CPUS390XState *env = &cpu->env;
-    uint8_t buf[TARGET_PAGE_SIZE];
+    uint8_t buf[CHSC_MAX_REQ_LEN];
       trace_ioinst("chsc");
       reg = (ipb >> 20) & 0x00f;
@@ -690,7 +691,7 @@ void ioinst_handle_chsc(S390CPU *cpu, uint32_t ipb, 
 uintptr_t ra)
           s390_program_interrupt(env, PGM_OPERAND, ra);
           return;
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
target/s390x/ioinst.c +1 -1
       }
-    memset((char *)req + len, 0, TARGET_PAGE_SIZE - len);
+    memset((char *)req + len, 0, CHSC_MAX_REQ_LEN - len);
       res = (void *)((char *)req + len);
       command = be16_to_cpu(req->command);

      trace_ioinst_chsc_cmd(command, len);

Sorry, I don't quite get it, there are still dozends of others TARGET_PAGE_SIZE usages in target/s390x/, what's the advantage of removing that one here?

The other ones are really related to the s390x page size.

Quoted 8 lines
Quoted 1 line

This one seems to use TARGET_PAGE_SIZE as an optimization.

Also, making this file common, we get the page size at runtime, and that triggers:

../../target/s390x/ioinst.c:663:17: error: variable length array used [- Werror,-Wvla]
  663 |     uint8_t buf[TARGET_PAGE_SIZE];
      |                 ^~~~~~~~~~~~~~~~

Using such big arrays on the stack is not good style anyway - unless this is a hot path, which I think it is not. So maybe you could simply post a patch that turns this into a "g_autofree uint8_t *buf = gmalloc(TARGET_PAGE_SIZE)" instead?

Thomas

#32 lore raw

PATCH 14/18 target/s390x: Simplify S390_ADAPTER_SUPPRESSIBLE definition

In reply to Philippe Mathieu-Daudé

Commit 1497c160661 ("s390x: add flags field for registering I/O adapter") defined S390_ADAPTER_SUPPRESSIBLE twice, one when KVM is available and another when it isn't. However both definitions expand to the same value. Unify them, adding an extra safety check in KVM-specific file.

This allows removing the target-specific 'CONFIG_KVM' definition in "cpu.h".

---
 include/hw/s390x/css.h | 2 ++
 target/s390x/cpu.h     | 6 ------
 target/s390x/kvm/kvm.c | 2 ++
 3 files changed, 4 insertions(+), 6 deletions(-)
include/hw/s390x/css.h +2 -0
index 0b0400a9d4f..d3326237c9f 100644
@@ -238,6 +238,8 @@ uint32_t css_get_adapter_id(CssIoAdapterType type, uint8_t isc);
 void css_register_io_adapters(CssIoAdapterType type, bool swap, bool maskable,
                               uint8_t flags, Error **errp);
 
+#define S390_ADAPTER_SUPPRESSIBLE 0x01
+
 SubchDev *css_find_subch(uint8_t m, uint8_t cssid, uint8_t ssid,
                          uint16_t schid);
 bool css_subch_visible(SubchDev *sch);
target/s390x/cpu.h +0 -6
index aa931cb6748..75608b038f4 100644
@@ -39,12 +39,6 @@
 
 #define S390_MAX_CPUS 248
 
-#ifndef CONFIG_KVM
-#define S390_ADAPTER_SUPPRESSIBLE 0x01
-#else
-#define S390_ADAPTER_SUPPRESSIBLE KVM_S390_ADAPTER_SUPPRESSIBLE
-#endif
-
 typedef struct PSW {
     uint64_t mask;
     uint64_t addr;
target/s390x/kvm/kvm.c +2 -0
index bd6c440aefb..54d28e37d4d 100644
@@ -2082,6 +2082,8 @@ int kvm_s390_vcpu_interrupt_post_load(S390CPU *cpu)
     return r;
 }
 
+QEMU_BUILD_BUG_ON(S390_ADAPTER_SUPPRESSIBLE != KVM_S390_ADAPTER_SUPPRESSIBLE);
+
 int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route,
                              uint64_t address, uint32_t data, PCIDevice *dev)
 {
Signature · 1 line
2.52.0
Reviewed-by on v1 14/18
#33 lore raw

Re: [PATCH 14/18] target/s390x: Simplify S390_ADAPTER_SUPPRESSIBLE definition

Quoted 9 lines · Philippe Mathieu-Daudé

Commit 1497c160661 ("s390x: add flags field for registering I/O adapter") defined S390_ADAPTER_SUPPRESSIBLE twice, one when KVM is available and another when it isn't. However both definitions expand to the same value. Unify them, adding an extra safety check in KVM-specific file.

This allows removing the target-specific 'CONFIG_KVM' definition in "cpu.h".

Quoted 6 lines
---
  include/hw/s390x/css.h | 2 ++
  target/s390x/cpu.h     | 6 ------
  target/s390x/kvm/kvm.c | 2 ++
  3 files changed, 4 insertions(+), 6 deletions(-)
#34 lore raw

PATCH 15/18 target/s390x: Un-inline s390_is_pv()

In reply to Philippe Mathieu-Daudé

Inlining a method which use a static variable is really a bad idea, as it totally defeats the point of both concepts.

Currently we have 12 + 4 = 16 static 'ccw' variables...:

  $ git grep -wl target/s390x/kvm/pv.h | fgrep .h
  hw/s390x/ipl.h
  $ git grep -wl target/s390x/kvm/pv.h | fgrep .c | wc -l
        12
  $ git grep -wl hw/s390x/ipl.h | fgrep .c | wc -l
         4
Fixes c3347ed0d2e ("s390x: protvirt: Support unpack facility")
---
 target/s390x/kvm/pv.h | 24 +-----------------------
 target/s390x/kvm/pv.c | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 23 deletions(-)
target/s390x/kvm/pv.h +1 -23
index 94e885e9335..e266fc3d545 100644
@@ -12,8 +12,6 @@
 #ifndef HW_S390_PV_H
 #define HW_S390_PV_H
 
-#include "qapi/error.h"
-#include "system/kvm.h"
 #include "hw/s390x/s390-virtio-ccw.h"
 
 struct S390PVResponse {
@@ -23,27 +21,7 @@ struct S390PVResponse {
 };
 
 #ifdef CONFIG_KVM
-#include "cpu.h"
-
-static inline bool s390_is_pv(void)
-{
-    static S390CcwMachineState *ccw;
-    Object *obj;
-
-    if (ccw) {
-        return ccw->pv;
-    }
-
-    /* we have to bail out for the "none" machine */
-    obj = object_dynamic_cast(qdev_get_machine(),
-                              TYPE_S390_CCW_MACHINE);
-    if (!obj) {
-        return false;
-    }
-    ccw = S390_CCW_MACHINE(obj);
-    return ccw->pv;
-}
-
+bool s390_is_pv(void);
 int s390_pv_query_info(void);
 int s390_pv_vm_enable(void);
 void s390_pv_vm_disable(void);
target/s390x/kvm/pv.c +18 -0
index 2bc916a5455..3d508165f34 100644
@@ -25,6 +25,24 @@
 #include "target/s390x/kvm/kvm_s390x.h"
 #include "target/s390x/kvm/pv.h"
 
+bool s390_is_pv(void)
+{
+    static S390CcwMachineState *ccw;
+    Object *obj;
+
+    if (ccw) {
+        return ccw->pv;
+    }
+
+    /* we have to bail out for the "none" machine */
+    obj = object_dynamic_cast(qdev_get_machine(), TYPE_S390_CCW_MACHINE);
+    if (!obj) {
+        return false;
+    }
+    ccw = S390_CCW_MACHINE(obj);
+    return ccw->pv;
+}
+
 static bool info_valid;
 static struct kvm_s390_pv_info_vm info_vm;
 static struct kvm_s390_pv_info_dump info_dump;
Signature · 1 line
2.52.0
Reviewed-by on v1 15/18
#35 lore raw

Re: [PATCH 15/18] target/s390x: Un-inline s390_is_pv()

Quoted 12 lines · Philippe Mathieu-Daudé

Inlining a method which use a static variable is really a bad idea, as it totally defeats the point of both concepts.

Currently we have 12 + 4 = 16 static 'ccw' variables...:

   $ git grep -wl target/s390x/kvm/pv.h | fgrep .h
   hw/s390x/ipl.h
   $ git grep -wl target/s390x/kvm/pv.h | fgrep .c | wc -l
         12
   $ git grep -wl hw/s390x/ipl.h | fgrep .c | wc -l
          4
Quoted 6 lines
Fixes c3347ed0d2e ("s390x: protvirt: Support unpack facility")
---
  target/s390x/kvm/pv.h | 24 +-----------------------
  target/s390x/kvm/pv.c | 18 ++++++++++++++++++
  2 files changed, 19 insertions(+), 23 deletions(-)
#36 lore raw

PATCH 16/18 target/s390x: Un-inline KVM Protected Virtualization stubs

In reply to Philippe Mathieu-Daudé
---
 target/s390x/kvm/pv.h    | 27 ------------
 target/s390x/kvm/stubs.c | 94 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 94 insertions(+), 27 deletions(-)
target/s390x/kvm/pv.h +0 -27
index e266fc3d545..ea4b4ec3403 100644
@@ -20,7 +20,6 @@ struct S390PVResponse {
     uint16_t rc;
 };
 
-#ifdef CONFIG_KVM
 bool s390_is_pv(void);
 int s390_pv_query_info(void);
 int s390_pv_vm_enable(void);
@@ -43,31 +42,5 @@ int kvm_s390_dump_init(void);
 int kvm_s390_dump_cpu(S390CPU *cpu, void *buff);
 int kvm_s390_dump_mem_state(uint64_t addr, size_t len, void *dest);
 int kvm_s390_dump_completion_data(void *buff);
-#else /* CONFIG_KVM */
-static inline bool s390_is_pv(void) { return false; }
-static inline int s390_pv_query_info(void) { return 0; }
-static inline int s390_pv_vm_enable(void) { return 0; }
-static inline void s390_pv_vm_disable(void) {}
-static inline bool s390_pv_vm_try_disable_async(S390CcwMachineState *ms) { return false; }
-static inline int s390_pv_set_sec_parms(uint64_t origin, uint64_t length,
-                                        struct S390PVResponse *pv_resp,
-                                        Error **errp) { return 0; }
-static inline int s390_pv_unpack(uint64_t addr, uint64_t size, uint64_t tweak,
-                                 struct S390PVResponse *pv_resp) { return 0; }
-static inline void s390_pv_prep_reset(void) {}
-static inline int s390_pv_verify(struct S390PVResponse *pv_resp) { return 0; }
-static inline void s390_pv_unshare(void) {}
-static inline void s390_pv_inject_reset_error(CPUState *cs,
-                                              struct S390PVResponse pv_resp) {};
-static inline uint64_t kvm_s390_pv_dmp_get_size_cpu(void) { return 0; }
-static inline uint64_t kvm_s390_pv_dmp_get_size_mem_state(void) { return 0; }
-static inline uint64_t kvm_s390_pv_dmp_get_size_completion_data(void) { return 0; }
-static inline bool kvm_s390_pv_info_basic_valid(void) { return false; }
-static inline int kvm_s390_dump_init(void) { return 0; }
-static inline int kvm_s390_dump_cpu(S390CPU *cpu, void *buff) { return 0; }
-static inline int kvm_s390_dump_mem_state(uint64_t addr, size_t len,
-                                          void *dest) { return 0; }
-static inline int kvm_s390_dump_completion_data(void *buff) { return 0; }
-#endif /* CONFIG_KVM */
 
 #endif /* HW_S390_PV_H */
target/s390x/kvm/stubs.c +94 -0

102 lines not on this page · raw message

Signature · 1 line
2.52.0
#37 lore raw

Re: [PATCH 16/18] target/s390x: Un-inline KVM Protected Virtualization stubs

Quoted 5 lines · Philippe Mathieu-Daudé
---
  target/s390x/kvm/pv.h    | 27 ------------
  target/s390x/kvm/stubs.c | 94 ++++++++++++++++++++++++++++++++++++++++
  2 files changed, 94 insertions(+), 27 deletions(-)

Please add a reasoning as patch description.

Thanks,
Thomas

#38 lore raw

Re: [PATCH 16/18] target/s390x: Un-inline KVM Protected Virtualization stubs

Quoted 8 lines · Thomas Huth
Quoted 5 lines · Philippe Mathieu-Daudé

---
  target/s390x/kvm/pv.h    | 27 ------------ target/s390x/kvm/stubs.c | 94 ++++++++++++++++++++++++++++++++++++++++

  2 files changed, 94 insertions(+), 27 deletions(-)

Please add a reasoning as patch description.

By removing the target-specific 'CONFIG_KVM' definition this header can be used by files in meson common_ss[].

I'll update.

#39 lore raw

PATCH 17/18 target/s390x: Add more unreachable KVM stubs

In reply to Philippe Mathieu-Daudé

Next patch will move s390x system objects from the target specific source set to the common one. Unfortunately the kvm_enabled() macro won't be evaluable at built-time anymore. Add stubs for KVM symbols unreachable at runtime.

---
 target/s390x/kvm/stubs.c | 76 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 75 insertions(+), 1 deletion(-)
target/s390x/kvm/stubs.c +75 -1
index 046e1f922b7..196127baa51 100644
@@ -4,8 +4,9 @@
 
 #include "qemu/osdep.h"
 
-#include "kvm_s390x.h"
+#include "target/s390x/kvm/kvm_s390x.h"
 #include "target/s390x/kvm/pv.h"
+#include "target/s390x/cpu_models.h"
 
 int kvm_s390_get_protected_dump(void)
 {
@@ -104,3 +105,76 @@ int kvm_s390_dump_completion_data(void *buff)
 {
     return 0;
 }
+
+bool kvm_s390_apply_cpu_model(const S390CPUModel *model,  Error **errp)
+{
+    g_assert_not_reached();
+}
+
+void kvm_s390_access_exception(S390CPU *cpu, uint16_t code, uint64_t te_code)
+{
+    g_assert_not_reached();
+}
+
+int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, uint8_t ar, void *hostbuf,
+                    int len, bool is_write)
+{
+    g_assert_not_reached();
+}
+
+int kvm_s390_mem_op_pv(S390CPU *cpu, vaddr addr, void *hostbuf, int len,
+                       bool is_write)
+{
+    g_assert_not_reached();
+}
+
+int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu_state)
+{
+    g_assert_not_reached();
+}
+
+void kvm_s390_vcpu_interrupt_pre_save(S390CPU *cpu)
+{
+    g_assert_not_reached();
+}
+
+int kvm_s390_vcpu_interrupt_post_load(S390CPU *cpu)
+{
+    g_assert_not_reached();
+}
+
+int kvm_s390_get_hpage_1m(void)
+{
+    g_assert_not_reached();
+}
+
+void kvm_s390_enable_css_support(S390CPU *cpu)
+{
+    g_assert_not_reached();
+}
+
+int kvm_s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch,
+                                    int vq, bool assign)
+{
+    g_assert_not_reached();
+}
+
+void kvm_s390_cmma_reset(void)
+{
+    g_assert_not_reached();
+}
+
+void kvm_s390_crypto_reset(void)
+{
+    g_assert_not_reached();
+}
+
+void kvm_s390_set_diag318(CPUState *cs, uint64_t diag318_info)
+{
+    g_assert_not_reached();
+}
+
+int kvm_s390_topology_set_mtcr(uint64_t attr)
+{
+    g_assert_not_reached();
+}
Signature · 1 line
2.52.0
Acked-by on v1 17/18
#40 lore raw

Re: [PATCH 17/18] target/s390x: Add more unreachable KVM stubs

Quoted 9 lines · Philippe Mathieu-Daudé

Next patch will move s390x system objects from the target specific source set to the common one. Unfortunately the kvm_enabled() macro won't be evaluable at built-time anymore. Add stubs for KVM symbols unreachable at runtime.

---
  target/s390x/kvm/stubs.c | 76 +++++++++++++++++++++++++++++++++++++++-
  1 file changed, 75 insertions(+), 1 deletion(-)
#41 lore raw

PATCH 18/18 target/s390x: Build system units in common source set

In reply to Philippe Mathieu-Daudé

For the qemu-system-s390x binary, this doesn't reduce the number of built objects, but this ensure the files in the meson source set won't get access to target_ulong and TARGET_PAGE_SIZE definitions, thus forcing to use the correct types instead (such vaddr, hwaddr, uint64_t, ...).

---
 target/s390x/meson.build     | 5 ++++-
 target/s390x/tcg/meson.build | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)
target/s390x/meson.build +4 -1
index 3b34ae034cb..626a8e18f82 100644
@@ -19,7 +19,9 @@ gen_features_h = custom_target('gen-features.h',
 s390x_ss.add(gen_features_h)
 
 s390x_system_ss = ss.source_set()
-s390x_system_ss.add(files(
+
+s390x_common_system_ss = ss.source_set()
+s390x_common_system_ss.add(files(
   'helper.c',
   'arch_dump.c',
   'diag.c',
@@ -41,4 +43,5 @@ subdir('kvm')
 
 target_arch += {'s390x': s390x_ss}
 target_system_arch += {'s390x': s390x_system_ss}
+target_common_system_arch += {'s390x': s390x_common_system_ss}
 target_user_arch += {'s390x': s390x_user_ss}
target/s390x/tcg/meson.build +1 -1
index 515cb8b473d..17c9374d09e 100644
@@ -12,6 +12,6 @@ s390x_ss.add(when: 'CONFIG_TCG', if_true: files(
   'vec_int_helper.c',
   'vec_string_helper.c',
 ))
-s390x_system_ss.add(when: 'CONFIG_TCG', if_true: files(
+s390x_common_system_ss.add(when: 'CONFIG_TCG', if_true: files(
   'debug.c',
 ))
Signature · 1 line
2.52.0