[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v8 10/12] s390x/cpu_topology: resetting the Topology-Change-Repor
From: |
Pierre Morel |
Subject: |
[PATCH v8 10/12] s390x/cpu_topology: resetting the Topology-Change-Report |
Date: |
Mon, 20 Jun 2022 16:03:50 +0200 |
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(+)
diff --git a/hw/s390x/cpu-topology.c b/hw/s390x/cpu-topology.c
index 2dbb42ee2b..ba12cafaf7 100644
--- a/hw/s390x/cpu-topology.c
+++ b/hw/s390x/cpu-topology.c
@@ -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 = {
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 5c0dbff6fd..0b30633ed5 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -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)
diff --git a/target/s390x/cpu-sysemu.c b/target/s390x/cpu-sysemu.c
index 948e4bd3e0..11d0d87301 100644
--- a/target/s390x/cpu-sysemu.c
+++ b/target/s390x/cpu-sysemu.c
@@ -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();
+ }
+}
diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
index 9d48087b71..793e72c81a 100644
--- a/target/s390x/cpu.h
+++ b/target/s390x/cpu.h
@@ -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
diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c
index c664c45e8a..277f8d37cf 100644
--- a/target/s390x/kvm/kvm.c
+++ b/target/s390x/kvm/kvm.c
@@ -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();
+ }
+}
diff --git a/target/s390x/kvm/kvm_s390x.h b/target/s390x/kvm/kvm_s390x.h
index 05a5e1e6f4..d717c05827 100644
--- a/target/s390x/kvm/kvm_s390x.h
+++ b/target/s390x/kvm/kvm_s390x.h
@@ -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 */
--
2.31.1
- Re: [PATCH v8 03/12] s390x/cpu_topology: implementating Store Topology System Information, (continued)
- [PATCH v8 07/12] s390x/cpu_topology: Adding drawers to STSI, Pierre Morel, 2022/06/20
- [PATCH v8 11/12] s390x/cpu_topology: CPU topology migration, Pierre Morel, 2022/06/20
- [PATCH v8 02/12] s390x/cpu_topology: CPU topology objects and structures, Pierre Morel, 2022/06/20
- [PATCH v8 06/12] s390x/cpu_topology: Adding drawers to CPU topology, Pierre Morel, 2022/06/20
- [PATCH v8 08/12] s390x/cpu_topology: implementing numa for the s390x topology, Pierre Morel, 2022/06/20
- [PATCH v8 09/12] target/s390x: interception of PTF instruction, Pierre Morel, 2022/06/20
- [PATCH v8 10/12] s390x/cpu_topology: resetting the Topology-Change-Report,
Pierre Morel <=
- [PATCH v8 12/12] s390x/cpu_topology: activating CPU topology, Pierre Morel, 2022/06/20