diff mbox

[RFC,v2,04/15] cpu-model/s390: Introduce S390 CPU models

Message ID 1424183053-4310-5-git-send-email-mimu@linux.vnet.ibm.com
State New
Headers show

Commit Message

Michael Mueller Feb. 17, 2015, 2:24 p.m. UTC
This patch implements the static part of the s390 cpu class definitions.
It defines s390 cpu models by means of virtual cpu ids (enum) 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 class per cpu
model.

In addition the patch introduces the QMP enumeration AccelId. It is used
to index certain cpu model poperties per accelerator.

Furthermore it extends the existing S390CPUClass by model related properties.

Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com>
---
 qapi-schema.json           | 11 +++++++
 target-s390x/Makefile.objs |  1 +
 target-s390x/cpu-models.c  | 79 ++++++++++++++++++++++++++++++++++++++++++++++
 target-s390x/cpu-models.h  | 71 +++++++++++++++++++++++++++++++++++++++++
 target-s390x/cpu-qom.h     | 22 +++++++++++++
 target-s390x/cpu.c         |  2 ++
 6 files changed, 186 insertions(+)
 create mode 100644 target-s390x/cpu-models.c
 create mode 100644 target-s390x/cpu-models.h

Comments

Alexander Graf Feb. 20, 2015, 1:54 p.m. UTC | #1
On 17.02.15 15:24, Michael Mueller wrote:
> This patch implements the static part of the s390 cpu class definitions.
> It defines s390 cpu models by means of virtual cpu ids (enum) 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 class per cpu
> model.
> 
> In addition the patch introduces the QMP enumeration AccelId. It is used
> to index certain cpu model poperties per accelerator.
> 
> Furthermore it extends the existing S390CPUClass by model related properties.
> 
> Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
> Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com>
> ---
>  qapi-schema.json           | 11 +++++++
>  target-s390x/Makefile.objs |  1 +
>  target-s390x/cpu-models.c  | 79 ++++++++++++++++++++++++++++++++++++++++++++++
>  target-s390x/cpu-models.h  | 71 +++++++++++++++++++++++++++++++++++++++++
>  target-s390x/cpu-qom.h     | 22 +++++++++++++
>  target-s390x/cpu.c         |  2 ++
>  6 files changed, 186 insertions(+)
>  create mode 100644 target-s390x/cpu-models.c
>  create mode 100644 target-s390x/cpu-models.h
> 
> diff --git a/qapi-schema.json b/qapi-schema.json
> index e16f8eb..4d237c8 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -2473,6 +2473,17 @@
>  ##
>  { 'command': 'query-machines', 'returns': ['MachineInfo'] }
>  
> +
> +##
> +# @AccelId
> +#
> +# Defines accelerator ids
> +#
> +# Since: 2.3.0
> +##
> +{ 'enum': 'AccelId',
> +  'data': ['qtest', 'tcg', 'kvm', 'xen'  ] }
> +
>  ##
>  # @CpuDefinitionInfo:
>  #
> diff --git a/target-s390x/Makefile.objs b/target-s390x/Makefile.objs
> index 2c57494..9f55140 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) += machine.o 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..4841553
> --- /dev/null
> +++ b/target-s390x/cpu-models.c
> @@ -0,0 +1,79 @@
> +/*
> + * CPU models for s390
> + *
> + * Copyright 2014,2015 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 "qemu-common.h"
> +#include "cpu-models.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->is_active[ACCEL_ID_KVM] = true;                             \
> +        cc->mach        = g_malloc0(sizeof(S390CPUMachineProps));       \
> +        cc->mach->ga    = cpu_ga(_cpu_id);                              \
> +        cc->mach->class = cpu_class(_cpu_id);                           \
> +        cc->mach->order = cpu_order(_cpu_id);                           \
> +        cc->proc        = g_malloc0(sizeof(S390CPUProcessorProps));     \
> +        cc->proc->gen   = cpu_generation(_cpu_id);                      \
> +        cc->proc->ver   = S390_DEF_VERSION;                             \
> +        cc->proc->id    = S390_DEF_ID;                                  \
> +        cc->proc->type  = cpu_type(_cpu_id);                            \
> +        cc->proc->ibc   = S390_DEF_IBC;                                 \
> +        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 System z9 EC GA1")
> +S390_PROC_DEF("2094-ga2", CPU_S390_2094_GA2, "IBM System z9 EC GA2")
> +S390_PROC_DEF("2094-ga3", CPU_S390_2094_GA3, "IBM System z9 EC GA3")
> +S390_PROC_DEF("2096-ga1", CPU_S390_2096_GA1, "IBM System z9 BC GA1")
> +S390_PROC_DEF("2096-ga2", CPU_S390_2096_GA2, "IBM System z9 BC GA2")
> +S390_PROC_DEF("2097-ga1", CPU_S390_2097_GA1, "IBM System z10 EC GA1")
> +S390_PROC_DEF("2097-ga2", CPU_S390_2097_GA2, "IBM System z10 EC GA2")
> +S390_PROC_DEF("2097-ga3", CPU_S390_2097_GA3, "IBM System z10 EC GA3")
> +S390_PROC_DEF("2098-ga1", CPU_S390_2098_GA1, "IBM System z10 BC GA1")
> +S390_PROC_DEF("2098-ga2", CPU_S390_2098_GA2, "IBM System 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..db681bf
> --- /dev/null
> +++ b/target-s390x/cpu-models.h
> @@ -0,0 +1,71 @@
> +/*
> + * CPU models for s390
> + *
> + * Copyright 2014,2015 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 S390_EC 0x1
> +#define S390_BC 0x2
> +
> +#define S390_DEF_VERSION 0xff
> +#define S390_DEF_IBC     0x0
> +#define S390_DEF_ID      0xdecade
> +#define S390_DEF_TYPE    0x2064
> +
> +#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) & 0x3)
> +#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
> + *
> + * note: bits are named according to s390
> + *       architecture specific endienness
> + */
> +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 8b376df..1332147 100644
> --- a/target-s390x/cpu-qom.h
> +++ b/target-s390x/cpu-qom.h
> @@ -32,6 +32,23 @@
>  #define S390_CPU_GET_CLASS(obj) \
>      OBJECT_GET_CLASS(S390CPUClass, (obj), TYPE_S390_CPU)
>  
> +/* machine related properties */
> +typedef struct S390CPUMachineProps {
> +    uint16_t class;      /* machine class */
> +    uint16_t ga;         /* availability number of machine */
> +    uint16_t order;      /* order of availability */
> +} S390CPUMachineProps;
> +
> +/* processor related properties */
> +typedef struct S390CPUProcessorProps {
> +    uint16_t gen;        /* S390 CMOS generation */
> +    uint16_t ver;        /* version of processor */
> +    uint32_t id;         /* processor identification*/
> +    uint16_t type;       /* machine type */
> +    uint16_t ibc;        /* IBC value */
> +    uint64_t *fac_list;  /* list of facilities */

Just make this uint64_t fac_list[2]. That way we don't have to track any
messy allocations.


Alex
Alexander Graf Feb. 20, 2015, 1:55 p.m. UTC | #2
On 17.02.15 15:24, Michael Mueller wrote:
> This patch implements the static part of the s390 cpu class definitions.
> It defines s390 cpu models by means of virtual cpu ids (enum) 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 class per cpu
> model.
> 
> In addition the patch introduces the QMP enumeration AccelId. It is used
> to index certain cpu model poperties per accelerator.
> 
> Furthermore it extends the existing S390CPUClass by model related properties.
> 
> Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
> Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com>
> ---
>  qapi-schema.json           | 11 +++++++
>  target-s390x/Makefile.objs |  1 +
>  target-s390x/cpu-models.c  | 79 ++++++++++++++++++++++++++++++++++++++++++++++
>  target-s390x/cpu-models.h  | 71 +++++++++++++++++++++++++++++++++++++++++
>  target-s390x/cpu-qom.h     | 22 +++++++++++++
>  target-s390x/cpu.c         |  2 ++
>  6 files changed, 186 insertions(+)
>  create mode 100644 target-s390x/cpu-models.c
>  create mode 100644 target-s390x/cpu-models.h
> 
> diff --git a/qapi-schema.json b/qapi-schema.json
> index e16f8eb..4d237c8 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -2473,6 +2473,17 @@
>  ##
>  { 'command': 'query-machines', 'returns': ['MachineInfo'] }
>  
> +
> +##
> +# @AccelId
> +#
> +# Defines accelerator ids
> +#
> +# Since: 2.3.0
> +##
> +{ 'enum': 'AccelId',
> +  'data': ['qtest', 'tcg', 'kvm', 'xen'  ] }
> +
>  ##
>  # @CpuDefinitionInfo:
>  #
> diff --git a/target-s390x/Makefile.objs b/target-s390x/Makefile.objs
> index 2c57494..9f55140 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) += machine.o 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..4841553
> --- /dev/null
> +++ b/target-s390x/cpu-models.c
> @@ -0,0 +1,79 @@
> +/*
> + * CPU models for s390
> + *
> + * Copyright 2014,2015 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 "qemu-common.h"
> +#include "cpu-models.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->is_active[ACCEL_ID_KVM] = true;                             \
> +        cc->mach        = g_malloc0(sizeof(S390CPUMachineProps));       \
> +        cc->mach->ga    = cpu_ga(_cpu_id);                              \
> +        cc->mach->class = cpu_class(_cpu_id);                           \
> +        cc->mach->order = cpu_order(_cpu_id);                           \
> +        cc->proc        = g_malloc0(sizeof(S390CPUProcessorProps));     \
> +        cc->proc->gen   = cpu_generation(_cpu_id);                      \
> +        cc->proc->ver   = S390_DEF_VERSION;                             \
> +        cc->proc->id    = S390_DEF_ID;                                  \
> +        cc->proc->type  = cpu_type(_cpu_id);                            \
> +        cc->proc->ibc   = S390_DEF_IBC;                                 \
> +        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 System z9 EC GA1")
> +S390_PROC_DEF("2094-ga2", CPU_S390_2094_GA2, "IBM System z9 EC GA2")
> +S390_PROC_DEF("2094-ga3", CPU_S390_2094_GA3, "IBM System z9 EC GA3")
> +S390_PROC_DEF("2096-ga1", CPU_S390_2096_GA1, "IBM System z9 BC GA1")
> +S390_PROC_DEF("2096-ga2", CPU_S390_2096_GA2, "IBM System z9 BC GA2")
> +S390_PROC_DEF("2097-ga1", CPU_S390_2097_GA1, "IBM System z10 EC GA1")
> +S390_PROC_DEF("2097-ga2", CPU_S390_2097_GA2, "IBM System z10 EC GA2")
> +S390_PROC_DEF("2097-ga3", CPU_S390_2097_GA3, "IBM System z10 EC GA3")
> +S390_PROC_DEF("2098-ga1", CPU_S390_2098_GA1, "IBM System z10 BC GA1")
> +S390_PROC_DEF("2098-ga2", CPU_S390_2098_GA2, "IBM System 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..db681bf
> --- /dev/null
> +++ b/target-s390x/cpu-models.h
> @@ -0,0 +1,71 @@
> +/*
> + * CPU models for s390
> + *
> + * Copyright 2014,2015 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 S390_EC 0x1
> +#define S390_BC 0x2
> +
> +#define S390_DEF_VERSION 0xff
> +#define S390_DEF_IBC     0x0
> +#define S390_DEF_ID      0xdecade
> +#define S390_DEF_TYPE    0x2064
> +
> +#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) & 0x3)
> +#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
> + *
> + * note: bits are named according to s390
> + *       architecture specific endienness
> + */
> +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 8b376df..1332147 100644
> --- a/target-s390x/cpu-qom.h
> +++ b/target-s390x/cpu-qom.h
> @@ -32,6 +32,23 @@
>  #define S390_CPU_GET_CLASS(obj) \
>      OBJECT_GET_CLASS(S390CPUClass, (obj), TYPE_S390_CPU)
>  
> +/* machine related properties */
> +typedef struct S390CPUMachineProps {
> +    uint16_t class;      /* machine class */
> +    uint16_t ga;         /* availability number of machine */
> +    uint16_t order;      /* order of availability */
> +} S390CPUMachineProps;
> +
> +/* processor related properties */
> +typedef struct S390CPUProcessorProps {
> +    uint16_t gen;        /* S390 CMOS generation */
> +    uint16_t ver;        /* version of processor */
> +    uint32_t id;         /* processor identification*/
> +    uint16_t type;       /* machine type */
> +    uint16_t ibc;        /* IBC value */
> +    uint64_t *fac_list;  /* list of facilities */
> +} S390CPUProcessorProps;
> +
>  /**
>   * S390CPUClass:
>   * @parent_realize: The parent class' realize handler.
> @@ -52,6 +69,11 @@ typedef struct S390CPUClass {
>      void (*load_normal)(CPUState *cpu);
>      void (*cpu_reset)(CPUState *cpu);
>      void (*initial_cpu_reset)(CPUState *cpu);
> +    bool is_active[ACCEL_ID_MAX]; /* model enabled for given host and accel */
> +    bool is_host[ACCEL_ID_MAX];   /* model markes host for given accel */
> +    uint64_t *fac_list;           /* active facility list */
> +    S390CPUMachineProps   *mach;  /* machine specific properties */
> +    S390CPUProcessorProps *proc;  /* processor specific properties */

