Skip to contentSkip to conversation

s390x bugfixes and cleanups

GIT PULL Applied Cornelia Huck 3 participants 13 messages Feb 3, 2015

lore
Share & tools
lore
#0 lore raw

The following changes since commit 16017c48547960539fcadb1f91d252124f442482:

softfloat: Clarify license status (2015-01-29 16:45:45 +0000)

are available in the git repository at:

git://github.com/cohuck/qemu tags/s390x-20150203

for you to fetch changes up to 553ce81c31e49d834b1bf635ab486695a4694333:

pc-bios/s390-ccw: update binary (2015-02-03 13:42:40 +0100)

----------------------------------------------------------------
Some bugfixes and cleanups for s390x, both in the new pci code and in old code.

----------------------------------------------------------------

Christian Borntraeger (2):
s390x/kvm: unknown DIAGNOSE code should give a specification
exception
pc-bios/s390-ccw: fix sparse warnings

Cornelia Huck (1):
pc-bios/s390-ccw: update binary

Frank Blaschka (2):
s390x/pci: avoid sign extension in stpcifc
s390x/pci: check for invalid function handle

Markus Armbruster (1):
s390: Plug memory leak on s390_pci_generate_event() error path

Thomas Huth (2):
s390x/kvm: Fix diag-308 register decoding s390x/ipl: Improved code indentation in s390_ipl_init()

Yi Min Zhao (1):
s390x/pci: fix dma notifications in rpcit instruction

 hw/s390x/ipl.c              |   47 ++++++++++++++++++++++---------------------
 hw/s390x/s390-pci-bus.c     |    5 +++--
 hw/s390x/s390-pci-inst.c    |   28 +++++++++++++++-----------
 pc-bios/s390-ccw.img        |  Bin 17752 -> 17752 bytes
 pc-bios/s390-ccw/bootmap.c  |    4 ++--
 pc-bios/s390-ccw/bootmap.h  |    2 +-
 pc-bios/s390-ccw/main.c     |    2 +-
 pc-bios/s390-ccw/s390-ccw.h |    2 ++
 pc-bios/s390-ccw/virtio.c   |    2 +-
 target-s390x/kvm.c          |    4 ++--
 10 files changed, 52 insertions(+), 44 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

[Qemu-devel] [PULL 2/9] s390x/pci: avoid sign extension in stpcifc

From: Frank Blaschka <[email protected]>

This patch avoids sign extension and fixes a data conversion bug in stpcifc. Both issues where found by Coverity.

---
 hw/s390x/s390-pci-inst.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
hw/s390x/s390-pci-inst.c +4 -4
index 5ea13e5..c269184 100644
@@ -784,10 +784,10 @@ int stpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba)
     stq_p(&fib.aisb, pbdev->routes.adapter.summary_addr);
     stq_p(&fib.fmb_addr, pbdev->fmb_addr);
 
