qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] target/s390x/cpu: Restrict CPUS390XState declaration to 'cpu.h'
@ 2023-11-06 11:44 Philippe Mathieu-Daudé
  2023-11-06 11:44 ` [PATCH 1/4] hw/s390x/css: Have css_do_sic() take S390CPU instead of CPUS390XState Philippe Mathieu-Daudé
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-11-06 11:44 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Thomas Huth, David Hildenbrand, Halil Pasic,
	Eric Farman, Christian Borntraeger, qemu-s390x, Ilya Leoshkevich,
	Philippe Mathieu-Daudé

In order to restrict CPUS390XState declaration to "cpu.h" (both
target-specific):
- have the following prototypes take a S390CPU* instead:
  . css_do_sic()
  . sclp_service_call()
  . sclp_service_call_protected()
- restrict cpu_get_tb_cpu_state() definition to TCG

Philippe Mathieu-Daudé (4):
  hw/s390x/css: Have css_do_sic() take S390CPU instead of CPUS390XState
  hw/s390x/sclp: Have sclp_service_call[_protected]() take S390CPU*
  target/s390x/cpu: Restrict cpu_get_tb_cpu_state() definition to TCG
  target/s390x/cpu: Restrict CPUS390XState declaration to 'cpu.h'

 include/hw/s390x/css.h         |  2 +-
 include/hw/s390x/sclp.h        |  5 ++---
 target/s390x/cpu-qom.h         |  2 --
 target/s390x/cpu.h             | 11 ++++++++---
 hw/s390x/css.c                 |  3 ++-
 hw/s390x/sclp.c                |  7 ++++---
 target/s390x/kvm/kvm.c         |  4 ++--
 target/s390x/tcg/misc_helper.c |  5 +++--
 8 files changed, 22 insertions(+), 17 deletions(-)

-- 
2.41.0



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/4] hw/s390x/css: Have css_do_sic() take S390CPU instead of CPUS390XState
  2023-11-06 11:44 [PATCH 0/4] target/s390x/cpu: Restrict CPUS390XState declaration to 'cpu.h' Philippe Mathieu-Daudé
@ 2023-11-06 11:44 ` Philippe Mathieu-Daudé
  2023-11-06 11:44 ` [PATCH 2/4] hw/s390x/sclp: Have sclp_service_call[_protected]() take S390CPU* Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-11-06 11:44 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Thomas Huth, David Hildenbrand, Halil Pasic,
	Eric Farman, Christian Borntraeger, qemu-s390x, Ilya Leoshkevich,
	Philippe Mathieu-Daudé

"hw/s390x/css.h" is a header used by target-agnostic objects
(such hw/s390x/virtio-ccw-gpu.c), thus can not use target-specific
types, such CPUS390XState.

Have css_do_sic() take S390CPU a pointer, which is target-agnostic.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/hw/s390x/css.h         | 2 +-
 hw/s390x/css.c                 | 3 ++-
 target/s390x/kvm/kvm.c         | 2 +-
 target/s390x/tcg/misc_helper.c | 3 ++-
 4 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h
index 75e5381613..ba72ee3dd2 100644
--- a/include/hw/s390x/css.h
+++ b/include/hw/s390x/css.h
@@ -233,7 +233,7 @@ typedef enum {
 } CssIoAdapterType;
 
 void css_adapter_interrupt(CssIoAdapterType type, uint8_t isc);
-int css_do_sic(CPUS390XState *env, uint8_t isc, uint16_t mode);
+int css_do_sic(S390CPU *cpu, uint8_t isc, uint16_t mode);
 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);
diff --git a/hw/s390x/css.c b/hw/s390x/css.c
index 95d1b3a3ce..bcedec2fc8 100644
--- a/hw/s390x/css.c
+++ b/hw/s390x/css.c
@@ -644,8 +644,9 @@ void css_conditional_io_interrupt(SubchDev *sch)
     }
 }
 
-int css_do_sic(CPUS390XState *env, uint8_t isc, uint16_t mode)
+int css_do_sic(S390CPU *cpu, uint8_t isc, uint16_t mode)
 {
+    CPUS390XState *env = &cpu->env;
     S390FLICState *fs = s390_get_flic();
     S390FLICStateClass *fsc = s390_get_flic_class(fs);
     int r;
diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c
index 0f0e784b2a..1ddad0bec1 100644
--- a/target/s390x/kvm/kvm.c
+++ b/target/s390x/kvm/kvm.c
@@ -1358,7 +1358,7 @@ static int kvm_sic_service_call(S390CPU *cpu, struct kvm_run *run)
 
     mode = env->regs[r1] & 0xffff;
     isc = (env->regs[r3] >> 27) & 0x7;
-    r = css_do_sic(env, isc, mode);
+    r = css_do_sic(cpu, isc, mode);
     if (r) {
         kvm_s390_program_interrupt(cpu, -r);
     }
diff --git a/target/s390x/tcg/misc_helper.c b/target/s390x/tcg/misc_helper.c
index e85658ce22..56c7f00cf9 100644
--- a/target/s390x/tcg/misc_helper.c
+++ b/target/s390x/tcg/misc_helper.c
@@ -761,10 +761,11 @@ void HELPER(stpcifc)(CPUS390XState *env, uint32_t r1, uint64_t fiba,
 
 void HELPER(sic)(CPUS390XState *env, uint64_t r1, uint64_t r3)
 {
+    S390CPU *cpu = env_archcpu(env);
     int r;
 
     qemu_mutex_lock_iothread();
-    r = css_do_sic(env, (r3 >> 27) & 0x7, r1 & 0xffff);
+    r = css_do_sic(cpu, (r3 >> 27) & 0x7, r1 & 0xffff);
     qemu_mutex_unlock_iothread();
     /* css_do_sic() may actually return a PGM_xxx value to inject */
     if (r) {
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/4] hw/s390x/sclp: Have sclp_service_call[_protected]() take S390CPU*
  2023-11-06 11:44 [PATCH 0/4] target/s390x/cpu: Restrict CPUS390XState declaration to 'cpu.h' Philippe Mathieu-Daudé
  2023-11-06 11:44 ` [PATCH 1/4] hw/s390x/css: Have css_do_sic() take S390CPU instead of CPUS390XState Philippe Mathieu-Daudé
