s390: remaining patches
cover s390: remaining patches
here is a bunch of patches that teaches recent HW features to the CPU model and kvm code in QEMU. We also add the enhanced suppression on protection facility to the z12 and later for the 2.10 machine type.
Christian Borntraeger (2):
s390x/arch_dump: also dump guarded storage control block s390x/gdb: add gs registers
Fan Zhang (1):
s390x/kvm: enable guarded storage
Farhan Ali (1):
s390x/kvm: Enable KSS facility for nested virtualization
Jason J. Herne (3):
s390x/cpumodel: wire up new hardware features s390x/cpumodel: we are always in zarchitecture mode s390x/cpumodel: add esop/esop2 to z12 model
configure | 2 +- gdb-xml/s390-gs.xml | 14 +++++ hw/s390x/s390-virtio-ccw.c | 21 +++++++ include/elf.h | 1 + include/hw/s390x/s390-virtio-ccw.h | 3 + include/hw/s390x/sclp.h | 3 +- target/s390x/arch_dump.c | 18 ++++++ target/s390x/cpu.h | 7 +++ target/s390x/cpu_features.c | 46 +++++++++++++- target/s390x/cpu_features.h | 4 ++ target/s390x/cpu_features_def.h | 41 ++++++++++++- target/s390x/cpu_models.c | 25 ++++++++ target/s390x/gdbstub.c | 24 ++++++++ target/s390x/gen-features.c | 42 +++++++++++++ target/s390x/kvm.c | 120 +++++++++++++++++++++++++------------ target/s390x/machine.c | 17 ++++++ 16 files changed, 345 insertions(+), 43 deletions(-) create mode 100644 gdb-xml/s390-gs.xml
Signature · 1 line
2.7.4
PATCH 1/7 s390x/cpumodel: wire up new hardware features
From: "Jason J. Herne" <[email protected]>
Some new guest features have been introduced recently. Lets wire them up in the CPU model.
--- include/hw/s390x/sclp.h | 3 +-- target/s390x/cpu_features.c | 41 +++++++++++++++++++++++++++++++++++++++++ target/s390x/cpu_features.h | 4 ++++ target/s390x/cpu_features_def.h | 41 ++++++++++++++++++++++++++++++++++++++++- target/s390x/cpu_models.c | 25 +++++++++++++++++++++++++ target/s390x/gen-features.c | 39 +++++++++++++++++++++++++++++++++++++++ target/s390x/kvm.c | 10 ++++++++++ 7 files changed, 160 insertions(+), 3 deletions(-)
include/hw/s390x/sclp.h +1 -2
@@ -123,8 +123,7 @@ typedef struct ReadInfo {uint64_t facilities;/* 48-55 */ uint8_t _reserved0[76 -56 ];/* 56-75 */ uint32_t ibc_val; -uint8_t conf_char[96 -80 ];/* 80-95 */ -uint8_t _reserved4[99 -96 ];/* 96-98 */ +uint8_t conf_char[99 -80 ];/* 80-98 */ uint8_t mha_pow;uint32_t rnsize2;uint64_t rnmax2;
target/s390x/cpu_features.c +41 -0
87 lines not on this page · raw message
target/s390x/cpu_features.h +4 -0
@@ -37,6 +37,7 @@ typedef enum {S390_FEAT_TYPE_KMO ,S390_FEAT_TYPE_PCC ,S390_FEAT_TYPE_PPNO , +S390_FEAT_TYPE_KMA , } S390FeatType;/* Definition of a CPU feature */
@@ -74,6 +75,9 @@ typedef enum {S390_FEAT_GROUP_MSA_EXT_3 ,S390_FEAT_GROUP_MSA_EXT_4 ,S390_FEAT_GROUP_MSA_EXT_5 , +S390_FEAT_GROUP_MSA_EXT_6 , +S390_FEAT_GROUP_MSA_EXT_7 , +S390_FEAT_GROUP_MSA_EXT_8 ,S390_FEAT_GROUP_MAX , } S390FeatGroup;
target/s390x/cpu_features_def.h +40 -1
83 lines not on this page · raw message
target/s390x/cpu_models.c +25 -0
@@ -697,6 +697,31 @@ static void check_consistency(const S390CPUModel *model) { S390_FEAT_SIE_CMMA, S390_FEAT_CMM }, { S390_FEAT_SIE_CMMA, S390_FEAT_SIE_GSLS }, { S390_FEAT_SIE_PFMFI, S390_FEAT_EDAT }, + { S390_FEAT_MSA_EXT_8, S390_FEAT_MSA_EXT_3 }, + { S390_FEAT_MULTIPLE_EPOCH, S390_FEAT_TOD_CLOCK_STEERING }, + { S390_FEAT_VECTOR_PACKED_DECIMAL, S390_FEAT_VECTOR }, + { S390_FEAT_VECTOR_ENH, S390_FEAT_VECTOR }, + { S390_FEAT_INSTRUCTION_EXEC_PROT, S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2 }, + { S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2, S390_FEAT_ESOP }, + { S390_FEAT_CMM_NT, S390_FEAT_CMM }, + { S390_FEAT_GUARDED_STORAGE, S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2 }, + { S390_FEAT_MULTIPLE_EPOCH, S390_FEAT_STORE_CLOCK_FAST }, + { S390_FEAT_MULTIPLE_EPOCH, S390_FEAT_TOD_CLOCK_STEERING }, + { S390_FEAT_SEMAPHORE_ASSIST, S390_FEAT_STFLE_49 }, + { S390_FEAT_KIMD_SHA3_224, S390_FEAT_MSA }, + { S390_FEAT_KIMD_SHA3_256, S390_FEAT_MSA }, + { S390_FEAT_KIMD_SHA3_384, S390_FEAT_MSA }, + { S390_FEAT_KIMD_SHA3_512, S390_FEAT_MSA }, + { S390_FEAT_KIMD_SHAKE_128, S390_FEAT_MSA }, + { S390_FEAT_KIMD_SHAKE_256, S390_FEAT_MSA }, + { S390_FEAT_KLMD_SHA3_224, S390_FEAT_MSA }, + { S390_FEAT_KLMD_SHA3_256, S390_FEAT_MSA }, + { S390_FEAT_KLMD_SHA3_384, S390_FEAT_MSA }, + { S390_FEAT_KLMD_SHA3_512, S390_FEAT_MSA }, + { S390_FEAT_KLMD_SHAKE_128, S390_FEAT_MSA }, + { S390_FEAT_KLMD_SHAKE_256, S390_FEAT_MSA }, + { S390_FEAT_PRNO_TRNG_QRTCR, S390_FEAT_MSA_EXT_5 }, + { S390_FEAT_PRNO_TRNG, S390_FEAT_MSA_EXT_5 }, };int i;
target/s390x/gen-features.c +39 -0
@@ -182,6 +182,33 @@S390_FEAT_MSA_EXT_5 , \ S390_FEAT_PPNO_SHA_512_DRNG +#define S390_FEAT_GROUP_MSA_EXT_6 \ + S390_FEAT_KIMD_SHA3_224, \ + S390_FEAT_KIMD_SHA3_256, \ + S390_FEAT_KIMD_SHA3_384, \ + S390_FEAT_KIMD_SHA3_512, \ + S390_FEAT_KIMD_SHAKE_128, \ + S390_FEAT_KIMD_SHAKE_256, \ + S390_FEAT_KLMD_SHA3_224, \ + S390_FEAT_KLMD_SHA3_256, \ + S390_FEAT_KLMD_SHA3_384, \ + S390_FEAT_KLMD_SHA3_512, \ + S390_FEAT_KLMD_SHAKE_128, \ + S390_FEAT_KLMD_SHAKE_256 + +#define S390_FEAT_GROUP_MSA_EXT_7 \ + S390_FEAT_PRNO_TRNG_QRTCR, \ + S390_FEAT_PRNO_TRNG + +#define S390_FEAT_GROUP_MSA_EXT_8 \ + S390_FEAT_MSA_EXT_8, \ + S390_FEAT_KMA_GCM_AES_128, \ + S390_FEAT_KMA_GCM_AES_192, \ + S390_FEAT_KMA_GCM_AES_256 , \ + S390_FEAT_KMA_GCM_EAES_128, \ + S390_FEAT_KMA_GCM_EAES_192, \ + S390_FEAT_KMA_GCM_EAES_256 +/* cpu feature groups */ static uint16_t group_PLO[] = {S390_FEAT_GROUP_PLO ,
@@ -210,6 +237,15 @@ static uint16_t group_MSA_EXT_4[] = {static uint16_t group_MSA_EXT_5[] = {S390_FEAT_GROUP_MSA_EXT_5 , }; +static uint16_t group_MSA_EXT_6[] = { +S390_FEAT_GROUP_MSA_EXT_6 , +}; +static uint16_t group_MSA_EXT_7[] = { +S390_FEAT_GROUP_MSA_EXT_7 , +}; +static uint16_t group_MSA_EXT_8[] = { +S390_FEAT_GROUP_MSA_EXT_8 , +};/* Base features (in order of release) * Only non-hypervisor managed features belong here.
@@ -548,6 +584,9 @@ static FeatGroupDefSpec FeatGroupDef[] = {FEAT_GROUP_INITIALIZER (MSA_EXT_3 ),FEAT_GROUP_INITIALIZER (MSA_EXT_4 ),FEAT_GROUP_INITIALIZER (MSA_EXT_5 ), +FEAT_GROUP_INITIALIZER (MSA_EXT_6 ), +FEAT_GROUP_INITIALIZER (MSA_EXT_7 ), + FEAT_GROUP_INITIALIZER(MSA_EXT_8), };static void set_bits (uint64_t list[],BitSpec bits)
target/s390x/kvm.c +10 -0
@@ -2447,6 +2447,9 @@ static int query_cpu_subfunc(S390FeatBitmap features)if (test_bit (S390_FEAT_MSA_EXT_5 , features)) {s390_add_from_feat_block (features,S390_FEAT_TYPE_PPNO , prop.ppno); } +if (test_bit (S390_FEAT_MSA_EXT_8 , features)) { +s390_add_from_feat_block (features,S390_FEAT_TYPE_KMA , prop.kma); + }return 0 ; }
@@ -2500,6 +2503,10 @@ static int configure_cpu_subfunc(const S390FeatBitmap features)s390_fill_feat_block (features,S390_FEAT_TYPE_PPNO , prop.ppno); prop.ppno[0 ] |=0x80 ;/* query is always available */ } +if (test_bit (S390_FEAT_MSA_EXT_8 , features)) { +s390_fill_feat_block (features,S390_FEAT_TYPE_KMA , prop.kma); + prop.kma[0 ] |=0x80 ;/* query is always available */ + }return kvm_vm_ioctl (kvm_state,KVM_SET_DEVICE_ATTR , &attr); }
@@ -2636,6 +2643,9 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp)/* with cpu model support, CMM is only indicated if really available */ if (kvm_s390_cmma_available ()) {set_bit (S390_FEAT_CMM , model->features); + }else { +/* no cmm -> no cmm nt */ +clear_bit (S390_FEAT_CMM_NT , model->features); }/* set zpci and aen facilities */
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH 1/7] s390x/cpumodel: wire up new hardware features
Quoted 3 lines · On Thu, 13 Jul 2017 18:03:03 +0200 Christian Borntraeger…
From: "Jason J. Herne" <[email protected]>
Some new guest features have been introduced recently. Lets wire
s/Lets/Let's/
:)
Quoted 6 lines
them up in the CPU model.
Signed-off-by Jason J. Herne <[email protected]>Signed-off-by Christian Borntraeger <[email protected]>[split patch]
Quoted 9 lines
--- include/hw/s390x/sclp.h | 3 +-- target/s390x/cpu_features.c | 41 +++++++++++++++++++++++++++++++++++++++++ target/s390x/cpu_features.h | 4 ++++ target/s390x/cpu_features_def.h | 41 ++++++++++++++++++++++++++++++++++++++++- target/s390x/cpu_models.c | 25 +++++++++++++++++++++++++ target/s390x/gen-features.c | 39 +++++++++++++++++++++++++++++++++++++++ target/s390x/kvm.c | 10 ++++++++++ 7 files changed, 160 insertions(+), 3 deletions(-)
AFAICS, this should be fine.
PATCH 2/7 s390x/cpumodel: we are always in zarchitecture mode
In reply to Christian BorntraegerFrom: "Jason J. Herne" <[email protected]>
In QEMU, a guest VCPU always started in and never was able to leave z/Architecture mode. Now we have an architected way of showing this condition.
The SIGP SET ARCHITECTURE instruction is simply rejected. Linux as guest seems to not care about the return value, which is a good thing The new handling is just like already being in z/Architecture mode.
We'll not try to fake absence of this facility, but still not indicate the facility in case some strange CPU model turned z/Architecture off completely (which doesn't work either way but let's us see how a guest would react on a lack of this facility).
--- target/s390x/cpu_features.c | 5 +++-- target/s390x/kvm.c | 38 +++++++++++--------------------------- 2 files changed, 14 insertions(+), 29 deletions(-)
target/s390x/cpu_features.c +3 -2
@@ -337,8 +337,9 @@ void s390_fill_feat_block(const S390FeatBitmap features, S390FeatType type,int bit_nr;if (type ==S390_FEAT_TYPE_STFL &&test_bit (S390_FEAT_ZARCH , features)) { -/* z/Architecture is always active if around */ - data[0 ] |=0x20 ; +/* Features that are always active */ + data[0 ] |=0x20 ;/* z/Architecture */ + data[17 ] |=0x20 ;/* Configuration-z-architectural-mode */ } feat =find_first_bit (features,S390_FEAT_MAX );
target/s390x/kvm.c +11 -27
@@ -1757,41 +1757,25 @@ static int sigp_set_architecture(S390CPU *cpu, uint32_t param, {CPUState *cur_cs;S390CPU *cur_cpu; +bool all_stopped = true; -/* due to the BQL, we are the only active cpu */ CPU_FOREACH (cur_cs) { cur_cpu =S390_CPU (cur_cs); -if (cur_cpu->env.sigp_order !=0 ) { -return SIGP_CC_BUSY ; + +if (cur_cpu == cpu) { +continue ; } -cpu_synchronize_state (cur_cs); -/* all but the current one have to be stopped */ -if (cur_cpu != cpu && -s390_cpu_get_state (cur_cpu) !=CPU_STATE_STOPPED ) { - *status_reg &=0xffffffff00000000ULL ; - *status_reg |=SIGP_STAT_INCORRECT_STATE ; -return SIGP_CC_STATUS_STORED ; +if (s390_cpu_get_state (cur_cpu) !=CPU_STATE_STOPPED ) { + all_stopped = false; } } -switch (param &0xff ) { -case SIGP_MODE_ESA_S390 : -/* not supported */ -return SIGP_CC_NOT_OPERATIONAL ; -case SIGP_MODE_Z_ARCH_TRANS_ALL_PSW : -case SIGP_MODE_Z_ARCH_TRANS_CUR_PSW : - CPU_FOREACH(cur_cs) { - cur_cpu =S390_CPU (cur_cs); - cur_cpu->env.pfault_token =-1UL ; - } -break ; -default : - *status_reg &=0xffffffff00000000ULL ; - *status_reg |=SIGP_STAT_INVALID_PARAMETER ; -return SIGP_CC_STATUS_STORED ; - } + *status_reg &=0xffffffff00000000ULL ; -return SIGP_CC_ORDER_CODE_ACCEPTED ; +/* Reject set arch order, with czam we're always in z/Arch mode. */ + *status_reg |= (all_stopped ?SIGP_STAT_INVALID_PARAMETER : +SIGP_STAT_INCORRECT_STATE ); +return SIGP_CC_STATUS_STORED ; }static int handle_sigp (S390CPU *cpu,struct kvm_run *run,uint8_t ipa1)
Signature · 1 line
2.7.4
PATCH 3/7 s390x/cpumodel: add esop/esop2 to z12 model
In reply to Christian BorntraegerFrom: "Jason J. Herne" <[email protected]>
Add esop and esop2 features to z12 model where esop2 was originally introduced. Provide a mechanism to disable features in compatibility machines and use this method to disable esop and esop2 when using compatibility machine v2.9 or earlier.
--- hw/s390x/s390-virtio-ccw.c | 3 +++ target/s390x/gen-features.c | 3 +++ 2 files changed, 6 insertions(+)
hw/s390x/s390-virtio-ccw.c +3 -0
@@ -30,6 +30,7 @@#include "hw/s390x/s390-virtio-ccw.h" #include "hw/s390x/css-bridge.h" #include "migration/register.h" +#include "cpu_models.h" static const char *const reset_dev_types[] = {TYPE_VIRTUAL_CSS_BRIDGE ,
@@ -503,6 +504,8 @@ DEFINE_CCW_MACHINE(2_10, "2.10", true);static void ccw_machine_2_9_instance_options (MachineState *machine) {ccw_machine_2_10_instance_options (machine); +s390_cpudef_featoff_greater (12 ,1 ,S390_FEAT_ESOP ); +s390_cpudef_featoff_greater (12 ,1 ,S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2 );s390_cpudef_featoff_greater (12 ,1 ,S390_FEAT_ZPCI );s390_cpudef_featoff_greater (12 ,1 ,S390_FEAT_ADAPTER_INT_SUPPRESSION );s390_cpudef_featoff_greater (12 ,1 ,S390_FEAT_ADAPTER_EVENT_NOTIFICATION );
target/s390x/gen-features.c +3 -0
@@ -429,6 +429,7 @@ static uint16_t full_GEN12_GA1[] = {S390_FEAT_ADAPTER_EVENT_NOTIFICATION ,S390_FEAT_ADAPTER_INT_SUPPRESSION ,S390_FEAT_EDAT_2 , + S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2, }; static uint16_t full_GEN12_GA2[] = {
@@ -488,6 +489,8 @@ static uint16_t default_GEN12_GA1[] = {S390_FEAT_ZPCI ,S390_FEAT_ADAPTER_EVENT_NOTIFICATION ,S390_FEAT_EDAT_2 , +S390_FEAT_ESOP , + S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2, };#define default_GEN12_GA2 EmptyFeat
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH 3/7] s390x/cpumodel: add esop/esop2 to z12 model
Quoted 6 lines · On Thu, 13 Jul 2017 18:03:05 +0200 Christian Borntraeger…
From: "Jason J. Herne" <[email protected]>
Add esop and esop2 features to z12 model where esop2 was originally introduced. Provide a mechanism to disable features in compatibility machines and use this method to disable esop and esop2 when using compatibility machine v2.9 or earlier.
The patch description does not quite fit anymore due to patch reordering. What about:
"Add esop and esop2 features to z12 model where esop2 was originally introduced. Disable esop and esop2 when using compatibility machine v2.9 or earlier."
Quoted 8 lines
Signed-off-by Jason J. Herne <[email protected]>Signed-off-by Christian Borntraeger <[email protected]>--- hw/s390x/s390-virtio-ccw.c | 3 +++ target/s390x/gen-features.c | 3 +++ 2 files changed, 6 insertions(+)
Re: [Qemu-devel] [PATCH 3/7] s390x/cpumodel: add esop/esop2 to z12 model
Quoted 11 lines · Cornelia Huck
Quoted 6 lines · On Thu, 13 Jul 2017 18:03:05 +0200 Christian Borntraeger…
From: "Jason J. Herne" <[email protected]>
Add esop and esop2 features to z12 model where esop2 was originally introduced. Provide a mechanism to disable features in compatibility machines and use this method to disable esop and esop2 when using compatibility machine v2.9 or earlier.
The patch description does not quite fit anymore due to patch
Right, I have splitted out the compat handling to be used for the PCI stuff.
Quoted 4 lines
reordering. What about:
"Add esop and esop2 features to z12 model where esop2 was originally introduced. Disable esop and esop2 when using compatibility machine v2.9 or earlier."
Will use that, thanks.
Quoted 12 lines
Quoted 9 lines
Signed-off-by Jason J. Herne <[email protected]>Signed-off-by Christian Borntraeger <[email protected]>--- hw/s390x/s390-virtio-ccw.c | 3 +++ target/s390x/gen-features.c | 3 +++ 2 files changed, 6 insertions(+)Reviewed-by Cornelia Huck <[email protected]>
PATCH 4/7 s390x/kvm: Enable KSS facility for nested virtualization
In reply to Christian BorntraegerFrom: Farhan Ali <[email protected]>
If the host supports keyless subset (KSS) then first level guest (G2) should enable KSS facility as well.
--- target/s390x/kvm.c | 1 + 1 file changed, 1 insertion(+)
target/s390x/kvm.c +1 -0
@@ -2508,6 +2508,7 @@ static int kvm_to_feat[][2] = { { KVM_S390_VM_CPU_FEAT_CMMA, S390_FEAT_SIE_CMMA }, { KVM_S390_VM_CPU_FEAT_PFMFI, S390_FEAT_SIE_PFMFI}, { KVM_S390_VM_CPU_FEAT_SIGPIF, S390_FEAT_SIE_SIGPIF}, + { KVM_S390_VM_CPU_FEAT_KSS, S390_FEAT_SIE_KSS}, };static int query_cpu_feat (S390FeatBitmap features)
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH 4/7] s390x/kvm: Enable KSS facility for nested virtualization
Quoted 11 lines · On Thu, 13 Jul 2017 18:03:06 +0200 Christian Borntraeger…
From: Farhan Ali <[email protected]>
If the host supports keyless subset (KSS) then first level guest (G2) should enable KSS facility as well.
Signed-off-by Farhan Ali <[email protected]>Reviewed-by Eric Farman <[email protected]>Signed-off-by Christian Borntraeger <[email protected]>--- target/s390x/kvm.c | 1 + 1 file changed, 1 insertion(+)
PATCH 5/7 s390x/kvm: enable guarded storage
In reply to Christian BorntraegerFrom: Fan Zhang <[email protected]>
Introduce guarded storage support for KVM guests on s390. We need to enable the capability, extend machine check validity, sigp store-additional-status-at-address, and migration.
The feature is fenced for older machine type versions.
--- hw/s390x/s390-virtio-ccw.c | 18 ++++++++++ include/hw/s390x/s390-virtio-ccw.h | 3 ++ target/s390x/cpu.h | 7 ++++ target/s390x/kvm.c | 71 ++++++++++++++++++++++++++++++++------ target/s390x/machine.c | 17 +++++++++ 5 files changed, 106 insertions(+), 10 deletions(-)
hw/s390x/s390-virtio-ccw.c +18 -0
@@ -211,6 +211,7 @@ static void ccw_machine_class_init(ObjectClass *oc, void *data) s390mc->ri_allowed = true; s390mc->cpu_model_allowed = true; s390mc->css_migration_enabled = true; + s390mc->gs_allowed = true; mc->init = ccw_init; mc->reset = s390_machine_reset; mc->hot_add_cpu = s390_hot_add_cpu;
@@ -288,6 +289,22 @@ bool cpu_model_allowed(void)return get_machine_class ()->cpu_model_allowed; } +bool gs_allowed (void ) +{ +if (kvm_enabled ()) { +MachineClass *mc =MACHINE_GET_CLASS (qdev_get_machine ()); +if (object_class_dynamic_cast (OBJECT_CLASS (mc), +TYPE_S390_CCW_MACHINE )) { +S390CcwMachineClass *s390mc =S390_MACHINE_CLASS (mc); + +return s390mc->gs_allowed; + } +/* Make sure the "none" machine can have gs */ +return true; + } +return false; +} +static char *machine_get_loadparm (Object *obj,Error **errp) {S390CcwMachineState *ms =S390_CCW_MACHINE (obj);
@@ -515,6 +532,7 @@ static void ccw_machine_2_9_class_options(MachineClass *mc) {S390CcwMachineClass *s390mc =S390_MACHINE_CLASS (mc); + s390mc->gs_allowed = false;ccw_machine_2_10_class_options (mc);SET_MACHINE_COMPAT (mc,CCW_COMPAT_2_9 ); s390mc->css_migration_enabled = false;
include/hw/s390x/s390-virtio-ccw.h +3 -0
@@ -40,12 +40,15 @@ typedef struct S390CcwMachineClass {bool ri_allowed;bool cpu_model_allowed;bool css_migration_enabled; +bool gs_allowed; } S390CcwMachineClass;/* runtime-instrumentation allowed by the machine */ bool ri_allowed (void );/* cpu model allowed by the machine */ bool cpu_model_allowed (void ); +/* guarded-storage allowed by the machine */ +bool gs_allowed (void );/** * Returns true if (vmstate based) migration of the channel subsystem
target/s390x/cpu.h +7 -0
@@ -89,6 +89,7 @@ typedef struct CPUS390XState {CPU_DoubleU vregs[32 ][2 ];/* vector registers */ uint32_t aregs[16 ];/* access registers */ uint8_t riccb[64 ];/* runtime instrumentation control */ +uint64_t gscb[4 ];/* guarded storage control */ /* Fields up to this point are not cleared by initial CPU reset */ struct {} start_initial_reset_fields;
@@ -1166,6 +1167,7 @@ int kvm_s390_set_mem_limit(KVMState *s, uint64_t new_limit, uint64_t *hw_limit);void kvm_s390_vcpu_interrupt_pre_save (S390CPU *cpu);int kvm_s390_vcpu_interrupt_post_load (S390CPU *cpu);int kvm_s390_get_ri (void ); +int kvm_s390_get_gs (void );void kvm_s390_crypto_reset (void );#else static inline void kvm_s390_io_interrupt(uint16_t subchannel_id,
@@ -1220,6 +1222,10 @@ static inline int kvm_s390_get_ri(void) {return 0 ; } +static inline int kvm_s390_get_gs (void ) +{ +return 0 ; +}static inline void kvm_s390_crypto_reset (void ) { }
@@ -1328,6 +1334,7 @@ static inline bool s390_get_squash_mcss(void)#define MCIC_VB_CR 0x0000000400000000ULL#define MCIC_VB_ST 0x0000000100000000ULL#define MCIC_VB_AR 0x0000000040000000ULL +#define MCIC_VB_GS 0x0000000008000000ULL#define MCIC_VB_PR 0x0000000000200000ULL#define MCIC_VB_FC 0x0000000000100000ULL#define MCIC_VB_CT 0x0000000000020000ULL
target/s390x/kvm.c +61 -10
146 lines not on this page · raw message
target/s390x/machine.c +17 -0
@@ -174,6 +174,22 @@ const VMStateDescription vmstate_exval = { } }; +static bool gscb_needed (void *opaque) +{ +return kvm_s390_get_gs (); +} + +const VMStateDescription vmstate_gscb = { + .name ="cpu/gscb" , + .version_id =1 , + .minimum_version_id =1 , + .needed = gscb_needed, + .fields = (VMStateField []) { +VMSTATE_UINT64_ARRAY (env.gscb,S390CPU ,4 ), +VMSTATE_END_OF_LIST () + } +}; +const VMStateDescription vmstate_s390_cpu = { .name ="cpu" , .post_load = cpu_post_load,
@@ -207,6 +223,7 @@ const VMStateDescription vmstate_s390_cpu = { &vmstate_vregs, &vmstate_riccb, &vmstate_exval, + &vmstate_gscb, NULL }, };
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH 5/7] s390x/kvm: enable guarded storage
Quoted 10 lines · On Thu, 13 Jul 2017 18:03:07 +0200 Christian Borntraeger…
From: Fan Zhang <[email protected]>
Introduce guarded storage support for KVM guests on s390. We need to enable the capability, extend machine check validity, sigp store-additional-status-at-address, and migration.
The feature is fenced for older machine type versions.
Signed-off-by Fan Zhang <[email protected]>Signed-off-by Christian Borntraeger <[email protected]>
Quoted 7 lines
--- hw/s390x/s390-virtio-ccw.c | 18 ++++++++++ include/hw/s390x/s390-virtio-ccw.h | 3 ++ target/s390x/cpu.h | 7 ++++ target/s390x/kvm.c | 71 ++++++++++++++++++++++++++++++++------ target/s390x/machine.c | 17 +++++++++ 5 files changed, 106 insertions(+), 10 deletions(-)
I'll trust you on the bits.
PATCH 6/7 s390x/arch_dump: also dump guarded storage control block
In reply to Christian BorntraegerWrite the new note section of type 30b (guarded storage control block).
--- include/elf.h | 1 + target/s390x/arch_dump.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+)
include/elf.h +1 -0
@@ -1476,6 +1476,7 @@ typedef struct elf64_shdr {#define NT_TASKSTRUCT 4#define NT_AUXV 6#define NT_PRXFPREG 0x46e62b7f/* copied from gdb5.1/include/elf/common.h */ +#define NT_S390_GS_CB 0x30b/* s390 guarded storage registers */ #define NT_S390_VXRS_HIGH 0x30a/* s390 vector registers 16-31 */ #define NT_S390_VXRS_LOW 0x309/* s390 vector registers 0-15 (lower half) */ #define NT_S390_PREFIX 0x305/* s390 prefix register */
target/s390x/arch_dump.c +18 -0
@@ -57,6 +57,12 @@ struct S390xElfVregsHiStruct {typedef struct S390xElfVregsHiStruct S390xElfVregsHi ; +struct S390xElfGSCBStruct { +uint64_t gsregs[4 ]; +}QEMU_PACKED ; + +typedef struct S390xElfGSCBStruct S390xElfGSCB ; + typedef struct noteStruct { Elf64_Nhdr hdr; char name[8];
@@ -65,6 +71,7 @@ typedef struct noteStruct {S390xElfFpregset fpregset;S390xElfVregsLo vregslo;S390xElfVregsHi vregshi; +S390xElfGSCB gscb;uint32_t prefix;uint64_t timer;uint64_t todcmp;
@@ -126,6 +133,16 @@ static void s390x_write_elf64_vregshi(Note *note, S390CPU *cpu, int id) } } +static void s390x_write_elf64_gscb (Note *note,S390CPU *cpu,int id) +{ +int i; + + note->hdr.n_type =cpu_to_be32 (NT_S390_GS_CB ); +for (i =0 ; i <4 ; i++) { + note->contents.gscb.gsregs[i] =cpu_to_be64 (cpu->env.gscb[i]); + } +} +static void s390x_write_elf64_timer (Note *note,S390CPU *cpu,int id) { note->hdr.n_type =cpu_to_be32 (NT_S390_TIMER );
@@ -181,6 +198,7 @@ static const NoteFuncDesc note_linux[] = { {sizeof(((Note *)0)->contents.todpreg), s390x_write_elf64_todpreg}, {sizeof(((Note *)0)->contents.vregslo), s390x_write_elf64_vregslo}, {sizeof(((Note *)0)->contents.vregshi), s390x_write_elf64_vregshi}, + {sizeof(((Note *)0)->contents.gscb), s390x_write_elf64_gscb}, { 0, NULL} };
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH 6/7] s390x/arch_dump: also dump guarded storage control block
Quoted 7 lines · On Thu, 13 Jul 2017 18:03:08 +0200 Christian Borntraeger…
Write the new note section of type 30b (guarded storage control block).
Signed-off-by Christian Borntraeger <[email protected]>--- include/elf.h | 1 + target/s390x/arch_dump.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+)
PATCH 7/7 s390x/gdb: add gs registers
In reply to Christian BorntraegerLet's provide the guarded storage registers via gdb server.
--- configure | 2 +- gdb-xml/s390-gs.xml | 14 ++++++++++++++ target/s390x/gdbstub.c | 24 ++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 gdb-xml/s390-gs.xml
configure +1 -1
@@ -6227,7 +6227,7 @@ case "$target_name" in echo "TARGET_ABI32=y" >> $config_target_mak ;; s390x) - gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml" + gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml s390-gs.xml" ;; tilegx) ;;
gdb-xml/s390-gs.xml new file +14 -0
@@ -0,0 +1,14 @@ +<?xml version="1.0"?> +<!-- Copyright 2017 IBM Corp. + + 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. --> + +<!DOCTYPE feature SYSTEM "gdb-target.dtd"> +<feature name="org.gnu.gdb.s390.gs"> + <reg name="gs_reserved" bitsize="64" type="uint64" group="system"/> + <reg name="gsd" bitsize="64" type="uint64" group="system"/> + <reg name="gssm" bitsize="64" type="uint64" group="system"/> + <reg name="gsepla" bitsize="64" type="data_ptr" group="system"/> +</feature>
target/s390x/gdbstub.c +24 -0
@@ -286,6 +286,26 @@ static int cpu_write_virt_reg(CPUS390XState *env, uint8_t *mem_buf, int n) }#endif +/* the values represent the positions in s390-gs.xml */ +#define S390_GS_RESERVED_REGNUM 0 +#define S390_GS_GSD_REGNUM 1 +#define S390_GS_GSSM_REGNUM 2 +#define S390_GS_GSEPLA_REGNUM 3 +/* total number of registers in s390-gs.xml */ +#define S390_NUM_GS_REGS 4 + +static int cpu_read_gs_reg (CPUS390XState *env,uint8_t *mem_buf,int n) +{ +return gdb_get_regl (mem_buf, env->gscb[n]); +} + +static int cpu_write_gs_reg (CPUS390XState *env,uint8_t *mem_buf,int n) +{ + env->gscb[n] =ldtul_p (mem_buf); +cpu_synchronize_post_init (ENV_GET_CPU (env)); +return 8 ; +} +void s390_cpu_gdb_init (CPUState *cs) { gdb_register_coprocessor(cs, cpu_read_ac_reg,
@@ -300,6 +320,10 @@ void s390_cpu_gdb_init(CPUState *cs) cpu_write_vreg, S390_NUM_VREGS, "s390-vx.xml", 0); +gdb_register_coprocessor (cs, cpu_read_gs_reg, + cpu_write_gs_reg, +S390_NUM_GS_REGS ,"s390-gs.xml" ,0 ); +#ifndef CONFIG_USER_ONLY gdb_register_coprocessor(cs, cpu_read_c_reg, cpu_write_c_reg,
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH 7/7] s390x/gdb: add gs registers
Quoted 9 lines · On Thu, 13 Jul 2017 18:03:09 +0200 Christian Borntraeger…
Let's provide the guarded storage registers via gdb server.
Signed-off-by Christian Borntraeger <[email protected]>--- configure | 2 +- gdb-xml/s390-gs.xml | 14 ++++++++++++++ target/s390x/gdbstub.c | 24 ++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 gdb-xml/s390-gs.xml
Quoted 4 lines · On Thu, 13 Jul 2017 18:03:02 +0200 Christian Borntraeger…
here is a bunch of patches that teaches recent HW features to the CPU model and kvm code in QEMU. We also add the enhanced suppression on protection facility to the z12 and later for the 2.10 machine type.
Looks good from my side.
I assume you'll put out a pull request soon?
Quoted 12 lines · Cornelia Huck
Quoted 4 lines · On Thu, 13 Jul 2017 18:03:02 +0200 Christian Borntraeger…
here is a bunch of patches that teaches recent HW features to the CPU model and kvm code in QEMU. We also add the enhanced suppression on protection facility to the z12 and later for the 2.10 machine type.
Looks good from my side.
I assume you'll put out a pull request soon?
Yes. Will do one today unless there is more feedback.