-    data = (pbdev->isc << 28) | (pbdev->noi << 16) |
-           (pbdev->routes.adapter.ind_offset << 8) | (pbdev->sum << 7) |
-           pbdev->routes.adapter.summary_offset;
-    stw_p(&fib.data, data);
+    data = ((uint32_t)pbdev->isc << 28) | ((uint32_t)pbdev->noi << 16) |
+           ((uint32_t)pbdev->routes.adapter.ind_offset << 8) |
+           ((uint32_t)pbdev->sum << 7) | pbdev->routes.adapter.summary_offset;
+    stl_p(&fib.data, data);
 
     if (pbdev->fh >> ENABLE_BIT_OFFSET) {
         fib.fc |= 0x80;
Signature · 1 line
1.7.9.5
#2 lore raw

[Qemu-devel] [PULL 1/9] s390: Plug memory leak on s390_pci_generate_event() error path

In reply to Cornelia Huck

From: Markus Armbruster <[email protected]>

---
 hw/s390x/s390-pci-bus.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/s390x/s390-pci-bus.c +2 -1
index 1201b8d..d25ac74 100644
@@ -187,7 +187,7 @@ S390PCIBusDevice *s390_pci_find_dev_by_fh(uint32_t fh)
 static void s390_pci_generate_event(uint8_t cc, uint16_t pec, uint32_t fh,
                                     uint32_t fid, uint64_t faddr, uint32_t e)
 {
-    SeiContainer *sei_cont = g_malloc0(sizeof(SeiContainer));
+    SeiContainer *sei_cont;
     S390pciState *s = S390_PCI_HOST_BRIDGE(
         object_resolve_path(TYPE_S390_PCI_HOST_BRIDGE, NULL));
 
@@ -195,6 +195,7 @@ static void s390_pci_generate_event(uint8_t cc, uint16_t pec, uint32_t fh,
         return;
     }
 
+    sei_cont = g_malloc0(sizeof(SeiContainer));
     sei_cont->fh = fh;
     sei_cont->fid = fid;
     sei_cont->cc = cc;
Signature · 1 line
1.7.9.5
#3 lore raw

[Qemu-devel] [PULL 3/9] s390x/pci: check for invalid function handle

In reply to Cornelia Huck

From: Frank Blaschka <[email protected]>

broken guest may provide 0 (invalid) function handle to zpci instructions. Since we use function handle 0 to indicate an empty slot in the PHB we have to add an additional check to spot this kind of error.

---
 hw/s390x/s390-pci-bus.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/s390x/s390-pci-bus.c +1 -1
index d25ac74..dc455a2 100644
@@ -170,7 +170,7 @@ S390PCIBusDevice *s390_pci_find_dev_by_fh(uint32_t fh)
     S390pciState *s = S390_PCI_HOST_BRIDGE(
         object_resolve_path(TYPE_S390_PCI_HOST_BRIDGE, NULL));
 
-    if (!s) {
+    if (!s || !fh) {
         return NULL;
     }
 
Signature · 1 line
1.7.9.5
#4 lore raw

[Qemu-devel] [PULL 4/9] s390x/pci: fix dma notifications in rpcit instruction

In reply to Cornelia Huck

From: Yi Min Zhao <[email protected]>

The virtual I/O address range passed to rpcit instruction might not map to consecutive physical guest pages. For this we have to translate and create mapping notifications for each vioa page separately.

---
 hw/s390x/s390-pci-inst.c |   20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
hw/s390x/s390-pci-inst.c +12 -8
index c269184..9e5bc5b 100644
@@ -487,7 +487,7 @@ int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2)
     CPUS390XState *env = &cpu->env;
     uint32_t fh;
     S390PCIBusDevice *pbdev;
-    ram_addr_t size;
+    hwaddr start, end;
     IOMMUTLBEntry entry;
     MemoryRegion *mr;
 
@@ -504,7 +504,8 @@ int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2)
     }
 
     fh = env->regs[r1] >> 32;
-    size = env->regs[r2 + 1];
+    start = env->regs[r2];
+    end = start + env->regs[r2 + 1];
 
     pbdev = s390_pci_find_dev_by_fh(fh);
 
@@ -515,15 +516,18 @@ int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2)
     }
 
     mr = pci_device_iommu_address_space(pbdev->pdev)->root;
