[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v21 05/20] s390x/cpu topology: resetting the Topology-Change-Repo
From: |
Pierre Morel |
Subject: |
[PATCH v21 05/20] s390x/cpu topology: resetting the Topology-Change-Report |
Date: |
Fri, 30 Jun 2023 11:17:37 +0200 |
During a subsystem reset the Topology-Change-Report is cleared
by the machine.
Let's ask KVM to clear the Modified Topology Change Report (MTCR)
bit of the SCA in the case of a subsystem reset.
Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
---
include/hw/s390x/cpu-topology.h | 1 +
target/s390x/cpu.h | 1 +
target/s390x/kvm/kvm_s390x.h | 1 +
hw/s390x/cpu-topology.c | 11 +++++++++++
hw/s390x/s390-virtio-ccw.c | 3 +++
target/s390x/cpu-sysemu.c | 13 +++++++++++++
target/s390x/kvm/kvm.c | 17 +++++++++++++++++
7 files changed, 47 insertions(+)
diff --git a/include/hw/s390x/cpu-topology.h b/include/hw/s390x/cpu-topology.h
index 193b33a2fc..ca7e9a22f2 100644
--- a/include/hw/s390x/cpu-topology.h
+++ b/include/hw/s390x/cpu-topology.h
@@ -58,6 +58,7 @@ static inline void s390_topology_setup_cpu(MachineState *ms,
#endif
extern S390Topology s390_topology;
+void s390_topology_reset(void);
static inline int s390_std_socket(int n, CpuTopology *smp)
{
diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
index 6e7d041b01..f236750cc5 100644
--- a/target/s390x/cpu.h
+++ b/target/s390x/cpu.h
@@ -654,6 +654,7 @@ typedef struct SysIBTl_cpu {
QEMU_BUILD_BUG_ON(sizeof(SysIBTl_cpu) != 16);
void insert_stsi_15_1_x(S390CPU *cpu, int sel2, uint64_t addr, uint8_t ar);
+void s390_cpu_topology_set_changed(bool changed);
/* MMU defines */
#define ASCE_ORIGIN (~0xfffULL) /* segment table origin
*/
diff --git a/target/s390x/kvm/kvm_s390x.h b/target/s390x/kvm/kvm_s390x.h
index f9785564d0..649dae5948 100644
--- a/target/s390x/kvm/kvm_s390x.h
+++ b/target/s390x/kvm/kvm_s390x.h
@@ -47,5 +47,6 @@ void kvm_s390_crypto_reset(void);
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);
+int kvm_s390_topology_set_mtcr(uint64_t attr);
#endif /* KVM_S390X_H */
diff --git a/hw/s390x/cpu-topology.c b/hw/s390x/cpu-topology.c
index ca1634d0ce..764ff92573 100644
--- a/hw/s390x/cpu-topology.c
+++ b/hw/s390x/cpu-topology.c
@@ -92,6 +92,17 @@ static void s390_topology_init(MachineState *ms)
smp->books * smp->drawers);
}
+/**
+ * s390_topology_reset:
+ *
+ * Generic reset for CPU topology, calls s390_topology_reset()
+ * to reset the kernel Modified Topology Change Record.
+ */
+void s390_topology_reset(void)
+{
+ s390_cpu_topology_set_changed(false);
+}
+
/**
* s390_topology_cpu_default:
* @cpu: pointer to a S390CPU
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 1dac9d5073..789b87f7aa 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -123,6 +123,9 @@ static void subsystem_reset(void)
device_cold_reset(dev);
}
}
+ if (s390_has_topology()) {
+ s390_topology_reset();
+ }
}
static int virtio_ccw_hcall_notify(const uint64_t *args)
diff --git a/target/s390x/cpu-sysemu.c b/target/s390x/cpu-sysemu.c
index 97d6c760a8..a8e2552ef4 100644
--- a/target/s390x/cpu-sysemu.c
+++ b/target/s390x/cpu-sysemu.c
@@ -307,3 +307,16 @@ 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_set_changed(bool changed)
+{
+ int ret;
+
+ if (kvm_enabled()) {
+ ret = kvm_s390_topology_set_mtcr(changed);
+ if (ret) {
+ error_report("Failed to set Modified Topology Change Report: %s",
+ strerror(-ret));
+ }
+ }
+}
diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c
index 5ea358cbb0..bc953151ce 100644
--- a/target/s390x/kvm/kvm.c
+++ b/target/s390x/kvm/kvm.c
@@ -2592,6 +2592,23 @@ int kvm_s390_get_zpci_op(void)
return cap_zpci_op;
}
+int kvm_s390_topology_set_mtcr(uint64_t attr)
+{
+ struct kvm_device_attr attribute = {
+ .group = KVM_S390_VM_CPU_TOPOLOGY,
+ .attr = attr,
+ };
+
+ if (!s390_has_feat(S390_FEAT_CONFIGURATION_TOPOLOGY)) {
+ return 0;
+ }
+ if (!kvm_vm_check_attr(kvm_state, KVM_S390_VM_CPU_TOPOLOGY, attr)) {
+ return -ENOTSUP;
+ }
+
+ return kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attribute);
+}
+
void kvm_arch_accel_class_init(ObjectClass *oc)
{
}
--
2.31.1
- [PATCH v21 00/20] s390x: CPU Topology, Pierre Morel, 2023/06/30
- [PATCH v21 01/20] s390x/cpu topology: add s390 specifics to CPU topology, Pierre Morel, 2023/06/30
- [PATCH v21 04/20] s390x/sclp: reporting the maximum nested topology entries, Pierre Morel, 2023/06/30
- [PATCH v21 02/20] s390x/cpu topology: add topology entries on CPU hotplug, Pierre Morel, 2023/06/30
- [PATCH v21 03/20] target/s390x/cpu topology: handle STSI(15) and build the SYSIB, Pierre Morel, 2023/06/30
- [PATCH v21 05/20] s390x/cpu topology: resetting the Topology-Change-Report,
Pierre Morel <=
- [PATCH v21 06/20] s390x/cpu topology: interception of PTF instruction, Pierre Morel, 2023/06/30
- [PATCH v21 07/20] target/s390x/cpu topology: activate CPU topology, Pierre Morel, 2023/06/30
- [PATCH v21 08/20] qapi/s390x/cpu topology: set-cpu-topology qmp command, Pierre Morel, 2023/06/30
- [PATCH v21 11/20] qapi/s390x/cpu topology: CPU_POLARIZATION_CHANGE qapi event, Pierre Morel, 2023/06/30
- [PATCH v21 12/20] qapi/s390x/cpu topology: query-cpu-polarization qmp command, Pierre Morel, 2023/06/30
- [PATCH v21 09/20] machine: adding s390 topology to query-cpu-fast, Pierre Morel, 2023/06/30
- [PATCH v21 10/20] machine: adding s390 topology to info hotpluggable-cpus, Pierre Morel, 2023/06/30
- [PATCH v21 14/20] tests/avocado: s390x cpu topology core, Pierre Morel, 2023/06/30
- [PATCH v21 16/20] tests/avocado: s390x cpu topology entitlement tests, Pierre Morel, 2023/06/30
- [PATCH v21 17/20] tests/avocado: s390x cpu topology test dedicated CPU, Pierre Morel, 2023/06/30