From: Pierre Morel <pmorel@linux.ibm.com>
To: qemu-s390x@nongnu.org
Cc: qemu-devel@nongnu.org, borntraeger@de.ibm.com,
pasic@linux.ibm.com, richard.henderson@linaro.org,
david@redhat.com, thuth@redhat.com, cohuck@redhat.com,
mst@redhat.com, pbonzini@redhat.com, kvm@vger.kernel.org,
ehabkost@redhat.com, marcel.apfelbaum@gmail.com,
eblake@redhat.com, armbru@redhat.com, seiden@linux.ibm.com,
nrb@linux.ibm.com, frankja@linux.ibm.com, berrange@redhat.com,
clg@kaod.org
Subject: [PATCH v10 3/9] s390x/cpu_topology: resetting the Topology-Change-Report
Date: Wed, 12 Oct 2022 18:21:01 +0200 [thread overview]
Message-ID: <20221012162107.91734-4-pmorel@linux.ibm.com> (raw)
In-Reply-To: <20221012162107.91734-1-pmorel@linux.ibm.com>
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: Nico Boehr <nrb@linux.ibm.com>
Reviewed-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
---
target/s390x/cpu.h | 1 +
target/s390x/kvm/kvm_s390x.h | 1 +
hw/s390x/cpu-topology.c | 12 ++++++++++++
hw/s390x/s390-virtio-ccw.c | 1 +
target/s390x/cpu-sysemu.c | 7 +++++++
target/s390x/kvm/kvm.c | 23 +++++++++++++++++++++++
6 files changed, 45 insertions(+)
diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
index d604aa9c78..9b35795ac8 100644
--- a/target/s390x/cpu.h
+++ b/target/s390x/cpu.h
@@ -825,6 +825,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_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_s390x.h b/target/s390x/kvm/kvm_s390x.h
index aaae8570de..a13c8fb9a3 100644
--- a/target/s390x/kvm/kvm_s390x.h
+++ b/target/s390x/kvm/kvm_s390x.h
@@ -46,5 +46,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 c73cebfe6f..9f202621d0 100644
--- a/hw/s390x/cpu-topology.c
+++ b/hw/s390x/cpu-topology.c
@@ -107,6 +107,17 @@ static void s390_topology_realize(DeviceState *dev, Error **errp)
qemu_mutex_init(&topo->topo_mutex);
}
+/**
+ * s390_topology_reset:
+ * @dev: the device
+ *
+ * Calls the sysemu topology reset
+ */
+static void s390_topology_reset(DeviceState *dev)
+{
+ s390_cpu_topology_reset();
+}
+
/**
* topology_class_init:
* @oc: Object class
@@ -120,6 +131,7 @@ static void topology_class_init(ObjectClass *oc, void *data)
dc->realize = s390_topology_realize;
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
+ dc->reset = s390_topology_reset;
}
static const TypeInfo cpu_topology_info = {
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index aa99a62e42..362378454a 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -113,6 +113,7 @@ static const char *const reset_dev_types[] = {
"s390-flic",
"diag288",
TYPE_S390_PCI_HOST_BRIDGE,
+ TYPE_S390_CPU_TOPOLOGY,
};
static void subsystem_reset(void)
diff --git a/target/s390x/cpu-sysemu.c b/target/s390x/cpu-sysemu.c
index 948e4bd3e0..707c0b658c 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_reset(void)
+{
+ if (kvm_enabled()) {
+ kvm_s390_topology_set_mtcr(0);
+ }
+}
diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c
index f96630440b..9c994d27d5 100644
--- a/target/s390x/kvm/kvm.c
+++ b/target/s390x/kvm/kvm.c
@@ -2585,3 +2585,26 @@ 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,
+ };
+ int ret;
+
+ if (!s390_has_feat(S390_FEAT_CONFIGURATION_TOPOLOGY)) {
+ return -EFAULT;
+ }
+ if (!kvm_vm_check_attr(kvm_state, KVM_S390_VM_CPU_TOPOLOGY, attr)) {
+ return -ENOENT;
+ }
+
+ 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));
+ }
+ return ret;
+}
--
2.31.1
next prev parent reply other threads:[~2022-10-12 16:21 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-12 16:20 [PATCH v10 0/9] s390x: CPU Topology Pierre Morel
2022-10-12 16:20 ` [PATCH v10 1/9] s390x/cpu topology: core_id sets s390x CPU topology Pierre Morel
2022-10-18 16:43 ` Cédric Le Goater
2022-10-19 15:39 ` Pierre Morel
2022-10-19 17:56 ` Janis Schoetterl-Glausch
2022-10-24 9:22 ` Cédric Le Goater
2022-10-24 19:26 ` Janis Schoetterl-Glausch
2022-10-24 19:25 ` Janis Schoetterl-Glausch
2022-10-27 8:05 ` Thomas Huth
2022-10-27 9:13 ` Janis Schoetterl-Glausch
2022-10-25 19:58 ` Janis Schoetterl-Glausch
2022-10-26 8:34 ` Pierre Morel
2022-10-27 20:20 ` Janis Schoetterl-Glausch
2022-10-28 9:30 ` Pierre Morel
2022-11-07 18:04 ` Janis Schoetterl-Glausch
2022-11-08 10:28 ` Pierre Morel
2022-10-12 16:21 ` [PATCH v10 2/9] s390x/cpu topology: reporting the CPU topology to the guest Pierre Morel
2022-10-18 17:10 ` Cédric Le Goater
2022-10-27 8:12 ` Thomas Huth
2022-10-27 11:24 ` Pierre Morel
2022-10-27 20:42 ` Janis Schoetterl-Glausch
2022-10-28 10:00 ` Pierre Morel
2022-11-07 13:20 ` Janis Schoetterl-Glausch
2022-11-07 13:57 ` Pierre Morel
2022-10-12 16:21 ` Pierre Morel [this message]
2022-10-18 17:19 ` [PATCH v10 3/9] s390x/cpu_topology: resetting the Topology-Change-Report Cédric Le Goater
2022-10-27 8:14 ` Thomas Huth
2022-10-27 9:11 ` Pierre Morel
2022-10-27 9:58 ` Cédric Le Goater
2022-10-27 11:26 ` Pierre Morel
2022-10-12 16:21 ` [PATCH v10 4/9] s390x/cpu_topology: CPU topology migration Pierre Morel
2022-10-12 16:21 ` [PATCH v10 5/9] target/s390x: interception of PTF instruction Pierre Morel
2022-10-12 16:21 ` [PATCH v10 6/9] s390x/cpu topology: add topology-disable machine property Pierre Morel
2022-10-18 17:34 ` Cédric Le Goater
2022-10-19 9:03 ` Cornelia Huck
2022-10-19 15:48 ` Pierre Morel
2022-10-20 14:01 ` Pierre Morel
2022-10-18 17:51 ` Cédric Le Goater
2022-10-20 14:32 ` Pierre Morel
2022-10-12 16:21 ` [PATCH v10 7/9] s390x/cpu topology: add max_threads machine class attribute Pierre Morel
2022-10-18 17:36 ` Cédric Le Goater
2022-10-26 9:04 ` Pierre Morel
2022-10-27 10:00 ` Cédric Le Goater
2022-10-27 11:28 ` Pierre Morel
2022-10-12 16:21 ` [PATCH v10 8/9] s390x/cpu_topology: activating CPU topology Pierre Morel
2022-10-12 16:21 ` [PATCH v10 9/9] docs/s390x: document s390x cpu topology Pierre Morel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221012162107.91734-4-pmorel@linux.ibm.com \
--to=pmorel@linux.ibm.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=clg@kaod.org \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=eblake@redhat.com \
--cc=ehabkost@redhat.com \
--cc=frankja@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=nrb@linux.ibm.com \
--cc=pasic@linux.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=seiden@linux.ibm.com \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox