Re: [PATCH 13/13] hw/net/tulip: Use ld/st_endian_pci_dma() API

2024-10-01 Thread Pierrick Bouvier

On 9/30/24 00:34, Philippe Mathieu-Daudé wrote:

Refactor to use the recently introduced ld/st_endian_pci_dma()
API. No logical change intended.

Signed-off-by: Philippe Mathieu-Daudé 
---
  hw/net/tulip.c | 32 ++--
  1 file changed, 10 insertions(+), 22 deletions(-)

diff --git a/hw/net/tulip.c b/hw/net/tulip.c
index 9df3e17162..6c67958da7 100644
--- a/hw/net/tulip.c
+++ b/hw/net/tulip.c
@@ -71,36 +71,24 @@ static void tulip_desc_read(TULIPState *s, hwaddr p,
  struct tulip_descriptor *desc)
  {
  const MemTxAttrs attrs = { .memory = true };
+bool use_big_endian = s->csr[0] & CSR0_DBO;
  
-if (s->csr[0] & CSR0_DBO) {

-ldl_be_pci_dma(&s->dev, p, &desc->status, attrs);
-ldl_be_pci_dma(&s->dev, p + 4, &desc->control, attrs);
-ldl_be_pci_dma(&s->dev, p + 8, &desc->buf_addr1, attrs);
-ldl_be_pci_dma(&s->dev, p + 12, &desc->buf_addr2, attrs);
-} else {
-ldl_le_pci_dma(&s->dev, p, &desc->status, attrs);
-ldl_le_pci_dma(&s->dev, p + 4, &desc->control, attrs);
-ldl_le_pci_dma(&s->dev, p + 8, &desc->buf_addr1, attrs);
-ldl_le_pci_dma(&s->dev, p + 12, &desc->buf_addr2, attrs);
-}
+ldl_endian_pci_dma(use_big_endian, &s->dev, p, &desc->status, attrs);
+ldl_endian_pci_dma(use_big_endian, &s->dev, p + 4, &desc->control, attrs);
+ldl_endian_pci_dma(use_big_endian, &s->dev, p + 8, &desc->buf_addr1, 
attrs);
+ldl_endian_pci_dma(use_big_endian, &s->dev, p + 12, &desc->buf_addr2, 
attrs);
  }
  
  static void tulip_desc_write(TULIPState *s, hwaddr p,

  struct tulip_descriptor *desc)
  {
  const MemTxAttrs attrs = { .memory = true };
+bool use_big_endian = s->csr[0] & CSR0_DBO;
  
-if (s->csr[0] & CSR0_DBO) {

-stl_be_pci_dma(&s->dev, p, desc->status, attrs);
-stl_be_pci_dma(&s->dev, p + 4, desc->control, attrs);
-stl_be_pci_dma(&s->dev, p + 8, desc->buf_addr1, attrs);
-stl_be_pci_dma(&s->dev, p + 12, desc->buf_addr2, attrs);
-} else {
-stl_le_pci_dma(&s->dev, p, desc->status, attrs);
-stl_le_pci_dma(&s->dev, p + 4, desc->control, attrs);
-stl_le_pci_dma(&s->dev, p + 8, desc->buf_addr1, attrs);
-stl_le_pci_dma(&s->dev, p + 12, desc->buf_addr2, attrs);
-}
+stl_endian_pci_dma(use_big_endian, &s->dev, p, desc->status, attrs);
+stl_endian_pci_dma(use_big_endian, &s->dev, p + 4, desc->control, attrs);
+stl_endian_pci_dma(use_big_endian, &s->dev, p + 8, desc->buf_addr1, attrs);
+stl_endian_pci_dma(use_big_endian, &s->dev, p + 12, desc->buf_addr2, 
attrs);
  }
  
  static void tulip_update_int(TULIPState *s)


Reviewed-by: Pierrick Bouvier 


Re: [PATCH 12/13] hw/pci/pci_device: Introduce ld/st_endian_pci_dma() API

2024-10-01 Thread Pierrick Bouvier

On 9/30/24 00:34, Philippe Mathieu-Daudé wrote:

Introduce the ld/st_endian_pci_dma() API, which takes an extra
boolean argument to dispatch to ld/st_{be,le}_pci_dma() methods.

Signed-off-by: Philippe Mathieu-Daudé 
---
TODO: Update docstring regexp
---
  include/hw/pci/pci_device.h | 24 +++-
  1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h
