~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to target-s390x/cpu_models.h

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * CPU models for s390x
3
 
 *
4
 
 * Copyright 2016 IBM Corp.
5
 
 *
6
 
 * Author(s): David Hildenbrand <dahi@linux.vnet.ibm.com>
7
 
 *
8
 
 * This work is licensed under the terms of the GNU GPL, version 2 or (at
9
 
 * your option) any later version. See the COPYING file in the top-level
10
 
 * directory.
11
 
 */
12
 
 
13
 
#ifndef TARGET_S390X_CPU_MODELS_H
14
 
#define TARGET_S390X_CPU_MODELS_H
15
 
 
16
 
#include "cpu_features.h"
17
 
#include "qom/cpu.h"
18
 
 
19
 
/* static CPU definition */
20
 
typedef struct S390CPUDef {
21
 
    const char *name;       /* name exposed to the user */
22
 
    const char *desc;       /* description exposed to the user */
23
 
    uint8_t gen;            /* hw generation identification */
24
 
    uint16_t type;          /* cpu type identification */
25
 
    uint8_t ec_ga;          /* EC GA version (on which also the BC is based) */
26
 
    uint8_t mha_pow;        /* Maximum Host Adress Power, mha = 2^pow-1 */
27
 
    uint32_t hmfai;         /* hypervisor-managed facilities */
28
 
    /* base/min features, must never be changed between QEMU versions */
29
 
    S390FeatBitmap base_feat;
30
 
    /* used to init base_feat from generated data */
31
 
    S390FeatInit base_init;
32
 
    /* deafault features, QEMU version specific */
33
 
    S390FeatBitmap default_feat;
34
 
    /* used to init default_feat from generated data */
35
 
    S390FeatInit default_init;
36
 
    /* max allowed features, QEMU version specific */
37
 
    S390FeatBitmap full_feat;
38
 
    /* used to init full_feat from generated data */
39
 
    S390FeatInit full_init;
40
 
} S390CPUDef;
41
 
 
42
 
/* CPU model based on a CPU definition */
43
 
typedef struct S390CPUModel {
44
 
    const S390CPUDef *def;
45
 
    S390FeatBitmap features;
46
 
    /* values copied from the "host" model, can change during migration */
47
 
    uint16_t lowest_ibc;    /* lowest IBC that the hardware supports */
48
 
    uint32_t cpu_id;        /* CPU id */
49
 
    uint8_t cpu_ver;        /* CPU version, usually "ff" for kvm */
50
 
} S390CPUModel;
51
 
 
52
 
/*
53
 
 * CPU ID
54
 
 *
55
 
 * bits 0-7: Zeroes (ff for kvm)
56
 
 * bits 8-31: CPU ID (serial number)
57
 
 * bits 32-48: Machine type
58
 
 * bits 48-63: Zeroes
59
 
 */
60
 
#define cpuid_type(x)     (((x) >> 16) & 0xffff)
61
 
#define cpuid_id(x)       (((x) >> 32) & 0xffffff)
62
 
#define cpuid_ver(x)      (((x) >> 56) & 0xff)
63
 
 
64
 
#define lowest_ibc(x)     (((uint32_t)(x) >> 16) & 0xfff)
65
 
#define unblocked_ibc(x)  ((uint32_t)(x) & 0xfff)
66
 
#define has_ibc(x)        (lowest_ibc(x) != 0)
67
 
 
68
 
#define S390_GEN_Z10 0xa
69
 
#define ibc_gen(x)        (x == 0 ? 0 : ((x >> 4) + S390_GEN_Z10))
70
 
#define ibc_ec_ga(x)      (x & 0xf)
71
 
 
72
 
uint32_t s390_get_hmfai(void);
73
 
uint8_t s390_get_mha_pow(void);
74
 
uint32_t s390_get_ibc_val(void);
75
 
static inline uint16_t s390_ibc_from_cpu_model(const S390CPUModel *model)
76
 
{
77
 
    uint16_t ibc = 0;
78
 
 
79
 
    if (model->def->gen >= S390_GEN_Z10) {
80
 
        ibc = ((model->def->gen - S390_GEN_Z10) << 4) + model->def->ec_ga;
81
 
    }
82
 
    return ibc;
83
 
}
84
 
void s390_get_feat_block(S390FeatType type, uint8_t *data);
85
 
bool s390_has_feat(S390Feat feat);
86
 
uint8_t s390_get_gen_for_cpu_type(uint16_t type);
87
 
static inline bool s390_known_cpu_type(uint16_t type)
88
 
{
89
 
    return s390_get_gen_for_cpu_type(type) != 0;
90
 
}
91
 
static inline uint64_t s390_cpuid_from_cpu_model(const S390CPUModel *model)
92
 
{
93
 
    return ((uint64_t)model->cpu_ver << 56) |
94
 
           ((uint64_t)model->cpu_id << 32) |
95
 
           ((uint64_t)model->def->type << 16);
96
 
}
97
 
S390CPUDef const *s390_find_cpu_def(uint16_t type, uint8_t gen, uint8_t ec_ga,
98
 
                                    S390FeatBitmap features);
99
 
 
100
 
#ifdef CONFIG_KVM
101
 
bool kvm_s390_cpu_models_supported(void);
102
 
void kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp);
103
 
void kvm_s390_apply_cpu_model(const S390CPUModel *model,  Error **errp);
104
 
#else
105
 
static inline void kvm_s390_get_host_cpu_model(S390CPUModel *model,
106
 
                                               Error **errp)
107
 
{
108
 
}
109
 
static inline void kvm_s390_apply_cpu_model(const S390CPUModel *model,
110
 
                                            Error **errp)
111
 
{
112
 
}
113
 
static inline bool kvm_s390_cpu_models_supported(void)
114
 
{
115
 
    return false;
116
 
}
117
 
#endif
118
 
 
119
 
#endif /* TARGET_S390X_CPU_MODELS_H */