target/s390x/cpu: Restrict CPUS390XState declaration to 'cpu.h'
cover target/s390x/cpu: Restrict CPUS390XState declaration to 'cpu.h'
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(-)
Signature · 1 line
2.41.0
PATCH 1/4 hw/s390x/css: Have css_do_sic() take S390CPU instead of CPUS390XState
"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.
--- 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(-)
include/hw/s390x/css.h +1 -1
@@ -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);
hw/s390x/css.c +2 -1
@@ -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;
target/s390x/kvm/kvm.c +1 -1
@@ -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); }
target/s390x/tcg/misc_helper.c +2 -1
@@ -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) {
Signature · 1 line
2.41.0
PATCH 2/4 hw/s390x/sclp: Have sclp_service_call[_protected]() take S390CPU*
In reply to 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.
--- 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(-)
include/hw/s390x/sclp.h +2 -3
@@ -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
hw/s390x/sclp.c +4 -3
@@ -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;
target/s390x/kvm/kvm.c +1 -1
@@ -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 :
target/s390x/tcg/misc_helper.c +1 -1
@@ -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 ());
Signature · 1 line
2.41.0
Re: [PATCH 2/4] hw/s390x/sclp: Have sclp_service_call[_protected]() take S390CPU*
Quoted 62 lines · 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é <[email protected]>--- 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(-)include/hw/s390x/sclp.h +2
-3@@ -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 hw/s390x/sclp.c +4
-3@@ -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;target/s390x/kvm/kvm.c +0
-0
target/s390x/kvm/kvm.c static void kvm_sclp_service_call(S390CPU *cpu, struct kvm_run *run, · line 1180
Quoted 8 lines
target/s390x/kvm/kvm.c +1
-1@@ -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;---
Quoted 13 lines
target/s390x/tcg/misc_helper.c +1
-1@@ -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 ());
PATCH 3/4 target/s390x/cpu: Restrict cpu_get_tb_cpu_state() definition to TCG
In reply to 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.
--- target/s390x/cpu.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
target/s390x/cpu.h +6 -1
@@ -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
Signature · 1 line
2.41.0
PATCH 4/4 target/s390x/cpu: Restrict CPUS390XState declaration to 'cpu.h'
In reply to 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".
--- target/s390x/cpu-qom.h | 2 -- target/s390x/cpu.h | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-)
target/s390x/cpu-qom.h +0 -2
@@ -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,
target/s390x/cpu.h +2 -2
@@ -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) {
Signature · 1 line
2.41.0
Quoted 10 lines · Philippe Mathieu-Daudé
Date: Mon, 6 Nov 2023 12:44:59 +0100
From: Philippe Mathieu-Daudé <[email protected]>
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".
Quoted 5 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- 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],
[1]: https://lore.kernel.org/qemu-devel/[email protected]/
Quoted 39 lines
target/s390x/cpu-qom.h +0
-2@@ -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,target/s390x/cpu.h +2
-2@@ -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) {Signature · 1 line
2.41.0
Quoted 6 lines · 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()
Quoted 7 lines
- restrict
cpu_get_tb_cpu_state()definition to TCGPhilippe 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
Quoted 9 lines · Thomas Huth
Quoted 8 lines · 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()
- restrictcpu_get_tb_cpu_state()definition to TCG
Quoted 7 lines
Quoted 5 lines
Philippe Mathieu-Daudé (4):
hw/s390x/css: Havecss_do_sic()take S390CPU instead of CPUS390XState hw/s390x/sclp: Have sclp_service_call[_protected]() take S390CPU* target/s390x/cpu: Restrictcpu_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.
Quoted 16 lines · Philippe Mathieu-Daudé
Quoted 15 lines · Thomas Huth
Quoted 13 lines · 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()
- restrictcpu_get_tb_cpu_state()definition to TCGPhilippe Mathieu-Daudé (4):
hw/s390x/css: Havecss_do_sic()take S390CPU instead of CPUS390XState hw/s390x/sclp: Have sclp_service_call[_protected]() take S390CPU* target/s390x/cpu: Restrictcpu_get_tb_cpu_state()definition to TCG target/s390x/cpu: Restrict CPUS390XState declaration to 'cpu.h'
Quoted 6 lines
Quoted 1 line
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
Quoted 14 lines · 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 TCGPhilippe 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'
Quoted 10 lines
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: