Skip to contentSkip to conversation

Misc bugfixes for QEMU hard freeze

GIT PULL Paolo Bonzini 4 participants 19 messages Jul 5, 2019 – Jul 6, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

The following changes since commit 68d7ff0cff0c4905802104843cf0100543b47314:

Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2019-06-21 13:32:10 +0100)

are available in the git repository at:

git://github.com/bonzini/qemu.git tags/for-upstream

for you to fetch changes up to 2994e7e66a8902d0e42c5e528489ca6484c66d2d:

ioapic: use irq number instead of vector in ioapic_eoi_broadcast (2019-07-05 18:35:43 +0200)

----------------------------------------------------------------
Bugfixes.

----------------------------------------------------------------
Alex Bennée (1):
target/i386: fix feature check in hyperv-stub.c

Igor Mammedov (1):
pc: fix possible NULL pointer dereference in pc_machine_get_device_memory_region_size()

Julio Montes (2):
Makefile: generate header file with the list of devices enabled hw/i386: Fix linker error when ISAPC is disabled

Li Qiang (2):
ioapic: clear irq_eoi when updating the ioapic redirect table entry
ioapic: use irq number instead of vector in ioapic_eoi_broadcast

Liran Alon (1):
target/i386: kvm: Fix when nested state is needed for migration

Max Reitz (1):

      i386/kvm: Fix build with -m32

Paolo Bonzini (2):
checkpatch: do not warn for multiline parenthesized returned value
minikconf: do not include variables from MINIKCONF_ARGS in config-all-devices.mak

Peter Xu (1):
intel_iommu: Fix unexpected unmaps during global unmap

Yan Zhao (1):
intel_iommu: Fix incorrect "end" for vtd_address_space_unmap

 Makefile.target           |  5 ++++
 hw/i386/intel_iommu.c     | 71 ++++++++++++++++++++++++++++-------------------
 hw/i386/pc.c              |  6 +++-
 hw/i386/pc_piix.c         | 12 ++++++--
 hw/intc/ioapic.c          | 11 ++++----
 scripts/checkpatch.pl     |  3 +-
 scripts/clean-includes    |  2 +-
 scripts/create_config     |  2 ++
 scripts/minikconf.py      |  5 +++-
 target/i386/hyperv-stub.c |  2 +-
 target/i386/kvm.c         |  7 +++--
 target/i386/machine.c     |  5 ++--
 12 files changed, 84 insertions(+), 47 deletions(-)
Signature · 1 line
1.8.3.1
#1 lore raw

[Qemu-devel] [PULL 02/12] checkpatch: do not warn for multiline parenthesized returned value

While indeed we do not want to have

    return (a);

it is less clear that this applies to

    return (a &&
            b);

Some editors indent more nicely if you have parentheses, and some people's eyes may appreciate that as well.

Message-Id: <[email protected]>

---
 scripts/checkpatch.pl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/checkpatch.pl +2 -1
index c2aaf42..2f81371 100755
@@ -2296,7 +2296,8 @@ sub process {
 			       $value =~ s/\([^\(\)]*\)/1/) {
 			}
 #print "value<$value>\n";
-			if ($value =~ /^\s*(?:$Ident|-?$Constant)\s*$/) {
+			if ($value =~ /^\s*(?:$Ident|-?$Constant)\s*$/ &&
+			    $line =~ /;$/) {
 				ERROR("return is not a function, parentheses are not required\n" . $herecurr);
 
 			} elsif ($spacing !~ /\s+/) {
Signature · 1 line
1.8.3.1
#2 lore raw

[Qemu-devel] [PULL 03/12] i386/kvm: Fix build with -m32

In reply to Paolo Bonzini

From: Max Reitz <[email protected]>

find_next_bit() takes a pointer of type "const unsigned long *", but the first argument passed here is a "uint64_t *". These types are incompatible when compiling qemu with -m32.

Just use ctz64() instead.

Fixes c686193072a47032d83cb4e131dc49ae30f9e5d

Message-Id: <[email protected]>

---
 target/i386/kvm.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
target/i386/kvm.c +4 -3
index e4b4f57..31490bf 100644
@@ -1043,14 +1043,15 @@ static int hv_cpuid_check_and_set(CPUState *cs, struct kvm_cpuid2 *cpuid,
     CPUX86State *env = &cpu->env;
     uint32_t r, fw, bits;
     uint64_t deps;
-    int i, dep_feat = 0;
+    int i, dep_feat;
 
     if (!hyperv_feat_enabled(cpu, feature) && !cpu->hyperv_passthrough) {
         return 0;
     }
 
     deps = kvm_hyperv_properties[feature].dependencies;
-    while ((dep_feat = find_next_bit(&deps, 64, dep_feat)) < 64) {
+    while (deps) {
+        dep_feat = ctz64(deps);
         if (!(hyperv_feat_enabled(cpu, dep_feat))) {
                 fprintf(stderr,
                         "Hyper-V %s requires Hyper-V %s\n",
@@ -1058,7 +1059,7 @@ static int hv_cpuid_check_and_set(CPUState *cs, struct kvm_cpuid2 *cpuid,
                         kvm_hyperv_properties[dep_feat].desc);
                 return 1;
         }
-        dep_feat++;
+        deps &= ~(1ull << dep_feat);
     }
 
     for (i = 0; i < ARRAY_SIZE(kvm_hyperv_properties[feature].flags); i++) {
Signature · 1 line
1.8.3.1
#3 lore raw

[Qemu-devel] [PULL 06/12] ioapic: clear irq_eoi when updating the ioapic redirect table entry

In reply to Paolo Bonzini

From: Li Qiang <[email protected]>

irq_eoi is used to count the number of irq injected during eoi broadcast. It should be set to 0 when updating the ioapic's redirect table entry.

Message-Id: <[email protected]>

---
 hw/intc/ioapic.c | 1 +
 1 file changed, 1 insertion(+)
hw/intc/ioapic.c +1 -0
index 7074489..db9e518 100644
@@ -380,6 +380,7 @@ ioapic_mem_write(void *opaque, hwaddr addr, uint64_t val,
                 /* restore RO bits */
                 s->ioredtbl[index] &= IOAPIC_RW_BITS;
                 s->ioredtbl[index] |= ro_bits;
+                s->irq_eoi[index] = 0;
                 ioapic_fix_edge_remote_irr(&s->ioredtbl[index]);
                 ioapic_service(s);
             }
Signature · 1 line
1.8.3.1
#4 lore raw

[Qemu-devel] [PULL 01/12] pc: fix possible NULL pointer dereference in pc_machine_get_device_memory_region_size()

In reply to Paolo Bonzini

From: Igor Mammedov <[email protected]>

QEMU will crash when device-memory-region-size property is read if ms->device_memory wasn't initialized yet.

Crash can be reproduced with:
$QEMU -preconfig -qmp unix:qmp_socket,server,nowait & ./scripts/qmp/qom-get -s qmp_socket /machine.device-memory-region-size

Instead of crashing return 0 if ms->device_memory hasn't been initialized.

Message-Id: <[email protected]>

---
 hw/i386/pc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
hw/i386/pc.c +5 -1
index e96360b..552f340 100644
@@ -2458,7 +2458,11 @@ pc_machine_get_device_memory_region_size(Object *obj, Visitor *v,
                                          Error **errp)
 {
     MachineState *ms = MACHINE(obj);
-    int64_t value = memory_region_size(&ms->device_memory->mr);
+    int64_t value = 0;
+
+    if (ms->device_memory) {
+        value = memory_region_size(&ms->device_memory->mr);
+    }
 
     visit_type_int(v, name, &value, errp);
 }
Signature · 1 line
1.8.3.1
#5 lore raw

[Qemu-devel] [PULL 05/12] intel_iommu: Fix unexpected unmaps during global unmap

In reply to Paolo Bonzini

From: Peter Xu <[email protected]>

This is an replacement work of Yan Zhao's patch:

https://www.mail-archive.com/[email protected]/msg625340.html

vtd_address_space_unmap() will do proper page mask alignment to make sure each IOTLB message will have correct masks for notification messages (2^N-1), but sometimes it can be expanded to even supercede the registered range. That could lead to unexpected UNMAP of already mapped regions in some other notifiers.

Instead of doing mindless expension of the start address and address mask, we split the range into smaller ones and guarantee that each small range will have correct masks (2^N-1) and at the same time we should also try our best to generate as less IOTLB messages as possible.

Message-Id: <[email protected]>

---
 hw/i386/intel_iommu.c | 67 +++++++++++++++++++++++++++++++--------------------
 1 file changed, 41 insertions(+), 26 deletions(-)
hw/i386/intel_iommu.c +41 -26
index 719ce19..de86f53 100644
@@ -3363,11 +3363,28 @@ VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int devfn)
     return vtd_dev_as;
 }
 
+static uint64_t get_naturally_aligned_size(uint64_t start,
+                                           uint64_t size, int gaw)
+{
+    uint64_t max_mask = 1ULL << gaw;
+    uint64_t alignment = start ? start & -start : max_mask;
+
+    alignment = MIN(alignment, max_mask);
+    size = MIN(size, max_mask);
+
+    if (alignment <= size) {
+        /* Increase the alignment of start */
+        return alignment;
+    } else {
+        /* Find the largest page mask from size */
+        return 1ULL << (63 - clz64(size));
+    }
+}
+
 /* Unmap the whole range in the notifier's scope. */
 static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n)
 {
-    IOMMUTLBEntry entry;
-    hwaddr size;
+    hwaddr size, remain;
     hwaddr start = n->start;
     hwaddr end = n->end;
     IntelIOMMUState *s = as->iommu_state;
@@ -3388,39 +3405,37 @@ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n)
     }
 
     assert(start <= end);
-    size = end - start;
+    size = remain = end - start + 1;
 
-    if (ctpop64(size) != 1) {
-        /*
-         * This size cannot format a correct mask. Let's enlarge it to
-         * suite the minimum available mask.
-         */
-        int n = 64 - clz64(size);
-        if (n > s->aw_bits) {
-            /* should not happen, but in case it happens, limit it */
-            n = s->aw_bits;
-        }
-        size = 1ULL << n;
+    while (remain >= VTD_PAGE_SIZE) {
+        IOMMUTLBEntry entry;
+        uint64_t mask = get_naturally_aligned_size(start, remain, s->aw_bits);
+
+        assert(mask);
+
+        entry.iova = start;
+        entry.addr_mask = mask - 1;
+        entry.target_as = &address_space_memory;
+        entry.perm = IOMMU_NONE;
+        /* This field is meaningless for unmap */
+        entry.translated_addr = 0;
+
+        memory_region_notify_one(n, &entry);
+
+        start += mask;
+        remain -= mask;
     }
 
-    entry.target_as = &address_space_memory;
-    /* Adjust iova for the size */
-    entry.iova = n->start & ~(size - 1);
-    /* This field is meaningless for unmap */
-    entry.translated_addr = 0;
-    entry.perm = IOMMU_NONE;
-    entry.addr_mask = size - 1;
+    assert(!remain);
 
     trace_vtd_as_unmap_whole(pci_bus_num(as->bus),
                              VTD_PCI_SLOT(as->devfn),
                              VTD_PCI_FUNC(as->devfn),
-                             entry.iova, size);
+                             n->start, size);
 
-    map.iova = entry.iova;
-    map.size = entry.addr_mask;
+    map.iova = n->start;
+    map.size = size;
     iova_tree_remove(as->iova_tree, &map);
-
-    memory_region_notify_one(n, &entry);
 }
 
 static void vtd_address_space_unmap_all(IntelIOMMUState *s)
Signature · 1 line
1.8.3.1
#6 lore raw

[Qemu-devel] [PULL 09/12] target/i386: kvm: Fix when nested state is needed for migration

In reply to Paolo Bonzini

From: Liran Alon <[email protected]>

When vCPU is in VMX operation and enters SMM mode,
it temporarily exits VMX operation but KVM maintained nested-state still stores the VMXON region physical address, i.e. even when the vCPU is in SMM mode then (nested_state->hdr.vmx.vmxon_pa != -1ull).

Therefore, there is no need to explicitly check for KVM_STATE_NESTED_SMM_VMXON to determine if it is necessary to save nested-state as part of migration stream.

Message-Id: <[email protected]>

---
 target/i386/machine.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
target/i386/machine.c +2 -3
index 851b249..704ba6d 100644
@@ -997,9 +997,8 @@ static bool vmx_nested_state_needed(void *opaque)
 {
     struct kvm_nested_state *nested_state = opaque;
 
-    return ((nested_state->format == KVM_STATE_NESTED_FORMAT_VMX) &&
-            ((nested_state->hdr.vmx.vmxon_pa != -1ull) ||
-             (nested_state->hdr.vmx.smm.flags & KVM_STATE_NESTED_SMM_VMXON)));
+    return (nested_state->format == KVM_STATE_NESTED_FORMAT_VMX &&
+            nested_state->hdr.vmx.vmxon_pa != -1ull);
 }
 
 static const VMStateDescription vmstate_vmx_nested_state = {
Signature · 1 line
1.8.3.1
#7 lore raw

[Qemu-devel] [PULL 04/12] intel_iommu: Fix incorrect "end" for vtd_address_space_unmap

In reply to Paolo Bonzini

From: Yan Zhao <[email protected]>

IOMMUNotifier is with inclusive ranges, so we should check against (VTD_ADDRESS_SIZE(s->aw_bits) - 1).

[peterx: split from another bigger patch]

Message-Id: <[email protected]>

---
 hw/i386/intel_iommu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/i386/intel_iommu.c +2 -2
index 44b1231..719ce19 100644
@@ -3379,12 +3379,12 @@ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n)
      * VT-d spec), otherwise we need to consider overflow of 64 bits.
      */
 