@ 2023-11-06 11:44 ` Philippe Mathieu-Daudé
  2023-11-07 12:10   ` Philippe Mathieu-Daudé
  2023-11-06 11:44 ` [PATCH 3/4] target/s390x/cpu: Restrict cpu_get_tb_cpu_state() definition to TCG Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-11-06 11:44 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Thomas Huth, David Hildenbrand, Halil Pasic,
	Eric Farman, Christian Borntraeger, qemu-s390x, Ilya Leoshkevich,
	Philippe Mathieu-Daudé

"hw/s390x/sclp.h" is a header used by target-agnostic objects
(such hw/char/sclpconsole[-lm].c), thus can not use target-specific
types, such CPUS390XState.

Have sclp_service_call[_protected]() take a S390CPU pointer, which
is target-agnostic.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/hw/s390x/sclp.h        | 5 ++---
 hw/s390x/sclp.c                | 7 ++++---
 target/s390x/kvm/kvm.c         | 2 +-
 target/s390x/tcg/misc_helper.c | 2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/include/hw/s390x/sclp.h b/include/hw/s390x/sclp.h
index 9aef6d9370..e229b81a67 100644
--- a/include/hw/s390x/sclp.h
+++ b/include/hw/s390x/sclp.h
@@ -227,8 +227,7 @@ static inline int sccb_data_len(SCCB *sccb)
 void s390_sclp_init(void);
 void sclp_service_interrupt(uint32_t sccb);
 void raise_irq_cpu_hotplug(void);
-int sclp_service_call(CPUS390XState *env, uint64_t sccb, uint32_t code);
-int sclp_service_call_protected(CPUS390XState *env, uint64_t sccb,
-                                uint32_t code);
+int sclp_service_call(S390CPU *cpu, uint64_t sccb, uint32_t code);
+int sclp_service_call_protected(S390CPU *cpu, uint64_t sccb, uint32_t code);
 
 #endif
diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
index d339cbb7e4..893e71a41b 100644
--- a/hw/s390x/sclp.c
+++ b/hw/s390x/sclp.c
@@ -269,9 +269,9 @@ static void sclp_execute(SCLPDevice *sclp, SCCB *sccb, uint32_t code)
  * service_interrupt call.
  */
 #define SCLP_PV_DUMMY_ADDR 0x4000
-int sclp_service_call_protected(CPUS390XState *env, uint64_t sccb,
-                                uint32_t code)
+int sclp_service_call_protected(S390CPU *cpu, uint64_t sccb, uint32_t code)
 {
+    CPUS390XState *env = &cpu->env;
     SCLPDevice *sclp = get_sclp_device();
     SCLPDeviceClass *sclp_c = SCLP_GET_CLASS(sclp);
     SCCBHeader header;
@@ -296,8 +296,9 @@ out_write:
     return 0;
 }
 
-int sclp_service_call(CPUS390XState *env, uint64_t sccb, uint32_t code)
+int sclp_service_call(S390CPU *cpu, uint64_t sccb, uint32_t code)
 {
+    CPUS390XState *env = &cpu->env;
     SCLPDevice *sclp = get_sclp_device();
     SCLPDeviceClass *sclp_c = SCLP_GET_CLASS(sclp);
     SCCBHeader header;
diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c
index 1ddad0bec1..a12fbfc026 100644
--- a/target/s390x/kvm/kvm.c
+++ b/target/s390x/kvm/kvm.c
@@ -1174,7 +1174,7 @@ static void kvm_sclp_service_call(S390CPU *cpu, struct kvm_run *run,
         break;
     case ICPT_PV_INSTR:
         g_assert(s390_is_pv());
-        sclp_service_call_protected(env, sccb, code);
+        sclp_service_call_protected(cpu, sccb, code);
         /* Setting the CC is done by the Ultravisor. */
         break;
     case ICPT_INSTRUCTION:
diff --git a/target/s390x/tcg/misc_helper.c b/target/s390x/tcg/misc_helper.c
index 56c7f00cf9..6aa7907438 100644
--- a/target/s390x/tcg/misc_helper.c
+++ b/target/s390x/tcg/misc_helper.c
@@ -102,7 +102,7 @@ uint64_t HELPER(stck)(CPUS390XState *env)
 uint32_t HELPER(servc)(CPUS390XState *env, uint64_t r1, uint64_t r2)
 {
     qemu_mutex_lock_iothread();
-    int r = sclp_service_call(env, r1, r2);
+    int r = sclp_service_call(env_archcpu(env), r1, r2);
     qemu_mutex_unlock_iothread();
     if (r < 0) {
         tcg_s390_program_interrupt(env, -r, GETPC());
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/4] target/s390x/cpu: Restrict cpu_get_tb_cpu_state() definition to TCG
  2023-11-06 11:44 [PATCH 0/4] target/s390x/cpu: Restrict CPUS390XState declaration to 'cpu.h' Philippe Mathieu-Daudé
  2023-11-06 11:44 ` [PATCH 1/4] hw/s390x/css: Have css_do_sic() take S390CPU instead of CPUS390XState Philippe Mathieu-Daudé
  2023-11-06 11:44 ` [PATCH 2/4] hw/s390x/sclp: Have sclp_service_call[_protected]() take S390CPU* Philippe Mathieu-Daudé
@ 2023-11-06 11:44 ` Philippe Mathieu-Daudé
  2023-11-06 11:44 ` [PATCH 4/4] target/s390x/cpu: Restrict CPUS390XState declaration to 'cpu.h' Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-11-06 11:44 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Thomas Huth, David Hildenbrand, Halil Pasic,
	Eric Farman, Christian Borntraeger, qemu-s390x, Ilya Leoshkevich,
	Philippe Mathieu-Daudé

cpu_get_tb_cpu_state() is TCG specific. Another accelerator
calling it would be a bug, so restrict the definition to TCG,
along with "tcg_s390x.h" header inclusion.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/s390x/cpu.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
index 38d7197f4c..110902fa3c 100644
--- a/target/s390x/cpu.h
+++ b/target/s390x/cpu.h
@@ -29,7 +29,6 @@
 #include "cpu_models.h"
 #include "exec/cpu-defs.h"
 #include "qemu/cpu-float.h"
-#include "tcg/tcg_s390x.h"
 #include "qapi/qapi-types-machine-common.h"
 
 #define ELF_MACHINE_UNAME "S390X"
@@ -383,6 +382,10 @@ static inline int cpu_mmu_index(CPUS390XState *env, bool ifetch)
 #endif
 }
 
+#ifdef CONFIG_TCG
+
+#include "tcg/tcg_s390x.h"
+
 static inline void cpu_get_tb_cpu_state(CPUS390XState *env, vaddr *pc,
                                         uint64_t *cs_base, uint32_t *flags)
 {
@@ -405,6 +408,8 @@ static inline void cpu_get_tb_cpu_state(CPUS390XState *env, vaddr *pc,
     }
 }
 
+#endif /* CONFIG_TCG */
+
 /* PER bits from control register 9 */
 #define PER_CR9_EVENT_BRANCH           0x80000000
 #define PER_CR9_EVENT_IFETCH           0x40000000
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/4] target/s390x/cpu: Restrict CPUS390XState declaration to 'cpu.h'
  2023-11-06 11:44 [PATCH 0/4] target/s390x/cpu: Restrict CPUS390XState declaration to 'cpu.h' Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2023-11-06 11:44 ` [PATCH 3/4] target/s390x/cpu: Restrict cpu_get_tb_cpu_state() definition to TCG Philippe Mathieu-Daudé
