first s390x update for 5.0
[PULL 11/16] s390x/cpumodel: Fix feature property error API violations
In reply to Cornelia HuckFrom: Markus Armbruster <[email protected]>
s390x-cpu property setters set_feature() and set_feature_group() dereference @errp when the visitor fails. That's wrong; see the big comment in error.h. Introduced in commit 0754f60429 "s390x/cpumodel:
expose features and feature groups as properties".
No caller actually passes null.
Fix anyway: splice in a local Error *err, and error_propagate().
Message-Id: <[email protected]>
--- target/s390x/cpu_models.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
target/s390x/cpu_models.c +8 -4
@@ -987,6 +987,7 @@ static void get_feature(Object *obj, Visitor *v, const char *name,static void set_feature (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { +Error *err =NULL ;S390Feat feat = (S390Feat ) opaque;DeviceState *dev =DEVICE (obj);S390CPU *cpu =S390_CPU (obj);
@@ -1002,8 +1003,9 @@ static void set_feature(Object *obj, Visitor *v, const char *name,return ; } -visit_type_bool (v, name, &value, errp); -if (*errp) { +visit_type_bool (v, name, &value, &err); +if (err) { +error_propagate (errp, err);return ; }if (value) {
@@ -1043,6 +1045,7 @@ static void get_feature_group(Object *obj, Visitor *v, const char *name,static void set_feature_group (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) { +Error *err =NULL ;S390FeatGroup group = (S390FeatGroup ) opaque;const S390FeatGroupDef *def =s390_feat_group_def (group);DeviceState *dev =DEVICE (obj);
@@ -1059,8 +1062,9 @@ static void set_feature_group(Object *obj, Visitor *v, const char *name,return ; } -visit_type_bool (v, name, &value, errp); -if (*errp) { +visit_type_bool (v, name, &value, &err); +if (err) { +error_propagate (errp, err);return ; }if (value) {
Signature · 1 line
2.21.0
[PULL 09/16] s390x: Fix cpu normal reset ri clearing
In reply to Cornelia HuckFrom: Janosch Frank <[email protected]>
As it turns out we need to clear the ri controls and PSW enablement bit to be architecture compliant.
Message-Id: <[email protected]>
--- target/s390x/cpu.c | 7 ++++++- target/s390x/cpu.h | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-)
target/s390x/cpu.c +6 -1
@@ -100,7 +100,7 @@ static void s390_cpu_reset(CPUState *s, cpu_reset_type type)case S390_CPU_RESET_INITIAL :/* initial reset does not clear everything! */ memset (&env->start_initial_reset_fields,0 , - offsetof(CPUS390XState , end_reset_fields) - + offsetof(CPUS390XState , start_normal_reset_fields) - offsetof(CPUS390XState , start_initial_reset_fields));/* architectured initial value for Breaking-Event-Address register */
@@ -123,6 +123,11 @@ static void s390_cpu_reset(CPUState *s, cpu_reset_type type) &env->fpu_status);/* fall through */ case S390_CPU_RESET_NORMAL : + env->psw.mask &= ~PSW_MASK_RI ; +memset (&env->start_normal_reset_fields,0 , + offsetof(CPUS390XState , end_reset_fields) - + offsetof(CPUS390XState , start_normal_reset_fields)); + env->pfault_token =-1UL ; env->bpbc = false;break ;
target/s390x/cpu.h +6 -1
@@ -58,7 +58,6 @@ struct CPUS390XState {*/ uint64_t vregs[32][2] QEMU_ALIGNED(16); /* vector registers */uint32_t aregs[16 ];/* access registers */ -uint8_t riccb[64 ];/* runtime instrumentation control */ uint64_t gscb[4 ];/* guarded storage control */ uint64_t etoken;/* etoken */ uint64_t etoken_extension;/* etoken extension */
@@ -114,6 +113,10 @@ struct CPUS390XState {uint64_t gbea;uint64_t pp; +/* Fields up to this point are not cleared by normal CPU reset */ +struct {} start_normal_reset_fields; +uint8_t riccb[64 ];/* runtime instrumentation control */ +/* Fields up to this point are cleared by a CPU reset */ struct {} end_reset_fields;
@@ -252,6 +255,7 @@ extern const VMStateDescription vmstate_s390_cpu;#undef PSW_SHIFT_ASC#undef PSW_MASK_CC#undef PSW_MASK_PM +#undef PSW_MASK_RI#undef PSW_SHIFT_MASK_PM#undef PSW_MASK_64#undef PSW_MASK_32
@@ -273,6 +277,7 @@ extern const VMStateDescription vmstate_s390_cpu;#define PSW_MASK_CC 0x0000300000000000ULL#define PSW_MASK_PM 0x00000F0000000000ULL#define PSW_SHIFT_MASK_PM 40 +#define PSW_MASK_RI 0x0000008000000000ULL#define PSW_MASK_64 0x0000000100000000ULL#define PSW_MASK_32 0x0000000080000000ULL#define PSW_MASK_ESA_ADDR 0x000000007fffffffULL
Signature · 1 line
2.21.0
[PULL 04/16] s390x: Move reset normal to shared reset handler
In reply to Cornelia HuckFrom: Janosch Frank <[email protected]>
Let's start moving the cpu reset functions into a single function with a switch/case, so we can later use fallthroughs and share more code between resets.
This patch introduces the reset function by renaming cpu_reset().
Message-Id: <[email protected]>
--- target/s390x/cpu-qom.h | 6 +++++- target/s390x/cpu.c | 19 +++++++++++++------ target/s390x/cpu.h | 2 +- target/s390x/sigp.c | 2 +- 4 files changed, 20 insertions(+), 9 deletions(-)
target/s390x/cpu-qom.h +5 -1
@@ -34,6 +34,10 @@typedef struct S390CPUModel S390CPUModel ;typedef struct S390CPUDef S390CPUDef ; +typedef enum cpu_reset_type { +S390_CPU_RESET_NORMAL , +}cpu_reset_type ; +/** * S390CPUClass: * @parent_realize: The parent class' realize handler.
@@ -57,7 +61,7 @@ typedef struct S390CPUClass {DeviceRealize parent_realize;void (*parent_reset)(CPUState *cpu);void (*load_normal)(CPUState *cpu); -void (*cpu_reset)(CPUState *cpu); +void (*reset)(CPUState *cpu,cpu_reset_type type);void (*initial_cpu_reset)(CPUState *cpu); } S390CPUClass;
target/s390x/cpu.c +13 -6
@@ -82,18 +82,25 @@ static void s390_cpu_load_normal(CPUState *s) }#endif -/* S390CPUClass::cpu_reset() */ -static void s390_cpu_reset (CPUState *s) +/* S390CPUClass::reset() */ +static void s390_cpu_reset (CPUState *s,cpu_reset_type type) {S390CPU *cpu =S390_CPU (s);S390CPUClass *scc =S390_CPU_GET_CLASS (cpu);CPUS390XState *env = &cpu->env; - env->pfault_token =-1UL ; - env->bpbc = false; scc->parent_reset (s); cpu->env.sigp_order =0 ;s390_cpu_set_state (S390_CPU_STATE_STOPPED , cpu); + +switch (type) { +case S390_CPU_RESET_NORMAL : + env->pfault_token =-1UL ; + env->bpbc = false; +break ; +default : +g_assert_not_reached (); + } }/* S390CPUClass::initial_reset() */
@@ -102,7 +109,7 @@ static void s390_cpu_initial_reset(CPUState *s)S390CPU *cpu =S390_CPU (s);CPUS390XState *env = &cpu->env; -s390_cpu_reset (s); +s390_cpu_reset (s,S390_CPU_RESET_NORMAL );/* initial reset does not clear everything! */ memset(&env->start_initial_reset_fields, 0, offsetof(CPUS390XState, end_reset_fields) -
@@ -473,7 +480,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data)#if !defined(CONFIG_USER_ONLY ) scc->load_normal = s390_cpu_load_normal;#endif - scc->cpu_reset = s390_cpu_reset; + scc->reset = s390_cpu_reset; scc->initial_cpu_reset = s390_cpu_initial_reset; cc->reset = s390_cpu_full_reset; cc->class_by_name = s390_cpu_class_by_name,
target/s390x/cpu.h +1 -1
@@ -741,7 +741,7 @@ static inline void s390_do_cpu_reset(CPUState *cs, run_on_cpu_data arg) {S390CPUClass *scc =S390_CPU_GET_CLASS (cs); - scc->cpu_reset (cs); + scc->reset (cs,S390_CPU_RESET_NORMAL ); }static inline void s390_do_cpu_initial_reset (CPUState *cs,run_on_cpu_data arg)
target/s390x/sigp.c +1 -1
@@ -266,7 +266,7 @@ static void sigp_cpu_reset(CPUState *cs, run_on_cpu_data arg)SigpInfo *si = arg.host_ptr;cpu_synchronize_state (cs); - scc->cpu_reset (cs); + scc->reset (cs,S390_CPU_RESET_NORMAL );cpu_synchronize_post_reset (cs); si->cc =SIGP_CC_ORDER_CODE_ACCEPTED ; }
Signature · 1 line
2.21.0
[PULL 14/16] s390x/cpumodel: Fix query-cpu-definitions error API violations
In reply to Cornelia HuckFrom: Markus Armbruster <[email protected]>
qmp_query_cpu_definitions() passes @errp to get_max_cpu_model(), then frees any error it gets back. This effectively ignores errors. Dereferencing @errp is wrong; see the big comment in error.h. Passing @errp is also wrong, because it works only as long as @errp is neither @error_fatal nor @error_abort. Introduced in commit 38cba1f4d8 "s390x: return unavailable features via query-cpu-definitions".
No caller actually passes such @errp values.
Fix anyway: simply pass NULL to get_max_cpu_model().
Message-Id: <[email protected]>
--- target/s390x/cpu_models.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
target/s390x/cpu_models.c +1 -5
@@ -462,11 +462,7 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) .list = NULL, }; - list_data.model =get_max_cpu_model (errp); -if (*errp) { -error_free (*errp); - *errp =NULL ; - } + list_data.model =get_max_cpu_model (NULL );object_class_foreach (create_cpu_model_list,TYPE_S390_CPU , false, &list_data);
Signature · 1 line
2.21.0
[PULL 05/16] s390x: Move initial reset
In reply to Cornelia HuckFrom: Janosch Frank <[email protected]>
Let's move the intial reset into the reset handler and cleanup afterwards.
Message-Id: <[email protected]>
--- target/s390x/cpu-qom.h | 2 +- target/s390x/cpu.c | 46 +++++++++++++++++------------------------- target/s390x/cpu.h | 2 +- target/s390x/sigp.c | 2 +- 4 files changed, 21 insertions(+), 31 deletions(-)
target/s390x/cpu-qom.h +1 -1
@@ -36,6 +36,7 @@ typedef struct S390CPUDef S390CPUDef;typedef enum cpu_reset_type {S390_CPU_RESET_NORMAL , +S390_CPU_RESET_INITIAL , }cpu_reset_type ;/**
@@ -62,7 +63,6 @@ typedef struct S390CPUClass {void (*parent_reset)(CPUState *cpu);void (*load_normal)(CPUState *cpu);void (*reset)(CPUState *cpu,cpu_reset_type type); -void (*initial_cpu_reset)(CPUState *cpu); } S390CPUClass;typedef struct S390CPU S390CPU ;
target/s390x/cpu.c +18 -28
66 lines not on this page · raw message
target/s390x/cpu.h +1 -1
@@ -748,7 +748,7 @@ static inline void s390_do_cpu_initial_reset(CPUState *cs, run_on_cpu_data arg) {S390CPUClass *scc =S390_CPU_GET_CLASS (cs); - scc->initial_cpu_reset (cs); + scc->reset (cs,S390_CPU_RESET_INITIAL ); }static inline void s390_do_cpu_load_normal (CPUState *cs,run_on_cpu_data arg)
target/s390x/sigp.c +1 -1
@@ -254,7 +254,7 @@ static void sigp_initial_cpu_reset(CPUState *cs, run_on_cpu_data arg)SigpInfo *si = arg.host_ptr;cpu_synchronize_state (cs); - scc->initial_cpu_reset (cs); + scc->reset (cs,S390_CPU_RESET_INITIAL );cpu_synchronize_post_reset (cs); si->cc =SIGP_CC_ORDER_CODE_ACCEPTED ; }
Signature · 1 line
2.21.0
[PULL 02/16] hw: add compat machines for 5.0
In reply to Cornelia HuckAdd 5.0 machine types for arm/i440fx/q35/s390x/spapr.
For i440fx and q35, unversioned cpu models are still translated to -v1; I'll leave changing this (if desired) to the respective maintainers.
Message-Id: <[email protected]>
--- hw/arm/virt.c | 7 ++++++- hw/core/machine.c | 3 +++ hw/i386/pc.c | 3 +++ hw/i386/pc_piix.c | 14 +++++++++++++- hw/i386/pc_q35.c | 13 ++++++++++++- hw/ppc/spapr.c | 15 +++++++++++++-- hw/s390x/s390-virtio-ccw.c | 14 +++++++++++++- include/hw/boards.h | 3 +++ include/hw/i386/pc.h | 3 +++ 9 files changed, 69 insertions(+), 6 deletions(-)
hw/arm/virt.c +6 -1
@@ -2147,10 +2147,15 @@ static void machvirt_machine_init(void) }type_init (machvirt_machine_init); +static void virt_machine_5_0_options (MachineClass *mc) +{ +} +DEFINE_VIRT_MACHINE_AS_LATEST(5, 0) +static void virt_machine_4_2_options (MachineClass *mc) { } -DEFINE_VIRT_MACHINE_AS_LATEST(4, 2) +DEFINE_VIRT_MACHINE(4, 2)static void virt_machine_4_1_options (MachineClass *mc) {
hw/core/machine.c +3 -0
@@ -27,6 +27,9 @@#include "hw/pci/pci.h" #include "hw/mem/nvdimm.h" +GlobalProperty hw_compat_4_2[] = {}; +const size_t hw_compat_4_2_len =G_N_ELEMENTS (hw_compat_4_2); +GlobalProperty hw_compat_4_1[] = { {"virtio-pci" ,"x-pcie-flr-init" ,"off" }, };
hw/i386/pc.c +3 -0
@@ -103,6 +103,9 @@struct hpet_fw_config hpet_cfg = {.count =UINT8_MAX }; +GlobalProperty pc_compat_4_2[] = {}; +const size_t pc_compat_4_2_len =G_N_ELEMENTS (pc_compat_4_2); +GlobalProperty pc_compat_4_1[] = {};const size_t pc_compat_4_1_len =G_N_ELEMENTS (pc_compat_4_1);
hw/i386/pc_piix.c +13 -1
@@ -424,7 +424,7 @@ static void pc_i440fx_machine_options(MachineClass *m)machine_class_allow_dynamic_sysbus_dev (m,TYPE_RAMFB_DEVICE ); } -static void pc_i440fx_4_2_machine_options (MachineClass *m) +static void pc_i440fx_5_0_machine_options (MachineClass *m) {PCMachineClass *pcmc =PC_MACHINE_CLASS (m);pc_i440fx_machine_options (m);
@@ -433,6 +433,18 @@ static void pc_i440fx_4_2_machine_options(MachineClass *m) pcmc->default_cpu_version =1 ; } +DEFINE_I440FX_MACHINE (v5_0,"pc-i440fx-5.0" ,NULL , + pc_i440fx_5_0_machine_options); + +static void pc_i440fx_4_2_machine_options (MachineClass *m) +{ +pc_i440fx_5_0_machine_options (m); + m->alias =NULL ; + m->is_default =0 ; +compat_props_add (m->compat_props, hw_compat_4_2, hw_compat_4_2_len); +compat_props_add (m->compat_props, pc_compat_4_2, pc_compat_4_2_len); +} +DEFINE_I440FX_MACHINE (v4_2,"pc-i440fx-4.2" ,NULL , pc_i440fx_4_2_machine_options);
hw/i386/pc_q35.c +12 -1
@@ -348,7 +348,7 @@ static void pc_q35_machine_options(MachineClass *m) m->max_cpus =288 ; } -static void pc_q35_4_2_machine_options (MachineClass *m) +static void pc_q35_5_0_machine_options (MachineClass *m) {PCMachineClass *pcmc =PC_MACHINE_CLASS (m);pc_q35_machine_options (m);
@@ -356,6 +356,17 @@ static void pc_q35_4_2_machine_options(MachineClass *m) pcmc->default_cpu_version =1 ; } +DEFINE_Q35_MACHINE (v5_0,"pc-q35-5.0" ,NULL , + pc_q35_5_0_machine_options); + +static void pc_q35_4_2_machine_options (MachineClass *m) +{ +pc_q35_5_0_machine_options (m); + m->alias =NULL ; +compat_props_add (m->compat_props, hw_compat_4_2, hw_compat_4_2_len); +compat_props_add (m->compat_props, pc_compat_4_2, pc_compat_4_2_len); +} +DEFINE_Q35_MACHINE (v4_2,"pc-q35-4.2" ,NULL , pc_q35_4_2_machine_options);
hw/ppc/spapr.c +13 -2
@@ -4491,15 +4491,26 @@ static const TypeInfo spapr_machine_info = { } \ type_init(spapr_machine_register_##suffix) +/* +* pseries-5.0 +*/ +static void spapr_machine_5_0_class_options(MachineClass *mc) +{ +/* Defaults for the latest behaviour inherited from the base class */ +} + +DEFINE_SPAPR_MACHINE(5_0, "5.0", true); +/* * pseries-4.2 */ static void spapr_machine_4_2_class_options (MachineClass *mc) { -/* Defaults for the latest behaviour inherited from the base class */ +spapr_machine_5_0_class_options (mc); +compat_props_add (mc->compat_props, hw_compat_4_2, hw_compat_4_2_len); } -DEFINE_SPAPR_MACHINE(4_2, "4.2", true); +DEFINE_SPAPR_MACHINE(4_2, "4.2", false);/* * pseries-4.1
hw/s390x/s390-virtio-ccw.c +13 -1
@@ -639,14 +639,26 @@ bool css_migration_enabled(void) } \ type_init(ccw_machine_register_##suffix) +static void ccw_machine_5_0_instance_options(MachineState *machine) +{ +} + +static void ccw_machine_5_0_class_options (MachineClass *mc) +{ +} +DEFINE_CCW_MACHINE(5_0, "5.0", true); +static void ccw_machine_4_2_instance_options (MachineState *machine) { +ccw_machine_5_0_instance_options (machine); }static void ccw_machine_4_2_class_options (MachineClass *mc) { +ccw_machine_5_0_class_options (mc); +compat_props_add (mc->compat_props, hw_compat_4_2, hw_compat_4_2_len); } -DEFINE_CCW_MACHINE(4_2, "4.2", true); +DEFINE_CCW_MACHINE(4_2, "4.2", false);static void ccw_machine_4_1_instance_options (MachineState *machine) {
include/hw/boards.h +3 -0
@@ -329,6 +329,9 @@ struct MachineState { } \ type_init(machine_initfn##_register_types) +extern GlobalProperty hw_compat_4_2[]; +extern const size_t hw_compat_4_2_len; +extern GlobalProperty hw_compat_4_1[];extern const size_t hw_compat_4_1_len;
include/hw/i386/pc.h +3 -0
@@ -237,6 +237,9 @@ void pc_system_firmware_init(PCMachineState *pcms, MemoryRegion *rom_memory);void pc_madt_cpu_entry (AcpiDeviceIf *adev,int uid,const CPUArchIdList *apic_ids,GArray *entry); +extern GlobalProperty pc_compat_4_2[]; +extern const size_t pc_compat_4_2_len; +extern GlobalProperty pc_compat_4_1[];extern const size_t pc_compat_4_1_len;
Signature · 1 line
2.21.0
[PULL 01/16] vfio-ccw: Fix error message
In reply to Cornelia HuckFrom: Boris Fiuczynski <[email protected]>
Message-Id: <[email protected]>
--- hw/vfio/ccw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/vfio/ccw.c +1 -1
@@ -102,7 +102,7 @@ again:if (errno ==EAGAIN ) { goto again; } -error_report ("vfio-ccw: wirte I/O region failed with errno=%d" , errno); +error_report ("vfio-ccw: write I/O region failed with errno=%d" , errno); ret = -errno; }else { ret = region->ret_code;
Signature · 1 line
2.21.0
[PULL 08/16] s390x: kvm: Make kvm_sclp_service_call void
In reply to Cornelia HuckFrom: Janosch Frank <[email protected]>
It defaults to returning 0 anyway and that return value is not necessary, as 0 is also the default rc that the caller would return.
While doing that we can simplify the logic a bit and return early if we inject a PGM exception.
Message-Id: <[email protected]>
--- target/s390x/kvm.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
target/s390x/kvm.c +5 -7
@@ -1159,13 +1159,13 @@ void kvm_s390_access_exception(S390CPU *cpu, uint16_t code, uint64_t te_code)kvm_s390_vcpu_interrupt (cpu, &irq); } -static int kvm_sclp_service_call (S390CPU *cpu,struct kvm_run *run, +static void kvm_sclp_service_call (S390CPU *cpu,struct kvm_run *run,uint16_t ipbh0) {CPUS390XState *env = &cpu->env;uint64_t sccb;uint32_t code; -int r =0 ; +int r; sccb = env->regs[ipbh0 &0xf ]; code = env->regs[(ipbh0 &0xf0 ) >>4 ];
@@ -1173,11 +1173,9 @@ static int kvm_sclp_service_call(S390CPU *cpu, struct kvm_run *run, r =sclp_service_call (env, sccb, code);if (r <0 ) {kvm_s390_program_interrupt (cpu, -r); - }else { -setcc (cpu, r); +return ; } - -return 0 ; +setcc (cpu, r); }static int handle_b2 (S390CPU *cpu,struct kvm_run *run,uint8_t ipa1)
@@ -1240,7 +1238,7 @@ static int handle_b2(S390CPU *cpu, struct kvm_run *run, uint8_t ipa1)setcc (cpu,3 );break ;case PRIV_B2_SCLP_CALL : - rc =kvm_sclp_service_call (cpu, run, ipbh0); +kvm_sclp_service_call (cpu, run, ipbh0);break ;default : rc =-1 ;
Signature · 1 line
2.21.0
[PULL 07/16] s390x: Beautify diag308 handling
In reply to Cornelia HuckFrom: Janosch Frank <[email protected]>
Let's improve readability by:
* Using constants for the subcodes
* Moving parameter checking into a function
* Removing subcode > 6 check as the default case catches that
Message-Id: <[email protected]>
--- target/s390x/diag.c | 54 +++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 22 deletions(-)
target/s390x/diag.c +32 -22
@@ -53,6 +53,29 @@ int handle_diag_288(CPUS390XState *env, uint64_t r1, uint64_t r3)#define DIAG_308_RC_NO_CONF 0x0102#define DIAG_308_RC_INVALID 0x0402 +#define DIAG308_RESET_MOD_CLR 0 +#define DIAG308_RESET_LOAD_NORM 1 +#define DIAG308_LOAD_CLEAR 3 +#define DIAG308_LOAD_NORMAL_DUMP 4 +#define DIAG308_SET 5 +#define DIAG308_STORE 6 + +static int diag308_parm_check (CPUS390XState *env,uint64_t r1,uint64_t addr, +uintptr_t ra,bool write) +{ +if ((r1 &1 ) || (addr & ~TARGET_PAGE_MASK )) { +s390_program_interrupt (env,PGM_SPECIFICATION , ra); +return -1 ; + } +if (!address_space_access_valid (&address_space_memory, addr, +sizeof (IplParameterBlock), write, +MEMTXATTRS_UNSPECIFIED )) { +s390_program_interrupt (env,PGM_ADDRESSING , ra); +return -1 ; + } +return 0 ; +} +void handle_diag_308 (CPUS390XState *env,uint64_t r1,uint64_t r3,uintptr_t ra) {CPUState *cs =env_cpu (env);
@@ -65,30 +88,24 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3, uintptr_t ra)return ; } -if ((subcode & ~0x0ffffULL ) || (subcode >6 )) { +if (subcode & ~0x0ffffULL ) {s390_program_interrupt (env,PGM_SPECIFICATION , ra);return ; }switch (subcode) { -case 0 : +case DIAG308_RESET_MOD_CLR :s390_ipl_reset_request (cs,S390_RESET_MODIFIED_CLEAR );break ; -case 1 : +case DIAG308_RESET_LOAD_NORM :s390_ipl_reset_request (cs,S390_RESET_LOAD_NORMAL );break ; -case 3 : +case DIAG308_LOAD_CLEAR : +/* Well we still lack the clearing bit... */ s390_ipl_reset_request (cs,S390_RESET_REIPL );break ; -case 5 : -if ((r1 &1 ) || (addr &0x0fffULL )) { -s390_program_interrupt (env,PGM_SPECIFICATION , ra); -return ; - } -if (!address_space_access_valid (&address_space_memory, addr, -sizeof (IplParameterBlock), false, -MEMTXATTRS_UNSPECIFIED )) { -s390_program_interrupt (env,PGM_ADDRESSING , ra); +case DIAG308_SET : +if (diag308_parm_check (env, r1, addr, ra, false)) {return ; } iplb =g_new0 (IplParameterBlock,1 );
@@ -110,15 +127,8 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3, uintptr_t ra) out:g_free (iplb);return ; -case 6 : -if ((r1 &1 ) || (addr &0x0fffULL )) { -s390_program_interrupt (env,PGM_SPECIFICATION , ra); -return ; - } -if (!address_space_access_valid (&address_space_memory, addr, -sizeof (IplParameterBlock), true, -MEMTXATTRS_UNSPECIFIED )) { -s390_program_interrupt (env,PGM_ADDRESSING , ra); +case DIAG308_STORE : +if (diag308_parm_check (env, r1, addr, ra, true)) {return ; } iplb =s390_ipl_get_iplb ();
Signature · 1 line
2.21.0
The following changes since commit b0ca999a43a22b38158a222233d3f5881648bb4f:
Update version for v4.2.0 release (2019-12-12 16:45:57 +0000)
are available in the Git repository at:
https://github.com/cohuck/qemu tags/s390x-20191213
for you to fetch changes up to b147562019dd845a224cde7a37c219f9848d1b8d:
qga: fence guest-set-time if hwclock not available (2019-12-13 12:16:50 +0100)
----------------------------------------------------------------
First s390x update for 5.0:
- compat machines (also for other architectures)
- cleanups and fixes in reset handling
- fence off guest-set-time, as we have no hwclock
- fix some misuses of the error API
- further cleanups
----------------------------------------------------------------
Boris Fiuczynski (1):
vfio-ccw: Fix error message
Cornelia Huck (3):
hw: add compat machines for 5.0
s390x/tcg: clear local interrupts on reset normal
qga: fence guest-set-time if hwclock not available
Janosch Frank (7):
s390x: Don't do a normal reset on the initial cpu
s390x: Move reset normal to shared reset handler
s390x: Move initial reset
s390x: Move clear reset
s390x: Beautify diag308 handling
s390x: kvm: Make kvm_sclp_service_call void
s390x: Fix cpu normal reset ri clearing
Markus Armbruster (5):
s390x/event-facility: Fix realize() error API violations s390x/cpumodel: Fix feature property error API violations s390x/cpumodel: Fix realize() error API violations s390x/cpumodel: Fix query-cpu-model-FOO error API violations s390x/cpumodel: Fix query-cpu-definitions error API violations
hw/arm/virt.c | 7 ++- hw/core/machine.c | 3 + hw/i386/pc.c | 3 + hw/i386/pc_piix.c | 14 ++++- hw/i386/pc_q35.c | 13 ++++- hw/ppc/spapr.c | 15 ++++- hw/s390x/event-facility.c | 6 +- hw/s390x/s390-virtio-ccw.c | 17 +++++- hw/vfio/ccw.c | 2 +- include/hw/boards.h | 3 + include/hw/i386/pc.h | 3 + qga/commands-posix.c | 13 ++++- target/s390x/cpu-qom.h | 9 ++- target/s390x/cpu.c | 112 +++++++++++++++---------------------- target/s390x/cpu.h | 19 ++++--- target/s390x/cpu_models.c | 98 +++++++++++++++++++------------- target/s390x/diag.c | 54 ++++++++++-------- target/s390x/kvm.c | 12 ++-- target/s390x/sigp.c | 4 +- 19 files changed, 250 insertions(+), 157 deletions(-)
Signature · 1 line
2.21.0
[PULL 15/16] s390x/tcg: clear local interrupts on reset normal
We neglected to clean up pending interrupts and emergency signals; fix that.
Message-Id: <[email protected]>
--- target/s390x/cpu.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
target/s390x/cpu.h +4 -4
@@ -98,10 +98,6 @@ struct CPUS390XState {uint64_t cregs[16 ];/* control registers */ -int pending_int; -uint16_t external_call_addr; -DECLARE_BITMAP (emergency_signals,S390_MAX_CPUS ); -uint64_t ckc;uint64_t cputm;uint32_t todpr;
@@ -117,6 +113,10 @@ struct CPUS390XState {struct {} start_normal_reset_fields;uint8_t riccb[64 ];/* runtime instrumentation control */ +int pending_int; +uint16_t external_call_addr; +DECLARE_BITMAP (emergency_signals,S390_MAX_CPUS ); +/* Fields up to this point are cleared by a CPU reset */ struct {} end_reset_fields;
Signature · 1 line
2.21.0
[PULL 13/16] s390x/cpumodel: Fix query-cpu-model-FOO error API violations
In reply to Cornelia HuckFrom: Markus Armbruster <[email protected]>
cpu_model_from_info() is a helper for qmp_query_cpu_model_expansion(), qmp_query_cpu_model_comparison(), qmp_query_cpu_model_baseline(). It dereferences @errp when the visitor or the QOM setter fails. That's wrong; see the big comment in error.h. Introduced in commit 137974cea3 's390x/cpumodel: implement QMP interface "query-cpu-model-expansion"'.
Its three callers have the same issue. Introduced in commit 4e82ef0502 's390x/cpumodel: implement QMP interface "query-cpu-model-comparison"' and commit f1a47d08ef 's390x/cpumodel:
implement QMP interface "query-cpu-model-baseline"'.
No caller actually passes null.
Fix anyway: splice in a local Error *err, and error_propagate().
Message-Id: <[email protected]>
--- target/s390x/cpu_models.c | 43 ++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 16 deletions(-)
target/s390x/cpu_models.c +27 -16
@@ -477,6 +477,7 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)static void cpu_model_from_info (S390CPUModel *model,const CpuModelInfo *info,Error **errp) { +Error *err =NULL ;const QDict *qdict =NULL ;const QDictEntry *e;Visitor *visitor;
@@ -513,24 +514,26 @@ static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info,if (qdict) { visitor =qobject_input_visitor_new (info->props); -visit_start_struct (visitor,NULL ,NULL ,0 , errp); -if (*errp) { +visit_start_struct (visitor,NULL ,NULL ,0 , &err); +if (err) { +error_propagate (errp, err);visit_free (visitor);object_unref (obj);return ; }for (e =qdict_first (qdict); e; e =qdict_next (qdict, e)) { -object_property_set (obj, visitor, e->key, errp); -if (*errp) { +object_property_set (obj, visitor, e->key, &err); +if (err) {break ; } } -if (!*errp) { +if (!err) {visit_check_struct (visitor, errp); }visit_end_struct (visitor,NULL );visit_free (visitor); -if (*errp) { +if (err) { +error_propagate (errp, err);object_unref (obj);return ; }
@@ -595,13 +598,15 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type, CpuModelInfo *model, Error **errp) { +Error *err =NULL ;CpuModelExpansionInfo *expansion_info =NULL ;S390CPUModel s390_model;bool delta_changes = false;/* convert it to our internal representation */ -cpu_model_from_info (&s390_model, model, errp); -if (*errp) { +cpu_model_from_info (&s390_model, model, &err); +if (err) { +error_propagate (errp, err);return NULL ; }
@@ -634,18 +639,21 @@ CpuModelCompareInfo *qmp_query_cpu_model_comparison(CpuModelInfo *infoa, CpuModelInfo *infob, Error **errp) { +Error *err =NULL ;CpuModelCompareResult feat_result, gen_result;CpuModelCompareInfo *compare_info;S390FeatBitmap missing, added;S390CPUModel modela, modelb;/* convert both models to our internal representation */ -cpu_model_from_info (&modela, infoa, errp); -if (*errp) { +cpu_model_from_info (&modela, infoa, &err); +if (err) { +error_propagate (errp, err);return NULL ; } -cpu_model_from_info (&modelb, infob, errp); -if (*errp) { +cpu_model_from_info (&modelb, infob, &err); +if (err) { +error_propagate (errp, err);return NULL ; } compare_info =g_new0 (CpuModelCompareInfo,1 );
@@ -707,6 +715,7 @@ CpuModelBaselineInfo *qmp_query_cpu_model_baseline(CpuModelInfo *infoa, CpuModelInfo *infob, Error **errp) { +Error *err =NULL ;CpuModelBaselineInfo *baseline_info;S390CPUModel modela, modelb, model;uint16_t cpu_type;
@@ -714,13 +723,15 @@ CpuModelBaselineInfo *qmp_query_cpu_model_baseline(CpuModelInfo *infoa,uint8_t max_gen;/* convert both models to our internal representation */ -cpu_model_from_info (&modela, infoa, errp); -if (*errp) { +cpu_model_from_info (&modela, infoa, &err); +if (err) { +error_propagate (errp, err);return NULL ; } -cpu_model_from_info (&modelb, infob, errp); -if (*errp) { +cpu_model_from_info (&modelb, infob, &err); +if (err) { +error_propagate (errp, err);return NULL ; }
Signature · 1 line
2.21.0
[PULL 10/16] s390x/event-facility: Fix realize() error API violations
In reply to Cornelia HuckFrom: Markus Armbruster <[email protected]>
sclp_events_bus_realize() dereferences @errp when object_property_set_bool() fails. That's wrong; see the big comment in error.h. Introduced in commit f6102c329c "s390/sclp: rework sclp event facility initialization + device realization".
No caller actually passes null.
Fix anyway: splice in a local Error *err, and error_propagate().
Message-Id: <[email protected]>
--- hw/s390x/event-facility.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
hw/s390x/event-facility.c +4 -2
@@ -339,14 +339,16 @@ out:static void sclp_events_bus_realize (BusState *bus,Error **errp) { +Error *err =NULL ;BusChild *kid;/* TODO: recursive realization has to be done in common code */ QTAILQ_FOREACH(kid, &bus->children, sibling) {DeviceState *dev = kid->child; -object_property_set_bool (OBJECT (dev), true,"realized" , errp); -if (*errp) { +object_property_set_bool (OBJECT (dev), true,"realized" , &err); +if (errp) { +error_propagate (errp, err);return ; } }
Signature · 1 line
2.21.0
[PULL 12/16] s390x/cpumodel: Fix realize() error API violations
In reply to Cornelia HuckFrom: Markus Armbruster <[email protected]>
get_max_cpu_model() dereferences @errp when kvm_s390_get_host_cpu_model() fails, apply_cpu_model() dereferences it when kvm_s390_apply_cpu_model() fails, and s390_realize_cpu_model() dereferences it when get_max_cpu_model() or check_compatibility() fail. That's wrong; see the big comment in error.h. All three introduced in commit 80560137cf "s390x/cpumodel: check and apply the CPU model".
No caller actually passes null.
Fix anyway: splice in a local Error *err, and error_propagate().
Message-Id: <[email protected]>
--- target/s390x/cpu_models.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-)
target/s390x/cpu_models.c +22 -15
@@ -870,6 +870,7 @@ static void check_compatibility(const S390CPUModel *max_model,static S390CPUModel *get_max_cpu_model (Error **errp) { +Error *err =NULL ;static S390CPUModel max_model;static bool cached;
@@ -878,22 +879,24 @@ static S390CPUModel *get_max_cpu_model(Error **errp) }if (kvm_enabled ()) { -kvm_s390_get_host_cpu_model (&max_model, errp); +kvm_s390_get_host_cpu_model (&max_model, &err); }else { max_model.def =s390_find_cpu_def (QEMU_MAX_CPU_TYPE ,QEMU_MAX_CPU_GEN ,QEMU_MAX_CPU_EC_GA ,NULL );bitmap_copy (max_model.features, qemu_max_cpu_feat,S390_FEAT_MAX ); - } -if (!*errp) { - cached = true; -return &max_model; } -return NULL ; +if (err) { +error_propagate (errp, err); +return NULL ; + } + cached = true; +return &max_model; }static inline void apply_cpu_model (const S390CPUModel *model,Error **errp) {#ifndef CONFIG_USER_ONLY +Error *err =NULL ;static S390CPUModel applied_model;static bool applied;
@@ -909,20 +912,23 @@ static inline void apply_cpu_model(const S390CPUModel *model, Error **errp) }if (kvm_enabled ()) { -kvm_s390_apply_cpu_model (model, errp); +kvm_s390_apply_cpu_model (model, &err); +if (err) { +error_propagate (errp, err); +return ; + } } -if (!*errp) { - applied = true; -if (model) { - applied_model = *model; - } + applied = true; +if (model) { + applied_model = *model; }#endif }void s390_realize_cpu_model (CPUState *cs,Error **errp) { +Error *err =NULL ;S390CPUClass *xcc =S390_CPU_GET_CLASS (cs);S390CPU *cpu =S390_CPU (cs);const S390CPUModel *max_model;
@@ -939,7 +945,7 @@ void s390_realize_cpu_model(CPUState *cs, Error **errp) } max_model =get_max_cpu_model (errp); -if (*errp) { +if (!max_model) {error_prepend (errp,"CPU models are not available: " );return ; }
@@ -951,8 +957,9 @@ void s390_realize_cpu_model(CPUState *cs, Error **errp) cpu->model->cpu_ver = max_model->cpu_ver;check_consistency (cpu->model); -check_compatibility (max_model, cpu->model, errp); -if (*errp) { +check_compatibility (max_model, cpu->model, &err); +if (err) { +error_propagate (errp, err);return ; }
Signature · 1 line
2.21.0
Quoted 21 lines · Cornelia Huck
The following changes since commit
b0ca999a43a22b38158a222233d3f5881648bb4f:Update version for v4.2.0 release (2019-12-12 16:45:57 +0000)
are available in the Git repository at:
https://github.com/cohuck/qemu tags/s390x-20191213
for you to fetch changes up to
b147562019dd845a224cde7a37c219f9848d1b8d:qga: fence guest-set-time if hwclock not available (2019-12-13 12:16:50 +0100)
----------------------------------------------------------------
First s390x update for 5.0:
- compat machines (also for other architectures)
- cleanups and fixes in reset handling
- fence off guest-set-time, as we have no hwclock
- fix some misuses of the error API
- further cleanups
Quoted 2 lines
----------------------------------------------------------------
Hi -- this has conflicts. Most of them I could probably fix up, but this one in particular:
hw/s390x/s390-virtio-ccw.c +0 -0
@@@ -645,9 -658,10 +658,13 @@@ static void ccw_machine_4_2_instance_op
static void ccw_machine_4_2_class_options(MachineClass *mc) {
++<<<<<<< HEAD
++=======
+ ccw_machine_5_0_class_options(mc);
++>>>>>>> remotes/cohuck/tags/s390x-20191213
compat_props_add(mc->compat_props, hw_compat_4_2, hw_compat_4_2_len);
}
- DEFINE_CCW_MACHINE(4_2, "4.2", true);
+ DEFINE_CCW_MACHINE(4_2, "4.2", false);
static void ccw_machine_4_1_instance_options(MachineState *machine)
{I don't know whether we want the 'true' or 'false' version...
Could you rebase and resend, please?
thanks
-- PMM
[PULL 03/16] s390x: Don't do a normal reset on the initial cpu
In reply to Cornelia HuckFrom: Janosch Frank <[email protected]>
The initiating cpu needs to be reset with an initial reset. While doing a normal reset followed by a initial reset is not wrong per se, the Ultravisor will only allow the correct reset to be performed.
Message-Id: <[email protected]>
--- hw/s390x/s390-virtio-ccw.c | 3 +++ 1 file changed, 3 insertions(+)
hw/s390x/s390-virtio-ccw.c +3 -0
@@ -348,6 +348,9 @@ static void s390_machine_reset(MachineState *machine)break ;case S390_RESET_LOAD_NORMAL : CPU_FOREACH(t) { +if (t == cs) { +continue ; + }run_on_cpu (t, s390_do_cpu_reset,RUN_ON_CPU_NULL ); }subsystem_reset ();
Signature · 1 line
2.21.0
[PULL 06/16] s390x: Move clear reset
In reply to Cornelia HuckFrom: Janosch Frank <[email protected]>
Let's also move the clear reset function into the reset handler.
Message-Id: <[email protected]>
--- target/s390x/cpu-qom.h | 1 + target/s390x/cpu.c | 58 +++++++++++++----------------------------- 2 files changed, 18 insertions(+), 41 deletions(-)
target/s390x/cpu-qom.h +1 -0
@@ -37,6 +37,7 @@ typedef struct S390CPUDef S390CPUDef;typedef enum cpu_reset_type {S390_CPU_RESET_NORMAL ,S390_CPU_RESET_INITIAL , +S390_CPU_RESET_CLEAR , }cpu_reset_type ;/**
target/s390x/cpu.c +17 -41
88 lines not on this page · raw message
Signature · 1 line
2.21.0
[PULL 16/16] qga: fence guest-set-time if hwclock not available
In reply to Cornelia HuckThe Posix implementation of guest-set-time invokes hwclock to set/retrieve the time to/from the hardware clock. If hwclock is not available, the user is currently informed that "hwclock failed to set hardware clock to system time", which is quite misleading. This may happen e.g. on s390x, which has a different timekeeping concept anyway.
Let's check for the availability of the hwclock command and return QERR_UNSUPPORTED for guest-set-time if it is not available.
Message-Id: <[email protected]>
--- qga/commands-posix.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
qga/commands-posix.c +12 -1
@@ -156,6 +156,17 @@ void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)pid_t pid;Error *local_err =NULL ;struct timeval tv; +static const char hwclock_path[] ="/sbin/hwclock" ; +static int hwclock_available =-1 ; + +if (hwclock_available <0 ) { + hwclock_available = (access (hwclock_path,X_OK ) ==0 ); + } + +if (!hwclock_available) { +error_setg (errp,QERR_UNSUPPORTED ); +return ; + }/* If user has passed a time, validate and set it. */ if (has_time) {
@@ -195,7 +206,7 @@ void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)/* Use '/sbin/hwclock -w' to set RTC from the system time, * or '/sbin/hwclock -s' to set the system time from RTC. */ -execle ("/sbin/hwclock" ,"hwclock" , has_time ?"-w" :"-s" , +execle (hwclock_path,"hwclock" , has_time ?"-w" :"-s" ,NULL , environ);_exit (EXIT_FAILURE ); }else if (pid <0 ) {
Signature · 1 line
2.21.0
Quoted 49 lines · On Fri, 13 Dec 2019 21:12:18 +0000 Peter Maydell <[email protected]>…
Quoted 21 lines · Cornelia Huck
The following changes since commit
b0ca999a43a22b38158a222233d3f5881648bb4f:Update version for v4.2.0 release (2019-12-12 16:45:57 +0000)
are available in the Git repository at:
https://github.com/cohuck/qemu tags/s390x-20191213
for you to fetch changes up to
b147562019dd845a224cde7a37c219f9848d1b8d:qga: fence guest-set-time if hwclock not available (2019-12-13 12:16:50 +0100)
----------------------------------------------------------------
First s390x update for 5.0:
- compat machines (also for other architectures)
- cleanups and fixes in reset handling
- fence off guest-set-time, as we have no hwclock
- fix some misuses of the error API
- further cleanupsQuoted 2 lines
----------------------------------------------------------------
Hi -- this has conflicts. Most of them I could probably fix up, but this one in particular:
hw/s390x/s390-virtio-ccw.c +5
-1@@@ -645,9 -658,10 +658,13 @@@ static void ccw_machine_4_2_instance_opstatic void ccw_machine_4_2_class_options (MachineClass *mc) { ++<<<<<<< HEAD ++======= +ccw_machine_5_0_class_options (mc); ++>>>>>>> remotes/cohuck/tags/s390x-20191213compat_props_add (mc->compat_props, hw_compat_4_2, hw_compat_4_2_len); } - DEFINE_CCW_MACHINE(4_2, "4.2", true); + DEFINE_CCW_MACHINE(4_2, "4.2", false);static void ccw_machine_4_1_instance_options (MachineState *machine) {
Quoted 7 lines
I don't know whether we want the 'true' or 'false' version...
Could you rebase and resend, please?
thanks
-- PMM
Yes, that's because 5f2585772fff ("virtio-blk: advertise F_WCE (F_FLUSH) if F_CONFIG_WCE is advertised") introduced 4.2 compat options before introducing the 5.0 machine types :/
Will send a rebased version.