Skip to contentSkip to conversation

Misc changes for 2016-05-27

GIT PULL Paolo Bonzini 2 participants 8 messages May 27, 2016 – May 31, 2016

lore
Share & tools
lore
#0 lore raw

The following changes since commit 2c56d06bafd8933d2a9c6e0aeb5d45f7c1fb5616:

Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2016-05-26 14:29:30 +0100)

are available in the git repository at:

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

for you to fetch changes up to 05d158af4bb817b05074a3846dce74466aea8d39:

exec: hide mr->ram_addr from qemu_get_ram_ptr users (2016-05-27 18:09:13 +0200)

----------------------------------------------------------------
* docs/atomics fixes and atomic_rcu_* optimization (Emilio)
* NBD bugfix (Eric)
* Memory fixes and cleanups (Paolo, Paul)
* scsi-block support for SCSI status, including persistent reservations (Paolo)
* linuxboot support for fw_cfg DMA (Marc, Richard Jones)
* kvm_stat moves to the Linux repository
* SCSI bug fixes (Peter, Prasad)
* Killing qemu_char_get_next_serial, non-ARM parts (Xiaoqiang)

----------------------------------------------------------------
Emilio G. Cota (3):
docs/atomics: update atomic_read/set comparison with Linux
atomics: emit an smp_read_barrier_depends() barrier only for Alpha and Thread Sanitizer
atomics: do not emit consume barrier for atomic_rcu_read

Eric Blake (1):
nbd: Don't trim unrequested bytes

Fam Zheng (1):
scsi-generic: Merge block max xfer len in INQUIRY response

Marc Marí (1):
Add optionrom compatible with fw_cfg DMA version

Paolo Bonzini (13):
Revert "memory: Drop FlatRange.romd_mode"
kvm_stat: Remove
bt: rewrite csrhci_write to avoid out-of-bounds writes docs/atomics: update comparison with Linux
scsi-disk: introduce a common base class
scsi-disk: introduce dma_readv and dma_writev
scsi-disk: add need_fua_emulation to SCSIDiskClass
scsi-disk: introduce scsi_disk_req_check_error
scsi-block: always use SG_IO
memory: remove qemu_get_ram_fd, qemu_set_ram_fd, qemu_ram_block_host_ptr
exec: remove ram_addr argument from qemu_ram_block_from_host
memory: split memory_region_from_host from qemu_ram_addr_from_host
exec: hide mr->ram_addr from qemu_get_ram_ptr users

Paul Durrant (1):
xen-hvm: ignore background I/O sections

Peter Lieven (1):

      block/iscsi: avoid potential overflow of acb->task->cdb

Prasad J Pandit (5):
scsi: pvscsi: check command descriptor ring buffer size (CVE-2016-4952)
scsi: mptsas: infinite loop while fetching requests
scsi: megasas: use appropriate property buffer size
scsi: megasas: initialise local configuration data buffer
scsi: megasas: check 'read_queue_head' index value