Sorry, same here. Just put the structs straight into the class struct.


Alex
Michael Mueller Feb. 20, 2015, 3 p.m. UTC | #3
On Fri, 20 Feb 2015 14:54:23 +0100
Alexander Graf <agraf@suse.de> wrote:

> >  
> > +/* machine related properties */
> > +typedef struct S390CPUMachineProps {
> > +    uint16_t class;      /* machine class */
> > +    uint16_t ga;         /* availability number of machine */
> > +    uint16_t order;      /* order of availability */
> > +} S390CPUMachineProps;
> > +
> > +/* processor related properties */
> > +typedef struct S390CPUProcessorProps {
> > +    uint16_t gen;        /* S390 CMOS generation */
> > +    uint16_t ver;        /* version of processor */
> > +    uint32_t id;         /* processor identification*/
> > +    uint16_t type;       /* machine type */
> > +    uint16_t ibc;        /* IBC value */
> > +    uint64_t *fac_list;  /* list of facilities */  
> 
> Just make this uint64_t fac_list[2]. That way we don't have to track any
> messy allocations.

It will be something like "uint64_t fac_list[S390_CPU_FAC_LIST_SIZE_UINT64]" and in total 2KB not
just 16 bytes but I will change it.
Michael Mueller Feb. 20, 2015, 3:02 p.m. UTC | #4
On Fri, 20 Feb 2015 14:55:32 +0100
Alexander Graf <agraf@suse.de> wrote:

> >  /**
> >   * S390CPUClass:
> >   * @parent_realize: The parent class' realize handler.
> > @@ -52,6 +69,11 @@ typedef struct S390CPUClass {
> >      void (*load_normal)(CPUState *cpu);
> >      void (*cpu_reset)(CPUState *cpu);
> >      void (*initial_cpu_reset)(CPUState *cpu);
> > +    bool is_active[ACCEL_ID_MAX]; /* model enabled for given host and accel */
> > +    bool is_host[ACCEL_ID_MAX];   /* model markes host for given accel */
> > +    uint64_t *fac_list;           /* active facility list */
> > +    S390CPUMachineProps   *mach;  /* machine specific properties */
> > +    S390CPUProcessorProps *proc;  /* processor specific properties */  
> 
> Sorry, same here. Just put the structs straight into the class struct.

Yep, consistent.
Alexander Graf Feb. 20, 2015, 3:22 p.m. UTC | #5
> Am 20.02.2015 um 16:00 schrieb Michael Mueller <mimu@linux.vnet.ibm.com>:
> 
> On Fri, 20 Feb 2015 14:54:23 +0100
> Alexander Graf <agraf@suse.de> wrote:
> 
>>> 
>>> +/* machine related properties */
>>> +typedef struct S390CPUMachineProps {
>>> +    uint16_t class;      /* machine class */
>>> +    uint16_t ga;         /* availability number of machine */
>>> +    uint16_t order;      /* order of availability */
>>> +} S390CPUMachineProps;
>>> +
>>> +/* processor related properties */
>>> +typedef struct S390CPUProcessorProps {
>>> +    uint16_t gen;        /* S390 CMOS generation */
>>> +    uint16_t ver;        /* version of processor */
>>> +    uint32_t id;         /* processor identification*/
>>> +    uint16_t type;       /* machine type */
>>> +    uint16_t ibc;        /* IBC value */
>>> +    uint64_t *fac_list;  /* list of facilities */  
>> 
>> Just make this uint64_t fac_list[2]. That way we don't have to track any
>> messy allocations.
> 
> It will be something like "uint64_t fac_list[S390_CPU_FAC_LIST_SIZE_UINT64]" and in total 2KB not
> just 16 bytes but I will change it. 

Why? Do we actually need that many? This is a qemu internal struct.

Alex
Michael Mueller Feb. 20, 2015, 3:49 p.m. UTC | #6
On Fri, 20 Feb 2015 16:22:20 +0100
Alexander Graf <agraf@suse.de> wrote:

> >> 
> >> Just make this uint64_t fac_list[2]. That way we don't have to track any
> >> messy allocations.  
> > 
> > It will be something like "uint64_t fac_list[S390_CPU_FAC_LIST_SIZE_UINT64]" and in total 2KB
> > not just 16 bytes but I will change it.   
> 
> Why? Do we actually need that many? This is a qemu internal struct.

How do you know that 2 is a good size?

I want to have this independent from a future machine of the z/Arch. The kernel stores the full
facility set, KVM does and there is no good reason for QEMU not to do. If other accelerators
decide to just implement 64 or 128 bits of facilities that's ok...

Michael
Alexander Graf Feb. 20, 2015, 4:57 p.m. UTC | #7
On 20.02.15 16:49, Michael Mueller wrote:
> On Fri, 20 Feb 2015 16:22:20 +0100
> Alexander Graf <agraf@suse.de> wrote:
> 
>>>>
>>>> Just make this uint64_t fac_list[2]. That way we don't have to track any
>>>> messy allocations.  
>>>
>>> It will be something like "uint64_t fac_list[S390_CPU_FAC_LIST_SIZE_UINT64]" and in total 2KB
>>> not just 16 bytes but I will change it.   
>>
>> Why? Do we actually need that many? This is a qemu internal struct.
> 
> How do you know that 2 is a good size?

Because all CPUs we have in our list only expose 128 bits?

> I want to have this independent from a future machine of the z/Arch. The kernel stores the full
> facility set, KVM does and there is no good reason for QEMU not to do. If other accelerators
> decide to just implement 64 or 128 bits of facilities that's ok...

So you want to support CPUs that are not part of the list?


Alex
Michael Mueller Feb. 20, 2015, 5:37 p.m. UTC | #8
On Fri, 20 Feb 2015 17:57:52 +0100
Alexander Graf <agraf@suse.de> wrote:

> Because all CPUs we have in our list only expose 128 bits?

Here a STFLE result on a EC12 GA2, already more than 128 bits... Is that model on the list?

[mimu@p57lp59 s390xfac]$ ./s390xfac -b
fac[0] = 0xfbfffffbfcfff840
fac[1] = 0xffde000000000000
fac[2] = 0x1800000000000000
> 
> > I want to have this independent from a future machine of the z/Arch. The kernel stores the
> > full facility set, KVM does and there is no good reason for QEMU not to do. If other
> > accelerators decide to just implement 64 or 128 bits of facilities that's ok...  
> 
> So you want to support CPUs that are not part of the list?

The architecture at least defines more than 2 or 3. Do you want me to limit it to an arbitrary
size?. Only in QEMU or also in the KVM interface?

Thanks
Michael
Alexander Graf Feb. 20, 2015, 5:50 p.m. UTC | #9
> Am 20.02.2015 um 18:37 schrieb Michael Mueller <mimu@linux.vnet.ibm.com>:
> 
> On Fri, 20 Feb 2015 17:57:52 +0100
> Alexander Graf <agraf@suse.de> wrote:
> 
>> Because all CPUs we have in our list only expose 128 bits?
> 
> Here a STFLE result on a EC12 GA2, already more than 128 bits... Is that model on the list?

If that model has 3 elements, yes, the array should span 3.

I hope it's in the list. Every model wecare about should be, no?

> 
> [mimu@p57lp59 s390xfac]$ ./s390xfac -b
> fac[0] = 0xfbfffffbfcfff840
> fac[1] = 0xffde000000000000
> fac[2] = 0x1800000000000000
>> 
>>> I want to have this independent from a future machine of the z/Arch. The kernel stores the
>>> full facility set, KVM does and there is no good reason for QEMU not to do. If other
>>> accelerators decide to just implement 64 or 128 bits of facilities that's ok...  
>> 
>> So you want to support CPUs that are not part of the list?
> 
> The architecture at least defines more than 2 or 3. Do you want me to limit it to an arbitrary
> size?. Only in QEMU or also in the KVM interface?

Only internally in QEMU. The kvm interface should definitely be as big as the spec allows!

Alex

> 
> Thanks
> Michael
>
Michael Mueller Feb. 20, 2015, 7:43 p.m. UTC | #10
On Fri, 20 Feb 2015 18:50:20 +0100
Alexander Graf <agraf@suse.de> wrote:

> 
> 
> 
> > Am 20.02.2015 um 18:37 schrieb Michael Mueller <mimu@linux.vnet.ibm.com>:
> > 
> > On Fri, 20 Feb 2015 17:57:52 +0100
> > Alexander Graf <agraf@suse.de> wrote:
> > 
> >> Because all CPUs we have in our list only expose 128 bits?
> > 
> > Here a STFLE result on a EC12 GA2, already more than 128 bits... Is that model on the list?
> 
> If that model has 3 elements, yes, the array should span 3.
> 
> I hope it's in the list. Every model wecare about should be, no?
> 

On my list? Yes!

> > 
> > [mimu@p57lp59 s390xfac]$ ./s390xfac -b
> > fac[0] = 0xfbfffffbfcfff840
> > fac[1] = 0xffde000000000000
> > fac[2] = 0x1800000000000000
> >> 
> >>> I want to have this independent from a future machine of the z/Arch. The kernel stores the
> >>> full facility set, KVM does and there is no good reason for QEMU not to do. If other
> >>> accelerators decide to just implement 64 or 128 bits of facilities that's ok...  
> >> 
> >> So you want to support CPUs that are not part of the list?
> > 
> > The architecture at least defines more than 2 or 3. Do you want me to limit it to an arbitrary
> > size?. Only in QEMU or also in the KVM interface?
> 
> Only internally in QEMU. The kvm interface should definitely be as big as the spec allows!

Right, now we're on the same page again. That can be taken in consideration. ... Although it's
just and optimization. :-)

Michael

> 
> Alex
> 
> > 
> > Thanks
> > Michael
> > 
>
Alexander Graf Feb. 20, 2015, 7:55 p.m. UTC | #11
On 20.02.15 20:43, Michael Mueller wrote:
> On Fri, 20 Feb 2015 18:50:20 +0100
> Alexander Graf <agraf@suse.de> wrote:
> 
>>
>>
>>
>>> Am 20.02.2015 um 18:37 schrieb Michael Mueller <mimu@linux.vnet.ibm.com>:
>>>
>>> On Fri, 20 Feb 2015 17:57:52 +0100
>>> Alexander Graf <agraf@suse.de> wrote:
>>>
>>>> Because all CPUs we have in our list only expose 128 bits?
>>>
>>> Here a STFLE result on a EC12 GA2, already more than 128 bits... Is that model on the list?
>>
>> If that model has 3 elements, yes, the array should span 3.
>>
>> I hope it's in the list. Every model wecare about should be, no?
>>
> 
> On my list? Yes!
> 
>>>
>>> [mimu@p57lp59 s390xfac]$ ./s390xfac -b
>>> fac[0] = 0xfbfffffbfcfff840
>>> fac[1] = 0xffde000000000000
>>> fac[2] = 0x1800000000000000
>>>>
>>>>> I want to have this independent from a future machine of the z/Arch. The kernel stores the
>>>>> full facility set, KVM does and there is no good reason for QEMU not to do. If other
>>>>> accelerators decide to just implement 64 or 128 bits of facilities that's ok...  
>>>>
>>>> So you want to support CPUs that are not part of the list?
>>>
>>> The architecture at least defines more than 2 or 3. Do you want me to limit it to an arbitrary
>>> size?. Only in QEMU or also in the KVM interface?
>>
>> Only internally in QEMU. The kvm interface should definitely be as big as the spec allows!
> 
> Right, now we're on the same page again. That can be taken in consideration. ... Although it's
> just and optimization. :-)

