[PATCH V14 4/8] target/mips: Add loongson-ext lsdc2 group of instructions

2020-10-16 Thread Huacai Chen
From: Jiaxun Yang 

LDC2/SDC2 opcodes have been rewritten as "load & store with offset"
group of instructions by loongson-ext ASE.

This patch add implementation of these instructions:
gslbx: load 1 bytes to GPR
gslhx: load 2 bytes to GPR
gslwx: load 4 bytes to GPR
gsldx: load 8 bytes to GPR
gslwxc1: load 4 bytes to FPR
gsldxc1: load 8 bytes to FPR
gssbx: store 1 bytes from GPR
gsshx: store 2 bytes from GPR
gsswx: store 4 bytes from GPR
gssdx: store 8 bytes from GPR
gsswxc1: store 4 bytes from FPR
gssdxc1: store 8 bytes from FPR

Details of Loongson-EXT is here:
https://github.com/FlyGoat/loongson-insn/blob/master/loongson-ext.md

Signed-off-by: Jiaxun Yang 
Signed-off-by: Huacai Chen 
---
 target/mips/translate.c | 179 
 1 file changed, 179 insertions(+)

diff --git a/target/mips/translate.c b/target/mips/translate.c
index 25321d3c17..b2ce323e39 100644
--- a/target/mips/translate.c
+++ b/target/mips/translate.c
@@ -484,6 +484,24 @@ enum {
 OPC_GSSDRC1 = 0x7 | OPC_GSSHFS,
 };
 
+/* Loongson EXT LDC2/SDC2 opcodes */
+#define MASK_LOONGSON_LSDC2(op)   (MASK_OP_MAJOR(op) | (op & 0x7))
+
+enum {
+OPC_GSLBX  = 0x0 | OPC_LDC2,
+OPC_GSLHX  = 0x1 | OPC_LDC2,
+OPC_GSLWX  = 0x2 | OPC_LDC2,
+OPC_GSLDX  = 0x3 | OPC_LDC2,
+OPC_GSLWXC1= 0x6 | OPC_LDC2,
+OPC_GSLDXC1= 0x7 | OPC_LDC2,
+OPC_GSSBX  = 0x0 | OPC_SDC2,
+OPC_GSSHX  = 0x1 | OPC_SDC2,
+OPC_GSSWX  = 0x2 | OPC_SDC2,
+OPC_GSSDX  = 0x3 | OPC_SDC2,
+OPC_GSSWXC1= 0x6 | OPC_SDC2,
+OPC_GSSDXC1= 0x7 | OPC_SDC2,
+};
+
 /* BSHFL opcodes */
 #define MASK_BSHFL(op)  (MASK_SPECIAL3(op) | (op & (0x1F << 6)))
 
@@ -6172,6 +6190,165 @@ static void gen_loongson_lswc2(DisasContext *ctx, int 
rt,
 tcg_temp_free(t0);
 }
 
+/* Loongson EXT LDC2/SDC2 */
+static void gen_loongson_lsdc2(DisasContext *ctx, int rt,
+   int rs, int rd)
+{
+int offset = sextract32(ctx->opcode, 3, 8);
+uint32_t opc = MASK_LOONGSON_LSDC2(ctx->opcode);
+TCGv t0, t1;
+TCGv_i32 fp0;
+
+/* Pre-conditions */
+switch (opc) {
+case OPC_GSLBX:
+case OPC_GSLHX:
+case OPC_GSLWX:
+case OPC_GSLDX:
+/* prefetch, implement as NOP */
+if (rt == 0) {
+return;
+}
+break;
+case OPC_GSSBX:
+case OPC_GSSHX:
+case OPC_GSSWX:
+case OPC_GSSDX:
+break;
+case OPC_GSLWXC1:
+#if defined(TARGET_MIPS64)
+case OPC_GSLDXC1:
+#endif
+check_cp1_enabled(ctx);
+/* prefetch, implement as NOP */
+if (rt == 0) {
+return;
+}
+break;
+case OPC_GSSWXC1:
+#if defined(TARGET_MIPS64)
+case OPC_GSSDXC1:
+#endif
+check_cp1_enabled(ctx);
+break;
+default:
+MIPS_INVAL("loongson_lsdc2");
+generate_exception_end(ctx, EXCP_RI);
+return;
+break;
+}
+
+t0 = tcg_temp_new();
+
+gen_base_offset_addr(ctx, t0, rs, offset);
+gen_op_addr_add(ctx, t0, cpu_gpr[rd], t0);
+
+switch (opc) {
+case OPC_GSLBX:
+tcg_gen_qemu_ld_tl(t0, t0, ctx->mem_idx, MO_SB);
+gen_store_gpr(t0, rt);
+break;
+case OPC_GSLHX:
+tcg_gen_qemu_ld_tl(t0, t0, ctx->mem_idx, MO_TESW |
+ctx->default_tcg_memop_mask);
+gen_store_gpr(t0, rt);
+break;
+case OPC_GSLWX:
+gen_base_offset_addr(ctx, t0, rs, offset);
+if (rd) {
+gen_op_addr_add(ctx, t0, cpu_gpr[rd], t0);
+}
+tcg_gen_qemu_ld_tl(t0, t0, ctx->mem_idx, MO_TESL |
+ctx->default_tcg_memop_mask);
+gen_store_gpr(t0, rt);
+break;
+#if defined(TARGET_MIPS64)
+case OPC_GSLDX:
+gen_base_offset_addr(ctx, t0, rs, offset);
+if (rd) {
+gen_op_addr_add(ctx, t0, cpu_gpr[rd], t0);
+}
+tcg_gen_qemu_ld_tl(t0, t0, ctx->mem_idx, MO_TEQ |
+ctx->default_tcg_memop_mask);
+gen_store_gpr(t0, rt);
+break;
+#endif
+case OPC_GSLWXC1:
+check_cp1_enabled(ctx);
+gen_base_offset_addr(ctx, t0, rs, offset);
+if (rd) {
+gen_op_addr_add(ctx, t0, cpu_gpr[rd], t0);
+}
+fp0 = tcg_temp_new_i32();
+tcg_gen_qemu_ld_i32(fp0, t0, ctx->mem_idx, MO_TESL |
+ctx->default_tcg_memop_mask);
+gen_store_fpr32(ctx, fp0, rt);
+tcg_temp_free_i32(fp0);
+break;
+#if defined(TARGET_MIPS64)
+case OPC_GSLDXC1:
+check_cp1_enabled(ctx);
+gen_base_offset_addr(ctx, t0, rs, offset);
+if (rd) {
+gen_op_addr_add(ctx, t0, cpu_gpr[rd], t0);
+}
+tcg_gen_qemu_ld_tl(t0, t0, ctx->mem_idx, MO_TEQ |
+ctx->default_tcg_memop_mask);
+gen_store_fpr64(ctx, t0, rt);
+break;
+#endif
+case OPC_GSSBX:
+t1 = tcg_te

Re: [PATCH v2 1/3] macio: don't reference serial_hd() directly within the device

2020-10-16 Thread Mark Cave-Ayland

On 16/10/2020 01:16, David Gibson wrote:


On Tue, Oct 13, 2020 at 12:49:20PM +0100, Mark Cave-Ayland wrote:

Instead use qdev_prop_set_chr() to configure the ESCC serial chardevs at the
Mac Old World and New World machine level.

Also remove the now obsolete comment referring to the use of serial_hd() and
the setting of user_creatable to false accordingly.

Signed-off-by: Mark Cave-Ayland 


Applied to ppc-for-5.2, thanks.


Ah okay, I was planning to send a separate qemu-macppc pull request myself with these 
patches plus some cherry-picks from Zoltan's patchset after some more testing. Does 
this mean you would prefer to take the patches directly yourself?



ATB,

Mark.



[PATCH V14 5/8] hw/mips: Implement fw_cfg_arch_key_name()

2020-10-16 Thread Huacai Chen
Implement fw_cfg_arch_key_name(), which returns the name of a
mips-specific key.

Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Huacai Chen 
Co-developed-by: Jiaxun Yang 
---
 hw/mips/fw_cfg.c| 35 +++
 hw/mips/fw_cfg.h| 19 +++
 hw/mips/meson.build |  2 +-
 3 files changed, 55 insertions(+), 1 deletion(-)
 create mode 100644 hw/mips/fw_cfg.c
 create mode 100644 hw/mips/fw_cfg.h

diff --git a/hw/mips/fw_cfg.c b/hw/mips/fw_cfg.c
new file mode 100644
index 00..67c4a74f4b
--- /dev/null
+++ b/hw/mips/fw_cfg.c
@@ -0,0 +1,35 @@
+/*
+ * QEMU fw_cfg helpers (MIPS specific)
+ *
+ * Copyright (c) 2020 Lemote, Inc.
+ *
+ * Author:
+ *   Huacai Chen (che...@lemote.com)
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/mips/fw_cfg.h"
+#include "hw/nvram/fw_cfg.h"
+
+const char *fw_cfg_arch_key_name(uint16_t key)
+{
+static const struct {
+uint16_t key;
+const char *name;
+} fw_cfg_arch_wellknown_keys[] = {
+{FW_CFG_MACHINE_VERSION, "machine_version"},
+{FW_CFG_CPU_FREQ, "cpu_frequency"},
+};
+
+for (size_t i = 0; i < ARRAY_SIZE(fw_cfg_arch_wellknown_keys); i++) {
+if (fw_cfg_arch_wellknown_keys[i].key == key) {
+return fw_cfg_arch_wellknown_keys[i].name;
+}
+}
+return NULL;
+}
diff --git a/hw/mips/fw_cfg.h b/hw/mips/fw_cfg.h
new file mode 100644
index 00..e317d5b9a3
--- /dev/null
+++ b/hw/mips/fw_cfg.h
@@ -0,0 +1,19 @@
+/*
+ * QEMU fw_cfg helpers (MIPS specific)
+ *
+ * Copyright (c) 2020 Huacai Chen
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#ifndef HW_MIPS_FW_CFG_H
+#define HW_MIPS_FW_CFG_H
+
+#include "hw/boards.h"
+#include "hw/nvram/fw_cfg.h"
+
+/* Data for BIOS to identify machine */
+#define FW_CFG_MACHINE_VERSION  (FW_CFG_ARCH_LOCAL + 0)
+#define FW_CFG_CPU_FREQ (FW_CFG_ARCH_LOCAL + 1)
+
+#endif
diff --git a/hw/mips/meson.build b/hw/mips/meson.build
index 46294b7382..c98391ce99 100644
--- a/hw/mips/meson.build
+++ b/hw/mips/meson.build
@@ -1,5 +1,5 @@
 mips_ss = ss.source_set()
-mips_ss.add(files('addr.c', 'mips_int.c'))
+mips_ss.add(files('addr.c', 'mips_int.c', 'fw_cfg.c'))
 mips_ss.add(when: 'CONFIG_FULOONG', if_true: files('fuloong2e.c'))
 mips_ss.add(when: 'CONFIG_JAZZ', if_true: files('jazz.c'))
 mips_ss.add(when: 'CONFIG_MALTA', if_true: files('gt64xxx_pci.c', 'malta.c'))
-- 
2.17.2




Re: [PATCH V14 0/8] mips: Add Loongson-3 machine support

2020-10-16 Thread no-reply
Patchew URL: 
https://patchew.org/QEMU/1602831120-3377-1-git-send-email-che...@lemote.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 1602831120-3377-1-git-send-email-che...@lemote.com
Subject: [PATCH V14 0/8] mips: Add Loongson-3 machine support

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag] patchew/1602831120-3377-1-git-send-email-che...@lemote.com 
-> patchew/1602831120-3377-1-git-send-email-che...@lemote.com
Switched to a new branch 'test'
d292df4 docs/system: Update MIPS machine documentation
4e63ead hw/mips: Add Loongson-3 machine support
1bf0737 hw/mips: Add Loongson-3 boot parameter helpers
bd43b2f hw/mips: Implement fw_cfg_arch_key_name()
f93634a target/mips: Add loongson-ext lsdc2 group of instructions
b55eee0 target/mips: Add loongson-ext lswc2 group of instructions (Part 2)
2c2eaaa target/mips: Add loongson-ext lswc2 group of instructions (Part 1)
ab68efd target/mips: Fix PageMask with variable page size

=== OUTPUT BEGIN ===
1/8 Checking commit ab68efdc70ef (target/mips: Fix PageMask with variable page 
size)
2/8 Checking commit 2c2eaaabbd3a (target/mips: Add loongson-ext lswc2 group of 
instructions (Part 1))
3/8 Checking commit b55eee07bfbe (target/mips: Add loongson-ext lswc2 group of 
instructions (Part 2))
4/8 Checking commit f93634a586de (target/mips: Add loongson-ext lsdc2 group of 
instructions)
5/8 Checking commit bd43b2ff95e9 (hw/mips: Implement fw_cfg_arch_key_name())
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#16: 
new file mode 100644

total: 0 errors, 1 warnings, 60 lines checked

Patch 5/8 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
6/8 Checking commit 1bf0737aee8c (hw/mips: Add Loongson-3 boot parameter 
helpers)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#15: 
new file mode 100644

WARNING: line over 80 characters
#47: FILE: hw/mips/loongson3_bootp.c:28:
+static struct efi_cpuinfo_loongson *init_cpu_info(void *g_cpuinfo, uint64_t 
cpu_freq)

WARNING: line over 80 characters
#66: FILE: hw/mips/loongson3_bootp.c:47:
+static struct efi_memory_map_loongson *init_memory_map(void *g_map, uint64_t 
ram_size)

total: 0 errors, 3 warnings, 394 lines checked

Patch 6/8 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
7/8 Checking commit 4e63ead64501 (hw/mips: Add Loongson-3 machine support)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#80: 
new file mode 100644

ERROR: line over 90 characters
#151: FILE: hw/mips/loongson3_virt.c:67:
+ * 3, 
http://www.anheng.com.cn/loongson/firmware-nonfree/uefi/loongson3-virt/bios_loongson3.bin

ERROR: line over 90 characters
#152: FILE: hw/mips/loongson3_virt.c:68:
+ * 4, 
http://mirrors.ustc.edu.cn/loongson/firmware-nonfree/uefi/loongson3-virt/bios_loongson3.bin

ERROR: line over 90 characters
#153: FILE: hw/mips/loongson3_virt.c:69:
+ * 5, 
http://mirrors.nju.edu.cn/loongson/firmware-nonfree/uefi/loongson3-virt/bios_loongson3.bin

ERROR: line over 90 characters
#154: FILE: hw/mips/loongson3_virt.c:70:
+ * 6, 
https://mirrors.tuna.tsinghua.edu.cn/loongson/firmware-nonfree/uefi/loongson3-virt/bios_loongson3.bin

ERROR: line over 90 characters
#155: FILE: hw/mips/loongson3_virt.c:71:
+ * 7, 
https://mirrors.bfsu.edu.cn/loongson/firmware-nonfree/uefi/loongson3-virt/bios_loongson3.bin

ERROR: line over 90 characters
#156: FILE: hw/mips/loongson3_virt.c:72:
+ * 8, 
https://mirrors.cloud.tencent.com/loongson/firmware-nonfree/uefi/loongson3-virt/bios_loongson3.bin

WARNING: line over 80 characters
#204: FILE: hw/mips/loongson3_virt.c:120:
+static void loongson3_pm_write(void *opaque, hwaddr addr, uint64_t val, 
unsigned size)

WARNING: line over 80 characters
#279: FILE: hw/mips/loongson3_virt.c:195:
+loaderparams.a2 = cpu_mips_phys_to_kseg0(NULL, 
loader_rommap[LOADER_PARAM].base);

WARNING: line over 80 characters
#361: FILE: hw/mips/loongson3_virt.c:277:
+fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, 
(uint16_t)current_machine->smp.max_cpus);

WARNING: line over 80 characters
#409: FILE: hw/mips/loongson3_virt.c:325:
+sprintf(highmemenv, "%ld", (unsigned long)(loaderparams.ram_size / MiB) - 
256);

WARNING: line over 80 characters
#495: FILE: hw/mips/loongson3_virt.c:411:
+static inline void loongson3_virt_devices_init(MachineState *machine, 
DeviceState *pic)

WARNING: line over 80 characters
#526: FILE: hw/mips/loongson3_virt.c:442:
+   

Re: [PATCH] meson: Only install icons and qemu.desktop if have_system

2020-10-16 Thread Paolo Bonzini
On 15/10/20 22:18, Bruce Rogers wrote:
> These files are not needed for a linux-user only install.
> 
> Signed-off-by: Bruce Rogers 
> ---
>  ui/meson.build | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/ui/meson.build b/ui/meson.build
> index 78ad792ffb..fb36d305ca 100644
> --- a/ui/meson.build
> +++ b/ui/meson.build
> @@ -113,8 +113,11 @@ if have_system or xkbcommon.found()
>  endif
>  
>  subdir('shader')
> -subdir('icons')
>  
> -install_data('qemu.desktop', install_dir: config_host['qemu_desktopdir'])
> +if have_system
> +  subdir('icons')
> +
> +  install_data('qemu.desktop', install_dir: config_host['qemu_desktopdir'])
> +endif
>  
>  modules += {'ui': ui_modules}
> 

Queued, thanks.

Paolo




Re: [PATCH v10 01/10] virtio-iommu: Fix virtio_iommu_mr()

2020-10-16 Thread Auger Eric
Hi Jean,

On 10/8/20 7:15 PM, Jean-Philippe Brucker wrote:
> Due to an invalid mask, virtio_iommu_mr() may return the wrong memory
> region. It hasn't been too problematic so far because the function was
> only used to test existence of an endpoint, but that is about to change.
> 
> Fixes: cfb42188b24d ("virtio-iommu: Implement attach/detach command")
> Signed-off-by: Jean-Philippe Brucker 
Maybe add
CC: QEMU Stable 

Acked-by: Eric Auger 

Thanks

Eric

