From da1804d17a9ed7f060c072fbc4889db5fbc9c7d2 Mon Sep 17 00:00:00 2001 From: Boxuan Li Date: Fri, 3 May 2019 23:44:24 +0800 Subject: [PATCH 1/9] hw/virtio/virtio-mmio: Convert DPRINTF to trace and log MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use traces for debug message and qemu_log_mask for errors. Signed-off-by: Boxuan Li Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Reviewed-by: Yuval Shaia Message-Id: <20190503154424.73933-1-liboxuan@connect.hku.hk> Signed-off-by: Laurent Vivier --- hw/virtio/trace-events | 7 +++++++ hw/virtio/virtio-mmio.c | 44 ++++++++++++++++++++--------------------- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 60c649c4bc..e28ba48da6 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -46,3 +46,10 @@ virtio_balloon_handle_output(const char *name, uint64_t gpa) "section name: %s g virtio_balloon_get_config(uint32_t num_pages, uint32_t actual) "num_pages: %d actual: %d" virtio_balloon_set_config(uint32_t actual, uint32_t oldactual) "actual: %d oldactual: %d" virtio_balloon_to_target(uint64_t target, uint32_t num_pages) "balloon target: 0x%"PRIx64" num_pages: %d" + +# virtio-mmio.c +virtio_mmio_read(uint64_t offset) "virtio_mmio_read offset 0x%" PRIx64 +virtio_mmio_write_offset(uint64_t offset, uint64_t value) "virtio_mmio_write offset 0x%" PRIx64 " value 0x%" PRIx64 +virtio_mmio_guest_page(uint64_t size, int shift) "guest page size 0x%" PRIx64 " shift %d" +virtio_mmio_queue_write(uint64_t value, int max_size) "mmio_queue write 0x%" PRIx64 " max %d" +virtio_mmio_setting_irq(int level) "virtio_mmio setting IRQ %d" diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index 5807aa87fe..96c762f0bf 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -27,16 +27,8 @@ #include "sysemu/kvm.h" #include "hw/virtio/virtio-bus.h" #include "qemu/error-report.h" - -/* #define DEBUG_VIRTIO_MMIO */ - -#ifdef DEBUG_VIRTIO_MMIO - -#define DPRINTF(fmt, ...) \ -do { printf("virtio_mmio: " fmt , ## __VA_ARGS__); } while (0) -#else -#define DPRINTF(fmt, ...) do {} while (0) -#endif +#include "qemu/log.h" +#include "trace.h" /* QOM macros */ /* virtio-mmio-bus */ @@ -107,7 +99,7 @@ static uint64_t virtio_mmio_read(void *opaque, hwaddr offset, unsigned size) VirtIOMMIOProxy *proxy = (VirtIOMMIOProxy *)opaque; VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); - DPRINTF("virtio_mmio_read offset 0x%x\n", (int)offset); + trace_virtio_mmio_read(offset); if (!vdev) { /* If no backend is present, we treat most registers as @@ -144,7 +136,9 @@ static uint64_t virtio_mmio_read(void *opaque, hwaddr offset, unsigned size) } } if (size != 4) { - DPRINTF("wrong size access to register!\n"); + qemu_log_mask(LOG_GUEST_ERROR, + "%s: wrong size access to register!\n", + __func__); return 0; } switch (offset) { @@ -182,10 +176,12 @@ static uint64_t virtio_mmio_read(void *opaque, hwaddr offset, unsigned size) case VIRTIO_MMIO_QUEUE_ALIGN: case VIRTIO_MMIO_QUEUE_NOTIFY: case VIRTIO_MMIO_INTERRUPT_ACK: - DPRINTF("read of write-only register\n"); + qemu_log_mask(LOG_GUEST_ERROR, + "%s: read of write-only register\n", + __func__); return 0; default: - DPRINTF("bad register offset\n"); + qemu_log_mask(LOG_GUEST_ERROR, "%s: bad register offset\n", __func__); return 0; } return 0; @@ -197,8 +193,7 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value, VirtIOMMIOProxy *proxy = (VirtIOMMIOProxy *)opaque; VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); - DPRINTF("virtio_mmio_write offset 0x%x value 0x%" PRIx64 "\n", - (int)offset, value); + trace_virtio_mmio_write_offset(offset, value); if (!vdev) { /* If no backend is present, we just make all registers @@ -226,7 +221,9 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value, return; } if (size != 4) { - DPRINTF("wrong size access to register!\n"); + qemu_log_mask(LOG_GUEST_ERROR, + "%s: wrong size access to register!\n", + __func__); return; } switch (offset) { @@ -246,8 +243,7 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value, if (proxy->guest_page_shift > 31) { proxy->guest_page_shift = 0; } - DPRINTF("guest page size %" PRIx64 " shift %d\n", value, - proxy->guest_page_shift); + trace_virtio_mmio_guest_page(value, proxy->guest_page_shift); break; case VIRTIO_MMIO_QUEUE_SEL: if (value < VIRTIO_QUEUE_MAX) { @@ -255,7 +251,7 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value, } break; case VIRTIO_MMIO_QUEUE_NUM: - DPRINTF("mmio_queue write %d max %d\n", (int)value, VIRTQUEUE_MAX_SIZE); + trace_virtio_mmio_queue_write(value, VIRTQUEUE_MAX_SIZE); virtio_queue_set_num(vdev, vdev->queue_sel, value); /* Note: only call this function for legacy devices */ virtio_queue_update_rings(vdev, vdev->queue_sel); @@ -303,11 +299,13 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value, case VIRTIO_MMIO_DEVICE_FEATURES: case VIRTIO_MMIO_QUEUE_NUM_MAX: case VIRTIO_MMIO_INTERRUPT_STATUS: - DPRINTF("write to readonly register\n"); + qemu_log_mask(LOG_GUEST_ERROR, + "%s: write to readonly register\n", + __func__); break; default: - DPRINTF("bad register offset\n"); + qemu_log_mask(LOG_GUEST_ERROR, "%s: bad register offset\n", __func__); } } @@ -327,7 +325,7 @@ static void virtio_mmio_update_irq(DeviceState *opaque, uint16_t vector) return; } level = (atomic_read(&vdev->isr) != 0); - DPRINTF("virtio_mmio setting IRQ %d\n", level); + trace_virtio_mmio_setting_irq(level); qemu_set_irq(proxy->irq, level); } From 652141e49e2a54e7ee7f25652817396fe5b5e152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Mon, 6 May 2019 16:19:22 +0200 Subject: [PATCH 2/9] roms: Correct the EDK2_BASETOOLS_OPTFLAGS variable description MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In commit 1cab464136b4 we incorrectly described the EDK2_BASETOOLS_OPTFLAGS can pass CPPFLAGS and CFLAGS options to the EDK2 build tools, but it only expands the CFLAGS (not to the CPPFLAGS). Update the description to be more accurate. Reported-by: Laszlo Ersek Reviewed-by: Laszlo Ersek Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20190506141923.12183-2-philmd@redhat.com> Signed-off-by: Laurent Vivier --- roms/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roms/Makefile b/roms/Makefile index 0ce84a45ad..ea6aec56ab 100644 --- a/roms/Makefile +++ b/roms/Makefile @@ -121,8 +121,8 @@ build-efi-roms: build-pxe-roms $(patsubst %,bin-i386-efi/%.efidrv,$(pxerom_targets)) \ $(patsubst %,bin-x86_64-efi/%.efidrv,$(pxerom_targets)) -# Build scripts can pass compiler/linker flags to the EDK2 build tools -# via the EDK2_BASETOOLS_OPTFLAGS (CPPFLAGS and CFLAGS) and +# Build scripts can pass compiler/linker flags to the EDK2 +# build tools via the EDK2_BASETOOLS_OPTFLAGS (CFLAGS) and # EDK2_BASETOOLS_LDFLAGS (LDFLAGS) environment variables. # # Example: From 60c85ec822cf306aef25d9831e61a811ac5328fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Mon, 6 May 2019 16:19:23 +0200 Subject: [PATCH 3/9] roms: List and describe the Makefile 'clean' rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Laszlo Ersek Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20190506141923.12183-3-philmd@redhat.com> Signed-off-by: Laurent Vivier --- roms/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/roms/Makefile b/roms/Makefile index ea6aec56ab..078d3fb705 100644 --- a/roms/Makefile +++ b/roms/Makefile @@ -62,6 +62,8 @@ default: @echo " u-boot.e500 -- update u-boot.e500" @echo " u-boot.sam460 -- update u-boot.sam460" @echo " efi -- update UEFI (edk2) platform firmware" + @echo " clean -- delete the files generated by the previous" \ + "build targets" bios: build-seabios-config-seabios-128k build-seabios-config-seabios-256k cp seabios/builds/seabios-128k/bios.bin ../pc-bios/bios.bin From b6eca81e1b6ce5f1b9d44c85019cb05e2a495cd7 Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Thu, 16 May 2019 12:58:05 +0200 Subject: [PATCH 4/9] migration: Fix typo in migrate_add_blocker() error message Signed-off-by: Greg Kurz Reviewed-by: Stefano Garzarella Reviewed-by: Dr. David Alan Gilbert Message-Id: <155800428514.543845.17558475870097990036.stgit@bahia.lan> Signed-off-by: Laurent Vivier --- migration/migration.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/migration.c b/migration/migration.c index d0a0f68f11..2865ae3fa9 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1728,7 +1728,7 @@ int migrate_add_blocker(Error *reason, Error **errp) if (only_migratable) { error_propagate_prepend(errp, error_copy(reason), "disallowing migration blocker " - "(--only_migratable) for: "); + "(--only-migratable) for: "); return -EACCES; } From 04c6e16f1f3ed052b1f06e2905ebe09fb5476cd5 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 17 May 2019 20:32:46 +0200 Subject: [PATCH 5/9] configure: Fix spelling of sdl-image in --help Fixes: a442fe2f2b2f20e7be0934277e9400b844b11999 Cc: qemu-trivial@nongnu.org Signed-off-by: Markus Armbruster Reviewed-by: Thomas Huth Message-Id: <20190517183246.11933-1-armbru@redhat.com> Signed-off-by: Laurent Vivier --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index d2fc346302..cef51b2a0b 100755 --- a/configure +++ b/configure @@ -1745,7 +1745,7 @@ disabled with --disable-FEATURE, default is enabled if available: gcrypt libgcrypt cryptography support auth-pam PAM access control sdl SDL UI - sdl_image SDL Image support for icons + sdl-image SDL Image support for icons gtk gtk UI vte vte support for the gtk UI curses curses UI From 0c0c8f8aaf084fc4bae15e92ef6b8c8e8a33e52e Mon Sep 17 00:00:00 2001 From: Li Qiang Date: Tue, 21 May 2019 08:15:40 -0700 Subject: [PATCH 6/9] vfio: pci: make "vfio-pci-nohotplug" as MACRO MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The QOMConventions recommends we should use TYPE_FOO for a TypeInfo's name. Though "vfio-pci-nohotplug" is not used in other parts, for consistency we should make this change. CC: qemu-trivial@nongnu.org Signed-off-by: Li Qiang Message-Id: <20190521151543.92274-2-liq3ea@163.com> Acked-by: Alex Williamson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Eric Auger Signed-off-by: Laurent Vivier --- hw/vfio/pci.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 8cecb53d5c..08729e5875 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -40,6 +40,8 @@ #define TYPE_VFIO_PCI "vfio-pci" #define PCI_VFIO(obj) OBJECT_CHECK(VFIOPCIDevice, obj, TYPE_VFIO_PCI) +#define TYPE_VIFO_PCI_NOHOTPLUG "vfio-pci-nohotplug" + static void vfio_disable_interrupts(VFIOPCIDevice *vdev); static void vfio_mmap_set_enabled(VFIOPCIDevice *vdev, bool enabled); @@ -3304,8 +3306,8 @@ static void vfio_pci_nohotplug_dev_class_init(ObjectClass *klass, void *data) } static const TypeInfo vfio_pci_nohotplug_dev_info = { - .name = "vfio-pci-nohotplug", - .parent = "vfio-pci", + .name = TYPE_VIFO_PCI_NOHOTPLUG, + .parent = TYPE_VFIO_PCI, .instance_size = sizeof(VFIOPCIDevice), .class_init = vfio_pci_nohotplug_dev_class_init, }; From da56e33006c3f2c0e703870f140b3ef72eb74aec Mon Sep 17 00:00:00 2001 From: Li Qiang Date: Tue, 21 May 2019 08:15:41 -0700 Subject: [PATCH 7/9] hw: vfio: drop TYPE_FOO MACRO in VMStateDescription MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's recommended that VMStateDescription names are decoupled from QOM type names as the latter may freely change without consideration of migration compatibility. Link: https://lists.gnu.org/archive/html/qemu-devel/2018-10/msg02175.html CC: qemu-trivial@nongnu.org Signed-off-by: Li Qiang Message-Id: <20190521151543.92274-3-liq3ea@163.com> Acked-by: Alex Williamson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Eric Auger Signed-off-by: Laurent Vivier --- hw/vfio/amd-xgbe.c | 2 +- hw/vfio/ap.c | 2 +- hw/vfio/calxeda-xgmac.c | 2 +- hw/vfio/ccw.c | 2 +- hw/vfio/platform.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/vfio/amd-xgbe.c b/hw/vfio/amd-xgbe.c index ee64a3b4a2..1b06c0f3ea 100644 --- a/hw/vfio/amd-xgbe.c +++ b/hw/vfio/amd-xgbe.c @@ -26,7 +26,7 @@ static void amd_xgbe_realize(DeviceState *dev, Error **errp) } static const VMStateDescription vfio_platform_amd_xgbe_vmstate = { - .name = TYPE_VFIO_AMD_XGBE, + .name = "vfio-amd-xgbe", .unmigratable = 1, }; diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c index d8b79ebe53..564751650f 100644 --- a/hw/vfio/ap.c +++ b/hw/vfio/ap.c @@ -155,7 +155,7 @@ static void vfio_ap_reset(DeviceState *dev) } static const VMStateDescription vfio_ap_vmstate = { - .name = VFIO_AP_DEVICE_TYPE, + .name = "vfio-ap", .unmigratable = 1, }; diff --git a/hw/vfio/calxeda-xgmac.c b/hw/vfio/calxeda-xgmac.c index e7767c4b02..6cc608b6ca 100644 --- a/hw/vfio/calxeda-xgmac.c +++ b/hw/vfio/calxeda-xgmac.c @@ -26,7 +26,7 @@ static void calxeda_xgmac_realize(DeviceState *dev, Error **errp) } static const VMStateDescription vfio_platform_calxeda_xgmac_vmstate = { - .name = TYPE_VFIO_CALXEDA_XGMAC, + .name = "vfio-calxeda-xgmac", .unmigratable = 1, }; diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 31dd3a2a87..d9e39552e2 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -468,7 +468,7 @@ static Property vfio_ccw_properties[] = { }; static const VMStateDescription vfio_ccw_vmstate = { - .name = TYPE_VFIO_CCW, + .name = "vfio-ccw", .unmigratable = 1, }; diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c index 398db38f14..e59a0234dd 100644 --- a/hw/vfio/platform.c +++ b/hw/vfio/platform.c @@ -697,7 +697,7 @@ out: } static const VMStateDescription vfio_platform_vmstate = { - .name = TYPE_VFIO_PLATFORM, + .name = "vfio-platform", .unmigratable = 1, }; From bf04ef354c9d9d343d73d5dee0c0a62574a0e6bf Mon Sep 17 00:00:00 2001 From: Li Qiang Date: Tue, 21 May 2019 08:15:42 -0700 Subject: [PATCH 8/9] vfio: platform: fix a typo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 'eventd' should be 'eventfd'. CC: qemu-trivial@nongnu.org Signed-off-by: Li Qiang Message-Id: <20190521151543.92274-4-liq3ea@163.com> Acked-by: Alex Williamson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Eric Auger Signed-off-by: Laurent Vivier --- hw/vfio/platform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c index e59a0234dd..d52d6552e0 100644 --- a/hw/vfio/platform.c +++ b/hw/vfio/platform.c @@ -72,7 +72,7 @@ static VFIOINTp *vfio_init_intp(VFIODevice *vbasedev, g_free(intp->interrupt); g_free(intp); error_setg_errno(errp, -ret, - "failed to initialize trigger eventd notifier"); + "failed to initialize trigger eventfd notifier"); return NULL; } if (vfio_irq_is_automasked(intp)) { @@ -84,7 +84,7 @@ static VFIOINTp *vfio_init_intp(VFIODevice *vbasedev, g_free(intp->unmask); g_free(intp); error_setg_errno(errp, -ret, - "failed to initialize resample eventd notifier"); + "failed to initialize resample eventfd notifier"); return NULL; } } From 2d9574bdbed69b374116c59259f6bd14f7dfad7f Mon Sep 17 00:00:00 2001 From: Li Qiang Date: Tue, 21 May 2019 08:15:43 -0700 Subject: [PATCH 9/9] pci: msix: move 'MSIX_CAP_LENGTH' to header file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 'MSIX_CAP_LENGTH' is defined in two .c file. Move it to hw/pci/msix.h file to reduce duplicated code. CC: qemu-trivial@nongnu.org Signed-off-by: Li Qiang Message-Id: <20190521151543.92274-5-liq3ea@163.com> Acked-by: Alex Williamson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Eric Auger Signed-off-by: Laurent Vivier --- hw/pci/msix.c | 2 -- hw/vfio/pci.c | 2 -- include/hw/pci/msix.h | 2 ++ 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/pci/msix.c b/hw/pci/msix.c index 4e336416a7..d39dcf32e8 100644 --- a/hw/pci/msix.c +++ b/hw/pci/msix.c @@ -24,8 +24,6 @@ #include "qapi/error.h" #include "trace.h" -#define MSIX_CAP_LENGTH 12 - /* MSI enable bit and maskall bit are in byte 1 in FLAGS register */ #define MSIX_CONTROL_OFFSET (PCI_MSIX_FLAGS + 1) #define MSIX_ENABLE_MASK (PCI_MSIX_FLAGS_ENABLE >> 8) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 08729e5875..8e555db12e 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -35,8 +35,6 @@ #include "trace.h" #include "qapi/error.h" -#define MSIX_CAP_LENGTH 12 - #define TYPE_VFIO_PCI "vfio-pci" #define PCI_VFIO(obj) OBJECT_CHECK(VFIOPCIDevice, obj, TYPE_VFIO_PCI) diff --git a/include/hw/pci/msix.h b/include/hw/pci/msix.h index 1f27658d35..08acfa836e 100644 --- a/include/hw/pci/msix.h +++ b/include/hw/pci/msix.h @@ -4,6 +4,8 @@ #include "qemu-common.h" #include "hw/pci/pci.h" +#define MSIX_CAP_LENGTH 12 + void msix_set_message(PCIDevice *dev, int vector, MSIMessage msg); MSIMessage msix_get_message(PCIDevice *dev, unsigned int vector); int msix_init(PCIDevice *dev, unsigned short nentries,