* [Qemu-devel] [PATCH RFC 00/11] s390 cpu models for KVM accelerator
@ 2013-10-02 11:33 Michael Mueller
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 01/11] s390/qemu: cpu modle disable list cpus Michael Mueller
` (10 more replies)
0 siblings, 11 replies; 19+ messages in thread
From: Michael Mueller @ 2013-10-02 11:33 UTC (permalink / raw)
To: qemu-devel; +Cc: Michael Mueller
The following patch set implements S390 cpu models in KVM accellerator
context. It is currently based on a configuration device interface not
yet published for RFC. The implementation can as well be used to feed
the currently discussed TCG related facility representation.
Michael Mueller (11):
s390/qemu: cpu modle disable list cpus
s390/qemu: cpu model extend config device
s390/qemu: cpu model cpu class definition
s390/qemu: cpu model cpu facilitiy support
s390/qemu: cpu model alias support
s390/qemu: cpu model KVM properties requests
s390/qemu: cpu model class initialization
s390/qemu: cpu model command line option help
s390/qemu: cpu model QMP query-cpu-definitions
s390/qemu: cpu model QMP query-cpu-model
s390/qemu: cpu model enablement
hw/s390x/s390-virtio-ccw.c | 15 +
hw/s390x/s390-virtio.c | 31 ++-
include/sysemu/arch_init.h | 1 +
linux-headers/asm-s390/kvm.h | 15 +
qapi-schema.json | 23 ++
qmp-commands.hx | 6 +
qmp.c | 5 +
target-s390x/Makefile.objs | 1 +
target-s390x/cpu-models.c | 637 +++++++++++++++++++++++++++++++++++++++++++
target-s390x/cpu-models.h | 97 +++++++
target-s390x/cpu-qom.h | 9 +
target-s390x/cpu.c | 106 ++++++-
target-s390x/helper.c | 24 +-
vl.c | 8 +-
14 files changed, 965 insertions(+), 13 deletions(-)
create mode 100644 target-s390x/cpu-models.c
create mode 100644 target-s390x/cpu-models.h
--
1.8.3.1
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH RFC 01/11] s390/qemu: cpu modle disable list cpus
2013-10-02 11:33 [Qemu-devel] [PATCH RFC 00/11] s390 cpu models for KVM accelerator Michael Mueller
@ 2013-10-02 11:33 ` Michael Mueller
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 02/11] s390/qemu: cpu model extend config device Michael Mueller
` (9 subsequent siblings)
10 siblings, 0 replies; 19+ messages in thread
From: Michael Mueller @ 2013-10-02 11:33 UTC (permalink / raw)
To: qemu-devel; +Cc: Michael Mueller
The patch disables the early invocation of list_cpus() to allow
the dynamically initialization of all S390 cpu classes in current
host runtime context.
Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
---
vl.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/vl.c b/vl.c
index efb8644..15731b0 100644
--- a/vl.c
+++ b/vl.c
@@ -3841,9 +3841,11 @@ int main(int argc, char **argv, char **envp)
*/
cpudef_init();
- if (cpu_model && is_help_option(cpu_model)) {
- list_cpus(stdout, &fprintf, cpu_model);
- exit(0);
+ if (arch_type != QEMU_ARCH_S390X) {
+ if (cpu_model && is_help_option(cpu_model)) {
+ list_cpus(stdout, &fprintf, cpu_model);
+ exit(0);
+ }
}
/* Open the logfile at this point, if necessary. We can't open the logfile
--
1.8.3.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH RFC 02/11] s390/qemu: cpu model extend config device
2013-10-02 11:33 [Qemu-devel] [PATCH RFC 00/11] s390 cpu models for KVM accelerator Michael Mueller
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 01/11] s390/qemu: cpu modle disable list cpus Michael Mueller
@ 2013-10-02 11:33 ` Michael Mueller
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 03/11] s390/qemu: cpu model cpu class definition Michael Mueller
` (8 subsequent siblings)
10 siblings, 0 replies; 19+ messages in thread
From: Michael Mueller @ 2013-10-02 11:33 UTC (permalink / raw)
To: qemu-devel; +Cc: Michael Mueller
This patch extends the s390 config device interface by the
following attributes used to impelemt cpu models:
- KVM_DEV_S390_CONFIG_CPU_TYPE
- KVM_DEV_S390_CONFIG_CPU_FACILITIES
- KVM_DEV_S390_CONFIG_KVM_FACILITY_MASK
Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
---
| 15 +++++++++++++++
1 file changed, 15 insertions(+)
--git a/linux-headers/asm-s390/kvm.h b/linux-headers/asm-s390/kvm.h
index aaddf03..d6f2ee9 100644
--- a/linux-headers/asm-s390/kvm.h
+++ b/linux-headers/asm-s390/kvm.h
@@ -58,7 +58,22 @@ struct kvm_s390_attr_name {
char name[128];
};
+struct kvm_s390_attr_cpu_type {
+ __u16 type;
+};
+
+struct kvm_s390_attr_cpu_facilities {
+ __u64 facilities[256];
+};
+
+struct kvm_s390_attr_kvm_facility_mask {
+ __u64 facility_mask[256];
+};
+
#define KVM_DEV_S390_CONFIG_NAME _IOWR(0, 1, struct kvm_s390_attr_name)
+#define KVM_DEV_S390_CONFIG_CPU_TYPE _IOWR(0, 2, struct kvm_s390_attr_cpu_type)
+#define KVM_DEV_S390_CONFIG_CPU_FACILITIES _IOWR(0, 4, struct kvm_s390_attr_cpu_facilities)
+#define KVM_DEV_S390_CONFIG_KVM_FACILITY_MASK _IOR(0, 6, struct kvm_s390_attr_kvm_facility_mask)
/* definition of registers in kvm_run */
struct kvm_sync_regs {
--
1.8.3.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH RFC 03/11] s390/qemu: cpu model cpu class definition
2013-10-02 11:33 [Qemu-devel] [PATCH RFC 00/11] s390 cpu models for KVM accelerator Michael Mueller
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 01/11] s390/qemu: cpu modle disable list cpus Michael Mueller
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 02/11] s390/qemu: cpu model extend config device Michael Mueller
@ 2013-10-02 11:33 ` Michael Mueller
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 04/11] s390/qemu: cpu model cpu facilitiy support Michael Mueller
` (7 subsequent siblings)
10 siblings, 0 replies; 19+ messages in thread
From: Michael Mueller @ 2013-10-02 11:33 UTC (permalink / raw)
To: qemu-devel; +Cc: Michael Mueller
This patch implements the static part of the s390 cpu class definitions.
It defines single cpu models by means of virtual cpu ids which contain
information on the cpu generation, the machine class, the GA number and
the machine type. The cpu id is used to instantiate a cpu classes per cpu
id.
Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
---
target-s390x/Makefile.objs | 1 +
target-s390x/cpu-models.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++
target-s390x/cpu-models.h | 66 +++++++++++++++++++++++++++++++++++++++
target-s390x/cpu-qom.h | 9 ++++++
4 files changed, 154 insertions(+)
create mode 100644 target-s390x/cpu-models.c
create mode 100644 target-s390x/cpu-models.h
diff --git a/target-s390x/Makefile.objs b/target-s390x/Makefile.objs
index f873146..6a38ce9 100644
--- a/target-s390x/Makefile.objs
+++ b/target-s390x/Makefile.objs
@@ -1,5 +1,6 @@
obj-y += translate.o helper.o cpu.o interrupt.o
obj-y += int_helper.o fpu_helper.o cc_helper.o mem_helper.o misc_helper.o
obj-y += gdbstub.o
+obj-y += cpu-models.o
obj-$(CONFIG_SOFTMMU) += ioinst.o arch_dump.o
obj-$(CONFIG_KVM) += kvm.o
diff --git a/target-s390x/cpu-models.c b/target-s390x/cpu-models.c
new file mode 100644
index 0000000..e2e8019
--- /dev/null
+++ b/target-s390x/cpu-models.c
@@ -0,0 +1,78 @@
+/*
+ * CPU models for s390
+ *
+ * Copyright 2013 IBM Corp.
+ *
+ * Author(s): Michael Mueller <mimu@linux.vnet.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at
+ * your option) any later version. See the COPYING file in the top-level
+ * directory.
+ */
+
+#include "cpu.h"
+#include "cpu-models.h"
+#include "hw/s390x/config.h"
+
+#define S390_PROC_DEF(_name, _cpu_id, _desc) \
+ static void \
+ glue(_cpu_id, _cpu_class_init) \
+ (ObjectClass *oc, void *data) \
+ { \
+ DeviceClass *dc = DEVICE_CLASS(oc); \
+ S390CPUClass *cc = S390_CPU_CLASS(oc); \
+ \
+ cc->order = cpu_order(_cpu_id); \
+ cc->type = cpu_type(_cpu_id); \
+ cc->class = cpu_class(_cpu_id); \
+ cc->ga = cpu_ga(_cpu_id); \
+ cc->generation = cpu_generation(_cpu_id); \
+ cc->facilities = NULL; \
+ cc->kvm_facilities = NULL; \
+ cc->is_active = true; \
+ cc->is_host = false; \
+ dc->desc = _desc; \
+ } \
+ static const TypeInfo \
+ glue(_cpu_id, _cpu_type_info) = { \
+ .name = _name "-" TYPE_S390_CPU, \
+ .parent = TYPE_S390_CPU, \
+ .class_init = glue(_cpu_id, _cpu_class_init), \
+ }; \
+ static void \
+ glue(_cpu_id, _cpu_register_types)(void) \
+ { \
+ type_register_static( \
+ &glue(_cpu_id, _cpu_type_info)); \
+ } \
+ type_init(glue(_cpu_id, _cpu_register_types))
+
+/* define S390 CPU model classes */
+S390_PROC_DEF("2064-ga1", CPU_S390_2064_GA1, "IBM zSeries 900 GA1")
+S390_PROC_DEF("2064-ga2", CPU_S390_2064_GA2, "IBM zSeries 900 GA2")
+S390_PROC_DEF("2064-ga3", CPU_S390_2064_GA3, "IBM zSeries 900 GA3")
+S390_PROC_DEF("2066-ga1", CPU_S390_2066_GA1, "IBM zSeries 800 GA1")
+S390_PROC_DEF("2084-ga1", CPU_S390_2084_GA1, "IBM zSeries 990 GA1")
+S390_PROC_DEF("2084-ga2", CPU_S390_2084_GA2, "IBM zSeries 990 GA2")
+S390_PROC_DEF("2084-ga3", CPU_S390_2084_GA3, "IBM zSeries 990 GA3")
+S390_PROC_DEF("2084-ga4", CPU_S390_2084_GA4, "IBM zSeries 990 GA4")
+S390_PROC_DEF("2084-ga5", CPU_S390_2084_GA5, "IBM zSeries 990 GA5")
+S390_PROC_DEF("2086-ga1", CPU_S390_2086_GA1, "IBM zSeries 890 GA1")
+S390_PROC_DEF("2086-ga2", CPU_S390_2086_GA2, "IBM zSeries 890 GA2")
+S390_PROC_DEF("2086-ga3", CPU_S390_2086_GA3, "IBM zSeries 890 GA3")
+S390_PROC_DEF("2094-ga1", CPU_S390_2094_GA1, "IBM Sytems z9 EC GA1")
+S390_PROC_DEF("2094-ga2", CPU_S390_2094_GA2, "IBM Sytems z9 EC GA2")
+S390_PROC_DEF("2094-ga3", CPU_S390_2094_GA3, "IBM Sytems z9 EC GA3")
+S390_PROC_DEF("2096-ga1", CPU_S390_2096_GA1, "IBM Sytems z9 BC GA1")
+S390_PROC_DEF("2096-ga2", CPU_S390_2096_GA2, "IBM Sytems z9 BC GA2")
+S390_PROC_DEF("2097-ga1", CPU_S390_2097_GA1, "IBM Sytems z10 EC GA1")
+S390_PROC_DEF("2097-ga2", CPU_S390_2097_GA2, "IBM Sytems z10 EC GA2")
+S390_PROC_DEF("2097-ga3", CPU_S390_2097_GA3, "IBM Sytems z10 EC GA3")
+S390_PROC_DEF("2098-ga1", CPU_S390_2098_GA1, "IBM Sytems z10 BC GA1")
+S390_PROC_DEF("2098-ga2", CPU_S390_2098_GA2, "IBM Sytems z10 BC GA2")
+S390_PROC_DEF("2817-ga1", CPU_S390_2817_GA1, "IBM zEnterprise 196 GA1")
+S390_PROC_DEF("2817-ga2", CPU_S390_2817_GA2, "IBM zEnterprise 196 GA2")
+S390_PROC_DEF("2818-ga1", CPU_S390_2818_GA1, "IBM zEnterprise 114 GA1")
+S390_PROC_DEF("2827-ga1", CPU_S390_2827_GA1, "IBM zEnterprise EC12 GA1")
+S390_PROC_DEF("2827-ga2", CPU_S390_2827_GA2, "IBM zEnterprise EC12 GA2")
+S390_PROC_DEF("2828-ga1", CPU_S390_2828_GA1, "IBM zEnterprise BC12 GA1")
diff --git a/target-s390x/cpu-models.h b/target-s390x/cpu-models.h
new file mode 100644
index 0000000..8a3b947
--- /dev/null
+++ b/target-s390x/cpu-models.h
@@ -0,0 +1,66 @@
+/*
+ * CPU models for s390
+ *
+ * Copyright 2013 IBM Corp.
+ *
+ * Author(s): Michael Mueller <mimu@linux.vnet.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at
+ * your option) any later version. See the COPYING file in the top-level
+ * directory.
+ */
+
+#ifndef TARGET_S390X_CPU_MODELS_H
+#define TARGET_S390X_CPU_MODELS_H
+
+#define MAX_S390_FACILITY_ULONG 2
+#define MAX_S390_FACILITY_BYTE \
+ (MAX_S390_FACILITY_ULONG * sizeof(unsigned long))
+#define MAX_S390_FACILITY_BIT \
+ (MAX_S390_FACILITY_BYTE << 3)
+
+#define cpu_type(x) (((x) >> 0) & 0xffff)
+#define cpu_order(x) (((x) >> 16) & 0xffff)
+#define cpu_ga(x) (((x) >> 16) & 0xf)
+#define cpu_class(x) (((x) >> 20) & 0x1)
+#define cpu_generation(x) (((x) >> 24) & 0xff)
+
+/*
+ * bits 0-7 : CMOS generation
+ * bits 8-9 : reserved
+ * bits 10-11 : machine class 0/unknown 1/EC 2/BC
+ * bits 12-15 : GA
+ * bits 16-31 : machine type
+ */
+enum {
+ CPU_S390_2064_GA1 = 0x07112064,
+ CPU_S390_2064_GA2 = 0x07122064,
+ CPU_S390_2064_GA3 = 0x07132064,
+ CPU_S390_2066_GA1 = 0x07212066,
+ CPU_S390_2084_GA1 = 0x08112084,
+ CPU_S390_2084_GA2 = 0x08122084,
+ CPU_S390_2084_GA3 = 0x08132084,
+ CPU_S390_2084_GA4 = 0x08142084,
+ CPU_S390_2084_GA5 = 0x08152084,
+ CPU_S390_2086_GA1 = 0x08212086,
+ CPU_S390_2086_GA2 = 0x08222086,
+ CPU_S390_2086_GA3 = 0x08232086,
+ CPU_S390_2094_GA1 = 0x09112094,
+ CPU_S390_2094_GA2 = 0x09122094,
+ CPU_S390_2094_GA3 = 0x09132094,
+ CPU_S390_2096_GA1 = 0x09212096,
+ CPU_S390_2096_GA2 = 0x09222096,
+ CPU_S390_2097_GA1 = 0x0a112097,
+ CPU_S390_2097_GA2 = 0x0a122097,
+ CPU_S390_2097_GA3 = 0x0a132097,
+ CPU_S390_2098_GA1 = 0x0a212098,
+ CPU_S390_2098_GA2 = 0x0a222098,
+ CPU_S390_2817_GA1 = 0x0b112817,
+ CPU_S390_2817_GA2 = 0x0b122817,
+ CPU_S390_2818_GA1 = 0x0b212818,
+ CPU_S390_2827_GA1 = 0x0c112827,
+ CPU_S390_2827_GA2 = 0x0c122827,
+ CPU_S390_2828_GA1 = 0x0c212828,
+};
+
+#endif
diff --git a/target-s390x/cpu-qom.h b/target-s390x/cpu-qom.h
index ac0460e..7026a8c 100644
--- a/target-s390x/cpu-qom.h
+++ b/target-s390x/cpu-qom.h
@@ -52,6 +52,15 @@ typedef struct S390CPUClass {
void (*load_normal)(CPUState *cpu);
void (*cpu_reset)(CPUState *cpu);
void (*initial_cpu_reset)(CPUState *cpu);
+ unsigned short class; /* machine class */
+ unsigned short ga; /* ga number of machine */
+ unsigned short type; /* machine type */
+ unsigned short order; /* order of availability */
+ unsigned short generation; /* S390 CMOS generation */
+ unsigned long *facilities; /* required facilities by machine type */
+ unsigned long *kvm_facilities; /* required facilities by virtual machine */
+ bool is_active; /* host supports all required facilities */
+ bool is_host; /* cpu class represents the "host" cpu model */
} S390CPUClass;
/**
--
1.8.3.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH RFC 04/11] s390/qemu: cpu model cpu facilitiy support
2013-10-02 11:33 [Qemu-devel] [PATCH RFC 00/11] s390 cpu models for KVM accelerator Michael Mueller
` (2 preceding siblings ...)
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 03/11] s390/qemu: cpu model cpu class definition Michael Mueller
@ 2013-10-02 11:33 ` Michael Mueller
2013-10-03 14:53 ` Richard Henderson
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 05/11] s390/qemu: cpu model alias support Michael Mueller
` (6 subsequent siblings)
10 siblings, 1 reply; 19+ messages in thread
From: Michael Mueller @ 2013-10-02 11:33 UTC (permalink / raw)
To: qemu-devel; +Cc: Michael Mueller
This patch defines s390 cpu facilities and their appearance/disappearance. The
implemented functions allow to calculate cpu model specific facility sets. These
sets are assiciated to the defiend cpu classes used to calculate the list of
supported cpu models.
Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
---
target-s390x/cpu-models.c | 126 +++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 125 insertions(+), 1 deletion(-)
diff --git a/target-s390x/cpu-models.c b/target-s390x/cpu-models.c
index e2e8019..b813f89 100644
--- a/target-s390x/cpu-models.c
+++ b/target-s390x/cpu-models.c
@@ -27,7 +27,7 @@
cc->class = cpu_class(_cpu_id); \
cc->ga = cpu_ga(_cpu_id); \
cc->generation = cpu_generation(_cpu_id); \
- cc->facilities = NULL; \
+ cc->facilities = facilities(_cpu_id); \
cc->kvm_facilities = NULL; \
cc->is_active = true; \
cc->is_host = false; \
@@ -47,6 +47,130 @@
} \
type_init(glue(_cpu_id, _cpu_register_types))
+static unsigned int facility_availability[MAX_S390_FACILITY_BIT] = {
+ [0] = CPU_S390_2064_GA1,
+ [1] = CPU_S390_2064_GA1,
+ [2] = CPU_S390_2064_GA1,
+ [3] = CPU_S390_2084_GA1,
+ [4] = CPU_S390_2084_GA2,
+ [6] = CPU_S390_2084_GA3,
+ [7] = CPU_S390_2094_GA1,
+ [8] = CPU_S390_2097_GA1,
+ [9] = CPU_S390_2094_GA2,
+ [10] = CPU_S390_2097_GA1,
+ [11] = CPU_S390_2097_GA1,
+ [13] = CPU_S390_2817_GA2,
+ [14] = CPU_S390_2817_GA2,
+ [16] = CPU_S390_2064_GA2, /* GA1+ */
+ [17] = CPU_S390_2084_GA1,
+ [18] = CPU_S390_2084_GA1,
+ [19] = CPU_S390_2084_GA1,
+ [20] = CPU_S390_2084_GA1,
+ [21] = CPU_S390_2094_GA1,
+ [22] = CPU_S390_2084_GA3,
+ [23] = CPU_S390_2094_GA1,
+ [24] = CPU_S390_2094_GA1,
+ [25] = CPU_S390_2094_GA1,
+ [26] = CPU_S390_2097_GA1,
+ [27] = CPU_S390_2094_GA2,
+ [28] = CPU_S390_2084_GA5,
+ [30] = CPU_S390_2094_GA1,
+ [31] = CPU_S390_2094_GA1,
+ [32] = CPU_S390_2094_GA2,
+ [33] = CPU_S390_2097_GA1,
+ [34] = CPU_S390_2097_GA1,
+ [35] = CPU_S390_2097_GA1,
+ [36] = CPU_S390_2817_GA1,
+ [37] = CPU_S390_2817_GA1,
+ [40] = CPU_S390_2097_GA3,
+ [41] = CPU_S390_2094_GA2,
+ [42] = CPU_S390_2094_GA2,
+ [43] = CPU_S390_2097_GA1,
+ [44] = CPU_S390_2094_GA3,
+ [45] = CPU_S390_2817_GA1,
+ [46] = CPU_S390_2817_GA1,
+ [47] = CPU_S390_2817_GA2,
+ [48] = CPU_S390_2827_GA1,
+ [49] = CPU_S390_2827_GA1,
+ [50] = CPU_S390_2827_GA1,
+ [51] = CPU_S390_2827_GA1,
+ [52] = CPU_S390_2827_GA1,
+ [65] = CPU_S390_2097_GA2,
+ [66] = CPU_S390_2817_GA2,
+ [67] = CPU_S390_2097_GA2,
+ [68] = CPU_S390_2097_GA2,
+ [73] = CPU_S390_2827_GA1,
+ [75] = CPU_S390_2817_GA1,
+ [76] = CPU_S390_2817_GA2,
+ [77] = CPU_S390_2817_GA2,
+ [78] = CPU_S390_2827_GA1,
+};
+
+static unsigned int facility_revocation[MAX_S390_FACILITY_BIT] = {
+ [65] = CPU_S390_2817_GA1,
+};
+
+/* set a specific bit in facility set */
+static void set_facility(unsigned int nr, void *facilities)
+{
+ unsigned char *ptr;
+
+ if (nr >= MAX_S390_FACILITY_BIT) {
+ return;
+ }
+ ptr = (unsigned char *) facilities + (nr >> 3);
+ *ptr |= (0x80 >> (nr & 7));
+}
+
+/* clear a specific bit in facility set */
+static void clear_facility(unsigned int nr, void *facilities)
+{
+ unsigned char *ptr;
+
+ if (nr >= MAX_S390_FACILITY_BIT) {
+ return;
+ }
+ ptr = (unsigned char *) facilities + (nr >> 3);
+ *ptr &= ~(0x80 >> (nr & 7));
+}
+
+/* test a specific bit in facility set to be set */
+static inline int test_facility(unsigned long nr, void *facilities)
+{
+ unsigned char *ptr;
+
+ if (nr >= MAX_S390_FACILITY_BIT)
+ return 0;
+ ptr = (unsigned char *) facilities + (nr >> 3);
+ return (*ptr & (0x80 >> (nr & 7))) != 0;
+}
+
+/* calculate the facility set for a specific cpu type */
+static unsigned long *facilities(unsigned int cpu_id)
+{
+ unsigned long *fac;
+ unsigned int i;
+
+ fac = g_malloc0(MAX_S390_FACILITY_BYTE);
+ if (fac) {
+ for (i = 0; i < ARRAY_SIZE(facility_availability); i++) {
+ if (facility_availability[i]) {
+ if (cpu_order(facility_availability[i]) <= cpu_order(cpu_id)) {
+ set_facility(i, fac);
+ }
+ }
+ }
+ for (i = 0; i < ARRAY_SIZE(facility_revocation); i++) {
+ if (facility_revocation[i]) {
+ if (cpu_order(facility_revocation[i]) <= cpu_order(cpu_id)) {
+ clear_facility(i, fac);
+ }
+ }
+ }
+ }
+ return fac;
+}
+
/* define S390 CPU model classes */
S390_PROC_DEF("2064-ga1", CPU_S390_2064_GA1, "IBM zSeries 900 GA1")
S390_PROC_DEF("2064-ga2", CPU_S390_2064_GA2, "IBM zSeries 900 GA2")
--
1.8.3.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH RFC 05/11] s390/qemu: cpu model alias support
2013-10-02 11:33 [Qemu-devel] [PATCH RFC 00/11] s390 cpu models for KVM accelerator Michael Mueller
` (3 preceding siblings ...)
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 04/11] s390/qemu: cpu model cpu facilitiy support Michael Mueller
@ 2013-10-02 11:33 ` Michael Mueller
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 06/11] s390/qemu: cpu model KVM properties requests Michael Mueller
` (5 subsequent siblings)
10 siblings, 0 replies; 19+ messages in thread
From: Michael Mueller @ 2013-10-02 11:33 UTC (permalink / raw)
To: qemu-devel; +Cc: Michael Mueller
This patch implements the infrastructure to dynamically add cpu model aliases.
Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
---
target-s390x/cpu-models.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++
target-s390x/cpu-models.h | 11 ++++++++
2 files changed, 77 insertions(+)
diff --git a/target-s390x/cpu-models.c b/target-s390x/cpu-models.c
index b813f89..4a4720a 100644
--- a/target-s390x/cpu-models.c
+++ b/target-s390x/cpu-models.c
@@ -171,6 +171,69 @@ static unsigned long *facilities(unsigned int cpu_id)
return fac;
}
+static gint s390_cpu_compare_class_name(gconstpointer a, gconstpointer b)
+{
+ ObjectClass *oc = (ObjectClass *)a;
+ const char *name = b;
+
+ if (strncasecmp(name, object_class_get_name(oc), strlen(name)) == 0 &&
+ strcmp(object_class_get_name(oc) + strlen(name),
+ "-" TYPE_S390_CPU) == 0) {
+ return 0;
+ }
+ return -1;
+}
+
+ObjectClass *s390_cpu_class_by_name(const char *name)
+{
+ GSList *list, *item;
+ ObjectClass *ret = NULL;
+ S390CPUAlias *alias;
+
+ for (item = s390_cpu_aliases; item != NULL; item = item->next) {
+ alias = (S390CPUAlias *) item->data;
+ if (strcmp(alias->name, name) == 0) {
+ return s390_cpu_class_by_name(alias->model);
+ }
+ }
+ list = object_class_get_list(TYPE_S390_CPU, false);
+ item = g_slist_find_custom(list, name, s390_cpu_compare_class_name);
+ if (item) {
+ ret = OBJECT_CLASS(item->data);
+ }
+ g_slist_free(list);
+ return ret;
+}
+
+/* define a new s390 cpu alias */
+static int set_s390_cpu_alias(const char *name, const char *model)
+{
+ S390CPUAlias *alias;
+ GSList *item;
+
+ if (!name || !model) {
+ return -1;
+ }
+ if (!s390_cpu_class_by_name(model)) {
+ return -1;
+ }
+
+ alias = g_malloc0(sizeof(S390CPUAlias));
+ if (!alias) {
+ return -1;
+ }
+ item = g_slist_alloc();
+ if (!item) {
+ g_free(alias);
+ return -1;
+ }
+ alias->name = g_strdup(name);
+ alias->model = g_strdup(model);
+ s390_cpu_aliases = g_slist_append(s390_cpu_aliases, alias);
+
+ return 0;
+}
+
/* define S390 CPU model classes */
S390_PROC_DEF("2064-ga1", CPU_S390_2064_GA1, "IBM zSeries 900 GA1")
S390_PROC_DEF("2064-ga2", CPU_S390_2064_GA2, "IBM zSeries 900 GA2")
@@ -200,3 +263,6 @@ S390_PROC_DEF("2818-ga1", CPU_S390_2818_GA1, "IBM zEnterprise 114 GA1")
S390_PROC_DEF("2827-ga1", CPU_S390_2827_GA1, "IBM zEnterprise EC12 GA1")
S390_PROC_DEF("2827-ga2", CPU_S390_2827_GA2, "IBM zEnterprise EC12 GA2")
S390_PROC_DEF("2828-ga1", CPU_S390_2828_GA1, "IBM zEnterprise BC12 GA1")
+
+/* S390 CPU aliases will be added dynamically to this list */
+GSList *s390_cpu_aliases;
diff --git a/target-s390x/cpu-models.h b/target-s390x/cpu-models.h
index 8a3b947..e188eca 100644
--- a/target-s390x/cpu-models.h
+++ b/target-s390x/cpu-models.h
@@ -26,6 +26,17 @@
#define cpu_generation(x) (((x) >> 24) & 0xff)
/*
+ * S390 cpu aliases will be added dynamically
+ */
+typedef struct S390CPUAlias {
+ char *name;
+ char *model;
+} S390CPUAlias;
+extern GSList *s390_cpu_aliases;
+
+ObjectClass *s390_cpu_class_by_name(const char *name);
+
+/*
* bits 0-7 : CMOS generation
* bits 8-9 : reserved
* bits 10-11 : machine class 0/unknown 1/EC 2/BC
--
1.8.3.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH RFC 06/11] s390/qemu: cpu model KVM properties requests
2013-10-02 11:33 [Qemu-devel] [PATCH RFC 00/11] s390 cpu models for KVM accelerator Michael Mueller
` (4 preceding siblings ...)
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 05/11] s390/qemu: cpu model alias support Michael Mueller
@ 2013-10-02 11:33 ` Michael Mueller
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 07/11] s390/qemu: cpu model class initialization Michael Mueller
` (4 subsequent siblings)
10 siblings, 0 replies; 19+ messages in thread
From: Michael Mueller @ 2013-10-02 11:33 UTC (permalink / raw)
To: qemu-devel; +Cc: Michael Mueller
This patch implements the functions s390_fetch_kvm_host_props() and
s390_request_kvm_cpu_config(). They respectively retrieve or request
the machine type, cpu facilities and KVM facility mask supported by
the host. Both functions are based on the s390 configuration device
interface.
Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
---
target-s390x/cpu-models.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++
target-s390x/cpu-models.h | 16 ++++++++++++
2 files changed, 81 insertions(+)
diff --git a/target-s390x/cpu-models.c b/target-s390x/cpu-models.c
index 4a4720a..4ce1546 100644
--- a/target-s390x/cpu-models.c
+++ b/target-s390x/cpu-models.c
@@ -234,6 +234,71 @@ static int set_s390_cpu_alias(const char *name, const char *model)
return 0;
}
+/* return host specific properties */
+int s390_fetch_kvm_host_props(struct S390HostProps *prop)
+{
+ int ret;
+
+ ret = get_s390_config_attr(KVM_DEV_S390_CONFIG_CPU_TYPE,
+ &prop->vcpu.type);
+ if (ret) {
+ return ret;
+ }
+ ret = get_s390_config_attr(KVM_DEV_S390_CONFIG_CPU_FACILITIES,
+ &prop->vcpu.facilities);
+ if (ret) {
+ return ret;
+ }
+
+ ret = get_s390_config_attr(KVM_DEV_S390_CONFIG_KVM_FACILITY_MASK,
+ &prop->host.facility_mask);
+ if (ret) {
+ return ret;
+ }
+
+ return 0;
+}
+
+/* request cpu configuration defined in S390 cpu class */
+int s390_request_kvm_cpu_config(S390CPUClass *cc)
+{
+ int ret = 0;
+
+ {
+ struct kvm_s390_attr_cpu_type cpu;
+ ret = set_s390_config_attr(KVM_DEV_S390_CONFIG_CPU_TYPE, &cc->type);
+ if (ret) {
+ goto out;
+ }
+ ret = get_s390_config_attr(KVM_DEV_S390_CONFIG_CPU_TYPE, &cpu.type);
+ if (ret) {
+ goto out;
+ }
+ if (cc->type != cpu.type) {
+ goto out;
+ }
+ }
+ {
+ struct kvm_s390_attr_cpu_facilities cpu;
+ int i;
+ ret = set_s390_config_attr(KVM_DEV_S390_CONFIG_CPU_FACILITIES, cc->kvm_facilities);
+ if (ret) {
+ goto out;
+ }
+ ret = get_s390_config_attr(KVM_DEV_S390_CONFIG_CPU_FACILITIES, &cpu.facilities);
+ if (ret) {
+ goto out;
+ }
+ for (i = 0; i < sizeof(cpu.facilities) / sizeof(unsigned long); i++) {
+ if (cc->kvm_facilities[i] != cpu.facilities[i]) {
+ goto out;
+ }
+ }
+ }
+out:
+ return ret;
+}
+
/* define S390 CPU model classes */
S390_PROC_DEF("2064-ga1", CPU_S390_2064_GA1, "IBM zSeries 900 GA1")
S390_PROC_DEF("2064-ga2", CPU_S390_2064_GA2, "IBM zSeries 900 GA2")
diff --git a/target-s390x/cpu-models.h b/target-s390x/cpu-models.h
index e188eca..0789a5e 100644
--- a/target-s390x/cpu-models.h
+++ b/target-s390x/cpu-models.h
@@ -34,6 +34,22 @@ typedef struct S390CPUAlias {
} S390CPUAlias;
extern GSList *s390_cpu_aliases;
+/*
+ * host system properties used to trim s390
+ * cpu class attributes during initial kvm setup
+ */
+struct S390HostProps {
+ struct {
+ unsigned long facility_mask[256];
+ } host;
+ struct {
+ unsigned short type;
+ unsigned long facilities[256];
+ } vcpu;
+};
+
+int s390_fetch_kvm_host_props(struct S390HostProps *prop);
+int s390_request_kvm_cpu_config(S390CPUClass *cc);
ObjectClass *s390_cpu_class_by_name(const char *name);
/*
--
1.8.3.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH RFC 07/11] s390/qemu: cpu model class initialization
2013-10-02 11:33 [Qemu-devel] [PATCH RFC 00/11] s390 cpu models for KVM accelerator Michael Mueller
` (5 preceding siblings ...)
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 06/11] s390/qemu: cpu model KVM properties requests Michael Mueller
@ 2013-10-02 11:33 ` Michael Mueller
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 08/11] s390/qemu: cpu model command line option help Michael Mueller
` (3 subsequent siblings)
10 siblings, 0 replies; 19+ messages in thread
From: Michael Mueller @ 2013-10-02 11:33 UTC (permalink / raw)
To: qemu-devel; +Cc: Michael Mueller
This patch provides routines to dynamically update the previously defined s390
cpu classes in the current host context. The main function issuing this process
is s390_setup_cpu_classes(). It takes the current host context as parameter to
setup the classes accordingly. It basically performs the following sub-tasks:
- update of cpu classes with KVM host properties
- mark cpu class for cpu model "host"
- invalidate cpu classes not supported by this host
- set machine type aliases to latest ga of model (e.g. 2064 -> 2064-ga3)
- set aliases for common model names to machine types
- set alias for cpu model "host"
Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
---
target-s390x/cpu-models.c | 259 ++++++++++++++++++++++++++++++++++++++++++++++
target-s390x/cpu-models.h | 2 +
2 files changed, 261 insertions(+)
diff --git a/target-s390x/cpu-models.c b/target-s390x/cpu-models.c
index 4ce1546..ecf94a4 100644
--- a/target-s390x/cpu-models.c
+++ b/target-s390x/cpu-models.c
@@ -234,6 +234,265 @@ static int set_s390_cpu_alias(const char *name, const char *model)
return 0;
}
+/* compare order of two cpu classes for ascending sort */
+gint s390_cpu_class_asc_order_compare(gconstpointer a, gconstpointer b)
+{
+ S390CPUClass *cc_a = S390_CPU_CLASS((ObjectClass *) a);
+ S390CPUClass *cc_b = S390_CPU_CLASS((ObjectClass *) b);
+
+ if (cc_a->order < cc_b->order) {
+ return -1;
+ }
+ if (cc_a->order > cc_b->order) {
+ return 1;
+ }
+ return 0;
+}
+
+/* return machine class for specific machine type */
+static void s390_machine_class_test_cpu_class(gpointer data, gpointer user_data)
+{
+ S390CPUClass *cc = S390_CPU_CLASS((ObjectClass *) data);
+ struct {
+ unsigned short type;
+ unsigned short class;
+ bool valid;
+ } *arg = user_data;
+
+ if (arg->valid || !cc->type || arg->type != cc->type) {
+ return;
+ }
+
+ arg->class = cc->class;
+ arg->valid = true;
+}
+
+/* return machine class by machine type */
+static unsigned short machine_class(unsigned short type, void *user_data)
+{
+ GSList *list = object_class_get_list(TYPE_S390_CPU, false);
+ struct {
+ unsigned short type;
+ unsigned short class;
+ } *arg = user_data;
+
+ if (arg->type != type) {
+ arg->class = 0;
+ }
+ if (!arg->class) {
+ struct {
+ unsigned short type;
+ unsigned short class;
+ bool valid;
+ } arg_class= {
+ .type = type,
+ .class = 0,
+ .valid = false,
+ };
+ g_slist_foreach(list, (GFunc) s390_machine_class_test_cpu_class, &arg_class);
+ g_slist_free(list);
+ if (arg_class.valid) {
+ arg->class = arg_class.class;
+ }
+ }
+ arg->type = type;
+
+ return arg->class;
+}
+
+/* mark cpu class, used in host cpu model case */
+static void s390_mark_host_cpu_class(gpointer data, gpointer user_data)
+{
+ S390CPUClass *cc = S390_CPU_CLASS((ObjectClass *) data);
+ struct {
+ struct S390HostProps *prop;
+ S390CPUClass *host_cc;
+ } *arg = user_data;
+
+ if (!cc->is_active) {
+ return;
+ }
+
+ struct {
+ unsigned short type;
+ unsigned short class;
+ } arg_class = {
+ .type = 0,
+ .class = 0,
+ };
+ if (cc->class != machine_class(arg->prop->vcpu.type, &arg_class)) {
+ return;
+ }
+ if (!arg->host_cc) {
+ cc->is_host = true;
+ arg->host_cc = cc;
+ return;
+ }
+ if (cc->order > arg->host_cc->order) {
+ arg->host_cc->is_host = false;
+ cc->is_host = true;
+ arg->host_cc = cc;
+ }
+}
+
+/* update a specific cpu model class with host retrieved configuration */
+static void s390_update_cpu_class(gpointer data, gpointer user_data)
+{
+ ObjectClass *oc = data;
+ struct S390HostProps *prop = user_data;
+ S390CPUClass *cc = S390_CPU_CLASS(oc);
+ unsigned int i;
+
+ if (!cc->type) {
+ return;
+ }
+
+ /* define model specific mandatory facility set in current host context */
+ cc->kvm_facilities = g_malloc0(MAX_S390_FACILITY_BYTE);
+ if (cc->kvm_facilities) {
+ for (i = 0; i < MAX_S390_FACILITY_ULONG; i++) {
+ cc->kvm_facilities[i] = cc->facilities[i] & prop->host.facility_mask[i];
+ }
+ }
+
+ /* mark cpu class active if all required facility bits are available */
+ for (i = 0; i < MAX_S390_FACILITY_BIT && cc->is_active; i++) {
+ if (test_facility(i, cc->kvm_facilities) && !test_facility(i, prop->vcpu.facilities)) {
+ cc->is_active = false;
+ }
+ }
+}
+
+/* a cpu class that is newer then the current host */
+static void s390_deactive_not_supported_cpu_class(gpointer data, gpointer user_data)
+{
+ S390CPUClass *cc = S390_CPU_CLASS((ObjectClass *) data);
+ struct {
+ S390CPUClass *host_cc;
+ } *arg = user_data;
+
+ if (!cc->is_active) {
+ return;
+ }
+ if (cc->order > arg->host_cc->order) {
+ cc->is_active = false;
+ }
+}
+
+/* set alias by type and ga */
+static int set_s390_cpu_alias_by_type_ga(unsigned short type, unsigned short ga)
+{
+ char name[8], model[16];
+
+ snprintf(name, sizeof(name), "%04x", type);
+ snprintf(model, sizeof(model), "%04x-ga%u", type, ga);
+
+ return set_s390_cpu_alias(name, model);
+}
+
+/* set alias if sytem has latest ga of a type type */
+static void s390_set_ga_alias_from_cpu_class(gpointer data, gpointer user_data)
+{
+ S390CPUClass *cc = S390_CPU_CLASS((ObjectClass *) data);
+ struct {
+ unsigned short type;
+ unsigned short ga;
+ } *arg = user_data;
+
+ if (!cc->is_active) {
+ return;
+ }
+ if (!arg->type) {
+ arg->type = cc->type;
+ }
+ if (cc->type == arg->type) {
+ arg->ga = cc->ga;
+ return;
+ }
+ set_s390_cpu_alias_by_type_ga(arg->type, arg->ga);
+ arg->type = cc->type;
+ arg->ga = cc->ga;
+}
+
+/* set host marked cpu class as alias to respective class */
+static void s390_set_host_alias_from_cpu_class(gpointer data, gpointer user_data)
+{
+ S390CPUClass *cc = S390_CPU_CLASS((ObjectClass *) data);
+ char model[16];
+
+ if (!cc->is_active || !cc->is_host) {
+ return;
+ }
+ snprintf(model, sizeof(model), "%04x-ga%u", cc->type, cc->ga);
+ set_s390_cpu_alias("host", model);
+}
+
+/*
+ * apply host properties retrieved from KVM to cpu model classes,
+ * then find cpu model host and define further aliases
+ */
+int s390_setup_cpu_classes(struct S390HostProps *prop)
+{
+ GSList *list;
+
+ list = object_class_get_list(TYPE_S390_CPU, false);
+ list = g_slist_sort(list, s390_cpu_class_asc_order_compare);
+
+ /* update cpu classes with KVM properties */
+ g_slist_foreach(list, (GFunc) s390_update_cpu_class, (gpointer) prop);
+
+ /* define cpu model "host" */
+ struct {
+ struct S390HostProps *prop;
+ S390CPUClass *host_cc;
+ } arg_host = {
+ .prop = prop,
+ .host_cc = NULL,
+ };
+ g_slist_foreach(list, (GFunc) s390_mark_host_cpu_class, (gpointer) &arg_host);
+
+ /* invalidate cpu classes not supported by this host */
+ struct {
+ S390CPUClass *host_cc;
+ } arg_deactivate = {
+ .host_cc = arg_host.host_cc,
+ };
+ g_slist_foreach(list, (GFunc) s390_deactive_not_supported_cpu_class, &arg_deactivate);
+
+ /* set machine type aliases to latest ga of model (e.g. 2064 -> 2064-ga3) */
+ struct {
+ unsigned short type;
+ unsigned short ga;
+ } arg_alias = {
+ .type = 0,
+ .ga = 0,
+ };
+ g_slist_foreach(list, (GFunc) s390_set_ga_alias_from_cpu_class, &arg_alias);
+ set_s390_cpu_alias_by_type_ga(arg_alias.type, arg_alias.ga);
+
+ /* set aliases for common model names to machine types */
+ set_s390_cpu_alias("z900", "2064");
+ set_s390_cpu_alias("z800", "2066");
+ set_s390_cpu_alias("z990", "2084");
+ set_s390_cpu_alias("z890", "2086");
+ set_s390_cpu_alias("z9-109", "2094-ga1");
+ set_s390_cpu_alias("z9", "2094");
+ set_s390_cpu_alias("z9-bc", "2096");
+ set_s390_cpu_alias("z10", "2097");
+ set_s390_cpu_alias("z10-bc", "2098");
+ set_s390_cpu_alias("z196", "2817");
+ set_s390_cpu_alias("z114", "2818");
+ set_s390_cpu_alias("zEC12", "2827");
+ set_s390_cpu_alias("zBC12", "2828");
+
+ /* set alias for cpu model "host" */
+ g_slist_foreach(list, (GFunc) s390_set_host_alias_from_cpu_class, NULL);
+
+ g_slist_free(list);
+
+ return 0;
+}
+
/* return host specific properties */
int s390_fetch_kvm_host_props(struct S390HostProps *prop)
{
diff --git a/target-s390x/cpu-models.h b/target-s390x/cpu-models.h
index 0789a5e..6164114 100644
--- a/target-s390x/cpu-models.h
+++ b/target-s390x/cpu-models.h
@@ -50,6 +50,8 @@ struct S390HostProps {
int s390_fetch_kvm_host_props(struct S390HostProps *prop);
int s390_request_kvm_cpu_config(S390CPUClass *cc);
+gint s390_cpu_class_asc_order_compare(gconstpointer a, gconstpointer b);
+int s390_setup_cpu_classes(struct S390HostProps *prop);
ObjectClass *s390_cpu_class_by_name(const char *name);
/*
--
1.8.3.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH RFC 08/11] s390/qemu: cpu model command line option help
2013-10-02 11:33 [Qemu-devel] [PATCH RFC 00/11] s390 cpu models for KVM accelerator Michael Mueller
` (6 preceding siblings ...)
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 07/11] s390/qemu: cpu model class initialization Michael Mueller
@ 2013-10-02 11:33 ` Michael Mueller
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 09/11] s390/qemu: cpu model QMP query-cpu-definitions Michael Mueller
` (2 subsequent siblings)
10 siblings, 0 replies; 19+ messages in thread
From: Michael Mueller @ 2013-10-02 11:33 UTC (permalink / raw)
To: qemu-devel; +Cc: Michael Mueller
This patch provides a list of supported cpu models and aliases in the
current host context. See command line option -cpu {help|?}
The returned list is determined from the current host and and contains
also well know alias names. It is sorted by appearance of the respective
system:
s390 2064-ga1 IBM zSeries 900 GA1
s390 2064-ga2 IBM zSeries 900 GA2
s390 2064-ga3 IBM zSeries 900 GA3
s390 2064 (alias for 2064-ga3)
s390 z900 (alias for 2064-ga3)
s390 2066-ga1 IBM zSeries 800 GA1
s390 2066 (alias for 2066-ga1)
s390 z800 (alias for 2066-ga1)
s390 2084-ga1 IBM zSeries 990 GA1
s390 2084-ga2 IBM zSeries 990 GA2
s390 2084-ga3 IBM zSeries 990 GA3
s390 2084-ga4 IBM zSeries 990 GA4
s390 2084-ga5 IBM zSeries 990 GA5
s390 2084 (alias for 2084-ga5)
s390 z990 (alias for 2084-ga5)
s390 2086-ga1 IBM zSeries 890 GA1
s390 2086-ga2 IBM zSeries 890 GA2
s390 2086-ga3 IBM zSeries 890 GA3
s390 2086 (alias for 2086-ga3)
s390 z890 (alias for 2086-ga3)
s390 2094-ga1 IBM Sytems z9 EC GA1
s390 2094-ga2 IBM Sytems z9 EC GA2
s390 2094-ga3 IBM Sytems z9 EC GA3
s390 2094 (alias for 2094-ga3)
s390 z9 (alias for 2094-ga3)
s390 2096-ga1 IBM Sytems z9 BC GA1
s390 2096-ga2 IBM Sytems z9 BC GA2
s390 2096 (alias for 2096-ga2)
s390 z9-bc (alias for 2096-ga2)
s390 2097-ga1 IBM Sytems z10 EC GA1
s390 2097-ga2 IBM Sytems z10 EC GA2
s390 2097-ga3 IBM Sytems z10 EC GA3
s390 2097 (alias for 2097-ga3)
s390 z10 (alias for 2097-ga3)
s390 2098-ga1 IBM Sytems z10 BC GA1
s390 2098-ga2 IBM Sytems z10 BC GA2
s390 2098 (alias for 2098-ga2)
s390 z10-bc (alias for 2098-ga2)
s390 2817-ga1 IBM zEnterprise 196 GA1
s390 2817-ga2 IBM zEnterprise 196 GA2
s390 2817 (alias for 2817-ga2)
s390 z196 (alias for 2817-ga2)
s390 2818-ga1 IBM zEnterprise 114 GA1
s390 2818 (alias for 2818-ga1)
s390 z114 (alias for 2818-ga1)
s390 2827-ga1 IBM zEnterprise EC12 GA1
s390 2827 (alias for 2827-ga1)
s390 zEC12 (alias for 2827-ga1)
s390 host (alias for 2827-ga1)
Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
---
target-s390x/cpu-models.c | 30 ++++++++++++++++++++++++++++++
target-s390x/cpu-models.h | 1 +
target-s390x/cpu.c | 16 +++++++++++++++-
3 files changed, 46 insertions(+), 1 deletion(-)
diff --git a/target-s390x/cpu-models.c b/target-s390x/cpu-models.c
index ecf94a4..68b978a 100644
--- a/target-s390x/cpu-models.c
+++ b/target-s390x/cpu-models.c
@@ -558,6 +558,36 @@ out:
return ret;
}
+void s390_cpu_list_entry(gpointer data, gpointer user_data)
+{
+ ObjectClass *alias_oc, *oc = data;
+ CPUListState *s = user_data;
+ DeviceClass *dc = DEVICE_CLASS(oc);
+ S390CPUClass *cc = S390_CPU_CLASS(oc);
+ const char *typename = object_class_get_name(oc);
+ S390CPUAlias *alias;
+ GSList *item;
+ char *name;
+
+ if (!cc->is_active) {
+ return;
+ }
+ name = g_strndup(typename, strlen(typename) - strlen("-" TYPE_S390_CPU));
+ (*s->cpu_fprintf)(s->file, "s390 %-10s %s\n", name, dc->desc);
+
+ for (item = s390_cpu_aliases; item != NULL; item = item->next) {
+ alias = (S390CPUAlias *) item->data;
+ alias_oc = s390_cpu_class_by_name(alias->model);
+ if (alias_oc != oc) {
+ continue;
+ }
+ (*s->cpu_fprintf)(s->file, "s390 %-10s (alias for %s)\n",
+ alias->name, name);
+ }
+
+ g_free(name);
+}
+
/* define S390 CPU model classes */
S390_PROC_DEF("2064-ga1", CPU_S390_2064_GA1, "IBM zSeries 900 GA1")
S390_PROC_DEF("2064-ga2", CPU_S390_2064_GA2, "IBM zSeries 900 GA2")
diff --git a/target-s390x/cpu-models.h b/target-s390x/cpu-models.h
index 6164114..fd01876 100644
--- a/target-s390x/cpu-models.h
+++ b/target-s390x/cpu-models.h
@@ -53,6 +53,7 @@ int s390_request_kvm_cpu_config(S390CPUClass *cc);
gint s390_cpu_class_asc_order_compare(gconstpointer a, gconstpointer b);
int s390_setup_cpu_classes(struct S390HostProps *prop);
ObjectClass *s390_cpu_class_by_name(const char *name);
+void s390_cpu_list_entry(gpointer data, gpointer user_data);
/*
* bits 0-7 : CMOS generation
diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
index 3c89f8a..0fccc72 100644
--- a/target-s390x/cpu.c
+++ b/target-s390x/cpu.c
@@ -24,6 +24,7 @@
*/
#include "cpu.h"
+#include "cpu-models.h"
#include "qemu-common.h"
#include "qemu/timer.h"
#include "hw/hw.h"
@@ -38,7 +39,20 @@
void s390_cpu_list(FILE *f, fprintf_function cpu_fprintf)
{
#ifdef CONFIG_KVM
- (*cpu_fprintf)(f, "s390 %16s\n", "host");
+ CPUListState s = {
+ .file = f,
+ .cpu_fprintf = cpu_fprintf,
+ };
+ GSList *list;
+
+ if (kvm_enabled()) {
+ list = object_class_get_list(TYPE_S390_CPU, false);
+ list = g_slist_sort(list, s390_cpu_class_asc_order_compare);
+ g_slist_foreach(list, s390_cpu_list_entry, &s);
+ g_slist_free(list);
+ } else {
+ (*cpu_fprintf)(f, "s390 host\n");
+ }
#endif
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH RFC 09/11] s390/qemu: cpu model QMP query-cpu-definitions
2013-10-02 11:33 [Qemu-devel] [PATCH RFC 00/11] s390 cpu models for KVM accelerator Michael Mueller
` (7 preceding siblings ...)
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 08/11] s390/qemu: cpu model command line option help Michael Mueller
@ 2013-10-02 11:33 ` Michael Mueller
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 10/11] s390/qemu: cpu model QMP query-cpu-model Michael Mueller
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 11/11] s390/qemu: cpu model enablement Michael Mueller
10 siblings, 0 replies; 19+ messages in thread
From: Michael Mueller @ 2013-10-02 11:33 UTC (permalink / raw)
To: qemu-devel; +Cc: Michael Mueller
This patch implements the QMP command "query-cpu-definitions" in the S390
context. The command returns a descending sorted list of cpu model names
derived from the currently (in the current host context) supported set of
cpu classes. That means a consumer can successfully request each reported
cpu model. Implicitly, the first reported cpu model is the host cpu model.
request: {"execute": "query-cpu-definitions"}
answer: {"return": [{"name": "2827-ga1"}, {"name": "2818-ga1"}, {"name": "2817-ga2"},
{"name": "2817-ga1"}, {"name": "2098-ga2"}, {"name": "2098-ga1"}, {"name": "2097-ga3"},
{"name": "2097-ga2"}, {"name": "2097-ga1"}, {"name": "2096-ga2"}, {"name": "2096-ga1"},
{"name": "2094-ga3"}, {"name": "2094-ga2"}, {"name": "2094-ga1"}, {"name": "2086-ga3"},
{"name": "2086-ga2"}, {"name": "2086-ga1"}, {"name": "2084-ga5"}, {"name": "2084-ga4"},
{"name": "2084-ga3"}, {"name": "2084-ga2"}, {"name": "2084-ga1"}, {"name": "2068-ga1"},
{"name": "2064-ga3"}, {"name": "2064-ga2"}, {"name": "2064-ga1"}]}
Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
---
target-s390x/cpu-models.c | 15 +++++++++++
target-s390x/cpu-models.h | 1 +
target-s390x/cpu.c | 69 +++++++++++++++++++++++++++++++++++++++++++----
3 files changed, 80 insertions(+), 5 deletions(-)
diff --git a/target-s390x/cpu-models.c b/target-s390x/cpu-models.c
index 68b978a..f07ff17 100644
--- a/target-s390x/cpu-models.c
+++ b/target-s390x/cpu-models.c
@@ -249,6 +249,21 @@ gint s390_cpu_class_asc_order_compare(gconstpointer a, gconstpointer b)
return 0;
}
+/* compare order of two cpu classes for descending sort */
+gint s390_cpu_class_desc_order_compare(gconstpointer a, gconstpointer b)
+{
+ S390CPUClass *cc_a = S390_CPU_CLASS((ObjectClass *) a);
+ S390CPUClass *cc_b = S390_CPU_CLASS((ObjectClass *) b);
+
+ if (cc_a->order < cc_b->order) {
+ return 1;
+ }
+ if (cc_a->order > cc_b->order) {
+ return -1;
+ }
+ return 0;
+}
+
/* return machine class for specific machine type */
static void s390_machine_class_test_cpu_class(gpointer data, gpointer user_data)
{
diff --git a/target-s390x/cpu-models.h b/target-s390x/cpu-models.h
index fd01876..9d02ce6 100644
--- a/target-s390x/cpu-models.h
+++ b/target-s390x/cpu-models.h
@@ -51,6 +51,7 @@ struct S390HostProps {
int s390_fetch_kvm_host_props(struct S390HostProps *prop);
int s390_request_kvm_cpu_config(S390CPUClass *cc);
gint s390_cpu_class_asc_order_compare(gconstpointer a, gconstpointer b);
+gint s390_cpu_class_desc_order_compare(gconstpointer a, gconstpointer b);
int s390_setup_cpu_classes(struct S390HostProps *prop);
ObjectClass *s390_cpu_class_by_name(const char *name);
void s390_cpu_list_entry(gpointer data, gpointer user_data);
diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
index 0fccc72..b790905 100644
--- a/target-s390x/cpu.c
+++ b/target-s390x/cpu.c
@@ -57,18 +57,77 @@ void s390_cpu_list(FILE *f, fprintf_function cpu_fprintf)
}
#ifndef CONFIG_USER_ONLY
-CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
-{
- CpuDefinitionInfoList *entry;
+static void s390_query_cpu_definition(gpointer data, gpointer user_data) {
+ S390CPUClass *cc = S390_CPU_CLASS((ObjectClass *) data);
+ char model[16];
CpuDefinitionInfo *info;
+ CpuDefinitionInfoList *entry;
+ struct {
+ CpuDefinitionInfoList *head;
+ CpuDefinitionInfoList *tail;
+ } *cpu_definition = user_data;
+
+ if (!cc->is_active) {
+ return;
+ }
+
info = g_malloc0(sizeof(*info));
- info->name = g_strdup("host");
+ if (!info) {
+ return;
+ }
+
+ snprintf(model, sizeof(model), "%04x-ga%u", cc->type, cc->ga);
+ info->name = g_strdup(model);
+ if (!info->name) {
+ return;
+ g_free(info);
+ }
entry = g_malloc0(sizeof(*entry));
+ if (!entry) {
+ g_free(info->name);
+ g_free(info);
+ return;
+ }
entry->value = info;
+ entry->next = NULL;
- return entry;
+ if (cpu_definition->tail) {
+ cpu_definition->tail->next = entry;
+ cpu_definition->tail = cpu_definition->tail->next;
+ } else {
+ cpu_definition->head = cpu_definition->tail = entry;
+ }
+}
+
+CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
+{
+ if (kvm_enabled()) {
+ GSList *list;
+
+ list = object_class_get_list(TYPE_S390_CPU, false);
+ list = g_slist_sort(list, s390_cpu_class_desc_order_compare);
+ struct {
+ CpuDefinitionInfoList *head;
+ CpuDefinitionInfoList *tail;
+ } cpu_definition = {
+ .head = NULL,
+ .tail = NULL,
+ };
+ g_slist_foreach(list, s390_query_cpu_definition, &cpu_definition);
+ g_slist_free(list);
+ return cpu_definition.head;
+ } else {
+ CpuDefinitionInfoList *entry;
+ CpuDefinitionInfo *info;
+
+ info = g_malloc0(sizeof(*info));
+ info->name = g_strdup("host");
+ entry = g_malloc0(sizeof(*entry));
+ entry->value = info;
+ return entry;
+ }
}
#endif
--
1.8.3.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH RFC 10/11] s390/qemu: cpu model QMP query-cpu-model
2013-10-02 11:33 [Qemu-devel] [PATCH RFC 00/11] s390 cpu models for KVM accelerator Michael Mueller
` (8 preceding siblings ...)
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 09/11] s390/qemu: cpu model QMP query-cpu-definitions Michael Mueller
@ 2013-10-02 11:33 ` Michael Mueller
2013-10-02 12:06 ` Eric Blake
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 11/11] s390/qemu: cpu model enablement Michael Mueller
10 siblings, 1 reply; 19+ messages in thread
From: Michael Mueller @ 2013-10-02 11:33 UTC (permalink / raw)
To: qemu-devel; +Cc: Michael Mueller
This patch implements a new QMP request named "cpu-model". It returns
the cpu model of cpu 0. eg:
request: '{"execute" : "query-cpu-model" }
answer: '{"return" : "2817-ga1" }
Alias names are resolved to their respactive machine type and GA names
already during cpu instantiation. Thus, also a cpu name like "host",
which is iplemented as alias, will return its normalized cpu model name.
Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
---
include/sysemu/arch_init.h | 1 +
qapi-schema.json | 23 +++++++++++++++++++++++
qmp-commands.hx | 6 ++++++
qmp.c | 5 +++++
target-s390x/cpu.c | 21 +++++++++++++++++++++
5 files changed, 56 insertions(+)
diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h
index be71bca..a8d623b 100644
--- a/include/sysemu/arch_init.h
+++ b/include/sysemu/arch_init.h
@@ -36,5 +36,6 @@ int kvm_available(void);
int xen_available(void);
CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp);
+CpuModelInfo *arch_query_cpu_model(Error **errp);
#endif
diff --git a/qapi-schema.json b/qapi-schema.json
index 145eca8..9e86186 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3129,6 +3129,29 @@
##
{ 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'] }
+##
+# @CpuModelInfo:
+#
+# Virtual CPU model definition.
+#
+# @name: the name of the CPU model definition
+#
+# Since: 1.x.0
+##
+{ 'type': 'CpuModelInfo',
+ 'data': { 'name': 'str' } }
+
+##
+# @query-cpu-model:
+#
+# Return to current virtual CPU model
+#
+# Returns: CpuModelInfo
+#
+# Since: 1.2.0
+##
+{ 'command': 'query-cpu-model', 'returns': 'CpuModelInfo' }
+
# @AddfdInfo:
#
# Information about a file descriptor that was added to an fd set.
diff --git a/qmp-commands.hx b/qmp-commands.hx
index b17c46e..fef83a4 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -3036,6 +3036,12 @@ EQMP
},
{
+ .name = "query-cpu-model",
+ .args_type = "",
+ .mhandler.cmd_new = qmp_marshal_input_query_cpu_model,
+ },
+
+ {
.name = "query-target",
.args_type = "",
.mhandler.cmd_new = qmp_marshal_input_query_target,
diff --git a/qmp.c b/qmp.c
index 4c149b3..d9b1921 100644
--- a/qmp.c
+++ b/qmp.c
@@ -486,6 +486,11 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
return arch_query_cpu_definitions(errp);
}
+CpuModelInfo *qmp_query_cpu_model(Error **errp)
+{
+ return arch_query_cpu_model(errp);
+}
+
void qmp_add_client(const char *protocol, const char *fdname,
bool has_skipauth, bool skipauth, bool has_tls, bool tls,
Error **errp)
diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
index b790905..605c124 100644
--- a/target-s390x/cpu.c
+++ b/target-s390x/cpu.c
@@ -129,6 +129,27 @@ CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
return entry;
}
}
+
+CpuModelInfo *arch_query_cpu_model(Error **errp)
+{
+ CpuModelInfo *cpu_model;
+ S390CPU *cpu;
+
+ cpu = s390_cpu_addr2state(0);
+ if (!cpu) {
+ return NULL;
+ }
+ cpu_model = g_malloc0(sizeof(*cpu_model));
+ if (!cpu_model) {
+ return NULL;
+ }
+ cpu_model->name = g_strdup(cpu->env.cpu_model_str);
+ if (!cpu_model->name) {
+ g_free(cpu_model);
+ return NULL;
+ }
+ return cpu_model;
+}
#endif
static void s390_cpu_set_pc(CPUState *cs, vaddr value)
--
1.8.3.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH RFC 11/11] s390/qemu: cpu model enablement
2013-10-02 11:33 [Qemu-devel] [PATCH RFC 00/11] s390 cpu models for KVM accelerator Michael Mueller
` (9 preceding siblings ...)
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 10/11] s390/qemu: cpu model QMP query-cpu-model Michael Mueller
@ 2013-10-02 11:33 ` Michael Mueller
10 siblings, 0 replies; 19+ messages in thread
From: Michael Mueller @ 2013-10-02 11:33 UTC (permalink / raw)
To: qemu-devel; +Cc: Michael Mueller
This patch enables all previous cpu model related patches and
allows the feature to become active. It basically implements
the host properties being fetched from the host and applied to
the predefined S390 cpu classes during initialization of the
HW platform. In a second step, the requeted cpu model determines
from which cpu class the cpus become instantiated.
Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
---
hw/s390x/s390-virtio-ccw.c | 15 +++++++++++++++
hw/s390x/s390-virtio.c | 31 +++++++++++++++++++++++++++++--
target-s390x/helper.c | 24 ++++++++++++++++++++++--
3 files changed, 66 insertions(+), 4 deletions(-)
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 9dd7bcc..64a1eaa 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -17,6 +17,7 @@
#include "css.h"
#include "virtio-ccw.h"
#include "hw/s390x/config.h"
+#include "cpu-models.h"
void io_subsystem_reset(void)
{
@@ -85,6 +86,7 @@ static void ccw_init(QEMUMachineInitArgs *args)
int ret;
VirtualCssBus *css_bus;
char machine_name[128];
+ struct S390HostProps prop;
/* s390x ram size detection needs a 16bit multiplier + an increment. So
guests > 64GB can be specified in 2MB steps etc. */
@@ -108,6 +110,19 @@ static void ccw_init(QEMUMachineInitArgs *args)
set_s390_config_attr(KVM_DEV_S390_CONFIG_NAME, machine_name);
}
+ if (kvm_enabled()) {
+ ret = s390_fetch_kvm_host_props(&prop);
+ if (ret) {
+ fprintf(stderr, "failed to retrieve KVM host properties\n");
+ exit(1);
+ }
+ ret = s390_setup_cpu_classes(&prop);
+ if (ret) {
+ fprintf(stderr, "failed to setup S390 cpu classes\n");
+ exit(1);
+ }
+ }
+
/* register hypercalls */
virtio_ccw_register_hcalls();
diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
index 9237150..272a987 100644
--- a/hw/s390x/s390-virtio.c
+++ b/hw/s390x/s390-virtio.c
@@ -39,6 +39,8 @@
#include "hw/s390x/s390-virtio.h"
#include "hw/s390x/config.h"
+#include "cpu-models.h"
+#include "sysemu/cpus.h"
//#define DEBUG_S390
@@ -180,12 +182,37 @@ void s390_init_ipl_dev(const char *kernel_filename,
void s390_init_cpus(const char *cpu_model, uint8_t *storage_keys)
{
- int i;
+ int i, ret;
+ S390CPUClass *cc;
+ ObjectClass *oc;
- if (cpu_model == NULL) {
+ if (!cpu_model) {
cpu_model = "host";
}
+ if (is_help_option(cpu_model)) {
+ list_cpus(stdout, &fprintf, cpu_model);
+ exit(0);
+ }
+
+ if (kvm_enabled()) {
+ oc = s390_cpu_class_by_name(cpu_model);
+ if (!oc) {
+ fprintf(stderr, "Unable to find s390 CPU definition %s\n", cpu_model);
+ exit(1);
+ }
+ cc = S390_CPU_CLASS(oc);
+ }
+
+ /* request CPU configuration */
+ if (kvm_enabled()) {
+ ret = s390_request_kvm_cpu_config(cc);
+ if (ret) {
+ fprintf(stderr, "failed to request CPU configaration\n");
+ exit(1);
+ }
+ }
+
ipi_states = g_malloc(sizeof(S390CPU *) * smp_cpus);
for (i = 0; i < smp_cpus; i++) {
diff --git a/target-s390x/helper.c b/target-s390x/helper.c
index 61abfd7..a3d16ff 100644
--- a/target-s390x/helper.c
+++ b/target-s390x/helper.c
@@ -19,6 +19,7 @@
*/
#include "cpu.h"
+#include "cpu-models.h"
#include "exec/gdbstub.h"
#include "qemu/timer.h"
#ifndef CONFIG_USER_ONLY
@@ -74,10 +75,29 @@ S390CPU *cpu_s390x_init(const char *cpu_model)
{
S390CPU *cpu;
CPUS390XState *env;
+ ObjectClass *oc;
+ S390CPUClass *cc;
+ char model[16];
+
+ if (kvm_enabled()) {
+ oc = s390_cpu_class_by_name(cpu_model);
+ if (!oc) {
+ return NULL;
+ }
+ cc = S390_CPU_CLASS(oc);
+ snprintf(model, sizeof(model), "%04x-ga%u", cc->type, cc->ga);
+ cpu = S390_CPU(object_new(object_class_get_name(oc)));
+ } else {
+ cpu = S390_CPU(object_new(TYPE_S390_CPU));
+ }
- cpu = S390_CPU(object_new(TYPE_S390_CPU));
env = &cpu->env;
- env->cpu_model_str = cpu_model;
+
+ if (kvm_enabled()) {
+ env->cpu_model_str = g_strdup(model);
+ } else {
+ env->cpu_model_str = cpu_model;
+ }
object_property_set_bool(OBJECT(cpu), true, "realized", NULL);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [Qemu-devel] [PATCH RFC 10/11] s390/qemu: cpu model QMP query-cpu-model
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 10/11] s390/qemu: cpu model QMP query-cpu-model Michael Mueller
@ 2013-10-02 12:06 ` Eric Blake
2013-10-02 14:30 ` Michael Mueller
0 siblings, 1 reply; 19+ messages in thread
From: Eric Blake @ 2013-10-02 12:06 UTC (permalink / raw)
To: Michael Mueller; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1216 bytes --]
On 10/02/2013 05:33 AM, Michael Mueller wrote:
> This patch implements a new QMP request named "cpu-model". It returns
> the cpu model of cpu 0. eg:
>
> request: '{"execute" : "query-cpu-model" }
> answer: '{"return" : "2817-ga1" }
>
> Alias names are resolved to their respactive machine type and GA names
> already during cpu instantiation. Thus, also a cpu name like "host",
> which is iplemented as alias, will return its normalized cpu model name.
>
> Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
> ---
> +++ b/qapi-schema.json
> @@ -3129,6 +3129,29 @@
> ##
> { 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'] }
>
> +##
> +# @CpuModelInfo:
> +#
> +# Virtual CPU model definition.
> +#
> +# @name: the name of the CPU model definition
> +#
> +# Since: 1.x.0
s/x/7/ - you are targetting 1.7.0 after all.
> +##
> +{ 'type': 'CpuModelInfo',
> + 'data': { 'name': 'str' } }
> +
> +##
> +# @query-cpu-model:
> +#
> +# Return to current virtual CPU model
> +#
> +# Returns: CpuModelInfo
> +#
> +# Since: 1.2.0
s/2/7/
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 621 bytes --]
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Qemu-devel] [PATCH RFC 10/11] s390/qemu: cpu model QMP query-cpu-model
2013-10-02 12:06 ` Eric Blake
@ 2013-10-02 14:30 ` Michael Mueller
0 siblings, 0 replies; 19+ messages in thread
From: Michael Mueller @ 2013-10-02 14:30 UTC (permalink / raw)
To: Eric Blake; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1290 bytes --]
On Wed, 02 Oct 2013 06:06:32 -0600
Eric Blake <eblake@redhat.com> wrote:
> On 10/02/2013 05:33 AM, Michael Mueller wrote:
> > This patch implements a new QMP request named "cpu-model". It returns
> > the cpu model of cpu 0. eg:
> >
> > request: '{"execute" : "query-cpu-model" }
> > answer: '{"return" : "2817-ga1" }
> >
> > Alias names are resolved to their respactive machine type and GA names
> > already during cpu instantiation. Thus, also a cpu name like "host",
> > which is iplemented as alias, will return its normalized cpu model name.
> >
> > Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
> > ---
>
> > +++ b/qapi-schema.json
> > @@ -3129,6 +3129,29 @@
> > ##
> > { 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'] }
> >
> > +##
> > +# @CpuModelInfo:
> > +#
> > +# Virtual CPU model definition.
> > +#
> > +# @name: the name of the CPU model definition
> > +#
> > +# Since: 1.x.0
>
> s/x/7/ - you are targetting 1.7.0 after all.
welcome
>
> > +##
> > +{ 'type': 'CpuModelInfo',
> > + 'data': { 'name': 'str' } }
> > +
> > +##
> > +# @query-cpu-model:
> > +#
> > +# Return to current virtual CPU model
> > +#
> > +# Returns: CpuModelInfo
> > +#
> > +# Since: 1.2.0
>
> s/2/7/
yep
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Qemu-devel] [PATCH RFC 04/11] s390/qemu: cpu model cpu facilitiy support
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 04/11] s390/qemu: cpu model cpu facilitiy support Michael Mueller
@ 2013-10-03 14:53 ` Richard Henderson
2013-10-07 10:47 ` Michael Mueller
0 siblings, 1 reply; 19+ messages in thread
From: Richard Henderson @ 2013-10-03 14:53 UTC (permalink / raw)
To: Michael Mueller; +Cc: qemu-devel
On 10/02/2013 04:33 AM, Michael Mueller wrote:
> +/* set a specific bit in facility set */
> +static void set_facility(unsigned int nr, void *facilities)
> +{
> + unsigned char *ptr;
> +
> + if (nr >= MAX_S390_FACILITY_BIT) {
> + return;
> + }
> + ptr = (unsigned char *) facilities + (nr >> 3);
> + *ptr |= (0x80 >> (nr & 7));
> +}
I'd like to see this done in a host endian independent way.
See my recent patch set to add facility support to the tcg side
of target-s390, with which this patch set is going to conflict.
Is there a good reason not to compute these facility masks at
compile-time? See
http://patchwork.ozlabs.org/patch/279534/
where I have pre-computed (possibly incomplete) facilities lists
for the major cpu revisions.
It just seems like your facility_availability array is the wrong
way to go about things, taking up more memory and startup time
than necessary.
r~
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Qemu-devel] [PATCH RFC 04/11] s390/qemu: cpu model cpu facilitiy support
2013-10-03 14:53 ` Richard Henderson
@ 2013-10-07 10:47 ` Michael Mueller
2013-10-07 15:35 ` Michael Mueller
2013-10-15 22:46 ` Richard Henderson
0 siblings, 2 replies; 19+ messages in thread
From: Michael Mueller @ 2013-10-07 10:47 UTC (permalink / raw)
To: Richard Henderson; +Cc: qemu-devel
On Thu, 03 Oct 2013 07:53:02 -0700
Richard Henderson <rth@twiddle.net> wrote:
> On 10/02/2013 04:33 AM, Michael Mueller wrote:
> > +/* set a specific bit in facility set */
> > +static void set_facility(unsigned int nr, void *facilities)
> > +{
> > + unsigned char *ptr;
> > +
> > + if (nr >= MAX_S390_FACILITY_BIT) {
> > + return;
> > + }
> > + ptr = (unsigned char *) facilities + (nr >> 3);
> > + *ptr |= (0x80 >> (nr & 7));
> > +}
>
> I'd like to see this done in a host endian independent way.
valid point, I will address that.
>
> See my recent patch set to add facility support to the tcg side
> of target-s390, with which this patch set is going to conflict.
I saw it, that's why I've pushed this patch set out for RFC.
>
> Is there a good reason not to compute these facility masks at
> compile-time? See
>
> http://patchwork.ozlabs.org/patch/279534/
>
> where I have pre-computed (possibly incomplete) facilities lists
> for the major cpu revisions.
Your facilities lists have been derived from constants introduced in head.S. They represent model
specific "required" facilities. That does not necessarily mean for all of them that they have
been introduced with the respective model. Some have been introduced already with model: N-1, GA>1
>
> It just seems like your facility_availability array is the wrong
> way to go about things, taking up more memory and startup time
> than necessary.
>
The reason why I represent them in the data segment is that they are are not considered as
constants in the s390 system perspective. I plan to be able to simulate firmware migration that
introduce new facility bits without the need of restarting the guest OS.
A second reason for using 2k of memory here is to fully represent the facilities as defined
in the s390x architecture. The SIE state needs it and I want to represent it identically in user
space and KVM. Otherwise I would need a specific interface just for the facilities.
I will consider to alternatively use your way of FAC definition, but still that would include a
copy.
In regard to the startup time, I will figure out what the overhead is.
Thanks a lot!
Michael
>
> r~
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Qemu-devel] [PATCH RFC 04/11] s390/qemu: cpu model cpu facilitiy support
2013-10-07 10:47 ` Michael Mueller
@ 2013-10-07 15:35 ` Michael Mueller
2013-10-15 22:46 ` Richard Henderson
1 sibling, 0 replies; 19+ messages in thread
From: Michael Mueller @ 2013-10-07 15:35 UTC (permalink / raw)
To: Michael Mueller; +Cc: qemu-devel, Richard Henderson
On Mon, 7 Oct 2013 12:47:53 +0200
Michael Mueller <mimu@linux.vnet.ibm.com> wrote:
> On Thu, 03 Oct 2013 07:53:02 -0700
> Richard Henderson <rth@twiddle.net> wrote:
>
> > On 10/02/2013 04:33 AM, Michael Mueller wrote:
> > > +/* set a specific bit in facility set */
> > > +static void set_facility(unsigned int nr, void *facilities)
> > > +{
> > > + unsigned char *ptr;
> > > +
> > > + if (nr >= MAX_S390_FACILITY_BIT) {
> > > + return;
> > > + }
> > > + ptr = (unsigned char *) facilities + (nr >> 3);
> > > + *ptr |= (0x80 >> (nr & 7));
> > > +}
> >
> > I'd like to see this done in a host endian independent way.
>
> valid point, I will address that.
>
> >
> > See my recent patch set to add facility support to the tcg side
> > of target-s390, with which this patch set is going to conflict.
>
> I saw it, that's why I've pushed this patch set out for RFC.
>
> >
> > Is there a good reason not to compute these facility masks at
> > compile-time? See
> >
> > http://patchwork.ozlabs.org/patch/279534/
> >
> > where I have pre-computed (possibly incomplete) facilities lists
> > for the major cpu revisions.
>
> Your facilities lists have been derived from constants introduced in head.S. They represent
> model specific "required" facilities. That does not necessarily mean for all of them that they
> have been introduced with the respective model. Some have been introduced already with model:
> N-1, GA>1
>
> >
> > It just seems like your facility_availability array is the wrong
> > way to go about things, taking up more memory and startup time
> > than necessary.
> >
>
> The reason why I represent them in the data segment is that they are are not considered as
> constants in the s390 system perspective. I plan to be able to simulate firmware migration that
> introduce new facility bits without the need of restarting the guest OS.
>
> A second reason for using 2k of memory here is to fully represent the facilities as defined
> in the s390x architecture. The SIE state needs it and I want to represent it identically in user
> space and KVM. Otherwise I would need a specific interface just for the facilities.
>
> I will consider to alternatively use your way of FAC definition, but still that would include a
> copy.
>
> In regard to the startup time, I will figure out what the overhead is.
A measurement on a z12EC shows the overhead time to be between 500-800 ns per model. Currently
28 models are defined that means the whole calculation time takes well below 30 us.
>
> Thanks a lot!
> Michael
> >
> > r~
> >
>
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Qemu-devel] [PATCH RFC 04/11] s390/qemu: cpu model cpu facilitiy support
2013-10-07 10:47 ` Michael Mueller
2013-10-07 15:35 ` Michael Mueller
@ 2013-10-15 22:46 ` Richard Henderson
2013-10-16 12:21 ` Michael Mueller
1 sibling, 1 reply; 19+ messages in thread
From: Richard Henderson @ 2013-10-15 22:46 UTC (permalink / raw)
To: Michael Mueller; +Cc: qemu-devel
On 10/07/2013 03:47 AM, Michael Mueller wrote:
> A second reason for using 2k of memory here is to fully represent the facilities as defined
> in the s390x architecture. The SIE state needs it and I want to represent it identically in user
> space and KVM. Otherwise I would need a specific interface just for the facilities.
If KVM needs the data in the format that you've got it in now, that's fair enough.
Otherwise, 128 bits per s390 system seems nicer than 32 bits per facility.
r~
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Qemu-devel] [PATCH RFC 04/11] s390/qemu: cpu model cpu facilitiy support
2013-10-15 22:46 ` Richard Henderson
@ 2013-10-16 12:21 ` Michael Mueller
0 siblings, 0 replies; 19+ messages in thread
From: Michael Mueller @ 2013-10-16 12:21 UTC (permalink / raw)
To: Richard Henderson; +Cc: qemu-devel
On Tue, 15 Oct 2013 15:46:57 -0700
Richard Henderson <rth@twiddle.net> wrote:
> On 10/07/2013 03:47 AM, Michael Mueller wrote:
> > A second reason for using 2k of memory here is to fully represent the facilities as defined
> > in the s390x architecture. The SIE state needs it and I want to represent it identically in
> > user space and KVM. Otherwise I would need a specific interface just for the facilities.
>
> If KVM needs the data in the format that you've got it in now, that's fair enough.
>
> Otherwise, 128 bits per s390 system seems nicer than 32 bits per facility.
>
I wrote it down with defines but it is really a mess, I need to double/tripple-check it:
#define FAC0_CPU_S390_2064_GA1 \
( FAC_BIT(0, FAC_N3) \
| FAC_BIT(0, FAC_ZARCH) \
| FAC_BIT(0, FAC_ZARCH_ACTIVE))
#define FAC1_CPU_S390_2064_GA1 0ul
#define FAC0_CPU_S390_2064_GA2 \
( FAC0_CPU_S390_2064_GA1 \
| FAC_BIT(0, FAC_EXTENDED_TRANSLATION_2))
#define FAC1_CPU_S390_2064_GA2 FAC1_CPU_S390_2064_GA1
#define FAC0_CPU_S390_2064_GA3 FAC0_CPU_S390_2064_GA2
#define FAC1_CPU_S390_2064_GA3 FAC1_CPU_S390_2064_GA2
#define FAC0_CPU_S390_2066_GA1 FAC0_CPU_S390_2064_GA3
#define FAC1_CPU_S390_2066_GA1 FAC0_CPU_S390_2064_GA3
#define FAC0_CPU_S390_2084_GA1 \
( FAC0_CPU_S390_2064_GA3 \
| FAC_BIT(0, FAC_DAT_ENH) \
| FAC_BIT(0, FAC_MESSAGE_SECURITY_ASSIST) \
| FAC_BIT(0, FAC_LONG_DISPLACEMENT) \
| FAC_BIT(0, FAC_LONG_DISPLACEMENT_FAST) \
| FAC_BIT(0, FAC_HFP_MADDSUB))
#define FAC1_CPU_S390_2084_GA1 FAC1_CPU_S390_2064_GA3
#define FAC0_CPU_S390_2084_GA2 \
( FAC0_CPU_S390_2084_GA1 \
| FAC_BIT(0, 4))
#define FAC1_CPU_S390_2084_GA2 FAC1_CPU_S390_2084_GA1
#define FAC0_CPU_S390_2084_GA3 \
( FAC0_CPU_S390_2084_GA2 \
| FAC_BIT(0, FAC_ASN_LX_REUSE) \
| FAC_BIT(0, FAC_EXTENDED_TRANSLATION_3))
#define FAC1_CPU_S390_2084_GA3 FAC1_CPU_S390_2084_GA2
#define FAC0_CPU_S390_2084_GA4 FAC0_CPU_S390_2084_GA3
#define FAC1_CPU_S390_2084_GA4 FAC1_CPU_S390_2084_GA3
#define FAC0_CPU_S390_2084_GA5 \
( FAC0_CPU_S390_2084_GA4 \
| FAC_BIT(0, FAC_TOD_CLOCK_STEERING))
#define FAC1_CPU_S390_2084_GA5 FAC1_CPU_S390_2084_GA4
#define FAC0_CPU_S390_2086_GA1 FAC0_CPU_S390_2084_GA3
#define FAC1_CPU_S390_2086_GA1 FAC1_CPU_S390_2084_GA3
#define FAC0_CPU_S390_2086_GA2 FAC0_CPU_S390_2084_GA4
#define FAC1_CPU_S390_2086_GA2 FAC1_CPU_S390_2084_GA4
#define FAC0_CPU_S390_2086_GA3 FAC0_CPU_S390_2084_GA5
#define FAC1_CPU_S390_2086_GA3 FAC1_CPU_S390_2084_GA5
#define FAC0_CPU_S390_2094_GA1 \
( FAC0_CPU_S390_2084_GA5 \
| FAC_BIT(0, FAC_STFLE) \
| FAC_BIT(0, FAC_EXTENDED_IMMEDIATE) \
| FAC_BIT(0, FAC_HFP_UNNORMALIZED_EXT) \
| FAC_BIT(0, FAC_ETF2_ENH) \
| FAC_BIT(0, FAC_STORE_CLOCK_FAST) \
| FAC_BIT(0, FAC_ETF3_ENH) \
| FAC_BIT(0, FAC_EXTRACT_CPU_TIME))
#define FAC1_CPU_S390_2094_GA1 FAC1_CPU_S390_2084_GA5
#define FAC0_CPU_S390_2094_GA2 \
( FAC0_CPU_S390_2094_GA1 \
| FAC_BIT(0, FAC_SENSE_RUNNING_STATUS) \
| FAC_BIT(0, FAC_MOVE_WITH_OPTIONAL_SPEC) \
| FAC_BIT(0, FAC_COMPARE_AND_SWAP_AND_STORE) \
| FAC_BIT(0, FAC_FLOATING_POINT_SUPPPORT_ENH) \
| FAC_BIT(0, FAC_DFP))
#define FAC1_CPU_S390_2094_GA2 FAC1_CPU_S390_2094_GA1
#define FAC0_CPU_S390_2094_GA3 \
( FAC0_CPU_S390_2094_GA2 \
| FAC_BIT(0, FAC_PFPO))
#define FAC1_CPU_S390_2094_GA3 FAC1_CPU_S390_2094_GA2
#define FAC0_CPU_S390_2096_GA1 FAC0_CPU_S390_2094_GA3
#define FAC1_CPU_S390_2096_GA1 FAC1_CPU_S390_2094_GA3
#define FAC0_CPU_S390_2096_GA2 FAC0_CPU_S390_2096_GA1
#define FAC1_CPU_S390_2096_GA2 FAC1_CPU_S390_2096_GA1
#define FAC0_CPU_S390_2097_GA1 \
( FAC0_CPU_S390_2094_GA3 \
| FAC_BIT(0, FAC_ENHANCED_DAT_1) \
| FAC_BIT(0, FAC_CONDITIONAL_SSKE) \
| FAC_BIT(0, FAC_CONFIGURATION_TOPOLOGY) \
| FAC_BIT(0, FAC_PARSING_ENH) \
| FAC_BIT(0, FAC_COMPARE_AND_SWAP_AND_STORE_2) \
| FAC_BIT(0, FAC_GENERAL_INSTRUCTIONS_EXT) \
| FAC_BIT(0, FAC_EXECUTE_EXT) \
| FAC_BIT(0, FAC_DFP_FAST))
#define FAC1_CPU_S390_2097_GA1 FAC1_CPU_S390_2094_GA3
#define FAC0_CPU_S390_2097_GA2 FAC0_CPU_S390_2097_GA1
#define FAC1_CPU_S390_2097_GA2 \
( FAC1_CPU_S390_2097_GA1 \
| FAC_BIT(1, 65) \
| FAC_BIT(1, FAC_CPU_MEASUREMENT_COUNTER) \
| FAC_BIT(1, FAC_CPU_MEASUREMENT_SAMPLING))
#define FAC0_CPU_S390_2097_GA3 \
( FAC0_CPU_S390_2097_GA2 \
| FAC_BIT(0, FAC_SET_PROGRAM_PARAMETERS))
#define FAC1_CPU_S390_2097_GA3 FAC1_CPU_S390_2097_GA2
#define FAC0_CPU_S390_2098_GA1 FAC0_CPU_S390_2097_GA2
#define FAC1_CPU_S390_2098_GA1 FAC1_CPU_S390_2097_GA2
#define FAC0_CPU_S390_2098_GA2 FAC0_CPU_S390_2097_GA3
#define FAC1_CPU_S390_2098_GA2 FAC1_CPU_S390_2097_GA3
#define FAC0_CPU_S390_2817_GA1 \
( FAC0_CPU_S390_2097_GA3 \
| FAC_BIT(0, FAC_ENHANCED_MONITOR) \
| FAC_BIT(0, FAC_FLOATING_POINT_EXT) \
| FAC_BIT(0, FAC_MULTI_45) \
| FAC_BIT(0, 46))
#define FAC1_CPU_S390_2817_GA1 \
((FAC1_CPU_S390_2097_GA3 \
& ~FAC_BIT(1, 65)) \
| FAC_BIT(1, FAC_ACCESS_EXCEPTION_FS_INDICATION))
#define FAC0_CPU_S390_2817_GA2 \
( FAC0_CPU_S390_2817_GA1 \
| FAC_BIT(0, FAC_IPTE_RANGE) \
| FAC_BIT(0, FAC_NONQ_KEY_SETTING) \
| FAC_BIT(0, FAC_CMPSC_ENH))
#define FAC1_CPU_S390_2817_GA2 \
( FAC1_CPU_S390_2817_GA1 \
| FAC_BIT(1, FAC_RESET_REFERENCE_BITS_MULTIPLE) \
| FAC_BIT(1, FAC_MESSAGE_SECURITY_ASSIST_3) \
| FAC_BIT(1, FAC_MESSAGE_SECURITY_ASSIST_4))
#define FAC0_CPU_S390_2818_GA1 FAC0_CPU_S390_2817_GA2
#define FAC1_CPU_S390_2818_GA1 FAC1_CPU_S390_2817_GA2
#define FAC0_CPU_S390_2827_GA1 \
( FAC0_CPU_S390_2817_GA2 \
| FAC_BIT(0, FAC_DFP_ZONED_CONVERSION) \
| FAC_BIT(0, FAC_MULTI_49) \
| FAC_BIT(0, FAC_CONSTRAINT_TRANSACTIONAL_EXE) \
| FAC_BIT(0, FAC_LOCAL_TLB_CLEARING) \
| FAC_BIT(0, FAC_INTERLOCKED_ACCESS_2))
#define FAC1_CPU_S390_2827_GA1 \
( FAC1_CPU_S390_2817_GA2 \
| FAC_BIT(1, FAC_TRANSACTIONAL_EXE) \
| FAC_BIT(1, FAC_ENHANCED_DAT_2))
#define FAC0_CPU_S390_2827_GA2 FAC0_CPU_S390_2827_GA1
#define FAC1_CPU_S390_2827_GA2 FAC1_CPU_S390_2827_GA1
#define FAC0_CPU_S390_2828_GA1 FAC0_CPU_S390_2827_GA2
#define FAC1_CPU_S390_2828_GA1 FAC1_CPU_S390_2827_GA2
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2013-10-16 12:22 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-02 11:33 [Qemu-devel] [PATCH RFC 00/11] s390 cpu models for KVM accelerator Michael Mueller
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 01/11] s390/qemu: cpu modle disable list cpus Michael Mueller
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 02/11] s390/qemu: cpu model extend config device Michael Mueller
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 03/11] s390/qemu: cpu model cpu class definition Michael Mueller
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 04/11] s390/qemu: cpu model cpu facilitiy support Michael Mueller
2013-10-03 14:53 ` Richard Henderson
2013-10-07 10:47 ` Michael Mueller
2013-10-07 15:35 ` Michael Mueller
2013-10-15 22:46 ` Richard Henderson
2013-10-16 12:21 ` Michael Mueller
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 05/11] s390/qemu: cpu model alias support Michael Mueller
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 06/11] s390/qemu: cpu model KVM properties requests Michael Mueller
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 07/11] s390/qemu: cpu model class initialization Michael Mueller
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 08/11] s390/qemu: cpu model command line option help Michael Mueller
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 09/11] s390/qemu: cpu model QMP query-cpu-definitions Michael Mueller
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 10/11] s390/qemu: cpu model QMP query-cpu-model Michael Mueller
2013-10-02 12:06 ` Eric Blake
2013-10-02 14:30 ` Michael Mueller
2013-10-02 11:33 ` [Qemu-devel] [PATCH RFC 11/11] s390/qemu: cpu model enablement Michael Mueller
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).