@@ -667,6 +667,11 @@ static void s390_node_device_realize(DeviceState *dev, Error **errp)
qbus_set_hotplug_handler(bus, OBJECT(dev));
}
+static void s390_topology_reset(DeviceState *dev)
+{
+ s390_cpu_topology_mtr_reset();
+}
+
static void node_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
@@ -676,6 +681,7 @@ static void node_class_init(ObjectClass *oc, void *data)
set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
dc->realize = s390_node_device_realize;
dc->desc = "topology node";
+ dc->reset = s390_topology_reset;
}
static const TypeInfo node_info = {
@@ -122,6 +122,7 @@ static const char *const reset_dev_types[] = {
"s390-flic",
"diag288",
TYPE_S390_PCI_HOST_BRIDGE,
+ TYPE_S390_TOPOLOGY_NODE,
};
static void subsystem_reset(void)
@@ -306,3 +306,10 @@ void s390_do_cpu_set_diag318(CPUState *cs, run_on_cpu_data arg)
kvm_s390_set_diag318(cs, arg.host_ulong);
}
}
+
+void s390_cpu_topology_mtr_reset(void)
+{
+ if (kvm_enabled()) {
+ kvm_s390_cpu_topology_reset();
+ }
+}
@@ -826,6 +826,7 @@ void s390_enable_css_support(S390CPU *cpu);
void s390_do_cpu_set_diag318(CPUState *cs, run_on_cpu_data arg);
int s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch_id,
int vq, bool assign);
+void s390_cpu_topology_mtr_reset(void);
#ifndef CONFIG_USER_ONLY
unsigned int s390_cpu_set_state(uint8_t cpu_state, S390CPU *cpu);
#else
@@ -2592,3 +2592,33 @@ bool kvm_arch_cpu_check_are_resettable(void)
{
return true;
}
+
+static void kvm_s390_set_mtr(uint64_t attr)
+{
+ struct kvm_device_attr attribute = {
+ .group = KVM_S390_VM_CPU_TOPOLOGY,
+ .attr = attr,
+ };
+ int ret = kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attribute);
+
+ if (ret) {
+ error_report("Failed to set cpu topology attribute %lu: %s",
+ attr, strerror(-ret));
+ }
+}
+
+static void kvm_s390_reset_mtr(void)
+{
+ uint64_t attr = KVM_S390_VM_CPU_TOPO_MTR_CLEAR;
+
+ if (kvm_vm_check_attr(kvm_state, KVM_S390_VM_CPU_TOPOLOGY, attr)) {
+ kvm_s390_set_mtr(attr);
+ }
+}
+
+void kvm_s390_cpu_topology_reset(void)
+{
+ if (s390_has_feat(S390_FEAT_CONFIGURATION_TOPOLOGY)) {
+ kvm_s390_reset_mtr();
+ }
+}
@@ -46,4 +46,6 @@ void kvm_s390_restart_interrupt(S390CPU *cpu);
void kvm_s390_stop_interrupt(S390CPU *cpu);
void kvm_s390_set_diag318(CPUState *cs, uint64_t diag318_info);
+void kvm_s390_cpu_topology_reset(void);
+
#endif /* KVM_S390X_H */
During a subsystem reset the Topology-Change-Report is cleared. Let's ask KVM to clear the MTCR in the case of a subsystem reset. Signed-off-by: Pierre Morel <pmorel@linux.ibm.com> --- hw/s390x/cpu-topology.c | 6 ++++++ hw/s390x/s390-virtio-ccw.c | 1 + target/s390x/cpu-sysemu.c | 7 +++++++ target/s390x/cpu.h | 1 + target/s390x/kvm/kvm.c | 30 ++++++++++++++++++++++++++++++ target/s390x/kvm/kvm_s390x.h | 2 ++ 6 files changed, 47 insertions(+)