@ 2023-11-06 11:44 ` Philippe Mathieu-Daudé
  2023-11-07 15:29   ` Zhao Liu
  2023-11-07 10:44 ` [PATCH 0/4] " Thomas Huth
  2023-11-07 11:21 ` Thomas Huth
  5 siblings, 1 reply; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-11-06 11:44 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Thomas Huth, David Hildenbrand, Halil Pasic,
	Eric Farman, Christian Borntraeger, qemu-s390x, Ilya Leoshkevich,
	Philippe Mathieu-Daudé

"target/s390x/cpu-qom.h" has to be target-agnostic. However, it
currently declares CPUS390XState, which is target-specific.
Move that declaration to "cpu.h".

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/s390x/cpu-qom.h | 2 --
 target/s390x/cpu.h     | 4 ++--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/target/s390x/cpu-qom.h b/target/s390x/cpu-qom.h
index fcd70daddf..ccf126b7a9 100644
--- a/target/s390x/cpu-qom.h
+++ b/target/s390x/cpu-qom.h
@@ -33,8 +33,6 @@ OBJECT_DECLARE_CPU_TYPE(S390CPU, S390CPUClass, S390_CPU)
 typedef struct S390CPUModel S390CPUModel;
 typedef struct S390CPUDef S390CPUDef;
 
