qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Michael Mueller <mimu@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org, kvm@vger.kernel.org,
	linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: mimu@linux.vnet.ibm.com, Gleb Natapov <gleb@kernel.org>,
	Alexander Graf <agraf@suse.de>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	"Jason J. Herne" <jjherne@linux.vnet.ibm.com>,
	Cornelia Huck <cornelia.huck@de.ibm.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Andreas Faerber <afaerber@suse.de>,
	Richard Henderson <rth@twiddle.net>
Subject: [Qemu-devel] [PATCH v1 RFC 06/10] QEMU: s390: cpu model kvm VM attr interface routines
Date: Tue, 13 May 2014 17:00:18 +0200	[thread overview]
Message-ID: <1399993222-16339-7-git-send-email-mimu@linux.vnet.ibm.com> (raw)
In-Reply-To: <1399993222-16339-1-git-send-email-mimu@linux.vnet.ibm.com>

The patch implements routines to set and retrieve processor configuration
data and to retrieve machine configuration data. The machine related data
will be used to determine the list of supported cpu models of this host.

Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
---
 target-s390x/cpu-models.h | 21 +++++++++++++++
 target-s390x/cpu.c        |  2 ++
 target-s390x/kvm.c        | 66 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 89 insertions(+)

diff --git a/target-s390x/cpu-models.h b/target-s390x/cpu-models.h
index f5c8112..3533c96 100644
--- a/target-s390x/cpu-models.h
+++ b/target-s390x/cpu-models.h
@@ -55,6 +55,27 @@ typedef struct S390CPUAlias {
 } S390CPUAlias;
 extern GSList *s390_cpu_aliases;
 
