Skip to contentSkip to conversation

Misc patches for 2016-06-01

GIT PULL Paolo Bonzini 2 participants 7 messages Jun 1, 2017 – Jun 2, 2017

lore
Share & tools
lore
#0 lore raw

The following changes since commit 56821559f0ba682fe6b367815572e6f974d329ab:

Merge remote-tracking branch 'dgilbert/tags/pull-hmp-20170517' into staging (2017-05-18 13:36:15 +0100)

are available in the git repository at:

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

for you to fetch changes up to f3c3ad2dc98c6610152355f6a4de1445efc87421:

cpus: reset throttle_thread_scheduled after sleep (2017-06-01 18:01:05 +0200)

----------------------------------------------------------------
* virtio-scsi use-after-free fix (Fam)
* vhost-user-scsi support (Felipe)
* SMM fixes and improvements for TCG (myself, Mihail)
* irqchip and AddressSpaceDispatch cleanups and fixes (Peter)
* Coverity fix (Stefano)
* NBD cleanups and fixes (Vladimir, Eric, myself)
* RTC accuracy improvements and code cleanups (Guangrong+Yunfang)
* socket error reporting improvement (Daniel)
* GDB XML description for SSE registers (Abdallah)
* kvmclock update fix (Denis)
* SMM memory savings (Gonglei)
* -cpu 486 fix (Paolo)
* various bugfixes (Roman, Peter, myself, Thomas)
* rtc-test improvement (Guangrong)
* migration throttling fix (Felipe)

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

Fixed patchew build failure, added another patch.

Abdallah Bouassida (1):
target/i386: Add GDB XML description for SSE registers

Daniel P. Berrange (1):
sockets: improve error reporting if UNIX socket path is too long

Denis Plotnikov (1):
kvmclock: update system_time_msr address forcibly

Eric Blake (1):
nbd: Fully initialize client in case of failed negotiation

Fam Zheng (1):
virtio-scsi: Unset hotplug handler when unrealize

Felipe Franciosi (3):
vhost-user-scsi: Introduce vhost-user-scsi host device
vhost-user-scsi: Introduce a vhost-user-scsi sample application
cpus: reset throttle_thread_scheduled after sleep

Gonglei (1):
kvm: don't register smram_listener when smm is off

Mihail Abakumov (1):
i386: fix read/write cr with icount option

Paolo Bonzini (5):
target/i386: enable A20 automatically in system management mode target/i386: use multiple CPU AddressSpaces
linuxboot_dma: compile for i486
edu: fix memory leak on msi_broken platforms
nbd: make it thread-safe, fix qcow2 over nbd

Peter Xu (5):
kvm: irqchip: trace changes on msi add/remove
msix: trace control bit write op
kvm: irqchip: skip update msi when disabled
exec: simplify phys_page_find() params
exec: fix address_space_get_iotlb_entry page mask

Roman Pen (1):
i386/kvm: do not zero out segment flags if segment is unusable or not present

Stefano Stabellini (1):
Check the return value of fcntl in qemu_set_cloexec

Tai Yunfang (1):
mc146818rtc: precisely count the clock for periodic timer

Thomas Huth (1):
hw/core: nmi.c can be compiled as common-obj nowadays

Vladimir Sementsov-Ogievskiy (5):
nbd: strict nbd_wr_syncv
nbd: read_sync and friends: return 0 on success
nbd: add errp parameter to nbd_wr_syncv()
nbd: add errp to read_sync, write_sync and drop_sync nbd/client.c: use errp instead of LOG