-typedef struct CPUArchState CPUS390XState;
-
 typedef enum cpu_reset_type {
     S390_CPU_RESET_NORMAL,
     S390_CPU_RESET_INITIAL,
diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
index 110902fa3c..942589c597 100644
--- a/target/s390x/cpu.h
+++ b/target/s390x/cpu.h
@@ -55,7 +55,7 @@ typedef struct PSW {
     uint64_t addr;
 } PSW;
 
-struct CPUArchState {
+typedef struct CPUArchState {
     uint64_t regs[16];     /* GP registers */
     /*
      * The floating point registers are part of the vector registers.
@@ -157,7 +157,7 @@ struct CPUArchState {
     /* currently processed sigp order */
     uint8_t sigp_order;
 
-};
+} CPUS390XState;
 
 static inline uint64_t *get_freg(CPUS390XState *cs, int nr)
 {
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/4] target/s390x/cpu: Restrict CPUS390XState declaration to 'cpu.h'
  2023-11-06 11:44 [PATCH 0/4] target/s390x/cpu: Restrict CPUS390XState declaration to 'cpu.h' Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2023-11-06 11:44 ` [PATCH 4/4] target/s390x/cpu: Restrict CPUS390XState declaration to 'cpu.h' Philippe Mathieu-Daudé
@ 2023-11-07 10:44 ` Thomas Huth
  2023-11-07 12:12   ` Philippe Mathieu-Daudé
  2023-11-07 11:21 ` Thomas Huth
  5 siblings, 1 reply; 11+ messages in thread
From: Thomas Huth @ 2023-11-07 10:44 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Richard Henderson, David Hildenbrand, Halil Pasic, Eric Farman,
	Christian Borntraeger, qemu-s390x, Ilya Leoshkevich

On 06/11/2023 12.44, Philippe Mathieu-Daudé wrote:
> In order to restrict CPUS390XState declaration to "cpu.h" (both
> target-specific):
> - have the following prototypes take a S390CPU* instead:
>    . css_do_sic()
>    . sclp_service_call()
>    . sclp_service_call_protected()
> - restrict cpu_get_tb_cpu_state() definition to TCG
> 
> Philippe Mathieu-Daudé (4):
>    hw/s390x/css: Have css_do_sic() take S390CPU instead of CPUS390XState
>    hw/s390x/sclp: Have sclp_service_call[_protected]() take S390CPU*
>    target/s390x/cpu: Restrict cpu_get_tb_cpu_state() definition to TCG
>    target/s390x/cpu: Restrict CPUS390XState declaration to 'cpu.h'

Patches look reasonable. Thanks, queued them now!

  Thomas




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/4] target/s390x/cpu: Restrict CPUS390XState declaration to 'cpu.h'
  2023-11-06 11:44 [PATCH 0/4] target/s390x/cpu: Restrict CPUS390XState declaration to 'cpu.h' Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2023-11-07 10:44 ` [PATCH 0/4] " Thomas Huth
@ 2023-11-07 11:21 ` Thomas Huth
  5 siblings, 0 replies; 11+ messages in thread