-    entry = mr->iommu_ops->translate(mr, env->regs[r2], 0);
+    while (start < end) {
+        entry = mr->iommu_ops->translate(mr, start, 0);
 
-    if (!entry.translated_addr) {
-        setcc(cpu, ZPCI_PCI_LS_ERR);
-        goto out;
+        if (!entry.translated_addr) {
+            setcc(cpu, ZPCI_PCI_LS_ERR);
+            goto out;
+        }
+
+        memory_region_notify_iommu(mr, entry);
+        start += entry.addr_mask + 1;
     }
 
-    entry.addr_mask = size - 1;
-    memory_region_notify_iommu(mr, entry);
     setcc(cpu, ZPCI_PCI_LS_OK);
 out:
     return 0;
Signature · 1 line
1.7.9.5
#5 lore raw

[Qemu-devel] [PULL 5/9] s390x/kvm: Fix diag-308 register decoding

In reply to Cornelia Huck

From: Thomas Huth <[email protected]>

Fix the decoding of the r1 register number in the diagnose 308 handler.

---
 target-s390x/kvm.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target-s390x/kvm.c +1 -1
index dcd7505..6bf2719 100644
@@ -1046,7 +1046,7 @@ static void kvm_handle_diag_308(S390CPU *cpu, struct kvm_run *run)
     uint64_t r1, r3;
 
     cpu_synchronize_state(CPU(cpu));
-    r1 = (run->s390_sieic.ipa & 0x00f0) >> 8;
+    r1 = (run->s390_sieic.ipa & 0x00f0) >> 4;
     r3 = run->s390_sieic.ipa & 0x000f;
     handle_diag_308(&cpu->env, r1, r3);
 }
Signature · 1 line
1.7.9.5
#6 lore raw

[Qemu-devel] [PULL 7/9] s390x/ipl: Improved code indentation in s390_ipl_init()

In reply to Cornelia Huck

From: Thomas Huth <[email protected]>

The indentation of the code in s390_ipl_init() can be simplified a little bit by removing superfluous else-statements.

---
 hw/s390x/ipl.c |   47 ++++++++++++++++++++++++-----------------------
 1 file changed, 24 insertions(+), 23 deletions(-)
hw/s390x/ipl.c +24 -23
index 3b77c9a..4ba8409 100644
@@ -62,6 +62,7 @@ typedef struct S390IPLState {
 static int s390_ipl_init(SysBusDevice *dev)
 {
     S390IPLState *ipl = S390_IPL(dev);
+    uint64_t pentry = KERN_IMAGE_START;
     int kernel_size;
 
     if (!ipl->kernel) {
@@ -94,31 +95,31 @@ static int s390_ipl_init(SysBusDevice *dev)
             hw_error("could not load bootloader '%s'\n", bios_name);
         }
         return 0;
+    }
+
+    kernel_size = load_elf(ipl->kernel, NULL, NULL, &pentry, NULL,
+                           NULL, 1, ELF_MACHINE, 0);
+    if (kernel_size < 0) {
+        kernel_size = load_image_targphys(ipl->kernel, 0, ram_size);
+    }
+    if (kernel_size < 0) {
+        fprintf(stderr, "could not load kernel '%s'\n", ipl->kernel);
+        return -1;
+    }
+    /*
+     * Is it a Linux kernel (starting at 0x10000)? If yes, we fill in the
+     * kernel parameters here as well. Note: For old kernels (up to 3.2)
+     * we can not rely on the ELF entry point - it was 0x800 (the SALIPL
+     * loader) and it won't work. For this case we force it to 0x10000, too.
+     */
+    if (pentry == KERN_IMAGE_START || pentry == 0x800) {
+        ipl->start_addr = KERN_IMAGE_START;
+        /* Overwrite parameters in the kernel image, which are "rom" */
+        strcpy(rom_ptr(KERN_PARM_AREA), ipl->cmdline);
     } else {
-        uint64_t pentry = KERN_IMAGE_START;
-        kernel_size = load_elf(ipl->kernel, NULL, NULL, &pentry, NULL,
-                               NULL, 1, ELF_MACHINE, 0);
-        if (kernel_size < 0) {
-            kernel_size = load_image_targphys(ipl->kernel, 0, ram_size);
-        }
-        if (kernel_size < 0) {
-            fprintf(stderr, "could not load kernel '%s'\n", ipl->kernel);
-            return -1;
-        }
-        /*
-         * Is it a Linux kernel (starting at 0x10000)? If yes, we fill in the
-         * kernel parameters here as well. Note: For old kernels (up to 3.2)
-         * we can not rely on the ELF entry point - it was 0x800 (the SALIPL
-         * loader) and it won't work. For this case we force it to 0x10000, too.
-         */
-        if (pentry == KERN_IMAGE_START || pentry == 0x800) {
-            ipl->start_addr = KERN_IMAGE_START;
-            /* Overwrite parameters in the kernel image, which are "rom" */
-            strcpy(rom_ptr(KERN_PARM_AREA), ipl->cmdline);
-        } else {
-            ipl->start_addr = pentry;
-        }
+        ipl->start_addr = pentry;
     }
+
     if (ipl->initrd) {
         ram_addr_t initrd_offset;
         int initrd_size;
Signature · 1 line
1.7.9.5
#7 lore raw

[Qemu-devel] [PULL 9/9] pc-bios/s390-ccw: update binary

In reply to Cornelia Huck
---
 pc-bios/s390-ccw.img |  Bin 17752 -> 17752 bytes
 1 file changed, 0 insertions(+), 0 deletions(-)
pc-bios/s390-ccw.img binary +0 -0
index 44873ad1817f44a5610ea556f86394b2c4a4c1ff..dbe5a38262cf6f2013154a77e850cda90e0fcaec 100644
GIT binary patch
Signature · 1 line
1.7.9.5
#8 lore raw

[Qemu-devel] [PULL 6/9] s390x/kvm: unknown DIAGNOSE code should give a specification exception

In reply to Cornelia Huck

From: Christian Borntraeger <[email protected]>

As described in CP programming services an unimplemented DIAGNOSE function should return a specification exception. Today we give the guest an operation exception.
As both exception types are suppressing and Linux as a guest does not care about the type of program check in its exception table handler as long as both types have the same kind of error handling (nullifying, terminating, suppressing etc.) this was unnoticed.

---
 target-s390x/kvm.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target-s390x/kvm.c +1 -1
index 6bf2719..6f2d5b4 100644
@@ -1091,7 +1091,7 @@ static int handle_diag(S390CPU *cpu, struct kvm_run *run, uint32_t ipb)
         break;
     default:
         DPRINTF("KVM: unknown DIAG: 0x%x\n", func_code);
-        r = -1;
+        enter_pgmcheck(cpu, PGM_SPECIFICATION);
         break;
     }
 
Signature · 1 line
1.7.9.5
#9 lore raw

[Qemu-devel] [PULL 8/9] pc-bios/s390-ccw: fix sparse warnings

In reply to Cornelia Huck

From: Christian Borntraeger <[email protected]>

Fix some sparse warnings in the s390-ccw bios.

---
 pc-bios/s390-ccw/bootmap.c  |    4 ++--
 pc-bios/s390-ccw/bootmap.h  |    2 +-
 pc-bios/s390-ccw/main.c     |    2 +-
 pc-bios/s390-ccw/s390-ccw.h |    2 ++
 pc-bios/s390-ccw/virtio.c   |    2 +-
 5 files changed, 7 insertions(+), 5 deletions(-)
pc-bios/s390-ccw/bootmap.c +2 -2
index 115d8bb..b678d5e 100644
@@ -33,7 +33,7 @@ typedef struct ResetInfo {
     uint32_t ipl_continue;
 } ResetInfo;
 
-ResetInfo save;
+static ResetInfo save;
 
 static void jump_to_IPL_2(void)
 {
@@ -80,7 +80,7 @@ static void jump_to_IPL_code(uint64_t address)
  */
 
 static unsigned char _bprs[8*1024]; /* guessed "max" ECKD sector size */
-const int max_bprs_entries = sizeof(_bprs) / sizeof(ExtEckdBlockPtr);
+static const int max_bprs_entries = sizeof(_bprs) / sizeof(ExtEckdBlockPtr);
 
 static inline void verify_boot_info(BootInfo *bip)
 {
pc-bios/s390-ccw/bootmap.h +1 -1
index 6a4823d..ab132e3 100644
@@ -15,7 +15,7 @@
 #include "virtio.h"
 
 typedef uint64_t block_number_t;
-#define NULL_BLOCK_NR 0xffffffffffffffff
+#define NULL_BLOCK_NR 0xffffffffffffffffULL
 
 #define FREE_SPACE_FILLER '\xAA'
 
pc-bios/s390-ccw/main.c +1 -1
index f9ec215..6f707bb 100644
@@ -13,7 +13,7 @@
 
 char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE)));
 uint64_t boot_value;
-struct subchannel_id blk_schid = { .one = 1 };
+static struct subchannel_id blk_schid = { .one = 1 };
 
 /*
  * Priniciples of Operations (SA22-7832-09) chapter 17 requires that
pc-bios/s390-ccw/s390-ccw.h +2 -0
index 2b773de..ceb7418 100644
@@ -51,6 +51,8 @@ void disabled_wait(void);
 /* main.c */
 void virtio_panic(const char *string);
 void write_subsystem_identification(void);
+extern char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE)));
+extern uint64_t boot_value;
 
 /* sclp-ascii.c */
 void sclp_print(const char *string);
pc-bios/s390-ccw/virtio.c +1 -1
index c0540d1..4dc91a7 100644
@@ -11,7 +11,7 @@
 #include "s390-ccw.h"
 #include "virtio.h"
 
-struct vring block;
+static struct vring block;
 
 static char chsc_page[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE)));
 
Signature · 1 line
1.7.9.5
#10 lore raw
In reply to Cornelia Huck
Quoted 10 lines · Cornelia Huck

The following changes since commit 16017c48547960539fcadb1f91d252124f442482:

softfloat: Clarify license status (2015-01-29 16:45:45 +0000)

are available in the git repository at:

git://github.com/cohuck/qemu tags/s390x-20150203

for you to fetch changes up to 553ce81c31e49d834b1bf635ab486695a4694333:

Quoted 7 lines

pc-bios/s390-ccw: update binary (2015-02-03 13:42:40 +0100)

----------------------------------------------------------------
Some bugfixes and cleanups for s390x, both in the new pci code and in old code.

----------------------------------------------------------------

I'm a bit sad my fix-clang-warnings-in-s390 code patches didn't make it in to this pull, because I think they're the only remaining obstacle to my enabling warnings-are-errors in that build config...

-- PMM

#11 lore raw

Am 03.02.2015 um 14:45 schrieb Peter Maydell:

Quoted 17 lines · Cornelia Huck
Quoted 16 lines

The following changes since commit 16017c48547960539fcadb1f91d252124f442482:

softfloat: Clarify license status (2015-01-29 16:45:45 +0000)

are available in the git repository at:

git://github.com/cohuck/qemu tags/s390x-20150203

for you to fetch changes up to 553ce81c31e49d834b1bf635ab486695a4694333:

pc-bios/s390-ccw: update binary (2015-02-03 13:42:40 +0100)

----------------------------------------------------------------
Some bugfixes and cleanups for s390x, both in the new pci code and in old code.

Quoted 6 lines
Quoted 1 line

----------------------------------------------------------------

I'm a bit sad my fix-clang-warnings-in-s390 code patches didn't make it in to this pull, because I think they're the only remaining obstacle to my enabling warnings-are-errors in that build config...

These fixes are tcg code, so Alex or Richard should take these.

Christian

#12 lore raw
In reply to Cornelia Huck
Quoted 10 lines · Cornelia Huck

The following changes since commit 16017c48547960539fcadb1f91d252124f442482:

softfloat: Clarify license status (2015-01-29 16:45:45 +0000)

are available in the git repository at:

git://github.com/cohuck/qemu tags/s390x-20150203

for you to fetch changes up to 553ce81c31e49d834b1bf635ab486695a4694333:

Quoted 7 lines

pc-bios/s390-ccw: update binary (2015-02-03 13:42:40 +0100)

----------------------------------------------------------------
Some bugfixes and cleanups for s390x, both in the new pci code and in old code.

----------------------------------------------------------------

Applied, thanks.

-- PMM