Xiao Guangrong (5):
mc146818rtc: update periodic timer only if it is needed
mc146818rtc: ensure LOST_TICK_POLICY_SLEW is only enabled on TARGET_I386
mc146818rtc: drop unnecessary '#ifdef TARGET_I386'
mc146818rtc: embrace all x86 specific code
qtest: add rtc periodic timer test

 .gitignore                                |   1 +
 Makefile                                  |   3 +
 Makefile.objs                             |   4 +
 block/nbd-client.c                        |  41 +-
 configure                                 |   4 +-
 contrib/libvhost-user/libvhost-user.h     |  11 +-
 contrib/vhost-user-scsi/Makefile.objs     |   1 +
 contrib/vhost-user-scsi/vhost-user-scsi.c | 886 ++++++++++++++++++++++++++++++
 cpus.c                                    |   2 +-
 default-configs/pci.mak                   |   1 +
 default-configs/s390x-softmmu.mak         |   1 +
 exec.c                                    |  27 +-
 gdb-xml/i386-32bit-sse.xml                |  52 ++
 gdb-xml/i386-32bit.xml                    |  14 +
 gdb-xml/i386-64bit-sse.xml                |  60 ++
 gdb-xml/i386-64bit.xml                    |  14 +
 hw/core/Makefile.objs                     |   2 +-
 hw/i386/kvm/clock.c                       |   3 +
 hw/misc/edu.c                             |  12 +-
 hw/pci/msix.c                             |  11 +-
 hw/pci/trace-events                       |   3 +
 hw/scsi/Makefile.objs                     |   1 +
 hw/scsi/vhost-scsi-common.c               |   1 -
 hw/scsi/vhost-user-scsi.c                 | 211 +++++++
 hw/scsi/virtio-scsi.c                     |   3 +
 hw/timer/mc146818rtc.c                    | 203 ++++---
 hw/virtio/virtio-pci.c                    |  54 ++
 hw/virtio/virtio-pci.h                    |  11 +
 include/block/nbd.h                       |   8 +-
 include/hw/timer/mc146818rtc_regs.h       |  20 +
 include/hw/virtio/vhost-user-scsi.h       |  35 ++
 include/hw/virtio/virtio-scsi.h           |   2 +
 kvm-all.c                                 |   8 +-
 nbd/client.c                              | 125 ++---
 nbd/common.c                              |  23 +-
 nbd/nbd-internal.h                        |  40 +-
 nbd/server.c                              | 100 ++--
 pc-bios/linuxboot_dma.bin                 | Bin 1536 -> 1536 bytes
 pc-bios/optionrom/Makefile                |   1 +
 qemu-nbd.c                                |   5 +-
 target/i386/arch_memory_mapping.c         |  18 +-
 target/i386/cpu.c                         |  23 +-
 target/i386/cpu.h                         |  20 +-
 target/i386/helper.c                      |  96 ++--
 target/i386/kvm.c                         |  36 +-
 target/i386/machine.c                     |   4 -
 target/i386/smm_helper.c                  |  18 -
 target/i386/translate.c                   |  12 +
 tests/qemu-iotests/083.out                |   2 +
 tests/rtc-test.c                          |  49 ++
 trace-events                              |   3 +-
 util/oslib-posix.c                        |   4 +-
 util/qemu-sockets.c                       |  68 ++-
 53 files changed, 1956 insertions(+), 401 deletions(-)
 create mode 100644 contrib/vhost-user-scsi/Makefile.objs
 create mode 100644 contrib/vhost-user-scsi/vhost-user-scsi.c
 create mode 100644 gdb-xml/i386-32bit-sse.xml
 create mode 100644 gdb-xml/i386-32bit.xml
 create mode 100644 gdb-xml/i386-64bit-sse.xml
 create mode 100644 gdb-xml/i386-64bit.xml
 create mode 100644 hw/scsi/vhost-user-scsi.c
 create mode 100644 include/hw/virtio/vhost-user-scsi.h
Signature · 1 line
2.13.0
#1 lore raw

[Qemu-devel] [PULL 06/34] qtest: add rtc periodic timer test

From: Xiao Guangrong <[email protected]>

It tests the accuracy of rtc periodic timer which is recently improved & fixed by commit 7ffcb539a3 ("mc146818rtc: precisely count the clock for periodic timer", 2017-05-19).

Message-Id: <[email protected]>

---
 hw/timer/mc146818rtc.c              | 15 +++---------
 include/hw/timer/mc146818rtc_regs.h | 20 +++++++++++++++
 tests/rtc-test.c                    | 49 +++++++++++++++++++++++++++++++++++++
 3 files changed, 72 insertions(+), 12 deletions(-)
hw/timer/mc146818rtc.c +3 -12
index 542cd09bc1..1b8d3d7d4c 100644
@@ -120,7 +120,7 @@ static void rtc_coalesced_timer_update(RTCState *s)
         /* divide each RTC interval to 2 - 8 smaller intervals */
         int c = MIN(s->irq_coalesced, 7) + 1; 
         int64_t next_clock = qemu_clock_get_ns(rtc_clock) +