xiaoqiang zhao (5):
hw/char: QOM'ify escc.c
hw/char: QOM'ify etraxfs_ser.c
hw/char: QOM'ify lm32_juart.c
hw/char: QOM'ify lm32_uart.c
hw/char: QOM'ify milkymist-uart.c

 .gitignore                        |   4 +
 Makefile                          |  11 +-
 block/iscsi.c                     |   7 +
 configure                         |  20 +
 cputlb.c                          |   3 +-
 docs/atomics.txt                  |  38 +-
 exec.c                            | 110 ++---
 hw/bt/hci-csr.c                   |  67 +++-
 hw/char/escc.c                    |  30 +-
 hw/char/etraxfs_ser.c             |  27 +-
 hw/char/lm32_juart.c              |  17 +-
 hw/char/lm32_uart.c               |  28 +-
 hw/char/milkymist-uart.c          |  10 +-
 hw/cris/axis_dev88.c              |   4 +-
 hw/i386/pc.c                      |  10 +-
 hw/lm32/lm32.h                    |  19 +-
 hw/lm32/lm32_boards.c             |   9 +-
 hw/lm32/milkymist-hw.h            |   4 +-
 hw/lm32/milkymist.c               |   4 +-
 hw/misc/ivshmem.c                 |   5 +-
 hw/nvram/fw_cfg.c                 |   2 +-
 hw/scsi/megasas.c                 |   6 +-
 hw/scsi/mptsas.c                  |   9 +-
 hw/scsi/scsi-disk.c               | 415 +++++++++++++------
 hw/scsi/scsi-generic.c            |  12 +
 hw/scsi/vmw_pvscsi.c              |  24 +-
 hw/virtio/vhost-user.c            |  25 +-
 include/exec/cpu-common.h         |   4 +-
 include/exec/memory.h             |  36 +-
 include/exec/ram_addr.h           |   3 -
 include/hw/cris/etraxfs.h         |  16 +
 include/hw/nvram/fw_cfg.h         |   1 +
 include/qemu/atomic.h             |  25 +-
 memory.c                          |  43 +-
 migration/postcopy-ram.c          |   3 +-
 nbd/server.c                      |  20 +-
 pc-bios/optionrom/Makefile        |  20 +-
 pc-bios/optionrom/code16gcc.h     |   3 +
 pc-bios/optionrom/linuxboot_dma.c | 292 ++++++++++++++
 scripts/dump-guest-memory.py      |  19 +-
 scripts/kvm/kvm_stat              | 825 --------------------------------------
 scripts/kvm/kvm_stat.texi         |  55 ---
 target-i386/kvm.c                 |   6 +-
 xen-hvm.c                         |  14 +-
 44 files changed, 1057 insertions(+), 1248 deletions(-)
 create mode 100644 pc-bios/optionrom/code16gcc.h
 create mode 100644 pc-bios/optionrom/linuxboot_dma.c
 delete mode 100755 scripts/kvm/kvm_stat
 delete mode 100644 scripts/kvm/kvm_stat.texi
Signature · 1 line
2.5.5
#1 lore raw

[Qemu-devel] [PULL 23/31] scsi-disk: introduce dma_readv and dma_writev

These are replacements for blk_aio_readv and blk_aio_writev that allow customization of the data path. They reuse the DMA helpers' DMAIOFunc callback type, so that the same function can be used in either the QEMUSGList or the bounce-buffered case.

This customization will be needed in the next patch to do zero-copy SG_IO on scsi-block.

---
 hw/scsi/scsi-disk.c | 67 +++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 52 insertions(+), 15 deletions(-)
