s390 cpu models for KVM accelerator
cover s390 cpu models for KVM accelerator
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
Signature · 1 line
1.8.3.1
RFC PATCH 1/11 s390/qemu: cpu modle disable list cpus
The patch disables the early invocation of list_cpus() to allow the dynamically initialization of all S390 cpu classes in current host runtime context.
--- vl.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
vl.c +5 -3
@@ -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
Signature · 1 line
1.8.3.1
RFC PATCH 2/11 s390/qemu: cpu model extend config device
In reply to Michael MuellerThis 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
--- linux-headers/asm-s390/kvm.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
linux-headers/asm-s390/kvm.h +15 -0
@@ -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 {
Signature · 1 line
1.8.3.1
RFC PATCH 3/11 s390/qemu: cpu model cpu class definition
In reply to Michael MuellerThis 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.
--- 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
target-s390x/Makefile.objs +1 -0
@@ -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
target-s390x/cpu-models.c new file +78 -0
78 lines not on this page · raw message
target-s390x/cpu-models.h new file +66 -0
66 lines not on this page · raw message
target-s390x/cpu-qom.h +9 -0
@@ -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;/**
Signature · 1 line
1.8.3.1
RFC PATCH 4/11 s390/qemu: cpu model cpu facilitiy support
In reply to Michael MuellerThis 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.
--- target-s390x/cpu-models.c | 126 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 125 insertions(+), 1 deletion(-)
target-s390x/cpu-models.c +125 -1
@@ -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" )
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH RFC 04/11] s390/qemu: cpu model cpu facilitiy support
target-s390x/cpu-models.c line 123
Quoted 11 lines · Michael Mueller
target-s390x/cpu-models.c +11
-0+/* 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~
Re: [Qemu-devel] [PATCH RFC 04/11] s390/qemu: cpu model cpu facilitiy support
Quoted 14 lines · On Thu, 03 Oct 2013 07:53:02 -0700 Richard Henderson <[email protected]> wrote:
target-s390x/cpu-models.c line 123
Quoted 11 lines · Michael Mueller
target-s390x/cpu-models.c +11
-0+/* 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.
Quoted 3 lines
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.
Quoted 8 lines
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
Quoted 5 lines
It just seems like your
facility_availabilityarray 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
Quoted 3 lines
r~
Re: [Qemu-devel] [PATCH RFC 04/11] s390/qemu: cpu model cpu facilitiy support
Quoted 50 lines · On Mon, 7 Oct 2013 12:47:53 +0200 Michael Mueller <[email protected]>…
Quoted 14 lines · On Thu, 03 Oct 2013 07:53:02 -0700 Richard Henderson <[email protected]> wrote:
target-s390x/cpu-models.c line 123
Quoted 11 lines · Michael Mueller
target-s390x/cpu-models.c +11
-0+/* 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.
Quoted 3 lines
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.
Quoted 8 lines
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>1Quoted 5 lines
It just seems like your
facility_availabilityarray 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.
Quoted 8 lines
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.
Quoted 8 lines
Thanks a lot!
MichaelQuoted 3 lines
r~
Re: [Qemu-devel] [PATCH RFC 04/11] s390/qemu: cpu model cpu facilitiy support
In reply to Michael MuellerQuoted 3 lines · Michael Mueller
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~
Re: [Qemu-devel] [PATCH RFC 04/11] s390/qemu: cpu model cpu facilitiy support
Quoted 9 lines · On Tue, 15 Oct 2013 15:46:57 -0700 Richard Henderson <[email protected]> wrote:
Quoted 3 lines · Michael Mueller
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
RFC PATCH 5/11 s390/qemu: cpu model alias support
In reply to Michael MuellerThis patch implements the infrastructure to dynamically add cpu model aliases.
--- target-s390x/cpu-models.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++ target-s390x/cpu-models.h | 11 ++++++++ 2 files changed, 77 insertions(+)
target-s390x/cpu-models.c +66 -0
@@ -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;
target-s390x/cpu-models.h +11 -0
@@ -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
Signature · 1 line
1.8.3.1
RFC PATCH 6/11 s390/qemu: cpu model KVM properties requests
In reply to Michael MuellerThis 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.
--- target-s390x/cpu-models.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++ target-s390x/cpu-models.h | 16 ++++++++++++ 2 files changed, 81 insertions(+)
target-s390x/cpu-models.c +65 -0
@@ -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" )
target-s390x/cpu-models.h +16 -0
@@ -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);/*
Signature · 1 line
1.8.3.1
RFC PATCH 7/11 s390/qemu: cpu model class initialization
In reply to Michael MuellerThis 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"
--- target-s390x/cpu-models.c | 259 ++++++++++++++++++++++++++++++++++++++++++++++ target-s390x/cpu-models.h | 2 + 2 files changed, 261 insertions(+)
target-s390x/cpu-models.c +259 -0
@@ -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) {
target-s390x/cpu-models.h +2 -0
@@ -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);/*
Signature · 1 line
1.8.3.1
RFC PATCH 8/11 s390/qemu: cpu model command line option help
In reply to Michael MuellerThis 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)
--- target-s390x/cpu-models.c | 30 ++++++++++++++++++++++++++++++ target-s390x/cpu-models.h | 1 + target-s390x/cpu.c | 16 +++++++++++++++- 3 files changed, 46 insertions(+), 1 deletion(-)
target-s390x/cpu-models.c +30 -0
@@ -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" )
target-s390x/cpu-models.h +1 -0
@@ -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
target-s390x/cpu.c +15 -1
@@ -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 }
Signature · 1 line
1.8.3.1
RFC PATCH 9/11 s390/qemu: cpu model QMP query-cpu-definitions
In reply to Michael MuellerThis 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"}]}
--- target-s390x/cpu-models.c | 15 +++++++++++ target-s390x/cpu-models.h | 1 + target-s390x/cpu.c | 69 +++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 80 insertions(+), 5 deletions(-)
target-s390x/cpu-models.c +15 -0
@@ -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) {
target-s390x/cpu-models.h +1 -0
@@ -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);
target-s390x/cpu.c +64 -5
82 lines not on this page · raw message
Signature · 1 line
1.8.3.1
RFC PATCH 10/11 s390/qemu: cpu model QMP query-cpu-model
In reply to Michael MuellerThis 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.
--- 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(+)
include/sysemu/arch_init.h +1 -0
@@ -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
qapi-schema.json +23 -0
@@ -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.
qmp-commands.hx +6 -0
@@ -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,
qmp.c +5 -0
@@ -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)
target-s390x/cpu.c +21 -0
@@ -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)
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH RFC 10/11] s390/qemu: cpu model QMP query-cpu-model
Quoted 16 lines · 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 <[email protected]>---
+++
b/qapi-schema.jsonqapi-schema.json +0
-0@@ -3129,6 +3129,29 @@ ##
qapi-schema.json line 3139
Quoted 10 lines
qapi-schema.json +8
-0{ '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.
qapi-schema.json line 3151
Quoted 12 lines
qapi-schema.json +12
-0+## +{ 'type': 'CpuModelInfo', + 'data': { 'name': 'str' } } + +## +# @query-cpu-model: +# +# Return to current virtual CPU model +# +# Returns: CpuModelInfo +# +# Since: 1.2.0
s/2/7/
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH RFC 10/11] s390/qemu: cpu model QMP query-cpu-model
Quoted 19 lines · On Wed, 02 Oct 2013 06:06:32 -0600 Eric Blake <[email protected]> wrote:
Quoted 18 lines · 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 <[email protected]>---
+++
b/qapi-schema.jsonqapi-schema.json +0
-0@@ -3129,6 +3129,29 @@ ## { 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'] }
Quoted 10 lines
qapi-schema.json line 3139
Quoted 8 lines
qapi-schema.json +8
-0+## +# @CpuModelInfo: +# +# Virtual CPU model definition. +# +# @name: the name of the CPU model definition +# +# Since: 1.x.0s/x/7/ - you are targetting 1.7.0 after all.
welcome
Quoted 15 lines
qapi-schema.json line 3151
Quoted 13 lines
qapi-schema.json +12
-0+## +{ 'type': 'CpuModelInfo', + 'data': { 'name': 'str' } } + +## +# @query-cpu-model: +# +# Return to current virtual CPU model +# +# Returns: CpuModelInfo +# +# Since: 1.2.0s/2/7/
yep
Quoted 1 line
RFC PATCH 11/11 s390/qemu: cpu model enablement
In reply to Michael MuellerThis 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.
--- 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(-)
hw/s390x/s390-virtio-ccw.c +15 -0
@@ -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 ();
hw/s390x/s390-virtio.c +29 -2
@@ -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++) {
target-s390x/helper.c +22 -2
@@ -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 );
Signature · 1 line
1.8.3.1