From b498484ed49ab9d1fcada3468f95dda1a5f59366 Mon Sep 17 00:00:00 2001 From: Cornelia Huck Date: Wed, 4 Nov 2015 18:40:54 +0100 Subject: [PATCH 01/15] s390x/css: sense data endianness We keep the device's sense data in a byte array (following the architecture), but the ecws are an array of 32 bit values. If we just blindly copy the values, the sense data will change from de-facto BE data to de-facto cpu-endian data, which means we end up doing an incorrect conversion on LE hosts. Let's just explicitly convert to cpu-endianness while assembling the irb. Reported-by: Andy Lutomirski Tested-by: Andy Lutomirski Signed-off-by: Cornelia Huck Reviewed-by: Christian Borntraeger --- hw/s390x/css.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index c033612889..19851ce6a9 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -892,8 +892,14 @@ int css_do_tsch_get_irb(SubchDev *sch, IRB *target_irb, int *irb_len) /* If a unit check is pending, copy sense data. */ if ((s->dstat & SCSW_DSTAT_UNIT_CHECK) && (p->chars & PMCW_CHARS_MASK_CSENSE)) { + int i; + irb.scsw.flags |= SCSW_FLAGS_MASK_ESWF | SCSW_FLAGS_MASK_ECTL; + /* Attention: sense_data is already BE! */ memcpy(irb.ecw, sch->sense_data, sizeof(sch->sense_data)); + for (i = 0; i < ARRAY_SIZE(irb.ecw); i++) { + irb.ecw[i] = be32_to_cpu(irb.ecw[i]); + } irb.esw[1] = 0x01000000 | (sizeof(sch->sense_data) << 8); } } From dce1b089249f52c053cf74dc3da98aea16656961 Mon Sep 17 00:00:00 2001 From: Yi Min Zhao Date: Wed, 28 Oct 2015 11:30:23 +0800 Subject: [PATCH 02/15] s390x/pci : fix up s390 pci iommu translation function On s390x, each pci device has its own iommu, which is only properly setup in qemu once the mpcifc instruction used to register the translation table has been intercepted. Therefore, for a pci device that is not configured or has not been initialized, proper translation is neither required nor possible. Moreover, we may not have a host bridge device ready yet. This was exposed by a recent vfio change that triggers iommu translation during the initialization of the vfio pci device. Let's do an early exit in that case. Reviewed-by: Cornelia Huck Reviewed-by: Jens Freimann Signed-off-by: Yi Min Zhao Signed-off-by: Cornelia Huck --- hw/s390x/s390-pci-bus.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 560b66a501..d5712ae754 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -309,8 +309,7 @@ static IOMMUTLBEntry s390_translate_iommu(MemoryRegion *iommu, hwaddr addr, uint64_t pte; uint32_t flags; S390PCIBusDevice *pbdev = container_of(iommu, S390PCIBusDevice, mr); - S390pciState *s = S390_PCI_HOST_BRIDGE(pci_device_root_bus(pbdev->pdev) - ->qbus.parent); + S390pciState *s; IOMMUTLBEntry ret = { .target_as = &address_space_memory, .iova = 0, @@ -319,8 +318,13 @@ static IOMMUTLBEntry s390_translate_iommu(MemoryRegion *iommu, hwaddr addr, .perm = IOMMU_NONE, }; + if (!pbdev->configured || !pbdev->pdev) { + return ret; + } + DPRINTF("iommu trans addr 0x%" PRIx64 "\n", addr); + s = S390_PCI_HOST_BRIDGE(pci_device_root_bus(pbdev->pdev)->qbus.parent); /* s390 does not have an APIC mapped to main storage so we use * a separate AddressSpace only for msix notifications */ From c5bfb202bb3bcdc1a368e85fef336e89d6254f8c Mon Sep 17 00:00:00 2001 From: Cornelia Huck Date: Wed, 4 Nov 2015 15:59:55 +0100 Subject: [PATCH 03/15] MAINTAINERS: update s390 file patterns We were missing some files, and some files should get an additional entry to add the people actually looking after the code. Reported-by: Thomas Huth Acked-by: Christian Borntraeger Signed-off-by: Cornelia Huck --- MAINTAINERS | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index fc8abe8dd3..9585a8b8eb 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -237,9 +237,12 @@ M: Cornelia Huck M: Alexander Graf S: Maintained F: target-s390x/kvm.c +F: target-s390x/ioinst.[ch] +F: target-s390x/machine.c F: hw/intc/s390_flic.c F: hw/intc/s390_flic_kvm.c F: include/hw/s390x/s390_flic.h +F: gdb-xml/s390*.xml X86 M: Paolo Bonzini @@ -637,14 +640,11 @@ M: Christian Borntraeger M: Alexander Graf S: Supported F: hw/char/sclp*.[hc] -F: hw/s390x/s390-virtio-ccw.c -F: hw/s390x/css.[hc] -F: hw/s390x/sclp*.[hc] -F: hw/s390x/ipl*.[hc] -F: hw/s390x/*pci*.[hc] -F: hw/s390x/s390-skeys*.c +F: hw/s390x/ +X: hw/s390x/s390-virtio-bus.[ch] F: include/hw/s390x/ F: pc-bios/s390-ccw/ +F: hw/watchdog/wdt_diag288.c T: git git://github.com/cohuck/qemu virtio-ccw-upstr UniCore32 Machines From 3e9ed24b84c4acdd077904a74eaec6d95cfef928 Mon Sep 17 00:00:00 2001 From: Cornelia Huck Date: Wed, 4 Nov 2015 16:08:20 +0100 Subject: [PATCH 04/15] MAINTAINERS: update virtio-ccw/s390 git tree Let's reference the git branch I actually use, and add Christian's git tree. Acked-by: Christian Borntraeger Signed-off-by: Cornelia Huck --- MAINTAINERS | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 9585a8b8eb..9e1fa7236a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -243,6 +243,8 @@ F: hw/intc/s390_flic.c F: hw/intc/s390_flic_kvm.c F: include/hw/s390x/s390_flic.h F: gdb-xml/s390*.xml +T: git git://github.com/cohuck/qemu.git s390-next +T: git git://github.com/borntraeger/qemu.git s390-next X86 M: Paolo Bonzini @@ -645,7 +647,8 @@ X: hw/s390x/s390-virtio-bus.[ch] F: include/hw/s390x/ F: pc-bios/s390-ccw/ F: hw/watchdog/wdt_diag288.c -T: git git://github.com/cohuck/qemu virtio-ccw-upstr +T: git git://github.com/cohuck/qemu.git s390-next +T: git git://github.com/borntraeger/qemu.git s390-next UniCore32 Machines ------------- @@ -872,7 +875,8 @@ M: Cornelia Huck M: Christian Borntraeger S: Supported F: hw/s390x/virtio-ccw.[hc] -T: git git://github.com/cohuck/qemu virtio-ccw-upstr +T: git git://github.com/cohuck/qemu.git s390-next +T: git git://github.com/borntraeger/qemu.git s390-next virtio-input M: Gerd Hoffmann From ae23a33591056d6349753766047ebc511158da9c Mon Sep 17 00:00:00 2001 From: Dominik Dingel Date: Tue, 12 May 2015 13:21:30 +0200 Subject: [PATCH 05/15] s390x: switch to memory_region_allocate_system_memory By replacing memory_region_init_ram with memory_region_allocate_system_memory we gain goodies like mem-path backends. This will allow us to use hugetlbfs once the kernel supports it. Signed-off-by: Dominik Dingel Acked-by: Christian Borntraeger Signed-off-by: Cornelia Huck --- hw/s390x/s390-virtio-ccw.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 84221f4f57..5a52ff26eb 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -104,8 +104,7 @@ void s390_memory_init(ram_addr_t mem_size) MemoryRegion *ram = g_new(MemoryRegion, 1); /* allocate RAM for core */ - memory_region_init_ram(ram, NULL, "s390.ram", mem_size, &error_fatal); - vmstate_register_ram_global(ram); + memory_region_allocate_system_memory(ram, NULL, "s390.ram", mem_size); memory_region_add_subregion(sysmem, 0, ram); /* Initialize storage key device */ From 4c292a009700755a1e6b234063ef3f2db235aaae Mon Sep 17 00:00:00 2001 From: Dominik Dingel Date: Tue, 11 Aug 2015 11:12:12 +0200 Subject: [PATCH 06/15] s390x/kvm: don't enable CMMA when hugetlbfs will be used On hugetlbfs CMMA will not be useful as every ESSA instruction will trap. So don't offer CMMA to guests with a hugepages backing. Signed-off-by: Dominik Dingel Acked-by: Christian Borntraeger Signed-off-by: Cornelia Huck --- target-s390x/kvm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c index c3be180de2..75a0e5d1c3 100644 --- a/target-s390x/kvm.c +++ b/target-s390x/kvm.c @@ -258,7 +258,9 @@ int kvm_arch_init(MachineState *ms, KVMState *s) cap_mem_op = kvm_check_extension(s, KVM_CAP_S390_MEM_OP); cap_s390_irq = kvm_check_extension(s, KVM_CAP_S390_INJECT_IRQ); - kvm_s390_enable_cmma(s); + if (!mem_path) { + kvm_s390_enable_cmma(s); + } if (!kvm_check_extension(s, KVM_CAP_S390_GMAP) || !kvm_check_extension(s, KVM_CAP_S390_COW)) { From 38150be860434de9d9c76cef71ff5c6b6112ee8f Mon Sep 17 00:00:00 2001 From: Maxim Samoylov Date: Mon, 12 Oct 2015 17:50:20 +0200 Subject: [PATCH 07/15] pc-bios/s390-ccw: Always adjust virtio sector count Let's always adjust the sector number to be read using the current virtio block size value. This prepares for the implementation of IPL from ISO-9660 media. Signed-off-by: Maxim Samoylov Reviewed-by: David Hildenbrand Reviewed-by: Cornelia Huck Signed-off-by: Cornelia Huck --- pc-bios/s390-ccw/virtio.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pc-bios/s390-ccw/virtio.h b/pc-bios/s390-ccw/virtio.h index c23466b8db..76c42f119d 100644 --- a/pc-bios/s390-ccw/virtio.h +++ b/pc-bios/s390-ccw/virtio.h @@ -199,14 +199,9 @@ extern int virtio_read_many(ulong sector, void *load_addr, int sec_num); #define VIRTIO_SECTOR_SIZE 512 -static inline ulong virtio_eckd_sector_adjust(ulong sector) -{ - return sector * (virtio_get_block_size() / VIRTIO_SECTOR_SIZE); -} - static inline ulong virtio_sector_adjust(ulong sector) { - return virtio_disk_is_eckd() ? virtio_eckd_sector_adjust(sector) : sector; + return sector * (virtio_get_block_size() / VIRTIO_SECTOR_SIZE); } #endif /* VIRTIO_H */ From 866cac91e06219f473a2900eefef0d1cf242b136 Mon Sep 17 00:00:00 2001 From: Maxim Samoylov Date: Mon, 12 Oct 2015 17:50:20 +0200 Subject: [PATCH 08/15] pc-bios/s390-ccw: ISO-9660 El Torito boot implementation This patch enables boot from media formatted according to ISO-9660 and El Torito bootable CD specification. We try to boot from device as ISO-9660 media when SCSI IPL failed. The first boot catalog entry with bootable flag is used. ISO-9660 media with default 2048-bytes sector size only is supported. Signed-off-by: Maxim Samoylov Reviewed-by: David Hildenbrand Signed-off-by: Cornelia Huck --- pc-bios/s390-ccw/bootmap.c | 107 +++++++++++++++++++++ pc-bios/s390-ccw/bootmap.h | 191 +++++++++++++++++++++++++++++++++++++ pc-bios/s390-ccw/virtio.c | 7 ++ pc-bios/s390-ccw/virtio.h | 1 + 4 files changed, 306 insertions(+) diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c index b678d5ebb8..7c8dce154a 100644 --- a/pc-bios/s390-ccw/bootmap.c +++ b/pc-bios/s390-ccw/bootmap.c @@ -444,6 +444,107 @@ static void ipl_scsi(void) zipl_run(prog_table_entry); /* no return */ } +/*********************************************************************** + * IPL El Torito ISO9660 image or DVD + */ + +static bool is_iso_bc_entry_compatible(IsoBcSection *s) +{ + return true; +} + +static void load_iso_bc_entry(IsoBcSection *load) +{ + IsoBcSection s = *load; + /* + * According to spec, extent for each file + * is padded and ISO_SECTOR_SIZE bytes aligned + */ + uint32_t blks_to_load = bswap16(s.sector_count) >> ET_SECTOR_SHIFT; + + read_iso_boot_image(bswap32(s.load_rba), + (void *)((uint64_t)bswap16(s.load_segment)), + blks_to_load); + + /* Trying to get PSW at zero address */ + if (*((uint64_t *)0) & IPL_PSW_MASK) { + jump_to_IPL_code((*((uint64_t *)0)) & 0x7fffffff); + } + + /* Try default linux start address */ + jump_to_IPL_code(KERN_IMAGE_START); +} + +static uint32_t find_iso_bc(void) +{ + IsoVolDesc *vd = (IsoVolDesc *)sec; + uint32_t block_num = ISO_PRIMARY_VD_SECTOR; + + if (virtio_read_many(block_num++, sec, 1)) { + /* If primary vd cannot be read, there is no boot catalog */ + return 0; + } + + while (is_iso_vd_valid(vd) && vd->type != VOL_DESC_TERMINATOR) { + if (vd->type == VOL_DESC_TYPE_BOOT) { + IsoVdElTorito *et = &vd->vd.boot; + + if (!_memcmp(&et->el_torito[0], el_torito_magic, 32)) { + return bswap32(et->bc_offset); + } + } + read_iso_sector(block_num++, sec, + "Failed to read ISO volume descriptor"); + } + + return 0; +} + +static IsoBcSection *find_iso_bc_entry(void) +{ + IsoBcEntry *e = (IsoBcEntry *)sec; + uint32_t offset = find_iso_bc(); + int i; + + if (!offset) { + return NULL; + } + + read_iso_sector(offset, sec, "Failed to read El Torito boot catalog"); + + if (!is_iso_bc_valid(e)) { + /* The validation entry is mandatory */ + virtio_panic("No valid boot catalog found!\n"); + return NULL; + } + + /* + * Each entry has 32 bytes size, so one sector cannot contain > 64 entries. + * We consider only boot catalogs with no more than 64 entries. + */ + for (i = 1; i < ISO_BC_ENTRY_PER_SECTOR; i++) { + if (e[i].id == ISO_BC_BOOTABLE_SECTION) { + if (is_iso_bc_entry_compatible(&e[i].body.sect)) { + return &e[i].body.sect; + } + } + } + + virtio_panic("No suitable boot entry found on ISO-9660 media!\n"); + + return NULL; +} + +static void ipl_iso_el_torito(void) +{ + IsoBcSection *s = find_iso_bc_entry(); + + if (s) { + load_iso_bc_entry(s); + /* no return */ + } +} + /*********************************************************************** * IPL starts here */ @@ -463,6 +564,12 @@ void zipl_load(void) ipl_scsi(); /* no return */ } + /* Check if we can boot as ISO media */ + if (virtio_guessed_disk_nature()) { + virtio_assume_iso9660(); + } + ipl_iso_el_torito(); + /* We have failed to follow the SCSI scheme, so */ if (virtio_guessed_disk_nature()) { sclp_print("Using guessed DASD geometry.\n"); diff --git a/pc-bios/s390-ccw/bootmap.h b/pc-bios/s390-ccw/bootmap.h index ab132e3579..4f6f767584 100644 --- a/pc-bios/s390-ccw/bootmap.h +++ b/pc-bios/s390-ccw/bootmap.h @@ -341,4 +341,195 @@ static inline bool magic_match(const void *data, const void *magic) return *((uint32_t *)data) == *((uint32_t *)magic); } +static inline int _memcmp(const void *s1, const void *s2, size_t n) +{ + int i; + const uint8_t *p1 = s1, *p2 = s2; + + for (i = 0; i < n; i++) { + if (p1[i] != p2[i]) { + return p1[i] > p2[i] ? 1 : -1; + } + } + + return 0; +} + +/* from include/qemu/bswap.h */ + +/* El Torito is always little-endian */ +static inline uint16_t bswap16(uint16_t x) +{ + return ((x & 0x00ff) << 8) | ((x & 0xff00) >> 8); +} + +static inline uint32_t bswap32(uint32_t x) +{ + return ((x & 0x000000ffU) << 24) | ((x & 0x0000ff00U) << 8) | + ((x & 0x00ff0000U) >> 8) | ((x & 0xff000000U) >> 24); +} + +static inline uint64_t bswap64(uint64_t x) +{ + return ((x & 0x00000000000000ffULL) << 56) | + ((x & 0x000000000000ff00ULL) << 40) | + ((x & 0x0000000000ff0000ULL) << 24) | + ((x & 0x00000000ff000000ULL) << 8) | + ((x & 0x000000ff00000000ULL) >> 8) | + ((x & 0x0000ff0000000000ULL) >> 24) | + ((x & 0x00ff000000000000ULL) >> 40) | + ((x & 0xff00000000000000ULL) >> 56); +} + +#define ISO_SECTOR_SIZE 2048 +/* El Torito specifies boot image size in 512 byte blocks */ +#define ET_SECTOR_SHIFT 2 +#define KERN_IMAGE_START 0x010000UL +#define PSW_MASK_64 0x0000000100000000ULL +#define PSW_MASK_32 0x0000000080000000ULL +#define IPL_PSW_MASK (PSW_MASK_32 | PSW_MASK_64) + +#define ISO_PRIMARY_VD_SECTOR 16 + +static inline void read_iso_sector(uint32_t block_offset, void *buf, + const char *errmsg) +{ + IPL_assert(virtio_read_many(block_offset, buf, 1) == 0, errmsg); +} + +static inline void read_iso_boot_image(uint32_t block_offset, void *load_addr, + uint32_t blks_to_load) +{ + IPL_assert(virtio_read_many(block_offset, load_addr, blks_to_load) == 0, + "Failed to read boot image!"); +} + +const uint8_t el_torito_magic[] = "EL TORITO SPECIFICATION" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; + +typedef struct IsoDirHdr { + uint8_t dr_len; + uint8_t ear_len; + uint64_t ext_loc; + uint64_t data_len; + uint8_t recording_datetime[7]; + uint8_t file_flags; + uint8_t file_unit_size; + uint8_t gap_size; + uint32_t vol_seqnum; + uint8_t fileid_len; +} __attribute__((packed)) IsoDirHdr; + +typedef struct IsoVdElTorito { + uint8_t el_torito[32]; /* must contain el_torito_magic value */ + uint8_t unused0[32]; + uint32_t bc_offset; + uint8_t unused1[1974]; +} __attribute__((packed)) IsoVdElTorito; + +typedef struct IsoVdPrimary { + uint8_t unused1; + uint8_t sys_id[32]; + uint8_t vol_id[32]; + uint8_t unused2[8]; + uint64_t vol_space_size; + uint8_t unused3[32]; + uint32_t vol_set_size; + uint32_t vol_seqnum; + uint32_t log_block_size; + uint64_t path_table_size; + uint32_t l_path_table; + uint32_t opt_l_path_table; + uint32_t m_path_table; + uint32_t opt_m_path_table; + IsoDirHdr rootdir; + uint8_t root_null; + uint8_t reserved2[1858]; +} __attribute__((packed)) IsoVdPrimary; + +typedef struct IsoVolDesc { + uint8_t type; + uint8_t ident[5]; + uint8_t version; + union { + IsoVdElTorito boot; + IsoVdPrimary primary; + } vd; +} __attribute__((packed)) IsoVolDesc; + +const uint8_t vol_desc_magic[] = "CD001"; +#define VOL_DESC_TYPE_BOOT 0 +#define VOL_DESC_TYPE_PRIMARY 1 +#define VOL_DESC_TYPE_SUPPLEMENT 2 +#define VOL_DESC_TYPE_PARTITION 3 +#define VOL_DESC_TERMINATOR 255 + +static inline bool is_iso_vd_valid(IsoVolDesc *vd) +{ + return !_memcmp(&vd->ident[0], vol_desc_magic, 5) && + vd->version == 0x1 && + vd->type <= VOL_DESC_TYPE_PARTITION; +} + +typedef struct IsoBcValid { + uint8_t platform_id; + uint16_t reserved; + uint8_t id[24]; + uint16_t checksum; + uint8_t key[2]; +} __attribute__((packed)) IsoBcValid; + +typedef struct IsoBcSection { + uint8_t boot_type; + uint16_t load_segment; + uint8_t sys_type; + uint8_t unused; + uint16_t sector_count; + uint32_t load_rba; + uint8_t selection[20]; +} __attribute__((packed)) IsoBcSection; + +typedef struct IsoBcHdr { + uint8_t platform_id; + uint16_t sect_num; + uint8_t id[28]; +} __attribute__((packed)) IsoBcHdr; + +typedef struct IsoBcEntry { + uint8_t id; + union { + IsoBcValid valid; /* id == 0x01 */ + IsoBcSection sect; /* id == 0x88 || id == 0x0 */ + IsoBcHdr hdr; /* id == 0x90 || id == 0x91 */ + } body; +} __attribute__((packed)) IsoBcEntry; + +#define ISO_BC_ENTRY_PER_SECTOR (ISO_SECTOR_SIZE / sizeof(IsoBcEntry)) +#define ISO_BC_HDR_VALIDATION 0x01 +#define ISO_BC_BOOTABLE_SECTION 0x88 +#define ISO_BC_MAGIC_55 0x55 +#define ISO_BC_MAGIC_AA 0xaa +#define ISO_BC_PLATFORM_X86 0x0 +#define ISO_BC_PLATFORM_PPC 0x1 +#define ISO_BC_PLATFORM_MAC 0x2 + +static inline bool is_iso_bc_valid(IsoBcEntry *e) +{ + IsoBcValid *v = &e->body.valid; + + if (e->id != ISO_BC_HDR_VALIDATION) { + return false; + } + + if (v->platform_id != ISO_BC_PLATFORM_X86 && + v->platform_id != ISO_BC_PLATFORM_PPC && + v->platform_id != ISO_BC_PLATFORM_MAC) { + return false; + } + + return v->key[0] == ISO_BC_MAGIC_55 && + v->key[1] == ISO_BC_MAGIC_AA && + v->reserved == 0x0; +} + #endif /* _PC_BIOS_S390_CCW_BOOTMAP_H */ diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c index 57ff1b07ee..87aed38a95 100644 --- a/pc-bios/s390-ccw/virtio.c +++ b/pc-bios/s390-ccw/virtio.c @@ -278,6 +278,13 @@ void virtio_assume_scsi(void) blk_cfg.physical_block_exp = 0; } +void virtio_assume_iso9660(void) +{ + guessed_disk_nature = true; + blk_cfg.blk_size = 2048; + blk_cfg.physical_block_exp = 0; +} + void virtio_assume_eckd(void) { guessed_disk_nature = true; diff --git a/pc-bios/s390-ccw/virtio.h b/pc-bios/s390-ccw/virtio.h index 76c42f119d..afa01a885b 100644 --- a/pc-bios/s390-ccw/virtio.h +++ b/pc-bios/s390-ccw/virtio.h @@ -187,6 +187,7 @@ typedef struct VirtioBlkConfig { bool virtio_guessed_disk_nature(void); void virtio_assume_scsi(void); void virtio_assume_eckd(void); +void virtio_assume_iso9660(void); extern bool virtio_disk_is_scsi(void); extern bool virtio_disk_is_eckd(void); From ba21f0cca8165c5b284274edd12dc955cf4fb248 Mon Sep 17 00:00:00 2001 From: Maxim Samoylov Date: Mon, 12 Oct 2015 17:50:20 +0200 Subject: [PATCH 09/15] pc-bios/s390-ccw: El Torito s390x boot entry check Boot entry is considered compatible if boot image is Linux kernel with matching S390 Linux magic string. Empty boot images with sector_count == 0 are considered broken. Signed-off-by: Maxim Samoylov Reviewed-by: David Hildenbrand Signed-off-by: Cornelia Huck --- pc-bios/s390-ccw/bootmap.c | 11 ++++++++++- pc-bios/s390-ccw/bootmap.h | 8 ++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c index 7c8dce154a..82cca9c9e8 100644 --- a/pc-bios/s390-ccw/bootmap.c +++ b/pc-bios/s390-ccw/bootmap.c @@ -450,7 +450,16 @@ static void ipl_scsi(void) static bool is_iso_bc_entry_compatible(IsoBcSection *s) { - return true; + uint8_t *magic_sec = (uint8_t *)(sec + ISO_SECTOR_SIZE); + + if (s->unused || !s->sector_count) { + return false; + } + read_iso_sector(bswap32(s->load_rba), magic_sec, + "Failed to read image sector 0"); + + /* Checking bytes 8 - 32 for S390 Linux magic */ + return !_memcmp(magic_sec + 8, linux_s390_magic, 24); } static void load_iso_bc_entry(IsoBcSection *load) diff --git a/pc-bios/s390-ccw/bootmap.h b/pc-bios/s390-ccw/bootmap.h index 4f6f767584..cc77fd753c 100644 --- a/pc-bios/s390-ccw/bootmap.h +++ b/pc-bios/s390-ccw/bootmap.h @@ -495,6 +495,14 @@ typedef struct IsoBcHdr { uint8_t id[28]; } __attribute__((packed)) IsoBcHdr; +/* + * Match two CCWs located after PSW and eight filler bytes. + * From libmagic and arch/s390/kernel/head.S. + */ +const uint8_t linux_s390_magic[] = "\x02\x00\x00\x18\x60\x00\x00\x50\x02\x00" + "\x00\x68\x60\x00\x00\x50\x40\x40\x40\x40" + "\x40\x40\x40\x40"; + typedef struct IsoBcEntry { uint8_t id; union { From 869648e87eeb998cc0ede230f3b7aabfdf0eb2dd Mon Sep 17 00:00:00 2001 From: Maxim Samoylov Date: Mon, 12 Oct 2015 17:50:20 +0200 Subject: [PATCH 10/15] pc-bios/s390-ccw: El Torito 16-bit boot image size field workaround Because of El Torito spec flaw boot image size needs to be verified. Boot catalog entry size field has 16-bit width, and specifies size in 512-byte units. Thus, boot image size cannot exceed 32M. We actually search for the file to get the file size. This is done by scanning the ISO directory tree for the ISO block number and reading the file size from the directory entry. Signed-off-by: Maxim Samoylov Reviewed-by: David Hildenbrand Signed-off-by: Cornelia Huck --- pc-bios/s390-ccw/bootmap.c | 90 ++++++++++++++++++++++++++++++++++++++ pc-bios/s390-ccw/bootmap.h | 7 +++ 2 files changed, 97 insertions(+) diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c index 82cca9c9e8..415508b279 100644 --- a/pc-bios/s390-ccw/bootmap.c +++ b/pc-bios/s390-ccw/bootmap.c @@ -462,6 +462,87 @@ static bool is_iso_bc_entry_compatible(IsoBcSection *s) return !_memcmp(magic_sec + 8, linux_s390_magic, 24); } +/* Location of the current sector of the directory */ +static uint32_t sec_loc[ISO9660_MAX_DIR_DEPTH]; +/* Offset in the current sector of the directory */ +static uint32_t sec_offset[ISO9660_MAX_DIR_DEPTH]; +/* Remained directory space in bytes */ +static uint32_t dir_rem[ISO9660_MAX_DIR_DEPTH]; + +static inline uint32_t iso_get_file_size(uint32_t load_rba) +{ + IsoVolDesc *vd = (IsoVolDesc *)sec; + IsoDirHdr *cur_record = &vd->vd.primary.rootdir; + uint8_t *temp = sec + ISO_SECTOR_SIZE; + int level = 0; + + read_iso_sector(ISO_PRIMARY_VD_SECTOR, sec, + "Failed to read ISO primary descriptor"); + sec_loc[0] = iso_733_to_u32(cur_record->ext_loc); + dir_rem[0] = 0; + sec_offset[0] = 0; + + while (level >= 0) { + IPL_assert(sec_offset[level] <= ISO_SECTOR_SIZE, + "Directory tree structure violation"); + + cur_record = (IsoDirHdr *)(temp + sec_offset[level]); + + if (sec_offset[level] == 0) { + read_iso_sector(sec_loc[level], temp, + "Failed to read ISO directory"); + if (dir_rem[level] == 0) { + /* Skip self and parent records */ + dir_rem[level] = iso_733_to_u32(cur_record->data_len) - + cur_record->dr_len; + sec_offset[level] += cur_record->dr_len; + + cur_record = (IsoDirHdr *)(temp + sec_offset[level]); + dir_rem[level] -= cur_record->dr_len; + sec_offset[level] += cur_record->dr_len; + continue; + } + } + + if (!cur_record->dr_len || sec_offset[level] == ISO_SECTOR_SIZE) { + /* Zero-padding and/or the end of current sector */ + dir_rem[level] -= ISO_SECTOR_SIZE - sec_offset[level]; + sec_offset[level] = 0; + sec_loc[level]++; + } else { + /* The directory record is valid */ + if (load_rba == iso_733_to_u32(cur_record->ext_loc)) { + return iso_733_to_u32(cur_record->data_len); + } + + dir_rem[level] -= cur_record->dr_len; + sec_offset[level] += cur_record->dr_len; + + if (cur_record->file_flags & 0x2) { + /* Subdirectory */ + if (level == ISO9660_MAX_DIR_DEPTH - 1) { + sclp_print("ISO-9660 directory depth limit exceeded\n"); + } else { + level++; + sec_loc[level] = iso_733_to_u32(cur_record->ext_loc); + sec_offset[level] = 0; + dir_rem[level] = 0; + continue; + } + } + } + + if (dir_rem[level] == 0) { + /* Nothing remaining */ + level--; + read_iso_sector(sec_loc[level], temp, + "Failed to read ISO directory"); + } + } + + return 0; +} + static void load_iso_bc_entry(IsoBcSection *load) { IsoBcSection s = *load; @@ -470,6 +551,15 @@ static void load_iso_bc_entry(IsoBcSection *load) * is padded and ISO_SECTOR_SIZE bytes aligned */ uint32_t blks_to_load = bswap16(s.sector_count) >> ET_SECTOR_SHIFT; + uint32_t real_size = iso_get_file_size(bswap32(s.load_rba)); + + if (real_size) { + /* Round up blocks to load */ + blks_to_load = (real_size + ISO_SECTOR_SIZE - 1) / ISO_SECTOR_SIZE; + sclp_print("ISO boot image size verified\n"); + } else { + sclp_print("ISO boot image size could not be verified\n"); + } read_iso_boot_image(bswap32(s.load_rba), (void *)((uint64_t)bswap16(s.load_segment)), diff --git a/pc-bios/s390-ccw/bootmap.h b/pc-bios/s390-ccw/bootmap.h index cc77fd753c..f98765b841 100644 --- a/pc-bios/s390-ccw/bootmap.h +++ b/pc-bios/s390-ccw/bootmap.h @@ -381,6 +381,11 @@ static inline uint64_t bswap64(uint64_t x) ((x & 0xff00000000000000ULL) >> 56); } +static inline uint32_t iso_733_to_u32(uint64_t x) +{ + return (uint32_t)x; +} + #define ISO_SECTOR_SIZE 2048 /* El Torito specifies boot image size in 512 byte blocks */ #define ET_SECTOR_SHIFT 2 @@ -407,6 +412,8 @@ static inline void read_iso_boot_image(uint32_t block_offset, void *load_addr, const uint8_t el_torito_magic[] = "EL TORITO SPECIFICATION" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; +#define ISO9660_MAX_DIR_DEPTH 8 + typedef struct IsoDirHdr { uint8_t dr_len; uint8_t ear_len; From 81a93ee64d78a1933998ff1b95f06b6d67db46fd Mon Sep 17 00:00:00 2001 From: Cornelia Huck Date: Thu, 5 Nov 2015 13:47:38 +0100 Subject: [PATCH 11/15] pc-bios/s390-ccw: rebuild image Contains: pc-bios/s390-ccw: Always adjust virtio sector count pc-bios/s390-ccw: ISO-9660 El Torito boot implementation pc-bios/s390-ccw: El Torito s390x boot entry check pc-bios/s390-ccw: El Torito 16-bit boot image size field workaround Signed-off-by: Cornelia Huck --- pc-bios/s390-ccw.img | Bin 13856 -> 17760 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/pc-bios/s390-ccw.img b/pc-bios/s390-ccw.img index 0c540a10cf2a662889f5fbd08a7580395a7577d0..e0d9452945668fa74402c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ACezSdxI5=7UMJN~-Z@>0J^6 zwLy#DRg<1v2Dp9#3Fys`NA0mo<)l9jgxy2sz#_v5zwVe(sf zYeC7|Z_}UWpNZRA53_DK*XS-_pmNKfpA&e0c(F?E-opN>7t$4La8R y)_mr;$xrm7c!oH7=4*=U_vL@iUGkHuZSm&{H}9Fm(BKm8Yc`(^0> From ff8de0757fc13407c81f002e936031ddc13057e4 Mon Sep 17 00:00:00 2001 From: David Hildenbrand Date: Tue, 21 Jul 2015 08:32:07 +0200 Subject: [PATCH 12/15] qdev: provide qdev_reset_all_fn() For TYPE_DEVICE, the dc->reset() function is not called on system resets yet. Until that is changed, we have to manually register a reset handler. Let's provide qdev_reset_all_fn(), that can directly be used - just like the reset handler that is already available for qbus. Reviewed-by: Cornelia Huck Signed-off-by: David Hildenbrand Signed-off-by: Cornelia Huck --- hw/core/qdev.c | 5 +++++ include/hw/qdev-core.h | 1 + 2 files changed, 6 insertions(+) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 4ab04aa31e..b3ad467754 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -325,6 +325,11 @@ void qdev_reset_all(DeviceState *dev) qdev_walk_children(dev, NULL, NULL, qdev_reset_one, qbus_reset_one, NULL); } +void qdev_reset_all_fn(void *opaque) +{ + qdev_reset_all(DEVICE(opaque)); +} + void qbus_reset_all(BusState *bus) { qbus_walk_children(bus, NULL, NULL, qdev_reset_one, qbus_reset_one, NULL); diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 8057aedaa6..e6dbde42c4 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -337,6 +337,7 @@ int qdev_walk_children(DeviceState *dev, void *opaque); void qdev_reset_all(DeviceState *dev); +void qdev_reset_all_fn(void *opaque); /** * @qbus_reset_all: From 04fccf106e22c4b861398cf2146f5a5b5f18d01e Mon Sep 17 00:00:00 2001 From: David Hildenbrand Date: Thu, 8 Oct 2015 12:32:13 +0200 Subject: [PATCH 13/15] s390x/ipl: clean up qom definitions and turn into TYPE_DEVICE Let's move the qom definitions of the ipl device into ipl.h, replace "s390-ipl" by a proper type define, turn it into a TYPE_DEVICE and remove the unneeded class definition. Signed-off-by: David Hildenbrand Signed-off-by: Cornelia Huck --- hw/s390x/ipl.c | 52 +++++------------------------------------- hw/s390x/ipl.h | 25 ++++++++++++++++++++ hw/s390x/s390-virtio.c | 10 ++++---- 3 files changed, 36 insertions(+), 51 deletions(-) diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index 5f7f34900a..c75071d0fc 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -15,7 +15,6 @@ #include "cpu.h" #include "elf.h" #include "hw/loader.h" -#include "hw/sysbus.h" #include "hw/s390x/virtio-ccw.h" #include "hw/s390x/css.h" #include "ipl.h" @@ -29,44 +28,6 @@ #define ZIPL_IMAGE_START 0x009000UL #define IPL_PSW_MASK (PSW_MASK_32 | PSW_MASK_64) -#define TYPE_S390_IPL "s390-ipl" -#define S390_IPL(obj) \ - OBJECT_CHECK(S390IPLState, (obj), TYPE_S390_IPL) -#if 0 -#define S390_IPL_CLASS(klass) \ - OBJECT_CLASS_CHECK(S390IPLState, (klass), TYPE_S390_IPL) -#define S390_IPL_GET_CLASS(obj) \ - OBJECT_GET_CLASS(S390IPLState, (obj), TYPE_S390_IPL) -#endif - -typedef struct S390IPLClass { - /*< private >*/ - SysBusDeviceClass parent_class; - /*< public >*/ - - void (*parent_reset) (SysBusDevice *dev); -} S390IPLClass; - -typedef struct S390IPLState { - /*< private >*/ - SysBusDevice parent_obj; - uint64_t start_addr; - uint64_t bios_start_addr; - bool enforce_bios; - IplParameterBlock iplb; - bool iplb_valid; - bool reipl_requested; - - /*< public >*/ - char *kernel; - char *initrd; - char *cmdline; - char *firmware; - uint8_t cssid; - uint8_t ssid; - uint16_t devno; -} S390IPLState; - static const VMStateDescription vmstate_iplb = { .name = "ipl/iplb", .version_id = 0, @@ -110,7 +71,7 @@ static uint64_t bios_translate_addr(void *opaque, uint64_t srcaddr) return srcaddr + dstaddr; } -static int s390_ipl_init(SysBusDevice *dev) +static void s390_ipl_realize(DeviceState *dev, Error **errp) { S390IPLState *ipl = S390_IPL(dev); uint64_t pentry = KERN_IMAGE_START; @@ -165,7 +126,7 @@ static int s390_ipl_init(SysBusDevice *dev) } if (kernel_size < 0) { fprintf(stderr, "could not load kernel '%s'\n", ipl->kernel); - return -1; + exit(1); } /* * Is it a Linux kernel (starting at 0x10000)? If yes, we fill in the @@ -205,7 +166,7 @@ static int s390_ipl_init(SysBusDevice *dev) stq_p(rom_ptr(INITRD_PARM_SIZE), initrd_size); } } - return 0; + qemu_register_reset(qdev_reset_all_fn, dev); } static Property s390_ipl_properties[] = { @@ -308,9 +269,8 @@ static void s390_ipl_reset(DeviceState *dev) static void s390_ipl_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); - k->init = s390_ipl_init; + dc->realize = s390_ipl_realize; dc->props = s390_ipl_properties; dc->reset = s390_ipl_reset; dc->vmsd = &vmstate_ipl; @@ -319,8 +279,8 @@ static void s390_ipl_class_init(ObjectClass *klass, void *data) static const TypeInfo s390_ipl_info = { .class_init = s390_ipl_class_init, - .parent = TYPE_SYS_BUS_DEVICE, - .name = "s390-ipl", + .parent = TYPE_DEVICE, + .name = TYPE_S390_IPL, .instance_size = sizeof(S390IPLState), }; diff --git a/hw/s390x/ipl.h b/hw/s390x/ipl.h index 7f2b4033d4..6b48ed7b93 100644 --- a/hw/s390x/ipl.h +++ b/hw/s390x/ipl.h @@ -12,6 +12,7 @@ #ifndef HW_S390_IPL_H #define HW_S390_IPL_H +#include "hw/qdev.h" #include "cpu.h" typedef struct IplParameterBlock { @@ -25,4 +26,28 @@ void s390_ipl_prepare_cpu(S390CPU *cpu); IplParameterBlock *s390_ipl_get_iplb(void); void s390_reipl_request(void); +#define TYPE_S390_IPL "s390-ipl" +#define S390_IPL(obj) OBJECT_CHECK(S390IPLState, (obj), TYPE_S390_IPL) + +struct S390IPLState { + /*< private >*/ + DeviceState parent_obj; + uint64_t start_addr; + uint64_t bios_start_addr; + bool enforce_bios; + IplParameterBlock iplb; + bool iplb_valid; + bool reipl_requested; + + /*< public >*/ + char *kernel; + char *initrd; + char *cmdline; + char *firmware; + uint8_t cssid; + uint8_t ssid; + uint16_t devno; +}; +typedef struct S390IPLState S390IPLState; + #endif diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c index cbde9772e5..cebebb1c0a 100644 --- a/hw/s390x/s390-virtio.c +++ b/hw/s390x/s390-virtio.c @@ -31,7 +31,6 @@ #include "hw/boards.h" #include "hw/loader.h" #include "hw/virtio/virtio.h" -#include "hw/sysbus.h" #include "sysemu/kvm.h" #include "exec/address-spaces.h" @@ -151,9 +150,9 @@ void s390_init_ipl_dev(const char *kernel_filename, const char *firmware, bool enforce_bios) { - DeviceState *dev; + Object *new = object_new(TYPE_S390_IPL); + DeviceState *dev = DEVICE(new); - dev = qdev_create(NULL, "s390-ipl"); if (kernel_filename) { qdev_prop_set_string(dev, "kernel", kernel_filename); } @@ -163,8 +162,9 @@ void s390_init_ipl_dev(const char *kernel_filename, qdev_prop_set_string(dev, "cmdline", kernel_cmdline); qdev_prop_set_string(dev, "firmware", firmware); qdev_prop_set_bit(dev, "enforce_bios", enforce_bios); - object_property_add_child(qdev_get_machine(), "s390-ipl", - OBJECT(dev), NULL); + object_property_add_child(qdev_get_machine(), TYPE_S390_IPL, + new, NULL); + object_unref(new); qdev_init_nofail(dev); } From 8f04e88e2cd792e348eb54983ce1a485d5db4f27 Mon Sep 17 00:00:00 2001 From: David Hildenbrand Date: Thu, 8 Oct 2015 12:33:28 +0200 Subject: [PATCH 14/15] s390x/ipl: switch error reporting to error_setg Now that we can report errors in the realize function, let's replace the fprintf's and hw_error's with error_setg. Signed-off-by: David Hildenbrand Signed-off-by: Cornelia Huck --- hw/s390x/ipl.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index c75071d0fc..b91fcc6e79 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -76,6 +76,7 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp) S390IPLState *ipl = S390_IPL(dev); uint64_t pentry = KERN_IMAGE_START; int kernel_size; + Error *l_err = NULL; int bios_size; char *bios_filename; @@ -93,7 +94,8 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp) bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (bios_filename == NULL) { - hw_error("could not find stage1 bootloader\n"); + error_setg(&l_err, "could not find stage1 bootloader\n"); + goto error; } bios_size = load_elf(bios_filename, bios_translate_addr, &fwbase, @@ -111,7 +113,8 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp) g_free(bios_filename); if (bios_size == -1) { - hw_error("could not load bootloader '%s'\n", bios_name); + error_setg(&l_err, "could not load bootloader '%s'\n", bios_name); + goto error; } /* default boot target is the bios */ @@ -125,8 +128,8 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp) kernel_size = load_image_targphys(ipl->kernel, 0, ram_size); } if (kernel_size < 0) { - fprintf(stderr, "could not load kernel '%s'\n", ipl->kernel); - exit(1); + error_setg(&l_err, "could not load kernel '%s'\n", ipl->kernel); + goto error; } /* * Is it a Linux kernel (starting at 0x10000)? If yes, we fill in the @@ -153,9 +156,8 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp) initrd_size = load_image_targphys(ipl->initrd, initrd_offset, ram_size - initrd_offset); if (initrd_size == -1) { - fprintf(stderr, "qemu: could not load initrd '%s'\n", - ipl->initrd); - exit(1); + error_setg(&l_err, "could not load initrd '%s'\n", ipl->initrd); + goto error; } /* @@ -167,6 +169,8 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp) } } qemu_register_reset(qdev_reset_all_fn, dev); +error: + error_propagate(errp, l_err); } static Property s390_ipl_properties[] = { From 3c4c694c7ce2d21c0cf17a27cc60c91b6725ce48 Mon Sep 17 00:00:00 2001 From: Christian Borntraeger Date: Fri, 6 Nov 2015 13:07:25 +0100 Subject: [PATCH 15/15] s390: deprecate the non-ccw machine in 2.5 The non-ccw machine for s390 (s390-virtio) is not very well maintained and caused several issues in the past: - aliases like virtio-blk did not work for s390 - virtio refactoring failed due to long standing bugs (e.g.see commit cb927b8a "s390-virtio: Accommodate guests using virtqueues too early") - some features like memory hotplug will cause trouble due to virtio storage being above guest memory - the boot loader bios no longer seems to work. the source code of that loader is also no longer maintained 2.4 changed the default to the ccw machine, let's deprecate the old machine for 2.5. Signed-off-by: Christian Borntraeger Acked-by: David Hildenbrand Message-Id: <1446811645-25565-1-git-send-email-borntraeger@de.ibm.com> Signed-off-by: Cornelia Huck --- hw/s390x/s390-virtio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c index cebebb1c0a..51dc0a8aaf 100644 --- a/hw/s390x/s390-virtio.c +++ b/hw/s390x/s390-virtio.c @@ -268,6 +268,10 @@ static void s390_init(MachineState *machine) hwaddr virtio_region_len; hwaddr virtio_region_start; + 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); @@ -334,7 +338,7 @@ static void s390_machine_class_init(ObjectClass *oc, void *data) NMIClass *nc = NMI_CLASS(oc); mc->alias = "s390"; - mc->desc = "VirtIO based S390 machine"; + mc->desc = "VirtIO based S390 machine (deprecated)"; mc->init = s390_init; mc->reset = s390_machine_reset; mc->block_default_type = IF_VIRTIO;