Yeah. You could also consider using the QEMU built-in bitmap type and
functions and just convert from there. That would give you native
support for bit values > 64.


Alex
Christian Borntraeger Feb. 23, 2015, 12:56 p.m. UTC | #12
Am 20.02.2015 um 16:22 schrieb Alexander Graf:
> 
> 
> 
>> Am 20.02.2015 um 16:00 schrieb Michael Mueller <mimu@linux.vnet.ibm.com>:
>>
>> On Fri, 20 Feb 2015 14:54:23 +0100
>> Alexander Graf <agraf@suse.de> wrote:
>>
>>>>
>>>> +/* machine related properties */
>>>> +typedef struct S390CPUMachineProps {
>>>> +    uint16_t class;      /* machine class */
>>>> +    uint16_t ga;         /* availability number of machine */
>>>> +    uint16_t order;      /* order of availability */
>>>> +} S390CPUMachineProps;
>>>> +
>>>> +/* processor related properties */
>>>> +typedef struct S390CPUProcessorProps {
>>>> +    uint16_t gen;        /* S390 CMOS generation */
>>>> +    uint16_t ver;        /* version of processor */
>>>> +    uint32_t id;         /* processor identification*/
>>>> +    uint16_t type;       /* machine type */
>>>> +    uint16_t ibc;        /* IBC value */
>>>> +    uint64_t *fac_list;  /* list of facilities */  
>>>
>>> Just make this uint64_t fac_list[2]. That way we don't have to track any
>>> messy allocations.
>>
>> It will be something like "uint64_t fac_list[S390_CPU_FAC_LIST_SIZE_UINT64]" and in total 2KB not
>> just 16 bytes but I will change it. 
> 
> Why? Do we actually need that many? This is a qemu internal struct.

The kernel already enabled the 3rd word for z13 support, 
https://git.kernel.org/cgit/linux/kernel/git/s390/linux.git/commit/?id=f8b2dcbd9e6d1479b9b5a9e9e78bbaf783bde819

so make it at least 3.
Christian Borntraeger Feb. 23, 2015, 1:27 p.m. UTC | #13
Am 23.02.2015 um 13:56 schrieb Christian Borntraeger:
> Am 20.02.2015 um 16:22 schrieb Alexander Graf:
>>
>>
>>
>>> Am 20.02.2015 um 16:00 schrieb Michael Mueller <mimu@linux.vnet.ibm.com>:
>>>
>>> On Fri, 20 Feb 2015 14:54:23 +0100
>>> Alexander Graf <agraf@suse.de> wrote:
>>>
>>>>>
>>>>> +/* machine related properties */
>>>>> +typedef struct S390CPUMachineProps {
>>>>> +    uint16_t class;      /* machine class */
>>>>> +    uint16_t ga;         /* availability number of machine */
>>>>> +    uint16_t order;      /* order of availability */
>>>>> +} S390CPUMachineProps;
>>>>> +
>>>>> +/* processor related properties */
>>>>> +typedef struct S390CPUProcessorProps {
>>>>> +    uint16_t gen;        /* S390 CMOS generation */
>>>>> +    uint16_t ver;        /* version of processor */
>>>>> +    uint32_t id;         /* processor identification*/
>>>>> +    uint16_t type;       /* machine type */
>>>>> +    uint16_t ibc;        /* IBC value */
>>>>> +    uint64_t *fac_list;  /* list of facilities */  
>>>>
>>>> Just make this uint64_t fac_list[2]. That way we don't have to track any
>>>> messy allocations.
>>>
>>> It will be something like "uint64_t fac_list[S390_CPU_FAC_LIST_SIZE_UINT64]" and in total 2KB not
>>> just 16 bytes but I will change it. 
>>
>> Why? Do we actually need that many? This is a qemu internal struct.
> 
> The kernel already enabled the 3rd word for z13 support, 
> https://git.kernel.org/cgit/linux/kernel/git/s390/linux.git/commit/?id=f8b2dcbd9e6d1479b9b5a9e9e78bbaf783bde819
> 
> so make it at least 3.


This should have been 

commit 8070361799ae1e3f4ef347bd10f0a508ac10acfb
Author: Martin Schwidefsky <schwidefsky@de.ibm.com>
Date:   Mon Oct 6 17:53:53 2014 +0200

    s390: add support for vector extension

which uses bit 129.
diff mbox

Patch

diff --git a/qapi-schema.json b/qapi-schema.json
index e16f8eb..4d237c8 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -2473,6 +2473,17 @@ 
 ##
 { 'command': 'query-machines', 'returns': ['MachineInfo'] }
 
+
+##
+# @AccelId
+#
+# Defines accelerator ids
+#
+# Since: 2.3.0
+##
+{ 'enum': 'AccelId',
+  'data': ['qtest', 'tcg', 'kvm', 'xen'  ] }
+
 ##
 # @CpuDefinitionInfo:
 #
diff --git a/target-s390x/Makefile.objs b/target-s390x/Makefile.objs
index 2c57494..9f55140 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) += machine.o 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..4841553
--- /dev/null
+++ b/target-s390x/cpu-models.c
@@ -0,0 +1,79 @@ 
+/*
+ * CPU models for s390
+ *
+ * Copyright 2014,2015 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 "qemu-common.h"
+#include "cpu-models.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->is_active[ACCEL_ID_KVM] = true;                             \
+        cc->mach        = g_malloc0(sizeof(S390CPUMachineProps));       \
+        cc->mach->ga    = cpu_ga(_cpu_id);                              \
+        cc->mach->class = cpu_class(_cpu_id);                           \
+        cc->mach->order = cpu_order(_cpu_id);                           \
+        cc->proc        = g_malloc0(sizeof(S390CPUProcessorProps));     \
+        cc->proc->gen   = cpu_generation(_cpu_id);                      \
+        cc->proc->ver   = S390_DEF_VERSION;                             \
+        cc->proc->id    = S390_DEF_ID;                                  \
+        cc->proc->type  = cpu_type(_cpu_id);                            \
+        cc->proc->ibc   = S390_DEF_IBC;                                 \
+        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 System z9 EC GA1")
+S390_PROC_DEF("2094-ga2", CPU_S390_2094_GA2, "IBM System z9 EC GA2")
+S390_PROC_DEF("2094-ga3", CPU_S390_2094_GA3, "IBM System z9 EC GA3")
+S390_PROC_DEF("2096-ga1", CPU_S390_2096_GA1, "IBM System z9 BC GA1")
+S390_PROC_DEF("2096-ga2", CPU_S390_2096_GA2, "IBM System z9 BC GA2")
+S390_PROC_DEF("2097-ga1", CPU_S390_2097_GA1, "IBM System z10 EC GA1")
+S390_PROC_DEF("2097-ga2", CPU_S390_2097_GA2, "IBM System z10 EC GA2")
+S390_PROC_DEF("2097-ga3", CPU_S390_2097_GA3, "IBM System z10 EC GA3")
+S390_PROC_DEF("2098-ga1", CPU_S390_2098_GA1, "IBM System z10 BC GA1")
+S390_PROC_DEF("2098-ga2", CPU_S390_2098_GA2, "IBM System 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..db681bf
--- /dev/null
+++ b/target-s390x/cpu-models.h
@@ -0,0 +1,71 @@ 
+/*
+ * CPU models for s390
+ *
+ * Copyright 2014,2015 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 S390_EC 0x1
+#define S390_BC 0x2
+
+#define S390_DEF_VERSION 0xff
+#define S390_DEF_IBC     0x0
+#define S390_DEF_ID      0xdecade
+#define S390_DEF_TYPE    0x2064
+
+#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) & 0x3)
+#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
+ *
+ * note: bits are named according to s390
+ *       architecture specific endienness
+ */
+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 8b376df..1332147 100644
--- a/target-s390x/cpu-qom.h
+++ b/target-s390x/cpu-qom.h
@@ -32,6 +32,23 @@ 
 #define S390_CPU_GET_CLASS(obj) \
     OBJECT_GET_CLASS(S390CPUClass, (obj), TYPE_S390_CPU)
 
+/* machine related properties */
+typedef struct S390CPUMachineProps {
+    uint16_t class;      /* machine class */
+    uint16_t ga;         /* availability number of machine */
+    uint16_t order;      /* order of availability */
+} S390CPUMachineProps;
+
+/* processor related properties */
+typedef struct S390CPUProcessorProps {
+    uint16_t gen;        /* S390 CMOS generation */
+    uint16_t ver;        /* version of processor */
+    uint32_t id;         /* processor identification*/
+    uint16_t type;       /* machine type */
+    uint16_t ibc;        /* IBC value */
+    uint64_t *fac_list;  /* list of facilities */
+} S390CPUProcessorProps;
+
 /**
  * S390CPUClass:
  * @parent_realize: The parent class' realize handler.
@@ -52,6 +69,11 @@  typedef struct S390CPUClass {
     void (*load_normal)(CPUState *cpu);
     void (*cpu_reset)(CPUState *cpu);
     void (*initial_cpu_reset)(CPUState *cpu);
+    bool is_active[ACCEL_ID_MAX]; /* model enabled for given host and accel */
+    bool is_host[ACCEL_ID_MAX];   /* model markes host for given accel */
+    uint64_t *fac_list;           /* active facility list */
+    S390CPUMachineProps   *mach;  /* machine specific properties */
+    S390CPUProcessorProps *proc;  /* processor specific properties */
 } S390CPUClass;
 
 /**
diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
index d2f6312..1040765 100644
--- a/target-s390x/cpu.c
+++ b/target-s390x/cpu.c
@@ -325,6 +325,8 @@  static void s390_cpu_class_init(ObjectClass *oc, void *data)
 #endif
     cc->gdb_num_core_regs = S390_NUM_CORE_REGS;
     cc->gdb_core_xml_file = "s390x-core64.xml";
+    scc->mach = g_malloc0(sizeof(*scc->mach));
+    scc->proc = g_malloc0(sizeof(*scc->proc));
 }
 
 static const TypeInfo s390_cpu_type_info = {