index ff619241a4..dc9b17dded 100644
--- a/include/hw/pci/pci_device.h
+++ b/include/hw/pci/pci_device.h
@@ -300,7 +300,29 @@ static inline MemTxResult pci_dma_write(PCIDevice *dev, 
dma_addr_t addr,
  
  #define PCI_DMA_DEFINE_LDST_END(_l, _s, _bits) \

  PCI_DMA_DEFINE_LDST(_l##_le, _s##_le, _bits) \
-PCI_DMA_DEFINE_LDST(_l##_be, _s##_be, _bits)
+PCI_DMA_DEFINE_LDST(_l##_be, _s##_be, _bits) \
+static inline MemTxResult ld##_l##_endian_pci_dma(bool is_big_endian, \
+  PCIDevice *dev, \
+  dma_addr_t addr, \
+  uint##_bits##_t *val, \
+  MemTxAttrs attrs) \
+{ \
+AddressSpace *pci_as = pci_get_address_space(dev); \
+return is_big_endian \
+   ? ld##_l##_be_dma(pci_as, addr, val, attrs) \
+   : ld##_l##_le_dma(pci_as, addr, val, attrs); \
+} \
+static inline MemTxResult st##_s##_endian_pci_dma(bool is_big_endian, \
+  PCIDevice *dev, \
+  dma_addr_t addr, \
+  uint##_bits##_t val, \
+  MemTxAttrs attrs) \
+{ \
+AddressSpace *pci_as = pci_get_address_space(dev); \
+return is_big_endian \
+   ? st##_s##_be_dma(pci_as, addr, val, attrs) \
+   : st##_s##_le_dma(pci_as, addr, val, attrs); \
+}
  
  PCI_DMA_DEFINE_LDST(ub, b, 8);

  PCI_DMA_DEFINE_LDST_END(uw, w, 16)


Reviewed-by: Pierrick Bouvier 


Re: [PATCH 11/13] hw/pci/pci_device: Add PCI_DMA_DEFINE_LDST_END() macro

2024-10-01 Thread Pierrick Bouvier



On 9/30/24 00:34, Philippe Mathieu-Daudé wrote:

Define both endianness variants with a single macro.
Useful to add yet other endian specific definitions
in the next commit.

Signed-off-by: Philippe Mathieu-Daudé 
---
  include/hw/pci/pci_device.h | 13 +++--
  1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h
index 91df40f989..ff619241a4 100644
--- a/include/hw/pci/pci_device.h
+++ b/include/hw/pci/pci_device.h
@@ -298,13 +298,14 @@ static inline MemTxResult pci_dma_write(PCIDevice *dev, 
dma_addr_t addr,
  return st##_s##_dma(pci_get_address_space(dev), addr, val, attrs); \
  }
  
+#define PCI_DMA_DEFINE_LDST_END(_l, _s, _bits) \

+PCI_DMA_DEFINE_LDST(_l##_le, _s##_le, _bits) \
+PCI_DMA_DEFINE_LDST(_l##_be, _s##_be, _bits)
+
  PCI_DMA_DEFINE_LDST(ub, b, 8);
-PCI_DMA_DEFINE_LDST(uw_le, w_le, 16)
-PCI_DMA_DEFINE_LDST(l_le, l_le, 32);
-PCI_DMA_DEFINE_LDST(q_le, q_le, 64);
-PCI_DMA_DEFINE_LDST(uw_be, w_be, 16)
-PCI_DMA_DEFINE_LDST(l_be, l_be, 32);
-PCI_DMA_DEFINE_LDST(q_be, q_be, 64);
+PCI_DMA_DEFINE_LDST_END(uw, w, 16)
+PCI_DMA_DEFINE_LDST_END(l,  l, 32)
+PCI_DMA_DEFINE_LDST_END(q,  q, 64)
  
  #undef PCI_DMA_DEFINE_LDST
  


Reviewed-by: Pierrick Bouvier 


Re: [PATCH 09/13] exec/memory_ldst_phys: Introduce ld/st_endian_phys() API

2024-10-01 Thread Pierrick Bouvier
)(ARG1, addr, val,
+   MEMTXATTRS_UNSPECIFIED, NULL);
+   } else {
+glue(address_space_stq_le, SUFFIX)(ARG1, addr, val,
+   MEMTXATTRS_UNSPECIFIED, NULL);
+}
+}
  #endif
  
  #undef ARG1_DECL


Reviewed-by: Pierrick Bouvier 


Re: [PATCH 10/13] hw/virtio/virtio-access: Use ld/st_endian_phys() API

2024-10-01 Thread Pierrick Bouvier

On 9/30/24 00:34, Philippe Mathieu-Daudé wrote:

Refactor to use the recently introduced ld/st_endian_phys() API.
No logical change intended.

Signed-off-by: Philippe Mathieu-Daudé 
---
  include/hw/virtio/virtio-access.h | 27 +--
  1 file changed, 5 insertions(+), 22 deletions(-)

diff --git a/include/hw/virtio/virtio-access.h 
b/include/hw/virtio/virtio-access.h
index b920874be8..37a42407ea 100644
--- a/include/hw/virtio/virtio-access.h
+++ b/include/hw/virtio/virtio-access.h
@@ -43,30 +43,21 @@ static inline uint16_t virtio_lduw_phys(VirtIODevice *vdev, 
hwaddr pa)
  {
  AddressSpace *dma_as = vdev->dma_as;
  
-if (virtio_access_is_big_endian(vdev)) {

-return lduw_be_phys(dma_as, pa);
-}
-return lduw_le_phys(dma_as, pa);
+return lduw_endian_phys(virtio_access_is_big_endian(vdev), dma_as, pa);
  }
  
  static inline uint32_t virtio_ldl_phys(VirtIODevice *vdev, hwaddr pa)

  {
  AddressSpace *dma_as = vdev->dma_as;
  
-if (virtio_access_is_big_endian(vdev)) {

-return ldl_be_phys(dma_as, pa);
-}
-return ldl_le_phys(dma_as, pa);
+return ldl_endian_phys(virtio_access_is_big_endian(vdev), dma_as, pa);
  }
  
  static inline uint64_t virtio_ldq_phys(VirtIODevice *vdev, hwaddr pa)

  {
  AddressSpace *dma_as = vdev->dma_as;
  
-if (virtio_access_is_big_endian(vdev)) {

-return ldq_be_phys(dma_as, pa);
-}
-return ldq_le_phys(dma_as, pa);
+return ldq_endian_phys(virtio_access_is_big_endian(vdev), dma_as, pa);
  }
  
  static inline void virtio_stw_phys(VirtIODevice *vdev, hwaddr pa,

@@ -74,11 +65,7 @@ static inline void virtio_stw_phys(VirtIODevice *vdev, 
hwaddr pa,
  {
  AddressSpace *dma_as = vdev->dma_as;
  
-if (virtio_access_is_big_endian(vdev)) {

-stw_be_phys(dma_as, pa, value);
-} else {
-stw_le_phys(dma_as, pa, value);
-}
+stw_endian_phys(virtio_access_is_big_endian(vdev), dma_as, pa, value);
  }
  
  static inline void virtio_stl_phys(VirtIODevice *vdev, hwaddr pa,

@@ -86,11 +73,7 @@ static inline void virtio_stl_phys(VirtIODevice *vdev, 
hwaddr pa,
  {
  AddressSpace *dma_as = vdev->dma_as;
  
-if (virtio_access_is_big_endian(vdev)) {

-stl_be_phys(dma_as, pa, value);
-} else {
-stl_le_phys(dma_as, pa, value);
-}
+stl_endian_phys(virtio_access_is_big_endian(vdev), dma_as, pa, value);
  }
  
  static inline void virtio_stw_p(VirtIODevice *vdev, void *ptr, uint16_t v)


Reviewed-by: Pierrick Bouvier 


Re: [PATCH 06/13] tests/tcg/plugins: Use the ld/st_endian_p() API

2024-10-01 Thread Pierrick Bouvier

On 9/30/24 00:34, Philippe Mathieu-Daudé wrote:

Refactor to use the recently introduced ld/st_endian_p() API
No logical change intended.

Signed-off-by: Philippe Mathieu-Daudé 
---
  tests/tcg/plugins/mem.c | 24 ++--
  1 file changed, 6 insertions(+), 18 deletions(-)

diff --git a/tests/tcg/plugins/mem.c b/tests/tcg/plugins/mem.c
index b0fa8a9f27..3586d05587 100644
--- a/tests/tcg/plugins/mem.c
+++ b/tests/tcg/plugins/mem.c
@@ -163,13 +163,9 @@ static void update_region_info(uint64_t region, uint64_t 
offset,
  {
  uint16_t *p = (uint16_t *) &ri->data[offset];
  if (is_store) {
-if (be) {
-stw_be_p(p, value.data.u16);
-} else {
-stw_le_p(p, value.data.u16);
-}
+stw_endian_p(be, p, value.data.u16);
  } else {
-uint16_t val = be ? lduw_be_p(p) : lduw_le_p(p);
+uint16_t val = lduw_endian_p(be, p);
  unseen_data = val != value.data.u16;
  }
  break;
@@ -178,13 +174,9 @@ static void update_region_info(uint64_t region, uint64_t 
offset,
  {
  uint32_t *p = (uint32_t *) &ri->data[offset];
  if (is_store) {
-if (be) {
-stl_be_p(p, value.data.u32);
-} else {
-stl_le_p(p, value.data.u32);
-}
+stl_endian_p(be, p, value.data.u32);
  } else {
-uint32_t val = be ? ldl_be_p(p) : ldl_le_p(p);
+uint32_t val = ldl_endian_p(be, p);
  unseen_data = val != value.data.u32;
  }
  break;
@@ -193,13 +185,9 @@ static void update_region_info(uint64_t region, uint64_t 
offset,
  {
  uint64_t *p = (uint64_t *) &ri->data[offset];
  if (is_store) {
-if (be) {
-stq_be_p(p, value.data.u64);
-} else {
-stq_le_p(p, value.data.u64);
-}
+stq_endian_p(be, p, value.data.u64);
  } else {
-uint64_t val = be ? ldq_be_p(p) : ldq_le_p(p);
+uint64_t val = ldq_endian_p(be, p);
  unseen_data = val != value.data.u64;
  }
  break;


Reviewed-by: Pierrick Bouvier 


Re: [PATCH 05/13] hw/mips: Add cpu_is_bigendian field to BlCpuCfg structure

2024-10-01 Thread Pierrick Bouvier

On 9/30/24 00:34, Philippe Mathieu-Daudé wrote:

Add the BlCpuCfg::cpu_is_bigendian field, initialize it in
machine code. Bootloader API use the ld/st_endian_p() to
dispatch to target endianness.

Signed-off-by: Philippe Mathieu-Daudé 
---
  include/hw/mips/bootloader.h |  1 +
  hw/mips/bootloader.c | 10 +-
  hw/mips/boston.c |  2 +-
  hw/mips/fuloong2e.c  |  2 +-
  hw/mips/malta.c  |  2 +-
  5 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/include/hw/mips/bootloader.h b/include/hw/mips/bootloader.h
index 744eb11d0e..ef778a38d0 100644
--- a/include/hw/mips/bootloader.h
+++ b/include/hw/mips/bootloader.h
@@ -13,6 +13,7 @@
  #include "exec/target_long.h"
  
  typedef struct bl_cpu_cfg {

+bool cpu_is_bigendian;
  } BlCpuCfg;
  
  void bl_gen_jump_to(const BlCpuCfg *cfg, void **p, target_ulong jump_addr);

diff --git a/hw/mips/bootloader.c b/hw/mips/bootloader.c
index ee1a1c4f20..258cc5d8c8 100644
--- a/hw/mips/bootloader.c
+++ b/hw/mips/bootloader.c
@@ -58,9 +58,9 @@ static void st_nm32_p(const BlCpuCfg *cfg, void **ptr, 
uint32_t insn)
  {
  uint16_t *p = *ptr;
  
-stw_p(p, insn >> 16);

+stw_endian_p(cfg->cpu_is_bigendian, p, insn >> 16);
  p++;
-stw_p(p, insn >> 0);
+stw_endian_p(cfg->cpu_is_bigendian, p, insn >> 0);
  p++;
  
  *ptr = p;

@@ -74,7 +74,7 @@ static void bl_gen_nop(const BlCpuCfg *cfg, void **ptr)
  } else {
  uint32_t *p = *ptr;
  
-stl_p(p, 0);

+stl_endian_p(cfg->cpu_is_bigendian, p, 0);
  p++;
  *ptr = p;
  }
@@ -95,7 +95,7 @@ static void bl_gen_r_type(const BlCpuCfg *cfg,
  insn = deposit32(insn, 6, 5, shift);
  insn = deposit32(insn, 0, 6, funct);
  
-stl_p(p, insn);

+stl_endian_p(cfg->cpu_is_bigendian, p, insn);
  p++;
  
  *ptr = p;

@@ -113,7 +113,7 @@ static void bl_gen_i_type(const BlCpuCfg *cfg,
  insn = deposit32(insn, 16, 5, rt);
  insn = deposit32(insn, 0, 16, imm);
  
-stl_p(p, insn);

+stl_endian_p(cfg->cpu_is_bigendian, p, insn);
  p++;
  
  *ptr = p;

diff --git a/hw/mips/boston.c b/hw/mips/boston.c
index 8e210876e1..d4dd242d0d 100644
--- a/hw/mips/boston.c
+++ b/hw/mips/boston.c
@@ -325,7 +325,7 @@ type_init(boston_register_types)
  
  static void gen_firmware(void *p, hwaddr kernel_entry, hwaddr fdt_addr)

  {
-const BlCpuCfg bl_cfg = { };
+const BlCpuCfg bl_cfg = { .cpu_is_bigendian = TARGET_BIG_ENDIAN };
  uint64_t regaddr;
  
  /* Move CM GCRs */

diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c
index a989637d3b..4fe5108845 100644
--- a/hw/mips/fuloong2e.c
+++ b/hw/mips/fuloong2e.c
@@ -165,7 +165,7 @@ static uint64_t load_kernel(MIPSCPU *cpu)
  static void write_bootloader(CPUMIPSState *env, uint8_t *base,
   uint64_t kernel_addr)
  {
-const BlCpuCfg bl_cfg = { };
+const BlCpuCfg bl_cfg = { .cpu_is_bigendian = false };
  uint32_t *p;
  
  /* Small bootloader */

diff --git a/hw/mips/malta.c b/hw/mips/malta.c
index fc485cc884..6e73c896ff 100644
--- a/hw/mips/malta.c
+++ b/hw/mips/malta.c
@@ -624,7 +624,7 @@ static void bl_setup_gt64120_jump_kernel(void **p, uint64_t 
run_addr,
  static const char pci_pins_cfg[PCI_NUM_PINS] = {
  10, 10, 11, 11 /* PIIX IRQRC[A:D] */
  };
-const BlCpuCfg bl_cfg = { };
+const BlCpuCfg bl_cfg = { .cpu_is_bigendian = TARGET_BIG_ENDIAN };
  
  /* Bus endianness is always reversed */

  #if TARGET_BIG_ENDIAN


Reviewed-by: Pierrick Bouvier 


Re: [PATCH 07/13] hw/xtensa/xtfpga: Remove TARGET_BIG_ENDIAN #ifdef'ry

2024-10-01 Thread Pierrick Bouvier

On 9/30/24 00:34, Philippe Mathieu-Daudé wrote:

Move code evaluation from preprocessor to compiler so
both if() ladders are processed. Mostly style change.

Signed-off-by: Philippe Mathieu-Daudé 
---
  hw/xtensa/xtfpga.c | 12 +++-
  1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c
index 955e8867a3..228f00b045 100644
--- a/hw/xtensa/xtfpga.c
+++ b/hw/xtensa/xtfpga.c
@@ -415,8 +415,7 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, 
MachineState *machine)
  }
  }
  if (entry_point != env->pc) {
-uint8_t boot[] = {
-#if TARGET_BIG_ENDIAN
+uint8_t boot_be[] = {
  0x60, 0x00, 0x08,   /* j1f */
  0x00,   /* .literal_position */
  0x00, 0x00, 0x00, 0x00, /* .literal entry_pc */
@@ -425,7 +424,8 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, 
MachineState *machine)
  0x10, 0xff, 0xfe,   /* l32r a0, entry_pc */
  0x12, 0xff, 0xfe,   /* l32r a2, entry_a2 */
  0x0a, 0x00, 0x00,   /* jx   a0 */
-#else
+};
+uint8_t boot_le[] = {
  0x06, 0x02, 0x00,   /* j1f */
  0x00,   /* .literal_position */
  0x00, 0x00, 0x00, 0x00, /* .literal entry_pc */
@@ -434,14 +434,16 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, 
MachineState *machine)
  0x01, 0xfe, 0xff,   /* l32r a0, entry_pc */
  0x21, 0xfe, 0xff,   /* l32r a2, entry_a2 */
  0xa0, 0x00, 0x00,   /* jx   a0 */
-#endif
  };
+const size_t boot_sz = TARGET_BIG_ENDIAN ? sizeof(boot_be)
+ : sizeof(boot_le);
+uint8_t *boot = TARGET_BIG_ENDIAN ? boot_be : boot_le;
  uint32_t entry_pc = tswap32(entry_point);
  uint32_t entry_a2 = tswap32(tagptr);
  
  memcpy(boot + 4, &entry_pc, sizeof(entry_pc));

  memcpy(boot + 8, &entry_a2, sizeof(entry_a2));
-cpu_physical_memory_write(env->pc, boot, sizeof(boot));
+cpu_physical_memory_write(env->pc, boot, boot_sz);
  }
  } else {
  if (flash) {


Reviewed-by: Pierrick Bouvier 


Re: [PATCH 01/13] qemu/bswap: Introduce ld/st_endian_p() API

2024-10-01 Thread Pierrick Bouvier

On 9/30/24 00:34, Philippe Mathieu-Daudé wrote:

Introduce the ld/st_endian_p() API, which takes an extra
boolean argument to dispatch to ld/st_{be,le}_p() methods.

Signed-off-by: Philippe Mathieu-Daudé 
---
TODO: Update docstring regexp
---
  include/qemu/bswap.h | 19 +++
  1 file changed, 19 insertions(+)

diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h
index ad22910a5d..ec813a756d 100644
--- a/include/qemu/bswap.h
+++ b/include/qemu/bswap.h
@@ -433,4 +433,23 @@ DO_STN_LDN_P(be)
  #undef le_bswaps
  #undef be_bswaps
  
+#define lduw_endian_p(big_endian, p) \

+ (big_endian) ? lduw_be_p(p) : lduw_le_p(p)
+#define ldsw_endian_p(big_endian, p) \
+ (big_endian) ? ldsw_be_p(p) : ldsw_be_p(p)
+#define ldl_endian_p(big_endian, p) \
+(big_endian) ? ldl_be_p(p) : ldl_le_p(p)
+#define ldq_endian_p(big_endian, p) \
+(big_endian) ? ldq_be_p(p) : ldq_le_p(p)
+#define stw_endian_p(big_endian, p, v) \
+(big_endian) ? stw_be_p(p, v) : stw_le_p(p, v)
+#define stl_endian_p(big_endian, p, v) \
+(big_endian) ? stl_be_p(p, v) : stl_le_p(p, v)
+#define stq_endian_p(big_endian, p, v) \
+(big_endian) ? stq_be_p(p, v) : stq_le_p(p, v)
+#define ldn_endian_p(big_endian, p, sz) \
+ (big_endian) ? ldn_be_p(p, sz) : ldn_le_p(p, sz)
+#define stn_endian_p(big_endian, p, sz, v) \
+(big_endian) ? stn_be_p(p, sz, v) : stn_le_p(p, sz, v)
+
  #endif /* BSWAP_H */


May it be useful to have extra parenthesis around macro value to prevent 
any issue when using it?

((big_endian) ? stn_be_p(p, sz, v) : stn_le_p(p, sz, v))

Else,
Reviewed-by: Pierrick Bouvier 


Re: [PATCH 04/13] hw/mips: Pass BlCpuCfg argument to bootloader API

2024-10-01 Thread Pierrick Bouvier
  true, 2, true, ENVP_VADDR,
 true, ENVP_VADDR + 8,
diff --git a/hw/mips/malta.c b/hw/mips/malta.c
index 664a2ae0a9..fc485cc884 100644
--- a/hw/mips/malta.c
+++ b/hw/mips/malta.c
@@ -624,6 +624,7 @@ static void bl_setup_gt64120_jump_kernel(void **p, uint64_t 
run_addr,
  static const char pci_pins_cfg[PCI_NUM_PINS] = {
  10, 10, 11, 11 /* PIIX IRQRC[A:D] */
  };
+const BlCpuCfg bl_cfg = { };
  
  /* Bus endianness is always reversed */

  #if TARGET_BIG_ENDIAN
@@ -635,29 +636,29 @@ static void bl_setup_gt64120_jump_kernel(void **p, 
uint64_t run_addr,
  /* setup MEM-to-PCI0 mapping as done by YAMON */
  
  /* move GT64120 registers from 0x1400 to 0x1be0 */

-bl_gen_write_u32(p, /* GT_ISD */
+bl_gen_write_u32(&bl_cfg, p, /* GT_ISD */
   cpu_mips_phys_to_kseg1(NULL, 0x1400 + 0x68),
   cpu_to_gt32(0x1be0 << 3));
  
  /* setup PCI0 io window to 0x1800-0x181f */

-bl_gen_write_u32(p, /* GT_PCI0IOLD */
+bl_gen_write_u32(&bl_cfg, p, /* GT_PCI0IOLD */
   cpu_mips_phys_to_kseg1(NULL, 0x1be0 + 0x48),
   cpu_to_gt32(0x1800 << 3));
-bl_gen_write_u32(p, /* GT_PCI0IOHD */
+bl_gen_write_u32(&bl_cfg, p, /* GT_PCI0IOHD */
   cpu_mips_phys_to_kseg1(NULL, 0x1be0 + 0x50),
   cpu_to_gt32(0x0800 << 3));
  
  /* setup PCI0 mem windows */

-bl_gen_write_u32(p, /* GT_PCI0M0LD */
+bl_gen_write_u32(&bl_cfg, p, /* GT_PCI0M0LD */
   cpu_mips_phys_to_kseg1(NULL, 0x1be0 + 0x58),
   cpu_to_gt32(0x1000 << 3));
-bl_gen_write_u32(p, /* GT_PCI0M0HD */
+bl_gen_write_u32(&bl_cfg, p, /* GT_PCI0M0HD */
   cpu_mips_phys_to_kseg1(NULL, 0x1be0 + 0x60),
   cpu_to_gt32(0x07e0 << 3));
-bl_gen_write_u32(p, /* GT_PCI0M1LD */
+bl_gen_write_u32(&bl_cfg, p, /* GT_PCI0M1LD */
   cpu_mips_phys_to_kseg1(NULL, 0x1be0 + 0x80),
   cpu_to_gt32(0x1820 << 3));
-bl_gen_write_u32(p, /* GT_PCI0M1HD */
+bl_gen_write_u32(&bl_cfg, p, /* GT_PCI0M1HD */
   cpu_mips_phys_to_kseg1(NULL, 0x1be0 + 0x88),
   cpu_to_gt32(0x0bc0 << 3));
  
@@ -668,16 +669,16 @@ static void bl_setup_gt64120_jump_kernel(void **p, uint64_t run_addr,

   * Load the PIIX IRQC[A:D] routing config address, then
   * write routing configuration to the config data register.
   */
-bl_gen_write_u32(p, /* GT_PCI0_CFGADDR */
+bl_gen_write_u32(&bl_cfg, p, /* GT_PCI0_CFGADDR */
   cpu_mips_phys_to_kseg1(NULL, 0x1be0 + 0xcf8),
   tswap32((1 << 31) /* ConfigEn */
   | PCI_BUILD_BDF(0, PIIX4_PCI_DEVFN) << 8
   | PIIX_PIRQCA));
-bl_gen_write_u32(p, /* GT_PCI0_CFGDATA */
+bl_gen_write_u32(&bl_cfg, p, /* GT_PCI0_CFGDATA */
   cpu_mips_phys_to_kseg1(NULL, 0x1be0 + 0xcfc),
   tswap32(ldl_be_p(pci_pins_cfg)));
  
-bl_gen_jump_kernel(p,

+bl_gen_jump_kernel(&bl_cfg, p,
 true, ENVP_VADDR - 64,
 /*
  * If semihosting is used, arguments have already


Reviewed-by: Pierrick Bouvier 


Re: [PATCH 03/13] target/arm/ptw: Use the ld/st_endian_p() API

2024-10-01 Thread Pierrick Bouvier

On 9/30/24 00:34, Philippe Mathieu-Daudé wrote:

Refactor to use the recently introduced ld/st_endian_p() API
No logical change intended.

Signed-off-by: Philippe Mathieu-Daudé 
---
  target/arm/ptw.c | 19 ---
  1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/target/arm/ptw.c b/target/arm/ptw.c
index defd6b84de..a1a6b1fec3 100644
--- a/target/arm/ptw.c
+++ b/target/arm/ptw.c
@@ -699,11 +699,7 @@ static uint64_t arm_ldq_ptw(CPUARMState *env, S1Translate 
*ptw,
  data = le64_to_cpu(data);
  }
  #else
-if (ptw->out_be) {
-data = ldq_be_p(host);
-} else {
-data = ldq_le_p(host);
-}
+data = ldq_endian_p(ptw->out_be, host);
  #endif
  } else {
  /* Page tables are in MMIO. */
@@ -860,16 +856,9 @@ static uint64_t arm_casq_ptw(CPUARMState *env, uint64_t 
old_val,
  if (!locked) {
  bql_lock();
  }
-if (ptw->out_be) {
-cur_val = ldq_be_p(host);
-if (cur_val == old_val) {
-stq_be_p(host, new_val);
-}
-} else {
-cur_val = ldq_le_p(host);
-if (cur_val == old_val) {
-stq_le_p(host, new_val);
-}
+cur_val = ldq_endian_p(ptw->out_be, host);
+if (cur_val == old_val) {
+stq_endian_p(ptw->out_be, host, new_val);
  }
  if (!locked) {
  bql_unlock();


Reviewed-by: Pierrick Bouvier 


Re: [PATCH 02/13] hw/virtio/virtio-access: Use the ld/st_endian_p() API

2024-10-01 Thread Pierrick Bouvier

On 9/30/24 00:34, Philippe Mathieu-Daudé wrote:

Refactor to use the recently introduced ld/st_endian_p() API
No logical change intended.

Signed-off-by: Philippe Mathieu-Daudé 
---
  include/hw/virtio/virtio-access.h | 36 ++-
  1 file changed, 6 insertions(+), 30 deletions(-)

diff --git a/include/hw/virtio/virtio-access.h 
b/include/hw/virtio/virtio-access.h
index 07aae69042..b920874be8 100644
--- a/include/hw/virtio/virtio-access.h
+++ b/include/hw/virtio/virtio-access.h
@@ -95,56 +95,32 @@ static inline void virtio_stl_phys(VirtIODevice *vdev, 
hwaddr pa,
  
  static inline void virtio_stw_p(VirtIODevice *vdev, void *ptr, uint16_t v)

  {
-if (virtio_access_is_big_endian(vdev)) {
-stw_be_p(ptr, v);
-} else {
-stw_le_p(ptr, v);
-}
+stw_endian_p(virtio_access_is_big_endian(vdev), ptr, v);
  }
  
  static inline void virtio_stl_p(VirtIODevice *vdev, void *ptr, uint32_t v)

  {
-if (virtio_access_is_big_endian(vdev)) {
-stl_be_p(ptr, v);
-} else {
-stl_le_p(ptr, v);
-}
+stl_endian_p(virtio_access_is_big_endian(vdev), ptr, v);
  }
  
  static inline void virtio_stq_p(VirtIODevice *vdev, void *ptr, uint64_t v)

  {
-if (virtio_access_is_big_endian(vdev)) {
-stq_be_p(ptr, v);
-} else {
-stq_le_p(ptr, v);
-}
+stq_endian_p(virtio_access_is_big_endian(vdev), ptr, v);
  }
  
  static inline int virtio_lduw_p(VirtIODevice *vdev, const void *ptr)

  {
-if (virtio_access_is_big_endian(vdev)) {
-return lduw_be_p(ptr);
-} else {
-return lduw_le_p(ptr);
-}
+return lduw_endian_p(virtio_access_is_big_endian(vdev), ptr);
  }
  
  static inline int virtio_ldl_p(VirtIODevice *vdev, const void *ptr)

  {
-if (virtio_access_is_big_endian(vdev)) {
-return ldl_be_p(ptr);
-} else {
-return ldl_le_p(ptr);
-}
+return ldl_endian_p(virtio_access_is_big_endian(vdev), ptr);
  }
  
  static inline uint64_t virtio_ldq_p(VirtIODevice *vdev, const void *ptr)

  {
-if (virtio_access_is_big_endian(vdev)) {
-return ldq_be_p(ptr);
-} else {
-return ldq_le_p(ptr);
-}
+return ldq_endian_p(virtio_access_is_big_endian(vdev), ptr);
  }
  
  static inline uint16_t virtio_tswap16(VirtIODevice *vdev, uint16_t s)


Reviewed-by: Pierrick Bouvier 


[PATCH v2 1/2] meson: build contrib/plugins with meson

2024-09-25 Thread Pierrick Bouvier
Tried to unify this meson.build with tests/tcg/plugins/meson.build but
the resulting modules are not output in the right directory.

Originally proposed by Anton Kochkov, thank you!

Solves: https://gitlab.com/qemu-project/qemu/-/issues/1710
Signed-off-by: Pierrick Bouvier 
---
 meson.build |  4 
 contrib/plugins/meson.build | 23 +++
 2 files changed, 27 insertions(+)
 create mode 100644 contrib/plugins/meson.build

diff --git a/meson.build b/meson.build
index ceee6b22c8d..b18c2a54ab5 100644
--- a/meson.build
+++ b/meson.build
@@ -3655,6 +3655,10 @@ subdir('accel')
 subdir('plugins')
 subdir('ebpf')
 
+if 'CONFIG_TCG' in config_all_accel
+  subdir('contrib/plugins')
+endif
+
 common_user_inc = []
 
 subdir('common-user')
diff --git a/contrib/plugins/meson.build b/contrib/plugins/meson.build
new file mode 100644
index 000..a0e026d25e2
--- /dev/null
+++ b/contrib/plugins/meson.build
@@ -0,0 +1,23 @@
+t = []
+if get_option('plugins')
+  foreach i : ['cache', 'drcov', 'execlog', 'hotblocks', 'hotpages', 'howvec',
+   'hwprofile', 'ips', 'lockstep', 'stoptrigger']
+if host_os == 'windows'
+  t += shared_module(i, files(i + '.c') + 'win32_linker.c',
+include_directories: '../../include/qemu',
+link_depends: [win32_qemu_plugin_api_lib],
+link_args: ['-Lplugins', '-lqemu_plugin_api'],
+dependencies: glib)
+
+else
+  t += shared_module(i, files(i + '.c'),
+include_directories: '../../include/qemu',
+dependencies: glib)
+endif
+  endforeach
+endif
+if t.length() > 0
+  alias_target('contrib-plugins', t)
+else
+  run_target('contrib-plugins', command: find_program('true'))
+endif
-- 
2.39.5




[PATCH v2 2/2] contrib/plugins: remove Makefile for contrib/plugins

2024-09-25 Thread Pierrick Bouvier
Now replaced by meson build.

Signed-off-by: Pierrick Bouvier 
---
 configure| 18 -
 Makefile | 10 -
 contrib/plugins/Makefile | 87 
 3 files changed, 115 deletions(-)
 delete mode 100644 contrib/plugins/Makefile

diff --git a/configure b/configure
index aa7aae70fa1..934336e5286 100755
--- a/configure
+++ b/configure
@@ -1055,7 +1055,6 @@ if test "$plugins" != "no" && test $host_bits -eq 64; then
 plugins="no"
 else
 plugins=yes
-subdirs="$subdirs contrib/plugins"
 fi
 fi
 
@@ -1555,7 +1554,6 @@ LINKS="$LINKS .gdbinit scripts" # scripts needed by 
relative path in .gdbinit
 LINKS="$LINKS tests/avocado tests/data"
 LINKS="$LINKS tests/qemu-iotests/check tests/qemu-iotests/Makefile"
 LINKS="$LINKS python"
-LINKS="$LINKS contrib/plugins/Makefile "
 for f in $LINKS ; do
 if [ -e "$source_path/$f" ]; then
 symlink "$source_path/$f" "$f"
@@ -1638,22 +1636,6 @@ if test "$default_targets" = "yes"; then
   echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
 fi
 
-# contrib/plugins configuration
-echo "# Automatically generated by configure - do not modify" > 
contrib/plugins/$config_host_mak
-echo "SRC_PATH=$source_path/contrib/plugins" >> 
contrib/plugins/$config_host_mak
-echo "PKG_CONFIG=${pkg_config}" >> contrib/plugins/$config_host_mak
-echo "CC=$cc $CPU_CFLAGS" >> contrib/plugins/$config_host_mak
-echo "CFLAGS=${CFLAGS-$default_cflags} $EXTRA_CFLAGS" >> 
contrib/plugins/$config_host_mak
-if test "$host_os" = windows; then
-  echo "DLLTOOL=$dlltool" >> contrib/plugins/$config_host_mak
-fi
-if test "$host_os" = darwin; then
-  echo "CONFIG_DARWIN=y" >> contrib/plugins/$config_host_mak
-fi
-if test "$host_os" = windows; then
-  echo "CONFIG_WIN32=y" >> contrib/plugins/$config_host_mak
-fi
-
 # tests/tcg configuration
 mkdir -p tests/tcg
 echo "# Automatically generated by configure - do not modify" > 
tests/tcg/$config_host_mak
diff --git a/Makefile b/Makefile
index 917c9a34d1c..b65b0bd41a8 100644
--- a/Makefile
+++ b/Makefile
@@ -187,11 +187,6 @@ SUBDIR_RULES=$(foreach t, all clean distclean, $(addsuffix 
/$(t), $(SUBDIRS)))
 $(SUBDIR_RULES):
$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)" 
TARGET_DIR="$(dir $@)" $(notdir $@),)
 
-ifneq ($(filter contrib/plugins, $(SUBDIRS)),)
-.PHONY: plugins
-plugins: contrib/plugins/all
-endif
-
 .PHONY: recurse-all recurse-clean
 recurse-all: $(addsuffix /all, $(SUBDIRS))
 recurse-clean: $(addsuffix /clean, $(SUBDIRS))
@@ -307,11 +302,6 @@ help:
$(call print-help,cscope,Generate cscope index)
$(call print-help,sparse,Run sparse on the QEMU source)
@echo  ''
-ifneq ($(filter contrib/plugins, $(SUBDIRS)),)
-   @echo  'Plugin targets:'
-   $(call print-help,plugins,Build the example TCG plugins)
-   @echo  ''
-endif
@echo  'Cleaning targets:'
$(call print-help,clean,Remove most generated files but keep the config)
$(call print-help,distclean,Remove all generated files)
diff --git a/contrib/plugins/Makefile b/contrib/plugins/Makefile
deleted file mode 100644
index bbddd4800ff..000
--- a/contrib/plugins/Makefile
+++ /dev/null
@@ -1,87 +0,0 @@
-# -*- Mode: makefile -*-
-#
-# This Makefile example is fairly independent from the main makefile
-# so users can take and adapt it for their build. We only really
-# include config-host.mak so we don't have to repeat probing for
-# programs that the main configure has already done for us.
-#
-
-include config-host.mak
-
-TOP_SRC_PATH = $(SRC_PATH)/../..
-
-VPATH += $(SRC_PATH)
-
-NAMES :=
-NAMES += bbv
-NAMES += execlog
-NAMES += hotblocks
-NAMES += hotpages
-NAMES += howvec
-
-# The lockstep example communicates using unix sockets,
-# and can't be easily made to work on windows.
-ifneq ($(CONFIG_WIN32),y)
-NAMES += lockstep
-endif
-
-NAMES += hwprofile
-NAMES += cache
-NAMES += drcov
-NAMES += ips
-NAMES += stoptrigger
-NAMES += cflow
-
-ifeq ($(CONFIG_WIN32),y)
-SO_SUFFIX := .dll
-LDLIBS += $(shell $(PKG_CONFIG) --libs glib-2.0)
-else
-SO_SUFFIX := .so
-endif
-
-SONAMES := $(addsuffix $(SO_SUFFIX),$(addprefix lib,$(NAMES)))
-
-# The main QEMU uses Glib extensively so it is perfectly fine to use it
-# in plugins (which many example do).
-PLUGIN_CFLAGS := $(shell $(PKG_CONFIG) --cflags glib-2.0)
-PLUGIN_CFLAGS += -fPIC -Wall
-PLUGIN_CFLAGS += -I$(TOP_SRC_PATH)/include/qemu
-
-# Helper that honours V=1 so we get some output when compiling
-quiet-@ = $(if $(V),,@$(if $1,printf "  %-7s %s\n" "

[PATCH v2 0/2] build contrib/plugins using meson

2024-09-25 Thread Pierrick Bouvier
Contrib plugins have been built out of tree so far, thanks to a Makefile.
However, it is quite inconvenient for maintenance, as we may break them,
especially for specific architectures.

First patches are fixing warnings for existing plugins, then we add meson
support, and finally, we remove Makefile for contrib/plugins.

Based on the proposal of Anton Kochkov on associated gitlab issue.
Solves: https://gitlab.com/qemu-project/qemu/-/issues/1710

Plugins are now deactivated by default on 32-bits hosts (since cf2a78), so we
can enable with meson without worrying of warnings when building plugins for 32
bits.

v2
--

- removed warnings fix for 32 bits as they were incorrect. They are not needed
  anymore as plugins are deprecated for 32 bits hosts.

Removed patches for individual plugins.

Pierrick Bouvier (2):
  meson: build contrib/plugins with meson
  contrib/plugins: remove Makefile for contrib/plugins

 configure   | 18 
 Makefile| 10 -
 meson.build |  4 ++
 contrib/plugins/Makefile| 87 -
 contrib/plugins/meson.build | 23 ++
 5 files changed, 27 insertions(+), 115 deletions(-)
 delete mode 100644 contrib/plugins/Makefile
 create mode 100644 contrib/plugins/meson.build

-- 
2.39.5




Re: [PULL 00/44] Functional test conversion, and assert(0) cleanup

2024-09-25 Thread Pierrick Bouvier

On 9/25/24 04:09, Thomas Huth wrote:

The following changes since commit 01dc65a3bc262ab1bec8fe89775e9bbfa627becb:

   Merge tag 'pull-target-arm-20240919' of 
https://git.linaro.org/people/pmaydell/qemu-arm into staging (2024-09-19 
14:15:15 +0100)

are available in the Git repository at:

   https://gitlab.com/thuth/qemu.git tags/pull-request-2024-09-25

for you to fetch changes up to dc05b2628e3913e668590ba66d9c618382d351ae:

   .gitlab-ci.d: Make separate collapsible log sections for build and test 
(2024-09-25 09:42:06 +0200)


* Convert more Avocado tests to the new functional test framework
* Clean up assert() statements, use g_assert_not_reached() when possible
* Improve output of the gitlab CI jobs


Peter Maydell (2):
   .gitlab-ci.d: Split build and test in cross build job templates
   .gitlab-ci.d: Make separate collapsible log sections for build and test

Pierrick Bouvier (34):
   hw/acpi: replace assert(0) with g_assert_not_reached()
   hw/arm: replace assert(0) with g_assert_not_reached()
   hw/net: replace assert(0) with g_assert_not_reached()
   migration: replace assert(0) with g_assert_not_reached()
   qobject: replace assert(0) with g_assert_not_reached()
   target/ppc: replace assert(0) with g_assert_not_reached()
   block: replace assert(false) with g_assert_not_reached()
   hw/hyperv: replace assert(false) with g_assert_not_reached()
   hw/net: replace assert(false) with g_assert_not_reached()
   hw/nvme: replace assert(false) with g_assert_not_reached()
   hw/pci: replace assert(false) with g_assert_not_reached()
   hw/ppc: replace assert(false) with g_assert_not_reached()
   migration: replace assert(false) with g_assert_not_reached()
   target/i386/kvm: replace assert(false) with g_assert_not_reached()
   accel/tcg: remove break after g_assert_not_reached()
   block: remove break after g_assert_not_reached()
   hw/acpi: remove break after g_assert_not_reached()
   hw/net: remove break after g_assert_not_reached()
   hw/scsi: remove break after g_assert_not_reached()
   hw/tpm: remove break after g_assert_not_reached()
   target/arm: remove break after g_assert_not_reached()
   target/riscv: remove break after g_assert_not_reached()
   fpu: remove break after g_assert_not_reached()
   tcg/loongarch64: remove break after g_assert_not_reached()
   include/qemu: remove return after g_assert_not_reached()
   hw/hyperv: remove return after g_assert_not_reached()
   hw/net: remove return after g_assert_not_reached()
   hw/pci: remove return after g_assert_not_reached()
   hw/ppc: remove return after g_assert_not_reached()
   migration: remove return after g_assert_not_reached()
   qobject: remove return after g_assert_not_reached()
   qom: remove return after g_assert_not_reached()
   tests/qtest: remove return after g_assert_not_reached()
   scripts/checkpatch.pl: emit error when using assert(false)

Thomas Huth (8):
   tests/functional/qemu_test: Add a function for launching kernels more 
easily
   tests/functional: Convert the vexpressa9 Avocado test
   tests/functional: Convert the xtensa lx60 Avocado test
   tests/functional: Convert the SPARCStation Avocado test
   tests/functional: Convert the e500 ppc64 Avocado test
   tests/functional: Convert the mac ppc Avocado tests
   tests/functional: Convert the r2d sh4 Avocado test
   tests/functional: Convert the powernv tests from boot_linux_console.py

  MAINTAINERS   |   7 ++
  include/qemu/pmem.h   |   1 -
  accel/tcg/plugin-gen.c|   1 -
  block/qcow2.c |   2 +-
  block/ssh.c   |   1 -
  hw/acpi/aml-build.c   |   3 +-
  hw/arm/highbank.c |   2 +-
  hw/hyperv/hyperv_testdev.c|   7 +-
  hw/hyperv/vmbus.c |  15 ++--
  hw/net/e1000e_core.c  |   4 +-
  hw/net/i82596.c   |   2 +-
  hw/net/igb_core.c |   4 +-
  hw/net/net_rx_pkt.c   |   3 +-
  hw/net/vmxnet3.c  |   1 -
  hw/nvme/ctrl.c|   8 +-
  hw/pci/pci-stub.c |   6 +-
  hw/ppc/ppc.c  |   1 -
  hw/ppc/spapr_events.c |   3 +-
  hw/scsi/virtio-scsi.c |   1 -
  hw/tpm/tpm_spapr.c|   1 -
  migration/dirtyrate.c |   3 +-
  migration/migration-hmp-cmds.c|   2 +-
  migration/postcopy-ram.c  |  21 ++---
  migration/ram.c   |   8 +-
  qobj

Re: [PATCH v2] Add -build-info and -build-info-json CLI arguments

2024-09-25 Thread Pierrick Bouvier

On 9/24/24 05:08, Daniel P. Berrangé wrote:

On Tue, Sep 24, 2024 at 01:02:26PM +0100, Alex Bennée wrote:

Manos Pitsidianakis  writes:


Hello Daniel,

On Tue, 24 Sept 2024 at 11:45, Daniel P. Berrangé  wrote:


On Mon, Sep 23, 2024 at 10:09:32PM +0300, Manos Pitsidianakis wrote:

Hello Daniel,

On Mon, 23 Sep 2024 19:45, "Daniel P. Berrangé"  wrote:

On Mon, Sep 23, 2024 at 09:05:24AM +0300, Manos Pitsidianakis wrote:



ie, look a query-audiodevs to discover what audio baxckends are
built-in, don't look for CONFIG_XXX settings related to audio.
If there are gaps in information we can query from QMP, we should
aim to close those gaps.

IOW, I don't think we should expose this build info info in either
human readable or machine readable format.


QAPI/QMP is not the perspective of this patch, this is for people who use
custom-built (i.e. not from a distro) binaries and want to be able to
identify how it was built. Launching a binary to query stuff is
unnecessarily complex for this task, and the info is not generally
interesting to the API consumers as you said.


Launching QEMU to talk QMP is our defined public API for querying
anything about the capabilities of QEMU. We're worked hard to get
away from providing ad-hoc ways to query QEMU from the command
line and going back to that is not desirable. It may be slightly
more complicated, but not by very much.


Again, this is not a "capabilities discovery" API. It lists the
build-time configuration of the binary. Perhaps we can expose it in a
different way so that people don't end up confused?


I think the problem is however much we might say it's not a capabilities
discovery API it's very existence encourages users to use it as one.

What about a script:

   qemu-get-build-info 

which would launch the binary and query it over QMP? Would that work?


If this is purely a debugging aid, we could make use of ELF notes to
just stick the config-host.h content into the binary. This has precedent
in systemd package notes (https://github.com/systemd/package-notes) and
is more clearly *NOT* an end user CLI option, nor a public API in QMP.

Querying is then

 objdump -j .note.qemu-config-h -s /usrbin/qemu-system-x86_64


With regards,
Daniel


This is neat!
@Manos: it would be convenient to still have a script as Alex mentioned, 
as remembering in which notes the information is hidden might be annoying.


Re: [PATCH 00/10] maintainer updates (testing, gdbstub)

2024-09-25 Thread Pierrick Bouvier

On 9/25/24 10:11, Alex Bennée wrote:

Welcome to the first post KVM forum series. We have:

   - fix from Ilya for microblaze atomics
   - Pierrick's tsan updates
   - I've added my testing and gdbstub trees to MAINTAINERS
   - enabled a very basic aarch64_be-linux-user test
   - fixed the missing gdb XML fails that cause aarch64_be-linux-user to assert
   - finally I've made the mips64el cross compiler bookworm and allow_fail

Alex Bennée (6):
   testing: bump mips64el cross to bookworm and allow to fail
   tests/docker: add NOFETCH env variable for testing
   MAINTAINERS: mention my testing/next tree
   MAINTAINERS: mention my gdbstub/next tree
   config/targets: update aarch64_be-linux-user gdb XML list
   tests/tcg: enable basic testing for aarch64_be-linux-user

Ilya Leoshkevich (1):
   tests/docker: Fix microblaze atomics

Pierrick Bouvier (3):
   meson: hide tsan related warnings
   target/i386: fix build warning (gcc-12 -fsanitize=thread)
   docs/devel: update tsan build documentation

  MAINTAINERS   |  2 ++
  docs/devel/testing/main.rst   | 26 +++---
  configure |  5 +++
  configs/targets/aarch64_be-linux-user.mak |  2 +-
  meson.build   | 10 +-
  target/i386/kvm/kvm.c |  4 +--
  tests/tcg/aarch64_be/hello.c  | 35 +++
  .gitlab-ci.d/container-cross.yml  |  3 ++
  tests/docker/Makefile.include |  5 +--
  .../build-toolchain.sh|  8 +
  .../dockerfiles/debian-mips64el-cross.docker  | 10 +++---
  .../dockerfiles/debian-toolchain.docker   |  7 
  tests/lcitool/refresh |  2 +-
  tests/tcg/Makefile.target |  7 +++-
  tests/tcg/aarch64_be/Makefile.target  | 17 +
  15 files changed, 125 insertions(+), 18 deletions(-)
  create mode 100644 tests/tcg/aarch64_be/hello.c
  create mode 100644 tests/tcg/aarch64_be/Makefile.target



Thanks for pulling tsan changes as part of this series.


Re: [PATCH v2] Add -build-info and -build-info-json CLI arguments

2024-09-23 Thread Pierrick Bouvier

On 9/22/24 23:05, Manos Pitsidianakis wrote:

Add -build-info and -build-info-json CLI arguments for human and machine
readable output of build/compile-time configuration data. The source for
this data is the meson generated config-host.h.

This information is mainly of interest to developers and other folk who
deal with many different builds of QEMU and need a way to properly
differentiate them.

Because there's always the chance someone will want to consume an
interface programmatically, also add a -json option that does the same
but outputs a machine-readable JSON object.

Signed-off-by: Manos Pitsidianakis 
---
Changes in v2:
- Fixed alignment of command and documentation in -h output.
- Link to v1: 
https://lore.kernel.org/r/20240923-feature-build-info-cli-v1-1-e8c42d845...@linaro.org
---
Notes:
Sample output:

$ ./qemu-system-aarch64 -build-info
./qemu-system-aarch64 version 9.1.50 (v9.0.0-3444-g8d988656d8) build information

   configuration key  key value
   -  -
   accept4
   af_vsock
   asan_iface_fiber
   atomic64
   attr
   audio_alsa
   audio_drivers  pa,sndio,oss
   audio_oss
   audio_pa
   audio_pipewire
   audio_sdl
   audio_sndio
   avx2_opt
   avx512bw_opt
   bdrv_ro_whitelist
   bdrv_rw_whitelist
   bindir /usr/local/bin
   blkzoned
   brlapi
   capstone
   clock_adjtime
   close_range
   coroutine_pool
   cpuid_h
   curl
   curses
   dbus_display
   debug_graph_lock
   debug_mutex
   debug_tcg
   dup3
   ebpf
   epoll
   epoll_create1
   eventfd
   fallocate
   fallocate_punch_hole
   fallocate_zero_range
   fdatasync
   fdt
   fiemap
   fsfreeze
   fstrim
   fuse
   fuse_lseek
   gbm
   getauxval
   getcpu
   getrandom
   gettid
   gio
   gnutls
   gnutls_crypto
   gtk
   hexagon_idef_parser
   host_dsosuf.so
   iasl   /bin/iasl
   inotify
   inotify1
   int128
   int128_type
   iovec
   keyutils
   kvm_targetsi386-softmmu,x86_64-softmmu
   l2tpv3
   libdw
   libudev
   linux
   linux_io_uring
   linux_magic_h
   madvise
   malloc_trim
   memalign
   memfd
   opengl
   open_by_handle
   pixman
   plugin
   png
   posix
   posix_fallocate
   posix_madvise
   posix_memalign
   ppoll
   prctl_pr_set_timerslack
   preadv
   prefix /usr/local
   pthread_affinity_np
   pthread_setname_np_w_tid
   qemu_confdir   /usr/local/etc/qemu
   qemu_datadir   /usr/local/share/qemu
   qemu_desktopdir/usr/local/share/applications
   qemu_firmwarepath  /usr/local/share/qemu-firmware
   qemu_helperdir /usr/local/libexec
   qemu_icondir   /usr/local/share/icons
   qemu_localedir /usr/local/share/locale
   qemu_localstatedir /var/local
   qemu_moddir/usr/local/lib/x86_64-linux-gnu/qemu
   qom_cast_debug
   relocatable
   replication
   rtnetlink
   sdl
   seccomp
   seccomp_sysrawrc
   secret_keyring
   selinux
   sendfile
   setns
   signalfd
   slirp
   smbd_command   /usr/sbin/smbd
   splice
   statx
   statx_mnt_id
   syncfs
   sync_file_range
   sysconfdir /usr/local/etc
   sysmacros
   tasn1
   tcg1
   timerfd
   tls_priority   NORMAL
   tpm
   trace_file trace
   trace_log
   usbfs
   usb_libusb
   valgrind_h
   valloc
   vduse_blk_export
   vhost
   vhost_crypto
   vhost_kernel
   vhost_net
   vhost_net_user
   vhost_net_vdpa
   vhost_user
   vhost_user_blk_server
   vhost_vdpa
   virtfs
   vnc
   vnc_jpeg
   vte
   x11
   xen_backend
   xen_ctrl_interface_version 41700
   xkbcommon
   zstd
   blk_zone_rep_capacity
   btrfs_h
   copy_file_range
   drm_h
   fsxattr
   getifaddrs
   host_block_device
   ipproto_mptcp
   mlockall
   openpty
   pty_h
   strchrnul
   struct_stat_st_atim
   system_function
   utmpx
   virgl_d3d_info_ext
   host_x86_641
   qemu_version   9.1.50
   qemu_version_major 9
   qemu_version_micro 50
   qemu_version_minor 1



This is a nice addition, and an easy way to get access to this 
information, including for a qemu you compile yourself.


If there are some concerns about it becoming a "public API" for 
consumers, maybe the option could simply be hidden from help, so only 
qemu devs know it's there.


An alternative could be to distribute a "config file" with qemu, like 
what is available for Linux kernel (cat /boot/config-*). But I really 
prefer something embedded in binary and accessible via option to be honest.



To: qemu-devel@nongnu.org
Cc: "Cleber Rosa" 
Cc: "Daniel P. Berrangé" 
Cc: "John Snow" 
Cc: "Marc-André Lureau" 
Cc: "Paolo Bonzini" 
Cc: "Alex Bennée" 
Cc: "Gustavo Romero" 
Cc: "Peter Maydell" 
Cc: "Philippe Mathieu-Daudé" 
Cc: "Pierrick Bouvier" 
Cc: "

[PATCH v3 18/34] hw/net: remove break after g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 hw/net/net_rx_pkt.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/net/net_rx_pkt.c b/hw/net/net_rx_pkt.c
index 6b9c4c9559d..0ea87344745 100644
--- a/hw/net/net_rx_pkt.c
+++ b/hw/net/net_rx_pkt.c
@@ -376,7 +376,6 @@ net_rx_pkt_calc_rss_hash(struct NetRxPkt *pkt,
 break;
 default:
 g_assert_not_reached();
-break;
 }
 
 net_toeplitz_key_init(&key_data, key);
-- 
2.39.5




[PATCH v3 08/34] hw/hyperv: replace assert(false) with g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Reviewed-by: Maciej S. Szmigiero 
Signed-off-by: Pierrick Bouvier 
---
 hw/hyperv/hyperv_testdev.c |  6 +++---
 hw/hyperv/vmbus.c  | 12 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/hw/hyperv/hyperv_testdev.c b/hw/hyperv/hyperv_testdev.c
index 9a56ddf83fe..ef50e490c4e 100644
--- a/hw/hyperv/hyperv_testdev.c
+++ b/hw/hyperv/hyperv_testdev.c
@@ -88,7 +88,7 @@ static TestSintRoute *sint_route_find(HypervTestDev *dev,
 return sint_route;
 }
 }
-assert(false);
+g_assert_not_reached();
 return NULL;
 }
 
@@ -187,7 +187,7 @@ static void msg_conn_destroy(HypervTestDev *dev, uint8_t 
conn_id)
 return;
 }
 }
-assert(false);
+g_assert_not_reached();
 }
 
 static void evt_conn_handler(EventNotifier *notifier)
@@ -237,7 +237,7 @@ static void evt_conn_destroy(HypervTestDev *dev, uint8_t 
conn_id)
 return;
 }
 }
-assert(false);
+g_assert_not_reached();
 }
 
 static uint64_t hv_test_dev_read(void *opaque, hwaddr addr, unsigned size)
diff --git a/hw/hyperv/vmbus.c b/hw/hyperv/vmbus.c
index 15e0d600c7f..03f415bf226 100644
--- a/hw/hyperv/vmbus.c
+++ b/hw/hyperv/vmbus.c
@@ -1874,7 +1874,7 @@ static void send_create_gpadl(VMBus *vmbus)
 }
 }
 
-assert(false);
+g_assert_not_reached();
 }
 
 static bool complete_create_gpadl(VMBus *vmbus)
@@ -1889,7 +1889,7 @@ static bool complete_create_gpadl(VMBus *vmbus)
 }
 }
 
-assert(false);
+g_assert_not_reached();
 return false;
 }
 
@@ -1931,7 +1931,7 @@ static void send_teardown_gpadl(VMBus *vmbus)
 }
 }
 
-assert(false);
+g_assert_not_reached();
 }
 
 static bool complete_teardown_gpadl(VMBus *vmbus)
@@ -1946,7 +1946,7 @@ static bool complete_teardown_gpadl(VMBus *vmbus)
 }
 }
 
-assert(false);
+g_assert_not_reached();
 return false;
 }
 
@@ -1996,7 +1996,7 @@ static void send_open_channel(VMBus *vmbus)
 }
 }
 
-assert(false);
+g_assert_not_reached();
 }
 
 static bool complete_open_channel(VMBus *vmbus)
@@ -2020,7 +2020,7 @@ static bool complete_open_channel(VMBus *vmbus)
 }
 }
 
-assert(false);
+g_assert_not_reached();
 return false;
 }
 
-- 
2.39.5




[PATCH v3 10/34] hw/nvme: replace assert(false) with g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Klaus Jensen 
Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 hw/nvme/ctrl.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index 9e94a240540..2589e1968ea 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -1816,7 +1816,7 @@ static uint16_t nvme_check_zone_state_for_write(NvmeZone 
*zone)
 trace_pci_nvme_err_zone_is_read_only(zslba);
 return NVME_ZONE_READ_ONLY;
 default:
-assert(false);
+g_assert_not_reached();
 }
 
 return NVME_INTERNAL_DEV_ERROR;
@@ -1870,7 +1870,7 @@ static uint16_t nvme_check_zone_state_for_read(NvmeZone 
*zone)
 trace_pci_nvme_err_zone_is_offline(zone->d.zslba);
 return NVME_ZONE_OFFLINE;
 default:
-assert(false);
+g_assert_not_reached();
 }
 
 return NVME_INTERNAL_DEV_ERROR;
@@ -4654,7 +4654,7 @@ static uint16_t nvme_io_cmd(NvmeCtrl *n, NvmeRequest *req)
 case NVME_CMD_IO_MGMT_SEND:
 return nvme_io_mgmt_send(n, req);
 default:
-assert(false);
+g_assert_not_reached();
 }
 
 return NVME_INVALID_OPCODE | NVME_DNR;
@@ -7205,7 +7205,7 @@ static uint16_t nvme_admin_cmd(NvmeCtrl *n, NvmeRequest 
*req)
 case NVME_ADM_CMD_DIRECTIVE_RECV:
 return nvme_directive_receive(n, req);
 default:
-assert(false);
+g_assert_not_reached();
 }
 
 return NVME_INVALID_OPCODE | NVME_DNR;
-- 
2.39.5




[PATCH v3 19/34] hw/scsi: remove break after g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Reviewed-by: Kevin Wolf 
Signed-off-by: Pierrick Bouvier 
---
 hw/scsi/virtio-scsi.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index 9f02ceea099..6637cfeaf51 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -357,7 +357,6 @@ static void virtio_scsi_do_one_tmf_bh(VirtIOSCSIReq *req)
 
 default:
 g_assert_not_reached();
-break;
 }
 
 out:
-- 
2.39.5




[PATCH v3 17/34] hw/acpi: remove break after g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 hw/acpi/aml-build.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index 006c506a375..34e0ddbde87 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -535,7 +535,6 @@ void aml_append(Aml *parent_ctx, Aml *child)
 break;
 default:
 g_assert_not_reached();
-break;
 }
 build_append_array(parent_ctx->buf, buf);
 build_free_array(buf);
-- 
2.39.5




[PATCH v3 21/34] target/arm: remove break after g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 target/arm/hyp_gdbstub.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/target/arm/hyp_gdbstub.c b/target/arm/hyp_gdbstub.c
index f120d55caab..1e861263b3d 100644
--- a/target/arm/hyp_gdbstub.c
+++ b/target/arm/hyp_gdbstub.c
@@ -158,7 +158,6 @@ int insert_hw_watchpoint(target_ulong addr, target_ulong 
len, int type)
 break;
 default:
 g_assert_not_reached();
-break;
 }
 if (len <= 8) {
 /* we align the address and set the bits in BAS */
-- 
2.39.5




[PATCH v3 13/34] migration: replace assert(false) with g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Fabiano Rosas 
Reviewed-by: Richard Henderson 
Reviewed-by: Peter Xu 
Signed-off-by: Pierrick Bouvier 
---
 migration/dirtyrate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c
index 1d9db812990..c03b13b624f 100644
--- a/migration/dirtyrate.c
+++ b/migration/dirtyrate.c
@@ -228,7 +228,7 @@ static int time_unit_to_power(TimeUnit time_unit)
 case TIME_UNIT_MILLISECOND:
 return -3;
 default:
-assert(false); /* unreachable */
+g_assert_not_reached();
 return 0;
 }
 }