> ---
>  hw/virtio/virtio-iommu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
> index a91fa2f674c..543fbbb24fb 100644
> --- a/hw/virtio/virtio-iommu.c
> +++ b/hw/virtio/virtio-iommu.c
> @@ -101,7 +101,7 @@ static IOMMUMemoryRegion *virtio_iommu_mr(VirtIOIOMMU *s, 
> uint32_t sid)
>  bus_n = PCI_BUS_NUM(sid);
>  iommu_pci_bus = iommu_find_iommu_pcibus(s, bus_n);
>  if (iommu_pci_bus) {
> -devfn = sid & PCI_DEVFN_MAX;
> +devfn = sid & (PCI_DEVFN_MAX - 1);
>  dev = iommu_pci_bus->pbdev[devfn];
>  if (dev) {
>  return &dev->iommu_mr;
> 




Re: [PATCH v10 02/10] virtio-iommu: Store memory region in endpoint struct

2020-10-16 Thread Auger Eric
Hi Jean,

On 10/8/20 7:15 PM, Jean-Philippe Brucker wrote:
> Store the memory region associated to each endpoint into the endpoint
> structure, to allow efficient memory notification on map/unmap.
> 
> Signed-off-by: Jean-Philippe Brucker 
Acked-by: Eric Auger 

> ---
> Not super confident about the reconstruct_endpoint() change since I
> haven't tested migration yet. Does it make sense?
It sounds good to me. I tested migration with vhost and this works properly.

Eric
> ---
>  hw/virtio/virtio-iommu.c | 11 ++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
> index 543fbbb24fb..33115e82186 100644
> --- a/hw/virtio/virtio-iommu.c
> +++ b/hw/virtio/virtio-iommu.c
> @@ -49,6 +49,7 @@ typedef struct VirtIOIOMMUDomain {
>  typedef struct VirtIOIOMMUEndpoint {
>  uint32_t id;
>  VirtIOIOMMUDomain *domain;
> +IOMMUMemoryRegion *iommu_mr;
>  QLIST_ENTRY(VirtIOIOMMUEndpoint) next;
>  } VirtIOIOMMUEndpoint;
>  
> @@ -137,16 +138,19 @@ static VirtIOIOMMUEndpoint 
> *virtio_iommu_get_endpoint(VirtIOIOMMU *s,
>uint32_t ep_id)
>  {
>  VirtIOIOMMUEndpoint *ep;
> +IOMMUMemoryRegion *mr;
>  
>  ep = g_tree_lookup(s->endpoints, GUINT_TO_POINTER(ep_id));
>  if (ep) {
>  return ep;
>  }
> -if (!virtio_iommu_mr(s, ep_id)) {
> +mr = virtio_iommu_mr(s, ep_id);
> +if (!mr) {
>  return NULL;
>  }
>  ep = g_malloc0(sizeof(*ep));
>  ep->id = ep_id;
> +ep->iommu_mr = mr;
>  trace_virtio_iommu_get_endpoint(ep_id);
>  g_tree_insert(s->endpoints, GUINT_TO_POINTER(ep_id), ep);
>  return ep;
> @@ -927,9 +931,14 @@ static gboolean reconstruct_endpoints(gpointer key, 
> gpointer value,
>  VirtIOIOMMU *s = (VirtIOIOMMU *)data;
>  VirtIOIOMMUDomain *d = (VirtIOIOMMUDomain *)value;
>  VirtIOIOMMUEndpoint *iter;
> +IOMMUMemoryRegion *mr;
>  
>  QLIST_FOREACH(iter, &d->endpoint_list, next) {
> +mr = virtio_iommu_mr(s, iter->id);
> +assert(mr);
> +
>  iter->domain = d;
> +iter->iommu_mr = mr;
>  g_tree_insert(s->endpoints, GUINT_TO_POINTER(iter->id), iter);
>  }
>  return false; /* continue the domain traversal */
> 




Re: [PATCH v4 3/4] meson: Move the detection logic for sphinx to meson

2020-10-16 Thread Paolo Bonzini
Here is a better way to write the meson test:

if get_option('sphinx_build') == ''
  sphinx_build = find_program(['sphinx-build-3', 'sphinx-build'],
  required: get_option('docs'))
else
  sphinx_build = find_program(get_option('sphinx_build'),
  required: get_option('docs'))
endif

SPHINX_ARGS = [sphinx_build]
# If we're making warnings fatal, apply this to Sphinx runs as well
if get_option('werror')
  SPHINX_TEST_ARGS += [ '-W' ]
endif

# Check if tools are available to build documentation.
build_docs = false
if sphinx_build.found()
  # This is a bit awkward but works: create a trivial document and
  # try to run it with our configuration file (which enforces a
  # version requirement). This will fail if sphinx-build is too old.
  run_command('mkdir', ['-p', tmpdir / 'sphinx'])
  run_command('touch', [tmpdir / 'sphinx/index.rst'])
  sphinx_build_test_out = run_command(SPHINX_ARGS + [
'-c', meson.current_source_dir() / 'docs',
'-b', 'html', tmpdir / 'sphinx',
tmpdir / 'sphinx/out'])
  build_docs = (sphinx_build_test_out.returncode() == 0)
endif

if not build_docs
  if sphinx_build_option != ''
warning('@0@ exists but it is either too old or uses too old a Python 
version'.format(sphinx_build_option))
  endif
  if get_option('docs').enabled()
error('Install a Python 3 version of python-sphinx')
  endif
endif



On 16/10/20 00:06, Yonggang Luo wrote:
> Signed-off-by: Yonggang Luo 
> ---
>  configure | 59 +++---
>  docs/meson.build  |  4 +--
>  meson.build   | 60 +++
>  meson_options.txt |  5 ++-
>  tests/qapi-schema/meson.build |  2 +-
>  5 files changed, 64 insertions(+), 66 deletions(-)
> 
> diff --git a/configure b/configure
> index 1ce31f97b4..ff593a8542 100755
> --- a/configure
> +++ b/configure
> @@ -297,7 +297,7 @@ brlapi=""
>  curl=""
>  iconv="auto"
>  curses="auto"
> -docs=""
> +docs="auto"
>  fdt="auto"
>  netmap="no"
>  sdl="auto"
> @@ -822,15 +822,6 @@ do
>  fi
>  done
>  
> -sphinx_build=
> -for binary in sphinx-build-3 sphinx-build
> -do
> -if has "$binary"
> -then
> -sphinx_build=$(command -v "$binary")
> -break
> -fi
> -done
>  
>  # Check for ancillary tools used in testing
>  genisoimage=
> @@ -1226,9 +1217,9 @@ for opt do
>;;
>--disable-crypto-afalg) crypto_afalg="no"
>;;
> -  --disable-docs) docs="no"
> +  --disable-docs) docs="disabled"
>;;
> -  --enable-docs) docs="yes"
> +  --enable-docs) docs="enabled"
>;;
>--disable-vhost-net) vhost_net="no"
>;;
> @@ -4413,45 +4404,6 @@ if check_include linux/btrfs.h ; then
>  btrfs=yes
>  fi
>  
> -# If we're making warnings fatal, apply this to Sphinx runs as well
> -sphinx_werror=""
> -if test "$werror" = "yes"; then
> -sphinx_werror="-W"
> -fi
> -
> -# Check we have a new enough version of sphinx-build
> -has_sphinx_build() {
> -# This is a bit awkward but works: create a trivial document and
> -# try to run it with our configuration file (which enforces a
> -# version requirement). This will fail if either
> -# sphinx-build doesn't exist at all or if it is too old.
> -mkdir -p "$TMPDIR1/sphinx"
> -touch "$TMPDIR1/sphinx/index.rst"
> -"$sphinx_build" $sphinx_werror -c "$source_path/docs" \
> --b html "$TMPDIR1/sphinx" \
> -"$TMPDIR1/sphinx/out"  >> config.log 2>&1
> -}
> -
> -# Check if tools are available to build documentation.
> -if test "$docs" != "no" ; then
> -  if has_sphinx_build; then
> -sphinx_ok=yes
> -  else
> -sphinx_ok=no
> -  fi
> -  if test "$sphinx_ok" = "yes"; then
> -docs=yes
> -  else
> -if test "$docs" = "yes" ; then
> -  if has $sphinx_build && test "$sphinx_ok" != "yes"; then
> -echo "Warning: $sphinx_build exists but it is either too old or uses 
> too old a Python version" >&2
> -  fi
> -  feature_not_found "docs" "Install a Python 3 version of python-sphinx"
> -fi
> -docs=no
> -  fi
> -fi
> -
>  # Search for bswap_32 function
>  byteswap_h=no
>  cat > $TMPC << EOF
> @@ -6087,9 +6039,6 @@ qemu_version=$(head $source_path/VERSION)
>  echo "PKGVERSION=$pkgversion" >>$config_host_mak
>  echo "SRC_PATH=$source_path" >> $config_host_mak
>  echo "TARGET_DIRS=$target_list" >> $config_host_mak
> -if [ "$docs" = "yes" ] ; then
> -  echo "BUILD_DOCS=yes" >> $config_host_mak
> -fi
>  if test "$modules" = "yes"; then
># $shacmd can generate a hash started with digit, which the compiler 
> doesn't
># like as an symbol. So prefix it with an underscore
> @@ -6794,7 +6743,6 @@ fi
>  echo "ROMS=$roms" >> $config_host_mak
>  echo "MAKE=$make" >> $config_host_mak
>  echo "PYTHON=$python" >> $config_host_mak
> -echo "SPHINX_BUILD=$sphinx_build" >> $config_host_mak
>  echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
>  echo "MESON=$meson" >> $config_host_mak
>  

Re: [PATCH v4 3/4] meson: Move the detection logic for sphinx to meson

2020-10-16 Thread Yonggang Luo
On Fri, Oct 16, 2020 at 3:46 PM Paolo Bonzini  wrote:
>
> Here is a better way to write the meson test:
>
> if get_option('sphinx_build') == ''
>   sphinx_build = find_program(['sphinx-build-3', 'sphinx-build'],
>   required: get_option('docs'))
> else
>   sphinx_build = find_program(get_option('sphinx_build'),
>   required: get_option('docs'))
> endif
>
> SPHINX_ARGS = [sphinx_build]
> # If we're making warnings fatal, apply this to Sphinx runs as well
> if get_option('werror')
>   SPHINX_TEST_ARGS += [ '-W' ]
> endif
>
> # Check if tools are available to build documentation.
> build_docs = false
> if sphinx_build.found()
>   # This is a bit awkward but works: create a trivial document and
>   # try to run it with our configuration file (which enforces a
>   # version requirement). This will fail if sphinx-build is too old.
>   run_command('mkdir', ['-p', tmpdir / 'sphinx'])
>   run_command('touch', [tmpdir / 'sphinx/index.rst'])
>   sphinx_build_test_out = run_command(SPHINX_ARGS + [
> '-c', meson.current_source_dir() / 'docs',
> '-b', 'html', tmpdir / 'sphinx',
> tmpdir / 'sphinx/out'])
>   build_docs = (sphinx_build_test_out.returncode() == 0)
> endif
There is subtle error here, when  sphinx_build not found, there is
SPHINX_ARGS  should be [],
otherwise, latter place using  SPHINX_ARGS  have not found sphinx_build
will cause error by meson
..
I'll add

else
  SPHINX_ARGS  = []
endif

>
> if not build_docs
>   if sphinx_build_option != ''
> warning('@0@ exists but it is either too old or uses too old a Python
version'.format(sphinx_build_option))
>   endif
>   if get_option('docs').enabled()
> error('Install a Python 3 version of python-sphinx')
>   endif
> endif
>
>
>
> On 16/10/20 00:06, Yonggang Luo wrote:
> > Signed-off-by: Yonggang Luo 
> > ---
> >  configure | 59 +++---
> >  docs/meson.build  |  4 +--
> >  meson.build   | 60 +++
> >  meson_options.txt |  5 ++-
> >  tests/qapi-schema/meson.build |  2 +-
> >  5 files changed, 64 insertions(+), 66 deletions(-)
> >
> > diff --git a/configure b/configure
> > index 1ce31f97b4..ff593a8542 100755
> > --- a/configure
> > +++ b/configure
> > @@ -297,7 +297,7 @@ brlapi=""
> >  curl=""
> >  iconv="auto"
> >  curses="auto"
> > -docs=""
> > +docs="auto"
> >  fdt="auto"
> >  netmap="no"
> >  sdl="auto"
> > @@ -822,15 +822,6 @@ do
> >  fi
> >  done
> >
> > -sphinx_build=
> > -for binary in sphinx-build-3 sphinx-build
> > -do
> > -if has "$binary"
> > -then
> > -sphinx_build=$(command -v "$binary")
> > -break
> > -fi
> > -done
> >
> >  # Check for ancillary tools used in testing
> >  genisoimage=
> > @@ -1226,9 +1217,9 @@ for opt do
> >;;
> >--disable-crypto-afalg) crypto_afalg="no"
> >;;
> > -  --disable-docs) docs="no"
> > +  --disable-docs) docs="disabled"
> >;;
> > -  --enable-docs) docs="yes"
> > +  --enable-docs) docs="enabled"
> >;;
> >--disable-vhost-net) vhost_net="no"
> >;;
> > @@ -4413,45 +4404,6 @@ if check_include linux/btrfs.h ; then
> >  btrfs=yes
> >  fi
> >
> > -# If we're making warnings fatal, apply this to Sphinx runs as well
> > -sphinx_werror=""
> > -if test "$werror" = "yes"; then
> > -sphinx_werror="-W"
> > -fi
> > -
> > -# Check we have a new enough version of sphinx-build
> > -has_sphinx_build() {
> > -# This is a bit awkward but works: create a trivial document and
> > -# try to run it with our configuration file (which enforces a
> > -# version requirement). This will fail if either
> > -# sphinx-build doesn't exist at all or if it is too old.
> > -mkdir -p "$TMPDIR1/sphinx"
> > -touch "$TMPDIR1/sphinx/index.rst"
> > -"$sphinx_build" $sphinx_werror -c "$source_path/docs" \
> > --b html "$TMPDIR1/sphinx" \
> > -"$TMPDIR1/sphinx/out"  >> config.log 2>&1
> > -}
> > -
> > -# Check if tools are available to build documentation.
> > -if test "$docs" != "no" ; then
> > -  if has_sphinx_build; then
> > -sphinx_ok=yes
> > -  else
> > -sphinx_ok=no
> > -  fi
> > -  if test "$sphinx_ok" = "yes"; then
> > -docs=yes
> > -  else
> > -if test "$docs" = "yes" ; then
> > -  if has $sphinx_build && test "$sphinx_ok" != "yes"; then
> > -echo "Warning: $sphinx_build exists but it is either too old
or uses too old a Python version" >&2
> > -  fi
> > -  feature_not_found "docs" "Install a Python 3 version of
python-sphinx"
> > -fi
> > -docs=no
> > -  fi
> > -fi
> > -
> >  # Search for bswap_32 function
> >  byteswap_h=no
> >  cat > $TMPC << EOF
> > @@ -6087,9 +6039,6 @@ qemu_version=$(head $source_path/VERSION)
> >  echo "PKGVERSION=$pkgversion" >>$config_host_mak
> >  echo "SRC_PATH=$source_path" >> $config_host_mak
> >  echo "TARGET_DIRS=$target_list" >> $config_host_mak
> > -if [ "$docs

Re: [PATCH v4 3/4] meson: Move the detection logic for sphinx to meson

2020-10-16 Thread Paolo Bonzini
On 16/10/20 09:52, 罗勇刚(Yonggang Luo) wrote:
> 
>> build_docs = false
>> if sphinx_build.found()
>>   # This is a bit awkward but works: create a trivial document and
>>   # try to run it with our configuration file (which enforces a
>>   # version requirement). This will fail if sphinx-build is too old.
>>   run_command('mkdir', ['-p', tmpdir / 'sphinx'])
>>   run_command('touch', [tmpdir / 'sphinx/index.rst'])
>>   sphinx_build_test_out = run_command(SPHINX_ARGS + [
>>     '-c', meson.current_source_dir() / 'docs',
>>     '-b', 'html', tmpdir / 'sphinx',
>>     tmpdir / 'sphinx/out'])
>>   build_docs = (sphinx_build_test_out.returncode() == 0)
>> endif
> There is subtle error here, when  sphinx_build not found, there is
> SPHINX_ARGS  should be [],
> otherwise, latter place using  SPHINX_ARGS  have not found sphinx_build
> will cause error by meson
> ..
> I'll add
> 
> else
>   SPHINX_ARGS  = []  
> endif

All uses of SPHINX_ARGS are protected by build_docs, and in turn
build_docs is false if "not sphinx_build.found()".  Am I missing something?

Paolo




Re: [PATCH v10 03/10] virtio-iommu: Add memory notifiers for map/unmap

2020-10-16 Thread Auger Eric
Hi Jean,

On 10/8/20 7:15 PM, Jean-Philippe Brucker wrote:
> From: Bharat Bhushan 
> 
> Extend VIRTIO_IOMMU_T_MAP/UNMAP request to notify memory listeners. It
> will call VFIO notifier to map/unmap regions in the physical IOMMU.
> 
> Signed-off-by: Bharat Bhushan 
> Signed-off-by: Eric Auger 
> Signed-off-by: Jean-Philippe Brucker 
> ---
> v10:
> * Use the flags from IOMMUMemoryRegion
> * Pass virt_start/virt_end rather than size, to avoid dealing with
>   overflow and for consistency.
> ---
>  hw/virtio/virtio-iommu.c | 53 
>  hw/virtio/trace-events   |  2 ++
>  2 files changed, 55 insertions(+)
> 
> diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
> index 33115e82186..fcdf3a819f8 100644
> --- a/hw/virtio/virtio-iommu.c
> +++ b/hw/virtio/virtio-iommu.c
> @@ -125,6 +125,49 @@ static gint interval_cmp(gconstpointer a, gconstpointer 
> b, gpointer user_data)
>  }
>  }
>  
> +static void virtio_iommu_notify_map(IOMMUMemoryRegion *mr, hwaddr virt_start,
> +hwaddr virt_end, hwaddr paddr)
> +{
> +IOMMUTLBEntry entry;
> +IOMMUNotifierFlag flags = mr->iommu_notify_flags;
> +
> +if (!(flags & IOMMU_NOTIFIER_MAP)) {
> +return;
> +}
> +
> +trace_virtio_iommu_notify_map(mr->parent_obj.name, virt_start, virt_end,
> +  paddr);
> +
> +entry.target_as = &address_space_memory;
> +entry.addr_mask = virt_end - virt_start;
> +entry.iova = virt_start;
> +entry.perm = IOMMU_RW;
logically you should be able to cascade the struct virtio_iommu_req_map
*req flags field instead.
> +entry.translated_addr = paddr;
> +
> +memory_region_notify_iommu(mr, 0, entry);
> +}
> +
> +static void virtio_iommu_notify_unmap(IOMMUMemoryRegion *mr, hwaddr 
> virt_start,
> +  hwaddr virt_end)
> +{
> +IOMMUTLBEntry entry;
> +IOMMUNotifierFlag flags = mr->iommu_notify_flags;
> +
> +if (!(flags & IOMMU_NOTIFIER_UNMAP)) {
> +return;
> +}
> +
> +trace_virtio_iommu_notify_unmap(mr->parent_obj.name, virt_start, 
> virt_end);
> +
> +entry.target_as = &address_space_memory;
> +entry.addr_mask = virt_end - virt_start;
> +entry.iova = virt_start;
> +entry.perm = IOMMU_NONE;
> +entry.translated_addr = 0;
> +
> +memory_region_notify_iommu(mr, 0, entry);
> +}
> +
>  static void virtio_iommu_detach_endpoint_from_domain(VirtIOIOMMUEndpoint *ep)
>  {
>  if (!ep->domain) {
> @@ -315,6 +358,7 @@ static int virtio_iommu_map(VirtIOIOMMU *s,
>  VirtIOIOMMUDomain *domain;
>  VirtIOIOMMUInterval *interval;
>  VirtIOIOMMUMapping *mapping;
> +VirtIOIOMMUEndpoint *ep;
>  
>  if (flags & ~VIRTIO_IOMMU_MAP_F_MASK) {
>  return VIRTIO_IOMMU_S_INVAL;
> @@ -344,6 +388,10 @@ static int virtio_iommu_map(VirtIOIOMMU *s,
>  
>  g_tree_insert(domain->mappings, interval, mapping);
>  
> +QLIST_FOREACH(ep, &domain->endpoint_list, next) {
> +virtio_iommu_notify_map(ep->iommu_mr, virt_start, virt_end, 
> phys_start);
> +}
> +
>  return VIRTIO_IOMMU_S_OK;
>  }
>  
> @@ -356,6 +404,7 @@ static int virtio_iommu_unmap(VirtIOIOMMU *s,
>  VirtIOIOMMUMapping *iter_val;
>  VirtIOIOMMUInterval interval, *iter_key;
>  VirtIOIOMMUDomain *domain;
> +VirtIOIOMMUEndpoint *ep;
>  int ret = VIRTIO_IOMMU_S_OK;
>  
>  trace_virtio_iommu_unmap(domain_id, virt_start, virt_end);
> @@ -373,6 +422,10 @@ static int virtio_iommu_unmap(VirtIOIOMMU *s,
>  uint64_t current_high = iter_key->high;
>  
>  if (interval.low <= current_low && interval.high >= current_high) {
> +QLIST_FOREACH(ep, &domain->endpoint_list, next) {
> +virtio_iommu_notify_unmap(ep->iommu_mr, current_low,
> +  current_high);
> +}
>  g_tree_remove(domain->mappings, iter_key);
>  trace_virtio_iommu_unmap_done(domain_id, current_low, 
> current_high);
>  } else {
> diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events
> index cf1e59de302..65a48555c78 100644
> --- a/hw/virtio/trace-events
> +++ b/hw/virtio/trace-events
> @@ -106,6 +106,8 @@ virtio_iommu_put_domain(uint32_t domain_id) "Free 
> domain=%d"
>  virtio_iommu_translate_out(uint64_t virt_addr, uint64_t phys_addr, uint32_t 
> sid) "0x%"PRIx64" -> 0x%"PRIx64 " for sid=%d"
>  virtio_iommu_report_fault(uint8_t reason, uint32_t flags, uint32_t endpoint, 
> uint64_t addr) "FAULT reason=%d flags=%d endpoint=%d address =0x%"PRIx64
>  virtio_iommu_fill_resv_property(uint32_t devid, uint8_t subtype, uint64_t 
> start, uint64_t end) "dev= %d, type=%d start=0x%"PRIx64" end=0x%"PRIx64
> +virtio_iommu_notify_map(const char *name, uint64_t virt_start, uint64_t 
> virt_end, uint64_t phys_start) "mr=%s virt_start=0x%"PRIx64" 
> virt_end=0x%"PRIx64" phys_start=0x%"PRIx64
> +virtio_iommu_notify_unmap(const char *name, uint64_t virt_start,

Re: [PATCH v4 3/4] meson: Move the detection logic for sphinx to meson

2020-10-16 Thread Yonggang Luo
On Fri, Oct 16, 2020 at 3:57 PM Paolo Bonzini  wrote:
>
> On 16/10/20 09:52, 罗勇刚(Yonggang Luo) wrote:
> >
> >> build_docs = false
> >> if sphinx_build.found()
> >>   # This is a bit awkward but works: create a trivial document and
> >>   # try to run it with our configuration file (which enforces a
> >>   # version requirement). This will fail if sphinx-build is too old.
> >>   run_command('mkdir', ['-p', tmpdir / 'sphinx'])
> >>   run_command('touch', [tmpdir / 'sphinx/index.rst'])
> >>   sphinx_build_test_out = run_command(SPHINX_ARGS + [
> >> '-c', meson.current_source_dir() / 'docs',
> >> '-b', 'html', tmpdir / 'sphinx',
> >> tmpdir / 'sphinx/out'])
> >>   build_docs = (sphinx_build_test_out.returncode() == 0)
> >> endif
> > There is subtle error here, when  sphinx_build not found, there is
> > SPHINX_ARGS  should be [],
> > otherwise, latter place using  SPHINX_ARGS  have not found sphinx_build
> > will cause error by meson
> > ..
> > I'll add
> >
> > else
> >   SPHINX_ARGS  = []
> > endif
>
> All uses of SPHINX_ARGS are protected by build_docs, and in turn
> build_docs is false if "not sphinx_build.found()".  Am I missing
something?
Not all protected, missed in qapi/schema tests
>
> Paolo
>


--
 此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo


[PATCH] hax: unbreak accelerator cpu code after cpus.c split

2020-10-16 Thread Claudio Fontana
during my split of cpus.c, code line
"current_cpu = cpu"
was removed by mistake, causing hax to break.

This commit fixes the situation restoring it.

Reported-by: Volker Rümelin 
Fixes: e92558e4bf8059ce4f0b310afe218802b72766bc
Signed-off-by: Claudio Fontana 
---
 target/i386/hax-cpus.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/i386/hax-cpus.c b/target/i386/hax-cpus.c
index 99770e590c..f72c85bd49 100644
--- a/target/i386/hax-cpus.c
+++ b/target/i386/hax-cpus.c
@@ -38,6 +38,7 @@ static void *hax_cpu_thread_fn(void *arg)
 qemu_thread_get_self(cpu->thread);
 
 cpu->thread_id = qemu_get_thread_id();
+current_cpu = cpu;
 hax_init_vcpu(cpu);
 cpu_thread_signal_created(cpu);
 qemu_guest_random_seed_thread_part2(cpu->random_seed);
-- 
2.26.2




Re: [PATCH v4 3/4] meson: Move the detection logic for sphinx to meson

2020-10-16 Thread Yonggang Luo
On Fri, Oct 16, 2020 at 3:57 PM Paolo Bonzini  wrote:
>
> On 16/10/20 09:52, 罗勇刚(Yonggang Luo) wrote:
> >
> >> build_docs = false
> >> if sphinx_build.found()
> >>   # This is a bit awkward but works: create a trivial document and
> >>   # try to run it with our configuration file (which enforces a
> >>   # version requirement). This will fail if sphinx-build is too old.
> >>   run_command('mkdir', ['-p', tmpdir / 'sphinx'])
> >>   run_command('touch', [tmpdir / 'sphinx/index.rst'])
> >>   sphinx_build_test_out = run_command(SPHINX_ARGS + [
> >> '-c', meson.current_source_dir() / 'docs',
> >> '-b', 'html', tmpdir / 'sphinx',
> >> tmpdir / 'sphinx/out'])
> >>   build_docs = (sphinx_build_test_out.returncode() == 0)
> >> endif
> > There is subtle error here, when  sphinx_build not found, there is
> > SPHINX_ARGS  should be [],
> > otherwise, latter place using  SPHINX_ARGS  have not found sphinx_build
> > will cause error by meson
> > ..
> > I'll add
> >
> > else
> >   SPHINX_ARGS  = []
> > endif
>
> All uses of SPHINX_ARGS are protected by build_docs, and in turn
> build_docs is false if "not sphinx_build.found()".  Am I missing
something?
>
> Paolo
>
Rfer to
https://github.com/lygstate/qemu/runs/1261141240?check_suite_focus=true

--
 此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo


Re: [PULL 07/37] cpus: extract out hax-specific code to target/i386/

2020-10-16 Thread Claudio Fontana
On 10/16/20 8:48 AM, Volker Rümelin wrote:
>> From: Claudio Fontana 
>>
>> register a "CpusAccel" interface for HAX as well.
>>
> 
>> diff --git a/softmmu/cpus.c b/softmmu/cpus.c
>> index 9fa73735a2..900fff827a 100644
>> --- a/softmmu/cpus.c
>> +++ b/softmmu/cpus.c
>> @@ -416,35 +403,6 @@ void qemu_wait_io_event(CPUState *cpu)
>>  qemu_wait_io_event_common(cpu);
>>  }
>>  
>> -static void *qemu_hax_cpu_thread_fn(void *arg)
>> -{
>> -CPUState *cpu = arg;
>> -int r;
>> -
>> -rcu_register_thread();
>> -qemu_mutex_lock_iothread();
>> -qemu_thread_get_self(cpu->thread);
>> -
>> -cpu->thread_id = qemu_get_thread_id();
>> -current_cpu = cpu;
> 
> Hi Claudio,
> 
> is there a reason why you removed current_cpu = cpu; from hax_cpu_thread_fn() 
> when you moved that function to target/i386/hax-cpus.c? This change broke HAX 
> on Windows. Adding back that line makes it work again.


Hello Volker, I see the change in the history and it was clearly an ugly 
mistake on my part.
There was no reason or intention to remove the current_cpu = cpu assignment

The fix seems indeed to just + current_cpu = cpu;
and I will send a patch momentarily that does just that,

but I don't know of any CI coverage for Windows + hax currently,
so it would be good if you could spin the change to verify that it fixes the 
problem.

Ciao,

Claudio

> 
> The simplest reproducer is:
> $ ./qemu-system-x86_64.exe -machine pc,accel=hax -smp 2 -display gtk
> HAX is working and emulator runs in fast virt mode.
> 
> Then the QEMU window opens and shows 'Guest has not initialized the display 
> (yet).' forever.
> 
> A look at the Windows Task Manager suggests one thread is busy looping.
> 
> With best regards,
> Volker
> 
>> -hax_init_vcpu(cpu);
>> -cpu_thread_signal_created(cpu);
>> -qemu_guest_random_seed_thread_part2(cpu->random_seed);
>> -
>> -do {
>> -if (cpu_can_run(cpu)) {
>> -r = hax_smp_cpu_exec(cpu);
>> -if (r == EXCP_DEBUG) {
>> -cpu_handle_guest_debug(cpu);
>> -}
>> -}
>> -
>> -qemu_wait_io_event(cpu);
>> -} while (!cpu->unplug || cpu_can_run(cpu));
>> -rcu_unregister_thread();
>> -return NULL;
>> -}
>> -
>>  /* The HVF-specific vCPU thread function. This one should only run when the 
>> host
>>   * CPU supports the VMX "unrestricted guest" feature. */
>>  static void *qemu_hvf_cpu_thread_fn(void *arg)
>>




Re: [PATCH v4 3/4] meson: Move the detection logic for sphinx to meson

2020-10-16 Thread Paolo Bonzini
On 16/10/20 09:57, Paolo Bonzini wrote:
> On 16/10/20 09:52, 罗勇刚(Yonggang Luo) wrote:
>>
>>> build_docs = false
>>> if sphinx_build.found()
>>>   # This is a bit awkward but works: create a trivial document and
>>>   # try to run it with our configuration file (which enforces a
>>>   # version requirement). This will fail if sphinx-build is too old.
>>>   run_command('mkdir', ['-p', tmpdir / 'sphinx'])
>>>   run_command('touch', [tmpdir / 'sphinx/index.rst'])
>>>   sphinx_build_test_out = run_command(SPHINX_ARGS + [
>>>     '-c', meson.current_source_dir() / 'docs',
>>>     '-b', 'html', tmpdir / 'sphinx',
>>>     tmpdir / 'sphinx/out'])
>>>   build_docs = (sphinx_build_test_out.returncode() == 0)
>>> endif
>> There is subtle error here, when  sphinx_build not found, there is
>> SPHINX_ARGS  should be [],
>> otherwise, latter place using  SPHINX_ARGS  have not found sphinx_build
>> will cause error by meson
>> ..
>> I'll add
>>
>> else
>>   SPHINX_ARGS  = []  
>> endif
> 
> All uses of SPHINX_ARGS are protected by build_docs, and in turn
> build_docs is false if "not sphinx_build.found()".  Am I missing something?

Ah there are uses in tests/ too, those should all be under "if
build_docs" too.

Paolo




Re: [PATCH v10 04/10] virtio-iommu: Call memory notifiers in attach/detach

2020-10-16 Thread Auger Eric
Hi jean,

On 10/8/20 7:15 PM, Jean-Philippe Brucker wrote:
> From: Bharat Bhushan 
> 
> Call the memory notifiers when attaching an endpoint to a domain, to
> replay existing mappings, and when detaching the endpoint, to remove all
> mappings.
> 
> Signed-off-by: Bharat Bhushan 
> Signed-off-by: Jean-Philippe Brucker 
> ---
> v10: Remove notifiers_list, rename callbacks
> ---
>  hw/virtio/virtio-iommu.c | 32 
>  1 file changed, 32 insertions(+)
> 
> diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
> index fcdf3a819f8..7e6e3cf5200 100644
> --- a/hw/virtio/virtio-iommu.c
> +++ b/hw/virtio/virtio-iommu.c
> @@ -168,11 +168,39 @@ static void virtio_iommu_notify_unmap(IOMMUMemoryRegion 
> *mr, hwaddr virt_start,
>  memory_region_notify_iommu(mr, 0, entry);
>  }
>  
> +static gboolean virtio_iommu_notify_unmap_cb(gpointer key, gpointer value,
> + gpointer data)
> +{
> +VirtIOIOMMUInterval *interval = (VirtIOIOMMUInterval *) key;
> +IOMMUMemoryRegion *mr = (IOMMUMemoryRegion *) data;
> +
> +virtio_iommu_notify_unmap(mr, interval->low, interval->high);
> +
> +return false;
> +}
> +
> +static gboolean virtio_iommu_notify_map_cb(gpointer key, gpointer value,
> +   gpointer data)
> +{
> +VirtIOIOMMUMapping *mapping = (VirtIOIOMMUMapping *) value;
> +VirtIOIOMMUInterval *interval = (VirtIOIOMMUInterval *) key;
> +IOMMUMemoryRegion *mr = (IOMMUMemoryRegion *) data;
> +
> +virtio_iommu_notify_map(mr, interval->low, interval->high,
> +mapping->phys_addr);
Here also I think we should apply the mapping->flags.
> +
> +return false;
> +}
> +
>  static void virtio_iommu_detach_endpoint_from_domain(VirtIOIOMMUEndpoint *ep)
>  {
> +VirtIOIOMMUDomain *domain = ep->domain;
> +
>  if (!ep->domain) {
>  return;
>  }
> +g_tree_foreach(domain->mappings, virtio_iommu_notify_unmap_cb,
> +   ep->iommu_mr);
>  QLIST_REMOVE(ep, next);
>  ep->domain = NULL;
>  }
> @@ -315,6 +343,10 @@ static int virtio_iommu_attach(VirtIOIOMMU *s,
>  
>  ep->domain = domain;
>  
> +/* Replay domain mappings on the associated memory region */
> +g_tree_foreach(domain->mappings, virtio_iommu_notify_map_cb,
> +   ep->iommu_mr);
> +
>  return VIRTIO_IOMMU_S_OK;
>  }
>  
> 
Thanks

Eric




Re: [PATCH] hax: unbreak accelerator cpu code after cpus.c split

2020-10-16 Thread Paolo Bonzini
On 16/10/20 10:00, Claudio Fontana wrote:
> during my split of cpus.c, code line
> "current_cpu = cpu"
> was removed by mistake, causing hax to break.
> 
> This commit fixes the situation restoring it.
> 
> Reported-by: Volker Rümelin 
> Fixes: e92558e4bf8059ce4f0b310afe218802b72766bc
> Signed-off-by: Claudio Fontana 
> ---
>  target/i386/hax-cpus.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/target/i386/hax-cpus.c b/target/i386/hax-cpus.c
> index 99770e590c..f72c85bd49 100644
> --- a/target/i386/hax-cpus.c
> +++ b/target/i386/hax-cpus.c
> @@ -38,6 +38,7 @@ static void *hax_cpu_thread_fn(void *arg)
>  qemu_thread_get_self(cpu->thread);
>  
>  cpu->thread_id = qemu_get_thread_id();
> +current_cpu = cpu;
>  hax_init_vcpu(cpu);
>  cpu_thread_signal_created(cpu);
>  qemu_guest_random_seed_thread_part2(cpu->random_seed);
> 

Queued, thanks.

Paolo




Re: [PATCH v4 3/4] meson: Move the detection logic for sphinx to meson

2020-10-16 Thread Yonggang Luo
On Fri, Oct 16, 2020 at 4:05 PM Paolo Bonzini  wrote:
>
> On 16/10/20 09:57, Paolo Bonzini wrote:
> > On 16/10/20 09:52, 罗勇刚(Yonggang Luo) wrote:
> >>
> >>> build_docs = false
> >>> if sphinx_build.found()
> >>>   # This is a bit awkward but works: create a trivial document and
> >>>   # try to run it with our configuration file (which enforces a
> >>>   # version requirement). This will fail if sphinx-build is too old.
> >>>   run_command('mkdir', ['-p', tmpdir / 'sphinx'])
> >>>   run_command('touch', [tmpdir / 'sphinx/index.rst'])
> >>>   sphinx_build_test_out = run_command(SPHINX_ARGS + [
> >>> '-c', meson.current_source_dir() / 'docs',
> >>> '-b', 'html', tmpdir / 'sphinx',
> >>> tmpdir / 'sphinx/out'])
> >>>   build_docs = (sphinx_build_test_out.returncode() == 0)
> >>> endif
> >> There is subtle error here, when  sphinx_build not found, there is
> >> SPHINX_ARGS  should be [],
> >> otherwise, latter place using  SPHINX_ARGS  have not found sphinx_build
> >> will cause error by meson
> >> ..
> >> I'll add
> >>
> >> else
> >>   SPHINX_ARGS  = []
> >> endif
> >
> > All uses of SPHINX_ARGS are protected by build_docs, and in turn
> > build_docs is false if "not sphinx_build.found()".  Am I missing
something?
>
> Ah there are uses in tests/ too, those should all be under "if
> build_docs" too.
Yeap, I did it before, but that changes a lot and not easy to review, you
can do it in separate patch.
Anyway setting  SPHINX_ARGS  to [] are more robust.
>
> Paolo
>


--
 此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo


[PATCH v5 2/4] configure: the docdir option should passed to meson as is.

2020-10-16 Thread Yonggang Luo
Signed-off-by: Yonggang Luo 
---
 configure | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/configure b/configure
index 78062fb091..432ea124e1 100755
--- a/configure
+++ b/configure
@@ -968,7 +968,7 @@ for opt do
   ;;
   --with-suffix=*) qemu_suffix="$optarg"
   ;;
-  --docdir=*) qemu_docdir="$optarg"
+  --docdir=*) docdir="$optarg"
   ;;
   --sysconfdir=*) sysconfdir="$optarg"
   ;;
@@ -5710,7 +5710,6 @@ fi
 qemu_confdir="$sysconfdir/$qemu_suffix"
 qemu_moddir="$libdir/$qemu_suffix"
 qemu_datadir="$datadir/$qemu_suffix"
-qemu_docdir="$docdir/$qemu_suffix"
 qemu_localedir="$datadir/locale"
 qemu_icondir="$datadir/icons"
 qemu_desktopdir="$datadir/applications"
-- 
2.28.0.windows.1




[PATCH v5 3/4] meson: Move the detection logic for sphinx to meson

2020-10-16 Thread Yonggang Luo
Signed-off-by: Yonggang Luo 
---
 configure | 59 +++
 docs/meson.build  |  4 +--
 meson.build   | 52 ++
 meson_options.txt |  5 ++-
 tests/qapi-schema/meson.build |  2 +-
 5 files changed, 57 insertions(+), 65 deletions(-)

diff --git a/configure b/configure
index 432ea124e1..c499c968cb 100755
--- a/configure
+++ b/configure
@@ -297,7 +297,7 @@ brlapi=""
 curl=""
 iconv="auto"
 curses="auto"
-docs=""
+docs="auto"
 fdt="auto"
 netmap="no"
 sdl="auto"
@@ -819,15 +819,6 @@ do
 fi
 done
 
-sphinx_build=
-for binary in sphinx-build-3 sphinx-build
-do
-if has "$binary"
-then
-sphinx_build=$(command -v "$binary")
-break
-fi
-done
 
 # Check for ancillary tools used in testing
 genisoimage=
@@ -1223,9 +1214,9 @@ for opt do
   ;;
   --disable-crypto-afalg) crypto_afalg="no"
   ;;
-  --disable-docs) docs="no"
+  --disable-docs) docs="disabled"
   ;;
-  --enable-docs) docs="yes"
+  --enable-docs) docs="enabled"
   ;;
   --disable-vhost-net) vhost_net="no"
   ;;
@@ -4408,45 +4399,6 @@ if check_include linux/btrfs.h ; then
 btrfs=yes
 fi
 
-# If we're making warnings fatal, apply this to Sphinx runs as well
-sphinx_werror=""
-if test "$werror" = "yes"; then
-sphinx_werror="-W"
-fi
-
-# Check we have a new enough version of sphinx-build
-has_sphinx_build() {
-# This is a bit awkward but works: create a trivial document and
-# try to run it with our configuration file (which enforces a
-# version requirement). This will fail if either
-# sphinx-build doesn't exist at all or if it is too old.
-mkdir -p "$TMPDIR1/sphinx"
-touch "$TMPDIR1/sphinx/index.rst"
-"$sphinx_build" $sphinx_werror -c "$source_path/docs" \
--b html "$TMPDIR1/sphinx" \
-"$TMPDIR1/sphinx/out"  >> config.log 2>&1
-}
-
-# Check if tools are available to build documentation.
-if test "$docs" != "no" ; then
-  if has_sphinx_build; then
-sphinx_ok=yes
-  else
-sphinx_ok=no
-  fi
-  if test "$sphinx_ok" = "yes"; then
-docs=yes
-  else
-if test "$docs" = "yes" ; then
-  if has $sphinx_build && test "$sphinx_ok" != "yes"; then
-echo "Warning: $sphinx_build exists but it is either too old or uses 
too old a Python version" >&2
-  fi
-  feature_not_found "docs" "Install a Python 3 version of python-sphinx"
-fi
-docs=no
-  fi
-fi
-
 # Search for bswap_32 function
 byteswap_h=no
 cat > $TMPC << EOF
@@ -6027,9 +5979,6 @@ qemu_version=$(head $source_path/VERSION)
 echo "PKGVERSION=$pkgversion" >>$config_host_mak
 echo "SRC_PATH=$source_path" >> $config_host_mak
 echo "TARGET_DIRS=$target_list" >> $config_host_mak
-if [ "$docs" = "yes" ] ; then
-  echo "BUILD_DOCS=yes" >> $config_host_mak
-fi
 if test "$modules" = "yes"; then
   # $shacmd can generate a hash started with digit, which the compiler doesn't
   # like as an symbol. So prefix it with an underscore
@@ -6702,7 +6651,6 @@ fi
 echo "ROMS=$roms" >> $config_host_mak
 echo "MAKE=$make" >> $config_host_mak
 echo "PYTHON=$python" >> $config_host_mak
-echo "SPHINX_BUILD=$sphinx_build" >> $config_host_mak
 echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
 echo "MESON=$meson" >> $config_host_mak
 echo "NINJA=$ninja" >> $config_host_mak
@@ -6984,6 +6932,7 @@ NINJA=$ninja $meson setup \
 -Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f \
 -Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt \
 -Diconv=$iconv -Dcurses=$curses \
+-Ddocs=$docs -Dsphinx_build=$sphinx_build \
 $cross_arg \
 "$PWD" "$source_path"
 
diff --git a/docs/meson.build b/docs/meson.build
index 0340d489ac..f566809a6a 100644
--- a/docs/meson.build
+++ b/docs/meson.build
@@ -37,7 +37,7 @@ if build_docs
 input: [files('conf.py'), files(manual / 'conf.py')],
 depfile: manual + '.d',
 depend_files: sphinx_extn_depends,
-command: [SPHINX_ARGS, '-Ddepfile=@DEPFILE@',
+command: SPHINX_ARGS + ['-Ddepfile=@DEPFILE@',
   '-Ddepfile_stamp=@OUTPUT0@',
   '-b', 'html', '-d', private_dir,
   input_dir, output_dir])
@@ -59,7 +59,7 @@ if build_docs
  input: this_manual,
  install: build_docs,
  install_dir: install_dirs,
- command: [SPHINX_ARGS, '-b', 'man', '-d', private_dir,
+ command: SPHINX_ARGS + ['-b', 'man', '-d', 
private_dir,
input_dir, meson.current_build_dir()])
 endif
   endforeach
diff --git a/meson.build b/meson.build
index 6cb8fe2882..70e6d59af4 100644
--- a/meson.build
+++ b/meson.build
@@ -17,7 +17,13 @@ cc = meson.get_compiler('c')
 config_host = keyval.load(meson.current_build_dir() / 'config-host.mak')
 enable_modules = 'CONFIG

[PATCH v5 1/4] docs: Fixes build docs on msys2/mingw

2020-10-16 Thread Yonggang Luo
meson didn't support running ../scripts/kernel-do directly
Add the perl as the first parameter

Signed-off-by: Yonggang Luo 
---
 docs/sphinx/kerneldoc.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/sphinx/kerneldoc.py b/docs/sphinx/kerneldoc.py
index 3e87940206..af130d0939 100644
--- a/docs/sphinx/kerneldoc.py
+++ b/docs/sphinx/kerneldoc.py
@@ -67,7 +67,7 @@ class KernelDocDirective(Directive):
 
 def run(self):
 env = self.state.document.settings.env
-cmd = [env.config.kerneldoc_bin, '-rst', '-enable-lineno']
+cmd = ['perl', env.config.kerneldoc_bin, '-rst', '-enable-lineno']
 
 filename = env.config.kerneldoc_srctree + '/' + self.arguments[0]
 export_file_patterns = []
-- 
2.28.0.windows.1




[PATCH v5 0/4] Fixes docs building on msys2/mingw

2020-10-16 Thread Yonggang Luo
V4-V5
Revise * docs: Fixes build docs on msys2/mingw
For easier to review.
Revise * meson: Move the detection logic for sphinx to meson
According Paolo's suggestion with fixes.

V3-V4
Quic fixes of
python style
if xxx:

tested locally

V2-V3
No need convert perl trick to python script anymore
after Paolo's removal of ninjatool.
Revise Meson: Move the detection logic for sphinx to meson
for pass other platform by letting SPHINX_ARGS to be empty
when build_docs are false

v1 - v2
Also move the docs configure part from
configure to meson, this also fixed the pending
ninjatool removal caused issue that docs  can
not be build under msys2/mingw

Yonggang Luo (4):
  docs: Fixes build docs on msys2/mingw
  configure: the docdir option should passed to meson as is.
  meson: Move the detection logic for sphinx to meson
  cirrus: Enable doc build on msys2/mingw

 .cirrus.yml   |  6 +++-
 configure | 62 +++
 docs/meson.build  |  4 +--
 docs/sphinx/kerneldoc.py  |  2 +-
 meson.build   | 52 +
 meson_options.txt |  5 ++-
 tests/qapi-schema/meson.build |  2 +-
 7 files changed, 64 insertions(+), 69 deletions(-)

-- 
2.28.0.windows.1




[PATCH v5 4/4] cirrus: Enable doc build on msys2/mingw

2020-10-16 Thread Yonggang Luo
Currently rST depends on old version sphinx-2.x.
Install it by downloading it.
Remove the need of university mirror, the main repo are recovered.

Signed-off-by: Yonggang Luo 
---
 .cirrus.yml | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/.cirrus.yml b/.cirrus.yml
index 9ccd2749ce..0481d99bb6 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -76,7 +76,6 @@ windows_msys2_task:
 ((Get-Content -path 
C:\tools\msys64\etc\\post-install\\07-pacman-key.post -Raw) -replace 
'--refresh-keys', '--version') | Set-Content -Path 
C:\tools\msys64\etc\\post-install\\07-pacman-key.post
 C:\tools\msys64\usr\bin\bash.exe -lc "sed -i 
's/^CheckSpace/#CheckSpace/g' /etc/pacman.conf"
 C:\tools\msys64\usr\bin\bash.exe -lc "export"
-C:\tools\msys64\usr\bin\bash.exe -lc "grep -rl 'repo.msys2.org/' 
/etc/pacman.d/mirrorlist.* | xargs sed -i 
's/repo.msys2.org\//mirrors.tuna.tsinghua.edu.cn\/msys2\//g'"
 C:\tools\msys64\usr\bin\pacman.exe --noconfirm -Sy
 echo Y | C:\tools\msys64\usr\bin\pacman.exe --noconfirm -Suu 