-            muldiv64(s->period / c, NANOSECONDS_PER_SECOND, RTC_CLOCK_RATE);
+            periodic_clock_to_ns(s->period / c);
         timer_mod(s->coalesced_timer, next_clock);
     }
 }
@@ -178,16 +178,8 @@ static uint32_t rtc_periodic_clock_ticks(RTCState *s)
      }
 
     period_code = s->cmos_data[RTC_REG_A] & 0x0f;
-    if (!period_code) {
-        return 0;
-    }
-
-    if (period_code <= 2) {
-        period_code += 7;
-    }
 
-    /* period in 32 Khz cycles */
-    return 1 << (period_code - 1);
+    return periodic_period_to_clock(period_code);
 }
 
 /*
@@ -260,8 +252,7 @@ periodic_timer_update(RTCState *s, int64_t current_time, uint32_t old_period)
         assert(lost_clock >= 0 && lost_clock <= period);
 
         next_irq_clock = cur_clock + period - lost_clock;
-        s->next_periodic_time = muldiv64(next_irq_clock, NANOSECONDS_PER_SECOND,
-                                         RTC_CLOCK_RATE) + 1;
+        s->next_periodic_time = periodic_clock_to_ns(next_irq_clock) + 1;
         timer_mod(s->periodic_timer, s->next_periodic_time);
     } else {
         s->irq_coalesced = 0;
include/hw/timer/mc146818rtc_regs.h +20 -0
index 6ede6c832e..c62f17bf2d 100644
@@ -65,4 +65,24 @@
 #define REG_C_AF   0x20
 #define REG_C_MASK 0x70
 
+static inline uint32_t periodic_period_to_clock(int period_code)
+{
+    if (!period_code) {
+        return 0;
+   }
+
+    if (period_code <= 2) {
+        period_code += 7;
+    }
+    /* period in 32 Khz cycles */
+   return 1 << (period_code - 1);
+}
+
+#define RTC_CLOCK_RATE            32768
+
+static inline int64_t periodic_clock_to_ns(int64_t clocks)
+{
+    return muldiv64(clocks, NANOSECONDS_PER_SECOND, RTC_CLOCK_RATE);
+}
+
 #endif
tests/rtc-test.c +49 -0

67 lines not on this page · raw message

Signature · 1 line
2.13.0
#2 lore raw

[Qemu-devel] [PULL 34/34] cpus: reset throttle_thread_scheduled after sleep

In reply to Paolo Bonzini

From: Felipe Franciosi <[email protected]>

Currently, the throttle_thread_scheduled flag is reset back to 0 before sleeping (as part of the throttling logic). Given that throttle_timer (well, any timer) may tick with a slight delay, it so happens that under heavy throttling (ie. close or on CPU_THROTTLE_PCT_MAX) the tick may schedule a further cpu_throttle_thread() work item after the flag reset, but before the previous sleep completed. This results on the vCPU thread sleeping continuously for potentially several seconds in a row.

The chances of that happening can be drastically minimised by resetting the flag after the sleep.

Message-Id: <[email protected]>

---
 cpus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cpus.c +1 -1
index 516e5cbac1..f42eebda91 100644
@@ -677,9 +677,9 @@ static void cpu_throttle_thread(CPUState *cpu, run_on_cpu_data opaque)
     sleeptime_ns = (long)(throttle_ratio * CPU_THROTTLE_TIMESLICE_NS);
 
     qemu_mutex_unlock_iothread();
-    atomic_set(&cpu->throttle_thread_scheduled, 0);
     g_usleep(sleeptime_ns / 1000); /* Convert ns to us for usleep call */
     qemu_mutex_lock_iothread();
+    atomic_set(&cpu->throttle_thread_scheduled, 0);
 }
 
 static void cpu_throttle_timer_tick(void *opaque)
Signature · 1 line
2.13.0
#3 lore raw
In reply to Paolo Bonzini
Quoted 12 lines · Paolo Bonzini

The following changes since commit 56821559f0ba682fe6b367815572e6f974d329ab:

Merge remote-tracking branch 'dgilbert/tags/pull-hmp-20170517' into staging (2017-05-18 13:36:15 +0100)

are available in the git repository at:

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

for you to fetch changes up to f3c3ad2dc98c6610152355f6a4de1445efc87421:

cpus: reset throttle_thread_scheduled after sleep (2017-06-01 18:01:05 +0200)

Quoted 16 lines

----------------------------------------------------------------
* virtio-scsi use-after-free fix (Fam)
* vhost-user-scsi support (Felipe)
* SMM fixes and improvements for TCG (myself, Mihail)
* irqchip and AddressSpaceDispatch cleanups and fixes (Peter)
* Coverity fix (Stefano)
* NBD cleanups and fixes (Vladimir, Eric, myself)
* RTC accuracy improvements and code cleanups (Guangrong+Yunfang)
* socket error reporting improvement (Daniel)
* GDB XML description for SSE registers (Abdallah)
* kvmclock update fix (Denis)
* SMM memory savings (Gonglei)
* -cpu 486 fix (Paolo)
* various bugfixes (Roman, Peter, myself, Thomas)
* rtc-test improvement (Guangrong)
* migration throttling fix (Felipe)

Test failure on OSX:

TEST: tests/device-introspect-test... (pid=66373)

  /aarch64/device/introspect/list:                                     OK
  /aarch64/device/introspect/none:                                     OK
  /aarch64/device/introspect/abstract:                                 OK
  /aarch64/device/introspect/concrete:                                 **

ERROR:/root/qemu/qom/object.c:364:object_initialize_with_type:
assertion failed: (type != NULL)
Broken pipe

