Skip to contentSkip to conversation

Add various undefined MMIO r/w functions

PATCH Superseded P J P 7 participants 19 messages Jun 17, 2020

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

P J P

author
#0 lore raw

cover Add various undefined MMIO r/w functions

From: Prasad J Pandit <[email protected]>

Hello,

This series adds various undefined MMIO read/write functions to avoid potential guest crash via a NULL pointer dereference.

ex. -> https://git.qemu.org/?p=qemu.git;a=commit;h=bb15013ef34617eb1344f5276292cadd326c21b2

Thank you.
--
Prasad J Pandit (6):
hw/pci-host: add pci-intack write method
pci-host: add pcie-msi read method
vfio: add quirk device write method
prep: add ppc-parity write method
nvram: add nrf51_soc flash read method
spapr_pci: add spapr msi read method

 hw/nvram/nrf51_nvm.c     | 7 +++++++
 hw/pci-host/designware.c | 9 +++++++++
 hw/pci-host/prep.c       | 8 ++++++++
 hw/ppc/prep_systemio.c   | 8 ++++++++
 hw/ppc/spapr_pci.c       | 9 ++++++++-
 hw/vfio/pci-quirks.c     | 8 ++++++++
 6 files changed, 48 insertions(+), 1 deletion(-)
Signature · 1 line
2.26.2
author
#1 lore raw

PATCH 1/6 hw/pci-host: add pci-intack write method

From: Prasad J Pandit <[email protected]>

Add pci-intack mmio write method to avoid NULL pointer dereference issue.

---
 hw/pci-host/prep.c | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/pci-host/prep.c +8 -0
index 1a02e9a670..41befee203 100644
@@ -27,6 +27,7 @@
 #include "qemu-common.h"
 #include "qemu/units.h"
 #include "qapi/error.h"
+#include "qemu/log.h"
 #include "hw/pci/pci.h"
 #include "hw/pci/pci_bus.h"
 #include "hw/pci/pci_host.h"
@@ -119,8 +120,15 @@ static uint64_t raven_intack_read(void *opaque, hwaddr addr,
     return pic_read_irq(isa_pic);
 }
 
+static void raven_intack_write(void *opaque, hwaddr addr,
+                                        uint64_t data, unsigned size)
+{
+    qemu_log_mask(LOG_UNIMP, "%s not implemented\n", __func__);
+}
+
 static const MemoryRegionOps raven_intack_ops = {
     .read = raven_intack_read,
+    .write = raven_intack_write,
     .valid = {
         .max_access_size = 1,
     },
Signature · 1 line
2.26.2
author
#2 lore raw

PATCH 2/6 pci-host: add pcie-msi read method

In reply to P J P

From: Prasad J Pandit <[email protected]>

Add pcie-msi mmio read method to avoid NULL pointer dereference issue.

---
 hw/pci-host/designware.c | 9 +++++++++
 1 file changed, 9 insertions(+)
hw/pci-host/designware.c +9 -0
index dd245516dd..c34c366f36 100644
@@ -21,6 +21,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "qemu/module.h"
+#include "qemu/log.h"
 #include "hw/pci/msi.h"
 #include "hw/pci/pci_bridge.h"
 #include "hw/pci/pci_host.h"
@@ -63,6 +64,13 @@ designware_pcie_root_to_host(DesignwarePCIERoot *root)
     return DESIGNWARE_PCIE_HOST(bus->parent);
 }
 