-    if (end > VTD_ADDRESS_SIZE(s->aw_bits)) {
+    if (end > VTD_ADDRESS_SIZE(s->aw_bits) - 1) {
         /*
          * Don't need to unmap regions that is bigger than the whole
          * VT-d supported address space size
          */
-        end = VTD_ADDRESS_SIZE(s->aw_bits);
+        end = VTD_ADDRESS_SIZE(s->aw_bits) - 1;
     }
 
     assert(start <= end);
Signature · 1 line
1.8.3.1
#8 lore raw

[Qemu-devel] [PULL 07/12] target/i386: fix feature check in hyperv-stub.c

In reply to Paolo Bonzini

From: Alex Bennée <[email protected]>

Commit 2d384d7c8 broken the build when built with:

  configure --without-default-devices --disable-user

The reason was the conversion of cpu->hyperv_synic to cpu->hyperv_synic_kvm_only although the rest of the patch introduces a feature checking mechanism. So I've fixed the KVM_EXIT_HYPERV_SYNIC in hyperv-stub to do the same feature check as in the real hyperv.c

Cc Vitaly Kuznetsov <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Roman Kagan <[email protected]>

Message-Id: <[email protected]>

---
 target/i386/hyperv-stub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/hyperv-stub.c +1 -1
index fe548cb..0028527 100644
@@ -15,7 +15,7 @@ int kvm_hv_handle_exit(X86CPU *cpu, struct kvm_hyperv_exit *exit)
 {
     switch (exit->type) {
     case KVM_EXIT_HYPERV_SYNIC:
-        if (!cpu->hyperv_synic) {
+        if (!hyperv_feat_enabled(cpu, HYPERV_FEAT_SYNIC)) {
             return -1;
         }
 
Signature · 1 line
1.8.3.1
#9 lore raw

[Qemu-devel] [PULL 10/12] Makefile: generate header file with the list of devices enabled

In reply to Paolo Bonzini

From: Julio Montes <[email protected]>

v2: generate config-devices.h which contains the list of devices enabled

Message-Id: <[email protected]>

---
 Makefile.target        | 5 +++++
 scripts/clean-includes | 2 +-
 scripts/create_config  | 2 ++
 3 files changed, 8 insertions(+), 1 deletion(-)
Makefile.target +5 -0
index 72c267f..25383f5 100644
@@ -45,6 +45,9 @@ include $(SRC_PATH)/tests/tcg/Makefile.include
 config-target.h: config-target.h-timestamp
 config-target.h-timestamp: config-target.mak
 
+config-devices.h: config-devices.h-timestamp
+config-devices.h-timestamp: config-devices.mak
+
 ifdef CONFIG_TRACE_SYSTEMTAP
 stap: $(QEMU_PROG).stp-installed $(QEMU_PROG).stp $(QEMU_PROG)-simpletrace.stp $(QEMU_PROG)-log.stp
 
@@ -171,6 +174,8 @@ generated-files-y += hmp-commands.h hmp-commands-info.h
 
 endif # CONFIG_SOFTMMU
 
+generated-files-y += config-devices.h
+
 dummy := $(call unnest-vars,,obj-y)
 all-obj-y := $(obj-y)
 
scripts/clean-includes +1 -1
index dd938da..fb05a63 100755
@@ -161,7 +161,7 @@ for f in "$@"; do
   # Remove includes that osdep.h already provides
   perl -n -i -e 'print if !/\s*#\s*include\s*(["<][^>"]*[">])/ ||
                           ! (grep { $_ eq $1 } qw (
-           "config-host.h" "config-target.h" "qemu/compiler.h"
+           "config-host.h" "config-target.h" "config-devices.h" "qemu/compiler.h"
            <setjmp.h> <stdarg.h> <stddef.h> <stdbool.h> <stdint.h> <sys/types.h>
            <stdlib.h> <stdio.h> <string.h> <strings.h> <inttypes.h>
            <limits.h> <unistd.h> <time.h> <ctype.h> <errno.h> <fcntl.h>
scripts/create_config +2 -0
index d727e5e..00e86c8 100755
@@ -58,6 +58,8 @@ case $line in
     name=${line%=*}
     echo "#define $name 1"
     ;;
+ CONFIG_*=n) # configuration
+    ;;
  CONFIG_*=*) # configuration
     name=${line%=*}
     value=${line#*=}
Signature · 1 line
1.8.3.1
#10 lore raw

[Qemu-devel] [PULL 08/12] minikconf: do not include variables from MINIKCONF_ARGS in config-all-devices.mak

In reply to Paolo Bonzini

When minikconf writes config-devices.mak, it includes all variables including those from MINIKCONF_ARGS. This causes values from config-host.mak to "stick" to the ones used in generating config-devices.mak, because config-devices.mak is included after config-host.mak. Avoid this by omitting assignments coming from the command line in the output of minikconf.

---
 scripts/minikconf.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
scripts/minikconf.py +4 -1
index 0ffc6c3..3109a81 100644
@@ -688,11 +688,13 @@ if __name__ == '__main__':
 
     data = KconfigData(mode)
     parser = KconfigParser(data)
+    external_vars = set()
     for arg in argv[3:]:
         m = re.match(r'^(CONFIG_[A-Z0-9_]+)=([yn]?)$', arg)
         if m is not None:
             name, value = m.groups()
             parser.do_assignment(name, value == 'y')
+            external_vars.add(name[7:])
         else:
             fp = open(arg, 'r')
             parser.parse_file(fp)
@@ -700,7 +702,8 @@ if __name__ == '__main__':
 
     config = data.compute_config()
     for key in sorted(config.keys()):
-        print ('CONFIG_%s=%s' % (key, ('y' if config[key] else 'n')))
+        if key not in external_vars:
+            print ('CONFIG_%s=%s' % (key, ('y' if config[key] else 'n')))
 
     deps = open(argv[2], 'w')
     for fname in data.previously_included:
Signature · 1 line
1.8.3.1
#11 lore raw

[Qemu-devel] [PULL 11/12] hw/i386: Fix linker error when ISAPC is disabled

In reply to Paolo Bonzini

From: Julio Montes <[email protected]>

v2: include config-devices.h to use CONFIG_IDE_ISA

Message-Id: <[email protected]>

---
 hw/i386/pc_piix.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
hw/i386/pc_piix.c +9 -3
index c07c4a5..cc04c01 100644
@@ -23,6 +23,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "config-devices.h"
 
 #include "qemu/units.h"
 #include "hw/hw.h"
@@ -61,9 +62,11 @@
 
 #define MAX_IDE_BUS 2
 
+#ifdef CONFIG_IDE_ISA
 static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 };
 static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
 static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
+#endif
 
 /* PC hardware initialisation */
 static void pc_init1(MachineState *machine,
@@ -254,7 +257,10 @@ static void pc_init1(MachineState *machine,
         }
         idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0");
         idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1");
-    } else {
+        pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state);
+    }
+#ifdef CONFIG_IDE_ISA
+else {
         for(i = 0; i < MAX_IDE_BUS; i++) {
             ISADevice *dev;
             char busname[] = "ide.0";
@@ -268,9 +274,9 @@ static void pc_init1(MachineState *machine,
             busname[4] = '0' + i;
             idebus[i] = qdev_get_child_bus(DEVICE(dev), busname);
         }
+        pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state);
     }
-
-    pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state);
+#endif
 
     if (pcmc->pci_enabled && machine_usb(machine)) {
         pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
Signature · 1 line
1.8.3.1
#13 lore raw

Re: [Qemu-devel] [PULL 11/12] hw/i386: Fix linker error when ISAPC is disabled

Quoted 11 lines · Markus Armbruster
Quoted 6 lines · Paolo Bonzini

From: Julio Montes <[email protected]>

v2: include config-devices.h to use CONFIG_IDE_ISA

Message-Id: <[email protected]>

You lost Julio's S-o-B due to his ill-advised '---' line. Also the part of his commit message that should be committed. Same for PULL 10/12.

Ah, you fixed the S-o-B in v2. You decide whether restoring the lost parts of the commit message is worth a respin.

#14 lore raw

[Qemu-devel] [PULL 12/12] ioapic: use irq number instead of vector in ioapic_eoi_broadcast

In reply to Paolo Bonzini

From: Li Qiang <[email protected]>

When emulating irqchip in qemu, such as following command:

x86_64-softmmu/qemu-system-x86_64 -m 1024 -smp 4 -hda /home/test/test.img -machine kernel-irqchip=off --enable-kvm -vnc :0 -device edu -monitor stdio

We will get a crash with following asan output:

(qemu) /home/test/qemu5/qemu/hw/intc/ioapic.c:266:27: runtime error: index 35 out of bounds for type 'int [24]'
=================================================================
==113504==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x61b000003114 at pc 0x5579e3c7a80f bp 0x7fd004bf8c10 sp 0x7fd004bf8c00 WRITE of size 4 at 0x61b000003114 thread T4

    #0 0x5579e3c7a80e in ioapic_eoi_broadcast /home/test/qemu5/qemu/hw/intc/ioapic.c:266
    #1 0x5579e3c6f480 in apic_eoi /home/test/qemu5/qemu/hw/intc/apic.c:428
    #2 0x5579e3c720a7 in apic_mem_write /home/test/qemu5/qemu/hw/intc/apic.c:802
    #3 0x5579e3b1e31a in memory_region_write_accessor /home/test/qemu5/qemu/memory.c:503
    #4 0x5579e3b1e6a2 in access_with_adjusted_size /home/test/qemu5/qemu/memory.c:569
    #5 0x5579e3b28d77 in memory_region_dispatch_write /home/test/qemu5/qemu/memory.c:1497
    #6 0x5579e3a1b36b in flatview_write_continue /home/test/qemu5/qemu/exec.c:3323
    #7 0x5579e3a1b633 in flatview_write /home/test/qemu5/qemu/exec.c:3362
    #8 0x5579e3a1bcb1 in address_space_write /home/test/qemu5/qemu/exec.c:3452
    #9 0x5579e3a1bd03 in address_space_rw /home/test/qemu5/qemu/exec.c:3463
    #10 0x5579e3b8b979 in kvm_cpu_exec /home/test/qemu5/qemu/accel/kvm/kvm-all.c:2045
    #11 0x5579e3ae4499 in qemu_kvm_cpu_thread_fn /home/test/qemu5/qemu/cpus.c:1287
    #12 0x5579e4cbdb9f in qemu_thread_start util/qemu-thread-posix.c:502
    #13 0x7fd0146376da in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x76da)
    #14 0x7fd01436088e in __clone (/lib/x86_64-linux-gnu/libc.so.6+0x12188e

This is because in ioapic_eoi_broadcast function, we uses 'vector' to index the 's->irq_eoi'. To fix this, we should uses the irq number.

Message-Id: <[email protected]>

---
 hw/intc/ioapic.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
hw/intc/ioapic.c +5 -5
index db9e518..c408749 100644
@@ -245,8 +245,8 @@ void ioapic_eoi_broadcast(int vector)
             s->ioredtbl[n] = entry & ~IOAPIC_LVT_REMOTE_IRR;
 
             if (!(entry & IOAPIC_LVT_MASKED) && (s->irr & (1 << n))) {
-                ++s->irq_eoi[vector];
-                if (s->irq_eoi[vector] >= SUCCESSIVE_IRQ_MAX_COUNT) {
+                ++s->irq_eoi[n];
+                if (s->irq_eoi[n] >= SUCCESSIVE_IRQ_MAX_COUNT) {
                     /*
                      * Real hardware does not deliver the interrupt immediately
                      * during eoi broadcast, and this lets a buggy guest make
@@ -254,16 +254,16 @@ void ioapic_eoi_broadcast(int vector)
                      * level-triggered interrupt. Emulate this behavior if we
                      * detect an interrupt storm.
                      */
-                    s->irq_eoi[vector] = 0;
+                    s->irq_eoi[n] = 0;
                     timer_mod_anticipate(s->delayed_ioapic_service_timer,
                                          qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
                                          NANOSECONDS_PER_SECOND / 100);
-                    trace_ioapic_eoi_delayed_reassert(vector);
+                    trace_ioapic_eoi_delayed_reassert(n);
                 } else {
                     ioapic_service(s);
                 }
             } else {
-                s->irq_eoi[vector] = 0;
+                s->irq_eoi[n] = 0;
             }
         }
     }
Signature · 1 line
1.8.3.1
#15 lore raw
In reply to Paolo Bonzini
Quoted 47 lines · Paolo Bonzini

The following changes since commit 68d7ff0cff0c4905802104843cf0100543b47314:

Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2019-06-21 13:32:10 +0100)

are available in the git repository at:

git://github.com/bonzini/qemu.git tags/for-upstream

for you to fetch changes up to 2994e7e66a8902d0e42c5e528489ca6484c66d2d:

ioapic: use irq number instead of vector in ioapic_eoi_broadcast (2019-07-05 18:35:43 +0200)

----------------------------------------------------------------
Bugfixes.

----------------------------------------------------------------
Alex Bennée (1):
target/i386: fix feature check in hyperv-stub.c

Igor Mammedov (1):
pc: fix possible NULL pointer dereference in pc_machine_get_device_memory_region_size()

Julio Montes (2):
Makefile: generate header file with the list of devices enabled hw/i386: Fix linker error when ISAPC is disabled

Li Qiang (2):
ioapic: clear irq_eoi when updating the ioapic redirect table entry
ioapic: use irq number instead of vector in ioapic_eoi_broadcast

Liran Alon (1):
target/i386: kvm: Fix when nested state is needed for migration

Max Reitz (1):

      i386/kvm: Fix build with -m32

Paolo Bonzini (2):
checkpatch: do not warn for multiline parenthesized returned value
minikconf: do not include variables from MINIKCONF_ARGS in config-all-devices.mak

Peter Xu (1):
intel_iommu: Fix unexpected unmaps during global unmap

Yan Zhao (1):
intel_iommu: Fix incorrect "end" for vtd_address_space_unmap

Quoted 14 lines
 Makefile.target           |  5 ++++
 hw/i386/intel_iommu.c     | 71 ++++++++++++++++++++++++++++-------------------
 hw/i386/pc.c              |  6 +++-
 hw/i386/pc_piix.c         | 12 ++++++--
 hw/intc/ioapic.c          | 11 ++++----
 scripts/checkpatch.pl     |  3 +-
 scripts/clean-includes    |  2 +-
 scripts/create_config     |  2 ++
 scripts/minikconf.py      |  5 +++-
 target/i386/hyperv-stub.c |  2 +-
 target/i386/kvm.c         |  7 +++--
 target/i386/machine.c     |  5 ++--
 12 files changed, 84 insertions(+), 47 deletions(-)

Sent v2 with a compilation fix I had not committed. :(

Paolo

#16 lore raw
In reply to Paolo Bonzini
Quoted 4 lines · Paolo Bonzini

The following changes since commit 68d7ff0cff0c4905802104843cf0100543b47314:

Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2019-06-21 13:32:10 +0100)

Quoted 8 lines

are available in the git repository at:

git://github.com/bonzini/qemu.git tags/for-upstream

for you to fetch changes up to 2994e7e66a8902d0e42c5e528489ca6484c66d2d:

ioapic: use irq number instead of vector in ioapic_eoi_broadcast (2019-07-05 18:35:43 +0200)

Missing v2 in the subject line to distinguish this from the failed v1 pull request. And per the comments on 11/12, it may need a v3 pull request to fix an issue with a missing S-o-b.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#17 lore raw
Quoted 10 lines · Eric Blake
Quoted 9 lines · Paolo Bonzini

The following changes since commit 68d7ff0cff0c4905802104843cf0100543b47314:

Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2019-06-21 13:32:10 +0100)

