First set of s390x patches for 2.6
cover First set of s390x patches for 2.6
This first round of s390x patches includes:
- new compat machine
- remove the old s390-virtio machine (would like an ack from Alex on this)
- a fix and some cleanup
Note: I won't send a pull request before my year's end vacation, i.e. not before next year.
Cornelia Huck (2):
s390x: add 2.6 compat machine
s390x/virtio: use qemu_check_nic_model()
Pierre Morel (2):
s390x: remove s390-virtio machine
s390x: remove s390-virtio devices
Yi Min Zhao (2):
s390x/pci: reject some operations to disabled PCI function s390x/pci: code cleanup
hw/s390x/Makefile.objs | 2 +- hw/s390x/s390-pci-bus.c | 6 +- hw/s390x/s390-pci-bus.h | 1 + hw/s390x/s390-pci-inst.c | 17 +- hw/s390x/s390-virtio-bus.c | 758 --------------------------------------------- hw/s390x/s390-virtio-bus.h | 186 ----------- hw/s390x/s390-virtio-ccw.c | 18 +- hw/s390x/s390-virtio.c | 168 +--------- target-s390x/cpu.h | 3 - target-s390x/helper.c | 2 +- vl.c | 7 +- 11 files changed, 34 insertions(+), 1134 deletions(-) delete mode 100644 hw/s390x/s390-virtio-bus.c delete mode 100644 hw/s390x/s390-virtio-bus.h
Signature · 1 line
2.6.4
PATCH 1/6 s390x: add 2.6 compat machine
New qemu version, new machine.
--- hw/s390x/s390-virtio-ccw.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
hw/s390x/s390-virtio-ccw.c +16 -2
@@ -297,9 +297,7 @@ static void ccw_machine_2_5_class_init(ObjectClass *oc, void *data) {MachineClass *mc =MACHINE_CLASS (oc); - mc->alias ="s390-ccw-virtio" ; mc->desc ="VirtIO-ccw based S390 machine v2.5" ; - mc->is_default =1 ; }static const TypeInfo ccw_machine_2_5_info = {
@@ -308,11 +306,27 @@ static const TypeInfo ccw_machine_2_5_info = { .class_init = ccw_machine_2_5_class_init, }; +static void ccw_machine_2_6_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); + + mc->alias ="s390-ccw-virtio" ; + mc->desc ="VirtIO-ccw based S390 machine v2.6" ; + mc->is_default =1 ; +} + +static const TypeInfo ccw_machine_2_6_info = { + .name =MACHINE_TYPE_NAME ("s390-ccw-virtio-2.6" ), + .parent =TYPE_S390_CCW_MACHINE , + .class_init = ccw_machine_2_6_class_init, +}; +static void ccw_machine_register_types (void ) {type_register_static (&ccw_machine_info);type_register_static (&ccw_machine_2_4_info);type_register_static (&ccw_machine_2_5_info); +type_register_static (&ccw_machine_2_6_info); }type_init (ccw_machine_register_types)
Signature · 1 line
2.6.4
PATCH 2/6 s390x: remove s390-virtio machine
In reply to Cornelia HuckFrom: Pierre Morel <[email protected]>
Remove machine code for the s390-virtio machine, but keep functions useful for the ccw machine.
--- hw/s390x/s390-virtio.c | 162 ------------------------------------------------- 1 file changed, 162 deletions(-)
hw/s390x/s390-virtio.c +0 -162
@@ -61,7 +61,6 @@#define S390_TOD_CLOCK_VALUE_MISSING 0x00#define S390_TOD_CLOCK_VALUE_PRESENT 0x01 -static VirtIOS390Bus *s390_bus;static S390CPU **ipi_states;S390CPU *s390_cpu_addr2state (uint16_t cpu_addr)
@@ -73,78 +72,6 @@ S390CPU *s390_cpu_addr2state(uint16_t cpu_addr)return ipi_states[cpu_addr]; } -static int s390_virtio_hcall_notify (const uint64_t *args) -{ -uint64_t mem = args[0 ]; -int r =0 , i; - -if (mem > ram_size) { -VirtIOS390Device *dev =s390_virtio_bus_find_vring (s390_bus, mem, &i); -if (dev) { -/* -* Older kernels will use the virtqueue before setting DRIVER_OK. -* In this case the feature bits are not yet up to date, meaning -* that several funny things can happen, e.g. the guest thinks -* EVENT_IDX is on and QEMU thinks it is off. Let's force a feature -* and status sync. -*/ -if (!(dev->vdev->status &VIRTIO_CONFIG_S_DRIVER_OK )) { -s390_virtio_device_update_status (dev); - } -virtio_queue_notify (dev->vdev, i); - }else { - r = -EINVAL ; - } - }else { -/* Early printk */ - } -return r; -} - -static int s390_virtio_hcall_reset (const uint64_t *args) -{ -uint64_t mem = args[0 ]; -VirtIOS390Device *dev; - - dev =s390_virtio_bus_find_mem (s390_bus, mem); -if (dev ==NULL ) { -return -EINVAL ; - } -virtio_reset (dev->vdev); -address_space_stb (&address_space_memory, - dev->dev_offs +VIRTIO_DEV_OFFS_STATUS ,0 , -MEMTXATTRS_UNSPECIFIED ,NULL ); -s390_virtio_device_sync (dev); -s390_virtio_reset_idx (dev); - -return 0 ; -} - -static int s390_virtio_hcall_set_status (const uint64_t *args) -{ -uint64_t mem = args[0 ]; -int r =0 ; -VirtIOS390Device *dev; - - dev =s390_virtio_bus_find_mem (s390_bus, mem); -if (dev) { -s390_virtio_device_update_status (dev); - }else { - r = -EINVAL ; - } -return r; -} - -static void s390_virtio_register_hcalls (void ) -{ -s390_register_virtio_hypercall (KVM_S390_VIRTIO_NOTIFY , - s390_virtio_hcall_notify); -s390_register_virtio_hypercall (KVM_S390_VIRTIO_RESET , - s390_virtio_hcall_reset); -s390_register_virtio_hypercall (KVM_S390_VIRTIO_SET_STATUS , - s390_virtio_hcall_set_status); -} - void s390_init_ipl_dev(const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename,
@@ -261,58 +188,6 @@ int gtod_load(QEMUFile *f, void *opaque, int version_id)return 0 ; } -/* PC hardware initialisation */ -static void s390_init (MachineState *machine) -{ -ram_addr_t my_ram_size; -void *virtio_region; -hwaddr virtio_region_len; -hwaddr virtio_region_start; - -if (!qtest_enabled ()) { -error_printf ("WARNING\n" -"The s390-virtio machine (non-ccw) is deprecated.\n" -"It will be removed in 2.6. Please use s390-ccw-virtio\n" ); - } - -if (machine->ram_slots) { -error_report ("Memory hotplug not supported by the selected machine." ); -exit (EXIT_FAILURE ); - } -s390_sclp_init (); - my_ram_size = machine->ram_size; - -/* get a BUS */ - s390_bus =s390_virtio_bus_init (&my_ram_size); -s390_init_ipl_dev (machine->kernel_filename, machine->kernel_cmdline, - machine->initrd_filename,ZIPL_FILENAME , false); -s390_flic_init (); - -/* register hypercalls */ -s390_virtio_register_hcalls (); - -/* allocate RAM */ -s390_memory_init (my_ram_size); - -/* clear virtio region */ - virtio_region_len = my_ram_size - ram_size; - virtio_region_start = ram_size; - virtio_region =cpu_physical_memory_map (virtio_region_start, - &virtio_region_len, true); -memset (virtio_region,0 , virtio_region_len); -cpu_physical_memory_unmap (virtio_region, virtio_region_len,1 , - virtio_region_len); - -/* init CPUs */ -s390_init_cpus (machine->cpu_model); - -/* Create VirtIO network adapters */ -s390_create_virtio_net ((BusState *)s390_bus,"virtio-net-s390" ); - -/* Register savevm handler for guest TOD clock */ -register_savevm (NULL ,"todclock" ,0 ,1 , gtod_save, gtod_load,NULL ); -} -void s390_nmi (NMIState *n,int cpu_index,Error **errp) {CPUState *cs =qemu_get_cpu (cpu_index);
@@ -334,40 +209,3 @@ void s390_machine_reset(void)s390_ipl_prepare_cpu (ipl_cpu);s390_cpu_set_state (CPU_STATE_OPERATING , ipl_cpu); } - -static void s390_machine_class_init (ObjectClass *oc,void *data) -{ -MachineClass *mc =MACHINE_CLASS (oc); -NMIClass *nc =NMI_CLASS (oc); - - mc->alias ="s390" ; - mc->desc ="VirtIO based S390 machine (deprecated)" ; - mc->init = s390_init; - mc->reset = s390_machine_reset; - mc->block_default_type =IF_VIRTIO ; - mc->max_cpus =255 ; - mc->no_serial =1 ; - mc->no_parallel =1 ; - mc->use_virtcon =1 ; - mc->no_floppy =1 ; - mc->no_cdrom =1 ; - mc->no_sdcard =1 ; - nc->nmi_monitor_handler = s390_nmi; -} - -static const TypeInfo s390_machine_info = { - .name =TYPE_S390_MACHINE , - .parent =TYPE_MACHINE , - .class_init = s390_machine_class_init, - .interfaces = (InterfaceInfo []) { - {TYPE_NMI }, - { } - }, -}; - -static void s390_machine_register_types (void ) -{ -type_register_static (&s390_machine_info); -} - -type_init (s390_machine_register_types)
Signature · 1 line
2.6.4
PATCH 3/6 s390x: remove s390-virtio devices
In reply to Cornelia HuckFrom: Pierre Morel <[email protected]>
The s390-virtio machine has been removed; remove the associated devices as well.
hw/s390x/s390-virtio-bus.c and hw/s390x/s390-virtio-bus.h have been deleted and removed from hw/s390x/Makefile.objs
virtio-size has no more meaning for the modern machine and has been removed from helper.c and cpu.h
virtio-serial-s390 belonging to the old machine is being removed from vl.c
--- hw/s390x/Makefile.objs | 2 +- hw/s390x/s390-virtio-bus.c | 758 --------------------------------------------- hw/s390x/s390-virtio-bus.h | 186 ----------- hw/s390x/s390-virtio.c | 1 - target-s390x/cpu.h | 3 - target-s390x/helper.c | 2 +- vl.c | 7 +- 7 files changed, 3 insertions(+), 956 deletions(-) delete mode 100644 hw/s390x/s390-virtio-bus.c delete mode 100644 hw/s390x/s390-virtio-bus.h
hw/s390x/Makefile.objs +1 -1
@@ -1,4 +1,4 @@ -obj-y = s390-virtio-bus.o s390-virtio.o +obj-y += s390-virtio.o obj-y += s390-virtio-hcall.o obj-y += sclp.o obj-y += event-facility.o
hw/s390x/s390-virtio-bus.c deleted +0 -758
758 lines not on this page · raw message
hw/s390x/s390-virtio-bus.h deleted +0 -186
186 lines not on this page · raw message
hw/s390x/s390-virtio.c +0 -1
@@ -35,7 +35,6 @@#include "exec/address-spaces.h" #include "sysemu/qtest.h" -#include "hw/s390x/s390-virtio-bus.h" #include "hw/s390x/sclp.h" #include "hw/s390x/s390_flic.h" #include "hw/s390x/s390-virtio.h"
target-s390x/cpu.h +0 -3
@@ -545,9 +545,6 @@ int gtod_load(QEMUFile *f, void *opaque, int version_id);/* service interrupts are floating therefore we must not pass an cpustate */ void s390_sclp_extint (uint32_t parm); -/* from s390-virtio-bus */ -extern const hwaddr virtio_size; -#else static inline unsigned int s390_cpu_halt (S390CPU *cpu) {
target-s390x/helper.c +1 -1
@@ -133,7 +133,7 @@ int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr orig_vaddr, }/* check out of RAM access */ -if (raddr > (ram_size + virtio_size)) { +if (raddr > (ram_size)) {DPRINTF ("%s: raddr %" PRIx64" > ram_size %" PRIx64"\n" , __func__, (uint64_t )raddr, (uint64_t )ram_size);trigger_pgm_exception (env,PGM_ADDRESSING ,ILEN_LATER );
vl.c +1 -6
@@ -227,7 +227,6 @@ static struct { { .driver = "ide-drive", .flag = &default_cdrom }, { .driver = "scsi-cd", .flag = &default_cdrom }, { .driver = "virtio-serial-pci", .flag = &default_virtcon }, - { .driver = "virtio-serial-s390", .flag = &default_virtcon }, { .driver = "virtio-serial", .flag = &default_virtcon }, { .driver = "VGA", .flag = &default_vga }, { .driver = "isa-vga", .flag = &default_vga },
@@ -2548,11 +2547,7 @@ static int virtcon_parse(const char *devname) } bus_opts =qemu_opts_create (device,NULL ,0 , &error_abort); -if (arch_type ==QEMU_ARCH_S390X ) { -qemu_opt_set (bus_opts,"driver" ,"virtio-serial-s390" , &error_abort); - }else { -qemu_opt_set (bus_opts,"driver" ,"virtio-serial-pci" , &error_abort); - } +qemu_opt_set (bus_opts,"driver" ,"virtio-serial" , &error_abort); dev_opts =qemu_opts_create (device,NULL ,0 , &error_abort);qemu_opt_set (dev_opts,"driver" ,"virtconsole" , &error_abort);
Signature · 1 line
2.6.4
PATCH 4/6 s390x/pci: reject some operations to disabled PCI function
In reply to Cornelia HuckFrom: Yi Min Zhao <[email protected]>
According to the s390 architecture, any mpcifc, pcilg, pcistg, pcistb and rpcit instructions issued to disabled PCI functions are rejected, and the instruction completes by setting condition code 3. In addition, any DMA and MSIX interruption operations are ignored.
--- hw/s390x/s390-pci-bus.c | 6 +++++- hw/s390x/s390-pci-bus.h | 1 + hw/s390x/s390-pci-inst.c | 11 +++++------ 3 files changed, 11 insertions(+), 7 deletions(-)
hw/s390x/s390-pci-bus.c +5 -1
@@ -318,7 +318,7 @@ static IOMMUTLBEntry s390_translate_iommu(MemoryRegion *iommu, hwaddr addr, .perm = IOMMU_NONE, }; -if (!pbdev->configured || !pbdev->pdev) { +if (!pbdev->configured || !pbdev->pdev || !(pbdev->fh &FH_ENABLED )) {return ret; }
@@ -429,6 +429,10 @@ static void s390_msi_ctrl_write(void *opaque, hwaddr addr, uint64_t data,return ; } +if (!(pbdev->fh &FH_ENABLED )) { +return ; + } + ind_bit = pbdev->routes.adapter.ind_offset; sum_bit = pbdev->routes.adapter.summary_offset;
hw/s390x/s390-pci-bus.h +1 -0
@@ -23,6 +23,7 @@#define TYPE_S390_PCI_HOST_BRIDGE "s390-pcihost"#define FH_VIRT 0x00ff0000#define ENABLE_BIT_OFFSET 31 +#define FH_ENABLED (1 << ENABLE_BIT_OFFSET)#define S390_PCIPT_ADAPTER 2#define S390_PCI_HOST_BRIDGE (obj) \
hw/s390x/s390-pci-inst.c +5 -6
@@ -313,7 +313,7 @@ int pcilg_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2) offset = env->regs[r2 +1 ]; pbdev =s390_pci_find_dev_by_fh (fh); -if (!pbdev) { +if (!pbdev || !(pbdev->fh &FH_ENABLED )) {DPRINTF ("pcilg no pci dev\n" );setcc (cpu,ZPCI_PCI_LS_INVAL_HANDLE );return 0 ;
@@ -430,7 +430,7 @@ int pcistg_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2) offset = env->regs[r2 +1 ]; pbdev =s390_pci_find_dev_by_fh (fh); -if (!pbdev) { +if (!pbdev || !(pbdev->fh &FH_ENABLED )) {DPRINTF ("pcistg no pci dev\n" );setcc (cpu,ZPCI_PCI_LS_INVAL_HANDLE );return 0 ;
@@ -521,8 +521,7 @@ int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2) end = start + env->regs[r2 +1 ]; pbdev =s390_pci_find_dev_by_fh (fh); - -if (!pbdev) { +if (!pbdev || !(pbdev->fh &FH_ENABLED )) {DPRINTF ("rpcit no pci dev\n" );setcc (cpu,ZPCI_PCI_LS_INVAL_HANDLE ); goto out;
@@ -586,7 +585,7 @@ int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8_t r3, uint64_t gaddr, } pbdev =s390_pci_find_dev_by_fh (fh); -if (!pbdev) { +if (!pbdev || !(pbdev->fh &FH_ENABLED )) {DPRINTF ("pcistb no pci dev fh 0x%x\n" , fh);setcc (cpu,ZPCI_PCI_LS_INVAL_HANDLE );return 0 ;
@@ -727,7 +726,7 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar) } pbdev =s390_pci_find_dev_by_fh (fh); -if (!pbdev) { +if (!pbdev || !(pbdev->fh &FH_ENABLED )) {DPRINTF ("mpcifc no pci dev fh 0x%x\n" , fh);setcc (cpu,ZPCI_PCI_LS_INVAL_HANDLE );return 0 ;
Signature · 1 line
2.6.4
PATCH 5/6 s390x/pci: code cleanup
In reply to Cornelia HuckFrom: Yi Min Zhao <[email protected]>
Make use of the new FH_ENABLED define in existing code.
--- hw/s390x/s390-pci-inst.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/s390x/s390-pci-inst.c +3 -3
@@ -208,12 +208,12 @@ int clp_service_call(S390CPU *cpu, uint8_t r2)switch (reqsetpci->oc) {case CLP_SET_ENABLE_PCI_FN : - pbdev->fh = pbdev->fh |1 <<ENABLE_BIT_OFFSET ; + pbdev->fh = pbdev->fh |FH_ENABLED ;stl_p (&ressetpci->fh, pbdev->fh);stw_p (&ressetpci->hdr.rsp,CLP_RC_OK );break ;case CLP_SET_DISABLE_PCI_FN : - pbdev->fh = pbdev->fh & ~(1 <<ENABLE_BIT_OFFSET ); + pbdev->fh = pbdev->fh & ~FH_ENABLED ; pbdev->error_state = false; pbdev->lgstg_blocked = false;stl_p (&ressetpci->fh, pbdev->fh);
@@ -818,7 +818,7 @@ int stpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar) ((uint32_t )pbdev->sum <<7 ) | pbdev->routes.adapter.summary_offset;stl_p (&fib.data, data); -if (pbdev->fh >>ENABLE_BIT_OFFSET ) { +if (pbdev->fh &FH_ENABLED ) { fib.fc |=0x80 ; }
Signature · 1 line
2.6.4
PATCH 6/6 s390x/virtio: use qemu_check_nic_model()
In reply to Cornelia HuckSwitching to the generally used interface changes the output of
s390x-softmmu/qemu-system-s390x -net nic,model=?
from
S390 only supports VirtIO nics
to the rather more useful
qemu: Supported NIC models: virtio
while still giving us a sensible error message for unsupported models:
s390x-softmmu/qemu-system-s390x -net nic,model=foo
qemu-system-s390x: Unsupported NIC model: foo
--- hw/s390x/s390-virtio.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
hw/s390x/s390-virtio.c +1 -4
@@ -131,10 +131,7 @@ void s390_create_virtio_net(BusState *bus, const char *name) nd->model =g_strdup ("virtio" ); } -if (strcmp (nd->model,"virtio" )) { -fprintf (stderr,"S390 only supports VirtIO nics\n" ); -exit (1 ); - } +qemu_check_nic_model (nd,"virtio" ); dev =qdev_create (bus, name);qdev_set_nic_properties (dev, nd);
Signature · 1 line
2.6.4