s390x: further patches
PATCH 1/23 s390x/css: handle ccw-0 TIC correctly
In reply to Cornelia HuckFrom: Pierre Morel <[email protected]>
In CCW-0 format TIC command 4 highest bits are ignored in the subchannel. In CCW-1 format the TIC command 4 highest bits must be 0.
To convert TIC from CCW-0 to CCW-1 we clear the 4 highest bits to guarantee compatibility.
--- hw/s390x/css.c | 3 +++ 1 file changed, 3 insertions(+)
hw/s390x/css.c +3 -0
@@ -261,6 +261,9 @@ static CCW1 copy_ccw_from_guest(hwaddr addr, bool fmt1) ret.flags = tmp0.flags; ret.count =be16_to_cpu (tmp0.count); ret.cda =be16_to_cpu (tmp0.cda1) | (tmp0.cda0 <<16 ); +if ((ret.cmd_code &0x0f ) ==CCW_CMD_TIC ) { + ret.cmd_code &=0x0f ; + } }return ret; }
Signature · 1 line
2.5.1
cover s390x: further patches
Hi,
here's a further set of patches on top of the storage key migration patches (v3) I just sent out.
Contained in there are:
- various bugfixes (css/event-facility)
- more efficient adapter interrupt routes setup
- gdb enhancement
- sclp got treated with a lot of remodelling/cleanup
Alexander Yarygin (1):
pc-bios/s390-ccw: Device detection in higher subchannel sets
Cornelia Huck (5):
s390x/css: ccw-0 enforces count > 0 s390x/event-facility: fix receive mask check s390x/css: start with cleared cstat/dstat s390x/event-facility: fix location of receive mask pc-bios/s390-ccw: rebuild image
David Hildenbrand (15):
s390x/gdb: support reading/writing of control registers sclp/s390: rework sclp cpu hotplug device notification s390/sclp: rework sclp event facility initialization + device
realization
s390/sclp: replace sclp event types with proper defines s390/sclp: temporarily fix unassignment/reassignment of memory
subregions
s390/sclp: introduce a root sclp device
s390/sclp: move sclp_execute related functions into the SCLP class s390/sclp: move sclp_service_interrupt into the sclp device
s390: no need to manually parse for slots and maxmem
s390: disallow memory hotplug for the s390-virtio machine s390/sclp: ignore memory hotplug operations if it is disabled
s390: move memory calculation into the sclp device
s390: unify allocation of initial memory
s390/sclp: store the increment_size in the sclp device s390/sclp: simplify calculation of rnmax
Jens Freimann (1):
s390x/kvm: make setting of in-kernel irq routes more efficient
Pierre Morel (1):
s390x/css: handle ccw-0 TIC correctly
configure | 2 +- gdb-xml/s390-cr.xml | 26 ++++ hw/intc/s390_flic_kvm.c | 2 + hw/s390x/css.c | 9 ++ hw/s390x/event-facility.c | 55 +++++--- hw/s390x/s390-virtio-ccw.c | 75 +++-------- hw/s390x/s390-virtio.c | 30 ++--- hw/s390x/s390-virtio.h | 1 + hw/s390x/sclp.c | 267 ++++++++++++++++++++++++++++---------- hw/s390x/sclpcpu.c | 28 +--- hw/s390x/sclpquiesce.c | 4 +- include/hw/s390x/event-facility.h | 12 +- include/hw/s390x/sclp.h | 33 +++++ kvm-all.c | 1 - pc-bios/s390-ccw.img | Bin 13784 -> 13856 bytes pc-bios/s390-ccw/main.c | 66 ++++++---- target-s390x/gdbstub.c | 39 ++++++ 17 files changed, 427 insertions(+), 223 deletions(-) create mode 100644 gdb-xml/s390-cr.xml
Signature · 1 line
2.5.1
PATCH 2/23 s390x/css: ccw-0 enforces count > 0
Type-0 ccws need to have a count > 0 for any command other than TIC. Generate a channel-program check if this is not the case.
--- hw/s390x/css.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/s390x/css.c +4 -0
@@ -290,6 +290,10 @@ static int css_interpret_ccw(SubchDev *sch, hwaddr ccw_addr) ((ccw.cmd_code & 0xf0) != 0)) {return -EINVAL ; } +if (!sch->ccw_fmt_1 && (ccw.count ==0 ) && + (ccw.cmd_code !=CCW_CMD_TIC )) { +return -EINVAL ; + }if (ccw.flags &CCW_FLAG_SUSPEND ) {return -EINPROGRESS ;
Signature · 1 line
2.5.1
PATCH 5/23 s390x/event-facility: fix location of receive mask
In reply to Cornelia HuckFor read event mask, we assumed that the layout of the sccb was
|sccb header|event buffer header|receive mask|...|
The correct layout, however, is
|sccb header|receive mask|...|
as in-buffer and
|sccb header|event buffer header|...|
as out-buffer.
Fix this: This makes selective read work.
--- include/hw/s390x/event-facility.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
include/hw/s390x/event-facility.h +4 -2
@@ -146,8 +146,10 @@ typedef struct WriteEventData {typedef struct ReadEventData {SCCBHeader h; -EventBufferHeader ebh; -uint32_t mask; +union { +uint32_t mask; +EventBufferHeader ebh; + }; } QEMU_PACKED ReadEventData; typedef struct SCLPEvent {
Signature · 1 line
2.5.1
PATCH 3/23 s390x/event-facility: fix receive mask check
In reply to Cornelia HuckFor selective read event, we need to check if any event is requested that is not active instead of whether none of the requested events is active.
--- hw/s390x/event-facility.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
hw/s390x/event-facility.c +3 -2
@@ -240,12 +240,13 @@ static void read_event_data(SCLPEventFacility *ef, SCCB *sccb) sclp_active_selection_mask = sclp_cp_receive_mask;break ;case SCLP_SELECTIVE_READ : -if (!(sclp_cp_receive_mask &be32_to_cpu (red->mask))) { + sclp_active_selection_mask =be32_to_cpu (red->mask); +if (!sclp_cp_receive_mask || + (sclp_active_selection_mask & ~sclp_cp_receive_mask)) { sccb->h.response_code =cpu_to_be16 (SCLP_RC_INVALID_SELECTION_MASK ); goto out; } - sclp_active_selection_mask =be32_to_cpu (red->mask);break ;default : sccb->h.response_code =cpu_to_be16 (SCLP_RC_INVALID_FUNCTION );
Signature · 1 line
2.5.1
PATCH 8/23 s390x/kvm: make setting of in-kernel irq routes more efficient
In reply to Cornelia HuckFrom: Jens Freimann <[email protected]>
When we add new adapter routes we call kvm_irqchip_add_route() for every virtqueue and in the same step also do the KVM_SET_GSI_ROUTING ioctl.
This is unnecessary costly as the interface allows us to set multiple routes in one go. Let's first add all routes to the table stored in the global kvm_state and then do the ioctl to commit the routes to the in-kernel irqchip.
This saves us several ioctls to the kernel where for each call a list is reallocated and populated.
--- hw/intc/s390_flic_kvm.c | 2 ++ kvm-all.c | 1 - 2 files changed, 2 insertions(+), 1 deletion(-)
hw/intc/s390_flic_kvm.c +2 -0
@@ -228,6 +228,8 @@ static int kvm_s390_add_adapter_routes(S390FLICState *fs, routes->gsi[i] = ret; routes->adapter.ind_offset++; } +kvm_irqchip_commit_routes (kvm_state); +/* Restore passed-in structure to original state. */ routes->adapter.ind_offset = ind_offset;return 0 ;
kvm-all.c +0 -1
@@ -1293,7 +1293,6 @@ int kvm_irqchip_add_adapter_route(KVMState *s, AdapterInfo *adapter) kroute.u.adapter.adapter_id = adapter->adapter_id;kvm_add_routing_entry (s, &kroute); -kvm_irqchip_commit_routes (s);return virq; }
Signature · 1 line
2.5.1
PATCH 11/23 s390/sclp: rework sclp event facility initialization + device realization
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
The current code only works by chance. The event facility is a sysbus device, but specifies in its class structure as parent the DeviceClass (instead of a device class).
The init function in return lies therefore at the same position as the init function of SysBusDeviceClass and gets triggered instead - a very bad idea of doing that (e.g. the parameter types don't match).
Let's bring the initialization code up to date, initializing the event facility + child events in .instance_init and moving the realization of the child events out of the init call, into the realization step.
Device realization is now automatically performed when the event facility itself is realized. That realization implicitly triggers realization of the child bus, which in turn initializes the events.
Please note that we have to manually propagate the realization of the bus children, common code still has a TODO set for that task.
--- hw/s390x/event-facility.c | 50 ++++++++++++++++++++++++++------------- include/hw/s390x/event-facility.h | 3 +-- 2 files changed, 34 insertions(+), 19 deletions(-)
hw/s390x/event-facility.c +33 -17
@@ -27,12 +27,12 @@ typedef struct SCLPEventsBus {struct SCLPEventFacility {SysBusDevice parent_obj;SCLPEventsBus sbus; +SCLPEvent quiesce_event; +SCLPEvent cpu_hotplug_event;/* guest' receive mask */ unsigned int receive_mask; }; -static SCLPEvent cpu_hotplug; -/* return true if any child has event pending set */ static bool event_pending (SCLPEventFacility *ef) {
@@ -287,8 +287,26 @@ out:#define TYPE_SCLP_EVENTS_BUS "s390-sclp-events-bus" +static void sclp_events_bus_realize (BusState *bus,Error **errp) +{ +BusChild *kid; + +/* TODO: recursive realization has to be done in common code */ + QTAILQ_FOREACH(kid, &bus->children, sibling) { +DeviceState *dev = kid->child; + +object_property_set_bool (OBJECT (dev), true,"realized" , errp); +if (*errp) { +return ; + } + } +} +static void sclp_events_bus_class_init (ObjectClass *klass,void *data) { +BusClass *bc =BUS_CLASS (klass); + + bc->realize = sclp_events_bus_realize; }static const TypeInfo sclp_events_bus_info = {
@@ -325,26 +343,24 @@ static const VMStateDescription vmstate_event_facility = { } }; -static int init_event_facility (SCLPEventFacility *event_facility) +static void init_event_facility (Object *obj) { -DeviceState *sdev =DEVICE (event_facility); -DeviceState *quiesce; +SCLPEventFacility *event_facility =EVENT_FACILITY (obj); +DeviceState *sdev =DEVICE (obj);/* Spawn a new bus for SCLP events */ qbus_create_inplace (&event_facility->sbus,sizeof (event_facility->sbus),TYPE_SCLP_EVENTS_BUS , sdev,NULL ); - quiesce =qdev_create (&event_facility->sbus.qbus,"sclpquiesce" ); -if (!quiesce) { -return -1 ; - } -qdev_init_nofail (quiesce); - -object_initialize (&cpu_hotplug,sizeof (cpu_hotplug),TYPE_SCLP_CPU_HOTPLUG ); -qdev_set_parent_bus (DEVICE (&cpu_hotplug),BUS (&event_facility->sbus)); -object_property_set_bool (OBJECT (&cpu_hotplug), true,"realized" ,NULL ); - -return 0 ; +object_initialize (&event_facility->quiesce_event,sizeof (SCLPEvent), +"sclpquiesce" ); +qdev_set_parent_bus (DEVICE (&event_facility->quiesce_event), + &event_facility->sbus.qbus); +object_initialize (&event_facility->cpu_hotplug_event,sizeof (SCLPEvent), +TYPE_SCLP_CPU_HOTPLUG ); +qdev_set_parent_bus (DEVICE (&event_facility->cpu_hotplug_event), + &event_facility->sbus.qbus); +/* the facility will automatically realize the devices via the bus */ }static void reset_event_facility (DeviceState *dev)
@@ -363,7 +379,6 @@ static void init_event_facility_class(ObjectClass *klass, void *data) dc->reset = reset_event_facility; dc->vmsd = &vmstate_event_facility;set_bit (DEVICE_CATEGORY_MISC , dc->categories); - k->init = init_event_facility; k->command_handler = command_handler; k->event_pending = event_pending; }
@@ -371,6 +386,7 @@ static void init_event_facility_class(ObjectClass *klass, void *data)static const TypeInfo sclp_event_facility_info = { .name =TYPE_SCLP_EVENT_FACILITY , .parent =TYPE_SYS_BUS_DEVICE , + .instance_init = init_event_facility, .instance_size =sizeof (SCLPEventFacility), .class_init = init_event_facility_class, .class_size =sizeof (SCLPEventFacilityClass),
include/hw/s390x/event-facility.h +1 -2
@@ -191,8 +191,7 @@ typedef struct SCLPEventClass {typedef struct SCLPEventFacility SCLPEventFacility ;typedef struct SCLPEventFacilityClass { -DeviceClass parent_class; -int (*init)(SCLPEventFacility *ef); +SysBusDeviceClass parent_class;void (*command_handler)(SCLPEventFacility *ef,SCCB *sccb,uint64_t code);bool (*event_pending)(SCLPEventFacility *ef); }SCLPEventFacilityClass ;
Signature · 1 line
2.5.1
PATCH 13/23 s390/sclp: temporarily fix unassignment/reassignment of memory subregions
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
Commit 374f2981d1f1 ("memory: protect current_map by RCU") broke unassignment of standby memory on s390x. Looks like that the new parallelism allows races with our (semi broken) memory hotplug code. The flatview_unref() can now be executed after our unparenting. Therefore memory_region_unref() tries to unreference the MemoryRegion itself instead of the parent.
In theory, MemoryRegions are now bound to separate devices that control their lifetime. We don't have this yet, so we really want to control their lifetime manually.
This patch fixes it temporarily, until we have a proper rework. The only drawback is that they won't pop up in "info qom-tree", but that's better than qemu crashes.
We have to release the reference to a memory region after a memory_region_find, as it automatically takes a reference. As we're now able to reassign memory, the MemoryRegion is in fact deleted (otherwise vmstate_register_ram() would complain).
--- hw/s390x/sclp.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
hw/s390x/sclp.c +8 -2
@@ -217,6 +217,7 @@ static void assign_storage(SCCB *sccb) (assign_addr >= mhd->padded_ram_size)) {/* Re-use existing memory region if found */ mr =memory_region_find (sysmem, assign_addr,1 ).mr; +memory_region_unref (mr);if (!mr) {MemoryRegion *standby_ram =g_new (MemoryRegion,1 );
@@ -242,6 +243,11 @@ static void assign_storage(SCCB *sccb) }memory_region_init_ram (standby_ram,NULL , id, this_subregion_size, &error_abort); +/* This is a hack to make memory hotunplug work again. Once we have +* subdevices, we have to unparent them when unassigning memory, +* instead of doing it via the ref count of the MemoryRegion. */ +object_ref (OBJECT (standby_ram)); +object_unparent (OBJECT (standby_ram));vmstate_register_ram_global (standby_ram);memory_region_add_subregion (sysmem, offset, standby_ram); }
@@ -269,6 +275,7 @@ static void unassign_storage(SCCB *sccb)/* find the specified memory region and destroy it */ mr =memory_region_find (sysmem, unassign_addr,1 ).mr; +memory_region_unref (mr);if (mr) {int i;int is_removable =1 ;
@@ -287,8 +294,7 @@ static void unassign_storage(SCCB *sccb) }if (is_removable) {memory_region_del_subregion (sysmem, mr); -object_unparent (OBJECT (mr)); -g_free (mr); +object_unref (OBJECT (mr)); } } }
Signature · 1 line
2.5.1
PATCH 16/23 s390/sclp: move sclp_service_interrupt into the sclp device
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
Let's make that function a method of the new sclp device, keeping the wrapper for existing users.
We can now let go of get_event_facility().
--- hw/s390x/sclp.c | 21 ++++++++++++--------- include/hw/s390x/sclp.h | 1 + 2 files changed, 13 insertions(+), 9 deletions(-)
hw/s390x/sclp.c +12 -9
@@ -22,12 +22,6 @@#include "hw/s390x/event-facility.h" #include "hw/s390x/s390-pci-bus.h" -static inline SCLPEventFacility *get_event_facility (void ) -{ -return EVENT_FACILITY (object_resolve_path_type ("" ,TYPE_SCLP_EVENT_FACILITY , -NULL )); -} -static inline SCLPDevice *get_sclp_device (void ) {return SCLP (object_resolve_path_type ("" ,TYPE_SCLP ,NULL ));
@@ -417,15 +411,15 @@ int sclp_service_call(CPUS390XState *env, uint64_t sccb, uint32_t code)cpu_physical_memory_write (sccb, &work_sccb,be16_to_cpu (work_sccb.h.length)); -sclp_service_interrupt (sccb); + sclp_c->service_interrupt (sclp, sccb); out:return r; } -void sclp_service_interrupt (uint32_t sccb) +static void service_interrupt (SCLPDevice *sclp,uint32_t sccb) { -SCLPEventFacility *ef =get_event_facility (); +SCLPEventFacility *ef = sclp->event_facility;SCLPEventFacilityClass *efc =EVENT_FACILITY_GET_CLASS (ef);uint32_t param = sccb & ~3 ;
@@ -440,6 +434,14 @@ void sclp_service_interrupt(uint32_t sccb)s390_sclp_extint (param); } +void sclp_service_interrupt (uint32_t sccb) +{ +SCLPDevice *sclp =get_sclp_device (); +SCLPDeviceClass *sclp_c =SCLP_GET_CLASS (sclp); + + sclp_c->service_interrupt (sclp, sccb); +} +/* qemu object creation and initialization functions */ void s390_sclp_init (void )
@@ -499,6 +501,7 @@ static void sclp_class_init(ObjectClass *oc, void *data) sc->unassign_storage = unassign_storage; sc->read_cpu_info = sclp_read_cpu_info; sc->execute = sclp_execute; + sc->service_interrupt = service_interrupt; }static TypeInfo sclp_info = {
include/hw/s390x/sclp.h +1 -0
@@ -192,6 +192,7 @@ typedef struct SCLPDeviceClass {/* public */ void (*execute)(SCLPDevice *sclp,SCCB *sccb,uint32_t code); +void (*service_interrupt)(SCLPDevice *sclp,uint32_t sccb); } SCLPDeviceClass;typedef struct sclpMemoryHotplugDev sclpMemoryHotplugDev ;
Signature · 1 line
2.5.1
PATCH 17/23 s390: no need to manually parse for slots and maxmem
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
ram_slots and maxram_size has already been parsed and verified by common code for us.
--- hw/s390x/s390-virtio-ccw.c | 3 +-- hw/s390x/sclp.c | 11 +++-------- 2 files changed, 4 insertions(+), 10 deletions(-)
hw/s390x/s390-virtio-ccw.c +1 -2
@@ -109,9 +109,8 @@ static void ccw_init(MachineState *machine)int ret;VirtualCssBus *css_bus;DeviceState *dev; -QemuOpts *opts =qemu_opts_find (qemu_find_opts ("memory" ),NULL );ram_addr_t pad_size =0 ; -ram_addr_t maxmem =qemu_opt_get_size (opts,"maxmem" , my_ram_size); +ram_addr_t maxmem = machine->maxram_size;ram_addr_t standby_mem_size = maxmem - my_ram_size;uint64_t kvm_limit;
hw/s390x/sclp.c +3 -8
@@ -17,7 +17,7 @@#include "exec/memory.h" #include "sysemu/sysemu.h" #include "exec/address-spaces.h" -#include "qemu/config-file.h" +#include "hw/boards.h" #include "hw/s390x/sclp.h" #include "hw/s390x/event-facility.h" #include "hw/s390x/s390-pci-bus.h"
@@ -31,19 +31,14 @@ static inline SCLPDevice *get_sclp_device(void)static void read_SCP_info (SCLPDevice *sclp,SCCB *sccb) {ReadInfo *read_info = (ReadInfo *) sccb; +MachineState *machine =MACHINE (qdev_get_machine ());sclpMemoryHotplugDev *mhd =get_sclp_memory_hotplug_dev ();CPUState *cpu;int cpu_count =0 ;int i =0 ;int increment_size =20 ;int rnsize, rnmax; -QemuOpts *opts =qemu_opts_find (qemu_find_opts ("memory" ),NULL ); -int slots =qemu_opt_get_number (opts,"slots" ,0 ); -int max_avail_slots =s390_get_memslot_count (kvm_state); - -if (slots > max_avail_slots) { - slots = max_avail_slots; - } +int slots =MIN (machine->ram_slots,s390_get_memslot_count (kvm_state));CPU_FOREACH (cpu) { cpu_count++;
Signature · 1 line
2.5.1
PATCH 7/23 pc-bios/s390-ccw: rebuild image
In reply to Cornelia HuckContains:
- Device detection in higher subchannel sets
--- pc-bios/s390-ccw.img | Bin 13784 -> 13856 bytes 1 file changed, 0 insertions(+), 0 deletions(-)
pc-bios/s390-ccw.img binary +0 -0
Signature · 1 line
2.5.1
PATCH 19/23 s390/sclp: ignore memory hotplug operations if it is disabled
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
If no memory hotplug device was created, the sclp command facility is not exposed (SCLP_FC_ASSIGN_ATTACH_READ_STOR). We therefore have no memory hotplug and should correctly report SCLP_RC_INVALID_SCLP_COMMAND if any such command is executed.
This gets rid of these ugly asserts that could have been triggered for the s390-virtio machine.
--- hw/s390x/sclp.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-)
hw/s390x/sclp.c +26 -7
@@ -130,7 +130,10 @@ static void read_storage_element0_info(SCLPDevice *sclp, SCCB *sccb)ReadStorageElementInfo *storage_info = (ReadStorageElementInfo *) sccb;sclpMemoryHotplugDev *mhd =get_sclp_memory_hotplug_dev (); -assert (mhd); +if (!mhd) { + sccb->h.response_code =cpu_to_be16 (SCLP_RC_INVALID_SCLP_COMMAND ); +return ; + }if ((ram_size >> mhd->increment_size) >=0x10000 ) { sccb->h.response_code =cpu_to_be16 (SCLP_RC_SCCB_BOUNDARY_VIOLATION );
@@ -154,7 +157,10 @@ static void read_storage_element1_info(SCLPDevice *sclp, SCCB *sccb)ReadStorageElementInfo *storage_info = (ReadStorageElementInfo *) sccb;sclpMemoryHotplugDev *mhd =get_sclp_memory_hotplug_dev (); -assert (mhd); +if (!mhd) { + sccb->h.response_code =cpu_to_be16 (SCLP_RC_INVALID_SCLP_COMMAND ); +return ; + }if ((mhd->standby_mem_size >> mhd->increment_size) >=0x10000 ) { sccb->h.response_code =cpu_to_be16 (SCLP_RC_SCCB_BOUNDARY_VIOLATION );
@@ -177,7 +183,10 @@ static void attach_storage_element(SCLPDevice *sclp, SCCB *sccb,AttachStorageElement *attach_info = (AttachStorageElement *) sccb;sclpMemoryHotplugDev *mhd =get_sclp_memory_hotplug_dev (); -assert (mhd); +if (!mhd) { + sccb->h.response_code =cpu_to_be16 (SCLP_RC_INVALID_SCLP_COMMAND ); +return ; + }if (element !=1 ) { sccb->h.response_code =cpu_to_be16 (SCLP_RC_INVALID_SCLP_COMMAND );
@@ -201,10 +210,15 @@ static void assign_storage(SCLPDevice *sclp, SCCB *sccb)uint64_t this_subregion_size;AssignStorage *assign_info = (AssignStorage *) sccb;sclpMemoryHotplugDev *mhd =get_sclp_memory_hotplug_dev (); -assert (mhd); -ram_addr_t assign_addr = (assign_info->rn -1 ) * mhd->rzm; +ram_addr_t assign_addr;MemoryRegion *sysmem =get_system_memory (); +if (!mhd) { + sccb->h.response_code =cpu_to_be16 (SCLP_RC_INVALID_SCLP_COMMAND ); +return ; + } + assign_addr = (assign_info->rn -1 ) * mhd->rzm; +if ((assign_addr %MEM_SECTION_SIZE ==0 ) && (assign_addr >= mhd->padded_ram_size)) {/* Re-use existing memory region if found */
@@ -255,10 +269,15 @@ static void unassign_storage(SCLPDevice *sclp, SCCB *sccb)MemoryRegion *mr =NULL ;AssignStorage *assign_info = (AssignStorage *) sccb;sclpMemoryHotplugDev *mhd =get_sclp_memory_hotplug_dev (); -assert (mhd); -ram_addr_t unassign_addr = (assign_info->rn -1 ) * mhd->rzm; +ram_addr_t unassign_addr;MemoryRegion *sysmem =get_system_memory (); +if (!mhd) { + sccb->h.response_code =cpu_to_be16 (SCLP_RC_INVALID_SCLP_COMMAND ); +return ; + } + unassign_addr = (assign_info->rn -1 ) * mhd->rzm; +/* if the addr is a multiple of 256 MB */ if ((unassign_addr %MEM_SECTION_SIZE ==0 ) && (unassign_addr >= mhd->padded_ram_size)) {
Signature · 1 line
2.5.1
PATCH 6/23 pc-bios/s390-ccw: Device detection in higher subchannel sets
In reply to Cornelia HuckFrom: Alexander Yarygin <[email protected]>
If no bootdevice was specified, we try to autodetect a suitable IPL device. Current code only searched in subchannel set 0; extend this search to higher subchannel sets as well.
--- pc-bios/s390-ccw/main.c | 66 ++++++++++++++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 25 deletions(-)
pc-bios/s390-ccw/main.c +41 -25
@@ -38,40 +38,56 @@ void virtio_panic(const char *string)while (1 ) { } } +static bool find_dev (struct schib *schib,int dev_no) +{ +int i, r; + +for (i =0 ; i <0x10000 ; i++) { + blk_schid.sch_no = i; + r =stsch_err (blk_schid, schib); +if ((r ==3 ) || (r == -EIO )) { +break ; + } +if (!schib->pmcw.dnv) { +continue ; + } +if (!virtio_is_blk (blk_schid)) { +continue ; + } +if ((dev_no <0 ) || (schib->pmcw.dev == dev_no)) { +return true; + } + } + +return false; +} +static void virtio_setup (uint64_t dev_info) {struct schib schib; -int i; -int r; +int ssid;bool found = false; -bool check_devno = false; -uint16_t dev_no =-1 ; +uint16_t dev_no; + +/* +* We unconditionally enable mss support. In every sane configuration, +* this will succeed; and even if it doesn't, stsch_err() can deal +* with the consequences. +*/ +enable_mss_facility ();if (dev_info !=-1 ) { - check_devno = true; dev_no = dev_info &0xffff ;debug_print_int ("device no. " , dev_no); blk_schid.ssid = (dev_info >>16 ) &0x3 ; -if (blk_schid.ssid !=0 ) { -debug_print_int ("ssid " , blk_schid.ssid); -if (enable_mss_facility () !=0 ) { -virtio_panic ("Failed to enable mss facility\n" ); - } - } - } - -for (i =0 ; i <0x10000 ; i++) { - blk_schid.sch_no = i; - r =stsch_err (blk_schid, &schib); -if (r ==3 ) { -break ; - } -if (schib.pmcw.dnv) { -if (!check_devno || (schib.pmcw.dev == dev_no)) { -if (virtio_is_blk (blk_schid)) { - found = true; -break ; - } +debug_print_int ("ssid " , blk_schid.ssid); + found =find_dev (&schib, dev_no); + }else { +for (ssid =0 ; ssid <0x3 ; ssid++) { + blk_schid.ssid = ssid; + found =find_dev (&schib,-1 ); +if (found) { +break ; } } }
Signature · 1 line
2.5.1
PATCH 10/23 sclp/s390: rework sclp cpu hotplug device notification
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
Let's get rid of this strange local variable + irq logic and work directly on the QOM. (hint: what happens if two such devices are created?)
We could introduce proper QOM class + state for the cpu hotplug device, however that would result in too much overhead for a simple "trigger_signal" function.
Also remove one unnecessary class function initialization.
--- hw/s390x/sclpcpu.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-)
hw/s390x/sclpcpu.c +6 -20
@@ -25,13 +25,16 @@ typedef struct ConfigMgtData {uint8_t event_qualifier; }QEMU_PACKED ConfigMgtData; -static qemu_irq *irq_cpu_hotplug;/* Only used in this file */ -#define EVENT_QUAL_CPU_CHANGE 1void raise_irq_cpu_hotplug (void ) { -qemu_irq_raise (*irq_cpu_hotplug); +Object *obj =object_resolve_path_type ("" ,TYPE_SCLP_CPU_HOTPLUG ,NULL ); + +SCLP_EVENT (obj)->event_pending = true; + +/* Trigger SCLP read operation */ +sclp_service_interrupt (0 ); }static unsigned int send_mask (void )
@@ -70,31 +73,14 @@ static int read_event_data(SCLPEvent *event, EventBufferHeader *evt_buf_hdr,return 1 ; } -static void trigger_signal (void *opaque,int n,int level) -{ -SCLPEvent *event = opaque; - event->event_pending = true; - -/* Trigger SCLP read operation */ -sclp_service_interrupt (0 ); -} - -static int irq_cpu_hotplug_init (SCLPEvent *event) -{ - irq_cpu_hotplug =qemu_allocate_irqs (trigger_signal, event,1 ); -return 0 ; -} -static void cpu_class_init (ObjectClass *oc,void *data) {SCLPEventClass *k =SCLP_EVENT_CLASS (oc);DeviceClass *dc =DEVICE_CLASS (oc); - k->init = irq_cpu_hotplug_init; k->get_send_mask = send_mask; k->get_receive_mask = receive_mask; k->read_event_data = read_event_data; - k->write_event_data =NULL ;set_bit (DEVICE_CATEGORY_MISC , dc->categories); }
Signature · 1 line
2.5.1
PATCH 14/23 s390/sclp: introduce a root sclp device
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
Let's create a root sclp device, which has other sclp devices as children (e.g. the event facility for now) and can later be used for migration of sclp specific attributes and setup of memory.
--- hw/s390x/sclp.c | 65 +++++++++++++++++++++++++++++++++------ include/hw/s390x/event-facility.h | 2 -- include/hw/s390x/sclp.h | 22 +++++++++++++ 3 files changed, 78 insertions(+), 11 deletions(-)
hw/s390x/sclp.c +56 -9
@@ -24,11 +24,8 @@static inline SCLPEventFacility *get_event_facility (void ) { -ObjectProperty *op =object_property_find (qdev_get_machine (), -TYPE_SCLP_EVENT_FACILITY , -NULL ); -assert (op); -return op->opaque; +return EVENT_FACILITY (object_resolve_path_type ("" ,TYPE_SCLP_EVENT_FACILITY , +NULL )); }/* Provide information about the configuration, CPUs and storage */
@@ -438,13 +435,62 @@ void sclp_service_interrupt(uint32_t sccb)void s390_sclp_init (void ) { -DeviceState *dev =qdev_create (NULL ,TYPE_SCLP_EVENT_FACILITY ); +Object *new =object_new (TYPE_SCLP ); -object_property_add_child (qdev_get_machine (),TYPE_SCLP_EVENT_FACILITY , -OBJECT (dev),NULL ); -qdev_init_nofail (dev); +object_property_add_child (qdev_get_machine (),TYPE_SCLP , new, +NULL ); +object_unref (OBJECT (new)); +qdev_init_nofail (DEVICE (new)); } +static void sclp_realize (DeviceState *dev,Error **errp) +{ +SCLPDevice *sclp =SCLP (dev); +Error *l_err =NULL ; + +object_property_set_bool (OBJECT (sclp->event_facility), true,"realized" , + &l_err); +if (l_err) { + goto error; + } +return ; +error: +assert (l_err); +error_propagate (errp, l_err); +} + +static void sclp_init (Object *obj) +{ +SCLPDevice *sclp =SCLP (obj); +Object *new; + + new =object_new (TYPE_SCLP_EVENT_FACILITY ); +object_property_add_child (obj,TYPE_SCLP_EVENT_FACILITY , new,NULL ); +/* qdev_device_add searches the sysbus for TYPE_SCLP_EVENTS_BUS */ +qdev_set_parent_bus (DEVICE (new),sysbus_get_default ()); +object_unref (new); + sclp->event_facility =EVENT_FACILITY (new); +} + +static void sclp_class_init (ObjectClass *oc,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (oc); + + dc->desc ="SCLP (Service-Call Logical Processor)" ; + dc->realize = sclp_realize; + dc->hotpluggable = false; +set_bit (DEVICE_CATEGORY_MISC , dc->categories); +} + +static TypeInfo sclp_info = { + .name =TYPE_SCLP , + .parent =TYPE_DEVICE , + .instance_init = sclp_init, + .instance_size =sizeof (SCLPDevice), + .class_init = sclp_class_init, + .class_size =sizeof (SCLPDeviceClass), +}; +sclpMemoryHotplugDev *init_sclp_memory_hotplug_dev (void ) {DeviceState *dev;
@@ -481,5 +527,6 @@ static TypeInfo sclp_memory_hotplug_dev_info = {static void register_types (void ) {type_register_static (&sclp_memory_hotplug_dev_info); +type_register_static (&sclp_info); }type_init (register_types);
include/hw/s390x/event-facility.h +0 -2
@@ -189,8 +189,6 @@ typedef struct SCLPEventClass {OBJECT_GET_CLASS (SCLPEventFacilityClass, (obj), \ TYPE_SCLP_EVENT_FACILITY) -typedef struct SCLPEventFacility SCLPEventFacility ; - typedef struct SCLPEventFacilityClass { SysBusDeviceClass parent_class; void (*command_handler)(SCLPEventFacility *ef, SCCB *sccb, uint64_t code);
include/hw/s390x/sclp.h +22 -0
@@ -163,6 +163,28 @@ typedef struct SCCB {char data[SCCB_DATA_LEN ]; }QEMU_PACKED SCCB ; +#define TYPE_SCLP "sclp" +#define SCLP (obj) OBJECT_CHECK(SCLPDevice, (obj), TYPE_SCLP) +#define SCLP_CLASS (oc) OBJECT_CLASS_CHECK(SCLPDeviceClass, (oc), TYPE_SCLP) +#define SCLP_GET_CLASS (obj) OBJECT_GET_CLASS(SCLPDeviceClass, (obj), TYPE_SCLP) + +typedef struct SCLPEventFacility SCLPEventFacility ; + +typedef struct SCLPDevice { +/* private */ +DeviceState parent_obj; +SCLPEventFacility *event_facility; + +/* public */ +}SCLPDevice ; + +typedef struct SCLPDeviceClass { +/* private */ +DeviceClass parent_class; + +/* public */ +}SCLPDeviceClass ; +typedef struct sclpMemoryHotplugDev sclpMemoryHotplugDev ;#define TYPE_SCLP_MEMORY_HOTPLUG_DEV "sclp-memory-hotplug-dev"
Signature · 1 line
2.5.1
PATCH 18/23 s390: disallow memory hotplug for the s390-virtio machine
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
That machine type doesn't currently support memory hotplug, so let's abort if it is requested. Reason is, that the virtio queues are allocated for now at the end of the initial ram - extending the ram is therefore not possible.
--- hw/s390x/s390-virtio.c | 5 +++++ 1 file changed, 5 insertions(+)
hw/s390x/s390-virtio.c +5 -0
@@ -23,6 +23,7 @@#include "hw/hw.h" #include "qapi/qmp/qerror.h" +#include "qemu/error-report.h" #include "sysemu/block-backend.h" #include "sysemu/blockdev.h" #include "sysemu/sysemu.h"
@@ -268,6 +269,10 @@ static void s390_init(MachineState *machine)hwaddr virtio_region_len;hwaddr virtio_region_start; +if (machine->ram_slots) { +error_report ("Memory hotplug not supported by the selected machine." ); +exit (EXIT_FAILURE ); + }/* * The storage increment size is a multiple of 1M and is a power of 2. * The number of storage increments must be MAX_STORAGE_INCREMENTS or
Signature · 1 line
2.5.1
PATCH 21/23 s390: unify allocation of initial memory
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
Now that the calculation of the initial memory is hidden in the sclp device, we can unify the allocation of the initial memory.
The remaining ugly part is the reserved memory for the virtio queues, but that can be cleaned up later.
--- hw/s390x/s390-virtio-ccw.c | 24 ++++++++++++++---------- hw/s390x/s390-virtio.c | 9 +-------- hw/s390x/s390-virtio.h | 1 + 3 files changed, 16 insertions(+), 18 deletions(-)
hw/s390x/s390-virtio-ccw.c +14 -10
@@ -100,15 +100,28 @@ static void virtio_ccw_register_hcalls(void) virtio_ccw_hcall_early_printk); } -static void ccw_init (MachineState *machine) +void s390_memory_init (ram_addr_t mem_size) {MemoryRegion *sysmem =get_system_memory ();MemoryRegion *ram =g_new (MemoryRegion,1 ); + +/* allocate RAM for core */ +memory_region_init_ram (ram,NULL ,"s390.ram" , mem_size, &error_abort); +vmstate_register_ram_global (ram); +memory_region_add_subregion (sysmem,0 , ram); + +/* Initialize storage key device */ +s390_skeys_init (); +} + +static void ccw_init (MachineState *machine) +{int ret;VirtualCssBus *css_bus;DeviceState *dev;s390_sclp_init (); +s390_memory_init (machine->ram_size);/* get a BUS */ css_bus =virtual_css_bus_init ();
@@ -124,15 +137,6 @@ static void ccw_init(MachineState *machine)/* register hypercalls */ virtio_ccw_register_hcalls (); -/* allocate RAM for core */ -memory_region_init_ram (ram,NULL ,"s390.ram" , machine->ram_size, - &error_abort); -vmstate_register_ram_global (ram); -memory_region_add_subregion (sysmem,0 , ram); - -/* Initialize storage key device */ -s390_skeys_init (); -/* init CPUs */ s390_init_cpus (machine->cpu_model);
hw/s390x/s390-virtio.c +1 -8
@@ -262,8 +262,6 @@ int gtod_load(QEMUFile *f, void *opaque, int version_id)static void s390_init (MachineState *machine) {ram_addr_t my_ram_size; -MemoryRegion *sysmem =get_system_memory (); -MemoryRegion *ram =g_new (MemoryRegion,1 );void *virtio_region;hwaddr virtio_region_len;hwaddr virtio_region_start;
@@ -285,9 +283,7 @@ static void s390_init(MachineState *machine)s390_virtio_register_hcalls ();/* allocate RAM */ -memory_region_init_ram (ram,NULL ,"s390.ram" , my_ram_size, &error_abort); -vmstate_register_ram_global (ram); -memory_region_add_subregion (sysmem,0 , ram); +s390_memory_init (my_ram_size);/* clear virtio region */ virtio_region_len = my_ram_size - ram_size;
@@ -298,9 +294,6 @@ static void s390_init(MachineState *machine)cpu_physical_memory_unmap (virtio_region, virtio_region_len,1 , virtio_region_len); -/* Initialize storage key device */ -s390_skeys_init (); -/* init CPUs */ s390_init_cpus (machine->cpu_model);
hw/s390x/s390-virtio.h +1 -0
@@ -27,4 +27,5 @@ void s390_init_ipl_dev(const char *kernel_filename, bool enforce_bios);void s390_create_virtio_net (BusState *bus,const char *name);void s390_nmi (NMIState *n,int cpu_index,Error **errp); +void s390_memory_init (ram_addr_t mem_size);#endif
Signature · 1 line
2.5.1
PATCH 15/23 s390/sclp: move sclp_execute related functions into the SCLP class
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
Let's move the sclp_execute related functions into the SCLP class and pass the device state as parameter, so we have easy access to the SCLPDevice later on.
--- hw/s390x/sclp.c | 53 +++++++++++++++++++++++++++++++++---------------- include/hw/s390x/sclp.h | 9 +++++++++ 2 files changed, 45 insertions(+), 17 deletions(-)
hw/s390x/sclp.c +36 -17
@@ -28,8 +28,13 @@ static inline SCLPEventFacility *get_event_facility(void) NULL)); } +static inline SCLPDevice *get_sclp_device (void ) +{ +return SCLP (object_resolve_path_type ("" ,TYPE_SCLP ,NULL )); +} +/* Provide information about the configuration, CPUs and storage */ -static void read_SCP_info (SCCB *sccb) +static void read_SCP_info (SCLPDevice *sclp,SCCB *sccb) {ReadInfo *read_info = (ReadInfo *) sccb;sclpMemoryHotplugDev *mhd =get_sclp_memory_hotplug_dev ();
@@ -129,7 +134,7 @@ static void read_SCP_info(SCCB *sccb) sccb->h.response_code =cpu_to_be16 (SCLP_RC_NORMAL_READ_COMPLETION ); } -static void read_storage_element0_info (SCCB *sccb) +static void read_storage_element0_info (SCLPDevice *sclp,SCCB *sccb) {int i, assigned;int subincrement_id =SCLP_STARTING_SUBINCREMENT_ID ;
@@ -155,7 +160,7 @@ static void read_storage_element0_info(SCCB *sccb) sccb->h.response_code =cpu_to_be16 (SCLP_RC_NORMAL_READ_COMPLETION ); } -static void read_storage_element1_info (SCCB *sccb) +static void read_storage_element1_info (SCLPDevice *sclp,SCCB *sccb) {ReadStorageElementInfo *storage_info = (ReadStorageElementInfo *) sccb;sclpMemoryHotplugDev *mhd =get_sclp_memory_hotplug_dev ();
@@ -176,7 +181,8 @@ static void read_storage_element1_info(SCCB *sccb) sccb->h.response_code =cpu_to_be16 (SCLP_RC_STANDBY_READ_COMPLETION ); } -static void attach_storage_element (SCCB *sccb,uint16_t element) +static void attach_storage_element (SCLPDevice *sclp,SCCB *sccb, +uint16_t element) {int i, assigned, subincrement_id;AttachStorageElement *attach_info = (AttachStorageElement *) sccb;
@@ -200,7 +206,7 @@ static void attach_storage_element(SCCB *sccb, uint16_t element) sccb->h.response_code =cpu_to_be16 (SCLP_RC_NORMAL_COMPLETION ); } -static void assign_storage (SCCB *sccb) +static void assign_storage (SCLPDevice *sclp,SCCB *sccb) {MemoryRegion *mr =NULL ;uint64_t this_subregion_size;
@@ -255,7 +261,7 @@ static void assign_storage(SCCB *sccb) sccb->h.response_code =cpu_to_be16 (SCLP_RC_NORMAL_COMPLETION ); } -static void unassign_storage (SCCB *sccb) +static void unassign_storage (SCLPDevice *sclp,SCCB *sccb) {MemoryRegion *mr =NULL ;AssignStorage *assign_info = (AssignStorage *) sccb;
@@ -299,7 +305,7 @@ static void unassign_storage(SCCB *sccb) }/* Provide information about the CPU */ -static void sclp_read_cpu_info (SCCB *sccb) +static void sclp_read_cpu_info (SCLPDevice *sclp,SCCB *sccb) {ReadCpuInfo *cpu_info = (ReadCpuInfo *) sccb;CPUState *cpu;
@@ -326,34 +332,35 @@ static void sclp_read_cpu_info(SCCB *sccb) sccb->h.response_code =cpu_to_be16 (SCLP_RC_NORMAL_READ_COMPLETION ); } -static void sclp_execute (SCCB *sccb,uint32_t code) +static void sclp_execute (SCLPDevice *sclp,SCCB *sccb,uint32_t code) { -SCLPEventFacility *ef =get_event_facility (); +SCLPDeviceClass *sclp_c =SCLP_GET_CLASS (sclp); +SCLPEventFacility *ef = sclp->event_facility;SCLPEventFacilityClass *efc =EVENT_FACILITY_GET_CLASS (ef);switch (code &SCLP_CMD_CODE_MASK ) {case SCLP_CMDW_READ_SCP_INFO :case SCLP_CMDW_READ_SCP_INFO_FORCED : -read_SCP_info (sccb); + sclp_c->read_SCP_info (sclp, sccb);break ;case SCLP_CMDW_READ_CPU_INFO : -sclp_read_cpu_info (sccb); + sclp_c->read_cpu_info (sclp, sccb);break ;case SCLP_READ_STORAGE_ELEMENT_INFO :if (code &0xff00 ) { -read_storage_element1_info (sccb); + sclp_c->read_storage_element1_info (sclp, sccb); }else { -read_storage_element0_info (sccb); + sclp_c->read_storage_element0_info (sclp, sccb); }break ;case SCLP_ATTACH_STORAGE_ELEMENT : -attach_storage_element (sccb, (code &0xff00 ) >>8 ); + sclp_c->attach_storage_element (sclp, sccb, (code &0xff00 ) >>8 );break ;case SCLP_ASSIGN_STORAGE : -assign_storage (sccb); + sclp_c->assign_storage (sclp, sccb);break ;case SCLP_UNASSIGN_STORAGE : -unassign_storage (sccb); + sclp_c->unassign_storage (sclp, sccb);break ;case SCLP_CMDW_CONFIGURE_PCI :s390_pci_sclp_configure (1 , sccb);
@@ -369,6 +376,8 @@ static void sclp_execute(SCCB *sccb, uint32_t code)int sclp_service_call (CPUS390XState *env,uint64_t sccb,uint32_t code) { +SCLPDevice *sclp =get_sclp_device (); +SCLPDeviceClass *sclp_c =SCLP_GET_CLASS (sclp);int r =0 ;SCCB work_sccb;
@@ -403,7 +412,7 @@ int sclp_service_call(CPUS390XState *env, uint64_t sccb, uint32_t code) goto out; } -sclp_execute ((SCCB *)&work_sccb, code); + sclp_c->execute (sclp, (SCCB *)&work_sccb, code);cpu_physical_memory_write (sccb, &work_sccb,be16_to_cpu (work_sccb.h.length));
@@ -474,12 +483,22 @@ static void sclp_init(Object *obj)static void sclp_class_init (ObjectClass *oc,void *data) { +SCLPDeviceClass *sc =SCLP_CLASS (oc);DeviceClass *dc =DEVICE_CLASS (oc); dc->desc ="SCLP (Service-Call Logical Processor)" ; dc->realize = sclp_realize; dc->hotpluggable = false;set_bit (DEVICE_CATEGORY_MISC , dc->categories); + + sc->read_SCP_info = read_SCP_info; + sc->read_storage_element0_info = read_storage_element0_info; + sc->read_storage_element1_info = read_storage_element1_info; + sc->attach_storage_element = attach_storage_element; + sc->assign_storage = assign_storage; + sc->unassign_storage = unassign_storage; + sc->read_cpu_info = sclp_read_cpu_info; + sc->execute = sclp_execute; }static TypeInfo sclp_info = {
include/hw/s390x/sclp.h +9 -0
@@ -181,8 +181,17 @@ typedef struct SCLPDevice {typedef struct SCLPDeviceClass {/* private */ DeviceClass parent_class; +void (*read_SCP_info)(SCLPDevice *sclp,SCCB *sccb); +void (*read_storage_element0_info)(SCLPDevice *sclp,SCCB *sccb); +void (*read_storage_element1_info)(SCLPDevice *sclp,SCCB *sccb); +void (*attach_storage_element)(SCLPDevice *sclp,SCCB *sccb, +uint16_t element); +void (*assign_storage)(SCLPDevice *sclp,SCCB *sccb); +void (*unassign_storage)(SCLPDevice *sclp,SCCB *sccb); +void (*read_cpu_info)(SCLPDevice *sclp,SCCB *sccb);/* public */ +void (*execute)(SCLPDevice *sclp,SCCB *sccb,uint32_t code); }SCLPDeviceClass ;typedef struct sclpMemoryHotplugDev sclpMemoryHotplugDev ;
Signature · 1 line
2.5.1
PATCH 9/23 s390x/gdb: support reading/writing of control registers
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
Let's support reading and writing of control registers for kvm and tcg.
We have to take care of flushing the tlb (tcg) and pushing the changed registers into kvm.
--- configure | 2 +- gdb-xml/s390-cr.xml | 26 ++++++++++++++++++++++++++ target-s390x/gdbstub.c | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 gdb-xml/s390-cr.xml
configure +1 -1
@@ -5384,7 +5384,7 @@ case "$target_name" in echo "TARGET_ABI32=y" >> $config_target_mak ;; s390x) - gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml" + gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml" ;; tricore) ;;
gdb-xml/s390-cr.xml new file +26 -0
@@ -0,0 +1,26 @@ +<?xml version="1.0"?> +<!-- Copyright 2015 IBM Corp. + + This work is licensed under the terms of the GNU GPL, version 2 or + (at your option) any later version. See the COPYING file in the + top-level directory. --> + +<!DOCTYPE feature SYSTEM "gdb-target.dtd"> +<feature name="org.gnu.gdb.s390.cr"> + <reg name="cr0" bitsize="64" type="uint64" group="control"/> + <reg name="cr1" bitsize="64" type="uint64" group="control"/> + <reg name="cr2" bitsize="64" type="uint64" group="control"/> + <reg name="cr3" bitsize="64" type="uint64" group="control"/> + <reg name="cr4" bitsize="64" type="uint64" group="control"/> + <reg name="cr5" bitsize="64" type="uint64" group="control"/> + <reg name="cr6" bitsize="64" type="uint64" group="control"/> + <reg name="cr7" bitsize="64" type="uint64" group="control"/> + <reg name="cr8" bitsize="64" type="uint64" group="control"/> + <reg name="cr9" bitsize="64" type="uint64" group="control"/> + <reg name="cr10" bitsize="64" type="uint64" group="control"/> + <reg name="cr11" bitsize="64" type="uint64" group="control"/> + <reg name="cr12" bitsize="64" type="uint64" group="control"/> + <reg name="cr13" bitsize="64" type="uint64" group="control"/> + <reg name="cr14" bitsize="64" type="uint64" group="control"/> + <reg name="cr15" bitsize="64" type="uint64" group="control"/> +</feature>
target-s390x/gdbstub.c +39 -0
@@ -174,6 +174,39 @@ static int cpu_write_vreg(CPUS390XState *env, uint8_t *mem_buf, int n) } } +/* the values represent the positions in s390-cr.xml */ +#define S390_C0_REGNUM 0 +#define S390_C15_REGNUM 15 +/* total number of registers in s390-cr.xml */ +#define S390_NUM_C_REGS 16 + +#ifndef CONFIG_USER_ONLY +static int cpu_read_c_reg (CPUS390XState *env,uint8_t *mem_buf,int n) +{ +switch (n) { + case S390_C0_REGNUM ... S390_C15_REGNUM: +return gdb_get_regl (mem_buf, env->cregs[n]); +default : +return 0 ; + } +} + +static int cpu_write_c_reg (CPUS390XState *env,uint8_t *mem_buf,int n) +{ +switch (n) { + case S390_C0_REGNUM ... S390_C15_REGNUM: + env->cregs[n] =ldtul_p (mem_buf); +if (tcg_enabled ()) { +tlb_flush (ENV_GET_CPU (env),1 ); + } +cpu_synchronize_post_init (ENV_GET_CPU (env)); +return 8 ; +default : +return 0 ; + } +} +#endif +void s390_cpu_gdb_init (CPUState *cs) { gdb_register_coprocessor(cs, cpu_read_ac_reg,
@@ -187,4 +220,10 @@ void s390_cpu_gdb_init(CPUState *cs)gdb_register_coprocessor (cs, cpu_read_vreg, cpu_write_vreg,S390_NUM_VREGS ,"s390-vx.xml" ,0 ); + +#ifndef CONFIG_USER_ONLY +gdb_register_coprocessor (cs, cpu_read_c_reg, + cpu_write_c_reg, +S390_NUM_C_REGS ,"s390-cr.xml" ,0 ); +#endif }
Signature · 1 line
2.5.1
PATCH 4/23 s390x/css: start with cleared cstat/dstat
In reply to Cornelia HuckWhen executing the start function, we should start with a clear state regarding subchannel and device status; it is easy to forget updating one of them after the ccw has been processed.
Note that we don't need to care about resetting the various control
fields: They are cleared by tsch(), and if they were still pending, we wouldn't be able to execute the start function in the first place.
Also note that we don't want to clear cstat/dstat if a suspended subchannel is resumed.
This fixes a bug where we would continue to present channel-program check in cstat even though later ccw requests for the subchannel finished without error (i.e. cstat should be 0).
--- hw/s390x/css.c | 2 ++ 1 file changed, 2 insertions(+)
hw/s390x/css.c +2 -0
@@ -399,6 +399,8 @@ static void sch_handle_start_func(SubchDev *sch, ORB *orb) path =0x80 ;if (!(s->ctrl &SCSW_ACTL_SUSP )) { + s->cstat =0 ; + s->dstat =0 ;/* Look at the orb and try to execute the channel program. */ assert (orb !=NULL );/* resume does not pass an orb */ p->intparm = orb->intparm;
Signature · 1 line
2.5.1
PATCH 12/23 s390/sclp: replace sclp event types with proper defines
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
Introduce TYPE_SCLP_QUIESCE and make use of it. Also use TYPE_SCLP_CPU_HOTPLUG where applicable.
--- hw/s390x/event-facility.c | 2 +- hw/s390x/sclpcpu.c | 2 +- hw/s390x/sclpquiesce.c | 4 ++-- include/hw/s390x/event-facility.h | 1 + 4 files changed, 5 insertions(+), 4 deletions(-)
hw/s390x/event-facility.c +1 -1
@@ -353,7 +353,7 @@ static void init_event_facility(Object *obj) TYPE_SCLP_EVENTS_BUS, sdev, NULL);object_initialize (&event_facility->quiesce_event,sizeof (SCLPEvent), -"sclpquiesce" ); +TYPE_SCLP_QUIESCE );qdev_set_parent_bus (DEVICE (&event_facility->quiesce_event), &event_facility->sbus.qbus); object_initialize(&event_facility->cpu_hotplug_event, sizeof(SCLPEvent),
hw/s390x/sclpcpu.c +1 -1
@@ -85,7 +85,7 @@ static void cpu_class_init(ObjectClass *oc, void *data) }static const TypeInfo sclp_cpu_info = { - .name ="sclp-cpu-hotplug" , + .name =TYPE_SCLP_CPU_HOTPLUG , .parent =TYPE_SCLP_EVENT , .instance_size =sizeof (SCLPEvent), .class_init = cpu_class_init,
hw/s390x/sclpquiesce.c +2 -2
@@ -66,7 +66,7 @@ static int read_event_data(SCLPEvent *event, EventBufferHeader *evt_buf_hdr, }static const VMStateDescription vmstate_sclpquiesce = { - .name ="sclpquiesce" , + .name =TYPE_SCLP_QUIESCE , .version_id =0 , .minimum_version_id =0 , .fields = (VMStateField []) {
@@ -127,7 +127,7 @@ static void quiesce_class_init(ObjectClass *klass, void *data) }static const TypeInfo sclp_quiesce_info = { - .name ="sclpquiesce" , + .name =TYPE_SCLP_QUIESCE , .parent =TYPE_SCLP_EVENT , .instance_size =sizeof (SCLPEvent), .class_init = quiesce_class_init,
include/hw/s390x/event-facility.h +1 -0
@@ -47,6 +47,7 @@ OBJECT_GET_CLASS(SCLPEventClass, (obj), TYPE_SCLP_EVENT)#define TYPE_SCLP_CPU_HOTPLUG "sclp-cpu-hotplug" +#define TYPE_SCLP_QUIESCE "sclpquiesce" typedef struct WriteEventMask { SCCBHeader h;
Signature · 1 line
2.5.1
PATCH 20/23 s390: move memory calculation into the sclp device
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
The restrictions for memory calculation belong to the sclp device.
Let's move the calculation to that point, so we are able to unify it for both s390 machines. The sclp device is the first device to be initialized. It performs the calculation and safely stores it in the machine, where other parts of the system can access an reuse it.
The memory hotplug device is now only created when it is really needed.
--- hw/s390x/s390-virtio-ccw.c | 54 +++------------------------------------- hw/s390x/s390-virtio.c | 18 +++----------- hw/s390x/sclp.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 66 deletions(-)
hw/s390x/s390-virtio-ccw.c +3 -51
@@ -102,54 +102,16 @@ static void virtio_ccw_register_hcalls(void)static void ccw_init (MachineState *machine) { -ram_addr_t my_ram_size = machine->ram_size;MemoryRegion *sysmem =get_system_memory ();MemoryRegion *ram =g_new (MemoryRegion,1 ); -sclpMemoryHotplugDev *mhd =init_sclp_memory_hotplug_dev ();int ret;VirtualCssBus *css_bus;DeviceState *dev; -ram_addr_t pad_size =0 ; -ram_addr_t maxmem = machine->maxram_size; -ram_addr_t standby_mem_size = maxmem - my_ram_size; -uint64_t kvm_limit; - -/* The storage increment size is a multiple of 1M and is a power of 2. -* The number of storage increments must be MAX_STORAGE_INCREMENTS or fewer. -* The variable 'mhd->increment_size' is an exponent of 2 that can be -* used to calculate the size (in bytes) of an increment. */ - mhd->increment_size =20 ; -while ((my_ram_size >> mhd->increment_size) >MAX_STORAGE_INCREMENTS ) { - mhd->increment_size++; - } -while ((standby_mem_size >> mhd->increment_size) >MAX_STORAGE_INCREMENTS ) { - mhd->increment_size++; - } -/* The core and standby memory areas need to be aligned with -* the increment size. In effect, this can cause the -* user-specified memory size to be rounded down to align -* with the nearest increment boundary. */ - standby_mem_size = standby_mem_size >> mhd->increment_size - << mhd->increment_size; - my_ram_size = my_ram_size >> mhd->increment_size - << mhd->increment_size; - -/* let's propagate the changed ram size into the global variable. */ - ram_size = my_ram_size; - machine->maxram_size = my_ram_size + standby_mem_size; - - ret =s390_set_memory_limit (machine->maxram_size, &kvm_limit); -if (ret == -E2BIG ) { -hw_error ("qemu: host supports a maximum of %" PRIu64" GB" , - kvm_limit >>30 ); - }else if (ret) { -hw_error ("qemu: setting the guest size failed" ); - } +s390_sclp_init ();/* get a BUS */ css_bus =virtual_css_bus_init (); -s390_sclp_init ();s390_init_ipl_dev (machine->kernel_filename, machine->kernel_cmdline, machine->initrd_filename,"s390-ccw.img" , true);s390_flic_init ();
@@ -163,21 +125,11 @@ static void ccw_init(MachineState *machine)virtio_ccw_register_hcalls ();/* allocate RAM for core */ -memory_region_init_ram (ram,NULL ,"s390.ram" , my_ram_size, &error_abort); +memory_region_init_ram (ram,NULL ,"s390.ram" , machine->ram_size, + &error_abort);vmstate_register_ram_global (ram);memory_region_add_subregion (sysmem,0 , ram); -/* If the size of ram is not on a MEM_SECTION_SIZE boundary, -calculate the pad size necessary to force this boundary. */ -if (standby_mem_size) { -if (my_ram_size %MEM_SECTION_SIZE ) { - pad_size =MEM_SECTION_SIZE - my_ram_size %MEM_SECTION_SIZE ; - } - my_ram_size += standby_mem_size + pad_size; - mhd->pad_size = pad_size; - mhd->standby_mem_size = standby_mem_size; - } -/* Initialize storage key device */ s390_skeys_init ();
hw/s390x/s390-virtio.c +3 -15
@@ -261,10 +261,9 @@ int gtod_load(QEMUFile *f, void *opaque, int version_id)/* PC hardware initialisation */ static void s390_init (MachineState *machine) { -ram_addr_t my_ram_size = machine->ram_size; +ram_addr_t my_ram_size;MemoryRegion *sysmem =get_system_memory ();MemoryRegion *ram =g_new (MemoryRegion,1 ); -int increment_size =20 ;void *virtio_region;hwaddr virtio_region_len;hwaddr virtio_region_start;
@@ -273,22 +272,11 @@ static void s390_init(MachineState *machine)error_report ("Memory hotplug not supported by the selected machine." );exit (EXIT_FAILURE ); } -/* -* The storage increment size is a multiple of 1M and is a power of 2. -* The number of storage increments must be MAX_STORAGE_INCREMENTS or -* fewer. -*/ -while ((my_ram_size >> increment_size) >MAX_STORAGE_INCREMENTS ) { - increment_size++; - } - my_ram_size = my_ram_size >> increment_size << increment_size; - -/* let's propagate the changed ram size into the global variable. */ - ram_size = my_ram_size; +s390_sclp_init (); + my_ram_size = machine->ram_size;/* get a BUS */ s390_bus =s390_virtio_bus_init (&my_ram_size); -s390_sclp_init ();s390_init_ipl_dev (machine->kernel_filename, machine->kernel_cmdline, machine->initrd_filename,ZIPL_FILENAME , false);s390_flic_init ();
hw/s390x/sclp.c +62 -0
88 lines not on this page · raw message
Signature · 1 line
2.5.1
PATCH 22/23 s390/sclp: store the increment_size in the sclp device
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
Let's calculate it once and reuse it.
--- hw/s390x/sclp.c | 20 +++----------------- include/hw/s390x/sclp.h | 1 + 2 files changed, 4 insertions(+), 17 deletions(-)
hw/s390x/sclp.c +3 -17
@@ -36,7 +36,6 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb)CPUState *cpu;int cpu_count =0 ;int i =0 ; -int increment_size =20 ;int rnsize, rnmax;int slots =MIN (machine->ram_slots,s390_get_memslot_count (kvm_state));
@@ -57,23 +56,9 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) read_info->facilities =cpu_to_be64 (SCLP_HAS_CPU_INFO |SCLP_HAS_PCI_RECONFIG ); -/* -* The storage increment size is a multiple of 1M and is a power of 2. -* The number of storage increments must be MAX_STORAGE_INCREMENTS or fewer. -*/ -while ((ram_size >> increment_size) >MAX_STORAGE_INCREMENTS ) { - increment_size++; - } - rnmax = ram_size >> increment_size; - + rnmax = ram_size >> sclp->increment_size;/* Memory Hotplug is only supported for the ccw machine type */ if (mhd) { -while ((mhd->standby_mem_size >> increment_size) > -MAX_STORAGE_INCREMENTS ) { - increment_size++; - } -assert (increment_size == mhd->increment_size); - mhd->standby_subregion_size =MEM_SECTION_SIZE ;/* Deduct the memory slot already used for core */ if (slots >0 ) {
@@ -105,7 +90,7 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) read_info->facilities |=cpu_to_be64 (SCLP_FC_ASSIGN_ATTACH_READ_STOR ); } - rnsize =1 << (increment_size -20 ); + rnsize =1 << (sclp->increment_size -20 );if (rnsize <=128 ) { read_info->rnsize = rnsize; }else {
@@ -518,6 +503,7 @@ static void sclp_memory_init(SCLPDevice *sclp) increment_size++; } } + sclp->increment_size = increment_size;/* The core and standby memory areas need to be aligned with * the increment size. In effect, this can cause the
include/hw/s390x/sclp.h +1 -0
@@ -174,6 +174,7 @@ typedef struct SCLPDevice {/* private */ DeviceState parent_obj;SCLPEventFacility *event_facility; +int increment_size;/* public */ } SCLPDevice;
Signature · 1 line
2.5.1
PATCH 23/23 s390/sclp: simplify calculation of rnmax
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
rnmax can be directly calculated using machine->maxram_size.
--- hw/s390x/sclp.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
hw/s390x/sclp.c +1 -3
@@ -56,7 +56,6 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) read_info->facilities =cpu_to_be64 (SCLP_HAS_CPU_INFO |SCLP_HAS_PCI_RECONFIG ); - rnmax = ram_size >> sclp->increment_size;/* Memory Hotplug is only supported for the ccw machine type */ if (mhd) { mhd->standby_subregion_size =MEM_SECTION_SIZE ;
@@ -84,8 +83,6 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) } mhd->padded_ram_size = ram_size + mhd->pad_size; mhd->rzm =1 << mhd->increment_size; - rnmax = ((ram_size + mhd->standby_mem_size + mhd->pad_size) - >> mhd->increment_size); read_info->facilities |=cpu_to_be64 (SCLP_FC_ASSIGN_ATTACH_READ_STOR ); }
@@ -98,6 +95,7 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) read_info->rnsize2 =cpu_to_be32 (rnsize); } + rnmax = machine->maxram_size >> sclp->increment_size;if (rnmax <0x10000 ) { read_info->rnmax =cpu_to_be16 (rnmax); }else {
Signature · 1 line
2.5.1