are available in the git repository at:

git://github.com/bonzini/qemu.git tags/for-upstream

Quoted 7 lines
Quoted 3 lines

for you to fetch changes up to 2994e7e66a8902d0e42c5e528489ca6484c66d2d:

ioapic: use irq number instead of vector in ioapic_eoi_broadcast (2019-07-05 18:35:43 +0200)

Missing v2 in the subject line to distinguish this from the failed v1 pull request. And per the comments on 11/12, it may need a v3 pull request to fix an issue with a missing S-o-b.

Or is this the v1, and the other posting v2?

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#18 lore raw
In reply to Paolo Bonzini
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series failed build test on s390x host. Please find the details below.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
# Testing script will be invoked under the git checkout with # HEAD pointing to a commit that has the patches applied on top of "base"

# branch
set -e

echo
echo "=== ENV ==="
env

echo
echo "=== PACKAGES ==="
rpm -qa

echo
echo "=== UNAME ==="
uname -a

CC=$HOME/bin/cc
INSTALL=$PWD/install
BUILD=$PWD/build
mkdir -p $BUILD $INSTALL
SRC=$PWD
cd $BUILD
$SRC/configure --cc=$CC --prefix=$INSTALL
make -j4
# XXX: we need reliable clean up

# make check -j4 V=1
make install
=== TEST SCRIPT END ===

The full log is available at
http://patchew.org/logs/[email protected]/testing.s390x/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]