First s390x batch for 2.7
cover First s390x batch for 2.7
Here's the first round of s390x patches for 2.7. We have the new machine for 2.7 and two features:
- Make use of the runtime instrumentation support introduced in the kernel.
- Enhance our ipl (boot) process: We can now start from devices in subchannel sets > 0 as well. As a bonus, the conversion to diag308 in the bios allows us to get rid of the gr7 hack.
Alexander Yarygin (6):
s390x/ipl: Extend the IplParameterBlock struct s390x/ipl: Add type and length checks for IplParameterBlock values s390x/ipl: Provide ipl parameter block
s390x/ipl: Add ssid field to IplParameterBlock pc-bios/s390-ccw: Get device address via diag 308/6 s390x/ipl: Remove redundant usage of gr7
Cornelia Huck (2):
s390x: add compat machine for 2.7
s390-ccw.img: rebuild image
Fan Zhang (1):
s390x: enable runtime instrumentation
hw/s390x/ipl.c | 63 ++++++++++++++++------------ hw/s390x/ipl.h | 84 ++++++++++++++++++++++++++++++++++--- hw/s390x/s390-virtio-ccw.c | 47 ++++++++++++++++++++- include/hw/compat.h | 3 ++ include/hw/s390x/s390-virtio-ccw.h | 4 ++ pc-bios/s390-ccw.img | Bin 26424 -> 26424 bytes pc-bios/s390-ccw/iplb.h | 79 ++++++++++++++++++++++++++++++++++ pc-bios/s390-ccw/main.c | 25 ++++++----- pc-bios/s390-ccw/s390-ccw.h | 2 +- pc-bios/s390-ccw/start.S | 2 - target-s390x/cpu.h | 18 ++++++++ target-s390x/ioinst.c | 1 + target-s390x/kvm.c | 21 ++++++++++ target-s390x/machine.c | 12 ++++++ target-s390x/misc_helper.c | 20 +++++++-- 15 files changed, 332 insertions(+), 49 deletions(-) create mode 100644 pc-bios/s390-ccw/iplb.h
Signature · 1 line
2.8.1
PATCH 1/9 s390x: add compat machine for 2.7
Also add some of the option cascading we were missing.
--- hw/s390x/s390-virtio-ccw.c | 21 ++++++++++++++++++++- include/hw/compat.h | 3 +++ 2 files changed, 23 insertions(+), 1 deletion(-)
hw/s390x/s390-virtio-ccw.c +20 -1
@@ -299,7 +299,11 @@ static const TypeInfo ccw_machine_info = { } \ type_init(ccw_machine_register_##suffix) +#define CCW_COMPAT_2_6 \ + HW_COMPAT_2_6 +#define CCW_COMPAT_2_5 \ + CCW_COMPAT_2_6 \ HW_COMPAT_2_5#define CCW_COMPAT_2_4 \
@@ -343,21 +347,35 @@ static const TypeInfo ccw_machine_info = { .value = "0",\ }, +static void ccw_machine_2_7_instance_options (MachineState *machine) +{ +} + +static void ccw_machine_2_7_class_options (MachineClass *mc) +{ +} +DEFINE_CCW_MACHINE(2_7, "2.7", true); +static void ccw_machine_2_6_instance_options (MachineState *machine) { +ccw_machine_2_7_instance_options (machine); }static void ccw_machine_2_6_class_options (MachineClass *mc) { +ccw_machine_2_7_class_options (mc); +SET_MACHINE_COMPAT (mc,CCW_COMPAT_2_6 ); } -DEFINE_CCW_MACHINE(2_6, "2.6", true); +DEFINE_CCW_MACHINE(2_6, "2.6", false);static void ccw_machine_2_5_instance_options (MachineState *machine) { +ccw_machine_2_6_instance_options (machine); }static void ccw_machine_2_5_class_options (MachineClass *mc) { +ccw_machine_2_6_class_options (mc);SET_MACHINE_COMPAT (mc,CCW_COMPAT_2_5 ); } DEFINE_CCW_MACHINE(2_5, "2.5", false);
@@ -369,6 +387,7 @@ static void ccw_machine_2_4_instance_options(MachineState *machine)static void ccw_machine_2_4_class_options (MachineClass *mc) { +ccw_machine_2_5_class_options (mc);SET_MACHINE_COMPAT (mc,CCW_COMPAT_2_4 ); } DEFINE_CCW_MACHINE(2_4, "2.4", false);
include/hw/compat.h +3 -0
@@ -1,6 +1,9 @@#ifndef HW_COMPAT_H #define HW_COMPAT_H +#define HW_COMPAT_2_6 \ +/* empty */ +#define HW_COMPAT_2_5 \ {\ .driver = "isa-fdc",\
Signature · 1 line
2.8.1
PATCH 2/9 s390x: enable runtime instrumentation
In reply to Cornelia HuckFrom: Fan Zhang <[email protected]>
Introduce run-time-instrumentation support when running under kvm for virtio-ccw 2.7 machine and make sure older machines can not enable it.
The new ri_allowed field in the s390MachineClass serves as an indicator whether the feature can be used by the machine and should therefore be activated if available.
riccb_needed() is used to check whether riccb is needed or not in live migration.
--- hw/s390x/s390-virtio-ccw.c | 20 ++++++++++++++++++++ include/hw/s390x/s390-virtio-ccw.h | 4 ++++ target-s390x/cpu.h | 18 ++++++++++++++++++ target-s390x/kvm.c | 21 +++++++++++++++++++++ target-s390x/machine.c | 12 ++++++++++++ 5 files changed, 75 insertions(+)
hw/s390x/s390-virtio-ccw.c +20 -0
@@ -190,7 +190,9 @@ static void ccw_machine_class_init(ObjectClass *oc, void *data)MachineClass *mc =MACHINE_CLASS (oc);NMIClass *nc =NMI_CLASS (oc);HotplugHandlerClass *hc =HOTPLUG_HANDLER_CLASS (oc); +S390CcwMachineClass *s390mc =S390_MACHINE_CLASS (mc); + s390mc->ri_allowed = true; mc->init = ccw_init; mc->reset = s390_machine_reset; mc->hot_add_cpu = s390_hot_add_cpu;
@@ -237,6 +239,20 @@ static inline void machine_set_dea_key_wrap(Object *obj, bool value, ms->dea_key_wrap = value; } +bool ri_allowed (void ) +{ +if (kvm_enabled ()) { +MachineClass *mc =MACHINE_GET_CLASS (qdev_get_machine ()); +if (object_class_dynamic_cast (OBJECT_CLASS (mc), +TYPE_S390_CCW_MACHINE )) { +S390CcwMachineClass *s390mc =S390_MACHINE_CLASS (mc); + +return s390mc->ri_allowed; + } + } +return 0 ; +} +static inline void s390_machine_initfn (Object *obj) { object_property_add_bool(obj, "aes-key-wrap",
@@ -262,6 +278,7 @@ static const TypeInfo ccw_machine_info = { .abstract = true, .instance_size = sizeof(S390CcwMachineState), .instance_init = s390_machine_initfn, + .class_size = sizeof(S390CcwMachineClass), .class_init = ccw_machine_class_init, .interfaces = (InterfaceInfo []) { {TYPE_NMI },
@@ -363,6 +380,9 @@ static void ccw_machine_2_6_instance_options(MachineState *machine)static void ccw_machine_2_6_class_options (MachineClass *mc) { +S390CcwMachineClass *s390mc =S390_MACHINE_CLASS (mc); + + s390mc->ri_allowed = false;ccw_machine_2_7_class_options (mc);SET_MACHINE_COMPAT (mc,CCW_COMPAT_2_6 ); }
include/hw/s390x/s390-virtio-ccw.h +4 -0
@@ -35,6 +35,10 @@ typedef struct S390CcwMachineClass {MachineClass parent_class;/*< public >*/ + bool ri_allowed; } S390CcwMachineClass; +/* runtime-instrumentation allowed by the machine */ +bool ri_allowed (void ); +#endif
target-s390x/cpu.h +18 -0
@@ -135,6 +135,8 @@ typedef struct CPUS390XState {uint64_t gbea;uint64_t pp; +uint8_t riccb[64 ]; +CPU_COMMON /* reset does memset(0) up to here */
@@ -1159,6 +1161,7 @@ void kvm_s390_reset_vcpu(S390CPU *cpu);int kvm_s390_set_mem_limit (KVMState *s,uint64_t new_limit,uint64_t *hw_limit);void kvm_s390_vcpu_interrupt_pre_save (S390CPU *cpu);int kvm_s390_vcpu_interrupt_post_load (S390CPU *cpu); +int kvm_s390_get_ri (void );void kvm_s390_crypto_reset (void );#else static inline void kvm_s390_io_interrupt(uint16_t subchannel_id,
@@ -1209,6 +1212,10 @@ static inline int kvm_s390_vcpu_interrupt_post_load(S390CPU *cpu) {return 0 ; } +static inline int kvm_s390_get_ri (void ) +{ +return 0 ; +}static inline void kvm_s390_crypto_reset (void ) { }
@@ -1272,11 +1279,22 @@ static inline bool vregs_needed(void *opaque) }return 0 ; } +static inline bool riccb_needed (void *opaque) +{ +if (kvm_enabled ()) { +return kvm_s390_get_ri (); + } +return 0 ; +}#else static inline bool vregs_needed (void *opaque) {return 0 ; } +static inline bool riccb_needed (void *opaque) +{ +return 0 ; +}#endif /* machine check interruption code */
target-s390x/kvm.c +21 -0
@@ -46,6 +46,7 @@#include "hw/s390x/ipl.h" #include "hw/s390x/ebcdic.h" #include "exec/memattrs.h" +#include "hw/s390x/s390-virtio-ccw.h" /* #define DEBUG_KVM */
@@ -135,6 +136,7 @@ static int cap_sync_regs;static int cap_async_pf;static int cap_mem_op;static int cap_s390_irq; +static int cap_ri;static void *legacy_s390_alloc (size_t size,uint64_t *align);
@@ -270,6 +272,11 @@ int kvm_arch_init(MachineState *ms, KVMState *s)kvm_vm_enable_cap (s,KVM_CAP_S390_USER_SIGP ,0 );kvm_vm_enable_cap (s,KVM_CAP_S390_VECTOR_REGISTERS ,0 );kvm_vm_enable_cap (s,KVM_CAP_S390_USER_STSI ,0 ); +if (ri_allowed ()) { +if (kvm_vm_enable_cap (s,KVM_CAP_S390_RI ,0 ) ==0 ) { + cap_ri =1 ; + } + }return 0 ; }
@@ -386,6 +393,11 @@ int kvm_arch_put_registers(CPUState *cs, int level)kvm_set_one_reg (cs,KVM_REG_S390_PP , &env->pp); } +if (can_sync_regs (cs,KVM_SYNC_RICCB )) { +memcpy (cs->kvm_run->s.regs.riccb, env->riccb,64 ); + cs->kvm_run->kvm_dirty_regs |=KVM_SYNC_RICCB ; + } +/* pfault parameters */ if (can_sync_regs (cs,KVM_SYNC_PFAULT )) { cs->kvm_run->s.regs.pft = env->pfault_token;
@@ -528,6 +540,10 @@ int kvm_arch_get_registers(CPUState *cs)kvm_get_one_reg (cs,KVM_REG_S390_PP , &env->pp); } +if (can_sync_regs (cs,KVM_SYNC_RICCB )) { +memcpy (env->riccb, cs->kvm_run->s.regs.riccb,64 ); + } +/* pfault parameters */ if (can_sync_regs (cs,KVM_SYNC_PFAULT )) { env->pfault_token = cs->kvm_run->s.regs.pft;
@@ -2136,6 +2152,11 @@ int kvm_s390_get_memslot_count(KVMState *s)return kvm_check_extension (s,KVM_CAP_NR_MEMSLOTS ); } +int kvm_s390_get_ri (void ) +{ +return cap_ri; +} +int kvm_s390_set_cpu_state (S390CPU *cpu,uint8_t cpu_state) {struct kvm_mp_state mp_state = {};
target-s390x/machine.c +12 -0
@@ -135,6 +135,17 @@ static const VMStateDescription vmstate_vregs = { } }; +const VMStateDescription vmstate_riccb = { + .name ="cpu/riccb" , + .version_id =1 , + .minimum_version_id =1 , + .needed = riccb_needed, + .fields = (VMStateField []) { +VMSTATE_UINT8_ARRAY (env.riccb,S390CPU ,64 ), +VMSTATE_END_OF_LIST () + } +}; +const VMStateDescription vmstate_s390_cpu = { .name ="cpu" , .post_load = cpu_post_load,
@@ -166,6 +177,7 @@ const VMStateDescription vmstate_s390_cpu = { .subsections = (const VMStateDescription*[]) { &vmstate_fpu, &vmstate_vregs, + &vmstate_riccb,NULL }, };
Signature · 1 line
2.8.1
PATCH 3/9 s390x/ipl: Extend the IplParameterBlock struct
In reply to Cornelia HuckFrom: Alexander Yarygin <[email protected]>
The IplParameterBlock struct currently has only 200 bytes filled, but it can be up to 4K.
This patch converts the struct to union with a fully populated struct inside it and second struct with old values.
For compatibility reasons we disable migration of the extended iplb field for pre-2.7 machines. Also a guest still can read/write only the first 200 bytes of IPLB for now.
--- hw/s390x/ipl.c | 24 ++++++++++++++++++ hw/s390x/ipl.h | 61 ++++++++++++++++++++++++++++++++++++++++++---- hw/s390x/s390-virtio-ccw.c | 8 +++++- target-s390x/misc_helper.c | 7 +++--- 4 files changed, 90 insertions(+), 10 deletions(-)
hw/s390x/ipl.c +24 -0
@@ -30,6 +30,24 @@#define ZIPL_IMAGE_START 0x009000UL#define IPL_PSW_MASK (PSW_MASK_32 | PSW_MASK_64) +static bool iplb_extended_needed (void *opaque) +{ +S390IPLState *ipl =S390_IPL (object_resolve_path (TYPE_S390_IPL ,NULL )); + +return ipl->iplbext_migration; +} + +static const VMStateDescription vmstate_iplb_extended = { + .name ="ipl/iplb_extended" , + .version_id =0 , + .minimum_version_id =0 , + .needed = iplb_extended_needed, + .fields = (VMStateField []) { +VMSTATE_UINT8_ARRAY (reserved_ext, IplParameterBlock,4096 -200 ), +VMSTATE_END_OF_LIST () + } +}; +static const VMStateDescription vmstate_iplb = { .name ="ipl/iplb" , .version_id =0 ,
@@ -39,6 +57,10 @@ static const VMStateDescription vmstate_iplb = { VMSTATE_UINT16(devno, IplParameterBlock), VMSTATE_UINT8_ARRAY(reserved2, IplParameterBlock, 88),VMSTATE_END_OF_LIST () + }, + .subsections = (const VMStateDescription *[]) { + &vmstate_iplb_extended, +NULL } };
@@ -181,6 +203,8 @@ static Property s390_ipl_properties[] = {DEFINE_PROP_STRING ("cmdline" , S390IPLState, cmdline),DEFINE_PROP_STRING ("firmware" , S390IPLState, firmware),DEFINE_PROP_BOOL ("enforce_bios" , S390IPLState, enforce_bios, false), +DEFINE_PROP_BOOL ("iplbext_migration" , S390IPLState, iplbext_migration, + true), DEFINE_PROP_END_OF_LIST(), };
hw/s390x/ipl.h +56 -5
74 lines not on this page · raw message
hw/s390x/s390-virtio-ccw.c +7 -1
@@ -25,6 +25,7 @@#include "s390-pci-bus.h" #include "hw/s390x/storage-keys.h" #include "hw/compat.h" +#include "ipl.h" #include "hw/s390x/s390-virtio-ccw.h" static const char *const reset_dev_types[] = {
@@ -317,7 +318,12 @@ static const TypeInfo ccw_machine_info = { type_init(ccw_machine_register_##suffix)#define CCW_COMPAT_2_6 \ - HW_COMPAT_2_6 + HW_COMPAT_2_6 \ + {\ + .driver = TYPE_S390_IPL,\ + .property = "iplbext_migration",\ + .value = "off",\ + },#define CCW_COMPAT_2_5 \ CCW_COMPAT_2_6 \
target-s390x/misc_helper.c +3 -4
@@ -232,8 +232,8 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3)program_interrupt (env,PGM_ADDRESSING ,ILEN_LATER_INC );return ; } - iplb =g_malloc0 (sizeof (struct IplParameterBlock )); -cpu_physical_memory_read (addr, iplb,sizeof (struct IplParameterBlock )); + iplb =g_malloc0 (sizeof (IplParameterBlock)); +cpu_physical_memory_read (addr, iplb,S390_IPLB_MIN_CCW_LEN );s390_ipl_update_diag308 (iplb); env->regs[r1 +1 ] =DIAG_308_RC_OK ;g_free (iplb);
@@ -250,8 +250,7 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3) } iplb =s390_ipl_get_iplb ();if (iplb) { -cpu_physical_memory_write (addr, iplb, -sizeof (struct IplParameterBlock )); +cpu_physical_memory_write (addr, iplb,S390_IPLB_MIN_CCW_LEN ); env->regs[r1 +1 ] =DIAG_308_RC_OK ; }else { env->regs[r1 +1 ] =DIAG_308_RC_NO_CONF ;
Signature · 1 line
2.8.1
Re: [Qemu-devel] [PATCH for-2.7 3/9] s390x/ipl: Extend the IplParameterBlock struct
hw/s390x/ipl.h line 60
Quoted 3 lines · Cornelia Huck
hw/s390x/ipl.h +3
-0+union { +IplBlockCcw ccw; +IplBlockCcw fcp;
you later fix this up in patch
s390x/ipl: Provide ipl parameter block
- IplBlockCcw fcp;
+ IplBlockFcp fcp;
Maybe just move this hunk to patch 3.
Re: [Qemu-devel] [PATCH for-2.7 3/9] s390x/ipl: Extend the IplParameterBlock struct
Quoted 14 lines · On Wed, 27 Apr 2016 15:43:45 +0200 Christian Borntraeger…
hw/s390x/ipl.h line 60
Quoted 3 lines · Cornelia Huck
hw/s390x/ipl.h +3
-0+union { +IplBlockCcw ccw; +IplBlockCcw fcp;you later fix this up in patch
s390x/ipl: Provide ipl parameter block(quoted diff) +1
-1- IplBlockCcw fcp; + IplBlockFcp fcp;
Quoted 2 lines
Maybe just move this hunk to patch 3.
Oops, definetly :)
PATCH 4/9 s390x/ipl: Add type and length checks for IplParameterBlock values
In reply to Cornelia HuckFrom: Alexander Yarygin <[email protected]>
We can check for valid type and lengths of the IplParameterBlock fields when receiving the struct from the guest.
Length of the IplParameterBlock can be less than 4K. To play safe we can read and write only required amount of data.
--- hw/s390x/ipl.h | 21 +++++++++++++++++++++ target-s390x/misc_helper.c | 17 +++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-)
hw/s390x/ipl.h +21 -0
@@ -99,6 +99,27 @@ struct S390IPLState { };typedef struct S390IPLState S390IPLState ; +#define S390_IPL_TYPE_FCP 0x00 +#define S390_IPL_TYPE_CCW 0x02 +#define S390_IPLB_MIN_CCW_LEN 200 +#define S390_IPLB_MIN_FCP_LEN 384 + +static inline bool iplb_valid_len (IplParameterBlock *iplb) +{ +return be32_to_cpu (iplb->len) <=sizeof (IplParameterBlock); +} + +static inline bool iplb_valid_ccw (IplParameterBlock *iplb) +{ +return be32_to_cpu (iplb->len) >=S390_IPLB_MIN_CCW_LEN && + iplb->pbt ==S390_IPL_TYPE_CCW ; +} + +static inline bool iplb_valid_fcp (IplParameterBlock *iplb) +{ +return be32_to_cpu (iplb->len) >=S390_IPLB_MIN_FCP_LEN && + iplb->pbt ==S390_IPL_TYPE_FCP ; +}#endif
target-s390x/misc_helper.c +15 -2
@@ -233,9 +233,22 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3)return ; } iplb =g_malloc0 (sizeof (IplParameterBlock)); -cpu_physical_memory_read (addr, iplb,S390_IPLB_MIN_CCW_LEN ); +cpu_physical_memory_read (addr, iplb,sizeof (iplb->len)); +if (!iplb_valid_len (iplb)) { + env->regs[r1 +1 ] =DIAG_308_RC_INVALID ; + goto out; + } + +cpu_physical_memory_read (addr, iplb,be32_to_cpu (iplb->len)); + +if (!iplb_valid_ccw (iplb) && !iplb_valid_fcp (iplb)) { + env->regs[r1 +1 ] =DIAG_308_RC_INVALID ; + goto out; + } +s390_ipl_update_diag308 (iplb); env->regs[r1 +1 ] =DIAG_308_RC_OK ; +out:g_free (iplb);return ;case 6 :
@@ -250,7 +263,7 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3) } iplb =s390_ipl_get_iplb ();if (iplb) { -cpu_physical_memory_write (addr, iplb,S390_IPLB_MIN_CCW_LEN ); +cpu_physical_memory_write (addr, iplb,be32_to_cpu (iplb->len)); env->regs[r1 +1 ] =DIAG_308_RC_OK ; }else { env->regs[r1 +1 ] =DIAG_308_RC_NO_CONF ;
Signature · 1 line
2.8.1
PATCH 5/9 s390x/ipl: Provide ipl parameter block
In reply to Cornelia HuckFrom: Alexander Yarygin <[email protected]>
Right now we return the ipl parameter block only if the guest specified one. Let's fill in the parameter block when bootindex parameter is available and not booting from an external kernel.
--- hw/s390x/ipl.c | 7 +++++++ hw/s390x/ipl.h | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-)
hw/s390x/ipl.c +7 -0
@@ -238,6 +238,12 @@ static uint64_t s390_update_iplstate(S390IPLState *ipl) ipl->cssid = ccw_dev->sch->cssid; ipl->ssid = ccw_dev->sch->ssid; ipl->devno = ccw_dev->sch->devno; + ipl->iplb.len =cpu_to_be32 (S390_IPLB_MIN_CCW_LEN ); + ipl->iplb.blk0_len = +cpu_to_be32 (S390_IPLB_MIN_CCW_LEN -S390_IPLB_HEADER_LEN ); + ipl->iplb.pbt =S390_IPL_TYPE_CCW ; + ipl->iplb.ccw.devno =cpu_to_be16 (ccw_dev->sch->devno); + ipl->iplb_valid = true; goto out; } }
@@ -292,6 +298,7 @@ static void s390_ipl_reset(DeviceState *dev)if (!ipl->reipl_requested) { ipl->iplb_valid = false; +memset (&ipl->iplb,0 ,sizeof (IplParameterBlock)); } ipl->reipl_requested = false; }
hw/s390x/ipl.h +2 -1
@@ -57,7 +57,7 @@ union IplParameterBlock {uint8_t loadparm[8 ];union {IplBlockCcw ccw; -IplBlockCcw fcp; +IplBlockFcp fcp; }; }QEMU_PACKED ;struct {
@@ -102,6 +102,7 @@ typedef struct S390IPLState S390IPLState;#define S390_IPL_TYPE_FCP 0x00#define S390_IPL_TYPE_CCW 0x02 +#define S390_IPLB_HEADER_LEN 8#define S390_IPLB_MIN_CCW_LEN 200#define S390_IPLB_MIN_FCP_LEN 384
Signature · 1 line
2.8.1
PATCH 6/9 s390x/ipl: Add ssid field to IplParameterBlock
In reply to Cornelia HuckFrom: Alexander Yarygin <[email protected]>
Add the ssid field to the ipl parameter block struct and fill it when necessary so the guest can use it.
--- hw/s390x/ipl.c | 1 + hw/s390x/ipl.h | 3 ++- target-s390x/ioinst.c | 1 + 3 files changed, 4 insertions(+), 1 deletion(-)
hw/s390x/ipl.c +1 -0
@@ -243,6 +243,7 @@ static uint64_t s390_update_iplstate(S390IPLState *ipl)cpu_to_be32 (S390_IPLB_MIN_CCW_LEN -S390_IPLB_HEADER_LEN ); ipl->iplb.pbt =S390_IPL_TYPE_CCW ; ipl->iplb.ccw.devno =cpu_to_be16 (ccw_dev->sch->devno); + ipl->iplb.ccw.ssid = ccw_dev->sch->ssid &3 ; ipl->iplb_valid = true; goto out; }
hw/s390x/ipl.h +2 -1
@@ -16,7 +16,8 @@#include "cpu.h" struct IplBlockCcw { -uint8_t reserved0[86 ]; +uint8_t reserved0[85 ]; +uint8_t ssid;uint16_t devno;uint8_t vm_flags;uint8_t reserved3[3 ];
target-s390x/ioinst.c +1 -0
@@ -509,6 +509,7 @@ static void ioinst_handle_chsc_scsc(ChscReq *req, ChscResp *res) general_chars[0 ] =cpu_to_be32 (0x03000000 ); general_chars[1 ] =cpu_to_be32 (0x00059000 ); + general_chars[3 ] =cpu_to_be32 (0x00080000 ); chsc_chars[0 ] =cpu_to_be32 (0x40000000 ); chsc_chars[3 ] =cpu_to_be32 (0x00040000 );
Signature · 1 line
2.8.1
PATCH 7/9 pc-bios/s390-ccw: Get device address via diag 308/6
In reply to Cornelia HuckFrom: Alexander Yarygin <[email protected]>
To IPL from a device, pc-bios receives from qemu a device address via general register 7. The better way to do it is to use diag308/6 instruction which returns so called
"IplParameterBlock". IplParameterBlock contains the device address for IPL and additional parameters that can be used by pc-bios.
This patch allows pc-bios to get device address via diag308/6 and doesn't use gr7 passed boot information anymore.
--- pc-bios/s390-ccw/iplb.h | 79 +++++++++++++++++++++++++++++++++++++++++++++ pc-bios/s390-ccw/main.c | 25 ++++++++------ pc-bios/s390-ccw/s390-ccw.h | 2 +- pc-bios/s390-ccw/start.S | 2 -- 4 files changed, 95 insertions(+), 13 deletions(-) create mode 100644 pc-bios/s390-ccw/iplb.h
pc-bios/s390-ccw/iplb.h new file +79 -0
@@ -0,0 +1,79 @@ +/* +* QEMU S390 IPL Block +* +* Copyright 2015 IBM Corp. +* Author(s): Alexander Yarygin <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or (at +* your option) any later version. See the COPYING file in the top-level +* directory. +*/ + +#ifndef IPLB_H +#define IPLB_H + +struct IplBlockCcw { +uint8_t reserved0[85 ]; +uint8_t ssid; +uint16_t devno; +uint8_t vm_flags; +uint8_t reserved3[3 ]; +uint32_t vm_parm_len; +uint8_t nss_name[8 ]; +uint8_t vm_parm[64 ]; +uint8_t reserved4[8 ]; +} __attribute__ ((packed)); +typedef struct IplBlockCcw IplBlockCcw ; + +struct IplBlockFcp { +uint8_t reserved1[305 -1 ]; +uint8_t opt; +uint8_t reserved2[3 ]; +uint16_t reserved3; +uint16_t devno; +uint8_t reserved4[4 ]; +uint64_t wwpn; +uint64_t lun; +uint32_t bootprog; +uint8_t reserved5[12 ]; +uint64_t br_lba; +uint32_t scp_data_len; +uint8_t reserved6[260 ]; +uint8_t scp_data[]; +} __attribute__ ((packed)); +typedef struct IplBlockFcp IplBlockFcp ; + +struct IplParameterBlock { +uint32_t len; +uint8_t reserved0[3 ]; +uint8_t version; +uint32_t blk0_len; +uint8_t pbt; +uint8_t flags; +uint16_t reserved01; +uint8_t loadparm[8 ]; +union { +IplBlockCcw ccw; +IplBlockFcp fcp; + }; +} __attribute__ ((packed)); +typedef struct IplParameterBlock IplParameterBlock ; + +extern IplParameterBlock iplb __attribute__((__aligned__(PAGE_SIZE))); + +#define S390_IPL_TYPE_FCP 0x00 +#define S390_IPL_TYPE_CCW 0x02 + +static inline bool store_iplb (IplParameterBlock *iplb) +{ + register unsigned long addr asm("0") = (unsigned long) iplb; + register unsigned long rc asm("1") = 0; + + asmvolatile ("diag %0,%2,0x308\n" + :"+d" (addr),"+d" (rc) + :"d" (6 ) + :"memory" ,"cc" ); +return rc ==0x01 ; +} + +#endif /* IPLB_H */
pc-bios/s390-ccw/main.c +15 -10
@@ -12,8 +12,8 @@#include "virtio.h" char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE))); -uint64_t boot_value;static SubChannelId blk_schid = { .one =1 }; +IplParameterBlock iplb __attribute__((__aligned__(PAGE_SIZE)));/* * Priniciples of Operations (SA22-7832-09) chapter 17 requires that
@@ -61,7 +61,7 @@ static bool find_dev(Schib *schib, int dev_no)return false; } -static void virtio_setup (uint64_t dev_info) +static void virtio_setup (void ) {Schib schib;int ssid;
@@ -75,12 +75,18 @@ static void virtio_setup(uint64_t dev_info)*/ enable_mss_facility (); -if (dev_info !=-1 ) { - dev_no = dev_info &0xffff ; -debug_print_int ("device no. " , dev_no); - blk_schid.ssid = (dev_info >>16 ) &0x3 ; -debug_print_int ("ssid " , blk_schid.ssid); - found =find_dev (&schib, dev_no); +if (store_iplb (&iplb)) { +switch (iplb.pbt) { +case S390_IPL_TYPE_CCW : + dev_no = iplb.ccw.devno; +debug_print_int ("device no. " , dev_no); + blk_schid.ssid = iplb.ccw.ssid &0x3 ; +debug_print_int ("ssid " , blk_schid.ssid); + found =find_dev (&schib, dev_no); +break ; +default : +panic ("List-directed IPL not supported yet!\n" ); + } }else {for (ssid =0 ; ssid <0x3 ; ssid++) { blk_schid.ssid = ssid;
@@ -101,8 +107,7 @@ static void virtio_setup(uint64_t dev_info)int main (void ) {sclp_setup (); -debug_print_int ("boot reg[7] " , boot_value); -virtio_setup (boot_value); +virtio_setup ();zipl_load ();/* no return */
pc-bios/s390-ccw/s390-ccw.h +1 -1
@@ -44,6 +44,7 @@ typedef unsigned long long __u64;#endif #include "cio.h" +#include "iplb.h" typedef struct irb Irb ;typedef struct ccw1 Ccw1 ;
@@ -61,7 +62,6 @@ void consume_sclp_int(void);void panic (const char *string);void write_subsystem_identification (void ); extern char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE))); -extern uint64_t boot_value;/* sclp-ascii.c */ void sclp_print (const char *string);
pc-bios/s390-ccw/start.S +0 -2
@@ -14,8 +14,6 @@ _start: larl %r15, stack + 0x8000 /* Set up stack */ -larl %r6, boot_value -stg %r7, 0(%r6) /* save the boot_value before any function calls */ j main /* And call C */ /*
Signature · 1 line
2.8.1
PATCH 8/9 s390-ccw.img: rebuild image
In reply to Cornelia HuckContains the following change:
pc-bios/s390-ccw: Get device address via diag 308/6
--- pc-bios/s390-ccw.img | Bin 26424 -> 26424 bytes 1 file changed, 0 insertions(+), 0 deletions(-)
pc-bios/s390-ccw.img binary +0 -0
Signature · 1 line
2.8.1
PATCH 9/9 s390x/ipl: Remove redundant usage of gr7
In reply to Cornelia HuckFrom: Alexander Yarygin <[email protected]>
We don't need to pass device address for pc-bios using gr7 anymore as the pcbios completely relies on diag308 now, so we can remove it from qemu. devno, ssid and cssid are migrated but the value was never reused, so we can safely ignore these fields and migrate 0.
--- hw/s390x/ipl.c | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-)
hw/s390x/ipl.c +6 -27
@@ -208,50 +208,27 @@ static Property s390_ipl_properties[] = { DEFINE_PROP_END_OF_LIST(), }; -/* -* In addition to updating the iplstate, this function returns: -* - 0 if system was ipled with external kernel -* - -1 if no valid boot device was found -* - ccw id of the boot device otherwise -*/ -static uint64_t s390_update_iplstate (S390IPLState *ipl) +static bool s390_gen_initial_iplb (S390IPLState *ipl) {DeviceState *dev_st; -if (ipl->iplb_valid) { - ipl->cssid =0 ; - ipl->ssid =0 ; - ipl->devno = ipl->iplb.devno; - goto out; - } - -if (ipl->kernel) { -return 0 ; - } - dev_st =get_boot_device (0 );if (dev_st) {VirtioCcwDevice *ccw_dev = (VirtioCcwDevice *)object_dynamic_cast (OBJECT (qdev_get_parent_bus (dev_st)->parent),TYPE_VIRTIO_CCW_DEVICE );if (ccw_dev) { - ipl->cssid = ccw_dev->sch->cssid; - ipl->ssid = ccw_dev->sch->ssid; - ipl->devno = ccw_dev->sch->devno; ipl->iplb.len =cpu_to_be32 (S390_IPLB_MIN_CCW_LEN ); ipl->iplb.blk0_len =cpu_to_be32 (S390_IPLB_MIN_CCW_LEN -S390_IPLB_HEADER_LEN ); ipl->iplb.pbt =S390_IPL_TYPE_CCW ; ipl->iplb.ccw.devno =cpu_to_be16 (ccw_dev->sch->devno); ipl->iplb.ccw.ssid = ccw_dev->sch->ssid &3 ; - ipl->iplb_valid = true; - goto out; +return true; } } -return -1 ; -out: -return (uint32_t ) (ipl->cssid <<24 | ipl->ssid <<16 | ipl->devno); +return false; }void s390_ipl_update_diag308 (IplParameterBlock *iplb)
@@ -289,7 +266,9 @@ void s390_ipl_prepare_cpu(S390CPU *cpu)if (!ipl->kernel || ipl->iplb_valid) { cpu->env.psw.addr = ipl->bios_start_addr; - cpu->env.regs[7 ] =s390_update_iplstate (ipl); +if (!ipl->iplb_valid) { + ipl->iplb_valid =s390_gen_initial_iplb (ipl); + } } }
Signature · 1 line
2.8.1