+static uint64_t designware_pcie_root_msi_read(void *opaque, hwaddr addr,
+                                              unsigned size)
+{
+    qemu_log_mask(LOG_UNIMP, "%s not implemented\n", __func__);
+    return 0;
+}
+
 static void designware_pcie_root_msi_write(void *opaque, hwaddr addr,
                                            uint64_t val, unsigned len)
 {
@@ -77,6 +85,7 @@ static void designware_pcie_root_msi_write(void *opaque, hwaddr addr,
 }
 
 static const MemoryRegionOps designware_pci_host_msi_ops = {
+    .read = designware_pcie_root_msi_read,
     .write = designware_pcie_root_msi_write,
     .endianness = DEVICE_LITTLE_ENDIAN,
     .valid = {
Signature · 1 line
2.26.2
author
#3 lore raw

PATCH 3/6 vfio: add quirk device write method

In reply to P J P

From: Prasad J Pandit <[email protected]>

Add vfio quirk device mmio write method to avoid NULL pointer dereference issue.

---
 hw/vfio/pci-quirks.c | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/vfio/pci-quirks.c +8 -0
index f2155ddb1d..5bd98885d5 100644
@@ -13,6 +13,7 @@
 #include "qemu/osdep.h"
 #include "exec/memop.h"
 #include "qemu/units.h"
+#include "qemu/log.h"
 #include "qemu/error-report.h"
 #include "qemu/main-loop.h"
 #include "qemu/module.h"
@@ -263,8 +264,15 @@ static uint64_t vfio_ati_3c3_quirk_read(void *opaque,
     return data;
 }
 
+static void vfio_ati_3c3_quirk_write(void *opaque, hwaddr addr,
+                                        uint64_t data, unsigned size)
+{
+    qemu_log_mask(LOG_UNIMP, "%s not implemented\n", __func__);
+}
+
 static const MemoryRegionOps vfio_ati_3c3_quirk = {
     .read = vfio_ati_3c3_quirk_read,
+    .write = vfio_ati_3c3_quirk_write,
     .endianness = DEVICE_LITTLE_ENDIAN,
 };
 
Signature · 1 line
2.26.2
#4 lore raw

Re: [PATCH 3/6] vfio: add quirk device write method

Quoted 24 lines · P J P

From: Prasad J Pandit <[email protected]>

Add vfio quirk device mmio write method to avoid NULL pointer dereference issue.

---
 hw/vfio/pci-quirks.c | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/vfio/pci-quirks.c +1 -0
index f2155ddb1d..5bd98885d5 100644
@@ -13,6 +13,7 @@
 #include "qemu/osdep.h"
 #include "exec/memop.h"
 #include "qemu/units.h"
+#include "qemu/log.h"
 #include "qemu/error-report.h"
 #include "qemu/main-loop.h"
 #include "qemu/module.h"

hw/vfio/pci-quirks.c static uint64_t vfio_ati_3c3_quirk_read(void *opaque, · line 270

Quoted 7 lines
hw/vfio/pci-quirks.c +4 -0
@@ -263,8 +264,15 @@ static uint64_t vfio_ati_3c3_quirk_read(void *opaque,
     return data;
 }
 
+static void vfio_ati_3c3_quirk_write(void *opaque, hwaddr addr,
+                                        uint64_t data, unsigned size)
+{
+    qemu_log_mask(LOG_UNIMP, "%s not implemented\n", __func__);

Shouldn't this be LOG_GUEST_ERROR?

Quoted 9 lines
hw/vfio/pci-quirks.c +3 -0
+}
+
 static const MemoryRegionOps vfio_ati_3c3_quirk = {
     .read = vfio_ati_3c3_quirk_read,
+    .write = vfio_ati_3c3_quirk_write,
     .endianness = DEVICE_LITTLE_ENDIAN,
 };
 
author
#5 lore raw

PATCH 4/6 prep: add ppc-parity write method

In reply to P J P

From: Prasad J Pandit <[email protected]>

Add ppc-parity mmio write method to avoid NULL pointer dereference issue.

---
 hw/ppc/prep_systemio.c | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/ppc/prep_systemio.c +8 -0
index bbc51b6e9a..aacd7831fd 100644
@@ -23,6 +23,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/log.h"
 #include "hw/irq.h"
 #include "hw/isa/isa.h"
 #include "hw/qdev-properties.h"
@@ -235,8 +236,15 @@ static uint64_t ppc_parity_error_readl(void *opaque, hwaddr addr,
     return val;
 }
 
+static void ppc_parity_error_writel(void *opaque, hwaddr addr,
+                                    uint64_t data, unsigned size)
+{
+    qemu_log_mask(LOG_UNIMP, "%s not implemented\n", __func__);
+}
+
 static const MemoryRegionOps ppc_parity_error_ops = {
     .read = ppc_parity_error_readl,
+    .write = ppc_parity_error_writel,
     .valid = {
         .min_access_size = 4,
         .max_access_size = 4,
Signature · 1 line
2.26.2
#6 lore raw

Re: [PATCH 4/6] prep: add ppc-parity write method

Quoted 24 lines · P J P

From: Prasad J Pandit <[email protected]>

Add ppc-parity mmio write method to avoid NULL pointer dereference issue.

---
 hw/ppc/prep_systemio.c | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/ppc/prep_systemio.c +1 -0
index bbc51b6e9a..aacd7831fd 100644
@@ -23,6 +23,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/log.h"
 #include "hw/irq.h"
 #include "hw/isa/isa.h"
 #include "hw/qdev-properties.h"

hw/ppc/prep_systemio.c static uint64_t ppc_parity_error_readl(void *opaque, hwaddr addr, · line 242

Quoted 7 lines
hw/ppc/prep_systemio.c +4 -0
@@ -235,8 +236,15 @@ static uint64_t ppc_parity_error_readl(void *opaque, hwaddr addr,
     return val;
 }
 
+static void ppc_parity_error_writel(void *opaque, hwaddr addr,
+                                    uint64_t data, unsigned size)
+{
+    qemu_log_mask(LOG_UNIMP, "%s not implemented\n", __func__);

I understand the parity bits are calculated by the hardware, I doubt we can write them. So probably LOG_GUEST_ERROR or a transaction failure here.

Quoted 9 lines
hw/ppc/prep_systemio.c +3 -0
+}
+
 static const MemoryRegionOps ppc_parity_error_ops = {
     .read = ppc_parity_error_readl,
+    .write = ppc_parity_error_writel,
     .valid = {
         .min_access_size = 4,
         .max_access_size = 4,
author
#7 lore raw

PATCH 5/6 nvram: add nrf51_soc flash read method

In reply to P J P

From: Prasad J Pandit <[email protected]>

Add nrf51_soc mmio read method to avoid NULL pointer dereference issue.

---
 hw/nvram/nrf51_nvm.c | 7 +++++++
 1 file changed, 7 insertions(+)
hw/nvram/nrf51_nvm.c +7 -0
index f2283c1a8d..e813c7ec72 100644
@@ -274,6 +274,12 @@ static const MemoryRegionOps io_ops = {
 };
 
 
+static uint64_t flash_read(void *opaque, hwaddr addr, unsigned size)
+{
+    qemu_log_mask(LOG_UNIMP, "%s not implemented\n", __func__);
+    return 0;
+}
+
 static void flash_write(void *opaque, hwaddr offset, uint64_t value,
         unsigned int size)
 {
@@ -300,6 +306,7 @@ static void flash_write(void *opaque, hwaddr offset, uint64_t value,
 
 
 static const MemoryRegionOps flash_ops = {
+    .read = flash_read,
     .write = flash_write,
     .valid.min_access_size = 4,
     .valid.max_access_size = 4,
Signature · 1 line
2.26.2
#8 lore raw

Re: [PATCH 5/6] nvram: add nrf51_soc flash read method

Quoted 16 lines · P J P

From: Prasad J Pandit <[email protected]>

Add nrf51_soc mmio read method to avoid NULL pointer dereference issue.

---
 hw/nvram/nrf51_nvm.c | 7 +++++++
 1 file changed, 7 insertions(+)
hw/nvram/nrf51_nvm.c +0 -0
index f2283c1a8d..e813c7ec72 100644

hw/nvram/nrf51_nvm.c static const MemoryRegionOps io_ops = { · line 280

Quoted 7 lines
hw/nvram/nrf51_nvm.c +4 -0
@@ -274,6 +274,12 @@ static const MemoryRegionOps io_ops = {
 };
 
 
+static uint64_t flash_read(void *opaque, hwaddr addr, unsigned size)
+{
+    qemu_log_mask(LOG_UNIMP, "%s not implemented\n", __func__);
+    return 0;

This is a ROM device, shouldn't we return this instead?

        return ldl_le_p(s->storage + offset);
Quoted 14 lines
hw/nvram/nrf51_nvm.c +3 -0
+}
+
 static void flash_write(void *opaque, hwaddr offset, uint64_t value,
         unsigned int size)
 {
@@ -300,6 +306,7 @@ static void flash_write(void *opaque, hwaddr offset, uint64_t value,
 
 
 static const MemoryRegionOps flash_ops = {
+    .read = flash_read,
     .write = flash_write,
     .valid.min_access_size = 4,
     .valid.max_access_size = 4,
author
#9 lore raw

PATCH 6/6 spapr_pci: add spapr msi read method

In reply to P J P

From: Prasad J Pandit <[email protected]>

Add spapr msi mmio read method to avoid NULL pointer dereference issue.

---
 hw/ppc/spapr_pci.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
hw/ppc/spapr_pci.c +8 -1
index 83f1453096..d4193be205 100644
@@ -52,6 +52,7 @@
 #include "sysemu/kvm.h"
 #include "sysemu/hostmem.h"
 #include "sysemu/numa.h"
+#include "qemu/log.h"
 
 /* Copied from the kernel arch/powerpc/platforms/pseries/msi.c */
 #define RTAS_QUERY_FN           0
@@ -738,6 +739,12 @@ static PCIINTxRoute spapr_route_intx_pin_to_irq(void *opaque, int pin)
     return route;
 }
 
+static uint64_t spapr_msi_read(void *opaque, hwaddr addr, unsigned size)
+{
+    qemu_log_mask(LOG_UNIMP, "%s not implemented\n", __func__);
+    return 0;
+}
+
 /*
  * MSI/MSIX memory region implementation.
  * The handler handles both MSI and MSIX.
@@ -756,7 +763,7 @@ static void spapr_msi_write(void *opaque, hwaddr addr,
 
 static const MemoryRegionOps spapr_msi_ops = {
     /* There is no .read as the read result is undefined by PCI spec */
-    .read = NULL,
+    .read = spapr_msi_read,
     .write = spapr_msi_write,
     .endianness = DEVICE_LITTLE_ENDIAN
 };
Signature · 1 line
2.26.2
#10 lore raw

Re: [PATCH 6/6] spapr_pci: add spapr msi read method

Quoted 37 lines · P J P

From: Prasad J Pandit <[email protected]>

Add spapr msi mmio read method to avoid NULL pointer dereference issue.

---
 hw/ppc/spapr_pci.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
hw/ppc/spapr_pci.c +7 -0
index 83f1453096..d4193be205 100644
@@ -52,6 +52,7 @@
 #include "sysemu/kvm.h"
 #include "sysemu/hostmem.h"
 #include "sysemu/numa.h"
+#include "qemu/log.h"
 
 /* Copied from the kernel arch/powerpc/platforms/pseries/msi.c */
 #define RTAS_QUERY_FN           0
@@ -738,6 +739,12 @@ static PCIINTxRoute spapr_route_intx_pin_to_irq(void *opaque, int pin)
     return route;
 }
 
+static uint64_t spapr_msi_read(void *opaque, hwaddr addr, unsigned size)
+{
+    qemu_log_mask(LOG_UNIMP, "%s not implemented\n", __func__);
+    return 0;
+}
+
 /*
  * MSI/MSIX memory region implementation.
  * The handler handles both MSI and MSIX.

hw/ppc/spapr_pci.c static void spapr_msi_write(void *opaque, hwaddr addr, · line 765

Quoted 3 lines
hw/ppc/spapr_pci.c +0 -0
@@ -756,7 +763,7 @@ static void spapr_msi_write(void *opaque, hwaddr addr,
 
 static const MemoryRegionOps spapr_msi_ops = {
     /* There is no .read as the read result is undefined by PCI spec */

We probably want to implement .accepts handler instead.

Quoted 6 lines
hw/ppc/spapr_pci.c +1 -1
-    .read = NULL,
+    .read = spapr_msi_read,
     .write = spapr_msi_write,
     .endianness = DEVICE_LITTLE_ENDIAN
 };
#11 lore raw
In reply to P J P
Patchew URL: https://patchew.org/QEMU/[email protected]/

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

Hi,

This series failed the asan build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
export ARCH=x86_64
make docker-image-fedora V=1 NETWORK=1
time make docker-test-debug@fedora TARGET_LIST=x86_64-softmmu J=14 NETWORK=1 === TEST SCRIPT END ===

  CC      qga/guest-agent-command-state.o
  CC      qga/main.o
  CC      qga/commands-posix.o
/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
  CC      qga/channel-posix.o
  CC      qga/qapi-generated/qga-qapi-types.o
  CC      qga/qapi-generated/qga-qapi-visit.o
---
  GEN     docs/interop/qemu-ga-ref.html
  GEN     docs/interop/qemu-ga-ref.txt
  GEN     docs/interop/qemu-ga-ref.7

/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
LINK qemu-keymap
/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
LINK ivshmem-client
LINK ivshmem-server
/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
LINK qemu-nbd
/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
LINK qemu-storage-daemon
/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
AS pc-bios/optionrom/multiboot.o
/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
LINK qemu-img
AS pc-bios/optionrom/linuxboot.o
/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)

  CC      pc-bios/optionrom/linuxboot_dma.o
  AS      pc-bios/optionrom/kvmvapic.o
  AS      pc-bios/optionrom/pvh.o
  CC      pc-bios/optionrom/pvh_main.o
  BUILD   pc-bios/optionrom/multiboot.img
  LINK    qemu-io
/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
  BUILD   pc-bios/optionrom/linuxboot.img
  BUILD   pc-bios/optionrom/linuxboot_dma.img
  BUILD   pc-bios/optionrom/kvmvapic.img
---
  LINK    fsdev/virtfs-proxy-helper
  BUILD   pc-bios/optionrom/linuxboot.raw
  BUILD   pc-bios/optionrom/multiboot.raw
/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
  BUILD   pc-bios/optionrom/kvmvapic.raw
  SIGN    pc-bios/optionrom/linuxboot.bin
  LINK    scsi/qemu-pr-helper
  SIGN    pc-bios/optionrom/linuxboot_dma.bin
  SIGN    pc-bios/optionrom/kvmvapic.bin
  LINK    qemu-bridge-helper

/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
SIGN pc-bios/optionrom/multiboot.bin
LINK virtiofsd
/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o) /usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)

  LINK    vhost-user-input
  LINK    qemu-ga
  BUILD   pc-bios/optionrom/pvh.img
  BUILD   pc-bios/optionrom/pvh.raw
  SIGN    pc-bios/optionrom/pvh.bin
/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
/usr/bin/ld: /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors_vfork.S.o): warning: common of `__interception::real_vfork' overridden by definition from /usr/lib64/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o)
  GEN     x86_64-softmmu/hmp-commands-info.h
  GEN     x86_64-softmmu/hmp-commands.h
  GEN     x86_64-softmmu/config-target.h
---
  CC      x86_64-softmmu/hw/scsi/virtio-scsi.o
  CC      x86_64-softmmu/hw/scsi/virtio-scsi-dataplane.o
  CC      x86_64-softmmu/hw/scsi/vhost-scsi-common.o
/tmp/qemu-test/src/migration/ram.c:919:45: error: implicit conversion from 'unsigned long' to 'double' changes value from 18446744073709551615 to 18446744073709551616 [-Werror,-Wimplicit-int-float-conversion]
            xbzrle_counters.encoding_rate = UINT64_MAX;
                                          ~ ^~~~~~~~~~

/usr/include/stdint.h:130:23: note: expanded from macro 'UINT64_MAX'
---
18446744073709551615UL
^~~~~~~~~~~~~~~~~~~~~~
1 error generated.
/tmp/qemu-test/src/fpu/softfloat.c:3365:13: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]

    absZ &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven );
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            !
/tmp/qemu-test/src/fpu/softfloat.c:3423:18: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
        absZ0 &= ~ ( ( (uint64_t) ( absZ1<<1 ) == 0 ) & roundNearestEven );
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                 !
/tmp/qemu-test/src/fpu/softfloat.c:3483:18: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
        absZ0 &= ~(((uint64_t)(absZ1<<1) == 0) & roundNearestEven);
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                 !
/tmp/qemu-test/src/fpu/softfloat.c:3606:13: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
    zSig &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven );
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            !
/tmp/qemu-test/src/fpu/softfloat.c:3760:13: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
    zSig &= ~ ( ( ( roundBits ^ 0x200 ) == 0 ) & roundNearestEven );
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            !
/tmp/qemu-test/src/fpu/softfloat.c:3987:21: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
                    ~ ( ( (uint64_t) ( zSig1<<1 ) == 0 ) & roundNearestEven );
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                    !
/tmp/qemu-test/src/fpu/softfloat.c:4003:22: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
            zSig0 &= ~ ( ( (uint64_t) ( zSig1<<1 ) == 0 ) & roundNearestEven );
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                     !
/tmp/qemu-test/src/fpu/softfloat.c:4273:18: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
        zSig1 &= ~ ( ( zSig2 + zSig2 == 0 ) & roundNearestEven );
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                 !

8 errors generated.
make[1]: *** [/tmp/qemu-test/src/rules.mak:69: migration/ram.o] Error 1 make[1]: *** Waiting for unfinished jobs....
make[1]: *** [/tmp/qemu-test/src/rules.mak:69: fpu/softfloat.o] Error 1
make: *** [Makefile:527: x86_64-softmmu/all] Error 2 Traceback (most recent call last):
File "./tests/docker/docker.py", line 669, in <module>

    sys.exit(main())

---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=01f020e1222945239d0a8e124f15f6c3', '-u', '1001', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=x86_64-softmmu', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-3dfzrfgw/src/docker-src.2020-06-17-02.03.49.10100:/var/tmp/qemu:z,ro', 'qemu:fedora', '/var/tmp/qemu/run', 'test-debug']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=01f020e1222945239d0a8e124f15f6c3
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-3dfzrfgw/src'
make: *** [docker-run-test-debug@fedora] Error 2

real 3m44.998s
user 0m8.259s

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

#12 lore raw
In reply to P J P
Quoted 6 lines · P J P

From: Prasad J Pandit <[email protected]>

Hello,

This series adds various undefined MMIO read/write functions to avoid potential guest crash via a NULL pointer dereference.

Hrm. If this is such a common problem, maybe we should just add a NULL check in the common paths.

Quoted 4 lines

ex. -> https://git.qemu.org/?p=qemu.git;a=commit;h=bb15013ef34617eb1344f5276292cadd326c21b2

Thank you.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#13 lore raw
Quoted 10 lines · On Wed, 17 Jun 2020 16:39:56 +1000 David Gibson <[email protected]>…
Quoted 6 lines · P J P

From: Prasad J Pandit <[email protected]>

Hello,

This series adds various undefined MMIO read/write functions to avoid potential guest crash via a NULL pointer dereference.

Hrm. If this is such a common problem, maybe we should just add a NULL check in the common paths.

+1, clearly the behavior is already expected. Thanks,

Alex

#14 lore raw
Quoted 8 lines · Alex Williamson
Quoted 5 lines · On Wed, 17 Jun 2020 16:39:56 +1000 David Gibson <[email protected]>…
Quoted 4 lines · P J P

From: Prasad J Pandit <[email protected]>

Hello,

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

This series adds various undefined MMIO read/write functions to avoid potential guest crash via a NULL pointer dereference.

Hrm. If this is such a common problem, maybe we should just add a NULL check in the common paths.

+1, clearly the behavior is already expected. Thanks,

20 months ago Peter suggested:

"assert that every MemoryRegionOps has pointers to callbacks
in it, when it is registered in memory_region_init_io() and memory_region_init_rom_device_nomigrate()."

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

Li Qiang refers to this post from Paolo:

Quoted 5 lines

static const MemoryRegionOps notdirty_mem_ops = {
+ .read = notdirty_mem_read,
.write = notdirty_mem_write, .valid.accepts = notdirty_mem_accepts, .endianness = DEVICE_NATIVE_ENDIAN,

"This cannot happen, since TLB_NOTDIRTY is only added
to the addr_write member (see accel/tcg/cputlb.c)."

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

#15 lore raw
Quoted 33 lines · Philippe Mathieu-Daudé
Quoted 8 lines · Alex Williamson
Quoted 5 lines · On Wed, 17 Jun 2020 16:39:56 +1000 David Gibson <[email protected]>…
Quoted 4 lines · P J P

From: Prasad J Pandit <[email protected]>

Hello,

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

This series adds various undefined MMIO read/write functions to avoid potential guest crash via a NULL pointer dereference.

Hrm. If this is such a common problem, maybe we should just add a NULL check in the common paths.

+1, clearly the behavior is already expected. Thanks,

20 months ago Peter suggested:

"assert that every MemoryRegionOps has pointers to callbacks
in it, when it is registered in memory_region_init_io() and memory_region_init_rom_device_nomigrate()."

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

Li Qiang refers to this post from Paolo:

Quoted 5 lines

static const MemoryRegionOps notdirty_mem_ops = {
+ .read = notdirty_mem_read,
.write = notdirty_mem_write, .valid.accepts = notdirty_mem_accepts, .endianness = DEVICE_NATIVE_ENDIAN,

Quoted 4 lines

"This cannot happen, since TLB_NOTDIRTY is only added
to the addr_write member (see accel/tcg/cputlb.c)."

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

What about catching it in memory_region_dispatch_write:

    if (mr->ops->write) {
        return access_with_adjusted_size(addr, &data, size,
                                         mr->ops->impl.min_access_size,
                                         mr->ops->impl.max_access_size,
                                         memory_region_write_accessor, mr,
                                         attrs);
    } else if (mr->ops->write_with_attrs) {
        return
            access_with_adjusted_size(addr, &data, size,
                                      mr->ops->impl.min_access_size,
                                      mr->ops->impl.max_access_size,
                                      memory_region_write_with_attrs_accessor,
                                      mr, attrs);
    } else {
        qemu_log_mask(LOG_UNIMP|LOG_GUEST_ERROR, "%s: %s un-handled write\n",
                      __func__, mr->name);
    }
Signature · 1 line
Alex Bennée
#16 lore raw
Quoted 43 lines · Alex Bennée
Quoted 33 lines · Philippe Mathieu-Daudé
Quoted 8 lines · Alex Williamson
Quoted 5 lines · On Wed, 17 Jun 2020 16:39:56 +1000 David Gibson <[email protected]>…
Quoted 4 lines · P J P

From: Prasad J Pandit <[email protected]>

Hello,

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

This series adds various undefined MMIO read/write functions to avoid potential guest crash via a NULL pointer dereference.

Hrm. If this is such a common problem, maybe we should just add a NULL check in the common paths.

+1, clearly the behavior is already expected. Thanks,

20 months ago Peter suggested:

"assert that every MemoryRegionOps has pointers to callbacks
in it, when it is registered in memory_region_init_io() and memory_region_init_rom_device_nomigrate()."

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

Li Qiang refers to this post from Paolo:

Quoted 5 lines

static const MemoryRegionOps notdirty_mem_ops = {
+ .read = notdirty_mem_read,
.write = notdirty_mem_write, .valid.accepts = notdirty_mem_accepts, .endianness = DEVICE_NATIVE_ENDIAN,

Quoted 4 lines

"This cannot happen, since TLB_NOTDIRTY is only added
to the addr_write member (see accel/tcg/cputlb.c)."

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

What about catching it in memory_region_dispatch_write:

Quoted 16 lines
    if (mr->ops->write) {
        return access_with_adjusted_size(addr, &data, size,
                                         mr->ops->impl.min_access_size,
                                         mr->ops->impl.max_access_size,
                                         memory_region_write_accessor, mr,
                                         attrs);
    } else if (mr->ops->write_with_attrs) {
        return
            access_with_adjusted_size(addr, &data, size,
                                      mr->ops->impl.min_access_size,
                                      mr->ops->impl.max_access_size,
                                      memory_region_write_with_attrs_accessor,
                                      mr, attrs);
    } else {
        qemu_log_mask(LOG_UNIMP|LOG_GUEST_ERROR, "%s: %s un-handled write\n",
                      __func__, mr->name);

The problem is what return value to return... MEMTX_OK/MEMTX_ERROR/MEMTX_DECODE_ERROR? This is very device-specific and can't be decided here for all the cases.

Better to abort() and fix each device?

Quoted 3 lines
    }
#17 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 27 lines · Philippe Mathieu-Daudé
Quoted 8 lines · Alex Williamson
Quoted 5 lines · On Wed, 17 Jun 2020 16:39:56 +1000 David Gibson <[email protected]>…
Quoted 4 lines · P J P

From: Prasad J Pandit <[email protected]>

Hello,

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

This series adds various undefined MMIO read/write functions to avoid potential guest crash via a NULL pointer dereference.

Hrm. If this is such a common problem, maybe we should just add a NULL check in the common paths.

+1, clearly the behavior is already expected. Thanks,

20 months ago Peter suggested:

"assert that every MemoryRegionOps has pointers to callbacks
in it, when it is registered in memory_region_init_io() and memory_region_init_rom_device_nomigrate()."

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

Li Qiang refers to this post from Paolo:

Quoted 8 lines
Quoted 5 lines

static const MemoryRegionOps notdirty_mem_ops = {
+ .read = notdirty_mem_read,
.write = notdirty_mem_write, .valid.accepts = notdirty_mem_accepts, .endianness = DEVICE_NATIVE_ENDIAN,

"This cannot happen, since TLB_NOTDIRTY is only added
to the addr_write member (see accel/tcg/cputlb.c)."

I'm now okay with asserting it, as long as notdirty_mem_read abort()s.

Paolo

author
#18 lore raw
+-- On Wed, 17 Jun 2020, Paolo Bonzini wrote --+
| On 17/06/20 15:20, Philippe Mathieu-Daudé wrote:
| > On 6/17/20 3:06 PM, Alex Williamson wrote:
| >> On Wed, 17 Jun 2020 16:39:56 +1000
| >> David Gibson <[email protected]> wrote:
| >>> Hrm.  If this is such a common problem, maybe we should just add a NULL 
| >>> check in the common paths.
| >>
| >> +1, clearly the behavior is already expected.  Thanks,
| >
| > 20 months ago Peter suggested:
| > 
| > "assert that every MemoryRegionOps has pointers to callbacks
| >  in it, when it is registered in memory_region_init_io() and
| >  memory_region_init_rom_device_nomigrate()."
| > 
| > https://www.mail-archive.com/[email protected]/msg573310.html
| > 
| > Li Qiang refers to this post from Paolo:
| > 
| >>  static const MemoryRegionOps notdirty_mem_ops = {
| >> +    .read = notdirty_mem_read,
| >>      .write = notdirty_mem_write,
| >>      .valid.accepts = notdirty_mem_accepts,
| >>      .endianness = DEVICE_NATIVE_ENDIAN,
| > 
| > "This cannot happen, since TLB_NOTDIRTY is only added
| >  to the addr_write member (see accel/tcg/cputlb.c)."
| 
| I'm now okay with asserting it, as long as notdirty_mem_read abort()s.

Okay, I'm preparing a revised patch.

Thank you.
--
Prasad J Pandit / Red Hat Product Security Team
8685 545E B54C 486B C6EB 271E E285 8B5A F050 DE8D