s390: guest support for diagnose 318 and limit max VCPUs to 247
PATCH 1/1 s390: guest support for diagnose 318 and limit max VCPUs to 247
Add migration and reset support for diagnose 318. This is a new z14 GA2 hardware feature, but we can provide guest support starting with the zEC12-full CPU model.
Because new hardware introduces a new facility-availability byte in the Read SCP Info block, we lose one byte in the CPU entries list and must limit the maximum VCPUs to 247 (down from 248).
---
Changelog
RFC -> v1
- introduced kvm stubs for set/get cpc
- s/fac134/byte_134
- moved diag318 vmstate description to diag.c
- reduced S390_VCPU_MAX to 247
hw/s390x/ipl.c | 3 +++ hw/s390x/s390-virtio-ccw.c | 3 +++ hw/s390x/sclp.c | 2 ++ include/hw/s390x/sclp.h | 2 ++ linux-headers/asm-s390/kvm.h | 5 ++++ target/s390x/cpu.h | 2 +- target/s390x/cpu_features.c | 3 +++ target/s390x/cpu_features.h | 1 + target/s390x/cpu_features_def.h | 3 +++ target/s390x/diag.c | 53 +++++++++++++++++++++++++++++++++++++++++ target/s390x/gen-features.c | 1 + target/s390x/internal.h | 4 +++- target/s390x/kvm-stub.c | 10 ++++++++ target/s390x/kvm.c | 23 ++++++++++++++++++ target/s390x/kvm_s390x.h | 3 +++ 15 files changed, 116 insertions(+), 2 deletions(-)
hw/s390x/ipl.c +3 -0
@@ -27,6 +27,7 @@#include "qemu/cutils.h" #include "qemu/option.h" #include "exec/exec-all.h" +#include "internal.h" #define KERN_IMAGE_START 0x010000UL#define LINUX_MAGIC_ADDR 0x010008UL
@@ -230,6 +231,8 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp) ipl->compat_start_addr = ipl->start_addr; ipl->compat_bios_start_addr = ipl->bios_start_addr;qemu_register_reset (qdev_reset_all_fn, dev); + +diag318_register (); error:error_propagate (errp, err); }
hw/s390x/s390-virtio-ccw.c +3 -0
@@ -37,6 +37,7 @@#include "cpu_models.h" #include "hw/nmi.h" #include "hw/s390x/tod.h" +#include "internal.h" S390CPU *s390_cpu_addr2state (uint16_t cpu_addr) {
@@ -357,6 +358,7 @@ static void s390_machine_reset(void) }subsystem_reset ();s390_crypto_reset (); +diag318_reset ();run_on_cpu (cs, s390_do_cpu_load_normal,RUN_ON_CPU_NULL );break ;case S390_RESET_LOAD_NORMAL :
@@ -364,6 +366,7 @@ static void s390_machine_reset(void)run_on_cpu (t, s390_do_cpu_reset,RUN_ON_CPU_NULL ); }subsystem_reset (); +diag318_reset ();run_on_cpu (cs, s390_do_cpu_initial_reset,RUN_ON_CPU_NULL );run_on_cpu (cs, s390_do_cpu_load_normal,RUN_ON_CPU_NULL );break ;
hw/s390x/sclp.c +2 -0
@@ -73,6 +73,8 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) read_info->conf_char);s390_get_feat_block (S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT , read_info->conf_char_ext); +/* Read Info byte 134 */ +s390_get_feat_block (S390_FEAT_TYPE_SCLP_BYTE_134 , read_info->byte_134); read_info->facilities =cpu_to_be64 (SCLP_HAS_CPU_INFO |SCLP_HAS_IOA_RECONFIG );
include/hw/s390x/sclp.h +2 -0
@@ -133,6 +133,8 @@ typedef struct ReadInfo {uint16_t highest_cpu;uint8_t _reserved5[124 -122 ];/* 122-123 */ uint32_t hmfai; +uint8_t _reserved7[134 -128 ];/* 128-133 */ +uint8_t byte_134[1 ];struct CPUEntry entries[0 ]; }QEMU_PACKED ReadInfo;
linux-headers/asm-s390/kvm.h +5 -0
@@ -74,6 +74,7 @@ struct kvm_s390_io_adapter_req {#define KVM_S390_VM_CRYPTO 2#define KVM_S390_VM_CPU_MODEL 3#define KVM_S390_VM_MIGRATION 4 +#define KVM_S390_VM_MISC 5/* kvm attributes for mem_ctrl */ #define KVM_S390_VM_MEM_ENABLE_CMMA 0
@@ -130,6 +131,7 @@ struct kvm_s390_vm_cpu_machine {#define KVM_S390_VM_CPU_FEAT_PFMFI 11#define KVM_S390_VM_CPU_FEAT_SIGPIF 12#define KVM_S390_VM_CPU_FEAT_KSS 13 +#define KVM_S390_VM_CPU_FEAT_DIAG318 14struct kvm_s390_vm_cpu_feat {__u64 feat[16 ]; };
@@ -168,6 +170,9 @@ struct kvm_s390_vm_cpu_subfunc {#define KVM_S390_VM_MIGRATION_START 1#define KVM_S390_VM_MIGRATION_STATUS 2 +/* kvm attributes for KVM_S390_VM_MISC */ +#define KVM_S390_VM_MISC_CPC 0 +/* for KVM_GET_REGS and KVM_SET_REGS */ struct kvm_regs {/* general purpose regs for s390 */
target/s390x/cpu.h +1 -1
@@ -52,7 +52,7 @@#define MMU_USER_IDX 0 -#define S390_MAX_CPUS 248 +#define S390_MAX_CPUS 247 typedef struct PSW { uint64_t mask;
target/s390x/cpu_features.c +3 -0
@@ -121,6 +121,9 @@ static const S390FeatDef s390_features[] = {FEAT_INIT ("pfmfi" ,S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT ,9 ,"SIE: PFMF interpretation facility" ),FEAT_INIT ("ibs" ,S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT ,10 ,"SIE: Interlock-and-broadcast-suppression facility" ), +/* SCLP SCCB Byte 134 */ +FEAT_INIT ("diag318" ,S390_FEAT_TYPE_SCLP_BYTE_134 ,0 ,"SIE: Diagnose 318" ), +FEAT_INIT ("sief2" ,S390_FEAT_TYPE_SCLP_CPU ,4 ,"SIE: interception format 2 (Virtual SIE)" ),FEAT_INIT ("skey" ,S390_FEAT_TYPE_SCLP_CPU ,5 ,"SIE: Storage-key facility" ), FEAT_INIT("gpereh", S390_FEAT_TYPE_SCLP_CPU, 10, "SIE: Guest-PER enhancement facility"),
target/s390x/cpu_features.h +1 -0
@@ -23,6 +23,7 @@ typedef enum {S390_FEAT_TYPE_STFL ,S390_FEAT_TYPE_SCLP_CONF_CHAR ,S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT , +S390_FEAT_TYPE_SCLP_BYTE_134 ,S390_FEAT_TYPE_SCLP_CPU ,S390_FEAT_TYPE_MISC , S390_FEAT_TYPE_PLO,
target/s390x/cpu_features_def.h +3 -0
@@ -109,6 +109,9 @@ typedef enum {S390_FEAT_SIE_PFMFI ,S390_FEAT_SIE_IBS , +/* Read Info Byte 134 */ +S390_FEAT_DIAG318 , +/* Sclp Cpu */ S390_FEAT_SIE_F2 , S390_FEAT_SIE_SKEY,
target/s390x/diag.c +53 -0
63 lines not on this page · raw message
target/s390x/gen-features.c +1 -0
@@ -450,6 +450,7 @@ static uint16_t full_GEN12_GA1[] = {S390_FEAT_AP_QUERY_CONFIG_INFO ,S390_FEAT_AP_FACILITIES_TEST ,S390_FEAT_AP , + S390_FEAT_DIAG318, }; static uint16_t full_GEN12_GA2[] = {
target/s390x/internal.h +3 -1
@@ -383,10 +383,12 @@ int mmu_translate_real(CPUS390XState *env, target_ulong raddr, int rw, target_ulong *addr, int *flags); -/* misc_helper.c */ +/* diag.c */ int handle_diag_288 (CPUS390XState *env,uint64_t r1,uint64_t r3);void handle_diag_308 (CPUS390XState *env,uint64_t r1,uint64_t r3,uintptr_t ra); +void diag318_register (void ); +void diag318_reset (void );/* translate.c */
target/s390x/kvm-stub.c +10 -0
@@ -104,3 +104,13 @@ void kvm_s390_stop_interrupt(S390CPU *cpu)void kvm_s390_restart_interrupt (S390CPU *cpu) { } + +int kvm_s390_get_cpc (uint64_t *cpc) +{ +return 0 ; +} + +int kvm_s390_set_cpc (uint64_t cpc) +{ +return 0 ; +}
target/s390x/kvm.c +23 -0
@@ -749,6 +749,28 @@ int kvm_s390_set_clock_ext(uint8_t tod_high, uint64_t tod_low)return kvm_vm_ioctl (kvm_state,KVM_SET_DEVICE_ATTR , &attr); } +int kvm_s390_get_cpc (uint64_t *cpc) +{ +struct kvm_device_attr attr = { + .group =KVM_S390_VM_MISC , + .attr =KVM_S390_VM_MISC_CPC , + .addr = (uint64_t )cpc, + }; + +return kvm_vm_ioctl (kvm_state,KVM_GET_DEVICE_ATTR , &attr); +} + +int kvm_s390_set_cpc (uint64_t cpc) +{ +struct kvm_device_attr attr = { + .group =KVM_S390_VM_MISC , + .attr =KVM_S390_VM_MISC_CPC , + .addr = (uint64_t )&cpc, + }; + +return kvm_vm_ioctl (kvm_state,KVM_SET_DEVICE_ATTR , &attr); +} +/** * kvm_s390_mem_op: * @addr: the logical start address in guest memory
@@ -2142,6 +2164,7 @@ static int kvm_to_feat[][2] = { { 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}, + { KVM_S390_VM_CPU_FEAT_DIAG318, S390_FEAT_DIAG318}, };static int query_cpu_feat (S390FeatBitmap features)
target/s390x/kvm_s390x.h +3 -0
@@ -29,6 +29,9 @@ int kvm_s390_get_clock(uint8_t *tod_high, uint64_t *tod_clock);int kvm_s390_get_clock_ext (uint8_t *tod_high,uint64_t *tod_clock);int kvm_s390_set_clock (uint8_t tod_high,uint64_t tod_clock);int kvm_s390_set_clock_ext (uint8_t tod_high,uint64_t tod_clock); +int kvm_s390_get_cpc (uint64_t *cpc); +int kvm_s390_set_cpc (uint64_t cpc); +bool kvm_s390_has_diag318 (void );void kvm_s390_enable_css_support (S390CPU *cpu);int kvm_s390_assign_subch_ioeventfd (EventNotifier *notifier,uint32_t sch,int vq,bool assign);
Signature · 1 line
2.7.4
I screen-scraped the @ibm address again (Conny was the victim this time)
Reply to this thread to avoid any delivery failures.
Quoted 368 lines · Collin Walling
Add migration and reset support for diagnose 318. This is a new z14 GA2 hardware feature, but we can provide guest support starting with the zEC12-full CPU model.
Because new hardware introduces a new facility-availability byte in the Read SCP Info block, we lose one byte in the CPU entries list and must limit the maximum VCPUs to 247 (down from 248).
Signed-off-by Collin Walling <[email protected]>---
Changelog
RFC -> v1
- introduced kvm stubs for set/get cpc
- s/fac134/byte_134
- moved diag318 vmstate description todiag.c
- reducedS390_VCPU_MAXto 247hw/s390x/ipl.c | 3 +++ hw/s390x/s390-virtio-ccw.c | 3 +++ hw/s390x/sclp.c | 2 ++ include/hw/s390x/sclp.h | 2 ++ linux-headers/asm-s390/kvm.h | 5 ++++ target/s390x/cpu.h | 2 +- target/s390x/cpu_features.c | 3 +++ target/s390x/cpu_features.h | 1 + target/s390x/cpu_features_def.h | 3 +++ target/s390x/diag.c | 53 +++++++++++++++++++++++++++++++++++++++++ target/s390x/gen-features.c | 1 + target/s390x/internal.h | 4 +++- target/s390x/kvm-stub.c | 10 ++++++++ target/s390x/kvm.c | 23 ++++++++++++++++++ target/s390x/kvm_s390x.h | 3 +++ 15 files changed, 116 insertions(+), 2 deletions(-)hw/s390x/ipl.c +3
-0@@ -27,6 +27,7 @@#include "qemu/cutils.h" #include "qemu/option.h" #include "exec/exec-all.h" +#include "internal.h" #define KERN_IMAGE_START 0x010000UL#define LINUX_MAGIC_ADDR 0x010008UL@@ -230,6 +231,8 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp) ipl->compat_start_addr = ipl->start_addr; ipl->compat_bios_start_addr = ipl->bios_start_addr;qemu_register_reset (qdev_reset_all_fn, dev); + +diag318_register (); error:error_propagate (errp, err); }hw/s390x/s390-virtio-ccw.c +3
-0@@ -37,6 +37,7 @@#include "cpu_models.h" #include "hw/nmi.h" #include "hw/s390x/tod.h" +#include "internal.h" S390CPU *s390_cpu_addr2state (uint16_t cpu_addr) {@@ -357,6 +358,7 @@ static void s390_machine_reset(void) }subsystem_reset ();s390_crypto_reset (); +diag318_reset ();run_on_cpu (cs, s390_do_cpu_load_normal,RUN_ON_CPU_NULL );break ;case S390_RESET_LOAD_NORMAL :@@ -364,6 +366,7 @@ static void s390_machine_reset(void)run_on_cpu (t, s390_do_cpu_reset,RUN_ON_CPU_NULL ); }subsystem_reset (); +diag318_reset ();run_on_cpu (cs, s390_do_cpu_initial_reset,RUN_ON_CPU_NULL );run_on_cpu (cs, s390_do_cpu_load_normal,RUN_ON_CPU_NULL );break ;hw/s390x/sclp.c +2
-0@@ -73,6 +73,8 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) read_info->conf_char);s390_get_feat_block (S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT , read_info->conf_char_ext); +/* Read Info byte 134 */ +s390_get_feat_block (S390_FEAT_TYPE_SCLP_BYTE_134 , read_info->byte_134); read_info->facilities =cpu_to_be64 (SCLP_HAS_CPU_INFO |SCLP_HAS_IOA_RECONFIG );include/hw/s390x/sclp.h +2
-0@@ -133,6 +133,8 @@ typedef struct ReadInfo {uint16_t highest_cpu;uint8_t _reserved5[124 -122 ];/* 122-123 */ uint32_t hmfai; +uint8_t _reserved7[134 -128 ];/* 128-133 */ +uint8_t byte_134[1 ];struct CPUEntry entries[0 ]; }QEMU_PACKED ReadInfo;linux-headers/asm-s390/kvm.h +5
-0@@ -74,6 +74,7 @@ struct kvm_s390_io_adapter_req {#define KVM_S390_VM_CRYPTO 2#define KVM_S390_VM_CPU_MODEL 3#define KVM_S390_VM_MIGRATION 4 +#define KVM_S390_VM_MISC 5/* kvm attributes for mem_ctrl */ #define KVM_S390_VM_MEM_ENABLE_CMMA 0@@ -130,6 +131,7 @@ struct kvm_s390_vm_cpu_machine {#define KVM_S390_VM_CPU_FEAT_PFMFI 11#define KVM_S390_VM_CPU_FEAT_SIGPIF 12#define KVM_S390_VM_CPU_FEAT_KSS 13 +#define KVM_S390_VM_CPU_FEAT_DIAG318 14struct kvm_s390_vm_cpu_feat {__u64 feat[16 ]; };@@ -168,6 +170,9 @@ struct kvm_s390_vm_cpu_subfunc {#define KVM_S390_VM_MIGRATION_START 1#define KVM_S390_VM_MIGRATION_STATUS 2 +/* kvm attributes for KVM_S390_VM_MISC */ +#define KVM_S390_VM_MISC_CPC 0 +/* for KVM_GET_REGS and KVM_SET_REGS */ struct kvm_regs {/* general purpose regs for s390 */ target/s390x/cpu.h +1
-1@@ -52,7 +52,7 @@#define MMU_USER_IDX 0 -#define S390_MAX_CPUS 248 +#define S390_MAX_CPUS 247 typedef struct PSW { uint64_t mask;target/s390x/cpu_features.c +3
-0@@ -121,6 +121,9 @@ static const S390FeatDef s390_features[] = {FEAT_INIT ("pfmfi" ,S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT ,9 ,"SIE: PFMF interpretation facility" ),FEAT_INIT ("ibs" ,S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT ,10 ,"SIE: Interlock-and-broadcast-suppression facility" ), +/* SCLP SCCB Byte 134 */ +FEAT_INIT ("diag318" ,S390_FEAT_TYPE_SCLP_BYTE_134 ,0 ,"SIE: Diagnose 318" ), +FEAT_INIT ("sief2" ,S390_FEAT_TYPE_SCLP_CPU ,4 ,"SIE: interception format 2 (Virtual SIE)" ),FEAT_INIT ("skey" ,S390_FEAT_TYPE_SCLP_CPU ,5 ,"SIE: Storage-key facility" ), FEAT_INIT("gpereh", S390_FEAT_TYPE_SCLP_CPU, 10, "SIE: Guest-PER enhancement facility"),target/s390x/cpu_features.h +1
-0@@ -23,6 +23,7 @@ typedef enum {S390_FEAT_TYPE_STFL ,S390_FEAT_TYPE_SCLP_CONF_CHAR ,S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT , +S390_FEAT_TYPE_SCLP_BYTE_134 ,S390_FEAT_TYPE_SCLP_CPU ,S390_FEAT_TYPE_MISC , S390_FEAT_TYPE_PLO,target/s390x/cpu_features_def.h +3
-0@@ -109,6 +109,9 @@ typedef enum {S390_FEAT_SIE_PFMFI ,S390_FEAT_SIE_IBS , +/* Read Info Byte 134 */ +S390_FEAT_DIAG318 , +/* Sclp Cpu */ S390_FEAT_SIE_F2 , S390_FEAT_SIE_SKEY,target/s390x/diag.c +53
-0@@ -20,6 +20,8 @@#include "sysemu/cpus.h" #include "hw/s390x/ipl.h" #include "hw/s390x/s390-virtio-ccw.h" +#include "kvm_s390x.h" +#include "sysemu/kvm.h" int handle_diag_288 (CPUS390XState *env,uint64_t r1,uint64_t r3) {@@ -134,3 +136,54 @@ out:break ; } } + +typedef struct Diag318Data { +uint64_t cpc; +}Diag318Data ; +static Diag318Data diag318data; + +void diag318_reset (void ) +{ +if (s390_has_feat (S390_FEAT_DIAG318 )) { +kvm_s390_set_cpc (0 ); + } +} + +static int diag318_post_load (void *opaque,int version_id) +{ +Diag318Data *d = opaque; + +kvm_s390_set_cpc (d->cpc); +return 0 ; +} + +static int diag318_pre_save (void *opaque) +{ +Diag318Data *d = opaque; + +kvm_s390_get_cpc (&d->cpc); +return 0 ; +} + +static bool diag318_needed (void *opaque) +{ +return s390_has_feat (S390_FEAT_DIAG318 ); +} + +const VMStateDescription vmstate_diag318 = { + .name ="diag318" , + .post_load = diag318_post_load, + .pre_save = diag318_pre_save, + .version_id =1 , + .minimum_version_id =1 , + .needed = diag318_needed, + .fields = (VMStateField []) { +VMSTATE_UINT64 (cpc, Diag318Data), +VMSTATE_END_OF_LIST () + } +}; + +void diag318_register (void ) +{ +vmstate_register (NULL ,0 , &vmstate_diag318, &diag318data); +}target/s390x/gen-features.c +1
-0@@ -450,6 +450,7 @@ static uint16_t full_GEN12_GA1[] = {S390_FEAT_AP_QUERY_CONFIG_INFO ,S390_FEAT_AP_FACILITIES_TEST ,S390_FEAT_AP , + S390_FEAT_DIAG318, }; static uint16_t full_GEN12_GA2[] = {target/s390x/internal.h +3
-1@@ -383,10 +383,12 @@ int mmu_translate_real(CPUS390XState *env, target_ulong raddr, int rw, target_ulong *addr, int *flags); -/* misc_helper.c */ +/* diag.c */ int handle_diag_288 (CPUS390XState *env,uint64_t r1,uint64_t r3);void handle_diag_308 (CPUS390XState *env,uint64_t r1,uint64_t r3,uintptr_t ra); +void diag318_register (void ); +void diag318_reset (void );/* translate.c */ target/s390x/kvm-stub.c +10
-0@@ -104,3 +104,13 @@ void kvm_s390_stop_interrupt(S390CPU *cpu)void kvm_s390_restart_interrupt (S390CPU *cpu) { } + +int kvm_s390_get_cpc (uint64_t *cpc) +{ +return 0 ; +} + +int kvm_s390_set_cpc (uint64_t cpc) +{ +return 0 ; +}target/s390x/kvm.c +23
-0@@ -749,6 +749,28 @@ int kvm_s390_set_clock_ext(uint8_t tod_high, uint64_t tod_low)return kvm_vm_ioctl (kvm_state,KVM_SET_DEVICE_ATTR , &attr); } +int kvm_s390_get_cpc (uint64_t *cpc) +{ +struct kvm_device_attr attr = { + .group =KVM_S390_VM_MISC , + .attr =KVM_S390_VM_MISC_CPC , + .addr = (uint64_t )cpc, + }; + +return kvm_vm_ioctl (kvm_state,KVM_GET_DEVICE_ATTR , &attr); +} + +int kvm_s390_set_cpc (uint64_t cpc) +{ +struct kvm_device_attr attr = { + .group =KVM_S390_VM_MISC , + .attr =KVM_S390_VM_MISC_CPC , + .addr = (uint64_t )&cpc, + }; + +return kvm_vm_ioctl (kvm_state,KVM_SET_DEVICE_ATTR , &attr); +} +/** * kvm_s390_mem_op: * @addr: the logical start address in guest memory @@ -2142,6 +2164,7 @@ static int kvm_to_feat[][2] = { { 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}, + { KVM_S390_VM_CPU_FEAT_DIAG318, S390_FEAT_DIAG318}, };static int query_cpu_feat (S390FeatBitmap features)target/s390x/kvm_s390x.h +3
-0@@ -29,6 +29,9 @@ int kvm_s390_get_clock(uint8_t *tod_high, uint64_t *tod_clock);int kvm_s390_get_clock_ext (uint8_t *tod_high,uint64_t *tod_clock);int kvm_s390_set_clock (uint8_t tod_high,uint64_t tod_clock);int kvm_s390_set_clock_ext (uint8_t tod_high,uint64_t tod_clock); +int kvm_s390_get_cpc (uint64_t *cpc); +int kvm_s390_set_cpc (uint64_t cpc); +bool kvm_s390_has_diag318 (void );void kvm_s390_enable_css_support (S390CPU *cpu);int kvm_s390_assign_subch_ioeventfd (EventNotifier *notifier,uint32_t sch,int vq,bool assign);
Signature · 2 lines
Respectfully, - Collin Walling
Quoted 41 lines · On Tue, 4 Dec 2018 17:26:36 -0500 Collin Walling <[email protected]> wrote:
I screen-scraped the @ibm address again (Conny was the victim this time)
Reply to this thread to avoid any delivery failures.
Quoted 35 lines · Collin Walling
Add migration and reset support for diagnose 318. This is a new z14 GA2 hardware feature, but we can provide guest support starting with the zEC12-full CPU model.
Because new hardware introduces a new facility-availability byte in the Read SCP Info block, we lose one byte in the CPU entries list and must limit the maximum VCPUs to 247 (down from 248).
Signed-off-by Collin Walling <[email protected]>---
Changelog
RFC -> v1
- introduced kvm stubs for set/get cpc
- s/fac134/byte_134
- moved diag318 vmstate description todiag.c
- reducedS390_VCPU_MAXto 247hw/s390x/ipl.c | 3 +++ hw/s390x/s390-virtio-ccw.c | 3 +++ hw/s390x/sclp.c | 2 ++ include/hw/s390x/sclp.h | 2 ++ linux-headers/asm-s390/kvm.h | 5 ++++ target/s390x/cpu.h | 2 +- target/s390x/cpu_features.c | 3 +++ target/s390x/cpu_features.h | 1 + target/s390x/cpu_features_def.h | 3 +++ target/s390x/diag.c | 53 +++++++++++++++++++++++++++++++++++++++++ target/s390x/gen-features.c | 1 + target/s390x/internal.h | 4 +++- target/s390x/kvm-stub.c | 10 ++++++++ target/s390x/kvm.c | 23 ++++++++++++++++++ target/s390x/kvm_s390x.h | 3 +++ 15 files changed, 116 insertions(+), 2 deletions(-)
Quoted 4 lines
linux-headers/asm-s390/kvm.h
Quoted 4 lines
linux-headers/asm-s390/kvm.h +0
-0
Please split this out into a dummy headers update patch, which will be replaced with a real headers update when applied.
Quoted 44 lines · Cornelia Huck
Quoted 40 lines · On Tue, 4 Dec 2018 17:26:36 -0500 Collin Walling <[email protected]> wrote:
I screen-scraped the @ibm address again (Conny was the victim this time)
Reply to this thread to avoid any delivery failures.
Quoted 35 lines · Collin Walling
Add migration and reset support for diagnose 318. This is a new z14 GA2 hardware feature, but we can provide guest support starting with the zEC12-full CPU model.
Because new hardware introduces a new facility-availability byte in the Read SCP Info block, we lose one byte in the CPU entries list and must limit the maximum VCPUs to 247 (down from 248).
Signed-off-by Collin Walling <[email protected]>---
Changelog
RFC -> v1
- introduced kvm stubs for set/get cpc
- s/fac134/byte_134
- moved diag318 vmstate description todiag.c
- reducedS390_VCPU_MAXto 247hw/s390x/ipl.c | 3 +++ hw/s390x/s390-virtio-ccw.c | 3 +++ hw/s390x/sclp.c | 2 ++ include/hw/s390x/sclp.h | 2 ++ linux-headers/asm-s390/kvm.h | 5 ++++ target/s390x/cpu.h | 2 +- target/s390x/cpu_features.c | 3 +++ target/s390x/cpu_features.h | 1 + target/s390x/cpu_features_def.h | 3 +++ target/s390x/diag.c | 53 +++++++++++++++++++++++++++++++++++++++++ target/s390x/gen-features.c | 1 + target/s390x/internal.h | 4 +++- target/s390x/kvm-stub.c | 10 ++++++++ target/s390x/kvm.c | 23 ++++++++++++++++++ target/s390x/kvm_s390x.h | 3 +++ 15 files changed, 116 insertions(+), 2 deletions(-)
Quoted 9 lines
Quoted 4 lines
linux-headers/asm-s390/kvm.h
Quoted 4 lines
linux-headers/asm-s390/kvm.h +0
-0Please split this out into a dummy headers update patch, which will be replaced with a real headers update when applied.
Will do.
Signature · 2 lines
Respectfully, - Collin Walling
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Subject: [Qemu-devel] [PATCH v1] s390: guest support for diagnose 318 and limit max VCPUs to 247
Message-id: [email protected]
=== TEST SCRIPT BEGIN ===
#!/bin/bash
BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))done
exit $failed
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
b5218a7 s390: guest support for diagnose 318 and limit max VCPUs to 247
=== OUTPUT BEGIN ===
Checking PATCH 1/1: s390: guest support for diagnose 318 and limit max VCPUs to 247...
ERROR: adding a line without newline at end of file
#243: FILE: target/s390x/diag.c:189:
+}
ERROR: adding a line without newline at end of file #292: FILE: target/s390x/kvm-stub.c:116:
+}
total: 2 errors, 0 warnings, 247 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]
Quoted 7 lines · Collin Walling
Add migration and reset support for diagnose 318. This is a new z14 GA2 hardware feature, but we can provide guest support starting with the zEC12-full CPU model.
Because new hardware introduces a new facility-availability byte in the Read SCP Info block, we lose one byte in the CPU entries list and must limit the maximum VCPUs to 247 (down from 248).
This could break setups that upgrade/migrate. At least forward migration can be broken. Do we care about that?
Can you split off
1. linux-header changes
2. CPU model changes? (introduction and definition of new feature, but not when it is used?)
Quoted 71 lines
Signed-off-by Collin Walling <[email protected]>---
Changelog
RFC -> v1
- introduced kvm stubs for set/get cpc
- s/fac134/byte_134
- moved diag318 vmstate description todiag.c
- reducedS390_VCPU_MAXto 247hw/s390x/ipl.c | 3 +++ hw/s390x/s390-virtio-ccw.c | 3 +++ hw/s390x/sclp.c | 2 ++ include/hw/s390x/sclp.h | 2 ++ linux-headers/asm-s390/kvm.h | 5 ++++ target/s390x/cpu.h | 2 +- target/s390x/cpu_features.c | 3 +++ target/s390x/cpu_features.h | 1 + target/s390x/cpu_features_def.h | 3 +++ target/s390x/diag.c | 53 +++++++++++++++++++++++++++++++++++++++++ target/s390x/gen-features.c | 1 + target/s390x/internal.h | 4 +++- target/s390x/kvm-stub.c | 10 ++++++++ target/s390x/kvm.c | 23 ++++++++++++++++++ target/s390x/kvm_s390x.h | 3 +++ 15 files changed, 116 insertions(+), 2 deletions(-)hw/s390x/ipl.c +3
-0@@ -27,6 +27,7 @@#include "qemu/cutils.h" #include "qemu/option.h" #include "exec/exec-all.h" +#include "internal.h" #define KERN_IMAGE_START 0x010000UL#define LINUX_MAGIC_ADDR 0x010008UL@@ -230,6 +231,8 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp) ipl->compat_start_addr = ipl->start_addr; ipl->compat_bios_start_addr = ipl->bios_start_addr;qemu_register_reset (qdev_reset_all_fn, dev); + +diag318_register (); error:error_propagate (errp, err); }hw/s390x/s390-virtio-ccw.c +2
-0@@ -37,6 +37,7 @@#include "cpu_models.h" #include "hw/nmi.h" #include "hw/s390x/tod.h" +#include "internal.h" S390CPU *s390_cpu_addr2state (uint16_t cpu_addr) {@@ -357,6 +358,7 @@ static void s390_machine_reset(void) }subsystem_reset ();s390_crypto_reset (); +diag318_reset ();run_on_cpu (cs, s390_do_cpu_load_normal,RUN_ON_CPU_NULL );break ;case S390_RESET_LOAD_NORMAL :
hw/s390x/s390-virtio-ccw.c static void s390_machine_reset(void) · line 372
Quoted 7 lines
hw/s390x/s390-virtio-ccw.c +1
-0@@ -364,6 +366,7 @@ static void s390_machine_reset(void)run_on_cpu (t, s390_do_cpu_reset,RUN_ON_CPU_NULL ); }subsystem_reset (); +diag318_reset ();run_on_cpu (cs, s390_do_cpu_initial_reset,RUN_ON_CPU_NULL );run_on_cpu (cs, s390_do_cpu_load_normal,RUN_ON_CPU_NULL );break ;
Why don't we have to reset this during reipl or external reset ("system_reset")?
Quoted 74 lines
hw/s390x/sclp.c +2
-0@@ -73,6 +73,8 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) read_info->conf_char);s390_get_feat_block (S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT , read_info->conf_char_ext); +/* Read Info byte 134 */ +s390_get_feat_block (S390_FEAT_TYPE_SCLP_BYTE_134 , read_info->byte_134); read_info->facilities =cpu_to_be64 (SCLP_HAS_CPU_INFO |SCLP_HAS_IOA_RECONFIG );include/hw/s390x/sclp.h +2
-0@@ -133,6 +133,8 @@ typedef struct ReadInfo {uint16_t highest_cpu;uint8_t _reserved5[124 -122 ];/* 122-123 */ uint32_t hmfai; +uint8_t _reserved7[134 -128 ];/* 128-133 */ +uint8_t byte_134[1 ];struct CPUEntry entries[0 ]; }QEMU_PACKED ReadInfo;linux-headers/asm-s390/kvm.h +5
-0@@ -74,6 +74,7 @@ struct kvm_s390_io_adapter_req {#define KVM_S390_VM_CRYPTO 2#define KVM_S390_VM_CPU_MODEL 3#define KVM_S390_VM_MIGRATION 4 +#define KVM_S390_VM_MISC 5/* kvm attributes for mem_ctrl */ #define KVM_S390_VM_MEM_ENABLE_CMMA 0@@ -130,6 +131,7 @@ struct kvm_s390_vm_cpu_machine {#define KVM_S390_VM_CPU_FEAT_PFMFI 11#define KVM_S390_VM_CPU_FEAT_SIGPIF 12#define KVM_S390_VM_CPU_FEAT_KSS 13 +#define KVM_S390_VM_CPU_FEAT_DIAG318 14struct kvm_s390_vm_cpu_feat {__u64 feat[16 ]; };@@ -168,6 +170,9 @@ struct kvm_s390_vm_cpu_subfunc {#define KVM_S390_VM_MIGRATION_START 1#define KVM_S390_VM_MIGRATION_STATUS 2 +/* kvm attributes for KVM_S390_VM_MISC */ +#define KVM_S390_VM_MISC_CPC 0 +/* for KVM_GET_REGS and KVM_SET_REGS */ struct kvm_regs {/* general purpose regs for s390 */ target/s390x/cpu.h +1
-1@@ -52,7 +52,7 @@#define MMU_USER_IDX 0 -#define S390_MAX_CPUS 248 +#define S390_MAX_CPUS 247 typedef struct PSW { uint64_t mask;target/s390x/cpu_features.c +0
-0
target/s390x/cpu_features.c static const S390FeatDef s390_features[] = { · line 125
Quoted 5 lines
target/s390x/cpu_features.c +2
-0@@ -121,6 +121,9 @@ static const S390FeatDef s390_features[] = {FEAT_INIT ("pfmfi" ,S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT ,9 ,"SIE: PFMF interpretation facility" ),FEAT_INIT ("ibs" ,S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT ,10 ,"SIE: Interlock-and-broadcast-suppression facility" ), +/* SCLP SCCB Byte 134 */ + FEAT_INIT("diag318", S390_FEAT_TYPE_SCLP_BYTE_134, 0, "SIE: Diagnose 318"),
Is this bit "SIE: Diagnose 318" or "SIE: SCLP Byte 14" ?
Or both?
Quoted 44 lines
target/s390x/cpu_features.c +1
-0+FEAT_INIT ("sief2" ,S390_FEAT_TYPE_SCLP_CPU ,4 ,"SIE: interception format 2 (Virtual SIE)" ),FEAT_INIT ("skey" ,S390_FEAT_TYPE_SCLP_CPU ,5 ,"SIE: Storage-key facility" ), FEAT_INIT("gpereh", S390_FEAT_TYPE_SCLP_CPU, 10, "SIE: Guest-PER enhancement facility"),target/s390x/cpu_features.h +1
-0@@ -23,6 +23,7 @@ typedef enum {S390_FEAT_TYPE_STFL ,S390_FEAT_TYPE_SCLP_CONF_CHAR ,S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT , +S390_FEAT_TYPE_SCLP_BYTE_134 ,S390_FEAT_TYPE_SCLP_CPU ,S390_FEAT_TYPE_MISC , S390_FEAT_TYPE_PLO,target/s390x/cpu_features_def.h +3
-0@@ -109,6 +109,9 @@ typedef enum {S390_FEAT_SIE_PFMFI ,S390_FEAT_SIE_IBS , +/* Read Info Byte 134 */ +S390_FEAT_DIAG318 , +/* Sclp Cpu */ S390_FEAT_SIE_F2 , S390_FEAT_SIE_SKEY,target/s390x/diag.c +2
-0@@ -20,6 +20,8 @@#include "sysemu/cpus.h" #include "hw/s390x/ipl.h" #include "hw/s390x/s390-virtio-ccw.h" +#include "kvm_s390x.h" +#include "sysemu/kvm.h" int handle_diag_288 (CPUS390XState *env,uint64_t r1,uint64_t r3) {
target/s390x/diag.c out: · line 145
Quoted 10 lines
target/s390x/diag.c +7
-0@@ -134,3 +136,54 @@ out:break ; } } + +typedef struct Diag318Data { +uint64_t cpc; +}Diag318Data ; +static Diag318Data diag318data; + +void diag318_reset (void )
please name this function
s390_diag318_reset()
or even (my preference, as we actually reset the CPC value)
s390_cpc_reset()
Quoted 31 lines
target/s390x/diag.c +31
-0+{ +if (s390_has_feat (S390_FEAT_DIAG318 )) { +kvm_s390_set_cpc (0 ); + } +} + +static int diag318_post_load (void *opaque,int version_id) +{ +Diag318Data *d = opaque; + +kvm_s390_set_cpc (d->cpc); +return 0 ; +} + +static int diag318_pre_save (void *opaque) +{ +Diag318Data *d = opaque; + +kvm_s390_get_cpc (&d->cpc); +return 0 ; +} + +static bool diag318_needed (void *opaque) +{ +return s390_has_feat (S390_FEAT_DIAG318 ); +} + +const VMStateDescription vmstate_diag318 = { + .name ="diag318" , + .post_load = diag318_post_load, + .pre_save = diag318_pre_save,
target/s390x/diag.c out: · line 186
Quoted 10 lines
target/s390x/diag.c +10
-0+ .version_id = 1, + .minimum_version_id = 1, + .needed = diag318_needed, + .fields = (VMStateField []) { +VMSTATE_UINT64 (cpc, Diag318Data), +VMSTATE_END_OF_LIST () + } +}; + +void diag318_register (void )
That somehow does not feel right nor look nice.
This code smells like it should go into hw/s390x/ ... as it is a machine specific property. Registering the vmstate can than be done in a nicer way than via this function.
Quoted 109 lines
target/s390x/diag.c +3
-0+{ +vmstate_register (NULL ,0 , &vmstate_diag318, &diag318data); +}target/s390x/gen-features.c +1
-0@@ -450,6 +450,7 @@ static uint16_t full_GEN12_GA1[] = {S390_FEAT_AP_QUERY_CONFIG_INFO ,S390_FEAT_AP_FACILITIES_TEST ,S390_FEAT_AP , + S390_FEAT_DIAG318, }; static uint16_t full_GEN12_GA2[] = {target/s390x/internal.h +3
-1@@ -383,10 +383,12 @@ int mmu_translate_real(CPUS390XState *env, target_ulong raddr, int rw, target_ulong *addr, int *flags); -/* misc_helper.c */ +/* diag.c */ int handle_diag_288 (CPUS390XState *env,uint64_t r1,uint64_t r3);void handle_diag_308 (CPUS390XState *env,uint64_t r1,uint64_t r3,uintptr_t ra); +void diag318_register (void ); +void diag318_reset (void );/* translate.c */ target/s390x/kvm-stub.c +10
-0@@ -104,3 +104,13 @@ void kvm_s390_stop_interrupt(S390CPU *cpu)void kvm_s390_restart_interrupt (S390CPU *cpu) { } + +int kvm_s390_get_cpc (uint64_t *cpc) +{ +return 0 ; +} + +int kvm_s390_set_cpc (uint64_t cpc) +{ +return 0 ; +}target/s390x/kvm.c +23
-0@@ -749,6 +749,28 @@ int kvm_s390_set_clock_ext(uint8_t tod_high, uint64_t tod_low)return kvm_vm_ioctl (kvm_state,KVM_SET_DEVICE_ATTR , &attr); } +int kvm_s390_get_cpc (uint64_t *cpc) +{ +struct kvm_device_attr attr = { + .group =KVM_S390_VM_MISC , + .attr =KVM_S390_VM_MISC_CPC , + .addr = (uint64_t )cpc, + }; + +return kvm_vm_ioctl (kvm_state,KVM_GET_DEVICE_ATTR , &attr); +} + +int kvm_s390_set_cpc (uint64_t cpc) +{ +struct kvm_device_attr attr = { + .group =KVM_S390_VM_MISC , + .attr =KVM_S390_VM_MISC_CPC , + .addr = (uint64_t )&cpc, + }; + +return kvm_vm_ioctl (kvm_state,KVM_SET_DEVICE_ATTR , &attr); +} +/** * kvm_s390_mem_op: * @addr: the logical start address in guest memory @@ -2142,6 +2164,7 @@ static int kvm_to_feat[][2] = { { 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}, + { KVM_S390_VM_CPU_FEAT_DIAG318, S390_FEAT_DIAG318}, };static int query_cpu_feat (S390FeatBitmap features)target/s390x/kvm_s390x.h +3
-0@@ -29,6 +29,9 @@ int kvm_s390_get_clock(uint8_t *tod_high, uint64_t *tod_clock);int kvm_s390_get_clock_ext (uint8_t *tod_high,uint64_t *tod_clock);int kvm_s390_set_clock (uint8_t tod_high,uint64_t tod_clock);int kvm_s390_set_clock_ext (uint8_t tod_high,uint64_t tod_clock); +int kvm_s390_get_cpc (uint64_t *cpc); +int kvm_s390_set_cpc (uint64_t cpc); +bool kvm_s390_has_diag318 (void );void kvm_s390_enable_css_support (S390CPU *cpu);int kvm_s390_assign_subch_ioeventfd (EventNotifier *notifier,uint32_t sch,int vq,bool assign);
Signature · 3 lines
Thanks, David / dhildenb
Quoted 11 lines · David Hildenbrand
Quoted 7 lines · Collin Walling
Add migration and reset support for diagnose 318. This is a new z14 GA2 hardware feature, but we can provide guest support starting with the zEC12-full CPU model.
Because new hardware introduces a new facility-availability byte in the Read SCP Info block, we lose one byte in the CPU entries list and must limit the maximum VCPUs to 247 (down from 248).
This could break setups that upgrade/migrate. At least forward migration can be broken. Do we care about that?
Can we maybe bind this feature and the cpu limit to the 4.0 machine?
Quoted 396 lines
Can you split off
1. linux-header changes
2. CPU model changes? (introduction and definition of new feature, but not when it is used?)Quoted 71 lines
Signed-off-by Collin Walling <[email protected]>---
Changelog
RFC -> v1
- introduced kvm stubs for set/get cpc
- s/fac134/byte_134
- moved diag318 vmstate description todiag.c
- reducedS390_VCPU_MAXto 247hw/s390x/ipl.c | 3 +++ hw/s390x/s390-virtio-ccw.c | 3 +++ hw/s390x/sclp.c | 2 ++ include/hw/s390x/sclp.h | 2 ++ linux-headers/asm-s390/kvm.h | 5 ++++ target/s390x/cpu.h | 2 +- target/s390x/cpu_features.c | 3 +++ target/s390x/cpu_features.h | 1 + target/s390x/cpu_features_def.h | 3 +++ target/s390x/diag.c | 53 +++++++++++++++++++++++++++++++++++++++++ target/s390x/gen-features.c | 1 + target/s390x/internal.h | 4 +++- target/s390x/kvm-stub.c | 10 ++++++++ target/s390x/kvm.c | 23 ++++++++++++++++++ target/s390x/kvm_s390x.h | 3 +++ 15 files changed, 116 insertions(+), 2 deletions(-)hw/s390x/ipl.c +3
-0@@ -27,6 +27,7 @@#include "qemu/cutils.h" #include "qemu/option.h" #include "exec/exec-all.h" +#include "internal.h" #define KERN_IMAGE_START 0x010000UL#define LINUX_MAGIC_ADDR 0x010008UL@@ -230,6 +231,8 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp) ipl->compat_start_addr = ipl->start_addr; ipl->compat_bios_start_addr = ipl->bios_start_addr;qemu_register_reset (qdev_reset_all_fn, dev); + +diag318_register (); error:error_propagate (errp, err); }hw/s390x/s390-virtio-ccw.c +2
-0@@ -37,6 +37,7 @@#include "cpu_models.h" #include "hw/nmi.h" #include "hw/s390x/tod.h" +#include "internal.h" S390CPU *s390_cpu_addr2state (uint16_t cpu_addr) {@@ -357,6 +358,7 @@ static void s390_machine_reset(void) }subsystem_reset ();s390_crypto_reset (); +diag318_reset ();run_on_cpu (cs, s390_do_cpu_load_normal,RUN_ON_CPU_NULL );break ;case S390_RESET_LOAD_NORMAL :hw/s390x/s390-virtio-ccw.c static void s390_machine_reset(void) · line 372
Quoted 7 lines
hw/s390x/s390-virtio-ccw.c +1
-0@@ -364,6 +366,7 @@ static void s390_machine_reset(void)run_on_cpu (t, s390_do_cpu_reset,RUN_ON_CPU_NULL ); }subsystem_reset (); +diag318_reset ();run_on_cpu (cs, s390_do_cpu_initial_reset,RUN_ON_CPU_NULL );run_on_cpu (cs, s390_do_cpu_load_normal,RUN_ON_CPU_NULL );break ;Why don't we have to reset this during reipl or external reset ("
system_reset")?Quoted 74 lines
hw/s390x/sclp.c +2
-0@@ -73,6 +73,8 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) read_info->conf_char);s390_get_feat_block (S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT , read_info->conf_char_ext); +/* Read Info byte 134 */ +s390_get_feat_block (S390_FEAT_TYPE_SCLP_BYTE_134 , read_info->byte_134); read_info->facilities =cpu_to_be64 (SCLP_HAS_CPU_INFO |SCLP_HAS_IOA_RECONFIG );include/hw/s390x/sclp.h +2
-0@@ -133,6 +133,8 @@ typedef struct ReadInfo {uint16_t highest_cpu;uint8_t _reserved5[124 -122 ];/* 122-123 */ uint32_t hmfai; +uint8_t _reserved7[134 -128 ];/* 128-133 */ +uint8_t byte_134[1 ];struct CPUEntry entries[0 ]; }QEMU_PACKED ReadInfo;linux-headers/asm-s390/kvm.h +5
-0@@ -74,6 +74,7 @@ struct kvm_s390_io_adapter_req {#define KVM_S390_VM_CRYPTO 2#define KVM_S390_VM_CPU_MODEL 3#define KVM_S390_VM_MIGRATION 4 +#define KVM_S390_VM_MISC 5/* kvm attributes for mem_ctrl */ #define KVM_S390_VM_MEM_ENABLE_CMMA 0@@ -130,6 +131,7 @@ struct kvm_s390_vm_cpu_machine {#define KVM_S390_VM_CPU_FEAT_PFMFI 11#define KVM_S390_VM_CPU_FEAT_SIGPIF 12#define KVM_S390_VM_CPU_FEAT_KSS 13 +#define KVM_S390_VM_CPU_FEAT_DIAG318 14struct kvm_s390_vm_cpu_feat {__u64 feat[16 ]; };@@ -168,6 +170,9 @@ struct kvm_s390_vm_cpu_subfunc {#define KVM_S390_VM_MIGRATION_START 1#define KVM_S390_VM_MIGRATION_STATUS 2 +/* kvm attributes for KVM_S390_VM_MISC */ +#define KVM_S390_VM_MISC_CPC 0 +/* for KVM_GET_REGS and KVM_SET_REGS */ struct kvm_regs {/* general purpose regs for s390 */ target/s390x/cpu.h +1
-1@@ -52,7 +52,7 @@#define MMU_USER_IDX 0 -#define S390_MAX_CPUS 248 +#define S390_MAX_CPUS 247 typedef struct PSW { uint64_t mask;target/s390x/cpu_features.c +0
-0target/s390x/cpu_features.c static const S390FeatDef s390_features[] = { · line 125
Quoted 5 lines
target/s390x/cpu_features.c +2
-0@@ -121,6 +121,9 @@ static const S390FeatDef s390_features[] = {FEAT_INIT ("pfmfi" ,S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT ,9 ,"SIE: PFMF interpretation facility" ),FEAT_INIT ("ibs" ,S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT ,10 ,"SIE: Interlock-and-broadcast-suppression facility" ), +/* SCLP SCCB Byte 134 */ + FEAT_INIT("diag318", S390_FEAT_TYPE_SCLP_BYTE_134, 0, "SIE: Diagnose 318"),Is this bit "SIE: Diagnose 318" or "SIE: SCLP Byte 14" ?
Or both?
Quoted 44 lines
target/s390x/cpu_features.c +1
-0+FEAT_INIT ("sief2" ,S390_FEAT_TYPE_SCLP_CPU ,4 ,"SIE: interception format 2 (Virtual SIE)" ),FEAT_INIT ("skey" ,S390_FEAT_TYPE_SCLP_CPU ,5 ,"SIE: Storage-key facility" ), FEAT_INIT("gpereh", S390_FEAT_TYPE_SCLP_CPU, 10, "SIE: Guest-PER enhancement facility"),target/s390x/cpu_features.h +1
-0@@ -23,6 +23,7 @@ typedef enum {S390_FEAT_TYPE_STFL ,S390_FEAT_TYPE_SCLP_CONF_CHAR ,S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT , +S390_FEAT_TYPE_SCLP_BYTE_134 ,S390_FEAT_TYPE_SCLP_CPU ,S390_FEAT_TYPE_MISC , S390_FEAT_TYPE_PLO,target/s390x/cpu_features_def.h +3
-0@@ -109,6 +109,9 @@ typedef enum {S390_FEAT_SIE_PFMFI ,S390_FEAT_SIE_IBS , +/* Read Info Byte 134 */ +S390_FEAT_DIAG318 , +/* Sclp Cpu */ S390_FEAT_SIE_F2 , S390_FEAT_SIE_SKEY,target/s390x/diag.c +2
-0@@ -20,6 +20,8 @@#include "sysemu/cpus.h" #include "hw/s390x/ipl.h" #include "hw/s390x/s390-virtio-ccw.h" +#include "kvm_s390x.h" +#include "sysemu/kvm.h" int handle_diag_288 (CPUS390XState *env,uint64_t r1,uint64_t r3) {target/s390x/diag.c out: · line 145
Quoted 10 lines
target/s390x/diag.c +7
-0@@ -134,3 +136,54 @@ out:break ; } } + +typedef struct Diag318Data { +uint64_t cpc; +}Diag318Data ; +static Diag318Data diag318data; + +void diag318_reset (void )please name this function
s390_diag318_reset()or even (my preference, as we actually reset the CPC value)
s390_cpc_reset()Quoted 31 lines
target/s390x/diag.c +31
-0+{ +if (s390_has_feat (S390_FEAT_DIAG318 )) { +kvm_s390_set_cpc (0 ); + } +} + +static int diag318_post_load (void *opaque,int version_id) +{ +Diag318Data *d = opaque; + +kvm_s390_set_cpc (d->cpc); +return 0 ; +} + +static int diag318_pre_save (void *opaque) +{ +Diag318Data *d = opaque; + +kvm_s390_get_cpc (&d->cpc); +return 0 ; +} + +static bool diag318_needed (void *opaque) +{ +return s390_has_feat (S390_FEAT_DIAG318 ); +} + +const VMStateDescription vmstate_diag318 = { + .name ="diag318" , + .post_load = diag318_post_load, + .pre_save = diag318_pre_save,target/s390x/diag.c out: · line 186
Quoted 10 lines
target/s390x/diag.c +10
-0+ .version_id = 1, + .minimum_version_id = 1, + .needed = diag318_needed, + .fields = (VMStateField []) { +VMSTATE_UINT64 (cpc, Diag318Data), +VMSTATE_END_OF_LIST () + } +}; + +void diag318_register (void )That somehow does not feel right nor look nice.
This code smells like it should go into hw/s390x/ ... as it is a machine specific property. Registering the vmstate can than be done in a nicer way than via this function.
Quoted 109 lines
target/s390x/diag.c +3
-0+{ +vmstate_register (NULL ,0 , &vmstate_diag318, &diag318data); +}target/s390x/gen-features.c +1
-0@@ -450,6 +450,7 @@ static uint16_t full_GEN12_GA1[] = {S390_FEAT_AP_QUERY_CONFIG_INFO ,S390_FEAT_AP_FACILITIES_TEST ,S390_FEAT_AP , + S390_FEAT_DIAG318, }; static uint16_t full_GEN12_GA2[] = {target/s390x/internal.h +3
-1@@ -383,10 +383,12 @@ int mmu_translate_real(CPUS390XState *env, target_ulong raddr, int rw, target_ulong *addr, int *flags); -/* misc_helper.c */ +/* diag.c */ int handle_diag_288 (CPUS390XState *env,uint64_t r1,uint64_t r3);void handle_diag_308 (CPUS390XState *env,uint64_t r1,uint64_t r3,uintptr_t ra); +void diag318_register (void ); +void diag318_reset (void );/* translate.c */ target/s390x/kvm-stub.c +10
-0@@ -104,3 +104,13 @@ void kvm_s390_stop_interrupt(S390CPU *cpu)void kvm_s390_restart_interrupt (S390CPU *cpu) { } + +int kvm_s390_get_cpc (uint64_t *cpc) +{ +return 0 ; +} + +int kvm_s390_set_cpc (uint64_t cpc) +{ +return 0 ; +}target/s390x/kvm.c +23
-0@@ -749,6 +749,28 @@ int kvm_s390_set_clock_ext(uint8_t tod_high, uint64_t tod_low)return kvm_vm_ioctl (kvm_state,KVM_SET_DEVICE_ATTR , &attr); } +int kvm_s390_get_cpc (uint64_t *cpc) +{ +struct kvm_device_attr attr = { + .group =KVM_S390_VM_MISC , + .attr =KVM_S390_VM_MISC_CPC , + .addr = (uint64_t )cpc, + }; + +return kvm_vm_ioctl (kvm_state,KVM_GET_DEVICE_ATTR , &attr); +} + +int kvm_s390_set_cpc (uint64_t cpc) +{ +struct kvm_device_attr attr = { + .group =KVM_S390_VM_MISC , + .attr =KVM_S390_VM_MISC_CPC , + .addr = (uint64_t )&cpc, + }; + +return kvm_vm_ioctl (kvm_state,KVM_SET_DEVICE_ATTR , &attr); +} +/** * kvm_s390_mem_op: * @addr: the logical start address in guest memory @@ -2142,6 +2164,7 @@ static int kvm_to_feat[][2] = { { 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}, + { KVM_S390_VM_CPU_FEAT_DIAG318, S390_FEAT_DIAG318}, };static int query_cpu_feat (S390FeatBitmap features)target/s390x/kvm_s390x.h +3
-0@@ -29,6 +29,9 @@ int kvm_s390_get_clock(uint8_t *tod_high, uint64_t *tod_clock);int kvm_s390_get_clock_ext (uint8_t *tod_high,uint64_t *tod_clock);int kvm_s390_set_clock (uint8_t tod_high,uint64_t tod_clock);int kvm_s390_set_clock_ext (uint8_t tod_high,uint64_t tod_clock); +int kvm_s390_get_cpc (uint64_t *cpc); +int kvm_s390_set_cpc (uint64_t cpc); +bool kvm_s390_has_diag318 (void );void kvm_s390_enable_css_support (S390CPU *cpu);int kvm_s390_assign_subch_ioeventfd (EventNotifier *notifier,uint32_t sch,int vq,bool assign);
Quoted 6 lines · On Wed, 5 Dec 2018 09:27:44 +0100 Christian Borntraeger…
Quoted 5 lines · David Hildenbrand
Quoted 4 lines · Collin Walling
Add migration and reset support for diagnose 318. This is a new z14 GA2 hardware feature, but we can provide guest support starting with the zEC12-full CPU model.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Because new hardware introduces a new facility-availability byte in the Read SCP Info block, we lose one byte in the CPU entries list and must limit the maximum VCPUs to 247 (down from 248).
This could break setups that upgrade/migrate. At least forward migration can be broken. Do we care about that?
Can we maybe bind this feature and the cpu limit to the 4.0 machine?
I think that would make sense.
Quoted 10 lines
Quoted 10 lines
Can you split off
1. linux-header changes
2. CPU model changes? (introduction and definition of new feature, but not when it is used?)Quoted 3 lines
Signed-off-by Collin Walling <[email protected]>---
Quoted 13 lines · Cornelia Huck
Quoted 10 lines · On Wed, 5 Dec 2018 09:27:44 +0100 Christian Borntraeger…
Quoted 9 lines · David Hildenbrand
Quoted 7 lines · Collin Walling
Add migration and reset support for diagnose 318. This is a new z14 GA2 hardware feature, but we can provide guest support starting with the zEC12-full CPU model.
Because new hardware introduces a new facility-availability byte in the Read SCP Info block, we lose one byte in the CPU entries list and must limit the maximum VCPUs to 247 (down from 248).
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
This could break setups that upgrade/migrate. At least forward migration can be broken. Do we care about that?
Can we maybe bind this feature and the cpu limit to the 4.0 machine?
I think that would make sense.
Won't be that easy, as we'll have different sizes of the struct size. Something that might uglify the code quite a bit.
Also we'll get a dependence between the cpu model features (e.g. probed via the NULL machine) and the compat machine. Have to think about this.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Can you split off
1. linux-header changes
2. CPU model changes? (introduction and definition of new feature, but not when it is used?)Quoted 3 lines
Signed-off-by Collin Walling <[email protected]>---
Signature · 3 lines
Thanks, David / dhildenb
Quoted 19 lines · David Hildenbrand
Quoted 18 lines · Cornelia Huck
Quoted 14 lines · On Wed, 5 Dec 2018 09:27:44 +0100 Christian Borntraeger…
Quoted 11 lines · David Hildenbrand
Quoted 7 lines · Collin Walling
Add migration and reset support for diagnose 318. This is a new z14 GA2 hardware feature, but we can provide guest support starting with the zEC12-full CPU model.
Because new hardware introduces a new facility-availability byte in the Read SCP Info block, we lose one byte in the CPU entries list and must limit the maximum VCPUs to 247 (down from 248).
This could break setups that upgrade/migrate. At least forward migration can be broken. Do we care about that?
Can we maybe bind this feature and the cpu limit to the 4.0 machine?
Quoted 8 lines
Quoted 1 line
I think that would make sense.
Won't be that easy, as we'll have different sizes of the struct size. Something that might uglify the code quite a bit.
Also we'll get a dependence between the cpu model features (e.g. probed via the NULL machine) and the compat machine. Have to think about this.
Are you referring to the struct CPUS390XState? Could we get away by adding a one-byte "unused" field after the bitmap?
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Can you split off
Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
1. linux-header changes
2. CPU model changes? (introduction and definition of new feature, but not when it is used?)Quoted 3 lines
Signed-off-by Collin Walling <[email protected]>---
I'll split the patches into:
1) linux-header changes
2) CPU model changes
3) diag318 usages / migration
Signature · 2 lines
Respectfully, - Collin Walling
You should clearly review your email list.....
Adding the "new" Conny, removing Carsten.
Quoted 368 lines · Collin Walling
Add migration and reset support for diagnose 318. This is a new z14 GA2 hardware feature, but we can provide guest support starting with the zEC12-full CPU model.
Because new hardware introduces a new facility-availability byte in the Read SCP Info block, we lose one byte in the CPU entries list and must limit the maximum VCPUs to 247 (down from 248).
Signed-off-by Collin Walling <[email protected]>---
Changelog
RFC -> v1
- introduced kvm stubs for set/get cpc
- s/fac134/byte_134
- moved diag318 vmstate description todiag.c
- reducedS390_VCPU_MAXto 247hw/s390x/ipl.c | 3 +++ hw/s390x/s390-virtio-ccw.c | 3 +++ hw/s390x/sclp.c | 2 ++ include/hw/s390x/sclp.h | 2 ++ linux-headers/asm-s390/kvm.h | 5 ++++ target/s390x/cpu.h | 2 +- target/s390x/cpu_features.c | 3 +++ target/s390x/cpu_features.h | 1 + target/s390x/cpu_features_def.h | 3 +++ target/s390x/diag.c | 53 +++++++++++++++++++++++++++++++++++++++++ target/s390x/gen-features.c | 1 + target/s390x/internal.h | 4 +++- target/s390x/kvm-stub.c | 10 ++++++++ target/s390x/kvm.c | 23 ++++++++++++++++++ target/s390x/kvm_s390x.h | 3 +++ 15 files changed, 116 insertions(+), 2 deletions(-)hw/s390x/ipl.c +3
-0@@ -27,6 +27,7 @@#include "qemu/cutils.h" #include "qemu/option.h" #include "exec/exec-all.h" +#include "internal.h" #define KERN_IMAGE_START 0x010000UL#define LINUX_MAGIC_ADDR 0x010008UL@@ -230,6 +231,8 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp) ipl->compat_start_addr = ipl->start_addr; ipl->compat_bios_start_addr = ipl->bios_start_addr;qemu_register_reset (qdev_reset_all_fn, dev); + +diag318_register (); error:error_propagate (errp, err); }hw/s390x/s390-virtio-ccw.c +3
-0@@ -37,6 +37,7 @@#include "cpu_models.h" #include "hw/nmi.h" #include "hw/s390x/tod.h" +#include "internal.h" S390CPU *s390_cpu_addr2state (uint16_t cpu_addr) {@@ -357,6 +358,7 @@ static void s390_machine_reset(void) }subsystem_reset ();s390_crypto_reset (); +diag318_reset ();run_on_cpu (cs, s390_do_cpu_load_normal,RUN_ON_CPU_NULL );break ;case S390_RESET_LOAD_NORMAL :@@ -364,6 +366,7 @@ static void s390_machine_reset(void)run_on_cpu (t, s390_do_cpu_reset,RUN_ON_CPU_NULL ); }subsystem_reset (); +diag318_reset ();run_on_cpu (cs, s390_do_cpu_initial_reset,RUN_ON_CPU_NULL );run_on_cpu (cs, s390_do_cpu_load_normal,RUN_ON_CPU_NULL );break ;hw/s390x/sclp.c +2
-0@@ -73,6 +73,8 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) read_info->conf_char);s390_get_feat_block (S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT , read_info->conf_char_ext); +/* Read Info byte 134 */ +s390_get_feat_block (S390_FEAT_TYPE_SCLP_BYTE_134 , read_info->byte_134); read_info->facilities =cpu_to_be64 (SCLP_HAS_CPU_INFO |SCLP_HAS_IOA_RECONFIG );include/hw/s390x/sclp.h +2
-0@@ -133,6 +133,8 @@ typedef struct ReadInfo {uint16_t highest_cpu;uint8_t _reserved5[124 -122 ];/* 122-123 */ uint32_t hmfai; +uint8_t _reserved7[134 -128 ];/* 128-133 */ +uint8_t byte_134[1 ];struct CPUEntry entries[0 ]; }QEMU_PACKED ReadInfo;linux-headers/asm-s390/kvm.h +5
-0@@ -74,6 +74,7 @@ struct kvm_s390_io_adapter_req {#define KVM_S390_VM_CRYPTO 2#define KVM_S390_VM_CPU_MODEL 3#define KVM_S390_VM_MIGRATION 4 +#define KVM_S390_VM_MISC 5/* kvm attributes for mem_ctrl */ #define KVM_S390_VM_MEM_ENABLE_CMMA 0@@ -130,6 +131,7 @@ struct kvm_s390_vm_cpu_machine {#define KVM_S390_VM_CPU_FEAT_PFMFI 11#define KVM_S390_VM_CPU_FEAT_SIGPIF 12#define KVM_S390_VM_CPU_FEAT_KSS 13 +#define KVM_S390_VM_CPU_FEAT_DIAG318 14struct kvm_s390_vm_cpu_feat {__u64 feat[16 ]; };@@ -168,6 +170,9 @@ struct kvm_s390_vm_cpu_subfunc {#define KVM_S390_VM_MIGRATION_START 1#define KVM_S390_VM_MIGRATION_STATUS 2 +/* kvm attributes for KVM_S390_VM_MISC */ +#define KVM_S390_VM_MISC_CPC 0 +/* for KVM_GET_REGS and KVM_SET_REGS */ struct kvm_regs {/* general purpose regs for s390 */ target/s390x/cpu.h +1
-1@@ -52,7 +52,7 @@#define MMU_USER_IDX 0 -#define S390_MAX_CPUS 248 +#define S390_MAX_CPUS 247 typedef struct PSW { uint64_t mask;target/s390x/cpu_features.c +3
-0@@ -121,6 +121,9 @@ static const S390FeatDef s390_features[] = {FEAT_INIT ("pfmfi" ,S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT ,9 ,"SIE: PFMF interpretation facility" ),FEAT_INIT ("ibs" ,S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT ,10 ,"SIE: Interlock-and-broadcast-suppression facility" ), +/* SCLP SCCB Byte 134 */ +FEAT_INIT ("diag318" ,S390_FEAT_TYPE_SCLP_BYTE_134 ,0 ,"SIE: Diagnose 318" ), +FEAT_INIT ("sief2" ,S390_FEAT_TYPE_SCLP_CPU ,4 ,"SIE: interception format 2 (Virtual SIE)" ),FEAT_INIT ("skey" ,S390_FEAT_TYPE_SCLP_CPU ,5 ,"SIE: Storage-key facility" ), FEAT_INIT("gpereh", S390_FEAT_TYPE_SCLP_CPU, 10, "SIE: Guest-PER enhancement facility"),target/s390x/cpu_features.h +1
-0@@ -23,6 +23,7 @@ typedef enum {S390_FEAT_TYPE_STFL ,S390_FEAT_TYPE_SCLP_CONF_CHAR ,S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT , +S390_FEAT_TYPE_SCLP_BYTE_134 ,S390_FEAT_TYPE_SCLP_CPU ,S390_FEAT_TYPE_MISC , S390_FEAT_TYPE_PLO,target/s390x/cpu_features_def.h +3
-0@@ -109,6 +109,9 @@ typedef enum {S390_FEAT_SIE_PFMFI ,S390_FEAT_SIE_IBS , +/* Read Info Byte 134 */ +S390_FEAT_DIAG318 , +/* Sclp Cpu */ S390_FEAT_SIE_F2 , S390_FEAT_SIE_SKEY,target/s390x/diag.c +53
-0@@ -20,6 +20,8 @@#include "sysemu/cpus.h" #include "hw/s390x/ipl.h" #include "hw/s390x/s390-virtio-ccw.h" +#include "kvm_s390x.h" +#include "sysemu/kvm.h" int handle_diag_288 (CPUS390XState *env,uint64_t r1,uint64_t r3) {@@ -134,3 +136,54 @@ out:break ; } } + +typedef struct Diag318Data { +uint64_t cpc; +}Diag318Data ; +static Diag318Data diag318data; + +void diag318_reset (void ) +{ +if (s390_has_feat (S390_FEAT_DIAG318 )) { +kvm_s390_set_cpc (0 ); + } +} + +static int diag318_post_load (void *opaque,int version_id) +{ +Diag318Data *d = opaque; + +kvm_s390_set_cpc (d->cpc); +return 0 ; +} + +static int diag318_pre_save (void *opaque) +{ +Diag318Data *d = opaque; + +kvm_s390_get_cpc (&d->cpc); +return 0 ; +} + +static bool diag318_needed (void *opaque) +{ +return s390_has_feat (S390_FEAT_DIAG318 ); +} + +const VMStateDescription vmstate_diag318 = { + .name ="diag318" , + .post_load = diag318_post_load, + .pre_save = diag318_pre_save, + .version_id =1 , + .minimum_version_id =1 , + .needed = diag318_needed, + .fields = (VMStateField []) { +VMSTATE_UINT64 (cpc, Diag318Data), +VMSTATE_END_OF_LIST () + } +}; + +void diag318_register (void ) +{ +vmstate_register (NULL ,0 , &vmstate_diag318, &diag318data); +}target/s390x/gen-features.c +1
-0@@ -450,6 +450,7 @@ static uint16_t full_GEN12_GA1[] = {S390_FEAT_AP_QUERY_CONFIG_INFO ,S390_FEAT_AP_FACILITIES_TEST ,S390_FEAT_AP , + S390_FEAT_DIAG318, }; static uint16_t full_GEN12_GA2[] = {target/s390x/internal.h +3
-1@@ -383,10 +383,12 @@ int mmu_translate_real(CPUS390XState *env, target_ulong raddr, int rw, target_ulong *addr, int *flags); -/* misc_helper.c */ +/* diag.c */ int handle_diag_288 (CPUS390XState *env,uint64_t r1,uint64_t r3);void handle_diag_308 (CPUS390XState *env,uint64_t r1,uint64_t r3,uintptr_t ra); +void diag318_register (void ); +void diag318_reset (void );/* translate.c */ target/s390x/kvm-stub.c +10
-0@@ -104,3 +104,13 @@ void kvm_s390_stop_interrupt(S390CPU *cpu)void kvm_s390_restart_interrupt (S390CPU *cpu) { } + +int kvm_s390_get_cpc (uint64_t *cpc) +{ +return 0 ; +} + +int kvm_s390_set_cpc (uint64_t cpc) +{ +return 0 ; +}target/s390x/kvm.c +23
-0@@ -749,6 +749,28 @@ int kvm_s390_set_clock_ext(uint8_t tod_high, uint64_t tod_low)return kvm_vm_ioctl (kvm_state,KVM_SET_DEVICE_ATTR , &attr); } +int kvm_s390_get_cpc (uint64_t *cpc) +{ +struct kvm_device_attr attr = { + .group =KVM_S390_VM_MISC , + .attr =KVM_S390_VM_MISC_CPC , + .addr = (uint64_t )cpc, + }; + +return kvm_vm_ioctl (kvm_state,KVM_GET_DEVICE_ATTR , &attr); +} + +int kvm_s390_set_cpc (uint64_t cpc) +{ +struct kvm_device_attr attr = { + .group =KVM_S390_VM_MISC , + .attr =KVM_S390_VM_MISC_CPC , + .addr = (uint64_t )&cpc, + }; + +return kvm_vm_ioctl (kvm_state,KVM_SET_DEVICE_ATTR , &attr); +} +/** * kvm_s390_mem_op: * @addr: the logical start address in guest memory @@ -2142,6 +2164,7 @@ static int kvm_to_feat[][2] = { { 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}, + { KVM_S390_VM_CPU_FEAT_DIAG318, S390_FEAT_DIAG318}, };static int query_cpu_feat (S390FeatBitmap features)target/s390x/kvm_s390x.h +3
-0@@ -29,6 +29,9 @@ int kvm_s390_get_clock(uint8_t *tod_high, uint64_t *tod_clock);int kvm_s390_get_clock_ext (uint8_t *tod_high,uint64_t *tod_clock);int kvm_s390_set_clock (uint8_t tod_high,uint64_t tod_clock);int kvm_s390_set_clock_ext (uint8_t tod_high,uint64_t tod_clock); +int kvm_s390_get_cpc (uint64_t *cpc); +int kvm_s390_set_cpc (uint64_t cpc); +bool kvm_s390_has_diag318 (void );void kvm_s390_enable_css_support (S390CPU *cpu);int kvm_s390_assign_subch_ioeventfd (EventNotifier *notifier,uint32_t sch,int vq,bool assign);
Quoted 4 lines · Christian Borntraeger
You should clearly review your email list.....
Adding the "new" Conny, removing Carsten.
Thanks for taking care of that. I'll be more careful when using the addresses at the top of the files.
Quoted 372 lines · Collin Walling
Quoted 368 lines
Add migration and reset support for diagnose 318. This is a new z14 GA2 hardware feature, but we can provide guest support starting with the zEC12-full CPU model.
Because new hardware introduces a new facility-availability byte in the Read SCP Info block, we lose one byte in the CPU entries list and must limit the maximum VCPUs to 247 (down from 248).
Signed-off-by Collin Walling <[email protected]>---
Changelog
RFC -> v1
- introduced kvm stubs for set/get cpc
- s/fac134/byte_134
- moved diag318 vmstate description todiag.c
- reducedS390_VCPU_MAXto 247hw/s390x/ipl.c | 3 +++ hw/s390x/s390-virtio-ccw.c | 3 +++ hw/s390x/sclp.c | 2 ++ include/hw/s390x/sclp.h | 2 ++ linux-headers/asm-s390/kvm.h | 5 ++++ target/s390x/cpu.h | 2 +- target/s390x/cpu_features.c | 3 +++ target/s390x/cpu_features.h | 1 + target/s390x/cpu_features_def.h | 3 +++ target/s390x/diag.c | 53 +++++++++++++++++++++++++++++++++++++++++ target/s390x/gen-features.c | 1 + target/s390x/internal.h | 4 +++- target/s390x/kvm-stub.c | 10 ++++++++ target/s390x/kvm.c | 23 ++++++++++++++++++ target/s390x/kvm_s390x.h | 3 +++ 15 files changed, 116 insertions(+), 2 deletions(-)hw/s390x/ipl.c +3
-0@@ -27,6 +27,7 @@#include "qemu/cutils.h" #include "qemu/option.h" #include "exec/exec-all.h" +#include "internal.h" #define KERN_IMAGE_START 0x010000UL#define LINUX_MAGIC_ADDR 0x010008UL@@ -230,6 +231,8 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp) ipl->compat_start_addr = ipl->start_addr; ipl->compat_bios_start_addr = ipl->bios_start_addr;qemu_register_reset (qdev_reset_all_fn, dev); + +diag318_register (); error:error_propagate (errp, err); }hw/s390x/s390-virtio-ccw.c +3
-0@@ -37,6 +37,7 @@#include "cpu_models.h" #include "hw/nmi.h" #include "hw/s390x/tod.h" +#include "internal.h" S390CPU *s390_cpu_addr2state (uint16_t cpu_addr) {@@ -357,6 +358,7 @@ static void s390_machine_reset(void) }subsystem_reset ();s390_crypto_reset (); +diag318_reset ();run_on_cpu (cs, s390_do_cpu_load_normal,RUN_ON_CPU_NULL );break ;case S390_RESET_LOAD_NORMAL :@@ -364,6 +366,7 @@ static void s390_machine_reset(void)run_on_cpu (t, s390_do_cpu_reset,RUN_ON_CPU_NULL ); }subsystem_reset (); +diag318_reset ();run_on_cpu (cs, s390_do_cpu_initial_reset,RUN_ON_CPU_NULL );run_on_cpu (cs, s390_do_cpu_load_normal,RUN_ON_CPU_NULL );break ;hw/s390x/sclp.c +2
-0@@ -73,6 +73,8 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) read_info->conf_char);s390_get_feat_block (S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT , read_info->conf_char_ext); +/* Read Info byte 134 */ +s390_get_feat_block (S390_FEAT_TYPE_SCLP_BYTE_134 , read_info->byte_134); read_info->facilities =cpu_to_be64 (SCLP_HAS_CPU_INFO |SCLP_HAS_IOA_RECONFIG );include/hw/s390x/sclp.h +2
-0@@ -133,6 +133,8 @@ typedef struct ReadInfo {uint16_t highest_cpu;uint8_t _reserved5[124 -122 ];/* 122-123 */ uint32_t hmfai; +uint8_t _reserved7[134 -128 ];/* 128-133 */ +uint8_t byte_134[1 ];struct CPUEntry entries[0 ]; }QEMU_PACKED ReadInfo;linux-headers/asm-s390/kvm.h +5
-0@@ -74,6 +74,7 @@ struct kvm_s390_io_adapter_req {#define KVM_S390_VM_CRYPTO 2#define KVM_S390_VM_CPU_MODEL 3#define KVM_S390_VM_MIGRATION 4 +#define KVM_S390_VM_MISC 5/* kvm attributes for mem_ctrl */ #define KVM_S390_VM_MEM_ENABLE_CMMA 0@@ -130,6 +131,7 @@ struct kvm_s390_vm_cpu_machine {#define KVM_S390_VM_CPU_FEAT_PFMFI 11#define KVM_S390_VM_CPU_FEAT_SIGPIF 12#define KVM_S390_VM_CPU_FEAT_KSS 13 +#define KVM_S390_VM_CPU_FEAT_DIAG318 14struct kvm_s390_vm_cpu_feat {__u64 feat[16 ]; };@@ -168,6 +170,9 @@ struct kvm_s390_vm_cpu_subfunc {#define KVM_S390_VM_MIGRATION_START 1#define KVM_S390_VM_MIGRATION_STATUS 2 +/* kvm attributes for KVM_S390_VM_MISC */ +#define KVM_S390_VM_MISC_CPC 0 +/* for KVM_GET_REGS and KVM_SET_REGS */ struct kvm_regs {/* general purpose regs for s390 */ target/s390x/cpu.h +1
-1@@ -52,7 +52,7 @@#define MMU_USER_IDX 0 -#define S390_MAX_CPUS 248 +#define S390_MAX_CPUS 247 typedef struct PSW { uint64_t mask;target/s390x/cpu_features.c +3
-0@@ -121,6 +121,9 @@ static const S390FeatDef s390_features[] = {FEAT_INIT ("pfmfi" ,S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT ,9 ,"SIE: PFMF interpretation facility" ),FEAT_INIT ("ibs" ,S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT ,10 ,"SIE: Interlock-and-broadcast-suppression facility" ), +/* SCLP SCCB Byte 134 */ +FEAT_INIT ("diag318" ,S390_FEAT_TYPE_SCLP_BYTE_134 ,0 ,"SIE: Diagnose 318" ), +FEAT_INIT ("sief2" ,S390_FEAT_TYPE_SCLP_CPU ,4 ,"SIE: interception format 2 (Virtual SIE)" ),FEAT_INIT ("skey" ,S390_FEAT_TYPE_SCLP_CPU ,5 ,"SIE: Storage-key facility" ), FEAT_INIT("gpereh", S390_FEAT_TYPE_SCLP_CPU, 10, "SIE: Guest-PER enhancement facility"),target/s390x/cpu_features.h +1
-0@@ -23,6 +23,7 @@ typedef enum {S390_FEAT_TYPE_STFL ,S390_FEAT_TYPE_SCLP_CONF_CHAR ,S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT , +S390_FEAT_TYPE_SCLP_BYTE_134 ,S390_FEAT_TYPE_SCLP_CPU ,S390_FEAT_TYPE_MISC , S390_FEAT_TYPE_PLO,target/s390x/cpu_features_def.h +3
-0@@ -109,6 +109,9 @@ typedef enum {S390_FEAT_SIE_PFMFI ,S390_FEAT_SIE_IBS , +/* Read Info Byte 134 */ +S390_FEAT_DIAG318 , +/* Sclp Cpu */ S390_FEAT_SIE_F2 , S390_FEAT_SIE_SKEY,target/s390x/diag.c +53
-0@@ -20,6 +20,8 @@#include "sysemu/cpus.h" #include "hw/s390x/ipl.h" #include "hw/s390x/s390-virtio-ccw.h" +#include "kvm_s390x.h" +#include "sysemu/kvm.h" int handle_diag_288 (CPUS390XState *env,uint64_t r1,uint64_t r3) {@@ -134,3 +136,54 @@ out:break ; } } + +typedef struct Diag318Data { +uint64_t cpc; +}Diag318Data ; +static Diag318Data diag318data; + +void diag318_reset (void ) +{ +if (s390_has_feat (S390_FEAT_DIAG318 )) { +kvm_s390_set_cpc (0 ); + } +} + +static int diag318_post_load (void *opaque,int version_id) +{ +Diag318Data *d = opaque; + +kvm_s390_set_cpc (d->cpc); +return 0 ; +} + +static int diag318_pre_save (void *opaque) +{ +Diag318Data *d = opaque; + +kvm_s390_get_cpc (&d->cpc); +return 0 ; +} + +static bool diag318_needed (void *opaque) +{ +return s390_has_feat (S390_FEAT_DIAG318 ); +} + +const VMStateDescription vmstate_diag318 = { + .name ="diag318" , + .post_load = diag318_post_load, + .pre_save = diag318_pre_save, + .version_id =1 , + .minimum_version_id =1 , + .needed = diag318_needed, + .fields = (VMStateField []) { +VMSTATE_UINT64 (cpc, Diag318Data), +VMSTATE_END_OF_LIST () + } +}; + +void diag318_register (void ) +{ +vmstate_register (NULL ,0 , &vmstate_diag318, &diag318data); +}target/s390x/gen-features.c +1
-0@@ -450,6 +450,7 @@ static uint16_t full_GEN12_GA1[] = {S390_FEAT_AP_QUERY_CONFIG_INFO ,S390_FEAT_AP_FACILITIES_TEST ,S390_FEAT_AP , + S390_FEAT_DIAG318, }; static uint16_t full_GEN12_GA2[] = {target/s390x/internal.h +3
-1@@ -383,10 +383,12 @@ int mmu_translate_real(CPUS390XState *env, target_ulong raddr, int rw, target_ulong *addr, int *flags); -/* misc_helper.c */ +/* diag.c */ int handle_diag_288 (CPUS390XState *env,uint64_t r1,uint64_t r3);void handle_diag_308 (CPUS390XState *env,uint64_t r1,uint64_t r3,uintptr_t ra); +void diag318_register (void ); +void diag318_reset (void );/* translate.c */ target/s390x/kvm-stub.c +10
-0@@ -104,3 +104,13 @@ void kvm_s390_stop_interrupt(S390CPU *cpu)void kvm_s390_restart_interrupt (S390CPU *cpu) { } + +int kvm_s390_get_cpc (uint64_t *cpc) +{ +return 0 ; +} + +int kvm_s390_set_cpc (uint64_t cpc) +{ +return 0 ; +}target/s390x/kvm.c +23
-0@@ -749,6 +749,28 @@ int kvm_s390_set_clock_ext(uint8_t tod_high, uint64_t tod_low)return kvm_vm_ioctl (kvm_state,KVM_SET_DEVICE_ATTR , &attr); } +int kvm_s390_get_cpc (uint64_t *cpc) +{ +struct kvm_device_attr attr = { + .group =KVM_S390_VM_MISC , + .attr =KVM_S390_VM_MISC_CPC , + .addr = (uint64_t )cpc, + }; + +return kvm_vm_ioctl (kvm_state,KVM_GET_DEVICE_ATTR , &attr); +} + +int kvm_s390_set_cpc (uint64_t cpc) +{ +struct kvm_device_attr attr = { + .group =KVM_S390_VM_MISC , + .attr =KVM_S390_VM_MISC_CPC , + .addr = (uint64_t )&cpc, + }; + +return kvm_vm_ioctl (kvm_state,KVM_SET_DEVICE_ATTR , &attr); +} +/** * kvm_s390_mem_op: * @addr: the logical start address in guest memory @@ -2142,6 +2164,7 @@ static int kvm_to_feat[][2] = { { 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}, + { KVM_S390_VM_CPU_FEAT_DIAG318, S390_FEAT_DIAG318}, };static int query_cpu_feat (S390FeatBitmap features)target/s390x/kvm_s390x.h +3
-0@@ -29,6 +29,9 @@ int kvm_s390_get_clock(uint8_t *tod_high, uint64_t *tod_clock);int kvm_s390_get_clock_ext (uint8_t *tod_high,uint64_t *tod_clock);int kvm_s390_set_clock (uint8_t tod_high,uint64_t tod_clock);int kvm_s390_set_clock_ext (uint8_t tod_high,uint64_t tod_clock); +int kvm_s390_get_cpc (uint64_t *cpc); +int kvm_s390_set_cpc (uint64_t cpc); +bool kvm_s390_has_diag318 (void );void kvm_s390_enable_css_support (S390CPU *cpu);int kvm_s390_assign_subch_ioeventfd (EventNotifier *notifier,uint32_t sch,int vq,bool assign);
Signature · 2 lines
Respectfully, - Collin Walling
Quoted 8 lines · On Wed, 5 Dec 2018 09:59:54 -0500 Collin Walling <[email protected]> wrote:
Quoted 4 lines · Christian Borntraeger
You should clearly review your email list.....
Adding the "new" Conny, removing Carsten.
Thanks for taking care of that. I'll be more careful when using the addresses at the top of the files.
scripts/get_maintainer.pl -f <file> is probably more useful to get current addresses :)
Quoted 6 lines · Cornelia Huck
Quoted 3 lines · On Wed, 5 Dec 2018 09:59:54 -0500 Collin Walling <[email protected]> wrote:
Quoted 2 lines · Christian Borntraeger
You should clearly review your email list.....
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
Adding the "new" Conny, removing Carsten.
Thanks for taking care of that. I'll be more careful when using the addresses at the top of the files.
scripts/get_maintainer.pl-f <file> is probably more useful to get current addresses :)
I'll give it a whirl next time. I appreciate the advice! :)
Signature · 2 lines
Respectfully, - Collin Walling