All of lore.kernel.org
 help / color / mirror / Atom feed
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, scgl@linux.ibm.com, frankja@linux.ibm.com,
	berrange@redhat.com, clg@kaod.org
Subject: [PATCH v13 6/7] s390x/cpu_topology: activating CPU topology
Date: Thu,  8 Dec 2022 10:44:31 +0100	[thread overview]
Message-ID: <20221208094432.9732-7-pmorel@linux.ibm.com> (raw)
In-Reply-To: <20221208094432.9732-1-pmorel@linux.ibm.com>

The KVM capability, KVM_CAP_S390_CPU_TOPOLOGY is used to
activate the S390_FEAT_CONFIGURATION_TOPOLOGY feature and
the topology facility for the guest in the case the topology
is available in QEMU and in KVM.

The feature is disabled by default and fenced for SE
(secure execution).

Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
---
 include/hw/s390x/cpu-topology.h | 10 +++++++++-
 hw/s390x/cpu-topology.c         |  5 ++---
 target/s390x/cpu_models.c       |  1 +
 target/s390x/kvm/kvm.c          | 12 ++++++++++++
 4 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/include/hw/s390x/cpu-topology.h b/include/hw/s390x/cpu-topology.h
index 6c3d2d080f..fe25a3bf6b 100644
--- a/include/hw/s390x/cpu-topology.h
+++ b/include/hw/s390x/cpu-topology.h
@@ -38,7 +38,15 @@ struct S390Topology {
 OBJECT_DECLARE_SIMPLE_TYPE(S390Topology, S390_CPU_TOPOLOGY)
 
 void s390_init_topology(MachineState *machine, Error **errp);
-bool s390_has_topology(void);
 S390Topology *s390_get_topology(void);
 
+#ifdef CONFIG_KVM
+bool s390_has_topology(void);
+#else
+static inline bool s390_has_topology(void)
+{
+    return false;
+}
+#endif
+
 #endif
diff --git a/hw/s390x/cpu-topology.c b/hw/s390x/cpu-topology.c
index a2a553e362..bf125bb4c0 100644
--- a/hw/s390x/cpu-topology.c
+++ b/hw/s390x/cpu-topology.c
@@ -75,12 +75,11 @@ void s390_handle_ptf(S390CPU *cpu, uint8_t r1, uintptr_t ra)
 /**
  * s390_has_topology
  *
- * Return false until the commit activating the topology is
- * commited.
+ * checks the S390_FEAT_CONFIGURATION_TOPOLOGY availability.
  */
 bool s390_has_topology(void)
 {
-    return false;
+    return s390_has_feat(S390_FEAT_CONFIGURATION_TOPOLOGY);
 }
 
 /**
diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c
index c3a4f80633..3f05e05fd3 100644
--- a/target/s390x/cpu_models.c
+++ b/target/s390x/cpu_models.c
@@ -253,6 +253,7 @@ bool s390_has_feat(S390Feat feat)
         case S390_FEAT_SIE_CMMA:
         case S390_FEAT_SIE_PFMFI:
         case S390_FEAT_SIE_IBS:
+        case S390_FEAT_CONFIGURATION_TOPOLOGY:
             return false;
             break;
         default:
diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c
index a79fdf1c79..abf1202c28 100644
--- a/target/s390x/kvm/kvm.c
+++ b/target/s390x/kvm/kvm.c
@@ -2471,6 +2471,18 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp)
         set_bit(S390_FEAT_UNPACK, model->features);
     }
 
+    /*
+     * If we have support for CPU Topology in KVM
+     * activate the CPU TOPOLOGY feature.
+     */
+    if (kvm_check_extension(kvm_state, KVM_CAP_S390_CPU_TOPOLOGY)) {
+        if (kvm_vm_enable_cap(kvm_state, KVM_CAP_S390_CPU_TOPOLOGY, 0) < 0) {
+            error_setg(errp, "KVM: Error enabling KVM_CAP_S390_CPU_TOPOLOGY");
+            return;
+        }
+        set_bit(S390_FEAT_CONFIGURATION_TOPOLOGY, model->features);
+    }
+
     /* We emulate a zPCI bus and AEN, therefore we don't need HW support */
     set_bit(S390_FEAT_ZPCI, model->features);
     set_bit(S390_FEAT_ADAPTER_EVENT_NOTIFICATION, model->features);
-- 
2.31.1


  parent reply	other threads:[~2022-12-08  9:45 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-08  9:44 [PATCH v13 0/7] s390x: CPU Topology Pierre Morel
2022-12-08  9:44 ` [PATCH v13 1/7] s390x/cpu topology: Creating CPU topology device Pierre Morel
2022-12-09 13:50   ` Thomas Huth
2022-12-12  8:52     ` Pierre Morel
2022-12-09 14:51   ` Cédric Le Goater
2022-12-08  9:44 ` [PATCH v13 2/7] s390x/cpu topology: reporting the CPU topology to the guest Pierre Morel
2022-12-09 15:43   ` Cédric Le Goater
2022-12-12  9:21     ` Pierre Morel
2022-12-08  9:44 ` [PATCH v13 3/7] s390x/cpu_topology: resetting the Topology-Change-Report Pierre Morel
2022-12-08  9:44 ` [PATCH v13 4/7] s390x/cpu_topology: CPU topology migration Pierre Morel
2022-12-09 14:56   ` Cédric Le Goater
2022-12-12  9:14     ` Pierre Morel
2022-12-11 14:55   ` Pierre Morel
2022-12-13 13:26   ` Christian Borntraeger
2022-12-13 17:40     ` Pierre Morel
2022-12-08  9:44 ` [PATCH v13 5/7] s390x/cpu_topology: interception of PTF instruction Pierre Morel
2022-12-08  9:44 ` Pierre Morel [this message]
2022-12-08  9:44 ` [PATCH v13 7/7] docs/s390x: document s390x cpu topology Pierre Morel
2022-12-09 13:32 ` [PATCH v13 0/7] s390x: CPU Topology Thomas Huth
2022-12-12  8:51   ` Pierre Morel
2022-12-12  9:07     ` Thomas Huth
2022-12-12 10:10       ` Pierre Morel
2022-12-12 10:17         ` Thomas Huth
2022-12-13 13:41           ` Christian Borntraeger
2022-12-13 13:57             ` Janis Schoetterl-Glausch
2022-12-13 14:00               ` Christian Borntraeger
2022-12-13 17:24             ` Pierre Morel
2022-12-14 10:39               ` Thomas Huth
2022-12-09 14:45 ` Cédric Le Goater
2022-12-12 10:01   ` Pierre Morel
2022-12-13 13:50     ` Christian Borntraeger
2022-12-13 15:12       ` Christian Borntraeger
2022-12-13 15:31         ` Janis Schoetterl-Glausch
2022-12-13 17:27           ` 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=20221208094432.9732-7-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=scgl@linux.ibm.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.