From: Thomas Huth @ 2023-11-07 11:21 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Richard Henderson, David Hildenbrand, Halil Pasic, Eric Farman,
	Christian Borntraeger, qemu-s390x, Ilya Leoshkevich

On 06/11/2023 12.44, Philippe Mathieu-Daudé wrote:
> In order to restrict CPUS390XState declaration to "cpu.h" (both
> target-specific):
> - have the following prototypes take a S390CPU* instead:
>    . css_do_sic()
>    . sclp_service_call()
>    . sclp_service_call_protected()
> - restrict cpu_get_tb_cpu_state() definition to TCG
> 
> Philippe Mathieu-Daudé (4):
>    hw/s390x/css: Have css_do_sic() take S390CPU instead of CPUS390XState
>    hw/s390x/sclp: Have sclp_service_call[_protected]() take S390CPU*
>    target/s390x/cpu: Restrict cpu_get_tb_cpu_state() definition to TCG
>    target/s390x/cpu: Restrict CPUS390XState declaration to 'cpu.h'
> 
>   include/hw/s390x/css.h         |  2 +-
>   include/hw/s390x/sclp.h        |  5 ++---
>   target/s390x/cpu-qom.h         |  2 --
>   target/s390x/cpu.h             | 11 ++++++++---
>   hw/s390x/css.c                 |  3 ++-
>   hw/s390x/sclp.c                |  7 ++++---
>   target/s390x/kvm/kvm.c         |  4 ++--
>   target/s390x/tcg/misc_helper.c |  5 +++--
>   8 files changed, 22 insertions(+), 17 deletions(-)
> 

FWIW:

Series:
Reviewed-by: Thomas Huth <thuth@redhat.com>



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/4] hw/s390x/sclp: Have sclp_service_call[_protected]() take S390CPU*
  2023-11-06 11:44 ` [PATCH 2/4] hw/s390x/sclp: Have sclp_service_call[_protected]() take S390CPU* Philippe Mathieu-Daudé
@ 2023-11-07 12:10   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-11-07 12:10 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Thomas Huth, David Hildenbrand, Halil Pasic,
	Eric Farman, Christian Borntraeger, qemu-s390x, Ilya Leoshkevich

On 6/11/23 12:44, Philippe Mathieu-Daudé wrote:
> "hw/s390x/sclp.h" is a header used by target-agnostic objects
> (such hw/char/sclpconsole[-lm].c), thus can not use target-specific
> types, such CPUS390XState.
> 
> Have sclp_service_call[_protected]() take a S390CPU pointer, which
> is target-agnostic.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/hw/s390x/sclp.h        | 5 ++---
>   hw/s390x/sclp.c                | 7 ++++---
>   target/s390x/kvm/kvm.c         | 2 +-
>   target/s390x/tcg/misc_helper.c | 2 +-
>   4 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/include/hw/s390x/sclp.h b/include/hw/s390x/sclp.h
> index 9aef6d9370..e229b81a67 100644
> --- a/include/hw/s390x/sclp.h
> +++ b/include/hw/s390x/sclp.h
> @@ -227,8 +227,7 @@ static inline int sccb_data_len(SCCB *sccb)
>   void s390_sclp_init(void);
>   void sclp_service_interrupt(uint32_t sccb);
>   void raise_irq_cpu_hotplug(void);
> -int sclp_service_call(CPUS390XState *env, uint64_t sccb, uint32_t code);
> -int sclp_service_call_protected(CPUS390XState *env, uint64_t sccb,
> -                                uint32_t code);
> +int sclp_service_call(S390CPU *cpu, uint64_t sccb, uint32_t code);
> +int sclp_service_call_protected(S390CPU *cpu, uint64_t sccb, uint32_t code);
>   
>   #endif
> diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
> index d339cbb7e4..893e71a41b 100644
> --- a/hw/s390x/sclp.c
> +++ b/hw/s390x/sclp.c
> @@ -269,9 +269,9 @@ static void sclp_execute(SCLPDevice *sclp, SCCB *sccb, uint32_t code)
>    * service_interrupt call.
>    */
>   #define SCLP_PV_DUMMY_ADDR 0x4000
> -int sclp_service_call_protected(CPUS390XState *env, uint64_t sccb,
> -                                uint32_t code)
> +int sclp_service_call_protected(S390CPU *cpu, uint64_t sccb, uint32_t code)
>   {
> +    CPUS390XState *env = &cpu->env;
>       SCLPDevice *sclp = get_sclp_device();
>       SCLPDeviceClass *sclp_c = SCLP_GET_CLASS(sclp);
>       SCCBHeader header;
> @@ -296,8 +296,9 @@ out_write:
>       return 0;
>   }
>   
> -int sclp_service_call(CPUS390XState *env, uint64_t sccb, uint32_t code)
> +int sclp_service_call(S390CPU *cpu, uint64_t sccb, uint32_t code)
>   {
> +    CPUS390XState *env = &cpu->env;
>       SCLPDevice *sclp = get_sclp_device();
>       SCLPDeviceClass *sclp_c = SCLP_GET_CLASS(sclp);
>       SCCBHeader header;
> diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c
> index 1ddad0bec1..a12fbfc026 100644
> --- a/target/s390x/kvm/kvm.c
> +++ b/target/s390x/kvm/kvm.c
> @@ -1174,7 +1174,7 @@ static void kvm_sclp_service_call(S390CPU *cpu, struct kvm_run *run,
>           break;
>       case ICPT_PV_INSTR:
>           g_assert(s390_is_pv());
> -        sclp_service_call_protected(env, sccb, code);
> +        sclp_service_call_protected(cpu, sccb, code);
>           /* Setting the CC is done by the Ultravisor. */
>           break;
>       case ICPT_INSTRUCTION:

Here I forgot:
-- >8 --
@@ -1179,7 +1179,7 @@ static void kvm_sclp_service_call(S390CPU *cpu, 
struct kvm_run *run,
          break;
      case ICPT_INSTRUCTION:
          g_assert(!s390_is_pv());
-        r = sclp_service_call(env, sccb, code);
+        r = sclp_service_call(cpu, sccb, code);
          if (r < 0) {
              kvm_s390_program_interrupt(cpu, -r);
              return;
---

> diff --git a/target/s390x/tcg/misc_helper.c b/target/s390x/tcg/misc_helper.c
> index 56c7f00cf9..6aa7907438 100644
> --- a/target/s390x/tcg/misc_helper.c
> +++ b/target/s390x/tcg/misc_helper.c
> @@ -102,7 +102,7 @@ uint64_t HELPER(stck)(CPUS390XState *env)
>   uint32_t HELPER(servc)(CPUS390XState *env, uint64_t r1, uint64_t r2)
>   {
>       qemu_mutex_lock_iothread();
> -    int r = sclp_service_call(env, r1, r2);
> +    int r = sclp_service_call(env_archcpu(env), r1, r2);
>       qemu_mutex_unlock_iothread();
>       if (r < 0) {
>           tcg_s390_program_interrupt(env, -r, GETPC());



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/4] target/s390x/cpu: Restrict CPUS390XState declaration to 'cpu.h'
  2023-11-07 10:44 ` [PATCH 0/4] " Thomas Huth
@ 2023-11-07 12:12   ` Philippe Mathieu-Daudé
  2023-11-07 13:30     ` Thomas Huth
  0 siblings, 1 reply; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-11-07 12:12 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel
  Cc: Richard Henderson, David Hildenbrand, Halil Pasic, Eric Farman,
	Christian Borntraeger, qemu-s390x, Ilya Leoshkevich

On 7/11/23 11:44, Thomas Huth wrote:
> On 06/11/2023 12.44, Philippe Mathieu-Daudé wrote:
>> In order to restrict CPUS390XState declaration to "cpu.h" (both
>> target-specific):
>> - have the following prototypes take a S390CPU* instead:
>>    . css_do_sic()
>>    . sclp_service_call()
>>    . sclp_service_call_protected()
>> - restrict cpu_get_tb_cpu_state() definition to TCG
>>
>> Philippe Mathieu-Daudé (4):
>>    hw/s390x/css: Have css_do_sic() take S390CPU instead of CPUS390XState
>>    hw/s390x/sclp: Have sclp_service_call[_protected]() take S390CPU*
>>    target/s390x/cpu: Restrict cpu_get_tb_cpu_state() definition to TCG
>>    target/s390x/cpu: Restrict CPUS390XState declaration to 'cpu.h'
> 
> Patches look reasonable. Thanks, queued them now!

Thanks, since I wasn't sure the series would be reviewed in time for
soft freeze, I didn't mention it would be more convenient for me to
take it via my hw-misc tree. Since you kindly reviewed it, I'll take
it :) Thanks!

Phil.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/4] target/s390x/cpu: Restrict CPUS390XState declaration to 'cpu.h'
  2023-11-07 12:12   ` Philippe Mathieu-Daudé
@ 2023-11-07 13:30     ` Thomas Huth
  0 siblings, 0 replies; 11+ messages in thread
From: Thomas Huth @ 2023-11-07 13:30 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Richard Henderson, David Hildenbrand, Halil Pasic, Eric Farman,
	Christian Borntraeger, qemu-s390x, Ilya Leoshkevich

On 07/11/2023 13.12, Philippe Mathieu-Daudé wrote:
> On 7/11/23 11:44, Thomas Huth wrote:
>> On 06/11/2023 12.44, Philippe Mathieu-Daudé wrote:
>>> In order to restrict CPUS390XState declaration to "cpu.h" (both
>>> target-specific):
>>> - have the following prototypes take a S390CPU* instead:
>>>    . css_do_sic()
>>>    . sclp_service_call()
>>>    . sclp_service_call_protected()
>>> - restrict cpu_get_tb_cpu_state() definition to TCG
>>>
>>> Philippe Mathieu-Daudé (4):
>>>    hw/s390x/css: Have css_do_sic() take S390CPU instead of CPUS390XState
>>>    hw/s390x/sclp: Have sclp_service_call[_protected]() take S390CPU*
>>>    target/s390x/cpu: Restrict cpu_get_tb_cpu_state() definition to TCG
>>>    target/s390x/cpu: Restrict CPUS390XState declaration to 'cpu.h'
>>
>> Patches look reasonable. Thanks, queued them now!
> 
> Thanks, since I wasn't sure the series would be reviewed in time for
> soft freeze, I didn't mention it would be more convenient for me to
> take it via my hw-misc tree. Since you kindly reviewed it, I'll take
> it :) Thanks!

All right, I'll drop them from my queue again then.

  Thomas




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 4/4] target/s390x/cpu: Restrict CPUS390XState declaration to 'cpu.h'
  2023-11-06 11:44 ` [PATCH 4/4] target/s390x/cpu: Restrict CPUS390XState declaration to 'cpu.h' Philippe Mathieu-Daudé
@ 2023-11-07 15:29   ` Zhao Liu
  0 siblings, 0 replies; 11+ messages in thread