-- 
2.39.5




[PATCH v3 33/34] tests/qtest: remove return after g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 tests/qtest/acpi-utils.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tests/qtest/acpi-utils.c b/tests/qtest/acpi-utils.c
index 673fc975862..9dc24fbe5a0 100644
--- a/tests/qtest/acpi-utils.c
+++ b/tests/qtest/acpi-utils.c
@@ -156,5 +156,4 @@ uint64_t acpi_find_rsdp_address_uefi(QTestState *qts, 
uint64_t start,
 g_usleep(TEST_DELAY);
 }
 g_assert_not_reached();
-return 0;
 }
-- 
2.39.5




[PATCH v3 11/34] hw/pci: replace assert(false) with g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 hw/pci/pci-stub.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/pci/pci-stub.c b/hw/pci/pci-stub.c
index f0508682d2b..c6950e21bd4 100644
--- a/hw/pci/pci-stub.c
+++ b/hw/pci/pci-stub.c
@@ -46,13 +46,13 @@ void hmp_pcie_aer_inject_error(Monitor *mon, const QDict 
*qdict)
 /* kvm-all wants this */
 MSIMessage pci_get_msi_message(PCIDevice *dev, int vector)
 {
-g_assert(false);
+g_assert_not_reached();
 return (MSIMessage){};
 }
 
 uint16_t pci_requester_id(PCIDevice *dev)
 {
-g_assert(false);
+g_assert_not_reached();
 return 0;
 }
 
-- 
2.39.5




[PATCH v3 22/34] target/riscv: remove break after g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Reviewed-by: Daniel Henrique Barboza 
Signed-off-by: Pierrick Bouvier 
---
 target/riscv/monitor.c  | 1 -
 target/riscv/insn_trans/trans_rvv.c.inc | 2 --
 2 files changed, 3 deletions(-)

diff --git a/target/riscv/monitor.c b/target/riscv/monitor.c
index f5b1ffe6c3e..15ea4e9 100644
--- a/target/riscv/monitor.c
+++ b/target/riscv/monitor.c
@@ -184,7 +184,6 @@ static void mem_info_svxx(Monitor *mon, CPUArchState *env)
 break;
 default:
 g_assert_not_reached();
-break;
 }
 
 /* calculate virtual address bits */
diff --git a/target/riscv/insn_trans/trans_rvv.c.inc 
b/target/riscv/insn_trans/trans_rvv.c.inc
index 3a3896ba06c..f8928c44a8b 100644
--- a/target/riscv/insn_trans/trans_rvv.c.inc
+++ b/target/riscv/insn_trans/trans_rvv.c.inc
@@ -3172,7 +3172,6 @@ static void load_element(TCGv_i64 dest, TCGv_ptr base,
 break;
 default:
 g_assert_not_reached();
-break;
 }
 }
 
@@ -3257,7 +3256,6 @@ static void store_element(TCGv_i64 val, TCGv_ptr base,
 break;
 default:
 g_assert_not_reached();
-break;
 }
 }
 
-- 
2.39.5




[PATCH v3 06/34] target/ppc: replace assert(0) with g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Reviewed-by: Daniel Henrique Barboza 
Signed-off-by: Pierrick Bouvier 
---
 target/ppc/dfp_helper.c | 8 
 target/ppc/mmu_helper.c | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/target/ppc/dfp_helper.c b/target/ppc/dfp_helper.c
index 5967ea07a92..ecc3f793267 100644
--- a/target/ppc/dfp_helper.c
+++ b/target/ppc/dfp_helper.c
@@ -249,7 +249,7 @@ static void dfp_set_FPRF_from_FRT_with_context(struct 
PPC_DFP *dfp,
 fprf = 0x05;
 break;
 default:
-assert(0); /* should never get here */
+g_assert_not_reached();
 }
 dfp->env->fpscr &= ~FP_FPRF;
 dfp->env->fpscr |= (fprf << FPSCR_FPRF);
@@ -1243,7 +1243,7 @@ void helper_##op(CPUPPCState *env, ppc_fprp_t *t, 
ppc_fprp_t *b) \
 } else if (decNumberIsQNaN(&dfp.b)) {  \
 vt.VsrD(1) = -2;   \
 } else {   \
-assert(0); \
+g_assert_not_reached();\
 }  \
 set_dfp64(t, &vt); \
 } else {   \
@@ -1252,7 +1252,7 @@ void helper_##op(CPUPPCState *env, ppc_fprp_t *t, 
ppc_fprp_t *b) \
 } else if ((size) == 128) {\
 vt.VsrD(1) = dfp.b.exponent + 6176;\
 } else {   \
-assert(0); \
+g_assert_not_reached();\
 }  \
 set_dfp64(t, &vt); \
 }  \
@@ -1300,7 +1300,7 @@ void helper_##op(CPUPPCState *env, ppc_fprp_t *t, 
ppc_fprp_t *a,  \
 raw_inf = 0x1e000;\
 bias = 6176;  \
 } else {  \
-assert(0);\
+g_assert_not_reached();   \
 } \
   \
 if (unlikely((exp < 0) || (exp > max_exp))) { \
diff --git a/target/ppc/mmu_helper.c b/target/ppc/mmu_helper.c
index b0a0676beba..b167b37e0ab 100644
--- a/target/ppc/mmu_helper.c
+++ b/target/ppc/mmu_helper.c
@@ -316,7 +316,7 @@ void ppc_tlb_invalidate_one(CPUPPCState *env, target_ulong 
addr)
 break;
 default:
 /* Should never reach here with other MMU models */
-assert(0);
+g_assert_not_reached();
 }
 #else
 ppc_tlb_invalidate_all(env);
-- 
2.39.5




[PATCH v3 12/34] hw/ppc: replace assert(false) with g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Reviewed-by: Daniel Henrique Barboza 
Signed-off-by: Pierrick Bouvier 
---
 hw/ppc/spapr_events.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c
index cb05874..38ac1cb7866 100644
--- a/hw/ppc/spapr_events.c
+++ b/hw/ppc/spapr_events.c
@@ -645,7 +645,7 @@ static void spapr_hotplug_req_event(uint8_t hp_id, uint8_t 
hp_action,
 /* we shouldn't be signaling hotplug events for resources
  * that don't support them
  */
-g_assert(false);
+g_assert_not_reached();
 return;
 }
 
-- 
2.39.5




[PATCH v3 29/34] hw/ppc: remove return after g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Cédric Le Goater 
Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 hw/ppc/ppc.c  | 1 -
 hw/ppc/spapr_events.c | 1 -
 2 files changed, 2 deletions(-)

diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c
index e6fa5580c01..fde46194122 100644
--- a/hw/ppc/ppc.c
+++ b/hw/ppc/ppc.c
@@ -267,7 +267,6 @@ static void power9_set_irq(void *opaque, int pin, int level)
 break;
 default:
 g_assert_not_reached();
-return;
 }
 }
 
diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c
index 38ac1cb7866..4dbf8e2e2ef 100644
--- a/hw/ppc/spapr_events.c
+++ b/hw/ppc/spapr_events.c
@@ -646,7 +646,6 @@ static void spapr_hotplug_req_event(uint8_t hp_id, uint8_t 
hp_action,
  * that don't support them
  */
 g_assert_not_reached();
-return;
 }
 
 if (hp_id == RTAS_LOG_V6_HP_ID_DRC_COUNT) {
-- 
2.39.5




[PATCH v3 32/34] qom: remove return after g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 qom/object.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/qom/object.c b/qom/object.c
index 157a45c5f8b..28c5b66eab5 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -2079,7 +2079,6 @@ const char *object_get_canonical_path_component(const 
Object *obj)
 
 /* obj had a parent but was not a child, should never happen */
 g_assert_not_reached();
-return NULL;
 }
 
 char *object_get_canonical_path(const Object *obj)
-- 
2.39.5




[PATCH v3 25/34] include/qemu: remove return after g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 include/qemu/pmem.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/qemu/pmem.h b/include/qemu/pmem.h
index d2d7ad085cc..e12a67ba2c0 100644
--- a/include/qemu/pmem.h
+++ b/include/qemu/pmem.h
@@ -22,7 +22,6 @@ pmem_memcpy_persist(void *pmemdest, const void *src, size_t 
len)
 /* If 'pmem' option is 'on', we should always have libpmem support,
or qemu will report a error and exit, never come here. */
 g_assert_not_reached();
-return NULL;
 }
 
 static inline void
-- 
2.39.5




[PATCH v3 23/34] fpu: remove break after g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 fpu/softfloat-parts.c.inc | 2 --
 1 file changed, 2 deletions(-)

diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
index a44649f4f4a..cc6e06b9761 100644
--- a/fpu/softfloat-parts.c.inc
+++ b/fpu/softfloat-parts.c.inc
@@ -1373,7 +1373,6 @@ static FloatPartsN *partsN(minmax)(FloatPartsN *a, 
FloatPartsN *b,
 break;
 default:
 g_assert_not_reached();
-break;
 }
 switch (b->cls) {
 case float_class_normal:
@@ -1386,7 +1385,6 @@ static FloatPartsN *partsN(minmax)(FloatPartsN *a, 
FloatPartsN *b,
 break;
 default:
 g_assert_not_reached();
-break;
 }
 }
 
-- 
2.39.5




[PATCH v3 03/34] hw/net: replace assert(0) with g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 hw/net/i82596.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/net/i82596.c b/hw/net/i82596.c
index 6cc8292a65a..cd416a00ffa 100644
--- a/hw/net/i82596.c
+++ b/hw/net/i82596.c
@@ -282,7 +282,7 @@ static void command_loop(I82596State *s)
 case CmdDump:
 case CmdDiagnose:
 printf("FIXME Command %d !!\n", cmd & 7);
-assert(0);
+g_assert_not_reached();
 }
 
 /* update status */
-- 
2.39.5




[PATCH v3 24/34] tcg/loongarch64: remove break after g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 tcg/loongarch64/tcg-target.c.inc | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc
index 5b7ed5c176b..973601aec36 100644
--- a/tcg/loongarch64/tcg-target.c.inc
+++ b/tcg/loongarch64/tcg-target.c.inc
@@ -650,7 +650,6 @@ static int tcg_out_setcond_int(TCGContext *s, TCGCond cond, 
TCGReg ret,
 
 default:
 g_assert_not_reached();
-break;
 }
 
 return ret | flags;
-- 
2.39.5




[PATCH v3 31/34] qobject: remove return after g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 qobject/qnum.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/qobject/qnum.c b/qobject/qnum.c
index 2138b563a9f..dd8ea495655 100644
--- a/qobject/qnum.c
+++ b/qobject/qnum.c
@@ -86,7 +86,6 @@ bool qnum_get_try_int(const QNum *qn, int64_t *val)
 }
 
 g_assert_not_reached();
-return false;
 }
 
 /**
@@ -124,7 +123,6 @@ bool qnum_get_try_uint(const QNum *qn, uint64_t *val)
 }
 
 g_assert_not_reached();
-return false;
 }
 
 /**
@@ -157,7 +155,6 @@ double qnum_get_double(QNum *qn)
 }
 
 g_assert_not_reached();
-return 0.0;
 }
 
 char *qnum_to_string(QNum *qn)
@@ -173,7 +170,6 @@ char *qnum_to_string(QNum *qn)
 }
 
 g_assert_not_reached();
-return NULL;
 }
 
 /**
-- 
2.39.5




[PATCH v3 34/34] scripts/checkpatch.pl: emit error when using assert(false)

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 scripts/checkpatch.pl | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 65b6f46f905..fa9c12230eb 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3102,6 +3102,9 @@ sub process {
if ($line =~ /\b(g_)?assert\(0\)/) {
ERROR("use g_assert_not_reached() instead of 
assert(0)\n" . $herecurr);
}
+   if ($line =~ /\b(g_)?assert\(false\)/) {
+   ERROR("use g_assert_not_reached() instead of 
assert(false)\n" . $herecurr);
+   }
if ($line =~ /\bstrerrorname_np\(/) {
ERROR("use strerror() instead of strerrorname_np()\n" . 
$herecurr);
}
-- 
2.39.5




[PATCH v3 30/34] migration: remove return after g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Signed-off-by: Pierrick Bouvier 
---
 migration/dirtyrate.c| 1 -
 migration/postcopy-ram.c | 7 ---
 migration/ram.c  | 2 --
 3 files changed, 10 deletions(-)

diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c
index c03b13b624f..5478d58de36 100644
--- a/migration/dirtyrate.c
+++ b/migration/dirtyrate.c
@@ -229,7 +229,6 @@ static int time_unit_to_power(TimeUnit time_unit)
 return -3;
 default:
 g_assert_not_reached();
-return 0;
 }
 }
 
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index f431bbc0d4f..0fe9d83d44a 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -1412,40 +1412,34 @@ int postcopy_ram_incoming_init(MigrationIncomingState 
*mis)
 int postcopy_ram_incoming_cleanup(MigrationIncomingState *mis)
 {
 g_assert_not_reached();
-return -1;
 }
 
 int postcopy_ram_prepare_discard(MigrationIncomingState *mis)
 {
 g_assert_not_reached();
-return -1;
 }
 
 int postcopy_request_shared_page(struct PostCopyFD *pcfd, RAMBlock *rb,
  uint64_t client_addr, uint64_t rb_offset)
 {
 g_assert_not_reached();
-return -1;
 }
 
 int postcopy_ram_incoming_setup(MigrationIncomingState *mis)
 {
 g_assert_not_reached();
-return -1;
 }
 
 int postcopy_place_page(MigrationIncomingState *mis, void *host, void *from,
 RAMBlock *rb)
 {
 g_assert_not_reached();
-return -1;
 }
 
 int postcopy_place_page_zero(MigrationIncomingState *mis, void *host,
 RAMBlock *rb)
 {
 g_assert_not_reached();
-return -1;
 }
 
 int postcopy_wake_shared(struct PostCopyFD *pcfd,
@@ -1453,7 +1447,6 @@ int postcopy_wake_shared(struct PostCopyFD *pcfd,
  RAMBlock *rb)
 {
 g_assert_not_reached();
-return -1;
 }
 #endif
 
diff --git a/migration/ram.c b/migration/ram.c
index 0aa5d347439..81eda2736a9 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1766,13 +1766,11 @@ bool ram_write_tracking_available(void)
 bool ram_write_tracking_compatible(void)
 {
 g_assert_not_reached();
-return false;
 }
 
 int ram_write_tracking_start(void)
 {
 g_assert_not_reached();
-return -1;
 }
 
 void ram_write_tracking_stop(void)
-- 
2.39.5




[PATCH v3 16/34] block: remove break after g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Reviewed-by: Richard W.M. Jones 
Reviewed-by: Kevin Wolf 
Signed-off-by: Pierrick Bouvier 
---
 block/ssh.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/block/ssh.c b/block/ssh.c
index 27d582e0e3d..871e1d47534 100644
--- a/block/ssh.c
+++ b/block/ssh.c
@@ -474,7 +474,6 @@ static int check_host_key(BDRVSSHState *s, SshHostKeyCheck 
*hkc, Error **errp)
errp);
 }
 g_assert_not_reached();
-break;
 case SSH_HOST_KEY_CHECK_MODE_KNOWN_HOSTS:
 return check_host_key_knownhosts(s, errp);
 default:
-- 
2.39.5




[PATCH v3 20/34] hw/tpm: remove break after g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 hw/tpm/tpm_spapr.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/tpm/tpm_spapr.c b/hw/tpm/tpm_spapr.c
index e084e987e6e..5f7a0dfc617 100644
--- a/hw/tpm/tpm_spapr.c
+++ b/hw/tpm/tpm_spapr.c
@@ -206,7 +206,6 @@ static int tpm_spapr_do_crq(struct SpaprVioDevice *dev, 
uint8_t *crq_data)
 break;
 default:
 g_assert_not_reached();
-break;
 }
 trace_tpm_spapr_do_crq_get_version(be32_to_cpu(local_crq.data));
 spapr_tpm_send_crq(dev, &local_crq);
-- 
2.39.5




[PATCH v3 27/34] hw/net: remove return after g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 hw/net/e1000e_core.c | 2 --
 hw/net/igb_core.c| 2 --
 hw/net/vmxnet3.c | 1 -
 3 files changed, 5 deletions(-)

diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c
index 248381f9766..2e4c50ddbaf 100644
--- a/hw/net/e1000e_core.c
+++ b/hw/net/e1000e_core.c
@@ -562,7 +562,6 @@ e1000e_rss_calc_hash(E1000ECore *core,
 break;
 default:
 g_assert_not_reached();
-return 0;
 }
 
 return net_rx_pkt_calc_rss_hash(pkt, type, (uint8_t *) &core->mac[RSSRK]);
@@ -841,7 +840,6 @@ e1000e_ring_free_descr_num(E1000ECore *core, const 
E1000ERingInfo *r)
 }
 
 g_assert_not_reached();
-return 0;
 }
 
 static inline bool
diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c
index 6be61407715..5dffa12c64b 100644
--- a/hw/net/igb_core.c
+++ b/hw/net/igb_core.c
@@ -398,7 +398,6 @@ igb_rss_calc_hash(IGBCore *core, struct NetRxPkt *pkt, 
E1000E_RSSInfo *info)
 break;
 default:
 g_assert_not_reached();
-return 0;
 }
 
 return net_rx_pkt_calc_rss_hash(pkt, type, (uint8_t *) &core->mac[RSSRK]);
@@ -747,7 +746,6 @@ igb_ring_free_descr_num(IGBCore *core, const E1000ERingInfo 
*r)
 }
 
 g_assert_not_reached();
-return 0;
 }
 
 static inline bool
diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index bb8583c7aba..8aa8c462283 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -456,7 +456,6 @@ vmxnet3_setup_tx_offloads(VMXNET3State *s)
 
 default:
 g_assert_not_reached();
-return false;
 }
 
 return true;
-- 
2.39.5




[PATCH v3 01/34] hw/acpi: replace assert(0) with g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 hw/acpi/aml-build.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index 6d4517cfbe3..006c506a375 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -534,7 +534,7 @@ void aml_append(Aml *parent_ctx, Aml *child)
 case AML_NO_OPCODE:
 break;
 default:
-assert(0);
+g_assert_not_reached();
 break;
 }
 build_append_array(parent_ctx->buf, buf);
-- 
2.39.5




[PATCH v3 15/34] accel/tcg: remove break after g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 accel/tcg/plugin-gen.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c
index ec89a085b43..2ee4c22befd 100644
--- a/accel/tcg/plugin-gen.c
+++ b/accel/tcg/plugin-gen.c
@@ -251,7 +251,6 @@ static void inject_mem_cb(struct qemu_plugin_dyn_cb *cb,
 break;
 default:
 g_assert_not_reached();
-break;
 }
 }
 
-- 
2.39.5




[PATCH v3 02/34] hw/arm: replace assert(0) with g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 hw/arm/highbank.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c
index 6915eb63c75..f103921d495 100644
--- a/hw/arm/highbank.c
+++ b/hw/arm/highbank.c
@@ -199,7 +199,7 @@ static void calxeda_init(MachineState *machine, enum 
cxmachines machine_id)
 machine->cpu_type = ARM_CPU_TYPE_NAME("cortex-a15");
 break;
 default:
-assert(0);
+g_assert_not_reached();
 }
 
 for (n = 0; n < smp_cpus; n++) {
-- 
2.39.5




[PATCH v3 26/34] hw/hyperv: remove return after g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 hw/hyperv/hyperv_testdev.c | 1 -
 hw/hyperv/vmbus.c  | 3 ---
 2 files changed, 4 deletions(-)

diff --git a/hw/hyperv/hyperv_testdev.c b/hw/hyperv/hyperv_testdev.c
index ef50e490c4e..a630ca70476 100644
--- a/hw/hyperv/hyperv_testdev.c
+++ b/hw/hyperv/hyperv_testdev.c
@@ -89,7 +89,6 @@ static TestSintRoute *sint_route_find(HypervTestDev *dev,
 }
 }
 g_assert_not_reached();
-return NULL;
 }
 
 static void sint_route_destroy(HypervTestDev *dev,
diff --git a/hw/hyperv/vmbus.c b/hw/hyperv/vmbus.c
index 03f415bf226..b36bd3d67d5 100644
--- a/hw/hyperv/vmbus.c
+++ b/hw/hyperv/vmbus.c
@@ -1890,7 +1890,6 @@ static bool complete_create_gpadl(VMBus *vmbus)
 }
 
 g_assert_not_reached();
-return false;
 }
 
 static void handle_gpadl_teardown(VMBus *vmbus,
@@ -1947,7 +1946,6 @@ static bool complete_teardown_gpadl(VMBus *vmbus)
 }
 
 g_assert_not_reached();
-return false;
 }
 
 static void handle_open_channel(VMBus *vmbus, vmbus_message_open_channel *msg,
@@ -2021,7 +2019,6 @@ static bool complete_open_channel(VMBus *vmbus)
 }
 
 g_assert_not_reached();
-return false;
 }
 
 static void vdev_reset_on_close(VMBusDevice *vdev)
-- 
2.39.5




[PATCH v3 14/34] target/i386/kvm: replace assert(false) with g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Philippe Mathieu-Daudé 
Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 target/i386/kvm/kvm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index ada581c5d6e..c8056ef83d7 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -5771,7 +5771,7 @@ static int kvm_handle_rdmsr(X86CPU *cpu, struct kvm_run 
*run)
 }
 }
 
-assert(false);
+g_assert_not_reached();
 }
 
 static int kvm_handle_wrmsr(X86CPU *cpu, struct kvm_run *run)
@@ -5790,7 +5790,7 @@ static int kvm_handle_wrmsr(X86CPU *cpu, struct kvm_run 
*run)
 }
 }
 
-assert(false);
+g_assert_not_reached();
 }
 
 static bool has_sgx_provisioning;
-- 
2.39.5




[PATCH v3 04/34] migration: replace assert(0) with g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Fabiano Rosas 
Reviewed-by: Peter Xu 
Signed-off-by: Pierrick Bouvier 
---
 migration/migration-hmp-cmds.c |  2 +-
 migration/postcopy-ram.c   | 14 +++---
 migration/ram.c|  6 +++---
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
index 28165cfc9ed..20d1a6e2194 100644
--- a/migration/migration-hmp-cmds.c
+++ b/migration/migration-hmp-cmds.c
@@ -640,7 +640,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict 
*qdict)
 visit_type_bool(v, param, &p->direct_io, &err);
 break;
 default:
-assert(0);
+g_assert_not_reached();
 }
 
 if (err) {
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index 1c374b7ea1e..f431bbc0d4f 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -1411,40 +1411,40 @@ int postcopy_ram_incoming_init(MigrationIncomingState 
*mis)
 
 int postcopy_ram_incoming_cleanup(MigrationIncomingState *mis)
 {
-assert(0);
+g_assert_not_reached();
 return -1;
 }
 
 int postcopy_ram_prepare_discard(MigrationIncomingState *mis)
 {
-assert(0);
+g_assert_not_reached();
 return -1;
 }
 
 int postcopy_request_shared_page(struct PostCopyFD *pcfd, RAMBlock *rb,
  uint64_t client_addr, uint64_t rb_offset)
 {
-assert(0);
+g_assert_not_reached();
 return -1;
 }
 
 int postcopy_ram_incoming_setup(MigrationIncomingState *mis)
 {
-assert(0);
+g_assert_not_reached();
 return -1;
 }
 
 int postcopy_place_page(MigrationIncomingState *mis, void *host, void *from,
 RAMBlock *rb)
 {
-assert(0);
+g_assert_not_reached();
 return -1;
 }
 
 int postcopy_place_page_zero(MigrationIncomingState *mis, void *host,
 RAMBlock *rb)
 {
-assert(0);
+g_assert_not_reached();
 return -1;
 }
 
@@ -1452,7 +1452,7 @@ int postcopy_wake_shared(struct PostCopyFD *pcfd,
  uint64_t client_addr,
  RAMBlock *rb)
 {
-assert(0);
+g_assert_not_reached();
 return -1;
 }
 #endif
diff --git a/migration/ram.c b/migration/ram.c
index 67ca3d5d51a..0aa5d347439 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1765,19 +1765,19 @@ bool ram_write_tracking_available(void)
 
 bool ram_write_tracking_compatible(void)
 {
-assert(0);
+g_assert_not_reached();
 return false;
 }
 
 int ram_write_tracking_start(void)
 {
-assert(0);
+g_assert_not_reached();
 return -1;
 }
 
 void ram_write_tracking_stop(void)
 {
-assert(0);
+g_assert_not_reached();
 }
 #endif /* defined(__linux__) */
 
-- 
2.39.5




[PATCH v3 09/34] hw/net: replace assert(false) with g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 hw/net/e1000e_core.c | 2 +-
 hw/net/igb_core.c| 2 +-
 hw/net/net_rx_pkt.c  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c
index 3ae2a184d5d..248381f9766 100644
--- a/hw/net/e1000e_core.c
+++ b/hw/net/e1000e_core.c
@@ -561,7 +561,7 @@ e1000e_rss_calc_hash(E1000ECore *core,
 type = NetPktRssIpV6Ex;
 break;
 default:
-assert(false);
+g_assert_not_reached();
 return 0;
 }
 
diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c
index bcd5f6cd9cd..6be61407715 100644
--- a/hw/net/igb_core.c
+++ b/hw/net/igb_core.c
@@ -397,7 +397,7 @@ igb_rss_calc_hash(IGBCore *core, struct NetRxPkt *pkt, 
E1000E_RSSInfo *info)
 type = NetPktRssIpV6Udp;
 break;
 default:
-assert(false);
+g_assert_not_reached();
 return 0;
 }
 
diff --git a/hw/net/net_rx_pkt.c b/hw/net/net_rx_pkt.c
index 32e5f3f9cf7..6b9c4c9559d 100644
--- a/hw/net/net_rx_pkt.c
+++ b/hw/net/net_rx_pkt.c
@@ -375,7 +375,7 @@ net_rx_pkt_calc_rss_hash(struct NetRxPkt *pkt,
 _net_rx_rss_prepare_udp(&rss_input[0], pkt, &rss_length);
 break;
 default:
-assert(false);
+g_assert_not_reached();
 break;
 }
 
-- 
2.39.5




[PATCH v3 28/34] hw/pci: remove return after g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 hw/pci/pci-stub.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/hw/pci/pci-stub.c b/hw/pci/pci-stub.c
index c6950e21bd4..3397d0c82ea 100644
--- a/hw/pci/pci-stub.c
+++ b/hw/pci/pci-stub.c
@@ -47,13 +47,11 @@ void hmp_pcie_aer_inject_error(Monitor *mon, const QDict 
*qdict)
 MSIMessage pci_get_msi_message(PCIDevice *dev, int vector)
 {
 g_assert_not_reached();
-return (MSIMessage){};
 }
 
 uint16_t pci_requester_id(PCIDevice *dev)
 {
 g_assert_not_reached();
-return 0;
 }
 
 /* Required by ahci.c */
-- 
2.39.5




[PATCH v3 07/34] block: replace assert(false) with g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Reviewed-by: Kevin Wolf 
Signed-off-by: Pierrick Bouvier 
---
 block/qcow2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/qcow2.c b/block/qcow2.c
index dd359d241b7..803ca73a2ff 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -5299,7 +5299,7 @@ qcow2_get_specific_info(BlockDriverState *bs, Error 
**errp)
 } else {
 /* if this assertion fails, this probably means a new version was
  * added without having it covered here */
-assert(false);
+g_assert_not_reached();
 }
 
 if (encrypt_info) {
-- 
2.39.5




[PATCH v3 00/34] Use g_assert_not_reached instead of (g_)assert(0, false)

2024-09-18 Thread Pierrick Bouvier
This series cleans up all usages of assert/g_assert who are supposed to stop
execution of QEMU. We replace those by g_assert_not_reached().
It was suggested recently when cleaning codebase to build QEMU with gcc
and tsan: 
https://lore.kernel.org/qemu-devel/54bb02a6-1b12-460a-97f6-3f478ef76...@linaro.org/.

In more, cleanup useless break and return after g_assert_not_reached();

And finally, ensure with scripts/checkpatch.pl that we don't reintroduce
(g_)assert(false) in the future.

New commits (removing return) need review.

Tested that it build warning free with gcc and clang.

If a maintainer could pull the whole series, this would be much more easier than
integrating various parts of it in different subsystems. Thanks!

v3
- drop changes on .promela files
- some changes were already merged

v2
- align backslashes for some changes
- add summary in all commits message
- remove redundant comment

v1
https://lore.kernel.org/qemu-devel/20240910221606.1817478-1-pierrick.bouv...@linaro.org/T/#t

Pierrick Bouvier (34):
  hw/acpi: replace assert(0) with g_assert_not_reached()
  hw/arm: replace assert(0) with g_assert_not_reached()
  hw/net: replace assert(0) with g_assert_not_reached()
  migration: replace assert(0) with g_assert_not_reached()
  qobject: replace assert(0) with g_assert_not_reached()
  target/ppc: replace assert(0) with g_assert_not_reached()
  block: replace assert(false) with g_assert_not_reached()
  hw/hyperv: replace assert(false) with g_assert_not_reached()
  hw/net: replace assert(false) with g_assert_not_reached()
  hw/nvme: replace assert(false) with g_assert_not_reached()
  hw/pci: replace assert(false) with g_assert_not_reached()
  hw/ppc: replace assert(false) with g_assert_not_reached()
  migration: replace assert(false) with g_assert_not_reached()
  target/i386/kvm: replace assert(false) with g_assert_not_reached()
  accel/tcg: remove break after g_assert_not_reached()
  block: remove break after g_assert_not_reached()
  hw/acpi: remove break after g_assert_not_reached()
  hw/net: remove break after g_assert_not_reached()
  hw/scsi: remove break after g_assert_not_reached()
  hw/tpm: remove break after g_assert_not_reached()
  target/arm: remove break after g_assert_not_reached()
  target/riscv: remove break after g_assert_not_reached()
  fpu: remove break after g_assert_not_reached()
  tcg/loongarch64: remove break after g_assert_not_reached()
  include/qemu: remove return after g_assert_not_reached()
  hw/hyperv: remove return after g_assert_not_reached()
  hw/net: remove return after g_assert_not_reached()
  hw/pci: remove return after g_assert_not_reached()
  hw/ppc: remove return after g_assert_not_reached()
  migration: remove return after g_assert_not_reached()
  qobject: remove return after g_assert_not_reached()
  qom: remove return after g_assert_not_reached()
  tests/qtest: remove return after g_assert_not_reached()
  scripts/checkpatch.pl: emit error when using assert(false)

 include/qemu/pmem.h |  1 -
 accel/tcg/plugin-gen.c  |  1 -
 block/qcow2.c   |  2 +-
 block/ssh.c |  1 -
 hw/acpi/aml-build.c |  3 +--
 hw/arm/highbank.c   |  2 +-
 hw/hyperv/hyperv_testdev.c  |  7 +++
 hw/hyperv/vmbus.c   | 15 ++-
 hw/net/e1000e_core.c|  4 +---
 hw/net/i82596.c |  2 +-
 hw/net/igb_core.c   |  4 +---
 hw/net/net_rx_pkt.c |  3 +--
 hw/net/vmxnet3.c|  1 -
 hw/nvme/ctrl.c  |  8 
 hw/pci/pci-stub.c   |  6 ++
 hw/ppc/ppc.c|  1 -
 hw/ppc/spapr_events.c   |  3 +--
 hw/scsi/virtio-scsi.c   |  1 -
 hw/tpm/tpm_spapr.c  |  1 -
 migration/dirtyrate.c   |  3 +--
 migration/migration-hmp-cmds.c  |  2 +-
 migration/postcopy-ram.c| 21 +++--
 migration/ram.c |  8 +++-
 qobject/qlit.c  |  2 +-
 qobject/qnum.c  | 12 
 qom/object.c|  1 -
 target/arm/hyp_gdbstub.c|  1 -
 target/i386/kvm/kvm.c   |  4 ++--
 target/ppc/dfp_helper.c |  8 
 target/ppc/mmu_helper.c |  2 +-
 target/riscv/monitor.c  |  1 -
 tests/qtest/acpi-utils.c|  1 -
 fpu/softfloat-parts.c.inc   |  2 --
 target/riscv/insn_trans/trans_rvv.c.inc |  2 --
 tcg/loongarch64/tcg-target.c.inc|  1 -
 scripts/checkpatch.pl   |  3 +++
 36 files changed, 50 insertions(+), 90 deletions(-)

-- 
2.39.5




[PATCH v3 05/34] qobject: replace assert(0) with g_assert_not_reached()

2024-09-18 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Reviewed-by: Kevin Wolf 
Signed-off-by: Pierrick Bouvier 
---
 qobject/qlit.c | 2 +-
 qobject/qnum.c | 8 
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/qobject/qlit.c b/qobject/qlit.c
index be8332136c2..a62865b6423 100644
--- a/qobject/qlit.c
+++ b/qobject/qlit.c
@@ -118,7 +118,7 @@ QObject *qobject_from_qlit(const QLitObject *qlit)
 case QTYPE_QBOOL:
 return QOBJECT(qbool_from_bool(qlit->value.qbool));
 default:
-assert(0);
+g_assert_not_reached();
 }
 
 return NULL;
diff --git a/qobject/qnum.c b/qobject/qnum.c
index 2bbeaedc7b4..2138b563a9f 100644
--- a/qobject/qnum.c
+++ b/qobject/qnum.c
@@ -85,7 +85,7 @@ bool qnum_get_try_int(const QNum *qn, int64_t *val)
 return false;
 }
 
-assert(0);
+g_assert_not_reached();
 return false;
 }
 
@@ -123,7 +123,7 @@ bool qnum_get_try_uint(const QNum *qn, uint64_t *val)
 return false;
 }
 
-assert(0);
+g_assert_not_reached();
 return false;
 }
 
@@ -156,7 +156,7 @@ double qnum_get_double(QNum *qn)
 return qn->u.dbl;
 }
 
-assert(0);
+g_assert_not_reached();
 return 0.0;
 }
 
@@ -172,7 +172,7 @@ char *qnum_to_string(QNum *qn)
 return g_strdup_printf("%.17g", qn->u.dbl);
 }
 
-assert(0);
+g_assert_not_reached();
 return NULL;
 }
 
-- 
2.39.5




Re: [PATCH v2 13/18] tests/tcg: add a system test to check memory instrumentation

2024-09-18 Thread Pierrick Bouvier
+seen_all = False
+
+with open(path, 'r') as f:
+next(f)  # Skip the header
+for line in f:
+
+if line.startswith("Region Base"):
+continue
+
+parts = line.strip().split(', ')
+if len(parts) != 4:
+continue
+
+region_base = int(parts[0], 16)
+reads = int(parts[1])
+writes = int(parts[2])
+
+if start <= region_base < end: # Checking if within range
+total_reads += reads
+total_writes += writes
+seen_all = parts[3] == "true"
+
+return total_reads, total_writes, seen_all
+
+def main() -> None:
+"""
+Process the arguments, injest the program and plugin out and
+verify they match up and report if they do not.
+"""
+parser = ArgumentParser(description="Validate memory instrumentation")
+parser.add_argument('test_output',
+help="The output from the test itself")
+parser.add_argument('plugin_output',
+help="The output from memory plugin")
+parser.add_argument('--bss-cleared',
+action='store_true',
+help='Assume bss was cleared (and adjusts counts).')
+
+args = parser.parse_args()
+
+# Extract counts from memory binary
+start, end, exp_reads, exp_writes = extract_counts(args.test_output)
+
+# Some targets clear BSS before running but the test doesn't know
+# that so we adjust it by the size of the test region.
+if args.bss_cleared:
+exp_writes += 16384
+
+if start is None or end is None:
+print("Failed to test_data boundaries from output.")
+sys.exit(1)
+
+# Parse plugin output
+preads, pwrites, seen_all = parse_plugin_output(args.plugin_output, start, 
end)
+
+if not seen_all:
+print("Fail: didn't instrument all accesses to test_data.")
+sys.exit(1)
+
+# Compare and report
+if preads == exp_reads and pwrites == exp_writes:
+sys.exit(0)
+else:
+print("Fail: The memory reads and writes count does not match.")
+print(f"Expected Reads: {exp_reads}, Actual Reads: {preads}")
+print(f"Expected Writes: {exp_writes}, Actual Writes: {pwrites}")
+sys.exit(1)
+
+if __name__ == "__main__":
+main()
diff --git a/tests/tcg/s390x/Makefile.softmmu-target 
b/tests/tcg/s390x/Makefile.softmmu-target
index be242ba8f1..3227903348 100644
--- a/tests/tcg/s390x/Makefile.softmmu-target
+++ b/tests/tcg/s390x/Makefile.softmmu-target
@@ -47,3 +47,8 @@ $(MULTIARCH_TESTS): $(S390X_MULTIARCH_RUNTIME_OBJS)
  $(MULTIARCH_TESTS): LDFLAGS += $(S390X_MULTIARCH_RUNTIME_OBJS)
  $(MULTIARCH_TESTS): CFLAGS += $(MINILIB_INC)
  memory: CFLAGS += -DCHECK_UNALIGNED=0
+
+# s390x clears the BSS section so we need to account for that
+run-plugin-memory-with-libmem.so:  \
+   
CHECK_PLUGIN_OUTPUT_COMMAND=$(MULTIARCH_SYSTEM_SRC)/validate-memory-counts.py \
+   --bss-cleared $@.out


Reviewed-by: Pierrick Bouvier 


Re: [PATCH v2 14/18] util/timer: avoid deadlock when shutting down

2024-09-18 Thread Pierrick Bouvier

On 9/16/24 01:53, Alex Bennée wrote:

When we shut down a guest we disable the timers. However this can
cause deadlock if the guest has queued some async work that is trying
to advance system time and spins forever trying to wind time forward.
Pay attention to the return code and bail early if we can't wind time
forward.

Signed-off-by: Alex Bennée 
Reported-by: Elisha Hollander 
---
  util/qemu-timer.c | 14 --
  1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/util/qemu-timer.c b/util/qemu-timer.c
index 213114be68..6b1533bc2a 100644
--- a/util/qemu-timer.c
+++ b/util/qemu-timer.c
@@ -685,10 +685,17 @@ int64_t qemu_clock_advance_virtual_time(int64_t dest)
  {
  int64_t clock = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
  AioContext *aio_context;
+int64_t deadline;
+
  aio_context = qemu_get_aio_context();
-while (clock < dest) {
-int64_t deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL,
+
+deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL,
QEMU_TIMER_ATTR_ALL);
+/*
+ * A deadline of < 0 indicates this timer is not enabled, so we
+ * won't get far trying to run it forward.
+ */
+while (deadline >= 0 && clock < dest) {
  int64_t warp = qemu_soonest_timeout(dest - clock, deadline);
  
  qemu_virtual_clock_set_ns(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + warp);

@@ -696,6 +703,9 @@ int64_t qemu_clock_advance_virtual_time(int64_t dest)
  qemu_clock_run_timers(QEMU_CLOCK_VIRTUAL);
  timerlist_run_timers(aio_context->tlg.tl[QEMU_CLOCK_VIRTUAL]);
  clock = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
+
+deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL,
+  QEMU_TIMER_ATTR_ALL);
  }
  qemu_clock_notify(QEMU_CLOCK_VIRTUAL);
  


Reviewed-by: Pierrick Bouvier 


Re: [PATCH v2 18/18] contrib/plugins: avoid hanging program

2024-09-18 Thread Pierrick Bouvier

On 9/16/24 01:54, Alex Bennée wrote:

Although we asks for instructions per second we work in quanta and
that cannot be 0. Fail to load the plugin instead and report the
minimum IPS we can handle.

Signed-off-by: Alex Bennée 
Reported-by: Elisha Hollander 
Reviewed-by: Richard Henderson 
---
  contrib/plugins/ips.c | 5 +
  1 file changed, 5 insertions(+)

diff --git a/contrib/plugins/ips.c b/contrib/plugins/ips.c
index 29fa556d0f..6f078689dc 100644
--- a/contrib/plugins/ips.c
+++ b/contrib/plugins/ips.c
@@ -152,6 +152,11 @@ QEMU_PLUGIN_EXPORT int 
qemu_plugin_install(qemu_plugin_id_t id,
  vcpus = qemu_plugin_scoreboard_new(sizeof(vCPUTime));
  max_insn_per_quantum = max_insn_per_second / NUM_TIME_UPDATE_PER_SEC;
  
+if (max_insn_per_quantum == 0) {

+fprintf(stderr, "minimum of %d instructions per second needed\n", 
NUM_TIME_UPDATE_PER_SEC);
+return -1;
+}
+
  time_handle = qemu_plugin_request_time_control();
  g_assert(time_handle);
  


Reviewed-by: Pierrick Bouvier 


Re: [RFC PATCH] contrib/plugins: avoid hanging program

2024-09-18 Thread Pierrick Bouvier

On 9/13/24 10:38, Alex Bennée wrote:

Although we asks for instructions per second we work in quanta and
that cannot be 0. Fail to load the plugin instead and report the
minimum IPS we can handle.

Signed-off-by: Alex Bennée 
Reported-by: Elisha Hollander 
---
  contrib/plugins/ips.c | 5 +
  1 file changed, 5 insertions(+)

diff --git a/contrib/plugins/ips.c b/contrib/plugins/ips.c
index 29fa556d0f..6f078689dc 100644
--- a/contrib/plugins/ips.c
+++ b/contrib/plugins/ips.c
@@ -152,6 +152,11 @@ QEMU_PLUGIN_EXPORT int 
qemu_plugin_install(qemu_plugin_id_t id,
  vcpus = qemu_plugin_scoreboard_new(sizeof(vCPUTime));
  max_insn_per_quantum = max_insn_per_second / NUM_TIME_UPDATE_PER_SEC;
  
+if (max_insn_per_quantum == 0) {

+fprintf(stderr, "minimum of %d instructions per second needed\n", 
NUM_TIME_UPDATE_PER_SEC);
+return -1;
+}
+
  time_handle = qemu_plugin_request_time_control();
  g_assert(time_handle);
  


The ips plugin uses tb based trap, so it should not be expected that an 
ips of 1 will do what is expected (it will execute the whole tb at minimum).


Either we could extend this plugin with a precise mode (instruction 
based), or simply emit an error when ips is too low, like < 100.

I'm more in favor of the latter solution.

Reviewed-by: Pierrick Bouvier 


Re: [PATCH 0/2] tcg: Fix branch/label link during plugin expansion

2024-09-18 Thread Pierrick Bouvier

On 9/13/24 03:23, Alex Bennée wrote:

Richard Henderson  writes:


On 9/10/24 14:23, Richard Henderson wrote:

With tcg_last_op(), we always get the last op of the stream.
With TCGContext.emit_before_op, the most recently emitted op
is no longer the last op.
Instead, pass the op being emitted back from the allocator so
that we can link it to the label without needing to look it up.


Oh, I meant to point out from whence this comes.
The plugin uses a conditional


 size_t n_insns = qemu_plugin_tb_n_insns(tb);
 qemu_plugin_u64 quantum_insn =
 qemu_plugin_scoreboard_u64_in_struct(vcpus, vCPUTime, quantum_insn);
 /* count (and eventually trap) once per tb */
 qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu(
 tb, QEMU_PLUGIN_INLINE_ADD_U64, quantum_insn, n_insns);


  ld_i32 tmp18,env,$0xdb10
  mul_i32 tmp18,tmp18,$0x18
  ext_i32_i64 tmp17,tmp18
  add_i64 tmp17,tmp17,$0x575410edadc8


 qemu_plugin_register_vcpu_tb_exec_cond_cb(
 tb, every_quantum_insn,
 QEMU_PLUGIN_CB_NO_REGS, QEMU_PLUGIN_COND_GE,
 quantum_insn, max_insn_per_quantum, NULL);

?


  ld_i64 tmp21,tmp17,$0x0
  brcond_i64 tmp21,$0x0,ltu,$L1
  ld_i32 tmp18,env,$0xdb10
  call plugin(0x79a2abfde66a),$0x1,$0,tmp18,$0x0
  set_label $L1

Note that the branch is X < 0 (unsigned), which is always false, and
thus the branch is optimized away.


I'm obviously missing something reading this. How can TCG know the state
of the scoreboard variables and optimise away the branch?



The constant against which we compare scoreboard entry value is known at 
translation time.





r~




[PATCH v2 44/48] migration: remove return after g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Signed-off-by: Pierrick Bouvier 
---
 migration/dirtyrate.c| 1 -
 migration/postcopy-ram.c | 7 ---
 migration/ram.c  | 2 --
 3 files changed, 10 deletions(-)

diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c
index c03b13b624f..5478d58de36 100644
--- a/migration/dirtyrate.c
+++ b/migration/dirtyrate.c
@@ -229,7 +229,6 @@ static int time_unit_to_power(TimeUnit time_unit)
 return -3;
 default:
 g_assert_not_reached();
-return 0;
 }
 }
 
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index f431bbc0d4f..0fe9d83d44a 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -1412,40 +1412,34 @@ int postcopy_ram_incoming_init(MigrationIncomingState 
*mis)
 int postcopy_ram_incoming_cleanup(MigrationIncomingState *mis)
 {
 g_assert_not_reached();
-return -1;
 }
 
 int postcopy_ram_prepare_discard(MigrationIncomingState *mis)
 {
 g_assert_not_reached();
-return -1;
 }
 
 int postcopy_request_shared_page(struct PostCopyFD *pcfd, RAMBlock *rb,
  uint64_t client_addr, uint64_t rb_offset)
 {
 g_assert_not_reached();
-return -1;
 }
 
 int postcopy_ram_incoming_setup(MigrationIncomingState *mis)
 {
 g_assert_not_reached();
-return -1;
 }
 
 int postcopy_place_page(MigrationIncomingState *mis, void *host, void *from,
 RAMBlock *rb)
 {
 g_assert_not_reached();
-return -1;
 }
 
 int postcopy_place_page_zero(MigrationIncomingState *mis, void *host,
 RAMBlock *rb)
 {
 g_assert_not_reached();
-return -1;
 }
 
 int postcopy_wake_shared(struct PostCopyFD *pcfd,
@@ -1453,7 +1447,6 @@ int postcopy_wake_shared(struct PostCopyFD *pcfd,
  RAMBlock *rb)
 {
 g_assert_not_reached();
-return -1;
 }
 #endif
 
diff --git a/migration/ram.c b/migration/ram.c
index 0aa5d347439..81eda2736a9 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1766,13 +1766,11 @@ bool ram_write_tracking_available(void)
 bool ram_write_tracking_compatible(void)
 {
 g_assert_not_reached();
-return false;
 }
 
 int ram_write_tracking_start(void)
 {
 g_assert_not_reached();
-return -1;
 }
 
 void ram_write_tracking_stop(void)
-- 
2.39.2




[PATCH v2 47/48] tests/qtest: remove return after g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Signed-off-by: Pierrick Bouvier 
---
 tests/qtest/acpi-utils.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tests/qtest/acpi-utils.c b/tests/qtest/acpi-utils.c
index 673fc975862..9dc24fbe5a0 100644
--- a/tests/qtest/acpi-utils.c
+++ b/tests/qtest/acpi-utils.c
@@ -156,5 +156,4 @@ uint64_t acpi_find_rsdp_address_uefi(QTestState *qts, 
uint64_t start,
 g_usleep(TEST_DELAY);
 }
 g_assert_not_reached();
-return 0;
 }
-- 
2.39.2




[PATCH v2 46/48] qom: remove return after g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Signed-off-by: Pierrick Bouvier 
---
 qom/object.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/qom/object.c b/qom/object.c
index 157a45c5f8b..28c5b66eab5 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -2079,7 +2079,6 @@ const char *object_get_canonical_path_component(const 
Object *obj)
 
 /* obj had a parent but was not a child, should never happen */
 g_assert_not_reached();
-return NULL;
 }
 
 char *object_get_canonical_path(const Object *obj)
-- 
2.39.2