Test failures on FreeBSD:
GTESTER check-qtest-aarch64
** ERROR:/Users/pm215/src/qemu-for-merges/qom/object.c:364:void object_initialize_with_type(void *, size_t, TypeImpl *): assertion
failed: (type != NULL)
Broken pipe
GTester: last random seed: R02S8983f4bd019deabaf27dbf8281490ab9
GTESTER check-qtest-alpha
** ERROR:/Users/pm215/src/qemu-for-merges/qom/object.c:364:void object_initialize_with_type(void *, size_t, TypeImpl *): assertion
failed: (type != NULL)
Broken pipe
GTester: last random seed: R02S5ba80c00f420a9cbe79b7926bc90901c
GTESTER check-qtest-arm
** ERROR:/Users/pm215/src/qemu-for-merges/qom/object.c:364:void object_initialize_with_type(void *, size_t, TypeImpl *): assertion
failed: (type != NULL)
Broken pipe
GTester: last random seed: R02S9a3f10d16d54467f421a79a355a25714
GTESTER check-qtest-cris
GTESTER check-qtest-i386
"kvm" accelerator not found.
"kvm" accelerator not found.
"kvm" accelerator not found.
"kvm" accelerator not found.
"kvm" accelerator not found.
"kvm" accelerator not found.
"kvm" accelerator not found.
"kvm" accelerator not found.
"kvm" accelerator not found.
"kvm" accelerator not found.
** ERROR:/Users/pm215/src/qemu-for-merges/qom/object.c:364:void object_initialize_with_type(void *, size_t, TypeImpl *): assertion
failed: (type != NULL)
Broken pipe
GTester: last random seed: R02S29797c8935576bfd6237cce3e02075c9
GTESTER check-qtest-lm32
GTESTER check-qtest-m68k
GTESTER check-qtest-microblaze
GTESTER check-qtest-microblazeel
GTESTER check-qtest-mips
** ERROR:/Users/pm215/src/qemu-for-merges/qom/object.c:364:void object_initialize_with_type(void *, size_t, TypeImpl *): assertion
failed: (type != NULL)
Broken pipe
GTester: last random seed: R02S1d5b7d14f648cc07be3bfc003b7c66a2
GTESTER check-qtest-mips64
** ERROR:/Users/pm215/src/qemu-for-merges/qom/object.c:364:void object_initialize_with_type(void *, size_t, TypeImpl *): assertion
failed: (type != NULL)
Broken pipe
GTester: last random seed: R02S6c9d59bd8f80319effd07c498108c129
GTESTER check-qtest-mips64el
** ERROR:/Users/pm215/src/qemu-for-merges/qom/object.c:364:void object_initialize_with_type(void *, size_t, TypeImpl *): assertion
failed: (type != NULL)
Broken pipe
GTester: last random seed: R02S530b42302d04c589e6a5f1fc49268dcb
GTESTER check-qtest-mipsel
** ERROR:/Users/pm215/src/qemu-for-merges/qom/object.c:364:void object_initialize_with_type(void *, size_t, TypeImpl *): assertion
failed: (type != NULL)
Broken pipe
GTester: last random seed: R02S404f19f557f26102621573b7b8641871
GTESTER check-qtest-moxie
GTESTER check-qtest-nios2
GTESTER check-qtest-or1k
GTESTER check-qtest-ppc
** ERROR:/Users/pm215/src/qemu-for-merges/qom/object.c:364:void object_initialize_with_type(void *, size_t, TypeImpl *): assertion
failed: (type != NULL)
Broken pipe
GTester: last random seed: R02S8a9874d645fde55f36b7df0204c82959
GTESTER check-qtest-ppc64
** ERROR:/Users/pm215/src/qemu-for-merges/qom/object.c:364:void object_initialize_with_type(void *, size_t, TypeImpl *): assertion
failed: (type != NULL)
Broken pipe
GTester: last random seed: R02S1bf51dd7caadd650ac3be82bd21cbae5
GTESTER check-qtest-ppcemb
** ERROR:/Users/pm215/src/qemu-for-merges/qom/object.c:364:void object_initialize_with_type(void *, size_t, TypeImpl *): assertion
failed: (type != NULL)
Broken pipe
GTester: last random seed: R02Sbb3adb4867092ddb73e7fc0ecfe68c96
GTESTER check-qtest-s390x
** ERROR:/Users/pm215/src/qemu-for-merges/qom/object.c:364:void object_initialize_with_type(void *, size_t, TypeImpl *): assertion
failed: (type != NULL)
Broken pipe
GTester: last random seed: R02S2e85df237abb737f12c5aba4c0592c41
GTESTER check-qtest-sh4
** ERROR:/Users/pm215/src/qemu-for-merges/qom/object.c:364:void object_initialize_with_type(void *, size_t, TypeImpl *): assertion
failed: (type != NULL)
Broken pipe
GTester: last random seed: R02S36667c3c9283bf56a54f105edfd951c4
GTESTER check-qtest-sh4eb
** ERROR:/Users/pm215/src/qemu-for-merges/qom/object.c:364:void object_initialize_with_type(void *, size_t, TypeImpl *): assertion
failed: (type != NULL)
Broken pipe
GTester: last random seed: R02S7a8f453c29b24767afcbf5af6c890072
GTESTER check-qtest-sparc
GTESTER check-qtest-sparc64
** ERROR:/Users/pm215/src/qemu-for-merges/qom/object.c:364:void object_initialize_with_type(void *, size_t, TypeImpl *): assertion
failed: (type != NULL)
Broken pipe
GTester: last random seed: R02Scf61ab29a9f9630cf0661370bca2f09d
GTESTER check-qtest-tricore
GTESTER check-qtest-unicore32
GTESTER check-qtest-x86_64
"kvm" accelerator not found.
"kvm" accelerator not found.
"kvm" accelerator not found.
"kvm" accelerator not found.
"kvm" accelerator not found.
"kvm" accelerator not found.
"kvm" accelerator not found.
"kvm" accelerator not found.
"kvm" accelerator not found.
"kvm" accelerator not found.
** ERROR:/Users/pm215/src/qemu-for-merges/qom/object.c:364:void object_initialize_with_type(void *, size_t, TypeImpl *): assertion
failed: (type != NULL)
Broken pipe
GTester: last random seed: R02S1639c5bd5af52de8b1b097d44666b889
GTESTER check-qtest-xtensa
GTESTER check-qtest-xtensaeb