--overwrite=*
 taskkill /F /FI "MODULES eq msys-2.0.dll"
@@ -112,6 +111,11 @@ windows_msys2_task:
   mingw-w64-x86_64-gnutls \
   mingw-w64-x86_64-libnfs \
   "
+bitsadmin /transfer msys_download /dynamic /download /priority 
FOREGROUND `
+  
https://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-python-sphinx-2.3.1-1-any.pkg.tar.xz
 `
+  C:\tools\mingw-w64-x86_64-python-sphinx-2.3.1-1-any.pkg.tar.xz
+C:\tools\msys64\usr\bin\bash.exe -lc "pacman --noconfirm -U 
/c/tools/mingw-w64-x86_64-python-sphinx-2.3.1-1-any.pkg.tar.xz"
+del C:\tools\mingw-w64-x86_64-python-sphinx-2.3.1-1-any.pkg.tar.xz
 C:\tools\msys64\usr\bin\bash.exe -lc "rm -rf /var/cache/pacman/pkg/*"
 cd C:\tools\msys64
 echo "Start archive"
-- 
2.28.0.windows.1




Re: [PATCH v10 06/10] virtio-iommu: Add notify_flag_changed() memory region callback

2020-10-16 Thread Auger Eric
Hi Jean,

On 10/8/20 7:15 PM, Jean-Philippe Brucker wrote:
> From: Bharat Bhushan 
> 
> Add notify_flag_changed() to notice when memory listeners are added and
> removed.
> 
> Signed-off-by: Bharat Bhushan 
> Signed-off-by: Jean-Philippe Brucker 
> ---
> v10:
> * Use notifier flags instead of notifiers_list
> * Homogenize tracepoints
> ---
>  hw/virtio/virtio-iommu.c | 14 ++
>  hw/virtio/trace-events   |  2 ++
>  2 files changed, 16 insertions(+)
> 
> diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
> index d2b96846134..8823bfc804a 100644
> --- a/hw/virtio/virtio-iommu.c
> +++ b/hw/virtio/virtio-iommu.c
> @@ -901,6 +901,19 @@ unlock:
>  qemu_mutex_unlock(&s->mutex);
>  }
>  
> +static int virtio_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu_mr,
> +IOMMUNotifierFlag old,
> +IOMMUNotifierFlag new,
> +Error **errp)
> +{
> +if (old == IOMMU_NOTIFIER_NONE) {
> +trace_virtio_iommu_notify_flag_add(iommu_mr->parent_obj.name);
> +} else if (new == IOMMU_NOTIFIER_NONE) {
> +trace_virtio_iommu_notify_flag_del(iommu_mr->parent_obj.name);
> +}
> +return 0;
> +}
> +
>  static void virtio_iommu_device_realize(DeviceState *dev, Error **errp)
>  {
>  VirtIODevice *vdev = VIRTIO_DEVICE(dev);
> @@ -1132,6 +1145,7 @@ static void 
> virtio_iommu_memory_region_class_init(ObjectClass *klass,
>  
>  imrc->translate = virtio_iommu_translate;
>  imrc->replay = virtio_iommu_replay;
> +imrc->notify_flag_changed = virtio_iommu_notify_flag_changed;
>  }
>  
>  static const TypeInfo virtio_iommu_info = {
> diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events
> index 16f4729db4b..9108992bcc3 100644
> --- a/hw/virtio/trace-events
> +++ b/hw/virtio/trace-events
> @@ -109,6 +109,8 @@ virtio_iommu_fill_resv_property(uint32_t devid, uint8_t 
> subtype, uint64_t start,
>  virtio_iommu_notify_map(const char *name, uint64_t virt_start, uint64_t 
> virt_end, uint64_t phys_start) "mr=%s virt_start=0x%"PRIx64" 
> virt_end=0x%"PRIx64" phys_start=0x%"PRIx64
>  virtio_iommu_notify_unmap(const char *name, uint64_t virt_start, uint64_t 
> virt_end) "mr=%s virt_start=0x%"PRIx64" virt_end=0x%"PRIx64
>  virtio_iommu_remap(const char *name, uint64_t virt_start, uint64_t virt_end, 
> uint64_t phys_start) "mr=%s virt_start=0x%"PRIx64" virt_end=0x%"PRIx64" 
> phys_start=0x%"PRIx64
> +virtio_iommu_notify_flag_add(const char *name) "add notifier mr=%s"
Maybe "add notifier %d to mr=%s"
> +virtio_iommu_notify_flag_del(const char *name) "del notifier mr=%s"
from?
>  
>  # virtio-mem.c
>  virtio_mem_send_response(uint16_t type) "type=%" PRIu16
> 

Besides
Acked-by: Eric Auger 

Thanks

Eric




Re: [PATCH] hax: unbreak accelerator cpu code after cpus.c split

2020-10-16 Thread Philippe Mathieu-Daudé
Le ven. 16 oct. 2020 10:03, Claudio Fontana  a écrit :

> during my split of cpus.c, code line
> "current_cpu = cpu"
> was removed by mistake, causing hax to break.
>
> This commit fixes the situation restoring it.
>
> Reported-by: Volker Rümelin 
> Fixes: e92558e4bf8059ce4f0b310afe218802b72766bc
> Signed-off-by: Claudio Fontana 
>

Reviewed-by: Philippe Mathieu-Daudé 

---
>  target/i386/hax-cpus.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/target/i386/hax-cpus.c b/target/i386/hax-cpus.c
> index 99770e590c..f72c85bd49 100644
> --- a/target/i386/hax-cpus.c
> +++ b/target/i386/hax-cpus.c
> @@ -38,6 +38,7 @@ static void *hax_cpu_thread_fn(void *arg)
>  qemu_thread_get_self(cpu->thread);
>
>  cpu->thread_id = qemu_get_thread_id();
> +current_cpu = cpu;
>  hax_init_vcpu(cpu);
>  cpu_thread_signal_created(cpu);
>  qemu_guest_random_seed_thread_part2(cpu->random_seed);
> --
> 2.26.2
>
>
>


Re: [PATCH] meson: Only install icons and qemu.desktop if have_system

2020-10-16 Thread Philippe Mathieu-Daudé
Le jeu. 15 oct. 2020 22:22, Bruce Rogers  a écrit :

> These files are not needed for a linux-user only install.


> Signed-off-by: Bruce Rogers 
> ---
>  ui/meson.build | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/ui/meson.build b/ui/meson.build
> index 78ad792ffb..fb36d305ca 100644
> --- a/ui/meson.build
> +++ b/ui/meson.build
> @@ -113,8 +113,11 @@ if have_system or xkbcommon.found()
>  endif
>
>  subdir('shader')
> -subdir('icons')
>
> -install_data('qemu.desktop', install_dir: config_host['qemu_desktopdir'])
> +if have_system
>

Some tools could have an icon, QSD later?

For now:
Reviewed-by: Philippe Mathieu-Daudé 

+  subdir('icons')
> +
> +  install_data('qemu.desktop', install_dir:
> config_host['qemu_desktopdir'])
> +endif
>
>  modules += {'ui': ui_modules}
> --
> 2.28.0
>
>
>


Re: [PATCH v5 2/2] hw/arm/sbsa-ref: add SBSA watchdog device

2020-10-16 Thread Graeme Gregory
On Thu, Oct 15, 2020 at 06:21:09PM +0300, Maxim Uvarov wrote:
> On Thu, 15 Oct 2020 at 17:12, Graeme Gregory  wrote:
> >
> > On Wed, Oct 14, 2020 at 01:04:43PM -0400, Shashi Mallela wrote:
> > > This was added as a placeholder for the virt requirement suggested by 
> > > Maxim
> > > earlier.Agreed that this fdt otherwise has no significance for sbsa-ref
> > > platform nor is being used by ACPI table created for wdt.
> > >
> > > -Shashi
> > >
> > > On Wed, 14 Oct 2020 at 05:31, Graeme Gregory <[1]gra...@nuviainc.com> 
> > > wrote:
> > >
> > > On Tue, Oct 13, 2020 at 11:16:31AM -0400, Shashi Mallela wrote:
> > > > Included the newly implemented SBSA generic watchdog device model 
> > > into
> > > > SBSA platform
> > > >
> > > > Signed-off-by: Shashi Mallela <[2]shashi.mall...@linaro.org>
> > > > ---
> > > >  hw/arm/sbsa-ref.c | 50 
> > > +++
> > > >  1 file changed, 50 insertions(+)
> > > >
> > > > diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
> > > > index 9c3a893bedfd..97ed41607119 100644
> > > > --- a/hw/arm/sbsa-ref.c
> > > > +++ b/hw/arm/sbsa-ref.c
> > > > @@ -30,6 +30,7 @@
> > > >  #include "exec/hwaddr.h"
> > > >  #include "kvm_arm.h"
> > > >  #include "hw/arm/boot.h"
> > > > +#include "hw/arm/fdt.h"
> > > >  #include "hw/block/flash.h"
> > > >  #include "hw/boards.h"
> > > >  #include "hw/ide/internal.h"
> > > > @@ -40,6 +41,7 @@
> > > >  #include "hw/qdev-properties.h"
> > > >  #include "hw/usb.h"
> > > >  #include "hw/char/pl011.h"
> > > > +#include "hw/watchdog/wdt_sbsa_gwdt.h"
> > > >  #include "net/net.h"
> > > >  #include "qom/object.h"
> > > >
> > > > @@ -64,6 +66,9 @@ enum {
> > > >  SBSA_GIC_DIST,
> > > >  SBSA_GIC_REDIST,
> > > >  SBSA_SECURE_EC,
> > > > +SBSA_GWDT,
> > > > +SBSA_GWDT_REFRESH,
> > > > +SBSA_GWDT_CONTROL,
> > > >  SBSA_SMMU,
> > > >  SBSA_UART,
> > > >  SBSA_RTC,
> > > > @@ -104,6 +109,8 @@ static const MemMapEntry sbsa_ref_memmap[] = {
> > > >  [SBSA_GIC_DIST] =   { 0x4006, 0x0001 },
> > > >  [SBSA_GIC_REDIST] = { 0x4008, 0x0400 },
> > > >  [SBSA_SECURE_EC] =  { 0x5000, 0x1000 },
> > > > +[SBSA_GWDT_REFRESH] =   { 0x5001, 0x1000 },
> > > > +[SBSA_GWDT_CONTROL] =   { 0x50011000, 0x1000 },
> > > >  [SBSA_UART] =   { 0x6000, 0x1000 },
> > > >  [SBSA_RTC] ={ 0x6001, 0x1000 },
> > > >  [SBSA_GPIO] =   { 0x6002, 0x1000 },
> > > > @@ -133,6 +140,8 @@ static const int sbsa_ref_irqmap[] = {
> > > >  [SBSA_SECURE_UART_MM] = 9,
> > > >  [SBSA_AHCI] = 10,
> > > >  [SBSA_EHCI] = 11,
> > > > +[SBSA_SMMU] = 12, /* ... to 15 */
> > > > +[SBSA_GWDT] = 16,
> > > >  };
> >
> > I guess your patch was not based on master here? You should make sure
> > you are rebased to the latest version before sending.
> >
> > > >
> > > >  static uint64_t sbsa_ref_cpu_mp_affinity(SBSAMachineState *sms, 
> > > int idx)
> > > > @@ -141,6 +150,30 @@ static uint64_t sbsa_ref_cpu_mp_affinity
> > > (SBSAMachineState *sms, int idx)
> > > >  return arm_cpu_mp_affinity(idx, clustersz);
> > > >  }
> > > >
> > > > +static void create_wdt_fdt(SBSAMachineState *sms)
> > > > +{
> > > > +char *nodename;
> > > > +const char compat[] = "arm,sbsa-gwdt";
> > > > +
> > > > +hwaddr rbase = sbsa_ref_memmap[SBSA_GWDT_REFRESH].base;
> > > > +hwaddr cbase = sbsa_ref_memmap[SBSA_GWDT_CONTROL].base;
> > > > +int irq = sbsa_ref_irqmap[SBSA_GWDT];
> > > > +
> > > > +nodename = g_strdup_printf("/watchdog@%" PRIx64, rbase);
> > > > +qemu_fdt_add_subnode(sms->fdt, nodename);
> > > > +
> > > > +qemu_fdt_setprop(sms->fdt, nodename, "compatible",
> > > > + compat, sizeof(compat));
> > > > +qemu_fdt_setprop_sized_cells(sms->fdt, nodename, "reg",
> > > > + 2, rbase, 2, SBSA_GWDT_RMMIO_SIZE,
> > > > + 2, cbase, 2, 
> > > SBSA_GWDT_CMMIO_SIZE);
> > > > +qemu_fdt_setprop_cells(sms->fdt, nodename, "interrupts",
> > > > +GIC_FDT_IRQ_TYPE_PPI, irq,
> > > > +GIC_FDT_IRQ_FLAGS_LEVEL_HI);
> > > > +qemu_fdt_setprop_cell(sms->fdt, nodename, "timeout-sec", 30);
> > > > +g_free(nodename);
> > > > +}
> > > > +
> > >
> > > Is this actually used anywhere? I ask because SBSA-ref is not a FDT
> > > booting machine and only uses FDT to transfer some dynamic info to
> > > arm-tf/edk2 and is not a full description tree. Your ACPI patch in
> > > 

Re: [PATCH v10 05/10] virtio-iommu: Add replay() memory region callback

2020-10-16 Thread Auger Eric
Hi Jean,

On 10/8/20 7:15 PM, Jean-Philippe Brucker wrote:
> From: Bharat Bhushan 
> 
> Implement the replay callback to setup all mappings for a new memory
> region.
> 
> Signed-off-by: Bharat Bhushan 
> Signed-off-by: Jean-Philippe Brucker 
> ---
> v10: Homogenize tracepoint arguments
> ---
>  hw/virtio/virtio-iommu.c | 41 
>  hw/virtio/trace-events   |  1 +
>  2 files changed, 42 insertions(+)
> 
> diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
> index 7e6e3cf5200..d2b96846134 100644
> --- a/hw/virtio/virtio-iommu.c
> +++ b/hw/virtio/virtio-iommu.c
> @@ -861,6 +861,46 @@ static gint int_cmp(gconstpointer a, gconstpointer b, 
> gpointer user_data)
>  return (ua > ub) - (ua < ub);
>  }
>  
> +static gboolean virtio_iommu_remap(gpointer key, gpointer value, gpointer 
> data)
> +{
> +VirtIOIOMMUMapping *mapping = (VirtIOIOMMUMapping *) value;
> +VirtIOIOMMUInterval *interval = (VirtIOIOMMUInterval *) key;
> +IOMMUMemoryRegion *mr = (IOMMUMemoryRegion *) data;
> +
> +trace_virtio_iommu_remap(mr->parent_obj.name, interval->low, 
> interval->high,
> + mapping->phys_addr);
> +virtio_iommu_notify_unmap(mr, interval->low, interval->high);
> +virtio_iommu_notify_map(mr, interval->low, interval->high,
> +mapping->phys_addr);
I don't get the preliminary unmap with the same data. Why isn't the map
sufficient to replay?

The default implementation only notifies for valid entries.
> +return false;
> +}
> +
> +static void virtio_iommu_replay(IOMMUMemoryRegion *mr, IOMMUNotifier *n)
> +{
> +IOMMUDevice *sdev = container_of(mr, IOMMUDevice, iommu_mr);
> +VirtIOIOMMU *s = sdev->viommu;
> +uint32_t sid;
> +VirtIOIOMMUEndpoint *ep;
> +
> +sid = virtio_iommu_get_bdf(sdev);
> +
> +qemu_mutex_lock(&s->mutex);
> +
> +if (!s->endpoints) {
> +goto unlock;
> +}
> +
> +ep = g_tree_lookup(s->endpoints, GUINT_TO_POINTER(sid));
> +if (!ep || !ep->domain) {
> +goto unlock;
> +}
> +
> +g_tree_foreach(ep->domain->mappings, virtio_iommu_remap, mr);
> +
> +unlock:
> +qemu_mutex_unlock(&s->mutex);
> +}
> +
>  static void virtio_iommu_device_realize(DeviceState *dev, Error **errp)
>  {
>  VirtIODevice *vdev = VIRTIO_DEVICE(dev);
> @@ -1091,6 +1131,7 @@ static void 
> virtio_iommu_memory_region_class_init(ObjectClass *klass,
>  IOMMUMemoryRegionClass *imrc = IOMMU_MEMORY_REGION_CLASS(klass);
>  
>  imrc->translate = virtio_iommu_translate;
> +imrc->replay = virtio_iommu_replay;
>  }
>  
>  static const TypeInfo virtio_iommu_info = {
> diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events
> index 65a48555c78..16f4729db4b 100644
> --- a/hw/virtio/trace-events
> +++ b/hw/virtio/trace-events
> @@ -108,6 +108,7 @@ virtio_iommu_report_fault(uint8_t reason, uint32_t flags, 
> uint32_t endpoint, uin
>  virtio_iommu_fill_resv_property(uint32_t devid, uint8_t subtype, uint64_t 
> start, uint64_t end) "dev= %d, type=%d start=0x%"PRIx64" end=0x%"PRIx64
>  virtio_iommu_notify_map(const char *name, uint64_t virt_start, uint64_t 
> virt_end, uint64_t phys_start) "mr=%s virt_start=0x%"PRIx64" 
> virt_end=0x%"PRIx64" phys_start=0x%"PRIx64
>  virtio_iommu_notify_unmap(const char *name, uint64_t virt_start, uint64_t 
> virt_end) "mr=%s virt_start=0x%"PRIx64" virt_end=0x%"PRIx64
> +virtio_iommu_remap(const char *name, uint64_t virt_start, uint64_t virt_end, 
> uint64_t phys_start) "mr=%s virt_start=0x%"PRIx64" virt_end=0x%"PRIx64" 
> phys_start=0x%"PRIx64
>  
>  # virtio-mem.c
>  virtio_mem_send_response(uint16_t type) "type=%" PRIu16
> 
Thanks

Eric




[PATCH] meson: move SPHINX_ARGS references within "if build_docs"

2020-10-16 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 tests/qapi-schema/meson.build | 88 +--
 1 file changed, 44 insertions(+), 44 deletions(-)

diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build
index 1f222a7a13..66c7f04cf8 100644
--- a/tests/qapi-schema/meson.build
+++ b/tests/qapi-schema/meson.build
@@ -219,53 +219,53 @@ qapi_doc = custom_target('QAPI doc',
 '-p', 'doc-good-', '@INPUT0@' ],
  depend_files: qapi_gen_depends)
 
-# Test the document-comment document generation code by running a test schema
-# file through Sphinx's plain-text builder and comparing the result against
-# a golden reference. This is in theory susceptible to failures if Sphinx
-# changes its output, but the text output has historically been very stable
-# (no changes between Sphinx 1.6 and 3.0), so it is a better bet than
-# texinfo or HTML generation, both of which have had changes. We might
-# need to add more sophisticated logic here in future for some sort of
-# fuzzy comparison if future Sphinx versions produce different text,
-# but for now the simple comparison suffices.
-qapi_doc_out = custom_target('QAPI rST doc',
- output: ['doc-good.txt'],
- input: files('doc-good.json', 'doc-good.rst'),
- build_by_default: build_docs,
- depend_files: sphinx_extn_depends,
- # We use -E to suppress Sphinx's caching, because
- # we want it to always really run the QAPI doc
- # generation code. It also means we don't
- # clutter up the build dir with the cache.
- command: [SPHINX_ARGS,
-   '-b', 'text', '-E',
-   '-c', meson.source_root() / 'docs',
-   '-D', 'master_doc=doc-good',
-   meson.current_source_dir(),
-   meson.current_build_dir()])
+if build_docs
+  # Test the document-comment document generation code by running a test schema
+  # file through Sphinx's plain-text builder and comparing the result against
+  # a golden reference. This is in theory susceptible to failures if Sphinx
+  # changes its output, but the text output has historically been very stable
+  # (no changes between Sphinx 1.6 and 3.0), so it is a better bet than
+  # texinfo or HTML generation, both of which have had changes. We might
+  # need to add more sophisticated logic here in future for some sort of
+  # fuzzy comparison if future Sphinx versions produce different text,
+  # but for now the simple comparison suffices.
+  qapi_doc_out = custom_target('QAPI rST doc',
+   output: ['doc-good.txt'],
+   input: files('doc-good.json', 'doc-good.rst'),
+   build_by_default: true,
+   depend_files: sphinx_extn_depends,
+   # We use -E to suppress Sphinx's caching, 
because
+   # we want it to always really run the QAPI doc
+   # generation code. It also means we don't
+   # clutter up the build dir with the cache.
+   command: [SPHINX_ARGS,
+ '-b', 'text', '-E',
+ '-c', meson.source_root() / 'docs',
+ '-D', 'master_doc=doc-good',
+ meson.current_source_dir(),
+ meson.current_build_dir()])
 
-# Fix possible inconsistency in line endings in generated output and
-# in the golden reference (which could otherwise cause test failures
-# on Windows hosts). Unfortunately diff --strip-trailing-cr
-# is GNU-diff only. The odd-looking perl is because we must avoid
-# using an explicit '\' character in the command arguments to
-# a custom_target(), as Meson will unhelpfully replace it with a '/'
-# (https://github.com/mesonbuild/meson/issues/1564)
-qapi_doc_out_nocr = custom_target('QAPI rST doc newline-sanitized',
-  output: ['doc-good.txt.nocr'],
-  input: qapi_doc_out[0],
-  build_by_default: build_docs,
-  command: ['perl', '-pe', '$x = chr 13; 
s/$x$//', '@INPUT@'],
-  capture: true)
+  # Fix possible inconsistency in line endings in generated output and
+  # in the golden reference (which could otherwise cause test failures
+  # on Windows hosts). Unfortunately diff --strip-trailing-cr
+  # is GNU-diff only. The odd-looking perl is because we must

Re: [PATCH v10 07/10] memory: Add interface to set iommu page size mask

2020-10-16 Thread Auger Eric
Hi Jean,

On 10/8/20 7:15 PM, Jean-Philippe Brucker wrote:
> From: Bharat Bhushan 
> 
> Allow to set the page size mask supported by an iommu memory region.
> This enables a vIOMMU to communicate the page size granule supported by
> an assigned device, on hosts that use page sizes greater than 4kB.
> 
> Signed-off-by: Bharat Bhushan 
> Signed-off-by: Jean-Philippe Brucker 
> ---
> v10: Add errp parameter
> ---
>  include/exec/memory.h | 26 ++
>  softmmu/memory.c  | 13 +
>  2 files changed, 39 insertions(+)
> 
> diff --git a/include/exec/memory.h b/include/exec/memory.h
> index dee09851622..c2da8381bec 100644
> --- a/include/exec/memory.h
> +++ b/include/exec/memory.h
> @@ -382,6 +382,20 @@ struct IOMMUMemoryRegionClass {
>   * @iommu: the IOMMUMemoryRegion
>   */
>  int (*num_indexes)(IOMMUMemoryRegion *iommu);
> +
> +/*
> + * Set supported IOMMU page size
> + *
> + * If supported, allows to restrict the page size mask that can be 
> supported
To match other docs: Optional method:
> + * with a given IOMMU memory region. For example, to propagate host 
> physical
> + * IOMMU page size mask limitations to the virtual IOMMU.
> + *
> + * Returns 0 on success, or a negative error. In case of failure, the 
> error
> + * object must be created.
document args as done for other functions?
> + */
> + int (*iommu_set_page_size_mask)(IOMMUMemoryRegion *iommu,
> + uint64_t page_size_mask,
> + Error **errp);
>  };
>  
>  typedef struct CoalescedMemoryRange CoalescedMemoryRange;
> @@ -1389,6 +1403,18 @@ int 
> memory_region_iommu_attrs_to_index(IOMMUMemoryRegion *iommu_mr,
>   */
>  int memory_region_iommu_num_indexes(IOMMUMemoryRegion *iommu_mr);
>  
> +/**
> + * memory_region_iommu_set_page_size_mask: set the supported page
> + * sizes for a given IOMMU memory region
> + *
> + * @iommu_mr: IOMMU memory region
> + * @page_size_mask: supported page size mask
> + * @errp: pointer to Error*, to store an error if it happens.
> + */
> +int memory_region_iommu_set_page_size_mask(IOMMUMemoryRegion *iommu_mr,
> +   uint64_t page_size_mask,
> +   Error **errp);
> +
>  /**
>   * memory_region_name: get a memory region's name
>   *
> diff --git a/softmmu/memory.c b/softmmu/memory.c
> index fa280a19f7f..5c855a02704 100644
> --- a/softmmu/memory.c
> +++ b/softmmu/memory.c
> @@ -1811,6 +1811,19 @@ static int 
> memory_region_update_iommu_notify_flags(IOMMUMemoryRegion *iommu_mr,
>  return ret;
>  }
>  
> +int memory_region_iommu_set_page_size_mask(IOMMUMemoryRegion *iommu_mr,
> +   uint64_t page_size_mask,
> +   Error **errp)
> +{
> +IOMMUMemoryRegionClass *imrc = IOMMU_MEMORY_REGION_GET_CLASS(iommu_mr);
> +int ret = 0;
> +
> +if (imrc->iommu_set_page_size_mask) {
> +ret = imrc->iommu_set_page_size_mask(iommu_mr, page_size_mask, errp);
> +}
> +return ret;
> +}
> +
>  int memory_region_register_iommu_notifier(MemoryRegion *mr,
>IOMMUNotifier *n, Error **errp)
>  {
> 
Besides

Reviewed-by: Eric Auger 

Thanks

Eric




Re: [PATCH] meson: move SPHINX_ARGS references within "if build_docs"

2020-10-16 Thread Philippe Mathieu-Daudé
Le ven. 16 oct. 2020 11:15, Paolo Bonzini  a écrit :

> Signed-off-by: Paolo Bonzini 
>

Reviewed-by: Philippe Mathieu-Daudé 

---
>  tests/qapi-schema/meson.build | 88 +--
>  1 file changed, 44 insertions(+), 44 deletions(-)
>
> diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build
> index 1f222a7a13..66c7f04cf8 100644
> --- a/tests/qapi-schema/meson.build
> +++ b/tests/qapi-schema/meson.build
> @@ -219,53 +219,53 @@ qapi_doc = custom_target('QAPI doc',
>  '-p', 'doc-good-', '@INPUT0@' ],
>   depend_files: qapi_gen_depends)
>
> -# Test the document-comment document generation code by running a test
> schema
> -# file through Sphinx's plain-text builder and comparing the result
> against
> -# a golden reference. This is in theory susceptible to failures if Sphinx
> -# changes its output, but the text output has historically been very
> stable
> -# (no changes between Sphinx 1.6 and 3.0), so it is a better bet than
> -# texinfo or HTML generation, both of which have had changes. We might
> -# need to add more sophisticated logic here in future for some sort of
> -# fuzzy comparison if future Sphinx versions produce different text,
> -# but for now the simple comparison suffices.
> -qapi_doc_out = custom_target('QAPI rST doc',
> - output: ['doc-good.txt'],
> - input: files('doc-good.json',
> 'doc-good.rst'),
> - build_by_default: build_docs,
> - depend_files: sphinx_extn_depends,
> - # We use -E to suppress Sphinx's caching,
> because
> - # we want it to always really run the QAPI
> doc
> - # generation code. It also means we don't
> - # clutter up the build dir with the cache.
> - command: [SPHINX_ARGS,
> -   '-b', 'text', '-E',
> -   '-c', meson.source_root() / 'docs',
> -   '-D', 'master_doc=doc-good',
> -   meson.current_source_dir(),
> -   meson.current_build_dir()])
> +if build_docs
> +  # Test the document-comment document generation code by running a test
> schema
> +  # file through Sphinx's plain-text builder and comparing the result
> against
> +  # a golden reference. This is in theory susceptible to failures if
> Sphinx
> +  # changes its output, but the text output has historically been very
> stable
> +  # (no changes between Sphinx 1.6 and 3.0), so it is a better bet than
> +  # texinfo or HTML generation, both of which have had changes. We might
> +  # need to add more sophisticated logic here in future for some sort of
> +  # fuzzy comparison if future Sphinx versions produce different text,
> +  # but for now the simple comparison suffices.
> +  qapi_doc_out = custom_target('QAPI rST doc',
> +   output: ['doc-good.txt'],
> +   input: files('doc-good.json',
> 'doc-good.rst'),
> +   build_by_default: true,
> +   depend_files: sphinx_extn_depends,
> +   # We use -E to suppress Sphinx's caching,
> because
> +   # we want it to always really run the QAPI
> doc
> +   # generation code. It also means we don't
> +   # clutter up the build dir with the cache.
> +   command: [SPHINX_ARGS,
> + '-b', 'text', '-E',
> + '-c', meson.source_root() /
> 'docs',
> + '-D', 'master_doc=doc-good',
> + meson.current_source_dir(),
> + meson.current_build_dir()])
>
> -# Fix possible inconsistency in line endings in generated output and
> -# in the golden reference (which could otherwise cause test failures
> -# on Windows hosts). Unfortunately diff --strip-trailing-cr
> -# is GNU-diff only. The odd-looking perl is because we must avoid
> -# using an explicit '\' character in the command arguments to
> -# a custom_target(), as Meson will unhelpfully replace it with a '/'
> -# (https://github.com/mesonbuild/meson/issues/1564)
> -qapi_doc_out_nocr = custom_target('QAPI rST doc newline-sanitized',
> -  output: ['doc-good.txt.nocr'],
> -  input: qapi_doc_out[0],
> -  build_by_default: build_docs,
> -  command: ['perl', '-pe', '$x = chr 13;
> s/$x$//', '@INPUT@'],
> -  capture: true)
>

Re: [PATCH v10 08/10] vfio: Set IOMMU page size as per host supported page size

2020-10-16 Thread Auger Eric
Hi Jean,
On 10/8/20 7:15 PM, Jean-Philippe Brucker wrote:
> From: Bharat Bhushan 
> 
> Set IOMMU supported page size mask same as host Linux supported page
> size mask.
> 
> Signed-off-by: Bharat Bhushan 
> Signed-off-by: Jean-Philippe Brucker 
Reviewed-by: Eric Auger 

Thanks

Eric
> ---
>  hw/vfio/common.c | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> index 13471ae2943..e66054b02a7 100644
> --- a/hw/vfio/common.c
> +++ b/hw/vfio/common.c
> @@ -636,6 +636,14 @@ static void vfio_listener_region_add(MemoryListener 
> *listener,
>  int128_get64(llend),
>  iommu_idx);
>  
> +ret = memory_region_iommu_set_page_size_mask(giommu->iommu,
> + container->pgsizes,
> + &err);
> +if (ret) {
> +g_free(giommu);
> +goto fail;
> +}
> +
>  ret = memory_region_register_iommu_notifier(section->mr, &giommu->n,
>  &err);
>  if (ret) {
> 




Re: [PATCH 0/7] build: replace ninjatool with ninja

2020-10-16 Thread Mark Cave-Ayland

On 15/10/2020 22:41, Paolo Bonzini wrote:

Il gio 15 ott 2020, 20:49 Mark Cave-Ayland > ha scritto:


Is there any reason why
https://lists.gnu.org/archive/html/qemu-devel/2020-09/msg06997.html
 still 
can't be
merged?


Because it's not the right approach. There is no reason why building firmware cannot 
be done with cross compilers, so moving those directories to Meson (not because Meson 
can't handle them; more specifically, the issue is tying the firmware build to the 
QEMU build system) is going in the wrong direction.


The "Canadian cross" scenario, where you build on Linux a mingw GCC but the compiler 
is s390, is not even enough to describe the complexity in the case of QEMU, because 
there are multiple firmware for different machines.


However we already have all the infrastructure to do such builds, we just don't use 
it for the firmware. So, instead of the patch you recalled above, the tests/tcg 
machinery should be extended into something that can be reused for firmware. As an 
aside, orchestrating this multi-compiler part of the build is what the Makefiles will 
keep on handling for the foreseeable future. As an aside to the aside, tests/tcg is 
more than underdocumented and I forget everything about it 5 minutes after looking at it.


This is not something that I will be able to work on anytime soon. But still I don't 
think that going in the wrong direction is a good idea, even if temporarily.


That's a shame, although I do appreciate the huge amount of time and effort that 
you've put into this release in order to get the Meson build up and running, and so 
why taking on another large task is going to be lower down the list :)


At the moment OpenBIOS doesn't have a docker image capable of building the required 
binaries: I did experiment with trying to use the QEMU docker images for openbios-ppc 
but whilst the binary built successfully, it did not run compared to my hand-rolled 
compilers. So there's still some debugging to be done there...



ATB,

Mark.



Re: [PATCH v2 0/2] hw/rtc/m48t59: Simplify m48t59_init()

2020-10-16 Thread Mark Cave-Ayland

On 15/10/2020 20:46, Philippe Mathieu-Daudé wrote:


Since v1:
- Do not remove mem_base in patch 1 (Laurent)
- Pass MemoryRegion* (new patch)
- Run check-qtest

Philippe Mathieu-Daudé (2):
   hw/rtc/m48t59: Simplify m48t59_init() removing 'io_base' argument
   hw/rtc/m48t59: Simplify m48t59_init() passing MemoryRegion argument

  include/hw/rtc/m48t59.h |  5 ++---
  hw/ppc/ppc405_boards.c  |  2 +-
  hw/rtc/m48t59.c | 14 +++---
  hw/sparc/sun4m.c|  3 ++-
  hw/sparc64/sun4u.c  |  7 ++-
  5 files changed, 10 insertions(+), 21 deletions(-)


This looks good, and from what you've done here it's only a little more work to 
remove m48t59_init() completely. Would you mind if I try this using these patches as 
a starting point? :)



ATB,

Mark.



Re: [RFC PATCH 00/12] hw/arm/virt: Introduce cpu and cache topology support

2020-10-16 Thread Ying Fang




On 10/15/2020 3:59 PM, Andrew Jones wrote:

On Thu, Oct 15, 2020 at 10:07:16AM +0800, Ying Fang wrote:



On 10/14/2020 2:08 AM, Andrew Jones wrote:

On Tue, Oct 13, 2020 at 12:11:20PM +, Zengtao (B) wrote:

Cc valentin


-Original Message-
From: Qemu-devel
[mailto:qemu-devel-bounces+prime.zeng=hisilicon@nongnu.org]
On Behalf Of Ying Fang
Sent: Thursday, September 17, 2020 11:20 AM
To: qemu-devel@nongnu.org
Cc: peter.mayd...@linaro.org; drjo...@redhat.com; Zhanghailiang;
Chenzhendong (alex); shannon.zha...@gmail.com;
qemu-...@nongnu.org; alistair.fran...@wdc.com; fangying;
imamm...@redhat.com
Subject: [RFC PATCH 00/12] hw/arm/virt: Introduce cpu and cache
topology support

An accurate cpu topology may help improve the cpu scheduler's
decision
making when dealing with multi-core system. So cpu topology
description
is helpful to provide guest with the right view. Cpu cache information
may
also have slight impact on the sched domain, and even userspace
software
may check the cpu cache information to do some optimizations. Thus
this patch
series is posted to provide cpu and cache topology support for arm.

To make the cpu topology consistent with MPIDR, an vcpu ioctl


For aarch64, the cpu topology don't depends on the MPDIR.
See https://patchwork.kernel.org/patch/11744387/



The topology should not be inferred from the MPIDR Aff fields,


MPIDR is abused by ARM OEM manufactures. It is only used as a
identifer for a specific cpu, not representation of the topology.


Right, which is why I stated topology should not be inferred from
it.




but MPIDR is the CPU identifier. When describing a topology
with ACPI or DT the CPU elements in the topology description
must map to actual CPUs. MPIDR is that mapping link. KVM
currently determines what the MPIDR of a VCPU is. If KVM


KVM currently assigns MPIDR with vcpu->vcpu_id which mapped
into affinity levels. See reset_mpidr in sys_regs.c


I know, but how KVM assigns MPIDRs today is not really important
to KVM userspace. KVM userspace shouldn't depend on a KVM
algorithm, as it could change.




userspace is going to determine the VCPU topology, then it
also needs control over the MPIDR values, otherwise it
becomes quite messy trying to get the mapping right.

If we are going to control MPIDR, shall we assign MPIDR with
vcpu_id or map topology hierarchy into affinity levels or any
other link schema ?



We can assign them to whatever we want, as long as they're
unique and as long as Aff0 is assigned per the GIC requirements,
e.g. GICv3 requires that Aff0 be from 0 to 0xf. Also, when
pinning VCPUs to PCPUs we should ensure that MPIDRs with matching
Aff3,Aff2,Aff1 fields should actually be peers with respect to
the GIC.


Still not clear why vCPU's MPIDR need to match pPCPU's GIC affinity.
Maybe I should read spec for GICv3.



We shouldn't try to encode topology in the MPIDR in any way,
so we might as well simply increment a counter to assign them,
which could possibly be the same as the VCPU ID.


Hmm, then we can leave it as it is.



Thanks,
drew

.





Re: [PATCH v2 03/10] softfloat: Tidy a * b + inf return

2020-10-16 Thread Alex Bennée


Richard Henderson  writes:

> No reason to set values in 'a', when we already
> have float_class_inf in 'c', and can flip that sign.
>
> Reviewed-by: David Hildenbrand 
> Signed-off-by: Richard Henderson 

Reviewed-by: Alex Bennée 

-- 
Alex Bennée



Re: [PATCH v2 04/10] softfloat: Add float_cmask and constants

2020-10-16 Thread Alex Bennée


Richard Henderson  writes:

> Testing more than one class at a time is better done with masks.
> This reduces the static branch count.
>
> Reviewed-by: David Hildenbrand 
> Signed-off-by: Richard Henderson 

Reviewed-by: Alex Bennée 

-- 
Alex Bennée



Re: [PATCH v10 10/10] vfio: Don't issue full 2^64 unmap

2020-10-16 Thread Auger Eric
Hi Jean,

On 10/8/20 7:15 PM, Jean-Philippe Brucker wrote:
> IOMMUs may declare memory regions spanning from 0 to UINT64_MAX. When
> attempting to deal with such region, vfio_listener_region_del() passes a
> size of 2^64 to int128_get64() which throws an assertion failure.  Even
> ignoring this, the VFIO_IOMMU_DMA_MAP ioctl cannot handle this size
> since the size field is 64-bit. Split the request in two.
> 
> Signed-off-by: Jean-Philippe Brucker 
Reviewed-by: Eric Auger 

Thanks

Eric
> ---
> For me this happens when memory_region_iommu_set_page_size_mask()
> returns an error because a hotplugged endpoint uses an incompatible page
> mask. vfio_connect_container() releases the memory listener which calls
> region_del() with the 2^64 IOMMU region. There are probably other ways
> to reach this.
> ---
>  hw/vfio/common.c | 11 +++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> index e66054b02a7..e90a89c389e 100644
> --- a/hw/vfio/common.c
> +++ b/hw/vfio/common.c
> @@ -797,6 +797,17 @@ static void vfio_listener_region_del(MemoryListener 
> *listener,
>  }
>  
>  if (try_unmap) {
> +if (llsize == int128_2_64()) {
> +/* The unmap ioctl doesn't accept a full 64-bit span. */
> +llsize = int128_rshift(llsize, 1);
> +ret = vfio_dma_unmap(container, iova, int128_get64(llsize));
> +if (ret) {
> +error_report("vfio_dma_unmap(%p, 0x%"HWADDR_PRIx", "
> + "0x%"HWADDR_PRIx") = %d (%m)",
> + container, iova, int128_get64(llsize), ret);
> +}
> +iova += int128_get64(llsize);
> +}
>  ret = vfio_dma_unmap(container, iova, int128_get64(llsize));
>  if (ret) {
>  error_report("vfio_dma_unmap(%p, 0x%"HWADDR_PRIx", "
> 




Re: [PATCH v2 0/2] hw/rtc/m48t59: Simplify m48t59_init()

2020-10-16 Thread Philippe Mathieu-Daudé
Le ven. 16 oct. 2020 11:39, Mark Cave-Ayland 
a écrit :

> On 15/10/2020 20:46, Philippe Mathieu-Daudé wrote:
>
> > Since v1:
> > - Do not remove mem_base in patch 1 (Laurent)
> > - Pass MemoryRegion* (new patch)
> > - Run check-qtest
> >
> > Philippe Mathieu-Daudé (2):
> >hw/rtc/m48t59: Simplify m48t59_init() removing 'io_base' argument
> >hw/rtc/m48t59: Simplify m48t59_init() passing MemoryRegion argument
> >
> >   include/hw/rtc/m48t59.h |  5 ++---
> >   hw/ppc/ppc405_boards.c  |  2 +-
> >   hw/rtc/m48t59.c | 14 +++---
> >   hw/sparc/sun4m.c|  3 ++-
> >   hw/sparc64/sun4u.c  |  7 ++-
> >   5 files changed, 10 insertions(+), 21 deletions(-)
>
> This looks good, and from what you've done here it's only a little more
> work to
> remove m48t59_init() completely. Would you mind if I try this using these
> patches as
> a starting point? :)
>

I had a look at your previous suggestion, but I have too many in flight
series waiting for 5.2, so sure go ahead!


>
> ATB,
>
> Mark.
>
>


Re: [PATCH v8 0/5] Mac Old World ROM experiment (ppc/mac_* clean ups and loading binary ROM)

2020-10-16 Thread Mark Cave-Ayland

On 16/10/2020 00:47, BALATON Zoltan via wrote:


This is the cut down version of the earlier series omitting unfinished
patches that I plan to rework later and rebased to Mark's qemu-macppc
branch. Compared to v7 the only change is the cast to (target_ulong)
from (uint32_t) as requested by Mark in patch 1.


FWIW the reason for suggesting the cast to target_ulong is so that the same code 
works for both qemu-system-ppc and qemu-system-ppc64. For qemu-system-ppc that should 
correctly drop the sign extension from 32-bit, whilst still allowing someone to load 
a 64-bit ELF into qemu-system-ppc64 if requested.


Can you confirm that the sign extension behaviour is still correct for both 
qemu-system-ppc and qemu-system-ppc64? If so I'm happy to give it a R-B tag.



ATB,

Mark.



[PATCH] ci: include configure and meson logs in all jobs if configure fails

2020-10-16 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 .cirrus.yml| 6 +++---
 .gitlab-ci.yml | 6 +++---
 .travis.yml| 8 
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/.cirrus.yml b/.cirrus.yml
index e099da0fec..81a2960b1a 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -13,7 +13,7 @@ freebsd_12_task:
   script:
 - mkdir build
 - cd build
-- ../configure --enable-werror || { cat config.log; exit 1; }
+- ../configure --enable-werror || { cat config.log 
meson-logs/meson-log.txt; exit 1; }
 - gmake -j$(sysctl -n hw.ncpu)
 - gmake -j$(sysctl -n hw.ncpu) check V=1
 
@@ -27,7 +27,7 @@ macos_task:
 - cd build
 - ../configure --python=/usr/local/bin/python3 --enable-werror
--extra-cflags='-Wno-error=deprecated-declarations'
-   || { cat config.log; exit 1; }
+   || { cat config.log meson-logs/meson-log.txt; exit 1; }
 - gmake -j$(sysctl -n hw.ncpu)
 - gmake check V=1
 
@@ -41,7 +41,7 @@ macos_xcode_task:
 - mkdir build
 - cd build
 - ../configure --extra-cflags='-Wno-error=deprecated-declarations'
-   --enable-werror --cc=clang || { cat config.log; exit 1; }
+   --enable-werror --cc=clang || { cat config.log 
meson-logs/meson-log.txt; exit 1; }
 - gmake -j$(sysctl -n hw.ncpu)
 - gmake check V=1
 
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8ffd415ca5..66ad7aa5c2 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -32,7 +32,7 @@ include:
 ../configure --enable-werror $CONFIGURE_ARGS --target-list="$TARGETS" ;
   else
 ../configure --enable-werror $CONFIGURE_ARGS ;
-  fi
+  fi || { cat config.log meson-logs/meson-log.txt && exit 1; }
 - make -j"$JOBS"
 - if test -n "$MAKE_CHECK_ARGS";
   then
@@ -229,7 +229,7 @@ build-tcg-disabled:
   script:
 - mkdir build
 - cd build
-- ../configure --disable-tcg --audio-drv-list=""
+- ../configure --disable-tcg --audio-drv-list="" || { cat config.log 
meson-logs/meson-log.txt && exit 1; }
 - make -j"$JOBS"
 - make check-unit
 - make check-qapi-schema
@@ -322,7 +322,7 @@ build-tci:
 - mkdir build
 - cd build
 - ../configure --enable-tcg-interpreter
---target-list="$(for tg in $TARGETS; do echo -n ${tg}'-softmmu '; 
done)"
+--target-list="$(for tg in $TARGETS; do echo -n ${tg}'-softmmu '; 
done)" || { cat config.log meson-logs/meson-log.txt && exit 1; }
 - make -j"$JOBS"
 - make run-tcg-tests-x86_64-softmmu
 - make tests/qtest/boot-serial-test tests/qtest/cdrom-test 
tests/qtest/pxe-test
diff --git a/.travis.yml b/.travis.yml
index d7bfbb8bfe..a3d78171ca 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -95,7 +95,7 @@ before_install:
 # Configure step - may be overridden
 before_script:
   - mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
-  - ${SRC_DIR}/configure ${BASE_CONFIG} ${CONFIG} || { cat config.log && exit 
1; }
+  - ${SRC_DIR}/configure ${BASE_CONFIG} ${CONFIG} || { cat config.log 
meson-logs/meson-log.txt && exit 1; }
 
 # Main build & test - rarely overridden - controlled by TEST_CMD
 script:
@@ -199,7 +199,7 @@ jobs:
   compiler: clang
   before_script:
 - mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
-- ${SRC_DIR}/configure ${CONFIG} --extra-cflags="-fsanitize=undefined 
-Werror" || { cat config.log && exit 1; }
+- ${SRC_DIR}/configure ${CONFIG} --extra-cflags="-fsanitize=undefined 
-Werror" || { cat config.log meson-logs/meson-log.txt && exit 1; }
 
 
 - name: "Clang (other-softmmu)"
@@ -298,7 +298,7 @@ jobs:
 - TEST_CMD=""
   before_script:
 - mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
-- ${SRC_DIR}/configure ${CONFIG} --extra-cflags="-g3 -O0 
-fsanitize=thread" || { cat config.log && exit 1; }
+- ${SRC_DIR}/configure ${CONFIG} --extra-cflags="-g3 -O0 
-fsanitize=thread" || { cat config.log meson-logs/meson-log.txt && exit 1; }
 
 
 # Run check-tcg against linux-user
@@ -530,7 +530,7 @@ jobs:
 - ls -l ${SRC_DIR}/qemu-${QEMU_VERSION}.tar.bz2
 - tar -xf ${SRC_DIR}/qemu-${QEMU_VERSION}.tar.bz2 && cd 
qemu-${QEMU_VERSION}
 - mkdir -p release-build && cd release-build
-- ../configure ${BASE_CONFIG} ${CONFIG} || { cat config.log && exit 1; 
}
+- ../configure ${BASE_CONFIG} ${CONFIG} || { cat config.log 
meson-logs/meson-log.txt && exit 1; }
 - make install
   allow_failures:
 - env: UNRELIABLE=true
-- 
2.26.2




Re: [RFC PATCH 00/12] hw/arm/virt: Introduce cpu and cache topology support

2020-10-16 Thread Andrew Jones
On Fri, Oct 16, 2020 at 05:40:02PM +0800, Ying Fang wrote:
> 
> 
> On 10/15/2020 3:59 PM, Andrew Jones wrote:
> > On Thu, Oct 15, 2020 at 10:07:16AM +0800, Ying Fang wrote:
> > > 
> > > 
> > > On 10/14/2020 2:08 AM, Andrew Jones wrote:
> > > > On Tue, Oct 13, 2020 at 12:11:20PM +, Zengtao (B) wrote:
> > > > > Cc valentin
> > > > > 
> > > > > > -Original Message-
> > > > > > From: Qemu-devel
> > > > > > [mailto:qemu-devel-bounces+prime.zeng=hisilicon@nongnu.org]
> > > > > > On Behalf Of Ying Fang
> > > > > > Sent: Thursday, September 17, 2020 11:20 AM
> > > > > > To: qemu-devel@nongnu.org
> > > > > > Cc: peter.mayd...@linaro.org; drjo...@redhat.com; Zhanghailiang;
> > > > > > Chenzhendong (alex); shannon.zha...@gmail.com;
> > > > > > qemu-...@nongnu.org; alistair.fran...@wdc.com; fangying;
> > > > > > imamm...@redhat.com
> > > > > > Subject: [RFC PATCH 00/12] hw/arm/virt: Introduce cpu and cache
> > > > > > topology support
> > > > > > 
> > > > > > An accurate cpu topology may help improve the cpu scheduler's
> > > > > > decision
> > > > > > making when dealing with multi-core system. So cpu topology
> > > > > > description
> > > > > > is helpful to provide guest with the right view. Cpu cache 
> > > > > > information
> > > > > > may
> > > > > > also have slight impact on the sched domain, and even userspace
> > > > > > software
> > > > > > may check the cpu cache information to do some optimizations. Thus
> > > > > > this patch
> > > > > > series is posted to provide cpu and cache topology support for arm.
> > > > > > 
> > > > > > To make the cpu topology consistent with MPIDR, an vcpu ioctl
> > > > > 
> > > > > For aarch64, the cpu topology don't depends on the MPDIR.
> > > > > See https://patchwork.kernel.org/patch/11744387/
> > > > > 
> > > > 
> > > > The topology should not be inferred from the MPIDR Aff fields,
> > > 
> > > MPIDR is abused by ARM OEM manufactures. It is only used as a
> > > identifer for a specific cpu, not representation of the topology.
> > 
> > Right, which is why I stated topology should not be inferred from
> > it.
> > 
> > > 
> > > > but MPIDR is the CPU identifier. When describing a topology
> > > > with ACPI or DT the CPU elements in the topology description
> > > > must map to actual CPUs. MPIDR is that mapping link. KVM
> > > > currently determines what the MPIDR of a VCPU is. If KVM
> > > 
> > > KVM currently assigns MPIDR with vcpu->vcpu_id which mapped
> > > into affinity levels. See reset_mpidr in sys_regs.c
> > 
> > I know, but how KVM assigns MPIDRs today is not really important
> > to KVM userspace. KVM userspace shouldn't depend on a KVM
> > algorithm, as it could change.
> > 
> > > 
> > > > userspace is going to determine the VCPU topology, then it
> > > > also needs control over the MPIDR values, otherwise it
> > > > becomes quite messy trying to get the mapping right.
> > > If we are going to control MPIDR, shall we assign MPIDR with
> > > vcpu_id or map topology hierarchy into affinity levels or any
> > > other link schema ?
> > > 
> > 
> > We can assign them to whatever we want, as long as they're
> > unique and as long as Aff0 is assigned per the GIC requirements,
> > e.g. GICv3 requires that Aff0 be from 0 to 0xf. Also, when
> > pinning VCPUs to PCPUs we should ensure that MPIDRs with matching
> > Aff3,Aff2,Aff1 fields should actually be peers with respect to
> > the GIC.
> 
> Still not clear why vCPU's MPIDR need to match pPCPU's GIC affinity.
> Maybe I should read spec for GICv3.

Look at how IPIs are efficiently sent to "peers", where the definition
of a peer is that only Aff0 differs in its MPIDR. But, gicv3's
optimizations can only handle 16 peers. If we want pinned VCPUs to
have the same performance as PCPUS, then we should maintain this
Aff0 limit.

Thanks,
drew

> 
> > 
> > We shouldn't try to encode topology in the MPIDR in any way,
> > so we might as well simply increment a counter to assign them,
> > which could possibly be the same as the VCPU ID.
> 
> Hmm, then we can leave it as it is.
> 
> > 
> > Thanks,
> > drew
> > 
> > .
> > 
> 




Re: [PATCH] ci: include configure and meson logs in all jobs if configure fails

2020-10-16 Thread Philippe Mathieu-Daudé
Le ven. 16 oct. 2020 12:05, Paolo Bonzini  a écrit :

> Signed-off-by: Paolo Bonzini 
>

Reviewed-by: Philippe Mathieu-Daudé 

---
>  .cirrus.yml| 6 +++---
>  .gitlab-ci.yml | 6 +++---
>  .travis.yml| 8 
>  3 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/.cirrus.yml b/.cirrus.yml
> index e099da0fec..81a2960b1a 100644
> --- a/.cirrus.yml
> +++ b/.cirrus.yml
> @@ -13,7 +13,7 @@ freebsd_12_task:
>script:
>  - mkdir build
>  - cd build
> -- ../configure --enable-werror || { cat config.log; exit 1; }
> +- ../configure --enable-werror || { cat config.log
> meson-logs/meson-log.txt; exit 1; }
>  - gmake -j$(sysctl -n hw.ncpu)
>  - gmake -j$(sysctl -n hw.ncpu) check V=1
>
> @@ -27,7 +27,7 @@ macos_task:
>  - cd build
>  - ../configure --python=/usr/local/bin/python3 --enable-werror
> --extra-cflags='-Wno-error=deprecated-declarations'
> -   || { cat config.log; exit 1; }
> +   || { cat config.log meson-logs/meson-log.txt; exit 1; }
>  - gmake -j$(sysctl -n hw.ncpu)
>  - gmake check V=1
>
> @@ -41,7 +41,7 @@ macos_xcode_task:
>  - mkdir build
>  - cd build
>  - ../configure --extra-cflags='-Wno-error=deprecated-declarations'
> -   --enable-werror --cc=clang || { cat config.log; exit
> 1; }
> +   --enable-werror --cc=clang || { cat config.log
> meson-logs/meson-log.txt; exit 1; }
>  - gmake -j$(sysctl -n hw.ncpu)
>  - gmake check V=1
>
> diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
> index 8ffd415ca5..66ad7aa5c2 100644
> --- a/.gitlab-ci.yml
> +++ b/.gitlab-ci.yml
> @@ -32,7 +32,7 @@ include:
>  ../configure --enable-werror $CONFIGURE_ARGS
> --target-list="$TARGETS" ;
>else
>  ../configure --enable-werror $CONFIGURE_ARGS ;
> -  fi
> +  fi || { cat config.log meson-logs/meson-log.txt && exit 1; }
>  - make -j"$JOBS"
>  - if test -n "$MAKE_CHECK_ARGS";
>then
> @@ -229,7 +229,7 @@ build-tcg-disabled:
>script:
>  - mkdir build
>  - cd build
> -- ../configure --disable-tcg --audio-drv-list=""
> +- ../configure --disable-tcg --audio-drv-list="" || { cat config.log
> meson-logs/meson-log.txt && exit 1; }
>  - make -j"$JOBS"
>  - make check-unit
>  - make check-qapi-schema
> @@ -322,7 +322,7 @@ build-tci:
>  - mkdir build
>  - cd build
>  - ../configure --enable-tcg-interpreter
> ---target-list="$(for tg in $TARGETS; do echo -n ${tg}'-softmmu ';
> done)"
> +--target-list="$(for tg in $TARGETS; do echo -n ${tg}'-softmmu ';
> done)" || { cat config.log meson-logs/meson-log.txt && exit 1; }
>  - make -j"$JOBS"
>  - make run-tcg-tests-x86_64-softmmu
>  - make tests/qtest/boot-serial-test tests/qtest/cdrom-test
> tests/qtest/pxe-test
> diff --git a/.travis.yml b/.travis.yml
> index d7bfbb8bfe..a3d78171ca 100644
> --- a/.travis.yml
> +++ b/.travis.yml
> @@ -95,7 +95,7 @@ before_install:
>  # Configure step - may be overridden
>  before_script:
>- mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
> -  - ${SRC_DIR}/configure ${BASE_CONFIG} ${CONFIG} || { cat config.log &&
> exit 1; }
> +  - ${SRC_DIR}/configure ${BASE_CONFIG} ${CONFIG} || { cat config.log
> meson-logs/meson-log.txt && exit 1; }
>
>  # Main build & test - rarely overridden - controlled by TEST_CMD
>  script:
> @@ -199,7 +199,7 @@ jobs:
>compiler: clang
>before_script:
>  - mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
> -- ${SRC_DIR}/configure ${CONFIG}
> --extra-cflags="-fsanitize=undefined -Werror" || { cat config.log && exit
> 1; }
> +- ${SRC_DIR}/configure ${CONFIG}
> --extra-cflags="-fsanitize=undefined -Werror" || { cat config.log
> meson-logs/meson-log.txt && exit 1; }
>
>
>  - name: "Clang (other-softmmu)"
> @@ -298,7 +298,7 @@ jobs:
>  - TEST_CMD=""
>before_script:
>  - mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
> -- ${SRC_DIR}/configure ${CONFIG} --extra-cflags="-g3 -O0
> -fsanitize=thread" || { cat config.log && exit 1; }
> +- ${SRC_DIR}/configure ${CONFIG} --extra-cflags="-g3 -O0
> -fsanitize=thread" || { cat config.log meson-logs/meson-log.txt && exit 1; }
>
>
>  # Run check-tcg against linux-user
> @@ -530,7 +530,7 @@ jobs:
>  - ls -l ${SRC_DIR}/qemu-${QEMU_VERSION}.tar.bz2
>  - tar -xf ${SRC_DIR}/qemu-${QEMU_VERSION}.tar.bz2 && cd
> qemu-${QEMU_VERSION}
>  - mkdir -p release-build && cd release-build
> -- ../configure ${BASE_CONFIG} ${CONFIG} || { cat config.log &&
> exit 1; }
> +- ../configure ${BASE_CONFIG} ${CONFIG} || { cat config.log
> meson-logs/meson-log.txt && exit 1; }
>  - make install
>allow_failures:
>  - env: UNRELIABLE=true
> --
> 2.26.2
>
>
>


[Bug 1900122] [NEW] Unsupported ioctl: cmd=0xffffffff80685600 when accessing /dev/video* in aarch64 guest

2020-10-16 Thread vak
Public bug reported:

**Description:**
Any attempt to work with video in aarch64 architecture emulated on x86_64 leads 
currently to the error "Function not implemented". For example:

```
# v4l2-ctl -l --verbose
Failed to open /dev/video0: Function not implemented

root@12dd9b6fcfcb:/# ll /dev/video*
crw-rw 1 root video 81, 0 Oct 16 09:23 /dev/video0
crw-rw 1 root video 81, 1 Oct 16 09:23 /dev/video1

```

**Steps to reproduce the issue:**

I have a following setup:

Host Hardware: x86_64 equipped with a webcam (tried different webcams)
Host OS: Ubuntu 20.04.1 

Guest Architecture: aarch64
Guest OS: Ubuntu 20.04 (also tried 16.x and 18.x)

Emulation: quemu-user-static (also tried binfmt)

Guest OS is running via Docker + QEMU

```
➜ cat /proc/sys/fs/binfmt_misc/qemu-aarch64
enabled
interpreter /usr/bin/qemu-aarch64-static
flags: F
offset 0
magic 7f454c46020101000200b700
mask ff00feff
```

**Results received:**
see desrciption.

**Environment:**


* QEMU version: (if you can know it):

ipxe-qemu-256k-compat-efi-roms/focal,now 1.0.0+git-20150424.a25a16d-0ubuntu4 
all [installed,automatic]
ipxe-qemu/focal-updates,now 1.0.0+git-20190109.133f4c4-0ubuntu3.2 all 
[installed,automatic]
qemu-block-extra/focal-updates,now 1:4.2-3ubuntu6.7 amd64 [installed,automatic]
qemu-kvm/focal-updates,now 1:4.2-3ubuntu6.7 amd64 [installed]
qemu-system-common/focal-updates,now 1:4.2-3ubuntu6.7 amd64 
[installed,automatic]
qemu-system-data/focal-updates,now 1:4.2-3ubuntu6.7 all [installed,automatic]
qemu-system-gui/focal-updates,now 1:4.2-3ubuntu6.7 amd64 [installed,automatic]
qemu-system-x86/focal-updates,now 1:4.2-3ubuntu6.7 amd64 [installed,automatic]
qemu-user-binfmt/focal-updates,now 1:4.2-3ubuntu6.7 amd64 [installed,automatic]
qemu-user/focal-updates,now 1:4.2-3ubuntu6.7 amd64 [installed]
qemu-utils/focal-updates,now 1:4.2-3ubuntu6.7 amd64 [installed,automatic]
qemu/focal-updates,now 1:4.2-3ubuntu6.7 amd64 [installed]

* Container application: Docker

**Output of `docker version`, `podman version` or `singularity
version`**

```
➜ docker version
Client: Docker Engine - Community
 Version:   20.10.0-beta1
 API version:   1.40
 Go version:go1.13.15
 Git commit:ac365d7
 Built: Tue Oct 13 18:15:22 2020
 OS/Arch:   linux/amd64
 Context:   default
 Experimental:  true

Server: Docker Engine - Community
 Engine:
  Version:  19.03.13
  API version:  1.40 (minimum version 1.12)
  Go version:   go1.13.15
  Git commit:   4484c46d9d
  Built:Wed Sep 16 17:01:20 2020
  OS/Arch:  linux/amd64
  Experimental: false
 containerd:
  Version:  1.4.1
  GitCommit:c623d1b36f09f8ef6536a057bd658b3aa8632828
 runc:
  Version:  1.0.0-rc92
  GitCommit:ff819c7e9184c13b7c2607fe6c30ae19403a7aff
 docker-init:
  Version:  0.18.0
  GitCommit:fec3683

```

Guest aarch64 runs in privileged mode:

`docker run --privileged --device=/dev/video0:/dev/video0 --env
DISPLAY=unix$DISPLAY -v $XAUTH:/root/.Xauthority  -v
/tmp/.X11-unix:/tmp/.X11-unix -it --rm arm64v8/ubuntu:20.04 bash`

**Additional information:**
I tried also binfmt way to register emulators. The output of `v4l-ctl` was a 
little bit different:

```
# v4l2-ctl -l
Unsupported ioctl: cmd=0x80685600
Failed to open /dev/video0: Function not implemented

```

** Affects: qemu
 Importance: Undecided
 Status: New


** Tags: aarch64 docker ioctl video

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1900122

Title:
  Unsupported ioctl: cmd=0x80685600 when accessing /dev/video*
  in aarch64 guest

Status in QEMU:
  New

Bug description:
  **Description:**
  Any attempt to work with video in aarch64 architecture emulated on x86_64 
leads currently to the error "Function not implemented". For example:

  ```
  # v4l2-ctl -l --verbose
  Failed to open /dev/video0: Function not implemented

  root@12dd9b6fcfcb:/# ll /dev/video*
  crw-rw 1 root video 81, 0 Oct 16 09:23 /dev/video0
  crw-rw 1 root video 81, 1 Oct 16 09:23 /dev/video1

  ```

  **Steps to reproduce the issue:**

  I have a following setup:

  Host Hardware: x86_64 equipped with a webcam (tried different webcams)
  Host OS: Ubuntu 20.04.1 

  Guest Architecture: aarch64
  Guest OS: Ubuntu 20.04 (also tried 16.x and 18.x)

  Emulation: quemu-user-static (also tried binfmt)

  Guest OS is running via Docker + QEMU

  ```
  ➜ cat /proc/sys/fs/binfmt_misc/qemu-aarch64
  enabled
  interpreter /usr/bin/qemu-aarch64-static
  flags: F
  offset 0
  magic 7f454c46020101000200b700
  mask ff00feff
  ```

  **Results received:**
  see desrciption.

  **Environment:**

  
  * QEMU version: (if you can know it):

  ipxe-qemu-256k-compat-efi-roms/focal,now 1.0.0+git-20150424.a25a16d-0

[PATCH v3 1/2] QSLIST: add atomic replace operation

2020-10-16 Thread wanghonghao
Replace a queue with another atomicly. It's useful when we need to transfer
queues between threads.

Signed-off-by: wanghonghao 
---
 include/qemu/queue.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/include/qemu/queue.h b/include/qemu/queue.h
index e029e7bf66..1f0cbdf87e 100644
--- a/include/qemu/queue.h
+++ b/include/qemu/queue.h
@@ -226,6 +226,10 @@ struct {   
 \
 (dest)->slh_first = qatomic_xchg(&(src)->slh_first, NULL);   \
 } while (/*CONSTCOND*/0)
 
+#define QSLIST_REPLACE_ATOMIC(dest, src, old) do {\
+(old)->slh_first = qatomic_xchg(&(dest)->slh_first, (src)->slh_first); 
\
+} while (/*CONSTCOND*/0)
+
 #define QSLIST_REMOVE_HEAD(head, field) do { \
 typeof((head)->slh_first) elm = (head)->slh_first;   \
 (head)->slh_first = elm->field.sle_next; \
-- 
2.24.3 (Apple Git-128)




[PATCH v3 2/2] coroutine: take exactly one batch from global pool at a time

2020-10-16 Thread wanghonghao
This patch replace the global coroutine queue with a lock-free stack of which
the elements are coroutine queues. Threads can put coroutine queues into the
stack or take queues from it and each coroutine queue has exactly
POOL_BATCH_SIZE coroutines. Note that the stack is not strictly LIFO, but it's
enough for buffer pool.

Coroutines will be put into thread-local pools first while release. Now the
fast pathes of both allocation and release are atomic-free, and there won't
be too many coroutines remain in a single thread since POOL_BATCH_SIZE has been
reduced to 16.

In practice, I've run a VM with two block devices binding to two different
iothreads, and run fio with iodepth 128 on each device. It maintains around
400 coroutines and has about 1% chance of calling to `qemu_coroutine_new`
without this patch. And with this patch, it maintains no more than 273
coroutines and doesn't call `qemu_coroutine_new` after initial allocations.

Signed-off-by: wanghonghao 
---
 util/qemu-coroutine.c | 63 ---
 1 file changed, 42 insertions(+), 21 deletions(-)

diff --git a/util/qemu-coroutine.c b/util/qemu-coroutine.c
index 38fb6d3084..46e5073796 100644
--- a/util/qemu-coroutine.c
+++ b/util/qemu-coroutine.c
@@ -21,13 +21,14 @@
 #include "block/aio.h"
 
 enum {
-POOL_BATCH_SIZE = 64,
+POOL_BATCH_SIZE = 16,
+POOL_MAX_BATCHES = 32,
 };
 
-/** Free list to speed up creation */
-static QSLIST_HEAD(, Coroutine) release_pool = QSLIST_HEAD_INITIALIZER(pool);
-static unsigned int release_pool_size;
-static __thread QSLIST_HEAD(, Coroutine) alloc_pool = 
QSLIST_HEAD_INITIALIZER(pool);
+/** Free stack to speed up creation */
+static QSLIST_HEAD(, Coroutine) pool[POOL_MAX_BATCHES];
+static int pool_top;
+static __thread QSLIST_HEAD(, Coroutine) alloc_pool;
 static __thread unsigned int alloc_pool_size;
 static __thread Notifier coroutine_pool_cleanup_notifier;
 
@@ -49,20 +50,26 @@ Coroutine *qemu_coroutine_create(CoroutineEntry *entry, 
void *opaque)
 if (CONFIG_COROUTINE_POOL) {
 co = QSLIST_FIRST(&alloc_pool);
 if (!co) {
-if (release_pool_size > POOL_BATCH_SIZE) {
-/* Slow path; a good place to register the destructor, too.  */
-if (!coroutine_pool_cleanup_notifier.notify) {
-coroutine_pool_cleanup_notifier.notify = 
coroutine_pool_cleanup;
-qemu_thread_atexit_add(&coroutine_pool_cleanup_notifier);
+int top;
+
+/* Slow path; a good place to register the destructor, too.  */
+if (!coroutine_pool_cleanup_notifier.notify) {
+coroutine_pool_cleanup_notifier.notify = 
coroutine_pool_cleanup;
+qemu_thread_atexit_add(&coroutine_pool_cleanup_notifier);
+}
+
+while ((top = qatomic_read(&pool_top)) > 0) {
+if (qatomic_cmpxchg(&pool_top, top, top - 1) != top) {
+continue;
 }
 
-/* This is not exact; there could be a little skew between
- * release_pool_size and the actual size of release_pool.  But
- * it is just a heuristic, it does not need to be perfect.
- */
-alloc_pool_size = qatomic_xchg(&release_pool_size, 0);
-QSLIST_MOVE_ATOMIC(&alloc_pool, &release_pool);
+QSLIST_MOVE_ATOMIC(&alloc_pool, &pool[top - 1]);
 co = QSLIST_FIRST(&alloc_pool);
+
+if (co) {
+alloc_pool_size = POOL_BATCH_SIZE;
+break;
+}
 }
 }
 if (co) {
@@ -86,16 +93,30 @@ static void coroutine_delete(Coroutine *co)
 co->caller = NULL;
 
 if (CONFIG_COROUTINE_POOL) {
-if (release_pool_size < POOL_BATCH_SIZE * 2) {
-QSLIST_INSERT_HEAD_ATOMIC(&release_pool, co, pool_next);
-qatomic_inc(&release_pool_size);
-return;
-}
+int top, value, old;
+
 if (alloc_pool_size < POOL_BATCH_SIZE) {
 QSLIST_INSERT_HEAD(&alloc_pool, co, pool_next);
 alloc_pool_size++;
 return;
 }
+
+for (top = qatomic_read(&pool_top); top < POOL_MAX_BATCHES; top++) {
+QSLIST_REPLACE_ATOMIC(&pool[top], &alloc_pool, &alloc_pool);
+if (!QSLIST_EMPTY(&alloc_pool)) {
+continue;
+}
+
+value = top + 1;
+
+do {
+old = qatomic_cmpxchg(&pool_top, top, value);
+} while (old != top && (top = old) < value);
+
+QSLIST_INSERT_HEAD(&alloc_pool, co, pool_next);
+alloc_pool_size = 1;
+return;
+}
 }
 
 qemu_coroutine_delete(co);
-- 
2.24.3 (Apple Git-128)




aio_poll() assertion fail on Windows

2020-10-16 Thread Mark Cave-Ayland
Whilst testing a Windows build of git master of qemu-system-ppc in MSYS2/MingW64 I 
noticed the following assertion message in the console after booting into OpenBIOS 
and then closing the GTK GUI window without booting a client OS:


$ ./qemu-system-ppc
**
ERROR:../util/aio-win32.c:337:aio_poll: assertion failed: 
(in_aio_context_home_thread(ctx))
Bail out! ERROR:../util/aio-win32.c:337:aio_poll: assertion failed: 
(in_aio_context_home_thread(ctx))


Has anyone else seen this at all?


ATB,

Mark.



[PATCH 0/1] Skip flatview_simplify() for cpu vendor zhaoxin

2020-10-16 Thread FelixCuioc
The actual situation we encountered is:
When assign EHCI device to the virtual machine,
after initializing EHCI in seabios,it will continuously
send dma cycles.
After flatview_simplify(),the IOVA mappings of the
EHCI device will be innocently unmapped between the
delate and add phases of the VFIO MemoryListener.
But the EHCI device is always sending DMA cycle.
At this time,the IOMMU will block the DMA cycle.
The purpose of this patch is to skip flatview_simplify()
for zx vendor.

FelixCuioc (1):
  Skip flatview_simplify() for cpu vendor zhaoxin

 softmmu/memory.c  | 20 +++-
 target/i386/cpu.c |  7 +++
 target/i386/cpu.h |  3 +++
 3 files changed, 29 insertions(+), 1 deletion(-)

-- 
2.17.1




[PATCH 1/1] Skip flatview_simplify() for cpu vendor zhaoxin

2020-10-16 Thread FelixCuioc
The issue here is that an assinged EHCI device accesses
an adjacent mapping between the delete and add phases
of the VFIO MemoryListener.
We want to skip flatview_simplify() is to prevent EHCI
device IOVA mappings from being unmapped.

Signed-off-by: FelixCuioc 
---
 softmmu/memory.c  | 20 +++-
 target/i386/cpu.c |  7 +++
 target/i386/cpu.h |  3 +++
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/softmmu/memory.c b/softmmu/memory.c
index 403ff3abc9..a998018d87 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -700,6 +700,22 @@ static MemoryRegion 
*memory_region_get_flatview_root(MemoryRegion *mr)
 return NULL;
 }
 
+static bool skip_simplify(void)
+{
+#ifdef I386_CPU_H
+char vendor[CPUID_VENDOR_SZ + 1] = { 0 };
+host_get_vendor(vendor);
+if (!strncmp(vendor, CPUID_VENDOR_VIA, strlen(CPUID_VENDOR_VIA))
+|| !strncmp(vendor, CPUID_VENDOR_ZHAOXIN,
+  strlen(CPUID_VENDOR_ZHAOXIN))) {
+return true;
+}
+return false;
+#else
+return false;
+#endif
+}
+
 /* Render a memory topology into a list of disjoint absolute ranges. */
 static FlatView *generate_memory_topology(MemoryRegion *mr)
 {
@@ -713,7 +729,9 @@ static FlatView *generate_memory_topology(MemoryRegion *mr)
  addrrange_make(int128_zero(), int128_2_64()),
  false, false);
 }
-flatview_simplify(view);
+if (!skip_simplify()) {
+flatview_simplify(view);
+}
 
 view->dispatch = address_space_dispatch_new(view);
 for (i = 0; i < view->nr; i++) {
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 5d713c8528..6bda35a03e 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -1559,6 +1559,13 @@ void host_cpuid(uint32_t function, uint32_t count,
 if (edx)
 *edx = vec[3];
 }
+void host_get_vendor(char *vendor)
+{
+  uint32_t eax, ebx, ecx, edx;
+
+  host_cpuid(0x0, 0, &eax, &ebx, &ecx, &edx);
+  x86_cpu_vendor_words2str(vendor, ebx, edx, ecx);
+}
 
 void host_vendor_fms(char *vendor, int *family, int *model, int *stepping)
 {
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 51c1d5f60a..e8e26e6a53 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -832,6 +832,8 @@ typedef uint64_t FeatureWordArray[FEATURE_WORDS];
 
 #define CPUID_VENDOR_VIA   "CentaurHauls"
 
+#define CPUID_VENDOR_ZHAOXIN   "  Shanghai  "
+
 #define CPUID_VENDOR_HYGON"HygonGenuine"
 
 #define IS_INTEL_CPU(env) ((env)->cpuid_vendor1 == CPUID_VENDOR_INTEL_1 && \
@@ -1918,6 +1920,7 @@ void cpu_clear_apic_feature(CPUX86State *env);
 void host_cpuid(uint32_t function, uint32_t count,
 uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx);
 void host_vendor_fms(char *vendor, int *family, int *model, int *stepping);
+void host_get_vendor(char *vendor);
 
 /* helper.c */
 bool x86_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
-- 
2.17.1




[PATCH 4/7] microvm: set pci_irq_mask

2020-10-16 Thread Gerd Hoffmann
Makes sure the PCI interrupt overrides are added to the
APIC table in case PCIe is enabled.

Signed-off-by: Gerd Hoffmann 
---
 hw/i386/acpi-microvm.c | 2 +-
 hw/i386/microvm.c  | 6 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/hw/i386/acpi-microvm.c b/hw/i386/acpi-microvm.c
index f16f2311955c..8e2d2b7cff83 100644
--- a/hw/i386/acpi-microvm.c
+++ b/hw/i386/acpi-microvm.c
@@ -196,7 +196,7 @@ static void acpi_build_microvm(AcpiBuildTables *tables,
 
 acpi_add_table(table_offsets, tables_blob);
 acpi_build_madt(tables_blob, tables->linker, X86_MACHINE(machine),
-ACPI_DEVICE_IF(x86ms->acpi_dev), false);
+ACPI_DEVICE_IF(x86ms->acpi_dev), x86ms->pci_irq_mask != 0);
 
 xsdt = tables_blob->len;
 build_xsdt(tables_blob, tables->linker, table_offsets, NULL, NULL);
diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c
index 73a7a142b44a..9dd74458aca4 100644
--- a/hw/i386/microvm.c
+++ b/hw/i386/microvm.c
@@ -210,6 +210,12 @@ static void microvm_devices_init(MicrovmMachineState *mms)
 mms->gpex.ecam.size   = PCIE_ECAM_SIZE;
 mms->gpex.irq = PCIE_IRQ_BASE;
 create_gpex(mms);
+x86ms->pci_irq_mask = ((1 << (PCIE_IRQ_BASE + 0)) |
+   (1 << (PCIE_IRQ_BASE + 1)) |
+   (1 << (PCIE_IRQ_BASE + 2)) |
+   (1 << (PCIE_IRQ_BASE + 3)));
+} else {
+x86ms->pci_irq_mask = 0;
 }
 
 if (mms->pic == ON_OFF_AUTO_ON || mms->pic == ON_OFF_AUTO_AUTO) {
-- 
2.27.0




[PATCH 6/7] tests/acpi: update expected data files

2020-10-16 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 tests/data/acpi/microvm/APIC.pcie | Bin 0 -> 110 bytes
 1 file changed, 0 insertions(+), 0 deletions(-)

diff --git a/tests/data/acpi/microvm/APIC.pcie 
b/tests/data/acpi/microvm/APIC.pcie
index 
e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..6c51081b50beb061c5f4e5baa134585d82db4c39
 100644
GIT binary patch
literal 110
zcmZ<^@N~{&U|?Xp@8s|75v<@85#a0y6k`O6f!H9Lf#JbFFwFr}2jnsGfW!{`1CdNz
b3_Kt%FNnp<3uE!|!C3tKU=|D8f1pMH#A*!z

literal 0
HcmV?d1

-- 
2.27.0




[PATCH 2/7] tests/acpi: add empty microvm/APIC.pcie

2020-10-16 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 tests/data/acpi/microvm/APIC.pcie | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 tests/data/acpi/microvm/APIC.pcie

diff --git a/tests/data/acpi/microvm/APIC.pcie 
b/tests/data/acpi/microvm/APIC.pcie
new file mode 100644
index ..e69de29bb2d1
-- 
2.27.0




[PATCH 7/7] tests/acpi: disallow changes for microvm/APIC.pcie

2020-10-16 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 tests/qtest/bios-tables-test-allowed-diff.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tests/qtest/bios-tables-test-allowed-diff.h 
b/tests/qtest/bios-tables-test-allowed-diff.h
index 0c37ccebc5ba..dfb8523c8bf4 100644
--- a/tests/qtest/bios-tables-test-allowed-diff.h
+++ b/tests/qtest/bios-tables-test-allowed-diff.h
@@ -1,2 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/microvm/APIC.pcie",
-- 
2.27.0




[PATCH 1/7] tests/acpi: allow changes for microvm/APIC.pcie

2020-10-16 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 tests/qtest/bios-tables-test-allowed-diff.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/qtest/bios-tables-test-allowed-diff.h 
b/tests/qtest/bios-tables-test-allowed-diff.h
index dfb8523c8bf4..0c37ccebc5ba 100644
--- a/tests/qtest/bios-tables-test-allowed-diff.h
+++ b/tests/qtest/bios-tables-test-allowed-diff.h
@@ -1 +1,2 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/microvm/APIC.pcie",
-- 
2.27.0




Re: [PATCH 1/1] Skip flatview_simplify() for cpu vendor zhaoxin

2020-10-16 Thread Paolo Bonzini
On 16/10/20 13:29, FelixCuioc wrote:
> The issue here is that an assinged EHCI device accesses
> an adjacent mapping between the delete and add phases
> of the VFIO MemoryListener.
> We want to skip flatview_simplify() is to prevent EHCI
> device IOVA mappings from being unmapped.

Hi,

there is indeed a bug, but I have already explained last month
(https://mail.gnu.org/archive/html/qemu-devel/2020-09/msg01279.html)
that this patch is conceptually wrong:

1) you're adding host_get_vendor conditioned on compiling the x86
emulator, so you are breaking compilation on non-x86 machines.

2) you're adding a check for the host, but the bug applies to all hosts.
 If there is a bug on x86 hardware emulation, it should be fixed even
when emulating x86 from ARM.  It should also apply to all CPU vendors.

Alex, the issue here is that the delete+add passes are racing against an
assigned device's DMA. For KVM we were thinking of changing the whole
memory map with a single ioctl, but that's much easier because KVM
builds its page tables lazily. It would be possible for the IOMMU too
but it would require a relatively complicated comparison of the old and
new memory maps in the kernel.

Paolo




[PATCH 0/7] microvm: fix PCIe IRQs in APIC table.

2020-10-16 Thread Gerd Hoffmann


Gerd Hoffmann (7):
  tests/acpi: allow changes for microvm/APIC.pcie
  tests/acpi: add empty microvm/APIC.pcie
  x86: make pci irqs runtime configurable
  microvm: set pci_irq_mask
  apci: drop has_pci arg for acpi_build_madt
  tests/acpi: update expected data files
  tests/acpi: disallow changes for microvm/APIC.pcie

 hw/i386/acpi-common.h |   3 +--
 include/hw/i386/x86.h |   2 ++
 hw/i386/acpi-build.c  |   2 +-
 hw/i386/acpi-common.c |  26 +++---
 hw/i386/acpi-microvm.c|   2 +-
 hw/i386/microvm.c |   6 ++
 hw/i386/x86.c |   1 +
 tests/data/acpi/microvm/APIC.pcie | Bin 0 -> 110 bytes
 8 files changed, 23 insertions(+), 19 deletions(-)
 create mode 100644 tests/data/acpi/microvm/APIC.pcie

-- 
2.27.0





[PATCH 5/7] apci: drop has_pci arg for acpi_build_madt

2020-10-16 Thread Gerd Hoffmann
Setting x86ms->pci_irq_mask to zero has the same effect,
so we don't need the has_pci argument any more.

Signed-off-by: Gerd Hoffmann 
---
 hw/i386/acpi-common.h  |  3 +--
 hw/i386/acpi-build.c   |  2 +-
 hw/i386/acpi-common.c  | 25 +++--
 hw/i386/acpi-microvm.c |  2 +-
 4 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/hw/i386/acpi-common.h b/hw/i386/acpi-common.h
index 9cac18dddf5b..c30e461f1854 100644
--- a/hw/i386/acpi-common.h
+++ b/hw/i386/acpi-common.h
@@ -9,7 +9,6 @@
 #define ACPI_BUILD_IOAPIC_ID 0x0
 
 void acpi_build_madt(GArray *table_data, BIOSLinker *linker,
- X86MachineState *x86ms, AcpiDeviceIf *adev,
- bool has_pci);
+ X86MachineState *x86ms, AcpiDeviceIf *adev);
 
 #endif
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 45ad2f953341..e3a4bc206c4e 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -2477,7 +2477,7 @@ void acpi_build(AcpiBuildTables *tables, MachineState 
*machine)
 
 acpi_add_table(table_offsets, tables_blob);
 acpi_build_madt(tables_blob, tables->linker, x86ms,
-ACPI_DEVICE_IF(x86ms->acpi_dev), true);
+ACPI_DEVICE_IF(x86ms->acpi_dev));
 
 vmgenid_dev = find_vmgenid_dev();
 if (vmgenid_dev) {
diff --git a/hw/i386/acpi-common.c b/hw/i386/acpi-common.c
index 1584abb3e6b0..8a769654060e 100644
--- a/hw/i386/acpi-common.c
+++ b/hw/i386/acpi-common.c
@@ -72,8 +72,7 @@ void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid,
 }
 
 void acpi_build_madt(GArray *table_data, BIOSLinker *linker,
- X86MachineState *x86ms, AcpiDeviceIf *adev,
- bool has_pci)
+ X86MachineState *x86ms, AcpiDeviceIf *adev)
 {
 MachineClass *mc = MACHINE_GET_CLASS(x86ms);
 const CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids(MACHINE(x86ms));
@@ -113,19 +112,17 @@ void acpi_build_madt(GArray *table_data, BIOSLinker 
*linker,
 intsrcovr->flags  = cpu_to_le16(0); /* conforms to bus specifications 
*/
 }
 
-if (has_pci) {
-for (i = 1; i < 16; i++) {
-if (!(x86ms->pci_irq_mask & (1 << i))) {
-/* No need for a INT source override structure. */
-continue;
-}
-intsrcovr = acpi_data_push(table_data, sizeof *intsrcovr);
-intsrcovr->type   = ACPI_APIC_XRUPT_OVERRIDE;
-intsrcovr->length = sizeof(*intsrcovr);
-intsrcovr->source = i;
-intsrcovr->gsi= cpu_to_le32(i);
-intsrcovr->flags  = cpu_to_le16(0xd); /* active high, level 
triggered */
+for (i = 1; i < 16; i++) {
+if (!(x86ms->pci_irq_mask & (1 << i))) {
+/* No need for a INT source override structure. */
+continue;
 }
+intsrcovr = acpi_data_push(table_data, sizeof *intsrcovr);
+intsrcovr->type   = ACPI_APIC_XRUPT_OVERRIDE;
+intsrcovr->length = sizeof(*intsrcovr);
+intsrcovr->source = i;
+intsrcovr->gsi= cpu_to_le32(i);
+intsrcovr->flags  = cpu_to_le16(0xd); /* active high, level triggered 
*/
 }
 
 if (x2apic_mode) {
diff --git a/hw/i386/acpi-microvm.c b/hw/i386/acpi-microvm.c
index 8e2d2b7cff83..5efa89c32709 100644
--- a/hw/i386/acpi-microvm.c
+++ b/hw/i386/acpi-microvm.c
@@ -196,7 +196,7 @@ static void acpi_build_microvm(AcpiBuildTables *tables,
 
 acpi_add_table(table_offsets, tables_blob);
 acpi_build_madt(tables_blob, tables->linker, X86_MACHINE(machine),
-ACPI_DEVICE_IF(x86ms->acpi_dev), x86ms->pci_irq_mask != 0);
+ACPI_DEVICE_IF(x86ms->acpi_dev));
 
 xsdt = tables_blob->len;
 build_xsdt(tables_blob, tables->linker, table_offsets, NULL, NULL);
-- 
2.27.0




[PATCH 0/4] RfC: microvm: add second ioapic

2020-10-16 Thread Gerd Hoffmann
Add a second ioapic to microvm.  Gives us more IRQ lines we can
use for virtio-mmio devices.  Bump number of possible virtio-mmio
devices from 8 to 24.

Gerd Hoffmann (4):
  microvm: make number of virtio transports runtime configurable
  microvm: make pcie irq base runtime configurable
  microvm: add second ioapic
  microvm: reconfigure irqs if second ioapic is available

 include/hw/i386/ioapic_internal.h |  2 +-
 include/hw/i386/microvm.h |  4 +--
 include/hw/i386/x86.h |  1 +
 hw/i386/acpi-common.c | 12 ++-
 hw/i386/microvm.c | 54 +--
 5 files changed, 60 insertions(+), 13 deletions(-)

-- 
2.27.0





[PATCH 3/7] x86: make pci irqs runtime configurable

2020-10-16 Thread Gerd Hoffmann
Add a variable to x86 machine state instead of
hard-coding the PCI interrupts.

Signed-off-by: Gerd Hoffmann 
---
 include/hw/i386/x86.h | 2 ++
 hw/i386/acpi-common.c | 3 +--
 hw/i386/x86.c | 1 +
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h
index d5dcf7a07fdc..bfa9cb2a258b 100644
--- a/include/hw/i386/x86.h
+++ b/include/hw/i386/x86.h
@@ -58,6 +58,7 @@ struct X86MachineState {
 
 /* CPU and apic information: */
 bool apic_xrupt_override;
+unsigned pci_irq_mask;
 unsigned apic_id_limit;
 uint16_t boot_cpus;
 unsigned smp_dies;
@@ -114,6 +115,7 @@ bool x86_machine_is_acpi_enabled(const X86MachineState 
*x86ms);
 /* Global System Interrupts */
 
 #define GSI_NUM_PINS IOAPIC_NUM_PINS
+#define ACPI_BUILD_PCI_IRQS ((1<<5) | (1<<9) | (1<<10) | (1<<11))
 
 typedef struct GSIState {
 qemu_irq i8259_irq[ISA_NUM_IRQS];
diff --git a/hw/i386/acpi-common.c b/hw/i386/acpi-common.c
index ab9b00581a15..1584abb3e6b0 100644
--- a/hw/i386/acpi-common.c
+++ b/hw/i386/acpi-common.c
@@ -115,8 +115,7 @@ void acpi_build_madt(GArray *table_data, BIOSLinker *linker,
 
 if (has_pci) {
 for (i = 1; i < 16; i++) {
-#define ACPI_BUILD_PCI_IRQS ((1<<5) | (1<<9) | (1<<10) | (1<<11))
-if (!(ACPI_BUILD_PCI_IRQS & (1 << i))) {
+if (!(x86ms->pci_irq_mask & (1 << i))) {
 /* No need for a INT source override structure. */
 continue;
 }
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index 3137a2008588..5944fc44edca 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -1178,6 +1178,7 @@ static void x86_machine_initfn(Object *obj)
 x86ms->smm = ON_OFF_AUTO_AUTO;
 x86ms->acpi = ON_OFF_AUTO_AUTO;
 x86ms->smp_dies = 1;
+x86ms->pci_irq_mask = ACPI_BUILD_PCI_IRQS;
 }
 
 static void x86_machine_class_init(ObjectClass *oc, void *data)
-- 
2.27.0




[PATCH 1/4] microvm: make number of virtio transports runtime configurable

2020-10-16 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 include/hw/i386/microvm.h | 2 +-
 hw/i386/microvm.c | 9 +++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/include/hw/i386/microvm.h b/include/hw/i386/microvm.h
index 91b064575d55..0154ad5bd707 100644
--- a/include/hw/i386/microvm.h
+++ b/include/hw/i386/microvm.h
@@ -52,7 +52,6 @@
 
 /* Platform virtio definitions */
 #define VIRTIO_MMIO_BASE  0xfeb0
-#define VIRTIO_NUM_TRANSPORTS 8
 #define VIRTIO_CMDLINE_MAXLEN 64
 
 #define GED_MMIO_BASE 0xfea0
@@ -95,6 +94,7 @@ struct MicrovmMachineState {
 
 /* Machine state */
 uint32_t virtio_irq_base;
+uint32_t virtio_num_transports;
 bool kernel_cmdline_fixed;
 Notifier machine_done;
 Notifier powerdown_req;
diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c
index 9dd74458aca4..eaf5da31f7e1 100644
--- a/hw/i386/microvm.c
+++ b/hw/i386/microvm.c
@@ -177,8 +177,13 @@ static void microvm_devices_init(MicrovmMachineState *mms)
 
 kvmclock_create(true);
 
-mms->virtio_irq_base = x86_machine_is_acpi_enabled(x86ms) ? 16 : 5;
-for (i = 0; i < VIRTIO_NUM_TRANSPORTS; i++) {
+mms->virtio_irq_base = 5;
+mms->virtio_num_transports = 8;
+if (x86_machine_is_acpi_enabled(x86ms)) {
+mms->virtio_irq_base = 16;
+}
+
+for (i = 0; i < mms->virtio_num_transports; i++) {
 sysbus_create_simple("virtio-mmio",
  VIRTIO_MMIO_BASE + i * 512,
  x86ms->gsi[mms->virtio_irq_base + i]);
-- 
2.27.0




[PATCH 2/4] microvm: make pcie irq base runtime configurable

2020-10-16 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 include/hw/i386/microvm.h |  2 +-
 hw/i386/microvm.c | 11 ++-
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/include/hw/i386/microvm.h b/include/hw/i386/microvm.h
index 0154ad5bd707..ede9625756b8 100644
--- a/include/hw/i386/microvm.h
+++ b/include/hw/i386/microvm.h
@@ -63,7 +63,6 @@
 #define PCIE_MMIO_SIZE0x2000
 #define PCIE_ECAM_BASE0xe000
 #define PCIE_ECAM_SIZE0x1000
-#define PCIE_IRQ_BASE 12
 
 /* Machine type options */
 #define MICROVM_MACHINE_PIT "pit"
@@ -93,6 +92,7 @@ struct MicrovmMachineState {
 bool auto_kernel_cmdline;
 
 /* Machine state */
+uint32_t pcie_irq_base;
 uint32_t virtio_irq_base;
 uint32_t virtio_num_transports;
 bool kernel_cmdline_fixed;
diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c
index eaf5da31f7e1..638e95c39e8c 100644
--- a/hw/i386/microvm.c
+++ b/hw/i386/microvm.c
@@ -180,6 +180,7 @@ static void microvm_devices_init(MicrovmMachineState *mms)
 mms->virtio_irq_base = 5;
 mms->virtio_num_transports = 8;
 if (x86_machine_is_acpi_enabled(x86ms)) {
+mms->pcie_irq_base = 12;
 mms->virtio_irq_base = 16;
 }
 
@@ -213,12 +214,12 @@ static void microvm_devices_init(MicrovmMachineState *mms)
 mms->gpex.mmio32.size = PCIE_MMIO_SIZE;
 mms->gpex.ecam.base   = PCIE_ECAM_BASE;
 mms->gpex.ecam.size   = PCIE_ECAM_SIZE;
-mms->gpex.irq = PCIE_IRQ_BASE;
+mms->gpex.irq = mms->pcie_irq_base;
 create_gpex(mms);
-x86ms->pci_irq_mask = ((1 << (PCIE_IRQ_BASE + 0)) |
-   (1 << (PCIE_IRQ_BASE + 1)) |
-   (1 << (PCIE_IRQ_BASE + 2)) |
-   (1 << (PCIE_IRQ_BASE + 3)));
+x86ms->pci_irq_mask = ((1 << (mms->pcie_irq_base + 0)) |
+   (1 << (mms->pcie_irq_base + 1)) |
+   (1 << (mms->pcie_irq_base + 2)) |
+   (1 << (mms->pcie_irq_base + 3)));
 } else {
 x86ms->pci_irq_mask = 0;
 }
-- 
2.27.0




[PULL 02/22] Makefile: Ensure cscope.out/tags/TAGS are generated in the source tree

2020-10-16 Thread Paolo Bonzini
From: Greg Kurz 

Tools usually expect the index files to be in the source tree, eg. emacs.
This is already the case when doing out-of-tree builds, but with in-tree
builds they end up in the build directory.

Force cscope, ctags and etags to put them in the source tree.

Signed-off-by: Greg Kurz 
Message-Id: <160277334665.1754102.10921580280105870386.st...@bahia.lan>
Signed-off-by: Paolo Bonzini 
---
 Makefile | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index c37e513431..d20c7a3f80 100644
--- a/Makefile
+++ b/Makefile
@@ -194,19 +194,19 @@ find-src-path = find "$(SRC_PATH)/" -path 
"$(SRC_PATH)/meson" -prune -o -name "*
 
 .PHONY: ctags
 ctags:
-   rm -f tags
-   $(find-src-path) -exec ctags --append {} +
+   rm -f "$(SRC_PATH)/"tags
+   $(find-src-path) -exec ctags -f "$(SRC_PATH)/"tags --append {} +
 
 .PHONY: TAGS
 TAGS:
-   rm -f TAGS
-   $(find-src-path) -exec etags --append {} +
+   rm -f "$(SRC_PATH)/"TAGS
+   $(find-src-path) -exec etags -f "$(SRC_PATH)/"TAGS --append {} +
 
 .PHONY: cscope
 cscope:
rm -f "$(SRC_PATH)"/cscope.*
$(find-src-path) -print | sed -e 's,^\./,,' > "$(SRC_PATH)/cscope.files"
-   cscope -b -i"$(SRC_PATH)/cscope.files"
+   cscope -b -i"$(SRC_PATH)/cscope.files" -f"$(SRC_PATH)"/cscope.out
 
 # Needed by "meson install"
 export DESTDIR
-- 
2.26.2





[PULL 08/22] add ninja to dockerfiles, CI configurations and test VMs

2020-10-16 Thread Paolo Bonzini
Reviewed-by: Daniel P. Berrangé 
Acked-by: Alex Bennée 
Signed-off-by: Paolo Bonzini 
---
 .cirrus.yml|  6 +++---
 .travis.yml| 13 +
 tests/docker/dockerfiles/centos7.docker|  1 +
 tests/docker/dockerfiles/centos8.docker|  1 +
 tests/docker/dockerfiles/debian10.docker   |  1 +
 tests/docker/dockerfiles/fedora.docker |  1 +
 tests/docker/dockerfiles/travis.docker |  2 +-
 tests/docker/dockerfiles/ubuntu.docker |  1 +
 tests/docker/dockerfiles/ubuntu1804.docker |  1 +
 tests/docker/dockerfiles/ubuntu2004.docker |  1 +
 tests/vm/centos|  2 +-
 tests/vm/centos.aarch64|  2 +-
 tests/vm/fedora|  2 +-
 tests/vm/freebsd   |  1 +
 tests/vm/netbsd|  1 +
 tests/vm/openbsd   |  1 +
 tests/vm/ubuntu.aarch64|  2 +-
 tests/vm/ubuntu.i386   |  2 +-
 18 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/.cirrus.yml b/.cirrus.yml
index 0f46cb5eaf..396888fbd3 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -9,7 +9,7 @@ freebsd_12_task:
   install_script:
 - ASSUME_ALWAYS_YES=yes pkg bootstrap -f ;
 - pkg install -y bash curl cyrus-sasl git glib gmake gnutls gsed
-  nettle perl5 pixman pkgconf png usbredir
+  nettle perl5 pixman pkgconf png usbredir ninja
   script:
 - mkdir build
 - cd build
@@ -21,7 +21,7 @@ macos_task:
   osx_instance:
 image: catalina-base
   install_script:
-- brew install pkg-config python gnu-sed glib pixman make sdl2 bash
+- brew install pkg-config python gnu-sed glib pixman make sdl2 bash ninja
   script:
 - mkdir build
 - cd build
@@ -36,7 +36,7 @@ macos_xcode_task:
 # this is an alias for the latest Xcode
 image: catalina-xcode
   install_script:
-- brew install pkg-config gnu-sed glib pixman make sdl2 bash
+- brew install pkg-config gnu-sed glib pixman make sdl2 bash ninja
   script:
 - mkdir build
 - cd build
diff --git a/.travis.yml b/.travis.yml
index 1054ec5d29..d7bfbb8bfe 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -49,6 +49,7 @@ addons:
   - libvdeplug-dev
   - libvte-2.91-dev
   - libzstd-dev
+  - ninja-build
   - sparse
   - uuid-dev
   - gcovr
@@ -177,6 +178,7 @@ jobs:
   addons:
 apt:
   packages:
+- ninja-build
 - python3-sphinx
 - perl
 
@@ -211,6 +213,10 @@ jobs:
 # gprof/gcov are GCC features
 - name: "GCC gprof/gcov"
   dist: bionic
+  addons:
+apt:
+  packages:
+- ninja-build
   env:
 - CONFIG="--enable-gprof --enable-gcov --disable-libssh
   --target-list=${MAIN_SOFTMMU_TARGETS}"
@@ -281,6 +287,7 @@ jobs:
 - liburcu-dev
 - libusb-1.0-0-dev
 - libvte-2.91-dev
+- ninja-build
 - sparse
 - uuid-dev
   language: generic
@@ -346,6 +353,7 @@ jobs:
   - libusb-1.0-0-dev
   - libvdeplug-dev
   - libvte-2.91-dev
+  - ninja-build
   # Tests dependencies
   - genisoimage
   env:
@@ -379,6 +387,7 @@ jobs:
   - libusb-1.0-0-dev
   - libvdeplug-dev
   - libvte-2.91-dev
+  - ninja-build
   # Tests dependencies
   - genisoimage
   env:
@@ -411,6 +420,7 @@ jobs:
   - libusb-1.0-0-dev
   - libvdeplug-dev
   - libvte-2.91-dev
+  - ninja-build
   # Tests dependencies
   - genisoimage
   env:
@@ -450,6 +460,7 @@ jobs:
   - libzstd-dev
   - nettle-dev
   - xfslibs-dev
+  - ninja-build
   # Tests dependencies
   - genisoimage
   env:
@@ -463,6 +474,7 @@ jobs:
 apt_packages:
   - libgcrypt20-dev
   - libgnutls28-dev
+  - ninja-build
   env:
 - CONFIG="--disable-containers --disable-system"
 
@@ -493,6 +505,7 @@ jobs:
   - libusb-1.0-0-dev
   - libvdeplug-dev
   - libvte-2.91-dev
+  - ninja-build
   env:
 - TEST_CMD="make check-unit"
 - CONFIG="--disable-containers --disable-tcg --enable-kvm
diff --git a/tests/docker/dockerfiles/centos7.docker 
b/tests/docker/dockerfiles/centos7.docker
index 4623bf..8b273725ee 100644
--- a/tests/docker/dockerfiles/centos7.docker
+++ b/tests/docker/dockerfiles/centos7.docker
@@ -27,6 +27,7 @@ ENV PACKAGES \
 mesa-libEGL-devel \
 mesa-libgbm-devel \
 nettle-devel \
+ninja-build \
 perl-Test-Harness \
 pixman-devel \
 python3 \
diff --git a/tests/docker/dockerfiles/centos8.docker 
b/tests/docker/dockerfiles/centos8.docker
index e29e9657fb..585dfad9be 100644
--- a/tests/docker/dockerfiles/centos8.docker
+++ b/tests/docker/dockerfiles/centos8.docker
@@ 

[PATCH 3/4] microvm: add second ioapic

2020-10-16 Thread Gerd Hoffmann
Add more IRQ lines.  Depends on ACPI.
Also enable this only with userspace ioapic,
not sure whenever the kernel can handle two ioapics.

Signed-off-by: Gerd Hoffmann 
---
 include/hw/i386/ioapic_internal.h |  2 +-
 include/hw/i386/x86.h |  1 +
 hw/i386/acpi-common.c | 10 ++
 hw/i386/microvm.c | 30 --
 4 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/include/hw/i386/ioapic_internal.h 
b/include/hw/i386/ioapic_internal.h
index 0ac9e2400d6b..4cebd2e32c9f 100644
--- a/include/hw/i386/ioapic_internal.h
+++ b/include/hw/i386/ioapic_internal.h
@@ -27,7 +27,7 @@
 #include "qemu/notify.h"
 #include "qom/object.h"
 
-#define MAX_IOAPICS 1
+#define MAX_IOAPICS 2
 
 #define IOAPIC_LVT_DEST_SHIFT   56
 #define IOAPIC_LVT_DEST_IDX_SHIFT   48
diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h
index bfa9cb2a258b..6da57033a875 100644
--- a/include/hw/i386/x86.h
+++ b/include/hw/i386/x86.h
@@ -120,6 +120,7 @@ bool x86_machine_is_acpi_enabled(const X86MachineState 
*x86ms);
 typedef struct GSIState {
 qemu_irq i8259_irq[ISA_NUM_IRQS];
 qemu_irq ioapic_irq[IOAPIC_NUM_PINS];
+qemu_irq ioapic2_irq[IOAPIC_NUM_PINS];
 } GSIState;
 
 qemu_irq x86_allocate_cpu_irq(void);
diff --git a/hw/i386/acpi-common.c b/hw/i386/acpi-common.c
index 8a769654060e..f0689392a39f 100644
--- a/hw/i386/acpi-common.c
+++ b/hw/i386/acpi-common.c
@@ -103,6 +103,16 @@ void acpi_build_madt(GArray *table_data, BIOSLinker 
*linker,
 io_apic->address = cpu_to_le32(IO_APIC_DEFAULT_ADDRESS);
 io_apic->interrupt = cpu_to_le32(0);
 
+if (object_property_find(OBJECT(x86ms), "ioapic2")) {
+AcpiMadtIoApic *io_apic2;
+io_apic2 = acpi_data_push(table_data, sizeof *io_apic);
+io_apic2->type = ACPI_APIC_IO;
+io_apic2->length = sizeof(*io_apic);
+io_apic2->io_apic_id = ACPI_BUILD_IOAPIC_ID + 1;
+io_apic2->address = cpu_to_le32(IO_APIC_DEFAULT_ADDRESS + 0x1);
+io_apic2->interrupt = cpu_to_le32(24);
+}
+
 if (x86ms->apic_xrupt_override) {
 intsrcovr = acpi_data_push(table_data, sizeof *intsrcovr);
 intsrcovr->type   = ACPI_APIC_XRUPT_OVERRIDE;
diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c
index 638e95c39e8c..15c3e078a4aa 100644
--- a/hw/i386/microvm.c
+++ b/hw/i386/microvm.c
@@ -99,7 +99,11 @@ static void microvm_gsi_handler(void *opaque, int n, int 
level)
 {
 GSIState *s = opaque;
 
-qemu_set_irq(s->ioapic_irq[n], level);
+if (n >= 24) {
+qemu_set_irq(s->ioapic2_irq[n - 24], level);
+} else {
+qemu_set_irq(s->ioapic_irq[n], level);
+}
 }
 
 static void create_gpex(MicrovmMachineState *mms)
@@ -157,6 +161,7 @@ static void microvm_devices_init(MicrovmMachineState *mms)
 ISABus *isa_bus;
 ISADevice *rtc_state;
 GSIState *gsi_state;
+bool ioapic2 = false;
 int i;
 
 /* Core components */
@@ -165,8 +170,13 @@ static void microvm_devices_init(MicrovmMachineState *mms)
 if (mms->pic == ON_OFF_AUTO_ON || mms->pic == ON_OFF_AUTO_AUTO) {
 x86ms->gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
 } else {
+int pins = GSI_NUM_PINS;
+if (!kvm_ioapic_in_kernel() && x86_machine_is_acpi_enabled(x86ms)) {
+ioapic2 = true;
+pins += 24;
+}
 x86ms->gsi = qemu_allocate_irqs(microvm_gsi_handler,
-gsi_state, GSI_NUM_PINS);
+gsi_state, pins);
 }
 
 isa_bus = isa_bus_new(NULL, get_system_memory(), get_system_io(),
@@ -175,6 +185,22 @@ static void microvm_devices_init(MicrovmMachineState *mms)
 
 ioapic_init_gsi(gsi_state, "machine");
 
+if (ioapic2) {
+DeviceState *dev;
+SysBusDevice *d;
+unsigned int i;
+
+dev = qdev_new(TYPE_IOAPIC);
+object_property_add_child(OBJECT(mms), "ioapic2", OBJECT(dev));
+d = SYS_BUS_DEVICE(dev);
+sysbus_realize_and_unref(d, &error_fatal);
+sysbus_mmio_map(d, 0, IO_APIC_DEFAULT_ADDRESS + 0x1);
+
+for (i = 0; i < IOAPIC_NUM_PINS; i++) {
+gsi_state->ioapic2_irq[i] = qdev_get_gpio_in(dev, i);
+}
+}
+
 kvmclock_create(true);
 
 mms->virtio_irq_base = 5;
-- 
2.27.0




[PULL 00/22] Build system + misc changes for 2020-10-16

2020-10-16 Thread Paolo Bonzini
The following changes since commit 57c98ea9acdcef5021f5671efa6475a5794a51c4:

  Merge remote-tracking branch 'remotes/kraxel/tags/ui-20201014-pull-request' 
into staging (2020-10-14 13:56:06 +0100)

are available in the Git repository at:

  https://gitlab.com/bonzini/qemu.git tags/for-upstream

for you to fetch changes up to 2a2f0924537993510e8d24d60ec2a43e7b4a72a9:

  ci: include configure and meson logs in all jobs if configure fails 
(2020-10-16 07:44:38 -0400)


* Drop ninjatool and just require ninja (Paolo)
* Fix docs build under msys2 (Yonggang)
* HAX snafu fix (Claudio)
* Disable signal handlers during fuzzing (Alex)
* Miscellaneous fixes (Bruce, Greg)


Alexander Bulekov (1):
  fuzz: Disable QEMU's SIG{INT,HUP,TERM} handlers

Bruce Rogers (3):
  meson.build: don't condition iconv detection on library detection
  configure: fix handling of --docdir parameter
  meson: Only install icons and qemu.desktop if have_system

Claudio Fontana (1):
  hax: unbreak accelerator cpu code after cpus.c split

Greg Kurz (1):
  Makefile: Ensure cscope.out/tags/TAGS are generated in the source tree

Paolo Bonzini (13):
  submodules: bump meson to 0.55.3
  tests/Makefile.include: unbreak non-tcg builds
  make: run shell with pipefail
  tests: add missing generated sources to testqapi
  configure: move QEMU_INCLUDES to meson
  dockerfiles: enable Centos 8 PowerTools
  add ninja to dockerfiles, CI configurations and test VMs
  build: cleanups to Makefile
  build: replace ninjatool with ninja
  build: add --enable/--disable-libudev
  meson: cleanup curses/iconv test
  meson: move SPHINX_ARGS references within "if build_docs"
  ci: include configure and meson logs in all jobs if configure fails

Yonggang Luo (3):
  docs: Fix Sphinx configuration for msys2/mingw
  meson: Move the detection logic for sphinx to meson
  cirrus: Enable doc build on msys2/mingw

 .cirrus.yml|   21 +-
 .gitlab-ci.yml |6 +-
 .travis.yml|   21 +-
 Makefile   |  134 ++--
 configure  |   99 +--
 docs/conf.py   |2 +-
 docs/devel/build-system.rst|6 +-
 docs/meson.build   |   46 ++
 docs/sphinx/kerneldoc.py   |2 +-
 meson  |2 +-
 meson.build|  185 ++---
 meson_options.txt  |6 +
 scripts/mtest2make.py  |3 +-
 scripts/ninjatool.py   | 1008 
 target/i386/hax-cpus.c |1 +
 tests/Makefile.include |2 +-
 tests/docker/dockerfiles/centos7.docker|1 +
 tests/docker/dockerfiles/centos8.docker|5 +-
 tests/docker/dockerfiles/debian10.docker   |1 +
 tests/docker/dockerfiles/fedora.docker |1 +
 tests/docker/dockerfiles/travis.docker |2 +-
 tests/docker/dockerfiles/ubuntu.docker |1 +
 tests/docker/dockerfiles/ubuntu1804.docker |1 +
 tests/docker/dockerfiles/ubuntu2004.docker |1 +
 tests/include/meson.build  |8 +-
 tests/meson.build  |   14 +-
 tests/qapi-schema/meson.build  |   88 +--
 tests/qtest/fuzz/fuzz.c|8 +
 tests/vm/centos|2 +-
 tests/vm/centos.aarch64|2 +-
 tests/vm/fedora|2 +-
 tests/vm/freebsd   |1 +
 tests/vm/netbsd|1 +
 tests/vm/openbsd   |1 +
 tests/vm/ubuntu.aarch64|2 +-
 tests/vm/ubuntu.i386   |2 +-
 ui/meson.build |7 +-
 37 files changed, 387 insertions(+), 1308 deletions(-)
 delete mode 100755 scripts/ninjatool.py
-- 
2.26.2




[PULL 11/22] build: add --enable/--disable-libudev

2020-10-16 Thread Paolo Bonzini
Initially, libudev detection was bundled with --enable-mpath because
qemu-pr-helper was the only user of libudev.  Recently however the USB
U2F emulation has also started using libudev, so add a separate
option.  This also allows 1) disabling libudev if desired for static
builds and 2) for non-static builds, requiring libudev even if
multipath support is undesirable.

The multipath test is adjusted, because it is now possible to enter it
with configurations that should fail, such as --static --enable-mpath
--disable-libudev.

Reported-by: Peter Maydell 
Signed-off-by: Paolo Bonzini 
---
 configure |  8 +++-
 meson.build   | 50 ++-
 meson_options.txt |  2 ++
 3 files changed, 37 insertions(+), 23 deletions(-)

diff --git a/configure b/configure
index 9317349044..c83a2eeb9d 100755
--- a/configure
+++ b/configure
@@ -303,6 +303,7 @@ netmap="no"
 sdl="auto"
 sdl_image="auto"
 virtfs=""
+libudev="auto"
 mpath="auto"
 vnc="enabled"
 sparse="auto"
@@ -1002,6 +1003,10 @@ for opt do
   ;;
   --enable-virtfs) virtfs="yes"
   ;;
+  --disable-libudev) libudev="disabled"
+  ;;
+  --enable-libudev) libudev="enabled"
+  ;;
   --disable-mpath) mpath="disabled"
   ;;
   --enable-mpath) mpath="enabled"
@@ -1759,6 +1764,7 @@ disabled with --disable-FEATURE, default is enabled if 
available:
   vnc-png PNG compression for VNC server
   cocoa   Cocoa UI (Mac OS X only)
   virtfs  VirtFS
+  libudev Use libudev to enumerate host devices
   mpath   Multipath persistent reservation passthrough
   xen xen backend driver support
   xen-pci-passthroughPCI passthrough support for Xen
@@ -7060,7 +7066,7 @@ NINJA=$ninja $meson setup \
 -Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg 
-Dvnc_png=$vnc_png \
 -Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f \
 -Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt \
--Diconv=$iconv -Dcurses=$curses \
+-Diconv=$iconv -Dcurses=$curses -Dlibudev=$libudev\
 $cross_arg \
 "$PWD" "$source_path"
 
diff --git a/meson.build b/meson.build
index 2c93e22382..0c0f4f9fd8 100644
--- a/meson.build
+++ b/meson.build
@@ -380,10 +380,11 @@ endif
 libudev = not_found
 if targetos == 'linux' and (have_system or have_tools)
   libudev = dependency('libudev',
-   required: get_option('mpath').enabled(),
+   required: get_option('libudev'),
static: enable_static)
 endif
 
+mpathlibs = [libudev]
 mpathpersist = not_found
 mpathpersist_new_api = false
 if targetos == 'linux' and have_tools and not get_option('mpath').disabled()
@@ -414,35 +415,40 @@ if targetos == 'linux' and have_tools and not 
get_option('mpath').disabled()
   mpath_lib_init(udev);
   return 0;
   }'''
-  mpathlibs = [libudev]
-  if enable_static
-mpathlibs += cc.find_library('devmapper',
-   required: get_option('mpath'),
-   static: enable_static)
-  endif
-  mpathlibs += cc.find_library('multipath',
-   required: get_option('mpath'),
-   static: enable_static)
-  mpathlibs += cc.find_library('mpathpersist',
-   required: get_option('mpath'),
-   static: enable_static)
-  foreach lib: mpathlibs
-if not lib.found()
-  mpathlibs = []
-  break
+  libmpathpersist = cc.find_library('mpathpersist',
+required: get_option('mpath'),
+static: enable_static)
+  if libmpathpersist.found()
+mpathlibs += libmpathpersist
+if enable_static
+  mpathlibs += cc.find_library('devmapper',
+ required: get_option('mpath'),
+ static: enable_static)
 endif
-  endforeach
-  if mpathlibs.length() > 0
-if cc.links(mpath_test_source_new, dependencies: mpathlibs)
+mpathlibs += cc.find_library('multipath',
+ required: get_option('mpath'),
+ static: enable_static)
+foreach lib: mpathlibs
+  if not lib.found()
+mpathlibs = []
+break
+  endif
+endforeach
+if mpathlibs.length() == 0
+  msg = 'Dependencies missing for libmpathpersist'
+elif cc.links(mpath_test_source_new, dependencies: mpathlibs)
   mpathpersist = declare_dependency(dependencies: mpathlibs)
   mpathpersist_new_api = true
 elif cc.links(mpath_test_source_old, dependencies: mpathlibs)
   mpathpersist = declare_dependency(dependencies: mpathlibs)
 else
+  msg = 'Cannot detect libmpathpersist API'
+endif
+if not mpathpersist.found()
   if get_option('mpath').enabled()
-error('Cannot detect libmpathpersist API')
+error(msg)
   else
-warning('Can

[PULL 07/22] dockerfiles: enable Centos 8 PowerTools

2020-10-16 Thread Paolo Bonzini
ninja is included in the CentOS PowerTools repository.

Signed-off-by: Paolo Bonzini 
---
 tests/docker/dockerfiles/centos8.docker | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tests/docker/dockerfiles/centos8.docker 
b/tests/docker/dockerfiles/centos8.docker
index 0fc2697491..e29e9657fb 100644
--- a/tests/docker/dockerfiles/centos8.docker
+++ b/tests/docker/dockerfiles/centos8.docker
@@ -28,5 +28,7 @@ ENV PACKAGES \
 tar \
 zlib-devel
 
-RUN dnf install -y $PACKAGES
+RUN dnf install -y dnf-plugins-core && \
+  dnf config-manager --set-enabled PowerTools && \
+  dnf install -y $PACKAGES
 RUN rpm -q $PACKAGES | sort > /packages.txt
-- 
2.26.2





[PATCH 4/4] microvm: reconfigure irqs if second ioapic is available

2020-10-16 Thread Gerd Hoffmann
Use GSI 16+ for PCIe (needs acpi_build_madt() tweak).
Use GSI 24+ (second ioapic) for virtio-mmio.
Use all irq lines of the second ioapic
and allow up to 24 virtio-mmio devices.

Signed-off-by: Gerd Hoffmann 
---
 hw/i386/acpi-common.c | 2 +-
 hw/i386/microvm.c | 6 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/hw/i386/acpi-common.c b/hw/i386/acpi-common.c
index f0689392a39f..1653a8315248 100644
--- a/hw/i386/acpi-common.c
+++ b/hw/i386/acpi-common.c
@@ -122,7 +122,7 @@ void acpi_build_madt(GArray *table_data, BIOSLinker *linker,
 intsrcovr->flags  = cpu_to_le16(0); /* conforms to bus specifications 
*/
 }
 
-for (i = 1; i < 16; i++) {
+for (i = 1; i < 24; i++) {
 if (!(x86ms->pci_irq_mask & (1 << i))) {
 /* No need for a INT source override structure. */
 continue;
diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c
index 15c3e078a4aa..70bb8a4e3954 100644
--- a/hw/i386/microvm.c
+++ b/hw/i386/microvm.c
@@ -205,7 +205,11 @@ static void microvm_devices_init(MicrovmMachineState *mms)
 
 mms->virtio_irq_base = 5;
 mms->virtio_num_transports = 8;
-if (x86_machine_is_acpi_enabled(x86ms)) {
+if (ioapic2) {
+mms->pcie_irq_base = 16;
+mms->virtio_irq_base = 24;
+mms->virtio_num_transports = 24;
+} else if (x86_machine_is_acpi_enabled(x86ms)) {
 mms->pcie_irq_base = 12;
 mms->virtio_irq_base = 16;
 }
-- 
2.27.0




[PULL 06/22] configure: move QEMU_INCLUDES to meson

2020-10-16 Thread Paolo Bonzini
Confusingly, QEMU_INCLUDES is not used by configure tests.  Moving
it to meson.build ensures that Windows paths are specified instead of
the msys paths like /c/Users/...

Reviewed-by: Daniel P. Berrangé 
Signed-off-by: Paolo Bonzini 
---
 configure   | 20 
 meson.build | 30 --
 2 files changed, 28 insertions(+), 22 deletions(-)

diff --git a/configure b/configure
index f839c2a557..8aa03876d4 100755
--- a/configure
+++ b/configure
@@ -537,8 +537,6 @@ QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv 
$QEMU_CFLAGS"
 QEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE 
$QEMU_CFLAGS"
-QEMU_INCLUDES="-iquote . -iquote ${source_path} -iquote 
${source_path}/accel/tcg -iquote ${source_path}/include"
-QEMU_INCLUDES="$QEMU_INCLUDES -iquote ${source_path}/disas/libvixl"
 
 # Flags that are needed during configure but later taken care of by Meson
 CONFIGURE_CFLAGS="-std=gnu99 -Wall"
@@ -796,7 +794,6 @@ Linux)
   audio_possible_drivers="oss alsa sdl pa"
   linux="yes"
   linux_user="yes"
-  QEMU_INCLUDES="-isystem ${source_path}/linux-headers -Ilinux-headers 
$QEMU_INCLUDES"
 ;;
 esac
 
@@ -6776,22 +6773,6 @@ if test "$secret_keyring" = "yes" ; then
   echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
 fi
 
-if test "$tcg_interpreter" = "yes"; then
-  QEMU_INCLUDES="-iquote ${source_path}/tcg/tci $QEMU_INCLUDES"
-elif test "$ARCH" = "sparc64" ; then
-  QEMU_INCLUDES="-iquote ${source_path}/tcg/sparc $QEMU_INCLUDES"
-elif test "$ARCH" = "s390x" ; then
-  QEMU_INCLUDES="-iquote ${source_path}/tcg/s390 $QEMU_INCLUDES"
-elif test "$ARCH" = "x86_64" || test "$ARCH" = "x32" ; then
-  QEMU_INCLUDES="-iquote ${source_path}/tcg/i386 $QEMU_INCLUDES"
-elif test "$ARCH" = "ppc64" ; then
-  QEMU_INCLUDES="-iquote ${source_path}/tcg/ppc $QEMU_INCLUDES"
-elif test "$ARCH" = "riscv32" || test "$ARCH" = "riscv64" ; then
-  QEMU_INCLUDES="-I${source_path}/tcg/riscv $QEMU_INCLUDES"
-else
-  QEMU_INCLUDES="-iquote ${source_path}/tcg/${ARCH} $QEMU_INCLUDES"
-fi
-
 echo "ROMS=$roms" >> $config_host_mak
 echo "MAKE=$make" >> $config_host_mak
 echo "PYTHON=$python" >> $config_host_mak
@@ -6818,7 +6799,6 @@ echo "WINDRES=$windres" >> $config_host_mak
 echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
 echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
-echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
 echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
 echo "GLIB_LIBS=$glib_libs" >> $config_host_mak
 echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
diff --git a/meson.build b/meson.build
index 1a4a482492..88f757eac9 100644
--- a/meson.build
+++ b/meson.build
@@ -93,9 +93,35 @@ add_project_arguments(config_host['QEMU_CXXFLAGS'].split(),
   native: false, language: 'cpp')
 add_project_link_arguments(config_host['QEMU_LDFLAGS'].split(),
native: false, language: ['c', 'cpp', 'objc'])
-add_project_arguments(config_host['QEMU_INCLUDES'].split(),
-  language: ['c', 'cpp', 'objc'])
 
+if targetos == 'linux'
+  add_project_arguments('-isystem', meson.current_source_dir() / 
'linux-headers',
+'-isystem', 'linux-headers',
+language: ['c', 'cpp'])
+endif
+
+if 'CONFIG_TCG_INTERPRETER' in config_host
+  tcg_arch = 'tci'
+elif config_host['ARCH'] == 'sparc64'
+  tcg_arch = 'sparc'
+elif config_host['ARCH'] == 's390x'
+  tcg_arch = 's390'
+elif config_host['ARCH'] in ['x86_64', 'x32']
+  tcg_arch = 'i386'
+elif config_host['ARCH'] == 'ppc64'
+  tcg_arch = 'ppc'
+elif config_host['ARCH'] in ['riscv32', 'riscv64']
+  tcg_arch = 'riscv'
+else
+  tcg_arch = config_host['ARCH']
+endif
+add_project_arguments('-iquote', meson.current_source_dir() / 'tcg' / tcg_arch,
+  '-iquote', '.',
+  '-iquote', meson.current_source_dir(),
+  '-iquote', meson.current_source_dir() / 'accel/tcg',
+  '-iquote', meson.current_source_dir() / 'include',
+  '-iquote', meson.current_source_dir() / 'disas/libvixl',
+  language: ['c', 'cpp', 'objc'])
 
 link_language = meson.get_external_property('link_language', 'cpp')
 if link_language == 'cpp'
-- 
2.26.2





[PULL 04/22] make: run shell with pipefail

2020-10-16 Thread Paolo Bonzini
Without pipefail, it is possible to miss failures if the recipes
include pipes.

Reviewed-by: Daniel P. Berrangé 
Signed-off-by: Paolo Bonzini 
---
 Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Makefile b/Makefile
index d20c7a3f80..91c62a26c8 100644
--- a/Makefile
+++ b/Makefile
@@ -14,6 +14,8 @@ SRC_PATH=.
 # we have explicit rules for everything
 MAKEFLAGS += -rR
 
+SHELL = /usr/bin/env bash -o pipefail
+
 # Usage: $(call quiet-command,command and args,"NAME","args to print")
 # This will run "command and args", and either:
 #  if V=1 just print the whole command and args
-- 
2.26.2





[PULL 14/22] configure: fix handling of --docdir parameter

2020-10-16 Thread Paolo Bonzini
From: Bruce Rogers 

Commit ca8c0909f01 changed qemu_docdir to be docdir, then later uses the
qemu_docdir name in the final assignment. Unfortunately, one instance of
qemu_docdir was missed: the one which comes from the --docdir parameter.
This patch restores the proper handling of the --docdir parameter.

Fixes: ca8c0909f01 ("configure: build docdir like other suffixed
directories")

Signed-off-by: Bruce Rogers 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20201015190742.270629-1-brog...@suse.com>
Signed-off-by: Paolo Bonzini 
---
 configure | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/configure b/configure
index c83a2eeb9d..3edbdd2a24 100755
--- a/configure
+++ b/configure
@@ -969,7 +969,7 @@ for opt do
   ;;
   --with-suffix=*) qemu_suffix="$optarg"
   ;;
-  --docdir=*) qemu_docdir="$optarg"
+  --docdir=*) docdir="$optarg"
   ;;
   --sysconfdir=*) sysconfdir="$optarg"
   ;;
@@ -5776,7 +5776,6 @@ fi
 qemu_confdir="$sysconfdir/$qemu_suffix"
 qemu_moddir="$libdir/$qemu_suffix"
 qemu_datadir="$datadir/$qemu_suffix"
-qemu_docdir="$docdir/$qemu_suffix"
 qemu_localedir="$datadir/locale"
 qemu_icondir="$datadir/icons"
 qemu_desktopdir="$datadir/applications"
-- 
2.26.2





[PULL 01/22] submodules: bump meson to 0.55.3

2020-10-16 Thread Paolo Bonzini
This adds some bugfixes, and allows MSYS2 to configure
without "--ninja=ninja".

Signed-off-by: Paolo Bonzini 
---
 .cirrus.yml | 3 +--
 meson   | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/.cirrus.yml b/.cirrus.yml
index 99d118239c..0f46cb5eaf 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -123,8 +123,7 @@ windows_msys2_task:
 
   script:
 - C:\tools\msys64\usr\bin\bash.exe -lc "mkdir build"
-- C:\tools\msys64\usr\bin\bash.exe -lc "cd build && ../configure
-  --python=python3 --ninja=ninja"
+- C:\tools\msys64\usr\bin\bash.exe -lc "cd build && ../configure 
--python=python3"
 - C:\tools\msys64\usr\bin\bash.exe -lc "cd build && make -j8"
   test_script:
 - C:\tools\msys64\usr\bin\bash.exe -lc "cd build && make V=1 check"
diff --git a/meson b/meson
index 68ed748f84..776acd2a80 16
--- a/meson
+++ b/meson
@@ -1 +1 @@
-Subproject commit 68ed748f84f14c2d4e62dcbd123816e5898eb04c
+Subproject commit 776acd2a805c9b42b4f0375150977df42130317f
-- 
2.26.2





[PULL 09/22] build: cleanups to Makefile

2020-10-16 Thread Paolo Bonzini
Group similar rules, add comments to "else" and "endif" lines,
detect too-old config-host.mak before messing things up.

Signed-off-by: Paolo Bonzini 
---
 Makefile | 45 -
 1 file changed, 28 insertions(+), 17 deletions(-)

diff --git a/Makefile b/Makefile
index 91c62a26c8..53d624a0be 100644
--- a/Makefile
+++ b/Makefile
@@ -30,13 +30,21 @@ UNCHECKED_GOALS := %clean TAGS cscope ctags dist \
 help check-help print-% \
 docker docker-% vm-help vm-test vm-build-%
 
+all:
+.PHONY: all clean distclean recurse-all dist msi FORCE
+
+# Don't try to regenerate Makefile or configure
+# We don't generate any of them
+Makefile: ;
+configure: ;
+
 # All following code might depend on configuration variables
 ifneq ($(wildcard config-host.mak),)
-# Put the all: rule here so that config-host.mak can contain dependencies.
-all:
 include config-host.mak
 
 git-submodule-update:
+.git-submodule-status: git-submodule-update config-host.mak
+Makefile: .git-submodule-status
 
 .PHONY: git-submodule-update
 
@@ -84,9 +92,7 @@ Makefile.mtest: build.ninja scripts/mtest2make.py
 -include Makefile.mtest
 endif
 
-Makefile: .git-submodule-status
-.git-submodule-status: git-submodule-update config-host.mak
-
+# Ensure the build tree is okay.
 # Check that we're not trying to do an out-of-tree build from
 # a tree that's been used for an in-tree build.
 ifneq ($(realpath $(SRC_PATH)),$(realpath .))
@@ -97,6 +103,20 @@ seems to have been used for an in-tree build. You can fix 
this by running \
 endif
 endif
 
+# force a rerun of configure if config-host.mak is too old or corrupted
+ifeq ($(MESON),)
+.PHONY: config-host.mak
+x := $(shell rm -rf meson-private meson-info meson-logs)
+endif
+ifeq ($(NINJA),)
+.PHONY: config-host.mak
+x := $(shell rm -rf meson-private meson-info meson-logs)
+endif
+ifeq ($(wildcard build.ninja),)
+.PHONY: config-host.mak
+x := $(shell rm -rf meson-private meson-info meson-logs)
+endif
+
 config-host.mak: $(SRC_PATH)/configure $(SRC_PATH)/pc-bios $(SRC_PATH)/VERSION
@echo $@ is out-of-date, running configure
@if test -f meson-private/coredata.dat; then \
@@ -114,15 +134,15 @@ plugins:
$(call quiet-command,\
$(MAKE) $(SUBDIR_MAKEFLAGS) -C contrib/plugins V="$(V)", \
"BUILD", "example plugins")
-endif
+endif # $(CONFIG_PLUGIN)
 
-else
+else # config-host.mak does not exist
 config-host.mak:
 ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if 
$(MAKECMDGOALS),,fail))
@echo "Please call configure before running make!"
@exit 1
 endif
-endif
+endif # config-host.mak does not exist
 
 # Only needed in case Makefile.ninja does not exist.
 .PHONY: ninja-clean ninja-distclean clean-ctlist
@@ -131,20 +151,11 @@ ninja-clean::
 ninja-distclean::
 build.ninja: config-host.mak
 
-# Don't try to regenerate Makefile or configure
-# We don't generate any of them
-Makefile: ;
-configure: ;
-
-.PHONY: all clean distclean install \
-   recurse-all dist msi FORCE
-
 SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory --quiet)
 
 include $(SRC_PATH)/tests/Makefile.include
 
 all: recurse-all
-Makefile:
 
 ROM_DIRS = $(addprefix pc-bios/, $(ROMS))
 ROM_DIRS_RULES=$(foreach t, all clean, $(addsuffix /$(t), $(ROM_DIRS)))
-- 
2.26.2





[PULL 10/22] build: replace ninjatool with ninja

2020-10-16 Thread Paolo Bonzini
Now that the build is done entirely by Meson, there is no need
to keep the Makefile conversion.  Instead, we can ask Ninja about
the targets it exposes and forward them.

The main advantages are, from smallest to largest:

- reducing the possible namespace pollution within the Makefile

- removal of a relatively large Python program

- faster build because parsing Makefile.ninja is slower than
parsing build.ninja; and faster build after Meson runs because
we do not have to generate Makefile.ninja.

- tracking of command lines, which provides more accurate rebuilds

In addition the change removes the requirement for GNU make 3.82, which
was annoying on Mac, and avoids bugs on Windows due to ninjatool not
knowing how to convert Windows escapes to POSIX escapes.

Signed-off-by: Paolo Bonzini 
---
 Makefile|   79 +--
 configure   |9 +-
 docs/devel/build-system.rst |6 +-
 meson.build |4 -
 scripts/mtest2make.py   |3 +-
 scripts/ninjatool.py| 1008 ---
 tests/Makefile.include  |2 +-
 7 files changed, 58 insertions(+), 1053 deletions(-)
 delete mode 100755 scripts/ninjatool.py

diff --git a/Makefile b/Makefile
index 53d624a0be..9196b31733 100644
--- a/Makefile
+++ b/Makefile
@@ -72,27 +72,8 @@ git-submodule-update:
 endif
 endif
 
-export NINJA=./ninjatool
+# 0. ensure the build tree is okay
 
-# Running meson regenerates both build.ninja and ninjatool, and that is
-# enough to prime the rest of the build.
-ninjatool: build.ninja
-
-Makefile.ninja: build.ninja ninjatool
-   ./ninjatool -t ninja2make --omit clean dist uninstall cscope TAGS ctags 
< $< > $@
--include Makefile.ninja
-
-${ninja-targets-c_COMPILER} ${ninja-targets-cpp_COMPILER}: .var.command += -MP
-
-# If MESON is empty, the rule will be re-evaluated after Makefiles are
-# reread (and MESON won't be empty anymore).
-ifneq ($(MESON),)
-Makefile.mtest: build.ninja scripts/mtest2make.py
-   $(MESON) introspect --targets --tests --benchmarks | $(PYTHON) 
scripts/mtest2make.py > $@
--include Makefile.mtest
-endif
-
-# Ensure the build tree is okay.
 # Check that we're not trying to do an out-of-tree build from
 # a tree that's been used for an in-tree build.
 ifneq ($(realpath $(SRC_PATH)),$(realpath .))
@@ -117,6 +98,7 @@ ifeq ($(wildcard build.ninja),)
 x := $(shell rm -rf meson-private meson-info meson-logs)
 endif
 
+# 1. ensure config-host.mak is up-to-date
 config-host.mak: $(SRC_PATH)/configure $(SRC_PATH)/pc-bios $(SRC_PATH)/VERSION
@echo $@ is out-of-date, running configure
@if test -f meson-private/coredata.dat; then \
@@ -125,6 +107,45 @@ config-host.mak: $(SRC_PATH)/configure $(SRC_PATH)/pc-bios 
$(SRC_PATH)/VERSION
  ./config.status; \
fi
 
+# 2. ensure generated build files are up-to-date
+
+ifneq ($(NINJA),)
+# A separate rule is needed for Makefile dependencies to avoid -n
+export NINJA
+Makefile.ninja: build.ninja
+   $(quiet-@){ echo 'ninja-targets = \'; $(NINJA) -t targets all | sed 
's/:.*//; $$!s/$$/ \\/'; } > $@
+-include Makefile.ninja
+endif
+
+ifneq ($(MESON),)
+Makefile.mtest: build.ninja scripts/mtest2make.py
+   $(MESON) introspect --targets --tests --benchmarks | $(PYTHON) 
scripts/mtest2make.py > $@
+-include Makefile.mtest
+endif
+
+# 3. Rules to bridge to other makefiles
+
+ifneq ($(NINJA),)
+NINJAFLAGS = $(if $V,-v,) \
+$(filter-out -j, $(lastword -j1 $(filter -l% -j%, $(MAKEFLAGS \
+$(subst -k, -k0, $(filter -n -k,$(MAKEFLAGS)))
+
+ninja-cmd-goals = $(or $(MAKECMDGOALS), all)
+ninja-cmd-goals += $(foreach t, $(.tests), $(.test.deps.$t))
+
+makefile-targets := build.ninja ctags TAGS cscope dist clean uninstall
+ninja-targets := $(filter-out $(makefile-targets), $(ninja-targets))
+.PHONY: $(ninja-targets) run-ninja
+$(ninja-targets): run-ninja
+
+# Use "| cat" to give Ninja a more "make-y" output.  Use "+" to bypass the
+# --output-sync line.
+run-ninja: config-host.mak
+ifneq ($(filter $(ninja-targets), $(ninja-cmd-goals)),)
+   +@$(NINJA) $(NINJAFLAGS) $(sort $(filter $(ninja-targets), 
$(ninja-cmd-goals))) | cat
+endif
+endif
+
 # Force configure to re-run if the API symbols are updated
 ifeq ($(CONFIG_PLUGIN),y)
 config-host.mak: $(SRC_PATH)/plugins/qemu-plugins.symbols
@@ -144,13 +165,6 @@ ifneq ($(filter-out 
$(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fa
 endif
 endif # config-host.mak does not exist
 
-# Only needed in case Makefile.ninja does not exist.
-.PHONY: ninja-clean ninja-distclean clean-ctlist
-clean-ctlist:
-ninja-clean::
-ninja-distclean::
-build.ninja: config-host.mak
-
 SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory --quiet)
 
 include $(SRC_PATH)/tests/Makefile.include
@@ -170,8 +184,9 @@ recurse-clean: $(addsuffix /clean, $(ROM_DIRS))
 
 ##
 
-clean: recurse-clean ninja-clean clean-ctlist
-   if test -f ninjatool; then ./ninja

[PULL 03/22] tests/Makefile.include: unbreak non-tcg builds

2020-10-16 Thread Paolo Bonzini
Remove from check-block the requirement that all TARGET_DIRS are built.

Reviewed-by: Daniel P. Berrangé 
Signed-off-by: Paolo Bonzini 
---
 tests/Makefile.include | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 5aca98e60c..4037490b69 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -140,7 +140,7 @@ QEMU_IOTESTS_HELPERS-$(CONFIG_LINUX) = 
tests/qemu-iotests/socket_scm_helper$(EXE
 check: check-block
 check-block: $(SRC_PATH)/tests/check-block.sh qemu-img$(EXESUF) \
qemu-io$(EXESUF) qemu-nbd$(EXESUF) $(QEMU_IOTESTS_HELPERS-y) \
-   $(patsubst %-softmmu,qemu-system-%,$(filter 
%-softmmu,$(TARGET_DIRS)))
+   $(filter qemu-system-%, $(ninja-targets-c_LINKER) 
$(ninja-targets-cpp_LINKER))
@$<
 endif
 
-- 
2.26.2





[PULL 16/22] docs: Fix Sphinx configuration for msys2/mingw

2020-10-16 Thread Paolo Bonzini
From: Yonggang Luo 

Python doesn't support running ../scripts/kernel-doc directly.

Signed-off-by: Yonggang Luo 
Message-Id: <20201015220626.418-2-luoyongg...@gmail.com>
Signed-off-by: Paolo Bonzini 
---
 docs/conf.py | 2 +-
 docs/sphinx/kerneldoc.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/docs/conf.py b/docs/conf.py
index 00e1b750e2..e584f68393 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -241,7 +241,7 @@ texinfo_documents = [
 # We use paths starting from qemu_docdir here so that you can run
 # sphinx-build from anywhere and the kerneldoc extension can still
 # find everything.
-kerneldoc_bin = os.path.join(qemu_docdir, '../scripts/kernel-doc')
+kerneldoc_bin = ['perl', os.path.join(qemu_docdir, '../scripts/kernel-doc')]
 kerneldoc_srctree = os.path.join(qemu_docdir, '..')
 hxtool_srctree = os.path.join(qemu_docdir, '..')
 qapidoc_srctree = os.path.join(qemu_docdir, '..')
diff --git a/docs/sphinx/kerneldoc.py b/docs/sphinx/kerneldoc.py
index 3e87940206..3ac277d162 100644
--- a/docs/sphinx/kerneldoc.py
+++ b/docs/sphinx/kerneldoc.py
@@ -67,7 +67,7 @@ class KernelDocDirective(Directive):
 
 def run(self):
 env = self.state.document.settings.env
-cmd = [env.config.kerneldoc_bin, '-rst', '-enable-lineno']
+cmd = env.config.kerneldoc_bin + ['-rst', '-enable-lineno']
 
 filename = env.config.kerneldoc_srctree + '/' + self.arguments[0]
 export_file_patterns = []
-- 
2.26.2





[PULL 17/22] meson: move SPHINX_ARGS references within "if build_docs"

2020-10-16 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 tests/qapi-schema/meson.build | 88 +--
 1 file changed, 44 insertions(+), 44 deletions(-)

diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build
index 1f222a7a13..304ef939bd 100644
--- a/tests/qapi-schema/meson.build
+++ b/tests/qapi-schema/meson.build
@@ -219,53 +219,53 @@ qapi_doc = custom_target('QAPI doc',
 '-p', 'doc-good-', '@INPUT0@' ],
  depend_files: qapi_gen_depends)
 
-# Test the document-comment document generation code by running a test schema
-# file through Sphinx's plain-text builder and comparing the result against
-# a golden reference. This is in theory susceptible to failures if Sphinx
-# changes its output, but the text output has historically been very stable
-# (no changes between Sphinx 1.6 and 3.0), so it is a better bet than
-# texinfo or HTML generation, both of which have had changes. We might
-# need to add more sophisticated logic here in future for some sort of
-# fuzzy comparison if future Sphinx versions produce different text,
-# but for now the simple comparison suffices.
-qapi_doc_out = custom_target('QAPI rST doc',
- output: ['doc-good.txt'],
- input: files('doc-good.json', 'doc-good.rst'),
- build_by_default: build_docs,
- depend_files: sphinx_extn_depends,
- # We use -E to suppress Sphinx's caching, because
- # we want it to always really run the QAPI doc
- # generation code. It also means we don't
- # clutter up the build dir with the cache.
- command: [SPHINX_ARGS,
-   '-b', 'text', '-E',
-   '-c', meson.source_root() / 'docs',
-   '-D', 'master_doc=doc-good',
-   meson.current_source_dir(),
-   meson.current_build_dir()])
+if build_docs
+  # Test the document-comment document generation code by running a test schema
+  # file through Sphinx's plain-text builder and comparing the result against
+  # a golden reference. This is in theory susceptible to failures if Sphinx
+  # changes its output, but the text output has historically been very stable
+  # (no changes between Sphinx 1.6 and 3.0), so it is a better bet than
+  # texinfo or HTML generation, both of which have had changes. We might
+  # need to add more sophisticated logic here in future for some sort of
+  # fuzzy comparison if future Sphinx versions produce different text,
+  # but for now the simple comparison suffices.
+  qapi_doc_out = custom_target('QAPI rST doc',
+   output: ['doc-good.txt'],
+   input: files('doc-good.json', 'doc-good.rst'),
+   build_by_default: true,
+   depend_files: sphinx_extn_depends,
+   # We use -E to suppress Sphinx's caching, 
because
+   # we want it to always really run the QAPI doc
+   # generation code. It also means we don't
+   # clutter up the build dir with the cache.
+   command: [SPHINX_ARGS,
+ '-b', 'text', '-E',
+ '-c', meson.source_root() / 'docs',
+ '-D', 'master_doc=doc-good',
+ meson.current_source_dir(),
+ meson.current_build_dir()])
 
-# Fix possible inconsistency in line endings in generated output and
-# in the golden reference (which could otherwise cause test failures
-# on Windows hosts). Unfortunately diff --strip-trailing-cr
-# is GNU-diff only. The odd-looking perl is because we must avoid
-# using an explicit '\' character in the command arguments to
-# a custom_target(), as Meson will unhelpfully replace it with a '/'
-# (https://github.com/mesonbuild/meson/issues/1564)
-qapi_doc_out_nocr = custom_target('QAPI rST doc newline-sanitized',
-  output: ['doc-good.txt.nocr'],
-  input: qapi_doc_out[0],
-  build_by_default: build_docs,
-  command: ['perl', '-pe', '$x = chr 13; 
s/$x$//', '@INPUT@'],
-  capture: true)
+  # Fix possible inconsistency in line endings in generated output and
+  # in the golden reference (which could otherwise cause test failures
+  # on Windows hosts). Unfortunately diff --strip-trailing-cr
+  # is GNU-diff only. The odd-looking perl is because we must

[PULL 15/22] meson: Only install icons and qemu.desktop if have_system

2020-10-16 Thread Paolo Bonzini
From: Bruce Rogers 

These files are not needed for a linux-user only install.

Signed-off-by: Bruce Rogers 
Message-Id: <20201015201840.282956-1-brog...@suse.com>
Signed-off-by: Paolo Bonzini 
---
 ui/meson.build | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/ui/meson.build b/ui/meson.build
index 78ad792ffb..fb36d305ca 100644
--- a/ui/meson.build
+++ b/ui/meson.build
@@ -113,8 +113,11 @@ if have_system or xkbcommon.found()
 endif
 
 subdir('shader')
-subdir('icons')
 
-install_data('qemu.desktop', install_dir: config_host['qemu_desktopdir'])
+if have_system
+  subdir('icons')
+
+  install_data('qemu.desktop', install_dir: config_host['qemu_desktopdir'])
+endif
 
 modules += {'ui': ui_modules}
-- 
2.26.2





[PULL 05/22] tests: add missing generated sources to testqapi

2020-10-16 Thread Paolo Bonzini
Ninja notices them due to a different order in visiting the graph.

Reviewed-by: Daniel P. Berrangé 
Signed-off-by: Paolo Bonzini 
---
 tests/include/meson.build |  8 
 tests/meson.build | 14 --
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/tests/include/meson.build b/tests/include/meson.build
index fea3a6342f..9abba308fa 100644
--- a/tests/include/meson.build
+++ b/tests/include/meson.build
@@ -10,7 +10,7 @@ test_qapi_outputs_extra = [
   'test-qapi-visit-sub-module.h',
 ]
 
-test_qapi_outputs_extra = custom_target('QAPI test (include)',
-output: test_qapi_outputs_extra,
-input: test_qapi_files,
-command: 'true')
+test_qapi_files_extra = custom_target('QAPI test (include)',
+  output: test_qapi_outputs_extra,
+  input: test_qapi_files,
+  command: 'true')
diff --git a/tests/meson.build b/tests/meson.build
index bf47a38c74..afeb6be689 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -56,8 +56,18 @@ test_qapi_files = custom_target('Test QAPI files',
 # perhaps change qapi_gen to replace / with _, like Meson itself does?
 subdir('include')
 
-libtestqapi = static_library('testqapi', sources: [test_qapi_files, genh, 
test_qapi_outputs_extra])
-testqapi = declare_dependency(link_with: libtestqapi)
+test_qapi_sources = []
+test_qapi_headers = []
+i = 0
+foreach o: test_qapi_files.to_list() + test_qapi_files_extra.to_list()
+  if o.full_path().endswith('.h')
+test_qapi_headers += o
+  endif
+  test_qapi_sources += o
+endforeach
+
+libtestqapi = static_library('testqapi', sources: [genh, test_qapi_sources])
+testqapi = declare_dependency(link_with: libtestqapi, sources: [genh, 
test_qapi_headers])
 
 testblock = declare_dependency(dependencies: [block], sources: 'iothread.c')
 
-- 
2.26.2





[PULL 18/22] meson: Move the detection logic for sphinx to meson

2020-10-16 Thread Paolo Bonzini
From: Yonggang Luo 

Signed-off-by: Yonggang Luo 
Message-Id: <20201015220626.418-4-luoyongg...@gmail.com>
Signed-off-by: Paolo Bonzini 
---
 configure | 59 ---
 docs/meson.build  | 46 
 meson.build   | 30 
 meson_options.txt |  4 
 4 files changed, 64 insertions(+), 75 deletions(-)

diff --git a/configure b/configure
index 3edbdd2a24..68f097861d 100755
--- a/configure
+++ b/configure
@@ -297,7 +297,7 @@ brlapi=""
 curl=""
 iconv="auto"
 curses="auto"
-docs=""
+docs="auto"
 fdt="auto"
 netmap="no"
 sdl="auto"
@@ -820,15 +820,6 @@ do
 fi
 done
 
-sphinx_build=
-for binary in sphinx-build-3 sphinx-build
-do
-if has "$binary"
-then
-sphinx_build=$(command -v "$binary")
-break
-fi
-done
 
 # Check for ancillary tools used in testing
 genisoimage=
@@ -1228,9 +1219,9 @@ for opt do
   ;;
   --disable-crypto-afalg) crypto_afalg="no"
   ;;
-  --disable-docs) docs="no"
+  --disable-docs) docs="disabled"
   ;;
-  --enable-docs) docs="yes"
+  --enable-docs) docs="enabled"
   ;;
   --disable-vhost-net) vhost_net="no"
   ;;
@@ -4419,45 +4410,6 @@ if check_include linux/btrfs.h ; then
 btrfs=yes
 fi
 
-# If we're making warnings fatal, apply this to Sphinx runs as well
-sphinx_werror=""
-if test "$werror" = "yes"; then
-sphinx_werror="-W"
-fi
-
-# Check we have a new enough version of sphinx-build
-has_sphinx_build() {
-# This is a bit awkward but works: create a trivial document and
-# try to run it with our configuration file (which enforces a
-# version requirement). This will fail if either
-# sphinx-build doesn't exist at all or if it is too old.
-mkdir -p "$TMPDIR1/sphinx"
-touch "$TMPDIR1/sphinx/index.rst"
-"$sphinx_build" $sphinx_werror -c "$source_path/docs" \
--b html "$TMPDIR1/sphinx" \
-"$TMPDIR1/sphinx/out"  >> config.log 2>&1
-}
-
-# Check if tools are available to build documentation.
-if test "$docs" != "no" ; then
-  if has_sphinx_build; then
-sphinx_ok=yes
-  else
-sphinx_ok=no
-  fi
-  if test "$sphinx_ok" = "yes"; then
-docs=yes
-  else
-if test "$docs" = "yes" ; then
-  if has $sphinx_build && test "$sphinx_ok" != "yes"; then
-echo "Warning: $sphinx_build exists but it is either too old or uses 
too old a Python version" >&2
-  fi
-  feature_not_found "docs" "Install a Python 3 version of python-sphinx"
-fi
-docs=no
-  fi
-fi
-
 # Search for bswap_32 function
 byteswap_h=no
 cat > $TMPC << EOF
@@ -6093,9 +6045,6 @@ qemu_version=$(head $source_path/VERSION)
 echo "PKGVERSION=$pkgversion" >>$config_host_mak
 echo "SRC_PATH=$source_path" >> $config_host_mak
 echo "TARGET_DIRS=$target_list" >> $config_host_mak
-if [ "$docs" = "yes" ] ; then
-  echo "BUILD_DOCS=yes" >> $config_host_mak
-fi
 if test "$modules" = "yes"; then
   # $shacmd can generate a hash started with digit, which the compiler doesn't
   # like as an symbol. So prefix it with an underscore
@@ -6784,7 +6733,6 @@ fi
 echo "ROMS=$roms" >> $config_host_mak
 echo "MAKE=$make" >> $config_host_mak
 echo "PYTHON=$python" >> $config_host_mak
-echo "SPHINX_BUILD=$sphinx_build" >> $config_host_mak
 echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
 echo "MESON=$meson" >> $config_host_mak
 echo "NINJA=$ninja" >> $config_host_mak
@@ -7066,6 +7014,7 @@ NINJA=$ninja $meson setup \
 -Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f \
 -Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt \
 -Diconv=$iconv -Dcurses=$curses -Dlibudev=$libudev\
+-Ddocs=$docs -Dsphinx_build=$sphinx_build \
 $cross_arg \
 "$PWD" "$source_path"
 
diff --git a/docs/meson.build b/docs/meson.build
index 0340d489ac..789dca8cc0 100644
--- a/docs/meson.build
+++ b/docs/meson.build
@@ -1,4 +1,50 @@
+if get_option('sphinx_build') == ''
+  sphinx_build = find_program(['sphinx-build-3', 'sphinx-build'],
+  required: get_option('docs'))
+else
+  sphinx_build = find_program(get_option('sphinx_build'),
+  required: get_option('docs'))
+endif
+
+# Check if tools are available to build documentation.
+build_docs = false
+if sphinx_build.found()
+  SPHINX_ARGS = [sphinx_build]
+  # If we're making warnings fatal, apply this to Sphinx runs as well
+  if get_option('werror')
+SPHINX_ARGS += [ '-W' ]
+  endif
+
+  # This is a bit awkward but works: create a trivial document and
+  # try to run it with our configuration file (which enforces a
+  # version requirement). This will fail if sphinx-build is too old.
+  run_command('mkdir', ['-p', tmpdir / 'sphinx'])
+  run_command('touch', [tmpdir / 'sphinx/index.rst'])
+  sphinx_build_test_out = run_command(SPHINX_ARGS + [
+'-c', meson.current_source_dir(),
+'-b', 'html', tmpdir / 'sphinx',
+tmpdir / 'sphinx/out'])
+  build_docs = (sphinx_build_test_out.returncode() =

[PULL 20/22] fuzz: Disable QEMU's SIG{INT,HUP,TERM} handlers

2020-10-16 Thread Paolo Bonzini
From: Alexander Bulekov 

Prior to this patch, the only way I found to terminate the fuzzer was
either to:
 1. Explicitly specify the number of fuzzer runs with the -runs= flag
 2. SIGKILL the process with "pkill -9 qemu-fuzz-*" or similar

In addition to being annoying to deal with, SIGKILLing the process skips
over any exit handlers(e.g. registered with atexit()). This is bad,
since some fuzzers might create temporary files that should ideally be
removed on exit using an exit handler. The only way to achieve a clean
exit now is to specify -runs=N , but the desired "N" is tricky to
identify prior to fuzzing.

Why doesn't the process exit with standard SIGINT,SIGHUP,SIGTERM
signals? QEMU installs its own handlers for these signals in
os-posix.c:os_setup_signal_handling, which notify the main loop that an
exit was requested. The fuzzer, however, does not run qemu_main_loop,
which performs the main_loop_should_exit() check.  This means that the
fuzzer effectively ignores these signals. As we don't really care about
cleanly stopping the disposable fuzzer "VM", this patch uninstalls
QEMU's signal handlers. Thus, we can stop the fuzzer with
SIG{INT,HUP,TERM} and the fuzzing code can optionally use atexit() to
clean up temporary files/resources.

Reviewed-by: Darren Kenny 
Signed-off-by: Alexander Bulekov 
Message-Id: <20201014142157.46028-1-alx...@bu.edu>
Signed-off-by: Paolo Bonzini 
---
 tests/qtest/fuzz/fuzz.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/tests/qtest/fuzz/fuzz.c b/tests/qtest/fuzz/fuzz.c
index d926c490c5..eb0070437f 100644
--- a/tests/qtest/fuzz/fuzz.c
+++ b/tests/qtest/fuzz/fuzz.c
@@ -217,5 +217,13 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char 
***envp)
 /* re-enable the rcu atfork, which was previously disabled in qemu_init */
 rcu_enable_atfork();
 
+/*
+ * Disable QEMU's signal handlers, since we manually control the main_loop,
+ * and don't check for main_loop_should_exit
+ */
+signal(SIGINT, SIG_DFL);
+signal(SIGHUP, SIG_DFL);
+signal(SIGTERM, SIG_DFL);
+
 return 0;
 }
-- 
2.26.2





[PULL 21/22] hax: unbreak accelerator cpu code after cpus.c split

2020-10-16 Thread Paolo Bonzini
From: Claudio Fontana 

during my split of cpus.c, code line
"current_cpu = cpu"
was removed by mistake, causing hax to break.

This commit fixes the situation restoring it.

Reported-by: Volker Rümelin 
Fixes: e92558e4bf8059ce4f0b310afe218802b72766bc
Signed-off-by: Claudio Fontana 
Message-Id: <20201016080032.13914-1-cfont...@suse.de>
Signed-off-by: Paolo Bonzini 
---
 target/i386/hax-cpus.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/i386/hax-cpus.c b/target/i386/hax-cpus.c
index 99770e590c..f72c85bd49 100644
--- a/target/i386/hax-cpus.c
+++ b/target/i386/hax-cpus.c
@@ -38,6 +38,7 @@ static void *hax_cpu_thread_fn(void *arg)
 qemu_thread_get_self(cpu->thread);
 
 cpu->thread_id = qemu_get_thread_id();
+current_cpu = cpu;
 hax_init_vcpu(cpu);
 cpu_thread_signal_created(cpu);
 qemu_guest_random_seed_thread_part2(cpu->random_seed);
-- 
2.26.2





[PULL 19/22] cirrus: Enable doc build on msys2/mingw

2020-10-16 Thread Paolo Bonzini
From: Yonggang Luo 

Currently rST depends on old version sphinx-2.x.
Install it by downloading it.
Remove the need of university mirror, the main repo are recovered.

Signed-off-by: Yonggang Luo 
Message-Id: <20201015220626.418-5-luoyongg...@gmail.com>
Signed-off-by: Paolo Bonzini 
---
 .cirrus.yml | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/.cirrus.yml b/.cirrus.yml
index 396888fbd3..e099da0fec 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -76,7 +76,6 @@ windows_msys2_task:
 ((Get-Content -path 
C:\tools\msys64\etc\\post-install\\07-pacman-key.post -Raw) -replace 
'--refresh-keys', '--version') | Set-Content -Path 
C:\tools\msys64\etc\\post-install\\07-pacman-key.post
 C:\tools\msys64\usr\bin\bash.exe -lc "sed -i 
's/^CheckSpace/#CheckSpace/g' /etc/pacman.conf"
 C:\tools\msys64\usr\bin\bash.exe -lc "export"
-C:\tools\msys64\usr\bin\bash.exe -lc "grep -rl 'repo.msys2.org/' 
/etc/pacman.d/mirrorlist.* | xargs sed -i 
's/repo.msys2.org\//mirrors.tuna.tsinghua.edu.cn\/msys2\//g'"
 C:\tools\msys64\usr\bin\pacman.exe --noconfirm -Sy
 echo Y | C:\tools\msys64\usr\bin\pacman.exe --noconfirm -Suu 
--overwrite=*
 taskkill /F /FI "MODULES eq msys-2.0.dll"
@@ -111,6 +110,11 @@ windows_msys2_task:
   mingw-w64-x86_64-curl \
   mingw-w64-x86_64-gnutls \
   "
+bitsadmin /transfer msys_download /dynamic /download /priority 
FOREGROUND `
+  
https://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-python-sphinx-2.3.1-1-any.pkg.tar.xz
 `
+  C:\tools\mingw-w64-x86_64-python-sphinx-2.3.1-1-any.pkg.tar.xz
+C:\tools\msys64\usr\bin\bash.exe -lc "pacman --noconfirm -U 
/c/tools/mingw-w64-x86_64-python-sphinx-2.3.1-1-any.pkg.tar.xz"
+del C:\tools\mingw-w64-x86_64-python-sphinx-2.3.1-1-any.pkg.tar.xz
 C:\tools\msys64\usr\bin\bash.exe -lc "rm -rf /var/cache/pacman/pkg/*"
 cd C:\tools\msys64
 echo "Start archive"
-- 
2.26.2





[PULL 13/22] meson: cleanup curses/iconv test

2020-10-16 Thread Paolo Bonzini
Skip the test if it is system emulation is not requested, and
differentiate errors for lack of iconv and lack of curses.

Signed-off-by: Paolo Bonzini 
---
 meson.build | 85 -
 1 file changed, 45 insertions(+), 40 deletions(-)

diff --git a/meson.build b/meson.build
index c1c45e9845..15732f4701 100644
--- a/meson.build
+++ b/meson.build
@@ -455,40 +455,40 @@ if targetos == 'linux' and have_tools and not 
get_option('mpath').disabled()
 endif
 
 iconv = not_found
-if not get_option('iconv').disabled()
-  libiconv = cc.find_library('iconv',
- required: false,
- static: enable_static)
-  if cc.links('''
-#include 
-int main(void) {
-  iconv_t conv = iconv_open("WCHAR_T", "UCS-2");
-  return conv != (iconv_t) -1;
-}''', dependencies: [libiconv])
-iconv = declare_dependency(dependencies: [libiconv])
-  endif
-endif
-if get_option('iconv').enabled() and not iconv.found()
-  error('Cannot detect iconv API')
-endif
-
 curses = not_found
-if iconv.found() and not get_option('curses').disabled()
-  curses_libname_list = ['ncursesw', 'ncurses', 'cursesw', 'pdcurses']
-  curses_test = '''
-#include 
-#include 
-#include 
-int main(void) {
-  wchar_t wch = L'w';
-  setlocale(LC_ALL, "");
-  resize_term(0, 0);
-  addwstr(L"wide chars\n");
-  addnwstr(&wch, 1);
-  add_wch(WACS_DEGREE);
-  return 0;
-}'''
-  foreach curses_libname : curses_libname_list
+if have_system and not get_option('curses').disabled()
+  if not get_option('iconv').disabled()
+libiconv = cc.find_library('iconv',
+   required: false,
+   static: enable_static)
+if cc.links('''
+  #include 
+  int main(void) {
+iconv_t conv = iconv_open("WCHAR_T", "UCS-2");
+return conv != (iconv_t) -1;
+  }''', dependencies: [libiconv])
+  iconv = declare_dependency(dependencies: [libiconv])
+endif
+  endif
+  if get_option('iconv').enabled() and not iconv.found()
+error('Cannot detect iconv API')
+  endif
+  if iconv.found()
+curses_libname_list = ['ncursesw', 'ncurses', 'cursesw', 'pdcurses']
+curses_test = '''
+  #include 
+  #include 
+  #include 
+  int main(void) {
+wchar_t wch = L'w';
+setlocale(LC_ALL, "");
+resize_term(0, 0);
+addwstr(L"wide chars\n");
+addnwstr(&wch, 1);
+add_wch(WACS_DEGREE);
+return 0;
+  }'''
+foreach curses_libname : curses_libname_list
   libcurses = dependency(curses_libname,
  required: false,
  method: 'pkg-config',
@@ -510,13 +510,18 @@ if iconv.found() and not get_option('curses').disabled()
   break
 endif
   endif
-  endforeach
-endif
-if get_option('curses').enabled() and not curses.found()
-  if not iconv.found()
-error('Cannot detect iconv API')
-  else
-error('Cannot detect curses API')
+endforeach
+  endif
+  if not curses.found()
+if iconv.found()
+  if get_option('curses').enabled()
+error('Cannot find curses')
+  endif
+elif get_option('curses').enabled()
+  error('iconv required for curses UI but not available')
+else
+  warning('iconv required for curses UI but not available, disabling')
+endif
   endif
 endif
 
-- 
2.26.2





[PULL 22/22] ci: include configure and meson logs in all jobs if configure fails

2020-10-16 Thread Paolo Bonzini
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Paolo Bonzini 
---
 .cirrus.yml| 6 +++---
 .gitlab-ci.yml | 6 +++---
 .travis.yml| 8 
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/.cirrus.yml b/.cirrus.yml
index e099da0fec..81a2960b1a 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -13,7 +13,7 @@ freebsd_12_task:
   script:
 - mkdir build
 - cd build
-- ../configure --enable-werror || { cat config.log; exit 1; }
+- ../configure --enable-werror || { cat config.log 
meson-logs/meson-log.txt; exit 1; }
 - gmake -j$(sysctl -n hw.ncpu)
 - gmake -j$(sysctl -n hw.ncpu) check V=1
 
@@ -27,7 +27,7 @@ macos_task:
 - cd build
 - ../configure --python=/usr/local/bin/python3 --enable-werror
--extra-cflags='-Wno-error=deprecated-declarations'
-   || { cat config.log; exit 1; }
+   || { cat config.log meson-logs/meson-log.txt; exit 1; }
 - gmake -j$(sysctl -n hw.ncpu)
 - gmake check V=1
 
@@ -41,7 +41,7 @@ macos_xcode_task:
 - mkdir build
 - cd build
 - ../configure --extra-cflags='-Wno-error=deprecated-declarations'
-   --enable-werror --cc=clang || { cat config.log; exit 1; }
+   --enable-werror --cc=clang || { cat config.log 
meson-logs/meson-log.txt; exit 1; }
 - gmake -j$(sysctl -n hw.ncpu)
 - gmake check V=1
 
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8ffd415ca5..66ad7aa5c2 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -32,7 +32,7 @@ include:
 ../configure --enable-werror $CONFIGURE_ARGS --target-list="$TARGETS" ;
   else
 ../configure --enable-werror $CONFIGURE_ARGS ;
-  fi
+  fi || { cat config.log meson-logs/meson-log.txt && exit 1; }
 - make -j"$JOBS"
 - if test -n "$MAKE_CHECK_ARGS";
   then
@@ -229,7 +229,7 @@ build-tcg-disabled:
   script:
 - mkdir build
 - cd build
-- ../configure --disable-tcg --audio-drv-list=""
+- ../configure --disable-tcg --audio-drv-list="" || { cat config.log 
meson-logs/meson-log.txt && exit 1; }
 - make -j"$JOBS"
 - make check-unit
 - make check-qapi-schema
@@ -322,7 +322,7 @@ build-tci:
 - mkdir build
 - cd build
 - ../configure --enable-tcg-interpreter
---target-list="$(for tg in $TARGETS; do echo -n ${tg}'-softmmu '; 
done)"
+--target-list="$(for tg in $TARGETS; do echo -n ${tg}'-softmmu '; 
done)" || { cat config.log meson-logs/meson-log.txt && exit 1; }
 - make -j"$JOBS"
 - make run-tcg-tests-x86_64-softmmu
 - make tests/qtest/boot-serial-test tests/qtest/cdrom-test 
tests/qtest/pxe-test
diff --git a/.travis.yml b/.travis.yml
index d7bfbb8bfe..a3d78171ca 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -95,7 +95,7 @@ before_install:
 # Configure step - may be overridden
 before_script:
   - mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
-  - ${SRC_DIR}/configure ${BASE_CONFIG} ${CONFIG} || { cat config.log && exit 
1; }
+  - ${SRC_DIR}/configure ${BASE_CONFIG} ${CONFIG} || { cat config.log 
meson-logs/meson-log.txt && exit 1; }
 
 # Main build & test - rarely overridden - controlled by TEST_CMD
 script:
@@ -199,7 +199,7 @@ jobs:
   compiler: clang
   before_script:
 - mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
-- ${SRC_DIR}/configure ${CONFIG} --extra-cflags="-fsanitize=undefined 
-Werror" || { cat config.log && exit 1; }
+- ${SRC_DIR}/configure ${CONFIG} --extra-cflags="-fsanitize=undefined 
-Werror" || { cat config.log meson-logs/meson-log.txt && exit 1; }
 
 
 - name: "Clang (other-softmmu)"
@@ -298,7 +298,7 @@ jobs:
 - TEST_CMD=""
   before_script:
 - mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
-- ${SRC_DIR}/configure ${CONFIG} --extra-cflags="-g3 -O0 
-fsanitize=thread" || { cat config.log && exit 1; }
+- ${SRC_DIR}/configure ${CONFIG} --extra-cflags="-g3 -O0 
-fsanitize=thread" || { cat config.log meson-logs/meson-log.txt && exit 1; }
 
 
 # Run check-tcg against linux-user
@@ -530,7 +530,7 @@ jobs:
 - ls -l ${SRC_DIR}/qemu-${QEMU_VERSION}.tar.bz2
 - tar -xf ${SRC_DIR}/qemu-${QEMU_VERSION}.tar.bz2 && cd 
qemu-${QEMU_VERSION}
 - mkdir -p release-build && cd release-build
-- ../configure ${BASE_CONFIG} ${CONFIG} || { cat config.log && exit 1; 
}
+- ../configure ${BASE_CONFIG} ${CONFIG} || { cat config.log 
meson-logs/meson-log.txt && exit 1; }
 - make install
   allow_failures:
 - env: UNRELIABLE=true
-- 
2.26.2




[PULL 12/22] meson.build: don't condition iconv detection on library detection

2020-10-16 Thread Paolo Bonzini
From: Bruce Rogers 

It isn't necessarily the case that use of iconv requires an additional
library. For that reason we shouldn't conditionalize iconv detection on
libiconv.found.

Fixes: 5285e593c33 (configure: Fixes ncursesw detection under msys2/mingw by 
convert them to meson)

Signed-off-by: Bruce Rogers 
Reviewed-by: Yonggang Luouoyongg...@gmail.com>
Reviewed-by:Yonggang Luo 
Message-Id: <20201014221939.196958-1-brog...@suse.com>
Signed-off-by: Paolo Bonzini 
---
 meson.build | 16 +++-
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/meson.build b/meson.build
index 0c0f4f9fd8..c1c45e9845 100644
--- a/meson.build
+++ b/meson.build
@@ -459,15 +459,13 @@ if not get_option('iconv').disabled()
   libiconv = cc.find_library('iconv',
  required: false,
  static: enable_static)
-  if libiconv.found()
-if cc.links('''
-  #include 
-  int main(void) {
-iconv_t conv = iconv_open("WCHAR_T", "UCS-2");
-return conv != (iconv_t) -1;
-  }''', dependencies: [libiconv])
-  iconv = declare_dependency(dependencies: [libiconv])
-endif
+  if cc.links('''
+#include 
+int main(void) {
+  iconv_t conv = iconv_open("WCHAR_T", "UCS-2");
+  return conv != (iconv_t) -1;
+}''', dependencies: [libiconv])
+iconv = declare_dependency(dependencies: [libiconv])
   endif
 endif
 if get_option('iconv').enabled() and not iconv.found()
-- 
2.26.2





Re: [PATCH v8 0/5] Mac Old World ROM experiment (ppc/mac_* clean ups and loading binary ROM)

2020-10-16 Thread BALATON Zoltan via

On Fri, 16 Oct 2020, Mark Cave-Ayland wrote:

On 16/10/2020 00:47, BALATON Zoltan via wrote:

This is the cut down version of the earlier series omitting unfinished
patches that I plan to rework later and rebased to Mark's qemu-macppc
branch. Compared to v7 the only change is the cast to (target_ulong)
from (uint32_t) as requested by Mark in patch 1.


FWIW the reason for suggesting the cast to target_ulong is so that the same 
code works for both qemu-system-ppc and qemu-system-ppc64. For 
qemu-system-ppc that should correctly drop the sign extension from 32-bit, 
whilst still allowing someone to load a 64-bit ELF into qemu-system-ppc64 if 
requested.


Can you confirm that the sign extension behaviour is still correct for both 
qemu-system-ppc and qemu-system-ppc64? If so I'm happy to give it a R-B tag.


I've tried it now again with both ppc and ppc64: both OpenBIOS and a G3 
beige ROM can be loaded with qemu-system-ppc but qemu-system-ppc64 fails 
with OpenBIOS when casting to target_ulong (i think because target_ulong 
is 64 bit there but g3beige is still 32 bit but I haven't throughly 
debugged it). But everything works with my original uint32_t cast, so 
ditch it and use my original version. Should I resubmit or you can fix up? 
(I think I wait until it's clear if this will be taken by David or you and 
send a fixed version cc-ing David if this is decided to go through the PPC 
queue.)


Regards,
BALATON Zoltan



Re: aio_poll() assertion fail on Windows

2020-10-16 Thread Howard Spoelstra
On Fri, Oct 16, 2020 at 1:32 PM Mark Cave-Ayland <
mark.cave-ayl...@ilande.co.uk> wrote:

> Whilst testing a Windows build of git master of qemu-system-ppc in
> MSYS2/MingW64 I
> noticed the following assertion message in the console after booting into
> OpenBIOS
> and then closing the GTK GUI window without booting a client OS:
>
> $ ./qemu-system-ppc
> **
> ERROR:../util/aio-win32.c:337:aio_poll: assertion failed:
> (in_aio_context_home_thread(ctx))
> Bail out! ERROR:../util/aio-win32.c:337:aio_poll: assertion failed:
> (in_aio_context_home_thread(ctx))
>
> Has anyone else seen this at all?
>
>
> ATB,
>
> Mark.
>
>
Same here with SDL and GTK.

C:\qemu-master-msys2>qemu-system-ppc.exe -L pc-bios -sdl -boot c -m 512 -M
mac99,via=pmu
**
ERROR:../util/aio-win32.c:337:aio_poll: assertion failed:
(in_aio_context_home_thread(ctx))
Bail out! ERROR:../util/aio-win32.c:337:aio_poll: assertion failed:
(in_aio_context_home_thread(ctx))

Best,
Howard


Re: [PATCH v8 0/5] Mac Old World ROM experiment (ppc/mac_* clean ups and loading binary ROM)

2020-10-16 Thread Philippe Mathieu-Daudé

On 10/16/20 11:58 AM, Mark Cave-Ayland wrote:

On 16/10/2020 00:47, BALATON Zoltan via wrote:


This is the cut down version of the earlier series omitting unfinished
patches that I plan to rework later and rebased to Mark's qemu-macppc
branch. Compared to v7 the only change is the cast to (target_ulong)
from (uint32_t) as requested by Mark in patch 1.


FWIW the reason for suggesting the cast to target_ulong is so that the 
same code works for both qemu-system-ppc and qemu-system-ppc64. For 
qemu-system-ppc that should correctly drop the sign extension from 
32-bit, whilst still allowing someone to load a 64-bit ELF into 
qemu-system-ppc64 if requested.


IMO this is part of a bigger design problem. Not all
machines main bus is 64-bit. I did some experiments
but changing that involves a lot of work.



Re: [PATCH v10 09/10] virtio-iommu: Set supported page size mask

2020-10-16 Thread Auger Eric
Hi Jean,

On 10/8/20 7:15 PM, Jean-Philippe Brucker wrote:
> From: Bharat Bhushan 
> 
> The virtio-iommu device can deal with arbitrary page sizes for virtual
> endpoints, but for endpoints assigned with VFIO it must follow the page
> granule used by the host IOMMU driver.
> 
> Implement the interface to set the vIOMMU page size mask, called by VFIO
> for each endpoint. We assume that all host IOMMU drivers use the same
> page granule (the host page granule). Override the page_size_mask field
> in the virtio config space.
> 
> Signed-off-by: Bharat Bhushan 
> Signed-off-by: Jean-Philippe Brucker 

> ---
> v10: Use global page mask, allowing VFIO to override it until boot.
> ---
>  hw/virtio/virtio-iommu.c | 51 
>  1 file changed, 51 insertions(+)
> 
> diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
> index 8823bfc804a..dd0b3093d1b 100644
> --- a/hw/virtio/virtio-iommu.c
> +++ b/hw/virtio/virtio-iommu.c
> @@ -914,6 +914,56 @@ static int 
> virtio_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu_mr,
>  return 0;
>  }
>  
> +static int virtio_iommu_set_page_size_mask(IOMMUMemoryRegion *mr,
> +   uint64_t page_size_mask,
> +   Error **errp)
> +{
> +int new_granule, old_granule;
> +IOMMUDevice *sdev = container_of(mr, IOMMUDevice, iommu_mr);
> +VirtIOIOMMU *s = sdev->viommu;
> +
> +if (!page_size_mask) {
set errp
> +return -1;
> +}
> +
> +new_granule = ctz64(page_size_mask);
> +old_granule = ctz64(s->config.page_size_mask);

I think this would be interesting to add a trace point
> +
> +/*
> + * Modifying the page size after machine initialization isn't supported.
> + * Having a different mask is possible but the guest will use sub-optimal
> + * block sizes, so warn about it.
> + */
> +if (qdev_hotplug) {
> +if (new_granule != old_granule) {
> +error_setg(errp,
> +   "virtio-iommu page mask 0x%"PRIx64
> +   " is incompatible with mask 0x%"PRIx64,
> +   s->config.page_size_mask, page_size_mask);
> +return -1;
> +} else if (page_size_mask != s->config.page_size_mask) {
> +warn_report("virtio-iommu page mask 0x%"PRIx64
> +" does not match 0x%"PRIx64,
> +s->config.page_size_mask, page_size_mask);
> +}
> +return 0;
> +}
> +
> +/*
> + * Disallow shrinking the page size. For example if an endpoint only
> + * supports 64kB pages, we can't globally enable 4kB pages. But that
> + * shouldn't happen, the host is unlikely to setup differing page 
> granules.
> + * The other bits are only hints describing optimal block sizes.
> + */
> +if (new_granule < old_granule) {
> +error_setg(errp, "memory region shrinks the virtio-iommu page 
> granule");
> +return -1;
> +}
> +
> +s->config.page_size_mask = page_size_mask;
> +return 0;
> +}
> +
>  static void virtio_iommu_device_realize(DeviceState *dev, Error **errp)
>  {
>  VirtIODevice *vdev = VIRTIO_DEVICE(dev);
> @@ -1146,6 +1196,7 @@ static void 
> virtio_iommu_memory_region_class_init(ObjectClass *klass,
>  imrc->translate = virtio_iommu_translate;
>  imrc->replay = virtio_iommu_replay;
>  imrc->notify_flag_changed = virtio_iommu_notify_flag_changed;
> +imrc->iommu_set_page_size_mask = virtio_iommu_set_page_size_mask;
>  }
>  
>  static const TypeInfo virtio_iommu_info = {
> 
Thanks

Eric




Re: [PATCH v10 00/10] virtio-iommu: VFIO integration

2020-10-16 Thread Auger Eric
Hi Jean,

On 10/8/20 7:15 PM, Jean-Philippe Brucker wrote:
> This series adds support for VFIO endpoints to virtio-iommu.
> 
> Versions 1 to 9 were posted by Bharat Bhushan, but I am taking over for
> now since he doesn't have much time to spend on it. Thanks again Bharat
> for the work!
> 
> Two major changes since [v9]:
> 
> * Don't use per-endoint page_size_mask properties. Instead keep a global
>   page size for the virtio-iommu device, updated when adding a VFIO
>   endpoint. Reject hotplug if the page size is incompatible.
> 
> * Try to make the MAP/UNMAP paths more efficient, by keeping track of
>   memory region within the endpoint structure.
> 
> More testing would be appreciated, since I can only test using a software
> model as host at the moment. But it does seem to hold well with PCIe
> hotplug/unplug, and pass-through to guest userspace, which are no mean
> feat.

I tested vhost migration and the following configurations:
host 4K- guest 4K: vhost, vfio, vfio hotplug
host 64K - guest 64K: vhost, vfio, vfio hotplug
host 4K - guest 64K: vhost, vfio, vfio hoplug

All those configs worked for me. I haven't noticed any isse with those.

Thanks

Eric
> 
> Note that one page size combination is not supported: host 64kB guest
> 4kB cannot work, because the host IOMMU driver will automatically pick
> 64kB pages which prevents mapping at a smaller granule. Supporting this
> case would require introducing a page size negotiation mechanism from
> the guest all the way to the host IOMMU driver. Possible, but not
> planned at the moment.
> 
> [v9] 
> https://lore.kernel.org/qemu-devel/20200323084617.1782-1-bbhush...@marvell.com/
> 
> Bharat Bhushan (7):
>   virtio-iommu: Add memory notifiers for map/unmap
>   virtio-iommu: Call memory notifiers in attach/detach
>   virtio-iommu: Add replay() memory region callback
>   virtio-iommu: Add notify_flag_changed() memory region callback
>   memory: Add interface to set iommu page size mask
>   vfio: Set IOMMU page size as per host supported page size
>   virtio-iommu: Set supported page size mask
> 
> Jean-Philippe Brucker (3):
>   virtio-iommu: Fix virtio_iommu_mr()
>   virtio-iommu: Store memory region in endpoint struct
>   vfio: Don't issue full 2^64 unmap
> 
>  include/exec/memory.h|  26 +
>  hw/vfio/common.c |  19 
>  hw/virtio/virtio-iommu.c | 204 ++-
>  softmmu/memory.c |  13 +++
>  hw/virtio/trace-events   |   5 +
>  5 files changed, 265 insertions(+), 2 deletions(-)
> 




Re: [PATCH 0/4] RfC: microvm: add second ioapic

2020-10-16 Thread Philippe Mathieu-Daudé

On 10/16/20 1:43 PM, Gerd Hoffmann wrote:

Add a second ioapic to microvm.  Gives us more IRQ lines we can
use for virtio-mmio devices.  Bump number of possible virtio-mmio
devices from 8 to 24.

Gerd Hoffmann (4):
   microvm: make number of virtio transports runtime configurable
   microvm: make pcie irq base runtime configurable
   microvm: add second ioapic
   microvm: reconfigure irqs if second ioapic is available


After looking at Laurent's m68k virt machine,
I wonder if it is possible to use the Goldfish-PIC
with the MicroVM instead (or another Goldfish machine
type).




Re: [PULL 18/22] meson: Move the detection logic for sphinx to meson

2020-10-16 Thread Yonggang Luo
On Fri, Oct 16, 2020 at 7:48 PM Paolo Bonzini  wrote:
>
> From: Yonggang Luo 
>
> Signed-off-by: Yonggang Luo 
> Message-Id: <20201015220626.418-4-luoyongg...@gmail.com>
> Signed-off-by: Paolo Bonzini 
> ---
>  configure | 59 ---
>  docs/meson.build  | 46 
>  meson.build   | 30 
>  meson_options.txt |  4 
>  4 files changed, 64 insertions(+), 75 deletions(-)
>
> diff --git a/configure b/configure
> index 3edbdd2a24..68f097861d 100755
> --- a/configure
> +++ b/configure
> @@ -297,7 +297,7 @@ brlapi=""
>  curl=""
>  iconv="auto"
>  curses="auto"
> -docs=""
> +docs="auto"
>  fdt="auto"
>  netmap="no"
>  sdl="auto"
> @@ -820,15 +820,6 @@ do
>  fi
>  done
>
> -sphinx_build=
> -for binary in sphinx-build-3 sphinx-build
> -do
> -if has "$binary"
> -then
> -sphinx_build=$(command -v "$binary")
> -break
> -fi
> -done
>
>  # Check for ancillary tools used in testing
>  genisoimage=
> @@ -1228,9 +1219,9 @@ for opt do
>;;
>--disable-crypto-afalg) crypto_afalg="no"
>;;
> -  --disable-docs) docs="no"
> +  --disable-docs) docs="disabled"
>;;
> -  --enable-docs) docs="yes"
> +  --enable-docs) docs="enabled"
>;;
>--disable-vhost-net) vhost_net="no"
>;;
> @@ -4419,45 +4410,6 @@ if check_include linux/btrfs.h ; then
>  btrfs=yes
>  fi
>
> -# If we're making warnings fatal, apply this to Sphinx runs as well
> -sphinx_werror=""
> -if test "$werror" = "yes"; then
> -sphinx_werror="-W"
> -fi
> -
> -# Check we have a new enough version of sphinx-build
> -has_sphinx_build() {
> -# This is a bit awkward but works: create a trivial document and
> -# try to run it with our configuration file (which enforces a
> -# version requirement). This will fail if either
> -# sphinx-build doesn't exist at all or if it is too old.
> -mkdir -p "$TMPDIR1/sphinx"
> -touch "$TMPDIR1/sphinx/index.rst"
> -"$sphinx_build" $sphinx_werror -c "$source_path/docs" \
> --b html "$TMPDIR1/sphinx" \
> -"$TMPDIR1/sphinx/out"  >> config.log 2>&1
> -}
> -
> -# Check if tools are available to build documentation.
> -if test "$docs" != "no" ; then
> -  if has_sphinx_build; then
> -sphinx_ok=yes
> -  else
> -sphinx_ok=no
> -  fi
> -  if test "$sphinx_ok" = "yes"; then
> -docs=yes
> -  else
> -if test "$docs" = "yes" ; then
> -  if has $sphinx_build && test "$sphinx_ok" != "yes"; then
> -echo "Warning: $sphinx_build exists but it is either too old or
uses too old a Python version" >&2
> -  fi
> -  feature_not_found "docs" "Install a Python 3 version of
python-sphinx"
> -fi
> -docs=no
> -  fi
> -fi
> -
>  # Search for bswap_32 function
>  byteswap_h=no
>  cat > $TMPC << EOF
> @@ -6093,9 +6045,6 @@ qemu_version=$(head $source_path/VERSION)
>  echo "PKGVERSION=$pkgversion" >>$config_host_mak
>  echo "SRC_PATH=$source_path" >> $config_host_mak
>  echo "TARGET_DIRS=$target_list" >> $config_host_mak
> -if [ "$docs" = "yes" ] ; then
> -  echo "BUILD_DOCS=yes" >> $config_host_mak
> -fi
>  if test "$modules" = "yes"; then
># $shacmd can generate a hash started with digit, which the compiler
doesn't
># like as an symbol. So prefix it with an underscore
> @@ -6784,7 +6733,6 @@ fi
>  echo "ROMS=$roms" >> $config_host_mak
>  echo "MAKE=$make" >> $config_host_mak
>  echo "PYTHON=$python" >> $config_host_mak
> -echo "SPHINX_BUILD=$sphinx_build" >> $config_host_mak
>  echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
>  echo "MESON=$meson" >> $config_host_mak
>  echo "NINJA=$ninja" >> $config_host_mak
> @@ -7066,6 +7014,7 @@ NINJA=$ninja $meson setup \
>  -Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f \
>  -Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt \
>  -Diconv=$iconv -Dcurses=$curses -Dlibudev=$libudev\
> +-Ddocs=$docs -Dsphinx_build=$sphinx_build \
>  $cross_arg \
>  "$PWD" "$source_path"
>
> diff --git a/docs/meson.build b/docs/meson.build
> index 0340d489ac..789dca8cc0 100644
> --- a/docs/meson.build
> +++ b/docs/meson.build
> @@ -1,4 +1,50 @@

> +if get_option('sphinx_build') == ''
> +  sphinx_build = find_program(['sphinx-build-3', 'sphinx-build'],
> +  required: get_option('docs'))
> +else
> +  sphinx_build = find_program(get_option('sphinx_build'),
> +  required: get_option('docs'))
> +endif
> +
> +# Check if tools are available to build documentation.
> +build_docs = false
> +if sphinx_build.found()
> +  SPHINX_ARGS = [sphinx_build]
> +  # If we're making warnings fatal, apply this to Sphinx runs as well
> +  if get_option('werror')
> +SPHINX_ARGS += [ '-W' ]
> +  endif
> +
> +  # This is a bit awkward but works: create a trivial document and
> +  # try to run it with our configuration file (which enforces a
> +  # version requirement). This will fail if

Re: [PATCH v4 14/16] fuzz: add general-fuzz configs for oss-fuzz

2020-10-16 Thread Paolo Bonzini
On 15/10/20 15:41, Alexander Bulekov wrote:
> +typedef struct general_fuzz_config {
> +const char *name, *args, *objects;
> +} general_fuzz_config;
> +
> +GArray *get_general_fuzz_configs(void);

Can't it be even a "const struct general_fuzz_config
general_fuzz_configs[] = ..." instead of a GArray?  Not a huge
difference, but still.

Paolo




[RFC PATCH v3] target/mips: Increase number of TLB entries on the 34Kf core (16 -> 64)

2020-10-16 Thread Philippe Mathieu-Daudé
Per "MIPS32 34K Processor Core Family Software User's Manual,
Revision 01.13" page 8 in "Joint TLB (JTLB)" section:

  "The JTLB is a fully associative TLB cache containing 16, 32,
   or 64-dual-entries mapping up to 128 virtual pages to their
   corresponding physical addresses."

There is no particular reason to restrict the 34Kf core model to
16 TLB entries, so raise its config to 64.

This is helpful for other projects, in particular the Yocto Project:

  Yocto Project uses qemu-system-mips 34Kf cpu model, to run 32bit
  MIPS CI loop. It was observed that in this case CI test execution
  time was almost twice longer than 64bit MIPS variant that runs
  under MIPS64R2-generic model. It was investigated and concluded
  that the difference in number of TLBs 16 in 34Kf case vs 64 in
  MIPS64R2-generic is responsible for most of CI real time execution
  difference. Because with 16 TLBs linux user-land trashes TLB more
  and it needs to execute more instructions in TLB refill handler
  calls, as result it runs much longer.

(https://lists.gnu.org/archive/html/qemu-devel/2020-10/msg03428.html)

Buglink: https://bugzilla.yoctoproject.org/show_bug.cgi?id=13992
Reported-by: Victor Kamensky 
Signed-off-by: Philippe Mathieu-Daudé 
---
v3: KISS
Supersedes: <20201015224746.540027-1-f4...@amsat.org>
Signed-off-by: Philippe Mathieu-Daudé 
---
 target/mips/translate_init.c.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/mips/translate_init.c.inc b/target/mips/translate_init.c.inc
index 637caccd890..ad21756f4d9 100644
--- a/target/mips/translate_init.c.inc
+++ b/target/mips/translate_init.c.inc
@@ -254,7 +254,7 @@ const mips_def_t mips_defs[] =
 .CP0_PRid = 0x00019500,
 .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
(MMU_TYPE_R4000 << CP0C0_MT),
-.CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (15 << CP0C1_MMU) |
+.CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (63 << CP0C1_MMU) |
(0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
(0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
(1 << CP0C1_CA),
-- 
2.26.2




Re: [PATCH v4 00/16] Add a General Virtual Device Fuzzer

2020-10-16 Thread Paolo Bonzini
If you have to do a v5, the correct word is generic not general. :)

Otherwise looks great.

Paolo

On 15/10/20 15:41, Alexander Bulekov wrote:
> v4:
> - Replace yaml + c template-based oss-fuzz configs, with C code to
>   register a FuzzTarget for each config (as suggested by Paolo)
> - Replicate the functionality of address_space_write_rom to ensure
>   matching behavior when QTEST_LOG is enabled
> - Improve code documentation/comments
> - Small formatting changes
> v3:
>   - Use flatviews to help select regions for fuzzing 
>   - Meson-related changes
> - Add some documentation
>   - Improve minimalization script to trim write{bwlq} commands
> v2:
>   - Remove QOS dependency.
>   - Add a custom crossover function
>   - Fix broken minimization scripts
>   - Fixes to the IO region and DMA handling code
> 
> This is a general virtual-device fuzzer, designed to fuzz devices over Port 
> IO,
> MMIO, and DMA.
> 
> To get started with this:
>  1. Build the fuzzers (see docs/devel/fuzzing.txt)
> Note: Build with --enable-sanitizers, or create a "dictionary file":
> echo kw1=\"FUZZ\" > dict
> and pass it as an argument to libFuzzer with -dict=./dict
> This magic value is a command separator that lets the fuzzer perform
> multiple IO actions with a single input.
> 
>  2. Pick the qemu arguments you wish to fuzz:
> export QEMU_FUZZ_ARGS="-M q35 -device virtio-balloon"
> 
>  3. Tell the fuzzer which QOM objects or MemoryRegion names to fuzz. I find 
> the
>  "info qom-tree", "info qtree" and "info mtree" commands useful for 
> identifying
>  these. Supports globbing. Here I will try to simultaneously fuzz(for no good
>  reason) virtio-balloon and e1000e, which is included by default in the q35:
> export QEMU_FUZZ_OBJECTS='virtio* e1000*'
> You can also try to fuzz the whole machine:
> export QEMU_FUZZ_OBJECTS='*'
> 
>  4. Run the fuzzer for 0 inputs. The fuzzer should output a list of
>  MemoryRegions/PCI Devices it will try to fuzz. Confirm that these match your
>  expectations.
> ./i386-softmmu/qemu-fuzz-i386 --fuzz-target=general-fuzz -runs=0
> 
>  5. Run the fuzzer:
> ./i386-softmmu/qemu-fuzz-i386 --fuzz-target=general-fuzz 
> 
> 
> Basically, at the core, this fuzzer is an interpreter that splits the input
> into a series of commands, such as mmio_write, pio_write, etc. We structure
> these commands to hit only MemoryRegions that are associated with the devices
> specified in QEMU_FUZZ_OBJECTS. Additionally, these patches add "hooks" to
> functions that are typically used by virtual-devices to read from RAM (DMA).
> These hooks attempt to populate these DMA regions with fuzzed data, just in
> time.
> 
> Some of the issues I have found or reproduced with this fuzzer:
> https://bugs.launchpad.net/bugs/1525123
> https://bugs.launchpad.net/bugs/1681439
> https://bugs.launchpad.net/bugs/1777315
> https://bugs.launchpad.net/bugs/1878034
> https://bugs.launchpad.net/bugs/1878043
> https://bugs.launchpad.net/bugs/1878054
> https://bugs.launchpad.net/bugs/1878057
> https://bugs.launchpad.net/bugs/1878067
> https://bugs.launchpad.net/bugs/1878134
> https://bugs.launchpad.net/bugs/1878136
> https://bugs.launchpad.net/bugs/1878253
> https://bugs.launchpad.net/bugs/1878255
> https://bugs.launchpad.net/bugs/1878259
> https://bugs.launchpad.net/bugs/1878263
> https://bugs.launchpad.net/bugs/1878323
> https://bugs.launchpad.net/bugs/1878641
> https://bugs.launchpad.net/bugs/1878642
> https://bugs.launchpad.net/bugs/1878645
> https://bugs.launchpad.net/bugs/1878651
> https://bugs.launchpad.net/bugs/1879223
> https://bugs.launchpad.net/bugs/1879227
> https://bugs.launchpad.net/bugs/1879531
> https://bugs.launchpad.net/bugs/1880355
> https://bugs.launchpad.net/bugs/1880539
> https://bugs.launchpad.net/bugs/1884693
> https://bugs.launchpad.net/bugs/1886362
> https://bugs.launchpad.net/bugs/1887303
> https://bugs.launchpad.net/bugs/1887309
> https://bugs.launchpad.net/bugs/697510
> 
> Alexander Bulekov (16):
>   memory: Add FlatView foreach function
>   fuzz: Add general virtual-device fuzzer
>   fuzz: Add PCI features to the general fuzzer
>   fuzz: Add DMA support to the generic-fuzzer
>   fuzz: Declare DMA Read callback function
>   fuzz: Add fuzzer callbacks to DMA-read functions
>   fuzz: Add support for custom crossover functions
>   fuzz: add a DISABLE_PCI op to general-fuzzer
>   fuzz: add a crossover function to generic-fuzzer
>   scripts/oss-fuzz: Add script to reorder a general-fuzzer trace
>   scripts/oss-fuzz: Add crash trace minimization script
>   fuzz: Add instructions for using general-fuzz
>   fuzz: add an "opaque" to the FuzzTarget struct
>   fuzz: add general-fuzz configs for oss-fuzz
>   fuzz: register predefined general-fuzz configs
>   scripts/oss-fuzz: remove the general-fuzz target
> 
>  docs/devel/fuzzing.txt|  39 +
>  include/exec/memory.h |  21 +
>  include/

Re: [PATCH v2 4/4] MAINTAINERS: Move MIPS GIC timer files to Boston board section

2020-10-16 Thread Philippe Mathieu-Daudé

On 10/14/20 3:39 PM, Thomas Huth wrote:

On 13/10/2020 12.16, Philippe Mathieu-Daudé wrote:

The MIPS GIC timer is only used by the Boston board.

Signed-off-by: Philippe Mathieu-Daudé 
---
  MAINTAINERS | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 702f73823fc..62db288bfc4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -233,11 +233,9 @@ F: docs/system/cpu-models-mips.rst.inc
  F: hw/intc/mips_gic.c
  F: hw/mips/
  F: hw/misc/mips_*
-F: hw/timer/mips_gictimer.c
  F: include/hw/intc/mips_gic.h
  F: include/hw/mips/
  F: include/hw/misc/mips_*
-F: include/hw/timer/mips_gictimer.h
  F: tests/tcg/mips/
  K: ^Subject:.*(?i)mips
  
@@ -1167,7 +1165,9 @@ S: Odd Fixes

  F: hw/core/loader-fit.c
  F: hw/mips/boston.c
  F: hw/pci-host/xilinx-pcie.c
+F: hw/timer/mips_gictimer.c
  F: include/hw/pci-host/xilinx-pcie.h
+F: include/hw/timer/mips_gictimer.h


If I grep for mips_gictimer_init, it seems like this function is used from
mips_gic_realize in hw/intc/mips_gic.c ... and mips_gic.c / TYPE_MIPS_GIC is
also used from the malta board ... so are you really sure this is right? Or
what did I miss?


We have another Frankenstein :(



Re: [PATCH v2 0/4] MAINTAINERS: Update MIPS sections

2020-10-16 Thread Philippe Mathieu-Daudé

On 10/13/20 12:16 PM, Philippe Mathieu-Daudé wrote:

Volunteer to maintain MIPS TCG.
As discussed on list, Huacai will likely send a similar patch.

Few more adjustments (in particular around Boston board).

Based-on: <1602103041-32017-1-git-send-email-aleksandar.qemu.de...@gmail.com>
https://lists.gnu.org/archive/html/qemu-devel/2020-10/msg01974.html

v2:
- Squashed Paul email address change with Boston downgrade (Thomas)

Philippe Mathieu-Daudé (4):
   MAINTAINERS: Put myself forward for MIPS target
   MAINTAINERS: Remove duplicated Malta test entries
   MAINTAINERS: Downgrade MIPS Boston to 'Odd Fixes', fix Paul Burton
 mail
   MAINTAINERS: Move MIPS GIC timer files to Boston board section


Thanks, patches 1-3 applied to mips-next.



Re: [PATCH 0/2] hw/mips/malta: Minor housekeeping in mips_malta_init()

2020-10-16 Thread Philippe Mathieu-Daudé

On 10/12/20 6:05 PM, Philippe Mathieu-Daudé wrote:

Move some code around to make this big function
easier to review.

Philippe Mathieu-Daudé (2):
   hw/mips/malta: Move gt64120 related code together
   hw/mips/malta: Use clearer qdev style

  hw/mips/malta.c | 21 ++---
  1 file changed, 10 insertions(+), 11 deletions(-)



Thanks, applied to mips-next.



  1   2   3   >