[PATCH v2 48/48] scripts/checkpatch.pl: emit error when using assert(false)

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 scripts/checkpatch.pl | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 65b6f46f905..fa9c12230eb 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3102,6 +3102,9 @@ sub process {
if ($line =~ /\b(g_)?assert\(0\)/) {
ERROR("use g_assert_not_reached() instead of 
assert(0)\n" . $herecurr);
}
+   if ($line =~ /\b(g_)?assert\(false\)/) {
+   ERROR("use g_assert_not_reached() instead of 
assert(false)\n" . $herecurr);
+   }
if ($line =~ /\bstrerrorname_np\(/) {
ERROR("use strerror() instead of strerrorname_np()\n" . 
$herecurr);
}
-- 
2.39.2




[PATCH v2 45/48] qobject: remove return after g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Signed-off-by: Pierrick Bouvier 
---
 qobject/qnum.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/qobject/qnum.c b/qobject/qnum.c
index 2138b563a9f..dd8ea495655 100644
--- a/qobject/qnum.c
+++ b/qobject/qnum.c
@@ -86,7 +86,6 @@ bool qnum_get_try_int(const QNum *qn, int64_t *val)
 }
 
 g_assert_not_reached();
-return false;
 }
 
 /**
@@ -124,7 +123,6 @@ bool qnum_get_try_uint(const QNum *qn, uint64_t *val)
 }
 
 g_assert_not_reached();
-return false;
 }
 
 /**
@@ -157,7 +155,6 @@ double qnum_get_double(QNum *qn)
 }
 
 g_assert_not_reached();
-return 0.0;
 }
 
 char *qnum_to_string(QNum *qn)
@@ -173,7 +170,6 @@ char *qnum_to_string(QNum *qn)
 }
 
 g_assert_not_reached();
-return NULL;
 }
 
 /**
-- 
2.39.2




[PATCH v2 36/48] ui: remove break after g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Pierrick Bouvier 
---
 ui/qemu-pixman.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/ui/qemu-pixman.c b/ui/qemu-pixman.c
index 5ca55dd1998..6cada8b45e1 100644
--- a/ui/qemu-pixman.c
+++ b/ui/qemu-pixman.c
@@ -49,7 +49,6 @@ PixelFormat qemu_pixelformat_from_pixman(pixman_format_code_t 
format)
 break;
 default:
 g_assert_not_reached();
-break;
 }
 
 pf.amax = (1 << pf.abits) - 1;
-- 
2.39.2




[PATCH v2 08/48] migration: replace assert(0) with g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Fabiano Rosas 
Reviewed-by: Peter Xu 
Signed-off-by: Pierrick Bouvier 
---
 migration/migration-hmp-cmds.c |  2 +-
 migration/postcopy-ram.c   | 14 +++---
 migration/ram.c|  6 +++---
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
index 28165cfc9ed..20d1a6e2194 100644
--- a/migration/migration-hmp-cmds.c
+++ b/migration/migration-hmp-cmds.c
@@ -640,7 +640,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict 
*qdict)
 visit_type_bool(v, param, &p->direct_io, &err);
 break;
 default:
-assert(0);
+g_assert_not_reached();
 }
 
 if (err) {
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index 1c374b7ea1e..f431bbc0d4f 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -1411,40 +1411,40 @@ int postcopy_ram_incoming_init(MigrationIncomingState 
*mis)
 
 int postcopy_ram_incoming_cleanup(MigrationIncomingState *mis)
 {
-assert(0);
+g_assert_not_reached();
 return -1;
 }
 
 int postcopy_ram_prepare_discard(MigrationIncomingState *mis)
 {
-assert(0);
+g_assert_not_reached();
 return -1;
 }
 
 int postcopy_request_shared_page(struct PostCopyFD *pcfd, RAMBlock *rb,
  uint64_t client_addr, uint64_t rb_offset)
 {
-assert(0);
+g_assert_not_reached();
 return -1;
 }
 
 int postcopy_ram_incoming_setup(MigrationIncomingState *mis)
 {
-assert(0);
+g_assert_not_reached();
 return -1;
 }
 
 int postcopy_place_page(MigrationIncomingState *mis, void *host, void *from,
 RAMBlock *rb)
 {
-assert(0);
+g_assert_not_reached();
 return -1;
 }
 
 int postcopy_place_page_zero(MigrationIncomingState *mis, void *host,
 RAMBlock *rb)
 {
-assert(0);
+g_assert_not_reached();
 return -1;
 }
 
@@ -1452,7 +1452,7 @@ int postcopy_wake_shared(struct PostCopyFD *pcfd,
  uint64_t client_addr,
  RAMBlock *rb)
 {
-assert(0);
+g_assert_not_reached();
 return -1;
 }
 #endif
diff --git a/migration/ram.c b/migration/ram.c
index 67ca3d5d51a..0aa5d347439 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1765,19 +1765,19 @@ bool ram_write_tracking_available(void)
 
 bool ram_write_tracking_compatible(void)
 {
-assert(0);
+g_assert_not_reached();
 return false;
 }
 
 int ram_write_tracking_start(void)
 {
-assert(0);
+g_assert_not_reached();
 return -1;
 }
 
 void ram_write_tracking_stop(void)
 {
-assert(0);
+g_assert_not_reached();
 }
 #endif /* defined(__linux__) */
 
-- 
2.39.2




[PATCH v2 30/48] hw/pci-host: remove break after g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Pierrick Bouvier 
---
 hw/pci-host/gt64120.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/hw/pci-host/gt64120.c b/hw/pci-host/gt64120.c
index 33607dfbec4..58557416629 100644
--- a/hw/pci-host/gt64120.c
+++ b/hw/pci-host/gt64120.c
@@ -689,7 +689,6 @@ static void gt64120_writel(void *opaque, hwaddr addr,
 case GT_PCI0_CFGDATA:
 /* Mapped via in gt64120_pci_mapping() */
 g_assert_not_reached();
-break;
 
 /* Interrupts */
 case GT_INTRCAUSE:
@@ -933,7 +932,6 @@ static uint64_t gt64120_readl(void *opaque,
 case GT_PCI0_CFGDATA:
 /* Mapped via in gt64120_pci_mapping() */
 g_assert_not_reached();
-break;
 
 case GT_PCI0_CMD:
 case GT_PCI0_TOR:
-- 
2.39.2




[PATCH v2 13/48] tests/unit: replace assert(0) with g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 tests/unit/test-xs-node.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/unit/test-xs-node.c b/tests/unit/test-xs-node.c
index ac94e7ed6c2..2f447a73fb8 100644
--- a/tests/unit/test-xs-node.c
+++ b/tests/unit/test-xs-node.c
@@ -212,7 +212,7 @@ static void compare_tx(gpointer key, gpointer val, gpointer 
opaque)
 printf("Comparison failure in TX %u after serdes:\n", tx_id);
 dump_ref("Original", t1->root, 0);
 dump_ref("Deserialised", t2->root, 0);
-g_assert(0);
+g_assert_not_reached();
 }
 g_assert(t1->nr_nodes == t2->nr_nodes);
 }
@@ -257,7 +257,7 @@ static void check_serdes(XenstoreImplState *s)
 printf("Comparison failure in main tree after serdes:\n");
 dump_ref("Original", s->root, 0);
 dump_ref("Deserialised", s2->root, 0);
-g_assert(0);
+g_assert_not_reached();
 }
 
 nr_transactions1 = g_hash_table_size(s->transactions);
-- 
2.39.2




[PATCH v2 29/48] hw/net: remove break after g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 hw/net/net_rx_pkt.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/net/net_rx_pkt.c b/hw/net/net_rx_pkt.c
index 6b9c4c9559d..0ea87344745 100644
--- a/hw/net/net_rx_pkt.c
+++ b/hw/net/net_rx_pkt.c
@@ -376,7 +376,6 @@ net_rx_pkt_calc_rss_hash(struct NetRxPkt *pkt,
 break;
 default:
 g_assert_not_reached();
-break;
 }
 
 net_toeplitz_key_init(&key_data, key);
-- 
2.39.2




[PATCH v2 42/48] hw/pci: remove return after g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Signed-off-by: Pierrick Bouvier 
---
 hw/pci/pci-stub.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/hw/pci/pci-stub.c b/hw/pci/pci-stub.c
index c6950e21bd4..3397d0c82ea 100644
--- a/hw/pci/pci-stub.c
+++ b/hw/pci/pci-stub.c
@@ -47,13 +47,11 @@ void hmp_pcie_aer_inject_error(Monitor *mon, const QDict 
*qdict)
 MSIMessage pci_get_msi_message(PCIDevice *dev, int vector)
 {
 g_assert_not_reached();
-return (MSIMessage){};
 }
 
 uint16_t pci_requester_id(PCIDevice *dev)
 {
 g_assert_not_reached();
-return 0;
 }
 
 /* Required by ahci.c */
-- 
2.39.2




[PATCH v2 40/48] hw/hyperv: remove return after g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Signed-off-by: Pierrick Bouvier 
---
 hw/hyperv/hyperv_testdev.c | 1 -
 hw/hyperv/vmbus.c  | 3 ---
 2 files changed, 4 deletions(-)

diff --git a/hw/hyperv/hyperv_testdev.c b/hw/hyperv/hyperv_testdev.c
index ef50e490c4e..a630ca70476 100644
--- a/hw/hyperv/hyperv_testdev.c
+++ b/hw/hyperv/hyperv_testdev.c
@@ -89,7 +89,6 @@ static TestSintRoute *sint_route_find(HypervTestDev *dev,
 }
 }
 g_assert_not_reached();
-return NULL;
 }
 
 static void sint_route_destroy(HypervTestDev *dev,
diff --git a/hw/hyperv/vmbus.c b/hw/hyperv/vmbus.c
index df47aae72b8..be7d3172c4f 100644
--- a/hw/hyperv/vmbus.c
+++ b/hw/hyperv/vmbus.c
@@ -1890,7 +1890,6 @@ static bool complete_create_gpadl(VMBus *vmbus)
 }
 
 g_assert_not_reached();
-return false;
 }
 
 static void handle_gpadl_teardown(VMBus *vmbus,
@@ -1947,7 +1946,6 @@ static bool complete_teardown_gpadl(VMBus *vmbus)
 }
 
 g_assert_not_reached();
-return false;
 }
 
 static void handle_open_channel(VMBus *vmbus, vmbus_message_open_channel *msg,
@@ -2021,7 +2019,6 @@ static bool complete_open_channel(VMBus *vmbus)
 }
 
 g_assert_not_reached();
-return false;
 }
 
 static void vdev_reset_on_close(VMBusDevice *vdev)
-- 
2.39.2




[PATCH v2 31/48] hw/scsi: remove break after g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Reviewed-by: Kevin Wolf 
Signed-off-by: Pierrick Bouvier 
---
 hw/scsi/virtio-scsi.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index 9f02ceea099..6637cfeaf51 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -357,7 +357,6 @@ static void virtio_scsi_do_one_tmf_bh(VirtIOSCSIReq *req)
 
 default:
 g_assert_not_reached();
-break;
 }
 
 out:
-- 
2.39.2




[PATCH v2 05/48] hw/core: replace assert(0) with g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Pierrick Bouvier 
---
 hw/core/numa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/core/numa.c b/hw/core/numa.c
index fb81c1ed51b..1b5f44baeac 100644
--- a/hw/core/numa.c
+++ b/hw/core/numa.c
@@ -380,7 +380,7 @@ void parse_numa_hmat_lb(NumaState *numa_state, 
NumaHmatLBOptions *node,
 }
 lb_data.data = node->bandwidth;
 } else {
-assert(0);
+g_assert_not_reached();
 }
 
 g_array_append_val(hmat_lb->list, lb_data);
-- 
2.39.2




[PATCH v2 37/48] fpu: remove break after g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 fpu/softfloat-parts.c.inc | 2 --
 1 file changed, 2 deletions(-)

diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
index a44649f4f4a..cc6e06b9761 100644
--- a/fpu/softfloat-parts.c.inc
+++ b/fpu/softfloat-parts.c.inc
@@ -1373,7 +1373,6 @@ static FloatPartsN *partsN(minmax)(FloatPartsN *a, 
FloatPartsN *b,
 break;
 default:
 g_assert_not_reached();
-break;
 }
 switch (b->cls) {
 case float_class_normal:
@@ -1386,7 +1385,6 @@ static FloatPartsN *partsN(minmax)(FloatPartsN *a, 
FloatPartsN *b,
 break;
 default:
 g_assert_not_reached();
-break;
 }
 }
 
-- 
2.39.2




[PATCH v2 07/48] hw/watchdog: replace assert(0) with g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Reviewed-by: Philippe Mathieu-Daudé 
Reviewed-by: Richard W.M. Jones 
Signed-off-by: Pierrick Bouvier 
---
 hw/watchdog/watchdog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/watchdog/watchdog.c b/hw/watchdog/watchdog.c
index 955046161bf..d0ce3c4ac55 100644
--- a/hw/watchdog/watchdog.c
+++ b/hw/watchdog/watchdog.c
@@ -85,7 +85,7 @@ void watchdog_perform_action(void)
 break;
 
 default:
-assert(0);
+g_assert_not_reached();
 }
 }
 
-- 
2.39.2




[PATCH v2 21/48] migration: replace assert(false) with g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Fabiano Rosas 
Reviewed-by: Richard Henderson 
Reviewed-by: Peter Xu 
Signed-off-by: Pierrick Bouvier 
---
 migration/dirtyrate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c
index 1d9db812990..c03b13b624f 100644
--- a/migration/dirtyrate.c
+++ b/migration/dirtyrate.c
@@ -228,7 +228,7 @@ static int time_unit_to_power(TimeUnit time_unit)
 case TIME_UNIT_MILLISECOND:
 return -3;
 default:
-assert(false); /* unreachable */
+g_assert_not_reached();
 return 0;
 }
 }
-- 
2.39.2




[PATCH v2 38/48] tcg/loongarch64: remove break after g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 tcg/loongarch64/tcg-target.c.inc | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc
index 5b7ed5c176b..973601aec36 100644
--- a/tcg/loongarch64/tcg-target.c.inc
+++ b/tcg/loongarch64/tcg-target.c.inc
@@ -650,7 +650,6 @@ static int tcg_out_setcond_int(TCGContext *s, TCGCond cond, 
TCGReg ret,
 
 default:
 g_assert_not_reached();
-break;
 }
 
 return ret | flags;
-- 
2.39.2




[PATCH v2 14/48] include/hw/s390x: replace assert(false) with g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Reviewed-by: Thomas Huth 
Signed-off-by: Pierrick Bouvier 
---
 include/hw/s390x/cpu-topology.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/hw/s390x/cpu-topology.h b/include/hw/s390x/cpu-topology.h
index a11b1baa77b..9283c948e3a 100644
--- a/include/hw/s390x/cpu-topology.h
+++ b/include/hw/s390x/cpu-topology.h
@@ -57,7 +57,7 @@ static inline void s390_topology_setup_cpu(MachineState *ms,
 static inline void s390_topology_reset(void)
 {
 /* Unreachable, CPU topology not implemented for TCG */
-assert(false);
+g_assert_not_reached();
 }
 #endif
 
-- 
2.39.2




[PATCH v2 43/48] hw/ppc: remove return after g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Signed-off-by: Pierrick Bouvier 
---
 hw/ppc/ppc.c  | 1 -
 hw/ppc/spapr_events.c | 1 -
 2 files changed, 2 deletions(-)

diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c
index e6fa5580c01..fde46194122 100644
--- a/hw/ppc/ppc.c
+++ b/hw/ppc/ppc.c
@@ -267,7 +267,6 @@ static void power9_set_irq(void *opaque, int pin, int level)
 break;
 default:
 g_assert_not_reached();
-return;
 }
 }
 
diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c
index 38ac1cb7866..4dbf8e2e2ef 100644
--- a/hw/ppc/spapr_events.c
+++ b/hw/ppc/spapr_events.c
@@ -646,7 +646,6 @@ static void spapr_hotplug_req_event(uint8_t hp_id, uint8_t 
hp_action,
  * that don't support them
  */
 g_assert_not_reached();
-return;
 }
 
 if (hp_id == RTAS_LOG_V6_HP_ID_DRC_COUNT) {
-- 
2.39.2




[PATCH v2 35/48] tests/qtest: remove break after g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 tests/qtest/migration-helpers.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helpers.c
index a43d180c807..00259338833 100644
--- a/tests/qtest/migration-helpers.c
+++ b/tests/qtest/migration-helpers.c
@@ -76,7 +76,6 @@ static QDict *SocketAddress_to_qdict(SocketAddress *addr)
 break;
 default:
 g_assert_not_reached();
-break;
 }
 
 return dict;
-- 
2.39.2




[PATCH v2 10/48] system: replace assert(0) with g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Pierrick Bouvier 
---
 system/rtc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/system/rtc.c b/system/rtc.c
index dc44576686e..216d2aee3ae 100644
--- a/system/rtc.c
+++ b/system/rtc.c
@@ -62,7 +62,7 @@ static time_t qemu_ref_timedate(QEMUClockType clock)
 }
 break;
 default:
-assert(0);
+g_assert_not_reached();
 }
 return value;
 }
-- 
2.39.2




[PATCH v2 41/48] hw/net: remove return after g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Signed-off-by: Pierrick Bouvier 
---
 hw/net/e1000e_core.c | 2 --
 hw/net/igb_core.c| 2 --
 hw/net/vmxnet3.c | 1 -
 3 files changed, 5 deletions(-)

diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c
index 248381f9766..2e4c50ddbaf 100644
--- a/hw/net/e1000e_core.c
+++ b/hw/net/e1000e_core.c
@@ -562,7 +562,6 @@ e1000e_rss_calc_hash(E1000ECore *core,
 break;
 default:
 g_assert_not_reached();
-return 0;
 }
 
 return net_rx_pkt_calc_rss_hash(pkt, type, (uint8_t *) &core->mac[RSSRK]);
@@ -841,7 +840,6 @@ e1000e_ring_free_descr_num(E1000ECore *core, const 
E1000ERingInfo *r)
 }
 
 g_assert_not_reached();
-return 0;
 }
 
 static inline bool
diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c
index 6be61407715..5dffa12c64b 100644
--- a/hw/net/igb_core.c
+++ b/hw/net/igb_core.c
@@ -398,7 +398,6 @@ igb_rss_calc_hash(IGBCore *core, struct NetRxPkt *pkt, 
E1000E_RSSInfo *info)
 break;
 default:
 g_assert_not_reached();
-return 0;
 }
 
 return net_rx_pkt_calc_rss_hash(pkt, type, (uint8_t *) &core->mac[RSSRK]);
@@ -747,7 +746,6 @@ igb_ring_free_descr_num(IGBCore *core, const E1000ERingInfo 
*r)
 }
 
 g_assert_not_reached();
-return 0;
 }
 
 static inline bool
diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index 63a91877730..6b5185c707b 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -456,7 +456,6 @@ vmxnet3_setup_tx_offloads(VMXNET3State *s)
 
 default:
 g_assert_not_reached();
-return false;
 }
 
 return true;
-- 
2.39.2




[PATCH v2 33/48] target/arm: remove break after g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 target/arm/hyp_gdbstub.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/target/arm/hyp_gdbstub.c b/target/arm/hyp_gdbstub.c
index f120d55caab..1e861263b3d 100644
--- a/target/arm/hyp_gdbstub.c
+++ b/target/arm/hyp_gdbstub.c
@@ -158,7 +158,6 @@ int insert_hw_watchpoint(target_ulong addr, target_ulong 
len, int type)
 break;
 default:
 g_assert_not_reached();
-break;
 }
 if (len <= 8) {
 /* we align the address and set the bits in BAS */
-- 
2.39.2




[PATCH v2 27/48] hw/gpio: remove break after g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Pierrick Bouvier 
---
 hw/gpio/nrf51_gpio.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/gpio/nrf51_gpio.c b/hw/gpio/nrf51_gpio.c
index ffc7dff7964..f259be651e1 100644
--- a/hw/gpio/nrf51_gpio.c
+++ b/hw/gpio/nrf51_gpio.c
@@ -40,7 +40,6 @@ static bool is_connected(uint32_t config, uint32_t level)
 break;
 default:
 g_assert_not_reached();
-break;
 }
 
 return state;
-- 
2.39.2




[PATCH v2 32/48] hw/tpm: remove break after g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 hw/tpm/tpm_spapr.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/tpm/tpm_spapr.c b/hw/tpm/tpm_spapr.c
index e084e987e6e..5f7a0dfc617 100644
--- a/hw/tpm/tpm_spapr.c
+++ b/hw/tpm/tpm_spapr.c
@@ -206,7 +206,6 @@ static int tpm_spapr_do_crq(struct SpaprVioDevice *dev, 
uint8_t *crq_data)
 break;
 default:
 g_assert_not_reached();
-break;
 }
 trace_tpm_spapr_do_crq_get_version(be32_to_cpu(local_crq.data));
 spapr_tpm_send_crq(dev, &local_crq);
-- 
2.39.2




[PATCH v2 39/48] include/qemu: remove return after g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Signed-off-by: Pierrick Bouvier 
---
 include/qemu/pmem.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/qemu/pmem.h b/include/qemu/pmem.h
index d2d7ad085cc..e12a67ba2c0 100644
--- a/include/qemu/pmem.h
+++ b/include/qemu/pmem.h
@@ -22,7 +22,6 @@ pmem_memcpy_persist(void *pmemdest, const void *src, size_t 
len)
 /* If 'pmem' option is 'on', we should always have libpmem support,
or qemu will report a error and exit, never come here. */
 g_assert_not_reached();
-return NULL;
 }
 
 static inline void
-- 
2.39.2




[PATCH v2 28/48] hw/misc: remove break after g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Pierrick Bouvier 
---
 hw/misc/imx6_ccm.c | 1 -
 hw/misc/mac_via.c  | 2 --
 2 files changed, 3 deletions(-)

diff --git a/hw/misc/imx6_ccm.c b/hw/misc/imx6_ccm.c
index b1def7f05b9..fd5d7ce4828 100644
--- a/hw/misc/imx6_ccm.c
+++ b/hw/misc/imx6_ccm.c
@@ -301,7 +301,6 @@ static uint64_t imx6_analog_get_periph_clk(IMX6CCMState 
*dev)
 default:
 /* We should never get there */
 g_assert_not_reached();
-break;
 }
 
 trace_imx6_analog_get_periph_clk(freq);
diff --git a/hw/misc/mac_via.c b/hw/misc/mac_via.c
index 652395b84fc..af2b2b1af3d 100644
--- a/hw/misc/mac_via.c
+++ b/hw/misc/mac_via.c
@@ -495,7 +495,6 @@ static void via1_rtc_update(MOS6522Q800VIA1State *v1s)
 break;
 default:
 g_assert_not_reached();
-break;
 }
 return;
 }
@@ -556,7 +555,6 @@ static void via1_rtc_update(MOS6522Q800VIA1State *v1s)
 break;
 default:
 g_assert_not_reached();
-break;
 }
 return;
 }
-- 
2.39.2




[PATCH v2 24/48] accel/tcg: remove break after g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 accel/tcg/plugin-gen.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c
index ec89a085b43..2ee4c22befd 100644
--- a/accel/tcg/plugin-gen.c
+++ b/accel/tcg/plugin-gen.c
@@ -251,7 +251,6 @@ static void inject_mem_cb(struct qemu_plugin_dyn_cb *cb,
 break;
 default:
 g_assert_not_reached();
-break;
 }
 }
 
-- 
2.39.2




[PATCH v2 26/48] hw/acpi: remove break after g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 hw/acpi/aml-build.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index 006c506a375..34e0ddbde87 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -535,7 +535,6 @@ void aml_append(Aml *parent_ctx, Aml *child)
 break;
 default:
 g_assert_not_reached();
-break;
 }
 build_append_array(parent_ctx->buf, buf);
 build_free_array(buf);
-- 
2.39.2




[PATCH v2 19/48] hw/pci: replace assert(false) with g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 hw/pci/pci-stub.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/pci/pci-stub.c b/hw/pci/pci-stub.c
index f0508682d2b..c6950e21bd4 100644
--- a/hw/pci/pci-stub.c
+++ b/hw/pci/pci-stub.c
@@ -46,13 +46,13 @@ void hmp_pcie_aer_inject_error(Monitor *mon, const QDict 
*qdict)
 /* kvm-all wants this */
 MSIMessage pci_get_msi_message(PCIDevice *dev, int vector)
 {
-g_assert(false);
+g_assert_not_reached();
 return (MSIMessage){};
 }
 
 uint16_t pci_requester_id(PCIDevice *dev)
 {
-g_assert(false);
+g_assert_not_reached();
 return 0;
 }
 
-- 
2.39.2




[PATCH v2 11/48] target/ppc: replace assert(0) with g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Reviewed-by: Daniel Henrique Barboza 
Signed-off-by: Pierrick Bouvier 
---
 target/ppc/dfp_helper.c | 8 
 target/ppc/mmu_helper.c | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/target/ppc/dfp_helper.c b/target/ppc/dfp_helper.c
index 5967ea07a92..ecc3f793267 100644
--- a/target/ppc/dfp_helper.c
+++ b/target/ppc/dfp_helper.c
@@ -249,7 +249,7 @@ static void dfp_set_FPRF_from_FRT_with_context(struct 
PPC_DFP *dfp,
 fprf = 0x05;
 break;
 default:
-assert(0); /* should never get here */
+g_assert_not_reached();
 }
 dfp->env->fpscr &= ~FP_FPRF;
 dfp->env->fpscr |= (fprf << FPSCR_FPRF);
@@ -1243,7 +1243,7 @@ void helper_##op(CPUPPCState *env, ppc_fprp_t *t, 
ppc_fprp_t *b) \
 } else if (decNumberIsQNaN(&dfp.b)) {  \
 vt.VsrD(1) = -2;   \
 } else {   \
-assert(0); \
+g_assert_not_reached();\
 }  \
 set_dfp64(t, &vt); \
 } else {   \
@@ -1252,7 +1252,7 @@ void helper_##op(CPUPPCState *env, ppc_fprp_t *t, 
ppc_fprp_t *b) \
 } else if ((size) == 128) {\
 vt.VsrD(1) = dfp.b.exponent + 6176;\
 } else {   \
-assert(0); \
+g_assert_not_reached();\
 }  \
 set_dfp64(t, &vt); \
 }  \
@@ -1300,7 +1300,7 @@ void helper_##op(CPUPPCState *env, ppc_fprp_t *t, 
ppc_fprp_t *a,  \
 raw_inf = 0x1e000;\
 bias = 6176;  \
 } else {  \
-assert(0);\
+g_assert_not_reached();   \
 } \
   \
 if (unlikely((exp < 0) || (exp > max_exp))) { \
diff --git a/target/ppc/mmu_helper.c b/target/ppc/mmu_helper.c
index b0a0676beba..b167b37e0ab 100644
--- a/target/ppc/mmu_helper.c
+++ b/target/ppc/mmu_helper.c
@@ -316,7 +316,7 @@ void ppc_tlb_invalidate_one(CPUPPCState *env, target_ulong 
addr)
 break;
 default:
 /* Should never reach here with other MMU models */
-assert(0);
+g_assert_not_reached();
 }
 #else
 ppc_tlb_invalidate_all(env);
-- 
2.39.2




[PATCH v2 25/48] block: remove break after g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Reviewed-by: Richard W.M. Jones 
Reviewed-by: Kevin Wolf 
Signed-off-by: Pierrick Bouvier 
---
 block/ssh.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/block/ssh.c b/block/ssh.c
index 27d582e0e3d..871e1d47534 100644
--- a/block/ssh.c
+++ b/block/ssh.c
@@ -474,7 +474,6 @@ static int check_host_key(BDRVSSHState *s, SshHostKeyCheck 
*hkc, Error **errp)
errp);
 }
 g_assert_not_reached();
-break;
 case SSH_HOST_KEY_CHECK_MODE_KNOWN_HOSTS:
 return check_host_key_knownhosts(s, errp);
 default:
-- 
2.39.2




[PATCH v2 15/48] block: replace assert(false) with g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Reviewed-by: Kevin Wolf 
Signed-off-by: Pierrick Bouvier 
---
 block/qcow2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/qcow2.c b/block/qcow2.c
index dd359d241b7..803ca73a2ff 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -5299,7 +5299,7 @@ qcow2_get_specific_info(BlockDriverState *bs, Error 
**errp)
 } else {
 /* if this assertion fails, this probably means a new version was
  * added without having it covered here */
-assert(false);
+g_assert_not_reached();
 }
 
 if (encrypt_info) {
-- 
2.39.2




[PATCH v2 34/48] target/riscv: remove break after g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Reviewed-by: Daniel Henrique Barboza 
Signed-off-by: Pierrick Bouvier 
---
 target/riscv/monitor.c  | 1 -
 target/riscv/insn_trans/trans_rvv.c.inc | 2 --
 2 files changed, 3 deletions(-)

diff --git a/target/riscv/monitor.c b/target/riscv/monitor.c
index f5b1ffe6c3e..15ea4e9 100644
--- a/target/riscv/monitor.c
+++ b/target/riscv/monitor.c
@@ -184,7 +184,6 @@ static void mem_info_svxx(Monitor *mon, CPUArchState *env)
 break;
 default:
 g_assert_not_reached();
-break;
 }
 
 /* calculate virtual address bits */
diff --git a/target/riscv/insn_trans/trans_rvv.c.inc 
b/target/riscv/insn_trans/trans_rvv.c.inc
index 3a3896ba06c..f8928c44a8b 100644
--- a/target/riscv/insn_trans/trans_rvv.c.inc
+++ b/target/riscv/insn_trans/trans_rvv.c.inc
@@ -3172,7 +3172,6 @@ static void load_element(TCGv_i64 dest, TCGv_ptr base,
 break;
 default:
 g_assert_not_reached();
-break;
 }
 }
 
@@ -3257,7 +3256,6 @@ static void store_element(TCGv_i64 val, TCGv_ptr base,
 break;
 default:
 g_assert_not_reached();
-break;
 }
 }
 
-- 
2.39.2




[PATCH v2 16/48] hw/hyperv: replace assert(false) with g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Reviewed-by: Maciej S. Szmigiero 
Signed-off-by: Pierrick Bouvier 
---
 hw/hyperv/hyperv_testdev.c |  6 +++---
 hw/hyperv/vmbus.c  | 12 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/hw/hyperv/hyperv_testdev.c b/hw/hyperv/hyperv_testdev.c
index 9a56ddf83fe..ef50e490c4e 100644
--- a/hw/hyperv/hyperv_testdev.c
+++ b/hw/hyperv/hyperv_testdev.c
@@ -88,7 +88,7 @@ static TestSintRoute *sint_route_find(HypervTestDev *dev,
 return sint_route;
 }
 }
-assert(false);
+g_assert_not_reached();
 return NULL;
 }
 
@@ -187,7 +187,7 @@ static void msg_conn_destroy(HypervTestDev *dev, uint8_t 
conn_id)
 return;
 }
 }
-assert(false);
+g_assert_not_reached();
 }
 
 static void evt_conn_handler(EventNotifier *notifier)
@@ -237,7 +237,7 @@ static void evt_conn_destroy(HypervTestDev *dev, uint8_t 
conn_id)
 return;
 }
 }
-assert(false);
+g_assert_not_reached();
 }
 
 static uint64_t hv_test_dev_read(void *opaque, hwaddr addr, unsigned size)
diff --git a/hw/hyperv/vmbus.c b/hw/hyperv/vmbus.c
index 490d805d298..df47aae72b8 100644
--- a/hw/hyperv/vmbus.c
+++ b/hw/hyperv/vmbus.c
@@ -1874,7 +1874,7 @@ static void send_create_gpadl(VMBus *vmbus)
 }
 }
 
-assert(false);
+g_assert_not_reached();
 }
 
 static bool complete_create_gpadl(VMBus *vmbus)
@@ -1889,7 +1889,7 @@ static bool complete_create_gpadl(VMBus *vmbus)
 }
 }
 
-assert(false);
+g_assert_not_reached();
 return false;
 }
 
@@ -1931,7 +1931,7 @@ static void send_teardown_gpadl(VMBus *vmbus)
 }
 }
 
-assert(false);
+g_assert_not_reached();
 }
 
 static bool complete_teardown_gpadl(VMBus *vmbus)
@@ -1946,7 +1946,7 @@ static bool complete_teardown_gpadl(VMBus *vmbus)
 }
 }
 
-assert(false);
+g_assert_not_reached();
 return false;
 }
 
@@ -1996,7 +1996,7 @@ static void send_open_channel(VMBus *vmbus)
 }
 }
 
-assert(false);
+g_assert_not_reached();
 }
 
 static bool complete_open_channel(VMBus *vmbus)
@@ -2020,7 +2020,7 @@ static bool complete_open_channel(VMBus *vmbus)
 }
 }
 
-assert(false);
+g_assert_not_reached();
 return false;
 }
 
-- 
2.39.2




[PATCH v2 18/48] hw/nvme: replace assert(false) with g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 hw/nvme/ctrl.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index 9f277b81d83..fc3b27c031e 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -1816,7 +1816,7 @@ static uint16_t nvme_check_zone_state_for_write(NvmeZone 
*zone)
 trace_pci_nvme_err_zone_is_read_only(zslba);
 return NVME_ZONE_READ_ONLY;
 default:
-assert(false);
+g_assert_not_reached();
 }
 
 return NVME_INTERNAL_DEV_ERROR;
@@ -1870,7 +1870,7 @@ static uint16_t nvme_check_zone_state_for_read(NvmeZone 
*zone)
 trace_pci_nvme_err_zone_is_offline(zone->d.zslba);
 return NVME_ZONE_OFFLINE;
 default:
-assert(false);
+g_assert_not_reached();
 }
 
 return NVME_INTERNAL_DEV_ERROR;
@@ -4654,7 +4654,7 @@ static uint16_t nvme_io_cmd(NvmeCtrl *n, NvmeRequest *req)
 case NVME_CMD_IO_MGMT_SEND:
 return nvme_io_mgmt_send(n, req);
 default:
-assert(false);
+g_assert_not_reached();
 }
 
 return NVME_INVALID_OPCODE | NVME_DNR;
@@ -7205,7 +7205,7 @@ static uint16_t nvme_admin_cmd(NvmeCtrl *n, NvmeRequest 
*req)
 case NVME_ADM_CMD_DIRECTIVE_RECV:
 return nvme_directive_receive(n, req);
 default:
-assert(false);
+g_assert_not_reached();
 }
 
 return NVME_INVALID_OPCODE | NVME_DNR;
-- 
2.39.2




[PATCH v2 22/48] target/i386/kvm: replace assert(false) with g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Philippe Mathieu-Daudé 
Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 target/i386/kvm/kvm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index 2fa88ef1e37..308b0e1cb37 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -5770,7 +5770,7 @@ static int kvm_handle_rdmsr(X86CPU *cpu, struct kvm_run 
*run)
 }
 }
 
-assert(false);
+g_assert_not_reached();
 }
 
 static int kvm_handle_wrmsr(X86CPU *cpu, struct kvm_run *run)
@@ -5789,7 +5789,7 @@ static int kvm_handle_wrmsr(X86CPU *cpu, struct kvm_run 
*run)
 }
 }
 
-assert(false);
+g_assert_not_reached();
 }
 
 static bool has_sgx_provisioning;
-- 
2.39.2




[PATCH v2 20/48] hw/ppc: replace assert(false) with g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Reviewed-by: Daniel Henrique Barboza 
Signed-off-by: Pierrick Bouvier 
---
 hw/ppc/spapr_events.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c
index cb05874..38ac1cb7866 100644
--- a/hw/ppc/spapr_events.c
+++ b/hw/ppc/spapr_events.c
@@ -645,7 +645,7 @@ static void spapr_hotplug_req_event(uint8_t hp_id, uint8_t 
hp_action,
 /* we shouldn't be signaling hotplug events for resources
  * that don't support them
  */
-g_assert(false);
+g_assert_not_reached();
 return;
 }
 
-- 
2.39.2




[PATCH v2 23/48] tests/qtest: replace assert(false) with g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Signed-off-by: Pierrick Bouvier 
---
 tests/qtest/numa-test.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/qtest/numa-test.c b/tests/qtest/numa-test.c
index ede418963cb..6d92baee860 100644
--- a/tests/qtest/numa-test.c
+++ b/tests/qtest/numa-test.c
@@ -162,7 +162,7 @@ static void pc_numa_cpu(const void *data)
 } else if (socket == 1 && core == 1 && thread == 1) {
 g_assert_cmpint(node, ==, 1);
 } else {
-g_assert(false);
+g_assert_not_reached();
 }
 qobject_unref(e);
 }
@@ -207,7 +207,7 @@ static void spapr_numa_cpu(const void *data)
 } else if (core == 3) {
 g_assert_cmpint(node, ==, 1);
 } else {
-g_assert(false);
+g_assert_not_reached();
 }
 qobject_unref(e);
 }
@@ -257,7 +257,7 @@ static void aarch64_numa_cpu(const void *data)
 } else if (socket == 1 && cluster == 0 && core == 0 && thread == 0) {
 g_assert_cmpint(node, ==, 0);
 } else {
-g_assert(false);
+g_assert_not_reached();
 }
 qobject_unref(e);
 }
@@ -305,7 +305,7 @@ static void loongarch64_numa_cpu(const void *data)
 } else if (socket == 1 && core == 0 && thread == 0) {
 g_assert_cmpint(node, ==, 0);
 } else {
-g_assert(false);
+g_assert_not_reached();
 }
 qobject_unref(e);
 }
@@ -367,7 +367,7 @@ static void pc_dynamic_cpu_cfg(const void *data)
 } else if (socket == 1) {
 g_assert_cmpint(node, ==, 0);
 } else {
-g_assert(false);
+g_assert_not_reached();
 }
 qobject_unref(e);
 }
-- 
2.39.2




[PATCH v2 04/48] hw/char: replace assert(0) with g_assert_not_reached()

2024-09-12 Thread Pierrick Bouvier
This patch is part of a series that moves towards a consistent use of
g_assert_not_reached() rather than an ad hoc mix of different
assertion mechanisms.

Reviewed-by: Richard Henderson 
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Pierrick Bouvier 
---
 hw/char/avr_usart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/char/avr_usart.c b/hw/char/avr_usart.c
index 5bcf9db0b78..e738a2ca97e 100644
--- a/hw/char/avr_usart.c
+++ b/hw/char/avr_usart.c
@@ -86,7 +86,7 @@ static void update_char_mask(AVRUsartState *usart)
 usart->char_mask = 0b;
 break;
 default:
-assert(0);
+g_assert_not_reached();
 }
 }
 
-- 
2.39.2




  1   2   3   4   5   6   7   8   >