more ais fixups
v3 cover more ais fixups
I think Patches 1 and 2 are undisputed.
Patch 1 needs to go into 2.10.1 as well.
Patch 2 is for 2.11
Patch 3 is still under discussion if this is the right solution
v2->v3:
- add the ais removal from the z14 cpu model
- fix indent
Christian Borntraeger (3):
s390x/cpumodel: remove ais from z14 default model-> also for 2.10.1 s390x/ais: enable ais when migration is available s390x/ais: disable ais for compat machines
hw/intc/s390_flic.c | 8 ++------ hw/intc/s390_flic_kvm.c | 18 +++++++++++++----- hw/s390x/css.c | 4 ++-- hw/s390x/s390-virtio-ccw.c | 20 +++++++++++++++++--- include/hw/s390x/s390-virtio-ccw.h | 3 +++ include/hw/s390x/s390_flic.h | 1 - target/s390x/gen-features.c | 1 - target/s390x/kvm.c | 10 ++-------- 8 files changed, 39 insertions(+), 26 deletions(-)
Signature · 1 line
2.9.4
PATCH v3 1/3 s390x/cpumodel: remove ais from z14 default model-> also for 2.10.1
We disabled ais for 2.10 lets also remove it from the z14 default model.
--- target/s390x/gen-features.c | 1 - 1 file changed, 1 deletion(-)
target/s390x/gen-features.c +0 -1
@@ -527,7 +527,6 @@ static uint16_t default_GEN13_GA1[] = {#define default_GEN13_GA2 EmptyFeatstatic uint16_t default_GEN14_GA1[] = { -S390_FEAT_ADAPTER_INT_SUPPRESSION ,S390_FEAT_INSTRUCTION_EXEC_PROT ,S390_FEAT_GUARDED_STORAGE ,S390_FEAT_VECTOR_PACKED_DECIMAL ,
Signature · 1 line
2.9.4
Re: [Qemu-devel] [PATCH v3 1/3] s390x/cpumodel: remove ais from z14 default model-> also for 2.10.1
Quoted 1 line · On Wed, 27 Sep 2017 09:20:28 +0200 Christian Borntraeger…
We disabled ais for 2.10 lets also remove it from the z14 default model.
s/lets/, so let's/
Quoted 12 lines
Fixes 3f2d07b3b01e s390x/ais: for 2.10 stable: disable ais facilitySigned-off-by Christian Borntraeger <[email protected]>--- target/s390x/gen-features.c | 1 - 1 file changed, 1 deletion(-)target/s390x/gen-features.c +0
-0
target/s390x/gen-features.c static uint16_t default_GEN13_GA1[] = { · line 532
Quoted 7 lines
target/s390x/gen-features.c +0
-1@@ -527,7 +527,6 @@ static uint16_t default_GEN13_GA1[] = {#define default_GEN13_GA2 EmptyFeatstatic uint16_t default_GEN14_GA1[] = { -S390_FEAT_ADAPTER_INT_SUPPRESSION ,S390_FEAT_INSTRUCTION_EXEC_PROT ,S390_FEAT_GUARDED_STORAGE ,S390_FEAT_VECTOR_PACKED_DECIMAL ,
Thanks, fixed description and applied to s390-fixes.
PATCH v3 2/3 s390x/ais: enable ais when migration is available
In reply to Christian BorntraegerInstead of unconditionally enabling the KVM AIS capability in the kvm arch init function, do this in the flic realize function when we know if migration is available. This requires to initialize flic before the CPUs (and cpu models).
--- hw/intc/s390_flic.c | 8 ++------ hw/intc/s390_flic_kvm.c | 16 +++++++++++----- hw/s390x/css.c | 4 ++-- hw/s390x/s390-virtio-ccw.c | 10 +++++++--- include/hw/s390x/s390_flic.h | 1 - target/s390x/kvm.c | 10 ++-------- 6 files changed, 24 insertions(+), 25 deletions(-)
hw/intc/s390_flic.c +2 -6
@@ -1,7 +1,7 @@/* * QEMU S390x floating interrupt controller (flic) * -* Copyright 2014 IBM Corp. +* Copyright IBM Corp. 2014, 2017 * Author(s): Jens Freimann <[email protected]> * Cornelia Huck <[email protected]> *
@@ -136,9 +136,7 @@ static void qemu_s390_flic_reset(DeviceState *dev)bool ais_needed (void *opaque) { -S390FLICState *s = opaque; - -return s->ais_supported; +return s390_has_feat (S390_FEAT_ADAPTER_INT_SUPPRESSION ); }static const VMStateDescription qemu_s390_flic_vmstate = {
@@ -185,8 +183,6 @@ static void s390_flic_common_realize(DeviceState *dev, Error **errp) " (%d > %d)", max_batch, ADAPTER_ROUTES_MAX_GSI);return ; } - - fs->ais_supported =s390_has_feat (S390_FEAT_ADAPTER_INT_SUPPRESSION ); }static void s390_flic_class_init (ObjectClass *oc,void *data)
hw/intc/s390_flic_kvm.c +11 -5
@@ -1,7 +1,7 @@/* * QEMU S390x KVM floating interrupt controller (flic) * -* Copyright 2014 IBM Corp. +* Copyright IBM Corp. 2014, 2017 * Author(s): Jens Freimann <[email protected]> * Cornelia Huck <[email protected]> *
@@ -164,7 +164,7 @@ static int kvm_s390_modify_ais_mode(S390FLICState *fs, uint8_t isc, .addr = (uint64_t)&req, }; -if (!fs->ais_supported) { +if (!s390_has_feat (S390_FEAT_ADAPTER_INT_SUPPRESSION )) {return -ENOSYS ; }
@@ -181,7 +181,7 @@ static int kvm_s390_inject_airq(S390FLICState *fs, uint8_t type, .attr = id, }; -if (!fs->ais_supported) { +if (!s390_has_feat (S390_FEAT_ADAPTER_INT_SUPPRESSION )) {return -ENOSYS ; }
@@ -459,7 +459,7 @@ static int kvm_flic_ais_post_load(void *opaque, int version_id)* migration from a host that has AIS to a host that has no AIS. * In that case the target system will reject the migration here. */ -if (!ais_needed (flic)) { +if (!s390_has_feat (S390_FEAT_ADAPTER_INT_SUPPRESSION )) {return -ENOSYS ; }
@@ -557,6 +557,12 @@ static void kvm_s390_flic_realize(DeviceState *dev, Error **errp) test_attr.group =KVM_DEV_FLIC_CLEAR_IO_IRQ ; flic_state->clear_io_supported = !ioctl (flic_state->fd,KVM_HAS_DEVICE_ATTR , test_attr); +/* try enable the AIS facility */ + test_attr.group =KVM_DEV_FLIC_AISM_ALL ; +if (!ioctl (flic_state->fd,KVM_HAS_DEVICE_ATTR , test_attr)) { +kvm_vm_enable_cap (kvm_state,KVM_CAP_S390_AIS ,0 ); + } +return ; fail:error_propagate (errp, errp_local);
@@ -578,7 +584,7 @@ static void kvm_s390_flic_reset(DeviceState *dev)flic_disable_wait_pfault (flic); -if (fs->ais_supported) { +if (s390_has_feat (S390_FEAT_ADAPTER_INT_SUPPRESSION )) {for (isc =0 ; isc <=MAX_ISC ; isc++) { rc =kvm_s390_modify_ais_mode (fs, isc,SIC_IRQ_MODE_ALL );if (rc) {
hw/s390x/css.c +2 -2
@@ -1,7 +1,7 @@/* * Channel subsystem base support. * -* Copyright 2012 IBM Corp. +* Copyright IBM Corp. 2012, 2017 * Author(s): Cornelia Huck <[email protected]> * * This work is licensed under the terms of the GNU GPL, version 2 or (at
@@ -672,7 +672,7 @@ void css_adapter_interrupt(CssIoAdapterType type, uint8_t isc) }trace_css_adapter_interrupt (isc); -if (fs->ais_supported) { +if (s390_has_feat (S390_FEAT_ADAPTER_INT_SUPPRESSION )) {if (fsc->inject_airq (fs, type, isc, adapter->flags)) {error_report ("Failed to inject airq with AIS supported" );exit (1 );
hw/s390x/s390-virtio-ccw.c +7 -3
@@ -1,7 +1,7 @@/* * virtio ccw machine * -* Copyright 2012 IBM Corp. +* Copyright IBM Corp. 2012, 2017 * Copyright (c) 2009 Alexander Graf <[email protected]> * Author(s): Cornelia Huck <[email protected]> *
@@ -279,11 +279,15 @@ static void ccw_init(MachineState *machine)s390_sclp_init ();s390_memory_init (machine->ram_size); +/* +* This might also enable some KVM features like AIS, so it must +* be called before the CPU model +*/ +s390_flic_init (); +/* init CPUs (incl. CPU model) early so s390_has_feature() works */ s390_init_cpus (machine); -s390_flic_init (); -/* get a BUS */ css_bus =virtual_css_bus_init (); s390_init_ipl_dev(machine->kernel_filename, machine->kernel_cmdline,
include/hw/s390x/s390_flic.h +0 -1
@@ -44,7 +44,6 @@ typedef struct S390FLICState {SysBusDevice parent_obj;/* to limit AdapterRoutes.num_routes for compat */ uint32_t adapter_routes_max_batch; -bool ais_supported; } S390FLICState;#define S390_FLIC_COMMON_CLASS (klass) \
target/s390x/kvm.c +2 -8
@@ -2,7 +2,7 @@* QEMU S390x KVM implementation * * Copyright (c) 2009 Alexander Graf <[email protected]> -* Copyright IBM Corp. 2012 +* Copyright IBM Corp. 2012, 2017 * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public
@@ -311,13 +311,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) } } -/* -* The migration interface for ais was introduced with kernel 4.13 -* but the capability itself had been active since 4.12. As migration -* support is considered necessary let's disable ais in the 2.10 -* machine. -*/ -/* kvm_vm_enable_cap(s, KVM_CAP_S390_AIS, 0); */ +/* The AIS enablement happens in the flic realize */ qemu_mutex_init (&qemu_sigp_mutex);
Signature · 1 line
2.9.4
Cornelia Huck
AppliedRe: [Qemu-devel] [PATCH v3 2/3] s390x/ais: enable ais when migration is available
Quoted 7 lines · On Wed, 27 Sep 2017 09:20:29 +0200 Christian Borntraeger…
Instead of unconditionally enabling the KVM AIS capability in the kvm arch init function, do this in the flic realize function when we know if migration is available. This requires to initialize flic before the CPUs (and cpu models).
Signed-off-by Christian Borntraeger <[email protected]>Reviewed-by David Hildenbrand <[email protected]>
Quoted 8 lines
--- hw/intc/s390_flic.c | 8 ++------ hw/intc/s390_flic_kvm.c | 16 +++++++++++----- hw/s390x/css.c | 4 ++-- hw/s390x/s390-virtio-ccw.c | 10 +++++++--- include/hw/s390x/s390_flic.h | 1 - target/s390x/kvm.c | 10 ++-------- 6 files changed, 24 insertions(+), 25 deletions(-)
Thanks, applied.
Re: [Qemu-devel] [PATCH v3 2/3] s390x/ais: enable ais when migration is available
In reply to Christian BorntraegerConny can you maybe defer this patch?
Turns out that this patch will enable the ais feature, so you can do -cpu z13,ais=on, but it will not enable ais for the none machine
That means that libvirt will not enable ais for host-model or host-passthrough.
Reason seems to be that the flic interrupt controller is not created when the none machine is used.
Quoted 204 lines · Christian Borntraeger
Instead of unconditionally enabling the KVM AIS capability in the kvm arch init function, do this in the flic realize function when we know if migration is available. This requires to initialize flic before the CPUs (and cpu models).
Signed-off-by Christian Borntraeger <[email protected]>Reviewed-by David Hildenbrand <[email protected]>--- hw/intc/s390_flic.c | 8 ++------ hw/intc/s390_flic_kvm.c | 16 +++++++++++----- hw/s390x/css.c | 4 ++-- hw/s390x/s390-virtio-ccw.c | 10 +++++++--- include/hw/s390x/s390_flic.h | 1 - target/s390x/kvm.c | 10 ++-------- 6 files changed, 24 insertions(+), 25 deletions(-)hw/intc/s390_flic.c +2
-6@@ -1,7 +1,7 @@/* * QEMU S390x floating interrupt controller (flic) * -* Copyright 2014 IBM Corp. +* Copyright IBM Corp. 2014, 2017 * Author(s): Jens Freimann <[email protected]> * Cornelia Huck <[email protected]> * @@ -136,9 +136,7 @@ static void qemu_s390_flic_reset(DeviceState *dev)bool ais_needed (void *opaque) { -S390FLICState *s = opaque; - -return s->ais_supported; +return s390_has_feat (S390_FEAT_ADAPTER_INT_SUPPRESSION ); }static const VMStateDescription qemu_s390_flic_vmstate = {@@ -185,8 +183,6 @@ static void s390_flic_common_realize(DeviceState *dev, Error **errp) " (%d > %d)", max_batch, ADAPTER_ROUTES_MAX_GSI);return ; } - - fs->ais_supported =s390_has_feat (S390_FEAT_ADAPTER_INT_SUPPRESSION ); }static void s390_flic_class_init (ObjectClass *oc,void *data)hw/intc/s390_flic_kvm.c +11
-5@@ -1,7 +1,7 @@/* * QEMU S390x KVM floating interrupt controller (flic) * -* Copyright 2014 IBM Corp. +* Copyright IBM Corp. 2014, 2017 * Author(s): Jens Freimann <[email protected]> * Cornelia Huck <[email protected]> * @@ -164,7 +164,7 @@ static int kvm_s390_modify_ais_mode(S390FLICState *fs, uint8_t isc, .addr = (uint64_t)&req, }; -if (!fs->ais_supported) { +if (!s390_has_feat (S390_FEAT_ADAPTER_INT_SUPPRESSION )) {return -ENOSYS ; }@@ -181,7 +181,7 @@ static int kvm_s390_inject_airq(S390FLICState *fs, uint8_t type, .attr = id, }; -if (!fs->ais_supported) { +if (!s390_has_feat (S390_FEAT_ADAPTER_INT_SUPPRESSION )) {return -ENOSYS ; }@@ -459,7 +459,7 @@ static int kvm_flic_ais_post_load(void *opaque, int version_id)* migration from a host that has AIS to a host that has no AIS. * In that case the target system will reject the migration here. */ -if (!ais_needed (flic)) { +if (!s390_has_feat (S390_FEAT_ADAPTER_INT_SUPPRESSION )) {return -ENOSYS ; }@@ -557,6 +557,12 @@ static void kvm_s390_flic_realize(DeviceState *dev, Error **errp) test_attr.group =KVM_DEV_FLIC_CLEAR_IO_IRQ ; flic_state->clear_io_supported = !ioctl (flic_state->fd,KVM_HAS_DEVICE_ATTR , test_attr); +/* try enable the AIS facility */ + test_attr.group =KVM_DEV_FLIC_AISM_ALL ; +if (!ioctl (flic_state->fd,KVM_HAS_DEVICE_ATTR , test_attr)) { +kvm_vm_enable_cap (kvm_state,KVM_CAP_S390_AIS ,0 ); + } +return ; fail:error_propagate (errp, errp_local);@@ -578,7 +584,7 @@ static void kvm_s390_flic_reset(DeviceState *dev)flic_disable_wait_pfault (flic); -if (fs->ais_supported) { +if (s390_has_feat (S390_FEAT_ADAPTER_INT_SUPPRESSION )) {for (isc =0 ; isc <=MAX_ISC ; isc++) { rc =kvm_s390_modify_ais_mode (fs, isc,SIC_IRQ_MODE_ALL );if (rc) {hw/s390x/css.c +2
-2@@ -1,7 +1,7 @@/* * Channel subsystem base support. * -* Copyright 2012 IBM Corp. +* Copyright IBM Corp. 2012, 2017 * Author(s): Cornelia Huck <[email protected]> * * This work is licensed under the terms of the GNU GPL, version 2 or (at @@ -672,7 +672,7 @@ void css_adapter_interrupt(CssIoAdapterType type, uint8_t isc) }trace_css_adapter_interrupt (isc); -if (fs->ais_supported) { +if (s390_has_feat (S390_FEAT_ADAPTER_INT_SUPPRESSION )) {if (fsc->inject_airq (fs, type, isc, adapter->flags)) {error_report ("Failed to inject airq with AIS supported" );exit (1 );hw/s390x/s390-virtio-ccw.c +7
-3@@ -1,7 +1,7 @@/* * virtio ccw machine * -* Copyright 2012 IBM Corp. +* Copyright IBM Corp. 2012, 2017 * Copyright (c) 2009 Alexander Graf <[email protected]> * Author(s): Cornelia Huck <[email protected]> * @@ -279,11 +279,15 @@ static void ccw_init(MachineState *machine)s390_sclp_init ();s390_memory_init (machine->ram_size); +/* +* This might also enable some KVM features like AIS, so it must +* be called before the CPU model +*/ +s390_flic_init (); +/* init CPUs (incl. CPU model) early so s390_has_feature() works */ s390_init_cpus (machine); -s390_flic_init (); -/* get a BUS */ css_bus =virtual_css_bus_init (); s390_init_ipl_dev(machine->kernel_filename, machine->kernel_cmdline,include/hw/s390x/s390_flic.h +0
-1@@ -44,7 +44,6 @@ typedef struct S390FLICState {SysBusDevice parent_obj;/* to limit AdapterRoutes.num_routes for compat */ uint32_t adapter_routes_max_batch; -bool ais_supported; } S390FLICState;#define S390_FLIC_COMMON_CLASS (klass) \target/s390x/kvm.c +2
-8@@ -2,7 +2,7 @@* QEMU S390x KVM implementation * * Copyright (c) 2009 Alexander Graf <[email protected]> -* Copyright IBM Corp. 2012 +* Copyright IBM Corp. 2012, 2017 * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -311,13 +311,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) } } -/* -* The migration interface for ais was introduced with kernel 4.13 -* but the capability itself had been active since 4.12. As migration -* support is considered necessary let's disable ais in the 2.10 -* machine. -*/ -/* kvm_vm_enable_cap(s, KVM_CAP_S390_AIS, 0); */ +/* The AIS enablement happens in the flic realize */ qemu_mutex_init (&qemu_sigp_mutex);
Re: [Qemu-devel] [PATCH v3 2/3] s390x/ais: enable ais when migration is available
Quoted 8 lines · On Fri, 29 Sep 2017 10:12:43 +0200 Christian Borntraeger…
Conny can you maybe defer this patch?
Turns out that this patch will enable the ais feature, so you can do -cpu z13,ais=on, but it will not enable ais for the none machine
That means that libvirt will not enable ais for host-model or host-passthrough.Reason seems to be that the flic interrupt controller is not created when the none machine is used.
Sigh :( Things are never easy...
I'll dequeue this again, thanks.
PATCH v3 3/3 s390x/ais: disable ais for compat machines
In reply to Christian BorntraegerWith newer kernels that do support the ais feature (4.13) a qemu 2.11 will not only enable the ais feature for the 2.11 machine, but also for a <=2.10 compat machine. As this feature is not available in QEMU <=2.9 (and QEMU 2.10.1), this guest will fail to migrate back to an older qemu like 2.9 with:
error while loading state for instance 0x0 of device 's390-flic'
making the whole compat machine dis-functional. As a permanent fix, we need to fence the ais feature for machines <= 2.10 similar to what we do for guarded storage, runtime instrumentation and css migration.
Due to ais being enabled on 2.10.0 (fixed in 2.10.1) this will prevent migration of ais-enabled guests from 2.10.0 with
qemu-system-s390x: Failed to load s390-flic/ais:tmp
qemu-system-s390x: error while loading state for instance 0x0 of device 's390-flic'
qemu-system-s390x: load of migration failed: Function not implemented
--- hw/intc/s390_flic_kvm.c | 4 +++- hw/s390x/s390-virtio-ccw.c | 10 ++++++++++ include/hw/s390x/s390-virtio-ccw.h | 3 +++ 3 files changed, 16 insertions(+), 1 deletion(-)
hw/intc/s390_flic_kvm.c +3 -1
@@ -22,6 +22,7 @@#include "hw/s390x/s390_flic.h" #include "hw/s390x/adapter.h" #include "hw/s390x/css.h" +#include "hw/s390x/s390-virtio-ccw.h" #include "trace.h" #define FLIC_SAVE_INITIAL_SIZE getpagesize()
@@ -559,7 +560,8 @@ static void kvm_s390_flic_realize(DeviceState *dev, Error **errp) KVM_HAS_DEVICE_ATTR, test_attr);/* try enable the AIS facility */ test_attr.group =KVM_DEV_FLIC_AISM_ALL ; -if (!ioctl (flic_state->fd,KVM_HAS_DEVICE_ATTR , test_attr)) { +if (ais_allowed () && + !ioctl (flic_state->fd,KVM_HAS_DEVICE_ATTR , test_attr)) {kvm_vm_enable_cap (kvm_state,KVM_CAP_S390_AIS ,0 ); }
hw/s390x/s390-virtio-ccw.c +10 -0
@@ -435,6 +435,7 @@ static void ccw_machine_class_init(ObjectClass *oc, void *data) s390mc->cpu_model_allowed = true; s390mc->css_migration_enabled = true; s390mc->gs_allowed = true; + s390mc->ais_allowed = true; mc->init = ccw_init; mc->reset = s390_machine_reset; mc->hot_add_cpu = s390_hot_add_cpu;
@@ -519,6 +520,11 @@ bool gs_allowed(void)return get_machine_class ()->gs_allowed; } +bool ais_allowed (void ) +{ +return get_machine_class ()->ais_allowed; +} +static char *machine_get_loadparm (Object *obj,Error **errp) {S390CcwMachineState *ms =S390_CCW_MACHINE (obj);
@@ -742,6 +748,10 @@ static void ccw_machine_2_10_instance_options(MachineState *machine)static void ccw_machine_2_10_class_options (MachineClass *mc) { +S390CcwMachineClass *s390mc =S390_MACHINE_CLASS (mc); + + s390mc->ais_allowed = false; +ccw_machine_2_11_class_options (mc);SET_MACHINE_COMPAT (mc,CCW_COMPAT_2_10 ); }
include/hw/s390x/s390-virtio-ccw.h +3 -0
@@ -41,6 +41,7 @@ typedef struct S390CcwMachineClass {bool cpu_model_allowed;bool css_migration_enabled;bool gs_allowed; +bool ais_allowed; } S390CcwMachineClass;/* runtime-instrumentation allowed by the machine */
@@ -49,6 +50,8 @@ bool ri_allowed(void);bool cpu_model_allowed (void );/* guarded-storage allowed by the machine */ bool gs_allowed (void ); +/* ais allowed by the machine */ +bool ais_allowed (void );/** * Returns true if (vmstate based) migration of the channel subsystem
Signature · 1 line
2.9.4