+typedef struct S390ProcessorProps {
+    uint64_t cpuid;
+    uint16_t ibc;
+    uint8_t  pad[6];
+    uint64_t fac_list[S390_ARCH_FAC_LIST_SIZE_UINT64];
+} S390ProcessorProps;
+
+typedef struct S390MachineProps {
+    uint64_t cpuid;
+    uint32_t ibc_range;
+    uint8_t  pad[4];
+    uint64_t fac_mask[S390_ARCH_FAC_MASK_SIZE_UINT64];
+    uint64_t hard_fac_list[S390_ARCH_FAC_LIST_SIZE_UINT64];
+    uint64_t soft_fac_list[S390_ARCH_FAC_LIST_SIZE_UINT64];
+} S390MachineProps;
+
+int kvm_s390_has_cpu_model_call(uint64_t attr);
+int kvm_s390_get_processor_props(S390ProcessorProps *prob);
+int kvm_s390_set_processor_props(S390ProcessorProps *prob);
+int kvm_s390_get_machine_props(S390MachineProps *prob);
+
 /*
  * bits 0-7   : CMOS generation
  * bits 8-9   : reserved
diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
index 10a03f9..5e292e7 100644
--- a/target-s390x/cpu.c
+++ b/target-s390x/cpu.c
@@ -28,6 +28,8 @@
 #include "qemu-common.h"
 #include "qemu/timer.h"
 #include "hw/hw.h"
+#include "cpu-qom.h"
+#include "cpu-models.h"
 #ifndef CONFIG_USER_ONLY
 #include "sysemu/arch_init.h"
 #endif
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index b7b0edc..b69d5d0 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -33,6 +33,7 @@
 #include "sysemu/sysemu.h"
 #include "sysemu/kvm.h"
 #include "cpu.h"
+#include "cpu-models.h"
 #include "sysemu/device_tree.h"
 #include "qapi/qmp/qjson.h"
 #include "monitor/monitor.h"
@@ -93,6 +94,8 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
 static int cap_sync_regs;
 static int cap_async_pf;
 
+static uint64_t cpu_model_call_cache;
+
 static void *legacy_s390_alloc(size_t size);
 
 int kvm_arch_init(KVMState *s)
@@ -959,3 +962,66 @@ int kvm_s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch,
     }
     return kvm_vm_ioctl(kvm_state, KVM_IOEVENTFD, &kick);
 }
+
+static int cpu_model_get(uint64_t attr, uint64_t addr)
+{
+    struct kvm_device_attr dev_attr = {
+        .group = KVM_S390_VM_CPU_MODEL,
+        .attr = attr,
+        .addr = addr,
+    };
+
+    return kvm_vm_ioctl(kvm_state, KVM_GET_DEVICE_ATTR, &dev_attr);
+}
+
+static int cpu_model_set(uint64_t attr, uint64_t addr)
+{
+    struct kvm_device_attr dev_attr = {
+        .group = KVM_S390_VM_CPU_MODEL,
+        .attr = attr,
+        .addr = addr,
+    };
+
+    return kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &dev_attr);
+}
+
+int kvm_s390_has_cpu_model_call(uint64_t attr)
+{
+    int rc;
+    struct kvm_device_attr dev_attr = {
+        .group = KVM_S390_VM_CPU_MODEL,
+        .attr = attr,
+    };
+
+    if (dev_attr.attr >= sizeof(cpu_model_call_cache)) {
+        return 0;
+    }
+
+    if (cpu_model_call_cache & (1UL << dev_attr.attr)) {
+        return 1;
+    }
+
+    rc = kvm_vm_ioctl(kvm_state, KVM_HAS_DEVICE_ATTR, &dev_attr);
+    if (rc == 0) {
+        cpu_model_call_cache |= (1UL << dev_attr.attr);
+        return 1;
+    }
+
+    return 0;
+}
+
+int kvm_s390_get_processor_props(S390ProcessorProps *prop)
+{
+    return cpu_model_get(KVM_S390_VM_CPU_PROCESSOR, (uint64_t) prop);
+}
+
+int kvm_s390_set_processor_props(S390ProcessorProps *prop)
+{
+    return cpu_model_set(KVM_S390_VM_CPU_PROCESSOR, (uint64_t) prop);
+}
+
+int kvm_s390_get_machine_props(S390MachineProps *prop)
+{
+    return cpu_model_get(KVM_S390_VM_CPU_MACHINE, (uint64_t) prop);
+}
+
-- 
1.8.3.1

  parent reply	other threads:[~2014-05-13 15:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-13 15:00 [Qemu-devel] [PATCH v1 RFC 00/10] QEMU: s390: cpu model implementation Michael Mueller
2014-05-13 15:00 ` [Qemu-devel] [PATCH v1 RFC 01/10] QEMU: introduce function cpudesc_avail Michael Mueller
2014-05-13 15:00 ` [Qemu-devel] [PATCH v1 RFC 02/10] QEMU: s390: cpu model cpu class definition Michael Mueller
2014-05-13 15:00 ` [Qemu-devel] [PATCH v1 RFC 03/10] QEMU: s390: cpu model facilities support Michael Mueller
2014-05-13 15:00 ` [Qemu-devel] [PATCH v1 RFC 04/10] QEMU: s390: cpu model alias support Michael Mueller
2014-05-13 15:00 ` [Qemu-devel] [PATCH v1 RFC 05/10] s390: update linux-headers for kvm VM device attributes Michael Mueller
2014-05-13 15:00 ` Michael Mueller [this message]
2014-05-13 15:00 ` [Qemu-devel] [PATCH v1 RFC 07/10] QEMU: s390: cpu model class initialization Michael Mueller
2014-05-13 15:00 ` [Qemu-devel] [PATCH v1 RFC 08/10] QEMU: s390: cpu model QMP query-cpu-definitions Michael Mueller
2014-05-13 15:00 ` [Qemu-devel] [PATCH v1 RFC 09/10] QEMU: s390: cpu model QMP query-cpu-model Michael Mueller
2014-05-13 15:29   ` Eric Blake
2014-05-14  9:07     ` Michael Mueller
2014-05-13 15:00 ` [Qemu-devel] [PATCH v1 RFC 10/10] QEMU: s390: cpu model enablement Michael Mueller

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=1399993222-16339-7-git-send-email-mimu@linux.vnet.ibm.com \
    --to=mimu@linux.vnet.ibm.com \
    --cc=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=borntraeger@de.ibm.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=gleb@kernel.org \
    --cc=jjherne@linux.vnet.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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;
as well as URLs for NNTP newsgroup(s).