hw/scsi/scsi-disk.c +52 -15
index 2d9dcde..6506257 100644
@@ -55,7 +55,18 @@ do { printf("scsi-disk: " fmt , ## __VA_ARGS__); } while (0)
 
 #define TYPE_SCSI_DISK_BASE         "scsi-disk-base"
 
-typedef struct SCSIDiskState SCSIDiskState;
+#define SCSI_DISK_BASE(obj) \
+     OBJECT_CHECK(SCSIDiskState, (obj), TYPE_SCSI_DISK_BASE)
+#define SCSI_DISK_BASE_CLASS(klass) \
+     OBJECT_CLASS_CHECK(SCSIDiskClass, (klass), TYPE_SCSI_DISK_BASE)
+#define SCSI_DISK_BASE_GET_CLASS(obj) \
+     OBJECT_GET_CLASS(SCSIDiskClass, (obj), TYPE_SCSI_DISK_BASE)
+
+typedef struct SCSIDiskClass {
+    SCSIDeviceClass parent_class;
+    DMAIOFunc       *dma_readv;
+    DMAIOFunc       *dma_writev;
+} SCSIDiskClass;
 
 typedef struct SCSIDiskReq {
     SCSIRequest req;
@@ -73,7 +84,7 @@ typedef struct SCSIDiskReq {
 #define SCSI_DISK_F_DPOFUA                1
 #define SCSI_DISK_F_NO_REMOVABLE_DEVOPS   2
 
-struct SCSIDiskState
+typedef struct SCSIDiskState
 {
     SCSIDevice qdev;
     uint32_t features;
@@ -90,7 +101,7 @@ struct SCSIDiskState
     char *product;
     bool tray_open;
     bool tray_locked;
-};
+} SCSIDiskState;
 
 static int scsi_handle_rw_error(SCSIDiskReq *r, int error, bool acct_failed);
 
@@ -317,6 +328,7 @@ done:
 static void scsi_do_read(SCSIDiskReq *r, int ret)
 {
     SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
+    SCSIDiskClass *sdc = (SCSIDiskClass *) object_get_class(OBJECT(s));
 
     assert (r->req.aiocb == NULL);
 
@@ -337,16 +349,16 @@ static void scsi_do_read(SCSIDiskReq *r, int ret)
     if (r->req.sg) {
         dma_acct_start(s->qdev.conf.blk, &r->acct, r->req.sg, BLOCK_ACCT_READ);
         r->req.resid -= r->req.sg->size;
-        r->req.aiocb = dma_blk_read(s->qdev.conf.blk, r->req.sg,
-                                    r->sector << BDRV_SECTOR_BITS,
-                                    scsi_dma_complete, r);
+        r->req.aiocb = dma_blk_io(blk_get_aio_context(s->qdev.conf.blk),
+                                  r->req.sg, r->sector << BDRV_SECTOR_BITS,
+                                  sdc->dma_readv, r, scsi_dma_complete, r,
+                                  DMA_DIRECTION_FROM_DEVICE);
     } else {
         scsi_init_iovec(r, SCSI_DMA_BUF_SIZE);
         block_acct_start(blk_get_stats(s->qdev.conf.blk), &r->acct,
                          r->qiov.size, BLOCK_ACCT_READ);
-        r->req.aiocb = blk_aio_preadv(s->qdev.conf.blk,
-                                      r->sector << BDRV_SECTOR_BITS, &r->qiov,
-                                      0, scsi_read_complete, r);
+        r->req.aiocb = sdc->dma_readv(r->sector, &r->qiov,
+                                      scsi_read_complete, r, r);
     }
 
 done:
@@ -506,6 +518,7 @@ static void scsi_write_data(SCSIRequest *req)
 {
     SCSIDiskReq *r = DO_UPCAST(SCSIDiskReq, req, req);
     SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
+    SCSIDiskClass *sdc = (SCSIDiskClass *) object_get_class(OBJECT(s));
 
     /* No data transfer may already be in progress */
     assert(r->req.aiocb == NULL);
@@ -542,15 +555,15 @@ static void scsi_write_data(SCSIRequest *req)
     if (r->req.sg) {
         dma_acct_start(s->qdev.conf.blk, &r->acct, r->req.sg, BLOCK_ACCT_WRITE);
         r->req.resid -= r->req.sg->size;
-        r->req.aiocb = dma_blk_write(s->qdev.conf.blk, r->req.sg,
-                                     r->sector << BDRV_SECTOR_BITS,
-                                     scsi_dma_complete, r);
+        r->req.aiocb = dma_blk_io(blk_get_aio_context(s->qdev.conf.blk),
+                                  r->req.sg, r->sector << BDRV_SECTOR_BITS,
+                                  sdc->dma_writev, r, scsi_dma_complete, r,
+                                  DMA_DIRECTION_TO_DEVICE);
     } else {
         block_acct_start(blk_get_stats(s->qdev.conf.blk), &r->acct,
                          r->qiov.size, BLOCK_ACCT_WRITE);
-        r->req.aiocb = blk_aio_pwritev(s->qdev.conf.blk,
-                                       r->sector << BDRV_SECTOR_BITS, &r->qiov,
-                                       0, scsi_write_complete, r);
+        r->req.aiocb = sdc->dma_writev(r->sector << BDRV_SECTOR_BITS, &r->qiov,
+                                       scsi_write_complete, r, r);
     }
 }
 
@@ -2658,12 +2671,35 @@ static int scsi_block_parse_cdb(SCSIDevice *d, SCSICommand *cmd,
 
 #endif
 
+static
+BlockAIOCB *scsi_dma_readv(int64_t offset, QEMUIOVector *iov,
+                           BlockCompletionFunc *cb, void *cb_opaque,
+                           void *opaque)
+{
+    SCSIDiskReq *r = opaque;
+    SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
+    return blk_aio_preadv(s->qdev.conf.blk, offset, iov, 0, cb, cb_opaque);
+}
+
+static
+BlockAIOCB *scsi_dma_writev(int64_t offset, QEMUIOVector *iov,
+                            BlockCompletionFunc *cb, void *cb_opaque,
+                            void *opaque)
+{
+    SCSIDiskReq *r = opaque;
+    SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
+    return blk_aio_pwritev(s->qdev.conf.blk, offset, iov, 0, cb, cb_opaque);
+}
+
 static void scsi_disk_base_class_initfn(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    SCSIDiskClass *sdc = SCSI_DISK_BASE_CLASS(klass);
 
     dc->fw_name = "disk";
     dc->reset = scsi_disk_reset;
+    sdc->dma_readv = scsi_dma_readv;
+    sdc->dma_writev = scsi_dma_writev;
 }
 
 static const TypeInfo scsi_disk_base_info = {
@@ -2671,6 +2707,7 @@ static const TypeInfo scsi_disk_base_info = {
     .parent        = TYPE_SCSI_DEVICE,
     .class_init    = scsi_disk_base_class_initfn,
     .instance_size = sizeof(SCSIDiskState),
+    .class_size    = sizeof(SCSIDiskClass),
 };
 
 #define DEFINE_SCSI_DISK_PROPERTIES()                                \
Signature · 1 line
2.5.5
#2 lore raw
In reply to Paolo Bonzini
Quoted 23 lines · Paolo Bonzini

The following changes since commit 2c56d06bafd8933d2a9c6e0aeb5d45f7c1fb5616:

Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2016-05-26 14:29:30 +0100)

are available in the git repository at:

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

for you to fetch changes up to 05d158af4bb817b05074a3846dce74466aea8d39:

exec: hide mr->ram_addr from qemu_get_ram_ptr users (2016-05-27 18:09:13 +0200)

----------------------------------------------------------------
* docs/atomics fixes and atomic_rcu_* optimization (Emilio)
* NBD bugfix (Eric)
* Memory fixes and cleanups (Paolo, Paul)
* scsi-block support for SCSI status, including persistent reservations (Paolo)
* linuxboot support for fw_cfg DMA (Marc, Richard Jones)
* kvm_stat moves to the Linux repository
* SCSI bug fixes (Peter, Prasad)
* Killing qemu_char_get_next_serial, non-ARM parts (Xiaoqiang)

Quoted 1 line

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

Doesn't build on clang :-(

CC optionrom/linuxboot_dma.o
clang: error: unknown argument: '-fno-toplevel-reorder'
clang: error: unknown argument: '-fno-toplevel-reorder'

thanks
-- PMM

#3 lore raw

----- Original Message -----

Quoted 33 lines

From: "Peter Maydell" <[email protected]>
To: "Paolo Bonzini" <[email protected]>
Cc: "QEMU Developers" <[email protected]>
Sent: Friday, May 27, 2016 6:38:10 PM
Subject: Re: [Qemu-devel] [PULL v3 00/31] Misc changes for 2016-05-27

Quoted 26 lines · Paolo Bonzini

The following changes since commit
2c56d06bafd8933d2a9c6e0aeb5d45f7c1fb5616:

Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2016-05-26 14:29:30 +0100)

are available in the git repository at:

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

for you to fetch changes up to 05d158af4bb817b05074a3846dce74466aea8d39:

exec: hide mr->ram_addr from qemu_get_ram_ptr users (2016-05-27 18:09:13 +0200)

----------------------------------------------------------------
* docs/atomics fixes and atomic_rcu_* optimization (Emilio)
* NBD bugfix (Eric)
* Memory fixes and cleanups (Paolo, Paul)
* scsi-block support for SCSI status, including persistent reservations (Paolo)
* linuxboot support for fw_cfg DMA (Marc, Richard Jones)
* kvm_stat moves to the Linux repository
* SCSI bug fixes (Peter, Prasad)
* Killing qemu_char_get_next_serial, non-ARM parts (Xiaoqiang)

Quoted 7 lines
Quoted 1 line

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

Doesn't build on clang :-(

CC optionrom/linuxboot_dma.o
clang: error: unknown argument: '-fno-toplevel-reorder'
clang: error: unknown argument: '-fno-toplevel-reorder'

Either there's a bug in the detection of -m16, or your clang version is too old. What does config.log say?

(Unfortunately I have clang here but it's broken---it fails to link anything).

Paolo

#4 lore raw
Quoted 38 lines · Paolo Bonzini

----- Original Message -----

Quoted 35 lines

From: "Peter Maydell" <[email protected]>
To: "Paolo Bonzini" <[email protected]>
Cc: "QEMU Developers" <[email protected]>
Sent: Friday, May 27, 2016 6:38:10 PM
Subject: Re: [Qemu-devel] [PULL v3 00/31] Misc changes for 2016-05-27

Quoted 27 lines · Paolo Bonzini

The following changes since commit
2c56d06bafd8933d2a9c6e0aeb5d45f7c1fb5616:

Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2016-05-26 14:29:30 +0100)

are available in the git repository at:

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

for you to fetch changes up to 05d158af4bb817b05074a3846dce74466aea8d39:

exec: hide mr->ram_addr from qemu_get_ram_ptr users (2016-05-27 18:09:13 +0200)

----------------------------------------------------------------
* docs/atomics fixes and atomic_rcu_* optimization (Emilio)
* NBD bugfix (Eric)
* Memory fixes and cleanups (Paolo, Paul)
* scsi-block support for SCSI status, including persistent reservations (Paolo)
* linuxboot support for fw_cfg DMA (Marc, Richard Jones)
* kvm_stat moves to the Linux repository
* SCSI bug fixes (Peter, Prasad)
* Killing qemu_char_get_next_serial, non-ARM parts (Xiaoqiang)

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

Quoted 8 lines
Quoted 5 lines

Doesn't build on clang :-(

CC optionrom/linuxboot_dma.o
clang: error: unknown argument: '-fno-toplevel-reorder'
clang: error: unknown argument: '-fno-toplevel-reorder'

Either there's a bug in the detection of -m16, or your clang version is too old. What does config.log say?

The only mention of m16 in the config.log is where it says:

clang -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fsanitize=undefined -Werror -Wno-string-plus-int -Wno-initializer-overrides -Wendif-labels -Wmissing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-definition -Wtype-limits -fstack-protector-all -m16 -o config-temp/qemu-conf.exe config-temp/qemu-conf.c -m64 -g
clang: error: unknown argument: '-m16'

thanks
-- PMM

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

Either there's a bug in the detection of -m16, or your clang version is too old. What does config.log say?

The only mention of m16 in the config.log is where it says:

clang -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE

(quoted diff) +0 -7
-Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings
-Wmissing-prototypes -fno-strict-aliasing -fno-common
-fsanitize=undefined -Werror -Wno-string-plus-int
-Wno-initializer-overrides -Wendif-labels -Wmissing-include-dirs
-Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k
-Winit-self -Wignored-qualifiers -Wold-style-definition -Wtype-limits
-fstack-protector-all -m16 -o config-temp/qemu-conf.exe
Quoted 2 lines

config-temp/qemu-conf.c -m64 -g
clang: error: unknown argument: '-m16'

Then I suppose your clang version is too old, what is it?

Thanks,

Paolo

#6 lore raw
Quoted 1 line · Paolo Bonzini

Then I suppose your clang version is too old, what is it?

Ubuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4)
Target: x86_64-pc-linux-gnu
Thread model: posix

(which is the default clang for Ubuntu Trusty).

thanks
-- PMM

#7 lore raw
Quoted 6 lines · Peter Maydell
Quoted 1 line
Quoted 1 line

Then I suppose your clang version is too old, what is it?

Ubuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4)
Target: x86_64-pc-linux-gnu
Thread model: posix

(which is the default clang for Ubuntu Trusty).

Yeah, that is too old. We'll have to do one of this:

- figure out whether the compiler has at least one of -m16 or -fno-toplevel-reorder, and if not disable building the ROMs

- figure out a way to build the ROMs with cross compilers, in which case I think it's acceptable to make that cross compiler be GCC.

Paolo