From: Zhao Liu @ 2023-11-07 15:29 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Richard Henderson, Thomas Huth, David Hildenbrand,
	Halil Pasic, Eric Farman, Christian Borntraeger, qemu-s390x,
	Ilya Leoshkevich

On Mon, Nov 06, 2023 at 12:44:59PM +0100, Philippe Mathieu-Daudé wrote:
> Date: Mon,  6 Nov 2023 12:44:59 +0100
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH 4/4] target/s390x/cpu: Restrict CPUS390XState declaration
>  to 'cpu.h'
> X-Mailer: git-send-email 2.41.0
> 
> "target/s390x/cpu-qom.h" has to be target-agnostic. However, it
> currently declares CPUS390XState, which is target-specific.
> Move that declaration to "cpu.h".
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  target/s390x/cpu-qom.h | 2 --
>  target/s390x/cpu.h     | 4 ++--
>  2 files changed, 2 insertions(+), 4 deletions(-)

Sorry be late, as the response for [1],

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>

[1]: https://lore.kernel.org/qemu-devel/9b6eb677-1655-e452-2555-01eb01cf9072@linaro.org/

> 
> diff --git a/target/s390x/cpu-qom.h b/target/s390x/cpu-qom.h
> index fcd70daddf..ccf126b7a9 100644
> --- a/target/s390x/cpu-qom.h
> +++ b/target/s390x/cpu-qom.h
> @@ -33,8 +33,6 @@ OBJECT_DECLARE_CPU_TYPE(S390CPU, S390CPUClass, S390_CPU)
>  typedef struct S390CPUModel S390CPUModel;
>  typedef struct S390CPUDef S390CPUDef;
>  
> -typedef struct CPUArchState CPUS390XState;
> -
>  typedef enum cpu_reset_type {
>      S390_CPU_RESET_NORMAL,
>      S390_CPU_RESET_INITIAL,
> diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
> index 110902fa3c..942589c597 100644
> --- a/target/s390x/cpu.h
> +++ b/target/s390x/cpu.h
> @@ -55,7 +55,7 @@ typedef struct PSW {
>      uint64_t addr;
>  } PSW;
>  
> -struct CPUArchState {
> +typedef struct CPUArchState {
>      uint64_t regs[16];     /* GP registers */
>      /*
>       * The floating point registers are part of the vector registers.
> @@ -157,7 +157,7 @@ struct CPUArchState {
>      /* currently processed sigp order */
>      uint8_t sigp_order;
>  
> -};
> +} CPUS390XState;
>  
>  static inline uint64_t *get_freg(CPUS390XState *cs, int nr)
>  {
> -- 
> 2.41.0
> 





^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-11-07 15:19 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-06 11:44 [PATCH 0/4] target/s390x/cpu: Restrict CPUS390XState declaration to 'cpu.h' Philippe Mathieu-Daudé
2023-11-06 11:44 ` [PATCH 1/4] hw/s390x/css: Have css_do_sic() take S390CPU instead of CPUS390XState Philippe Mathieu-Daudé
2023-11-06 11:44 ` [PATCH 2/4] hw/s390x/sclp: Have sclp_service_call[_protected]() take S390CPU* Philippe Mathieu-Daudé
2023-11-07 12:10   ` Philippe Mathieu-Daudé
2023-11-06 11:44 ` [PATCH 3/4] target/s390x/cpu: Restrict cpu_get_tb_cpu_state() definition to TCG Philippe Mathieu-Daudé
2023-11-06 11:44 ` [PATCH 4/4] target/s390x/cpu: Restrict CPUS390XState declaration to 'cpu.h' Philippe Mathieu-Daudé
2023-11-07 15:29   ` Zhao Liu
2023-11-07 10:44 ` [PATCH 0/4] " Thomas Huth
2023-11-07 12:12   ` Philippe Mathieu-Daudé
2023-11-07 13:30     ` Thomas Huth
2023-11-07 11:21 ` Thomas Huth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).