s390x/kvm: implement new hardware/firmware features
v3 cover s390x/kvm: implement new hardware/firmware features
We want to provide more hw features to guests, namely the new bpb control as well as other transparent facilities that might be introduced by firmware updates (e.g. the stfle facility 81).
See the kernel discussion for the KVM side
https://www.spinics.net/lists/kernel/msg2700551.html
v2->v3: - use bool for bpbc
- sort cpu facilitiesv1->v2: - style and comment fixes
- drop transparent facility patch
- add patch to introduce facility 81
Christian Borntraeger (3):
header sync
s390x/kvm: Handle bpb feature
s390x/kvm: provide stfle.81
linux-headers/asm-s390/kvm.h | 9 ++++----- linux-headers/linux/kvm.h | 5 +++-- target/s390x/cpu.c | 1 + target/s390x/cpu.h | 1 + target/s390x/cpu_features.c | 2 ++ target/s390x/cpu_features_def.h | 2 ++ target/s390x/gen-features.c | 2 ++ target/s390x/kvm.c | 14 ++++++++++++++ target/s390x/machine.c | 17 +++++++++++++++++ 9 files changed, 46 insertions(+), 7 deletions(-)
Signature · 1 line
2.9.4
PATCH v3 1/3 header sync
replace with proper header sync
--- linux-headers/asm-s390/kvm.h | 9 ++++----- linux-headers/linux/kvm.h | 5 +++-- 2 files changed, 7 insertions(+), 7 deletions(-)
linux-headers/asm-s390/kvm.h +4 -5
@@ -6,10 +6,6 @@* * Copyright IBM Corp. 2008 * -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License (version 2 only) -* as published by the Free Software Foundation. -* * Author(s): Carsten Otte <[email protected]> * Christian Borntraeger <[email protected]> */
@@ -228,6 +224,7 @@ struct kvm_guest_debug_arch {#define KVM_SYNC_RICCB (1UL << 7)#define KVM_SYNC_FPRS (1UL << 8)#define KVM_SYNC_GSCB (1UL << 9) +#define KVM_SYNC_BPBC (1UL << 10)/* length and alignment of the sdnx as a power of two */ #define SDNXC 8#define SDNXL (1UL << SDNXC)
@@ -251,7 +248,9 @@ struct kvm_sync_regs { };__u8 reserved[512 ];/* for future vector expansion */ __u32 fpc;/* valid on KVM_SYNC_VRS or KVM_SYNC_FPRS */ -__u8 padding1[52 ];/* riccb needs to be 64byte aligned */ + __u8 bpbc : 1; /* bp mode */ + __u8 reserved2 : 7; +__u8 padding1[51 ];/* riccb needs to be 64byte aligned */ __u8 riccb[64 ];/* runtime instrumentation controls block */ __u8 padding2[192 ];/* sdnx needs to be 256byte aligned */ union {
linux-headers/linux/kvm.h +3 -2
@@ -630,9 +630,9 @@ struct kvm_s390_irq {struct kvm_s390_irq_state {__u64 buf; -__u32 flags; +__u32 flags;/* will stay unused for compatibility reasons */ __u32 len; -__u32 reserved[4 ]; +__u32 reserved[4 ];/* will stay unused for compatibility reasons */ };/* for KVM_SET_GUEST_DEBUG */
@@ -932,6 +932,7 @@ struct kvm_ppc_resize_hpt {#define KVM_CAP_HYPERV_SYNIC2 148#define KVM_CAP_HYPERV_VP_INDEX 149#define KVM_CAP_S390_AIS_MIGRATION 150 +#define KVM_CAP_S390_BPB 151#ifdef KVM_CAP_IRQ_ROUTING
Signature · 1 line
2.9.4
Re: [Qemu-devel] [PATCH v3 1/3] header sync
Quoted 60 lines · Christian Borntraeger
replace with proper header sync
Signed-off-by Christian Borntraeger <[email protected]>--- linux-headers/asm-s390/kvm.h | 9 ++++----- linux-headers/linux/kvm.h | 5 +++-- 2 files changed, 7 insertions(+), 7 deletions(-)linux-headers/asm-s390/kvm.h +4
-5@@ -6,10 +6,6 @@* * Copyright IBM Corp. 2008 * -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License (version 2 only) -* as published by the Free Software Foundation. -* * Author(s): Carsten Otte <[email protected]> * Christian Borntraeger <[email protected]> */ @@ -228,6 +224,7 @@ struct kvm_guest_debug_arch {#define KVM_SYNC_RICCB (1UL << 7)#define KVM_SYNC_FPRS (1UL << 8)#define KVM_SYNC_GSCB (1UL << 9) +#define KVM_SYNC_BPBC (1UL << 10)/* length and alignment of the sdnx as a power of two */ #define SDNXC 8#define SDNXL (1UL << SDNXC)@@ -251,7 +248,9 @@ struct kvm_sync_regs { };__u8 reserved[512 ];/* for future vector expansion */ __u32 fpc;/* valid on KVM_SYNC_VRS or KVM_SYNC_FPRS */ -__u8 padding1[52 ];/* riccb needs to be 64byte aligned */ + __u8 bpbc : 1; /* bp mode */ + __u8 reserved2 : 7; +__u8 padding1[51 ];/* riccb needs to be 64byte aligned */ __u8 riccb[64 ];/* runtime instrumentation controls block */ __u8 padding2[192 ];/* sdnx needs to be 256byte aligned */ union {linux-headers/linux/kvm.h +2
-2@@ -630,9 +630,9 @@ struct kvm_s390_irq {struct kvm_s390_irq_state {__u64 buf; -__u32 flags; +__u32 flags;/* will stay unused for compatibility reasons */ __u32 len; -__u32 reserved[4 ]; +__u32 reserved[4 ];/* will stay unused for compatibility reasons */ };/* for KVM_SET_GUEST_DEBUG */
linux-headers/linux/kvm.h struct kvm_ppc_resize_hpt { · line 938
Quoted 7 lines
linux-headers/linux/kvm.h +1
-0@@ -932,6 +932,7 @@ struct kvm_ppc_resize_hpt {#define KVM_CAP_HYPERV_SYNIC2 148#define KVM_CAP_HYPERV_VP_INDEX 149#define KVM_CAP_S390_AIS_MIGRATION 150 +#define KVM_CAP_S390_BPB 151#ifdef KVM_CAP_IRQ_ROUTING
Signature · 3 lines
Thanks, David / dhildenb
Re: [Qemu-devel] [qemu-s390x] [PATCH v3 1/3] header sync
kernel patch has now landed as
commit 35b3fde6203b932b2b1a5b53b3d8808abc9c4f60
KVM: s390: wire up bpb feature
in Linus tree.
The new number is
#define KVM_CAP_S390_BPB 152
(instead of 151)
Quoted 71 lines · David Hildenbrand
Quoted 60 lines · Christian Borntraeger
replace with proper header sync
Signed-off-by Christian Borntraeger <[email protected]>--- linux-headers/asm-s390/kvm.h | 9 ++++----- linux-headers/linux/kvm.h | 5 +++-- 2 files changed, 7 insertions(+), 7 deletions(-)linux-headers/asm-s390/kvm.h +4
-5@@ -6,10 +6,6 @@* * Copyright IBM Corp. 2008 * -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License (version 2 only) -* as published by the Free Software Foundation. -* * Author(s): Carsten Otte <[email protected]> * Christian Borntraeger <[email protected]> */ @@ -228,6 +224,7 @@ struct kvm_guest_debug_arch {#define KVM_SYNC_RICCB (1UL << 7)#define KVM_SYNC_FPRS (1UL << 8)#define KVM_SYNC_GSCB (1UL << 9) +#define KVM_SYNC_BPBC (1UL << 10)/* length and alignment of the sdnx as a power of two */ #define SDNXC 8#define SDNXL (1UL << SDNXC)@@ -251,7 +248,9 @@ struct kvm_sync_regs { };__u8 reserved[512 ];/* for future vector expansion */ __u32 fpc;/* valid on KVM_SYNC_VRS or KVM_SYNC_FPRS */ -__u8 padding1[52 ];/* riccb needs to be 64byte aligned */ + __u8 bpbc : 1; /* bp mode */ + __u8 reserved2 : 7; +__u8 padding1[51 ];/* riccb needs to be 64byte aligned */ __u8 riccb[64 ];/* runtime instrumentation controls block */ __u8 padding2[192 ];/* sdnx needs to be 256byte aligned */ union {linux-headers/linux/kvm.h +2
-2@@ -630,9 +630,9 @@ struct kvm_s390_irq {struct kvm_s390_irq_state {__u64 buf; -__u32 flags; +__u32 flags;/* will stay unused for compatibility reasons */ __u32 len; -__u32 reserved[4 ]; +__u32 reserved[4 ];/* will stay unused for compatibility reasons */ };/* for KVM_SET_GUEST_DEBUG */ linux-headers/linux/kvm.h struct kvm_ppc_resize_hpt { · line 938
Quoted 7 lines
linux-headers/linux/kvm.h +1
-0@@ -932,6 +932,7 @@ struct kvm_ppc_resize_hpt {#define KVM_CAP_HYPERV_SYNIC2 148#define KVM_CAP_HYPERV_VP_INDEX 149#define KVM_CAP_S390_AIS_MIGRATION 150 +#define KVM_CAP_S390_BPB 151#ifdef KVM_CAP_IRQ_ROUTING
Re: [Qemu-devel] [qemu-s390x] [PATCH v3 1/3] header sync
Quoted 11 lines · On Mon, 22 Jan 2018 09:31:43 +0100 Christian Borntraeger…
kernel patch has now landed as
commit
35b3fde6203b932b2b1a5b53b3d8808abc9c4f60
KVM: s390: wire up bpb featurein Linus tree.
The new number is
#defineKVM_CAP_S390_BPB152
(instead of 151)
I'll replace this with a proper header sync and push out later today.
PATCH v3 2/3 s390x/kvm: Handle bpb feature
In reply to Christian BorntraegerWe need to handle the bpb control on reset and migration. Normally stfle.82 is transparent (and the normal guest part works without hypervisor activity). To prevent any issues we require full host kernel support for this feature.
--- target/s390x/cpu.c | 1 + target/s390x/cpu.h | 1 + target/s390x/cpu_features.c | 1 + target/s390x/cpu_features_def.h | 1 + target/s390x/gen-features.c | 1 + target/s390x/kvm.c | 14 ++++++++++++++ target/s390x/machine.c | 17 +++++++++++++++++ 7 files changed, 36 insertions(+)
target/s390x/cpu.c +1 -0
@@ -89,6 +89,7 @@ static void s390_cpu_reset(CPUState *s)CPUS390XState *env = &cpu->env; env->pfault_token =-1UL ; + env->bpbc = false; scc->parent_reset (s); cpu->env.sigp_order =0 ;s390_cpu_set_state (CPU_STATE_STOPPED , cpu);
target/s390x/cpu.h +1 -0
@@ -93,6 +93,7 @@ struct CPUS390XState {uint32_t fpc;/* floating-point control register */ uint32_t cc_op; +bool bpbc;/* branch prediction blocking */ float_status fpu_status;/* passed to softfloat lib */
target/s390x/cpu_features.c +1 -0
@@ -89,6 +89,7 @@ static const S390FeatDef s390_features[] = {FEAT_INIT ("msa4-base" ,S390_FEAT_TYPE_STFL ,77 ,"Message-security-assist-extension-4 facility (excluding subfunctions)" ),FEAT_INIT ("edat2" ,S390_FEAT_TYPE_STFL ,78 ,"Enhanced-DAT facility 2" ),FEAT_INIT ("dfppc" ,S390_FEAT_TYPE_STFL ,80 ,"Decimal-floating-point packed-conversion facility" ), +FEAT_INIT ("bpb" ,S390_FEAT_TYPE_STFL ,82 ,"Branch Prediction Blocking" ),FEAT_INIT ("vx" ,S390_FEAT_TYPE_STFL ,129 ,"Vector facility" ),FEAT_INIT ("iep" ,S390_FEAT_TYPE_STFL ,130 ,"Instruction-execution-protection facility" ), FEAT_INIT("sea_esop2", S390_FEAT_TYPE_STFL, 131, "Side-effect-access facility and Enhanced-suppression-on-protection facility 2"),
target/s390x/cpu_features_def.h +1 -0
@@ -80,6 +80,7 @@ typedef enum {S390_FEAT_MSA_EXT_4 ,S390_FEAT_EDAT_2 ,S390_FEAT_DFP_PACKED_CONVERSION , +S390_FEAT_BPB ,S390_FEAT_VECTOR ,S390_FEAT_INSTRUCTION_EXEC_PROT , S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2,
target/s390x/gen-features.c +1 -0
@@ -352,6 +352,7 @@ static uint16_t base_GEN14_GA1[] = {* support these features yet. */ static uint16_t full_GEN7_GA1[] = { +S390_FEAT_BPB ,S390_FEAT_SIE_F2 ,S390_FEAT_SIE_SKEY ,S390_FEAT_SIE_GPERE ,
target/s390x/kvm.c +14 -0
@@ -490,6 +490,11 @@ int kvm_arch_put_registers(CPUState *cs, int level) cs->kvm_run->kvm_dirty_regs |=KVM_SYNC_GSCB ; } +if (can_sync_regs (cs,KVM_SYNC_BPBC )) { + cs->kvm_run->s.regs.bpbc = env->bpbc; + cs->kvm_run->kvm_dirty_regs |=KVM_SYNC_BPBC ; + } +/* Finally the prefix */ if (can_sync_regs (cs,KVM_SYNC_PREFIX )) { cs->kvm_run->s.regs.prefix = env->psa;
@@ -600,6 +605,10 @@ int kvm_arch_get_registers(CPUState *cs)memcpy (env->gscb, cs->kvm_run->s.regs.gscb,32 ); } +if (can_sync_regs (cs,KVM_SYNC_BPBC )) { + env->bpbc = cs->kvm_run->s.regs.bpbc; + } +/* pfault parameters */ if (can_sync_regs (cs,KVM_SYNC_PFAULT )) { env->pfault_token = cs->kvm_run->s.regs.pft;
@@ -2278,6 +2287,11 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp)clear_bit (S390_FEAT_CMM_NT , model->features); } +/* bpb needs kernel support for migration, VSIE and reset */ +if (!kvm_check_extension (kvm_state,KVM_CAP_S390_BPB )) { +clear_bit (S390_FEAT_BPB , model->features); + } +/* We emulate a zPCI bus and AEN, therefore we don't need HW support */ if (pci_available) {set_bit (S390_FEAT_ZPCI , model->features);
target/s390x/machine.c +17 -0
@@ -194,6 +194,22 @@ const VMStateDescription vmstate_gscb = { } }; +static bool bpbc_needed (void *opaque) +{ +return s390_has_feat (S390_FEAT_BPB ); +} + +const VMStateDescription vmstate_bpbc = { + .name ="cpu/bpbc" , + .version_id =1 , + .minimum_version_id =1 , + .needed = bpbc_needed, + .fields = (VMStateField []) { +VMSTATE_BOOL (env.bpbc,S390CPU ), +VMSTATE_END_OF_LIST () + } +}; +const VMStateDescription vmstate_s390_cpu = { .name ="cpu" , .post_load = cpu_post_load,
@@ -228,6 +244,7 @@ const VMStateDescription vmstate_s390_cpu = { &vmstate_riccb, &vmstate_exval, &vmstate_gscb, + &vmstate_bpbc, NULL }, };
Signature · 1 line
2.9.4
Re: [Qemu-devel] [PATCH v3 2/3] s390x/kvm: Handle bpb feature
Quoted 45 lines · Christian Borntraeger
We need to handle the bpb control on reset and migration. Normally stfle.82 is transparent (and the normal guest part works without hypervisor activity). To prevent any issues we require full host kernel support for this feature.
Signed-off-by Christian Borntraeger <[email protected]>--- target/s390x/cpu.c | 1 + target/s390x/cpu.h | 1 + target/s390x/cpu_features.c | 1 + target/s390x/cpu_features_def.h | 1 + target/s390x/gen-features.c | 1 + target/s390x/kvm.c | 14 ++++++++++++++ target/s390x/machine.c | 17 +++++++++++++++++ 7 files changed, 36 insertions(+)target/s390x/cpu.c +1
-0@@ -89,6 +89,7 @@ static void s390_cpu_reset(CPUState *s)CPUS390XState *env = &cpu->env; env->pfault_token =-1UL ; + env->bpbc = false; scc->parent_reset (s); cpu->env.sigp_order =0 ;s390_cpu_set_state (CPU_STATE_STOPPED , cpu);target/s390x/cpu.h +1
-0@@ -93,6 +93,7 @@ struct CPUS390XState {uint32_t fpc;/* floating-point control register */ uint32_t cc_op; +bool bpbc;/* branch prediction blocking */ float_status fpu_status;/* passed to softfloat lib */ target/s390x/cpu_features.c +0
-0
target/s390x/cpu_features.c static const S390FeatDef s390_features[] = { · line 95
Quoted 7 lines
target/s390x/cpu_features.c +1
-0@@ -89,6 +89,7 @@ static const S390FeatDef s390_features[] = {FEAT_INIT ("msa4-base" ,S390_FEAT_TYPE_STFL ,77 ,"Message-security-assist-extension-4 facility (excluding subfunctions)" ),FEAT_INIT ("edat2" ,S390_FEAT_TYPE_STFL ,78 ,"Enhanced-DAT facility 2" ),FEAT_INIT ("dfppc" ,S390_FEAT_TYPE_STFL ,80 ,"Decimal-floating-point packed-conversion facility" ), +FEAT_INIT ("bpb" ,S390_FEAT_TYPE_STFL ,82 ,"Branch Prediction Blocking" ),FEAT_INIT ("vx" ,S390_FEAT_TYPE_STFL ,129 ,"Vector facility" ),FEAT_INIT ("iep" ,S390_FEAT_TYPE_STFL ,130 ,"Instruction-execution-protection facility" ), FEAT_INIT("sea_esop2", S390_FEAT_TYPE_STFL, 131, "Side-effect-access facility and Enhanced-suppression-on-protection facility 2"),
I'm not an expert with all this CPU model stuff, but at least for me, the patch looks fine now.
Re: [Qemu-devel] [PATCH v3 2/3] s390x/kvm: Handle bpb feature
In reply to Christian BorntraegerQuoted 144 lines · Christian Borntraeger
We need to handle the bpb control on reset and migration. Normally stfle.82 is transparent (and the normal guest part works without hypervisor activity). To prevent any issues we require full host kernel support for this feature.
Signed-off-by Christian Borntraeger <[email protected]>--- target/s390x/cpu.c | 1 + target/s390x/cpu.h | 1 + target/s390x/cpu_features.c | 1 + target/s390x/cpu_features_def.h | 1 + target/s390x/gen-features.c | 1 + target/s390x/kvm.c | 14 ++++++++++++++ target/s390x/machine.c | 17 +++++++++++++++++ 7 files changed, 36 insertions(+)target/s390x/cpu.c +1
-0@@ -89,6 +89,7 @@ static void s390_cpu_reset(CPUState *s)CPUS390XState *env = &cpu->env; env->pfault_token =-1UL ; + env->bpbc = false; scc->parent_reset (s); cpu->env.sigp_order =0 ;s390_cpu_set_state (CPU_STATE_STOPPED , cpu);target/s390x/cpu.h +1
-0@@ -93,6 +93,7 @@ struct CPUS390XState {uint32_t fpc;/* floating-point control register */ uint32_t cc_op; +bool bpbc;/* branch prediction blocking */ float_status fpu_status;/* passed to softfloat lib */ target/s390x/cpu_features.c +1
-0@@ -89,6 +89,7 @@ static const S390FeatDef s390_features[] = {FEAT_INIT ("msa4-base" ,S390_FEAT_TYPE_STFL ,77 ,"Message-security-assist-extension-4 facility (excluding subfunctions)" ),FEAT_INIT ("edat2" ,S390_FEAT_TYPE_STFL ,78 ,"Enhanced-DAT facility 2" ),FEAT_INIT ("dfppc" ,S390_FEAT_TYPE_STFL ,80 ,"Decimal-floating-point packed-conversion facility" ), +FEAT_INIT ("bpb" ,S390_FEAT_TYPE_STFL ,82 ,"Branch Prediction Blocking" ),FEAT_INIT ("vx" ,S390_FEAT_TYPE_STFL ,129 ,"Vector facility" ),FEAT_INIT ("iep" ,S390_FEAT_TYPE_STFL ,130 ,"Instruction-execution-protection facility" ), FEAT_INIT("sea_esop2", S390_FEAT_TYPE_STFL, 131, "Side-effect-access facility and Enhanced-suppression-on-protection facility 2"),target/s390x/cpu_features_def.h +1
-0@@ -80,6 +80,7 @@ typedef enum {S390_FEAT_MSA_EXT_4 ,S390_FEAT_EDAT_2 ,S390_FEAT_DFP_PACKED_CONVERSION , +S390_FEAT_BPB ,S390_FEAT_VECTOR ,S390_FEAT_INSTRUCTION_EXEC_PROT , S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2,target/s390x/gen-features.c +1
-0@@ -352,6 +352,7 @@ static uint16_t base_GEN14_GA1[] = {* support these features yet. */ static uint16_t full_GEN7_GA1[] = { +S390_FEAT_BPB ,S390_FEAT_SIE_F2 ,S390_FEAT_SIE_SKEY ,S390_FEAT_SIE_GPERE ,target/s390x/kvm.c +14
-0@@ -490,6 +490,11 @@ int kvm_arch_put_registers(CPUState *cs, int level) cs->kvm_run->kvm_dirty_regs |=KVM_SYNC_GSCB ; } +if (can_sync_regs (cs,KVM_SYNC_BPBC )) { + cs->kvm_run->s.regs.bpbc = env->bpbc; + cs->kvm_run->kvm_dirty_regs |=KVM_SYNC_BPBC ; + } +/* Finally the prefix */ if (can_sync_regs (cs,KVM_SYNC_PREFIX )) { cs->kvm_run->s.regs.prefix = env->psa;@@ -600,6 +605,10 @@ int kvm_arch_get_registers(CPUState *cs)memcpy (env->gscb, cs->kvm_run->s.regs.gscb,32 ); } +if (can_sync_regs (cs,KVM_SYNC_BPBC )) { + env->bpbc = cs->kvm_run->s.regs.bpbc; + } +/* pfault parameters */ if (can_sync_regs (cs,KVM_SYNC_PFAULT )) { env->pfault_token = cs->kvm_run->s.regs.pft;@@ -2278,6 +2287,11 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp)clear_bit (S390_FEAT_CMM_NT , model->features); } +/* bpb needs kernel support for migration, VSIE and reset */ +if (!kvm_check_extension (kvm_state,KVM_CAP_S390_BPB )) { +clear_bit (S390_FEAT_BPB , model->features); + } +/* We emulate a zPCI bus and AEN, therefore we don't need HW support */ if (pci_available) {set_bit (S390_FEAT_ZPCI , model->features);target/s390x/machine.c +16
-0@@ -194,6 +194,22 @@ const VMStateDescription vmstate_gscb = { } }; +static bool bpbc_needed (void *opaque) +{ +return s390_has_feat (S390_FEAT_BPB ); +} + +const VMStateDescription vmstate_bpbc = { + .name ="cpu/bpbc" , + .version_id =1 , + .minimum_version_id =1 , + .needed = bpbc_needed, + .fields = (VMStateField []) { +VMSTATE_BOOL (env.bpbc,S390CPU ), +VMSTATE_END_OF_LIST () + } +}; +const VMStateDescription vmstate_s390_cpu = { .name ="cpu" , .post_load = cpu_post_load,
target/s390x/machine.c const VMStateDescription vmstate_s390_cpu = { · line 250
Quoted 7 lines
target/s390x/machine.c +1
-0@@ -228,6 +244,7 @@ const VMStateDescription vmstate_s390_cpu = { &vmstate_riccb, &vmstate_exval, &vmstate_gscb, + &vmstate_bpbc, NULL }, };
Signature · 3 lines
Thanks, David / dhildenb
Re: [Qemu-devel] [PATCH v3 2/3] s390x/kvm: Handle bpb feature
In reply to Christian BorntraegerQuoted 81 lines · Christian Borntraeger
We need to handle the bpb control on reset and migration. Normally stfle.82 is transparent (and the normal guest part works without hypervisor activity). To prevent any issues we require full host kernel support for this feature.
Signed-off-by Christian Borntraeger <[email protected]>--- target/s390x/cpu.c | 1 + target/s390x/cpu.h | 1 + target/s390x/cpu_features.c | 1 + target/s390x/cpu_features_def.h | 1 + target/s390x/gen-features.c | 1 + target/s390x/kvm.c | 14 ++++++++++++++ target/s390x/machine.c | 17 +++++++++++++++++ 7 files changed, 36 insertions(+)target/s390x/cpu.c +1
-0@@ -89,6 +89,7 @@ static void s390_cpu_reset(CPUState *s)CPUS390XState *env = &cpu->env; env->pfault_token =-1UL ; + env->bpbc = false; scc->parent_reset (s); cpu->env.sigp_order =0 ;s390_cpu_set_state (CPU_STATE_STOPPED , cpu);target/s390x/cpu.h +1
-0@@ -93,6 +93,7 @@ struct CPUS390XState {uint32_t fpc;/* floating-point control register */ uint32_t cc_op; +bool bpbc;/* branch prediction blocking */ float_status fpu_status;/* passed to softfloat lib */ target/s390x/cpu_features.c +1
-0@@ -89,6 +89,7 @@ static const S390FeatDef s390_features[] = {FEAT_INIT ("msa4-base" ,S390_FEAT_TYPE_STFL ,77 ,"Message-security-assist-extension-4 facility (excluding subfunctions)" ),FEAT_INIT ("edat2" ,S390_FEAT_TYPE_STFL ,78 ,"Enhanced-DAT facility 2" ),FEAT_INIT ("dfppc" ,S390_FEAT_TYPE_STFL ,80 ,"Decimal-floating-point packed-conversion facility" ), +FEAT_INIT ("bpb" ,S390_FEAT_TYPE_STFL ,82 ,"Branch Prediction Blocking" ),FEAT_INIT ("vx" ,S390_FEAT_TYPE_STFL ,129 ,"Vector facility" ),FEAT_INIT ("iep" ,S390_FEAT_TYPE_STFL ,130 ,"Instruction-execution-protection facility" ), FEAT_INIT("sea_esop2", S390_FEAT_TYPE_STFL, 131, "Side-effect-access facility and Enhanced-suppression-on-protection facility 2"),target/s390x/cpu_features_def.h +1
-0@@ -80,6 +80,7 @@ typedef enum {S390_FEAT_MSA_EXT_4 ,S390_FEAT_EDAT_2 ,S390_FEAT_DFP_PACKED_CONVERSION , +S390_FEAT_BPB ,S390_FEAT_VECTOR ,S390_FEAT_INSTRUCTION_EXEC_PROT , S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2,target/s390x/gen-features.c +1
-0@@ -352,6 +352,7 @@ static uint16_t base_GEN14_GA1[] = {* support these features yet. */ static uint16_t full_GEN7_GA1[] = { +S390_FEAT_BPB ,S390_FEAT_SIE_F2 ,S390_FEAT_SIE_SKEY ,S390_FEAT_SIE_GPERE ,target/s390x/kvm.c +0
-0
target/s390x/kvm.c int kvm_arch_put_registers(CPUState *cs, int level) · line 493
Quoted 4 lines
target/s390x/kvm.c +1
-0@@ -490,6 +490,11 @@ int kvm_arch_put_registers(CPUState *cs, int level) cs->kvm_run->kvm_dirty_regs |=KVM_SYNC_GSCB ; } +if (can_sync_regs (cs,KVM_SYNC_BPBC )) {
This is for compat machines <= 2.7, or? Should the guest of these get the STFLE bit 82 regardless of the outcome of kvm_check_extension(kvm_state, KVM_CAP_S390_BPB) if we have STFLE bit 82 in the host?
Quoted 19 lines
target/s390x/kvm.c +8
-0+ cs->kvm_run->s.regs.bpbc = env->bpbc; + cs->kvm_run->kvm_dirty_regs |=KVM_SYNC_BPBC ; + } +/* Finally the prefix */ if (can_sync_regs (cs,KVM_SYNC_PREFIX )) { cs->kvm_run->s.regs.prefix = env->psa;@@ -600,6 +605,10 @@ int kvm_arch_get_registers(CPUState *cs)memcpy (env->gscb, cs->kvm_run->s.regs.gscb,32 ); } +if (can_sync_regs (cs,KVM_SYNC_BPBC )) { + env->bpbc = cs->kvm_run->s.regs.bpbc; + } +/* pfault parameters */ if (can_sync_regs (cs,KVM_SYNC_PFAULT )) { env->pfault_token = cs->kvm_run->s.regs.pft;
target/s390x/kvm.c void kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp) · line 2290
Quoted 4 lines
target/s390x/kvm.c +1
-0@@ -2278,6 +2287,11 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp)clear_bit (S390_FEAT_CMM_NT , model->features); } +/* bpb needs kernel support for migration, VSIE and reset */
I would not mind being a little more verbose about the fact that although this is a non-hyp bit it should have been a hyp manged bit, and that is why we need the KVM_CAP_S390_BPB.
Quoted 36 lines
target/s390x/kvm.c +4
-0+if (!kvm_check_extension (kvm_state,KVM_CAP_S390_BPB )) { +clear_bit (S390_FEAT_BPB , model->features); + } +/* We emulate a zPCI bus and AEN, therefore we don't need HW support */ if (pci_available) {set_bit (S390_FEAT_ZPCI , model->features);target/s390x/machine.c +16
-0@@ -194,6 +194,22 @@ const VMStateDescription vmstate_gscb = { } }; +static bool bpbc_needed (void *opaque) +{ +return s390_has_feat (S390_FEAT_BPB ); +} + +const VMStateDescription vmstate_bpbc = { + .name ="cpu/bpbc" , + .version_id =1 , + .minimum_version_id =1 , + .needed = bpbc_needed, + .fields = (VMStateField []) { +VMSTATE_BOOL (env.bpbc,S390CPU ), +VMSTATE_END_OF_LIST () + } +}; +const VMStateDescription vmstate_s390_cpu = { .name ="cpu" , .post_load = cpu_post_load,
target/s390x/machine.c const VMStateDescription vmstate_s390_cpu = { · line 250
Quoted 7 lines
target/s390x/machine.c +1
-0@@ -228,6 +244,7 @@ const VMStateDescription vmstate_s390_cpu = { &vmstate_riccb, &vmstate_exval, &vmstate_gscb, + &vmstate_bpbc, NULL }, };
My comments aren't anything major, so:
Re: [Qemu-devel] [PATCH v3 2/3] s390x/kvm: Handle bpb feature
Quoted 87 lines · Halil Pasic
Quoted 84 lines · Christian Borntraeger
We need to handle the bpb control on reset and migration. Normally stfle.82 is transparent (and the normal guest part works without hypervisor activity). To prevent any issues we require full host kernel support for this feature.
Signed-off-by Christian Borntraeger <[email protected]>--- target/s390x/cpu.c | 1 + target/s390x/cpu.h | 1 + target/s390x/cpu_features.c | 1 + target/s390x/cpu_features_def.h | 1 + target/s390x/gen-features.c | 1 + target/s390x/kvm.c | 14 ++++++++++++++ target/s390x/machine.c | 17 +++++++++++++++++ 7 files changed, 36 insertions(+)target/s390x/cpu.c +1
-0@@ -89,6 +89,7 @@ static void s390_cpu_reset(CPUState *s)CPUS390XState *env = &cpu->env; env->pfault_token =-1UL ; + env->bpbc = false; scc->parent_reset (s); cpu->env.sigp_order =0 ;s390_cpu_set_state (CPU_STATE_STOPPED , cpu);target/s390x/cpu.h +1
-0@@ -93,6 +93,7 @@ struct CPUS390XState {uint32_t fpc;/* floating-point control register */ uint32_t cc_op; +bool bpbc;/* branch prediction blocking */ float_status fpu_status;/* passed to softfloat lib */ target/s390x/cpu_features.c +1
-0@@ -89,6 +89,7 @@ static const S390FeatDef s390_features[] = {FEAT_INIT ("msa4-base" ,S390_FEAT_TYPE_STFL ,77 ,"Message-security-assist-extension-4 facility (excluding subfunctions)" ),FEAT_INIT ("edat2" ,S390_FEAT_TYPE_STFL ,78 ,"Enhanced-DAT facility 2" ),FEAT_INIT ("dfppc" ,S390_FEAT_TYPE_STFL ,80 ,"Decimal-floating-point packed-conversion facility" ), +FEAT_INIT ("bpb" ,S390_FEAT_TYPE_STFL ,82 ,"Branch Prediction Blocking" ),FEAT_INIT ("vx" ,S390_FEAT_TYPE_STFL ,129 ,"Vector facility" ),FEAT_INIT ("iep" ,S390_FEAT_TYPE_STFL ,130 ,"Instruction-execution-protection facility" ), FEAT_INIT("sea_esop2", S390_FEAT_TYPE_STFL, 131, "Side-effect-access facility and Enhanced-suppression-on-protection facility 2"),target/s390x/cpu_features_def.h +1
-0@@ -80,6 +80,7 @@ typedef enum {S390_FEAT_MSA_EXT_4 ,S390_FEAT_EDAT_2 ,S390_FEAT_DFP_PACKED_CONVERSION , +S390_FEAT_BPB ,S390_FEAT_VECTOR ,S390_FEAT_INSTRUCTION_EXEC_PROT , S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2,target/s390x/gen-features.c +1
-0@@ -352,6 +352,7 @@ static uint16_t base_GEN14_GA1[] = {* support these features yet. */ static uint16_t full_GEN7_GA1[] = { +S390_FEAT_BPB ,S390_FEAT_SIE_F2 ,S390_FEAT_SIE_SKEY ,S390_FEAT_SIE_GPERE ,target/s390x/kvm.c +0
-0@@ -490,6 +490,11 @@ int kvm_arch_put_registers(CPUState *cs, int level) cs->kvm_run->kvm_dirty_regs |=KVM_SYNC_GSCB ; }
Quoted 5 lines
target/s390x/kvm.c int kvm_arch_put_registers(CPUState *cs, int level) · line 493
Quoted 1 line
target/s390x/kvm.c +1
-0+if (can_sync_regs (cs,KVM_SYNC_BPBC )) {This is for compat machines <= 2.7, or? Should the guest of these get the STFLE bit 82 regardless of the outcome of
kvm_check_extension(kvm_state, KVM_CAP_S390_BPB)if we have STFLE bit 82 in the host?
I mirror the bpbc in the env of the CPU, mostly to properly reset the bpbc value on reset. We need this here to have the up-to-date values in QEMU (on synchronize-state) and kernel (on synchronize-back).
So whenever the kernel exposes this we will reset bpbc on reset.
PATCH v3 3/3 s390x/kvm: provide stfle.81
In reply to Christian Borntraegerstfle.81 (ppa15) is a transparent facility that can be passed to the guest without the need to implement hypervisor support. As this feature can be provided by firmware we add it to all full models.
--- target/s390x/cpu_features.c | 1 + target/s390x/cpu_features_def.h | 1 + target/s390x/gen-features.c | 1 + 3 files changed, 3 insertions(+)
target/s390x/cpu_features.c +1 -0
@@ -89,6 +89,7 @@ static const S390FeatDef s390_features[] = {FEAT_INIT ("msa4-base" ,S390_FEAT_TYPE_STFL ,77 ,"Message-security-assist-extension-4 facility (excluding subfunctions)" ),FEAT_INIT ("edat2" ,S390_FEAT_TYPE_STFL ,78 ,"Enhanced-DAT facility 2" ),FEAT_INIT ("dfppc" ,S390_FEAT_TYPE_STFL ,80 ,"Decimal-floating-point packed-conversion facility" ), +FEAT_INIT ("ppa15" ,S390_FEAT_TYPE_STFL ,81 ,"PPA15 is installed" ),FEAT_INIT ("bpb" ,S390_FEAT_TYPE_STFL ,82 ,"Branch Prediction Blocking" ),FEAT_INIT ("vx" ,S390_FEAT_TYPE_STFL ,129 ,"Vector facility" ), FEAT_INIT("iep", S390_FEAT_TYPE_STFL, 130, "Instruction-execution-protection facility"),
target/s390x/cpu_features_def.h +1 -0
@@ -80,6 +80,7 @@ typedef enum {S390_FEAT_MSA_EXT_4 ,S390_FEAT_EDAT_2 ,S390_FEAT_DFP_PACKED_CONVERSION , +S390_FEAT_PPA15 ,S390_FEAT_BPB ,S390_FEAT_VECTOR , S390_FEAT_INSTRUCTION_EXEC_PROT,
target/s390x/gen-features.c +1 -0
@@ -352,6 +352,7 @@ static uint16_t base_GEN14_GA1[] = {* support these features yet. */ static uint16_t full_GEN7_GA1[] = { +S390_FEAT_PPA15 ,S390_FEAT_BPB ,S390_FEAT_SIE_F2 ,S390_FEAT_SIE_SKEY ,
Signature · 1 line
2.9.4
Re: [Qemu-devel] [PATCH v3 3/3] s390x/kvm: provide stfle.81
Quoted 5 lines · Christian Borntraeger
stfle.81 (ppa15) is a transparent facility that can be passed to the guest without the need to implement hypervisor support. As this feature can be provided by firmware we add it to all full models.
Signed-off-by Christian Borntraeger <[email protected]>
Re: [Qemu-devel] [PATCH v3 3/3] s390x/kvm: provide stfle.81
In reply to Christian BorntraegerQuoted 41 lines · Christian Borntraeger
stfle.81 (ppa15) is a transparent facility that can be passed to the guest without the need to implement hypervisor support. As this feature can be provided by firmware we add it to all full models.
Signed-off-by Christian Borntraeger <[email protected]>--- target/s390x/cpu_features.c | 1 + target/s390x/cpu_features_def.h | 1 + target/s390x/gen-features.c | 1 + 3 files changed, 3 insertions(+)target/s390x/cpu_features.c +1
-0@@ -89,6 +89,7 @@ static const S390FeatDef s390_features[] = {FEAT_INIT ("msa4-base" ,S390_FEAT_TYPE_STFL ,77 ,"Message-security-assist-extension-4 facility (excluding subfunctions)" ),FEAT_INIT ("edat2" ,S390_FEAT_TYPE_STFL ,78 ,"Enhanced-DAT facility 2" ),FEAT_INIT ("dfppc" ,S390_FEAT_TYPE_STFL ,80 ,"Decimal-floating-point packed-conversion facility" ), +FEAT_INIT ("ppa15" ,S390_FEAT_TYPE_STFL ,81 ,"PPA15 is installed" ),FEAT_INIT ("bpb" ,S390_FEAT_TYPE_STFL ,82 ,"Branch Prediction Blocking" ),FEAT_INIT ("vx" ,S390_FEAT_TYPE_STFL ,129 ,"Vector facility" ), FEAT_INIT("iep", S390_FEAT_TYPE_STFL, 130, "Instruction-execution-protection facility"),target/s390x/cpu_features_def.h +1
-0@@ -80,6 +80,7 @@ typedef enum {S390_FEAT_MSA_EXT_4 ,S390_FEAT_EDAT_2 ,S390_FEAT_DFP_PACKED_CONVERSION , +S390_FEAT_PPA15 ,S390_FEAT_BPB ,S390_FEAT_VECTOR , S390_FEAT_INSTRUCTION_EXEC_PROT,target/s390x/gen-features.c +0
-0
target/s390x/gen-features.c static uint16_t base_GEN14_GA1[] = { · line 358
Quoted 7 lines
target/s390x/gen-features.c +1
-0@@ -352,6 +352,7 @@ static uint16_t base_GEN14_GA1[] = {* support these features yet. */ static uint16_t full_GEN7_GA1[] = { +S390_FEAT_PPA15 ,S390_FEAT_BPB ,S390_FEAT_SIE_F2 ,S390_FEAT_SIE_SKEY ,
Signature · 3 lines
Thanks, David / dhildenb
Re: [Qemu-devel] [PATCH v3 3/3] s390x/kvm: provide stfle.81
In reply to Christian BorntraegerQuoted 11 lines · Christian Borntraeger
stfle.81 (ppa15) is a transparent facility that can be passed to the guest without the need to implement hypervisor support. As this feature can be provided by firmware we add it to all full models.
Signed-off-by Christian Borntraeger <[email protected]>--- target/s390x/cpu_features.c | 1 + target/s390x/cpu_features_def.h | 1 + target/s390x/gen-features.c | 1 + 3 files changed, 3 insertions(+)
Quoted 18 lines · On Thu, 18 Jan 2018 09:56:25 +0100 Christian Borntraeger…
We want to provide more hw features to guests, namely the new bpb control as well as other transparent facilities that might be introduced by firmware updates (e.g. the stfle facility 81).
See the kernel discussion for the KVM side
https://www.spinics.net/lists/kernel/msg2700551.html
v2->v3: - use bool for bpbc
- sort cpu facilitiesv1->v2: - style and comment fixes
- drop transparent facility patch
- add patch to introduce facility 81Christian Borntraeger (3):
header sync
s390x/kvm: Handle bpb feature
s390x/kvm: provide stfle.81
Quoted 11 lines
linux-headers/asm-s390/kvm.h | 9 ++++----- linux-headers/linux/kvm.h | 5 +++-- target/s390x/cpu.c | 1 + target/s390x/cpu.h | 1 + target/s390x/cpu_features.c | 2 ++ target/s390x/cpu_features_def.h | 2 ++ target/s390x/gen-features.c | 2 ++ target/s390x/kvm.c | 14 ++++++++++++++ target/s390x/machine.c | 17 +++++++++++++++++ 9 files changed, 46 insertions(+), 7 deletions(-)
Thanks, I've queued this. Once the bpb code lands in Linux, I'll replace patch 1 with a proper header sync and push to s390-next.
Quoted 33 lines · Cornelia Huck
Quoted 18 lines · On Thu, 18 Jan 2018 09:56:25 +0100 Christian Borntraeger…
We want to provide more hw features to guests, namely the new bpb control as well as other transparent facilities that might be introduced by firmware updates (e.g. the stfle facility 81).
See the kernel discussion for the KVM side
https://www.spinics.net/lists/kernel/msg2700551.html
v2->v3: - use bool for bpbc
- sort cpu facilitiesv1->v2: - style and comment fixes
- drop transparent facility patch
- add patch to introduce facility 81Christian Borntraeger (3):
header sync
s390x/kvm: Handle bpb feature
s390x/kvm: provide stfle.81Quoted 11 lines
linux-headers/asm-s390/kvm.h | 9 ++++----- linux-headers/linux/kvm.h | 5 +++-- target/s390x/cpu.c | 1 + target/s390x/cpu.h | 1 + target/s390x/cpu_features.c | 2 ++ target/s390x/cpu_features_def.h | 2 ++ target/s390x/gen-features.c | 2 ++ target/s390x/kvm.c | 14 ++++++++++++++ target/s390x/machine.c | 17 +++++++++++++++++ 9 files changed, 46 insertions(+), 7 deletions(-)
Quoted 2 lines
Thanks, I've queued this. Once the bpb code lands in Linux, I'll replace patch 1 with a proper header sync and push to s390-next.
Have the x86 features been marked as stable? If the answer is yes, shall we mark these patches for stable as well?
Quoted 2 lines · On Thu, 18 Jan 2018 13:47:54 +0100 Christian Borntraeger…
Have the x86 features been marked as stable? If the answer is yes, shall we mark these patches for stable as well?
Doesn't look like it.
TBH, I'm not quite sure whether this should go into stable as I'm a bit unclear what our use case for stable is. It seems to be mostly "don't let people run into known crashes" or something like that.
These patches are not very useful on their own unless you run on a z with updated microcode and an updated host kernel. OTOH, the patches should be low risk.
Quoted 11 lines · Cornelia Huck
Quoted 2 lines · On Thu, 18 Jan 2018 13:47:54 +0100 Christian Borntraeger…
Have the x86 features been marked as stable? If the answer is yes, shall we mark these patches for stable as well?
Doesn't look like it.
TBH, I'm not quite sure whether this should go into stable as I'm a bit unclear what our use case for stable is. It seems to be mostly "don't let people run into known crashes" or something like that.
I read the public statement [1] as "... non-x86 processors ... backported to recent stable releases." or did the changes in discussion here end up structurally so different that this doesn't apply anymore?
Quoted 13 lines · On Thu, 18 Jan 2018 14:31:50 +0100 Christian Ehrhardt…
Quoted 11 lines · Cornelia Huck
Quoted 2 lines · On Thu, 18 Jan 2018 13:47:54 +0100 Christian Borntraeger…
Have the x86 features been marked as stable? If the answer is yes, shall we mark these patches for stable as well?
Doesn't look like it.
TBH, I'm not quite sure whether this should go into stable as I'm a bit unclear what our use case for stable is. It seems to be mostly "don't let people run into known crashes" or something like that.
Quoted 6 lines
I read the public statement [1] as "... non-x86 processors ... backported to recent stable releases." or did the changes in discussion here end up structurally so different that this doesn't apply anymore?
OK, that would read as "do backport". (The x86 patches I saw didn't carry an explicit cc:stable.)
Quoted 18 lines · On Thu, 18 Jan 2018 09:56:25 +0100 Christian Borntraeger…
We want to provide more hw features to guests, namely the new bpb control as well as other transparent facilities that might be introduced by firmware updates (e.g. the stfle facility 81).
See the kernel discussion for the KVM side
https://www.spinics.net/lists/kernel/msg2700551.html
v2->v3: - use bool for bpbc
- sort cpu facilitiesv1->v2: - style and comment fixes
- drop transparent facility patch
- add patch to introduce facility 81Christian Borntraeger (3):
header sync
s390x/kvm: Handle bpb feature
s390x/kvm: provide stfle.81
Quoted 11 lines
linux-headers/asm-s390/kvm.h | 9 ++++----- linux-headers/linux/kvm.h | 5 +++-- target/s390x/cpu.c | 1 + target/s390x/cpu.h | 1 + target/s390x/cpu_features.c | 2 ++ target/s390x/cpu_features_def.h | 2 ++ target/s390x/gen-features.c | 2 ++ target/s390x/kvm.c | 14 ++++++++++++++ target/s390x/machine.c | 17 +++++++++++++++++ 9 files changed, 46 insertions(+), 7 deletions(-)
Thanks, queued to s390-next (with a proper headers update).