(Yes, the test's error messages are pretty useless.)

thanks
-- PMM

#4 lore raw
Quoted 10 lines · Peter Maydell

Test failure on OSX:

TEST: tests/device-introspect-test... (pid=66373)

  /aarch64/device/introspect/list:                                     OK
  /aarch64/device/introspect/none:                                     OK
  /aarch64/device/introspect/abstract:                                 OK
  /aarch64/device/introspect/concrete:                                 **

ERROR:/root/qemu/qom/object.c:364:object_initialize_with_type:
assertion failed: (type != NULL)
Broken pipe

Got those the wrong way round -- this is the FreeBSD failure and the other lot are OSX. Pretty sure it's the same error, though -- it's just that for some reason my OSX setup doesn't actually cause make to exit with an error when a test fails, so it goes on to hit what's probably the same bug in all the other check-qtest-$ARCH targets rather than bailing out.

thanks
-- PMM

#5 lore raw
Quoted 12 lines · Peter Maydell
Quoted 10 lines · Peter Maydell

Test failure on OSX:

TEST: tests/device-introspect-test... (pid=66373)

  /aarch64/device/introspect/list:                                     OK
  /aarch64/device/introspect/none:                                     OK
  /aarch64/device/introspect/abstract:                                 OK
  /aarch64/device/introspect/concrete:                                 **

ERROR:/root/qemu/qom/object.c:364:object_initialize_with_type:
assertion failed: (type != NULL)
Broken pipe

Quoted 6 lines

Got those the wrong way round -- this is the FreeBSD failure and the other lot are OSX. Pretty sure it's the same error, though -- it's just that for some reason my OSX setup doesn't actually cause make to exit with an error when a test fails, so it goes on to hit what's probably the same bug in all the other check-qtest-$ARCH targets rather than bailing out.

Thanks, any chance you can bisect these? I'll install a FreeBSD VM next week.

Paolo

#6 lore raw
Quoted 20 lines · Paolo Bonzini
Quoted 12 lines · Peter Maydell
Quoted 10 lines · Peter Maydell

Test failure on OSX:

TEST: tests/device-introspect-test... (pid=66373)

  /aarch64/device/introspect/list:                                     OK
  /aarch64/device/introspect/none:                                     OK
  /aarch64/device/introspect/abstract:                                 OK
  /aarch64/device/introspect/concrete:                                 **

ERROR:/root/qemu/qom/object.c:364:object_initialize_with_type:
assertion failed: (type != NULL)
Broken pipe

Quoted 6 lines

Got those the wrong way round -- this is the FreeBSD failure and the other lot are OSX. Pretty sure it's the same error, though -- it's just that for some reason my OSX setup doesn't actually cause make to exit with an error when a test fails, so it goes on to hit what's probably the same bug in all the other check-qtest-$ARCH targets rather than bailing out.

Quoted 2 lines

Thanks, any chance you can bisect these? I'll install a FreeBSD VM next week.

No bisection, but using QTEST_LOG:

QTEST_LOG=1 QTEST_QEMU_BINARY=aarch64-softmmu/qemu-system-aarch64 QTEST_QEMU_IMG=qemu-img MALLOC_PERTURB_=${MALLOC_PERTURB_:-$((RANDOM % 255 + 1))} gtester -k --verbose -m=quick tests/device-introspect-test -p=/aarch64/device/introspect/concrete
[...]
{"return": "/machine (none-machine)\r\n /peripheral (container)\r\n /peripheral-anon (container)\r\n /unattached (container)\r\n
/io[0] (qemu:memory-region)\r\n /sysbus (System)\r\n /system[0]
(qemu:memory-region)\r\n"}{"execute": "device-list-properties", "arguments": {"typename": "vhost-user-scsi-pci"}}

** ERROR:/Users/pm215/src/qemu-for-merges/qom/object.c:364:void object_initialize_with_type(void *, size_t, TypeImpl *): assertion
failed: (type != NULL)
Broken pipe
FAIL

suggests that there's a bug in the new vhost-user-scsi-pci device. Specifically in commit 550811c37e0f2 ("vhost-user-scsi: Introduce vhost-user-scsi host device") hw/virtio/virtio-pci.c is changed to unconditionally call type_register_static(&vhost_user_scsi_pci_info), whose instance_init method tries to use TYPE_VHOST_USER_SCSI, but hw/scsi/vhost-user-scsi.c (where that type is defined) is only compiled if CONFIG_VHOST_USER_SCSI is set (which only happens for Linux).

thanks
-- PMM