Re: [Qemu-devel] [PATCH 03/13] hw: Move MC146818 device from hw/timer/ to hw/rtc/ subdirectory

2019-09-16 Thread Thomas Huth
On 16/09/2019 17.48, Philippe Mathieu-Daudé wrote:
> The MC146818 is a Real Time Clock, not a timer.
> Move it under the hw/rtc/ subdirectory.
> 
> Signed-off-by: Philippe Mathieu-Daudé 
[...]
> diff --git a/include/hw/rtc/mc146818rtc.h b/include/hw/rtc/mc146818rtc.h
> new file mode 100644
> index 00..888e04f9ab
> --- /dev/null
> +++ b/include/hw/rtc/mc146818rtc.h
> @@ -0,0 +1,38 @@
> +/*
> + * QEMU MC146818 RTC emulation
> + *
> + * Copyright (c) 2003-2004 Fabrice Bellard
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a 
> copy
> + * of this software and associated documentation files (the "Software"), to 
> deal
> + * in the Software without restriction, including without limitation the 
> rights
> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> + * copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
> FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> + * THE SOFTWARE.
> + */

If you run "git blame" on the old header file, it does not seem like
Fabrice wrote this header, so I'm not sure whether it makes sense to add
his (c) statement here?

Maybe rather use a one-line "SPDX-License-Identifier: GPL-2.0-or-later"
here?

 Thomas





Re: [Qemu-devel] [PATCH 01/13] hw/timer: Compile devices not target-dependent as common object

2019-09-16 Thread Thomas Huth
On 16/09/2019 17.48, Philippe Mathieu-Daudé wrote:
> All these devices do not contain any target-specific. While most
> of them are arch-specific, they are shared between different
> targets of the same arch family (ARM and AArch64, MIPS32/MIPS64,
> endianess, ...).
> Put them into common-obj-y to compile them once for all targets.
> 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  hw/timer/Makefile.objs | 22 +++---
>  1 file changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs
> index 123d92c969..f407523aa4 100644
> --- a/hw/timer/Makefile.objs
> +++ b/hw/timer/Makefile.objs
> @@ -25,20 +25,20 @@ common-obj-$(CONFIG_MILKYMIST) += milkymist-sysctl.o
>  common-obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp-rtc.o
>  common-obj-$(CONFIG_NRF51_SOC) += nrf51_timer.o
>  
> -obj-$(CONFIG_ALTERA_TIMER) += altera_timer.o
> -obj-$(CONFIG_EXYNOS4) += exynos4210_mct.o
> -obj-$(CONFIG_EXYNOS4) += exynos4210_pwm.o
> -obj-$(CONFIG_EXYNOS4) += exynos4210_rtc.o
> -obj-$(CONFIG_OMAP) += omap_gptimer.o
> -obj-$(CONFIG_OMAP) += omap_synctimer.o
> -obj-$(CONFIG_PXA2XX) += pxa2xx_timer.o
> -obj-$(CONFIG_SH4) += sh_timer.o
> -obj-$(CONFIG_DIGIC) += digic-timer.o
> -obj-$(CONFIG_MIPS_CPS) += mips_gictimer.o
> +common-obj-$(CONFIG_ALTERA_TIMER) += altera_timer.o
> +common-obj-$(CONFIG_EXYNOS4) += exynos4210_mct.o
> +common-obj-$(CONFIG_EXYNOS4) += exynos4210_pwm.o
> +common-obj-$(CONFIG_EXYNOS4) += exynos4210_rtc.o
> +common-obj-$(CONFIG_OMAP) += omap_gptimer.o
> +common-obj-$(CONFIG_OMAP) += omap_synctimer.o
> +common-obj-$(CONFIG_PXA2XX) += pxa2xx_timer.o
> +common-obj-$(CONFIG_SH4) += sh_timer.o
> +common-obj-$(CONFIG_DIGIC) += digic-timer.o
> +common-obj-$(CONFIG_MIPS_CPS) += mips_gictimer.o
>  
>  obj-$(CONFIG_MC146818RTC) += mc146818rtc.o
>  
> -obj-$(CONFIG_ALLWINNER_A10_PIT) += allwinner-a10-pit.o
> +common-obj-$(CONFIG_ALLWINNER_A10_PIT) += allwinner-a10-pit.o
>  
>  common-obj-$(CONFIG_STM32F2XX_TIMER) += stm32f2xx_timer.o
>  common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o aspeed_rtc.o
> 

Reviewed-by: Thomas Huth 

FWIW, that change is also part of my "hw/*/Makefile.objs: Move many .o
files to common-objs" patch ... but since it looks identical, it should
not matter, which patch goes in first.



Re: [Qemu-devel] [PATCH 03/13] hw: Move MC146818 device from hw/timer/ to hw/rtc/ subdirectory

2019-09-16 Thread David Gibson
On Mon, Sep 16, 2019 at 05:48:37PM +0200, Philippe Mathieu-Daudé wrote:
> The MC146818 is a Real Time Clock, not a timer.
> Move it under the hw/rtc/ subdirectory.
> 
> Signed-off-by: Philippe Mathieu-Daudé 

ppc parts

Acked-by: David Gibson 

> ---
>  MAINTAINERS  |  4 +--
>  hw/alpha/dp264.c |  2 +-
>  hw/hppa/machine.c|  2 +-
>  hw/i386/acpi-build.c |  2 +-
>  hw/i386/pc.c |  2 +-
>  hw/i386/pc_q35.c |  2 +-
>  hw/mips/mips_fulong2e.c  |  2 +-
>  hw/mips/mips_jazz.c  |  2 +-
>  hw/mips/mips_malta.c |  2 +-
>  hw/mips/mips_r4k.c   |  2 +-
>  hw/ppc/pnv.c |  2 +-
>  hw/ppc/prep.c|  2 +-
>  hw/rtc/Kconfig   |  3 ++
>  hw/rtc/Makefile.objs |  1 +
>  hw/{timer => rtc}/mc146818rtc.c  |  2 +-
>  hw/timer/Kconfig |  3 --
>  hw/timer/Makefile.objs   |  2 --
>  hw/timer/hpet.c  |  2 +-
>  include/hw/rtc/mc146818rtc.h | 38 
>  include/hw/{timer => rtc}/mc146818rtc_regs.h |  1 +
>  include/hw/timer/mc146818rtc.h   | 14 
>  tests/rtc-test.c |  2 +-
>  22 files changed, 59 insertions(+), 35 deletions(-)
>  rename hw/{timer => rtc}/mc146818rtc.c (99%)
>  create mode 100644 include/hw/rtc/mc146818rtc.h
>  rename include/hw/{timer => rtc}/mc146818rtc_regs.h (98%)
>  delete mode 100644 include/hw/timer/mc146818rtc.h
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 5562d2c6d0..481f2318cb 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1263,7 +1263,7 @@ F: hw/misc/debugexit.c
>  F: hw/misc/pc-testdev.c
>  F: hw/timer/hpet*
>  F: hw/timer/i8254*
> -F: hw/timer/mc146818rtc*
> +F: hw/rtc/mc146818rtc*
>  F: hw/watchdog/wdt_ib700.c
>  F: hw/watchdog/wdt_i6300esb.c
>  F: include/hw/display/vga.h
> @@ -1275,7 +1275,7 @@ F: include/hw/isa/i8259_internal.h
>  F: include/hw/isa/superio.h
>  F: include/hw/timer/hpet.h
>  F: include/hw/timer/i8254*
> -F: include/hw/timer/mc146818rtc*
> +F: include/hw/rtc/mc146818rtc*
>  
>  Machine core
>  M: Eduardo Habkost 
> diff --git a/hw/alpha/dp264.c b/hw/alpha/dp264.c
> index 51feee8558..51b3cf7a61 100644
> --- a/hw/alpha/dp264.c
> +++ b/hw/alpha/dp264.c
> @@ -14,7 +14,7 @@
>  #include "alpha_sys.h"
>  #include "qemu/error-report.h"
>  #include "sysemu/sysemu.h"
> -#include "hw/timer/mc146818rtc.h"
> +#include "hw/rtc/mc146818rtc.h"
>  #include "hw/ide.h"
>  #include "hw/timer/i8254.h"
>  #include "hw/isa/superio.h"
> diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
> index 2736ce835e..6598e2469d 100644
> --- a/hw/hppa/machine.c
> +++ b/hw/hppa/machine.c
> @@ -12,7 +12,7 @@
>  #include "qemu/error-report.h"
>  #include "sysemu/reset.h"
>  #include "sysemu/sysemu.h"
> -#include "hw/timer/mc146818rtc.h"
> +#include "hw/rtc/mc146818rtc.h"
>  #include "hw/ide.h"
>  #include "hw/timer/i8254.h"
>  #include "hw/char/serial.h"
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index e54e571a75..44a8073507 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -45,7 +45,7 @@
>  #include "hw/acpi/vmgenid.h"
>  #include "hw/boards.h"
>  #include "sysemu/tpm_backend.h"
> -#include "hw/timer/mc146818rtc_regs.h"
> +#include "hw/rtc/mc146818rtc_regs.h"
>  #include "migration/vmstate.h"
>  #include "hw/mem/memory-device.h"
>  #include "sysemu/numa.h"
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index bad866fe44..beef7a992d 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -42,7 +42,7 @@
>  #include "elf.h"
>  #include "migration/vmstate.h"
>  #include "multiboot.h"
> -#include "hw/timer/mc146818rtc.h"
> +#include "hw/rtc/mc146818rtc.h"
>  #include "hw/dma/i8257.h"
>  #include "hw/timer/i8254.h"
>  #include "hw/input/i8042.h"
> diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
> index d4e8a1cb9f..a976af9a2a 100644
> --- a/hw/i386/pc_q35.c
> +++ b/hw/i386/pc_q35.c
> @@ -33,7 +33,7 @@
>  #include "hw/loader.h"
>  #include "sysemu/arch_init.h"
>  #include "hw/i2c/smbus_eeprom.h"
> -#include "hw/timer/mc146818rtc.h"
> +#include "hw/rtc/mc146818rtc.h"
>  #include "hw/xen/xen.h"
>  #include "sysemu/kvm.h"
>  #include "kvm_i386.h"
> diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c
> index cf537dd7e6..03a27e1767 100644
> --- a/hw/mips/mips_fulong2e.c
> +++ b/hw/mips/mips_fulong2e.c
> @@ -39,7 +39,7 @@
>  #include "hw/ide.h"
>  #include "elf.h"
>  #include "hw/isa/vt82c686.h"
> -#include "hw/timer/mc146818rtc.h"
> +#include "hw/rtc/mc146818rtc.h"
>  #include "hw/timer/i8254.h"
>  #include "exec/address-spaces.h"
>  #include "sysemu/qtest.h"
> diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c
> index 

Re: [Qemu-devel] [PATCH 04/13] hw: Move M48T59 device from hw/timer/ to hw/rtc/ subdirectory

2019-09-16 Thread David Gibson
On Mon, Sep 16, 2019 at 05:48:38PM +0200, Philippe Mathieu-Daudé wrote:
> The M48T59 is a Real Time Clock, not a timer.
> Move it under the hw/rtc/ subdirectory.
> 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  MAINTAINERS |  4 +-
>  hw/ppc/ppc405_boards.c  |  2 +-
>  hw/ppc/prep.c   |  2 +-
>  hw/rtc/Kconfig  |  3 ++
>  hw/rtc/Makefile.objs|  4 ++
>  hw/{timer => rtc}/m48t59-internal.h |  0
>  hw/{timer => rtc}/m48t59-isa.c  |  4 +-
>  hw/{timer => rtc}/m48t59.c  |  2 +-
>  hw/sparc/sun4m.c|  2 +-
>  hw/sparc64/sun4u.c  |  2 +-
>  hw/timer/Kconfig|  3 --
>  hw/timer/Makefile.objs  |  4 --
>  include/hw/rtc/m48t59.h | 57 +

Uh.. this file seems to be coming out of nowhere, which doesn't seem
right for a code motion.

>  13 files changed, 73 insertions(+), 16 deletions(-)
>  rename hw/{timer => rtc}/m48t59-internal.h (100%)
>  rename hw/{timer => rtc}/m48t59-isa.c (98%)
>  rename hw/{timer => rtc}/m48t59.c (99%)
>  create mode 100644 include/hw/rtc/m48t59.h
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 481f2318cb..679b026fe0 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1064,9 +1064,9 @@ F: hw/pci-host/prep.[hc]
>  F: hw/isa/i82378.c
>  F: hw/isa/pc87312.c
>  F: hw/dma/i82374.c
> -F: hw/timer/m48t59-isa.c
> +F: hw/rtc/m48t59-isa.c
>  F: include/hw/isa/pc87312.h
> -F: include/hw/timer/m48t59.h
> +F: include/hw/rtc/m48t59.h
>  F: pc-bios/ppc_rom.bin
>  
>  sPAPR
> diff --git a/hw/ppc/ppc405_boards.c b/hw/ppc/ppc405_boards.c
> index 388cae0b43..1f721feed6 100644
> --- a/hw/ppc/ppc405_boards.c
> +++ b/hw/ppc/ppc405_boards.c
> @@ -29,7 +29,7 @@
>  #include "cpu.h"
>  #include "hw/ppc/ppc.h"
>  #include "ppc405.h"
> -#include "hw/timer/m48t59.h"
> +#include "hw/rtc/m48t59.h"
>  #include "hw/block/flash.h"
>  #include "sysemu/sysemu.h"
>  #include "sysemu/qtest.h"
> diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
> index 3a51536e1a..862345c2ac 100644
> --- a/hw/ppc/prep.c
> +++ b/hw/ppc/prep.c
> @@ -25,7 +25,7 @@
>  
>  #include "qemu/osdep.h"
>  #include "cpu.h"
> -#include "hw/timer/m48t59.h"
> +#include "hw/rtc/m48t59.h"
>  #include "hw/char/serial.h"
>  #include "hw/block/fdc.h"
>  #include "net/net.h"
> diff --git a/hw/rtc/Kconfig b/hw/rtc/Kconfig
> index 7ffd702268..159c233517 100644
> --- a/hw/rtc/Kconfig
> +++ b/hw/rtc/Kconfig
> @@ -1,3 +1,6 @@
> +config M48T59
> +bool
> +
>  config PL031
>  bool
>  
> diff --git a/hw/rtc/Makefile.objs b/hw/rtc/Makefile.objs
> index 3cac0d5a63..c87f81405e 100644
> --- a/hw/rtc/Makefile.objs
> +++ b/hw/rtc/Makefile.objs
> @@ -1,2 +1,6 @@
> +common-obj-$(CONFIG_M48T59) += m48t59.o
> +ifeq ($(CONFIG_ISA_BUS),y)
> +common-obj-$(CONFIG_M48T59) += m48t59-isa.o
> +endif
>  common-obj-$(CONFIG_PL031) += pl031.o
>  obj-$(CONFIG_MC146818RTC) += mc146818rtc.o
> diff --git a/hw/timer/m48t59-internal.h b/hw/rtc/m48t59-internal.h
> similarity index 100%
> rename from hw/timer/m48t59-internal.h
> rename to hw/rtc/m48t59-internal.h
> diff --git a/hw/timer/m48t59-isa.c b/hw/rtc/m48t59-isa.c
> similarity index 98%
> rename from hw/timer/m48t59-isa.c
> rename to hw/rtc/m48t59-isa.c
> index 5e5432abfd..7fde854c0f 100644
> --- a/hw/timer/m48t59-isa.c
> +++ b/hw/rtc/m48t59-isa.c
> @@ -1,5 +1,5 @@
>  /*
> - * QEMU M48T59 and M48T08 NVRAM emulation (ISA bus interface
> + * QEMU M48T59 and M48T08 NVRAM emulation (ISA bus interface)
>   *
>   * Copyright (c) 2003-2005, 2007 Jocelyn Mayer
>   * Copyright (c) 2013 Hervé Poussineau
> @@ -26,7 +26,7 @@
>  #include "qemu/osdep.h"
>  #include "hw/isa/isa.h"
>  #include "hw/qdev-properties.h"
> -#include "hw/timer/m48t59.h"
> +#include "hw/rtc/m48t59.h"
>  #include "m48t59-internal.h"
>  #include "qemu/module.h"
>  
> diff --git a/hw/timer/m48t59.c b/hw/rtc/m48t59.c
> similarity index 99%
> rename from hw/timer/m48t59.c
> rename to hw/rtc/m48t59.c
> index a9fc2f981a..fc592b9fb1 100644
> --- a/hw/timer/m48t59.c
> +++ b/hw/rtc/m48t59.c
> @@ -27,7 +27,7 @@
>  #include "qemu-common.h"
>  #include "hw/irq.h"
>  #include "hw/qdev-properties.h"
> -#include "hw/timer/m48t59.h"
> +#include "hw/rtc/m48t59.h"
>  #include "qemu/timer.h"
>  #include "sysemu/runstate.h"
>  #include "sysemu/sysemu.h"
> diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
> index 6c5a17a020..2aaa5bf1ae 100644
> --- a/hw/sparc/sun4m.c
> +++ b/hw/sparc/sun4m.c
> @@ -31,7 +31,7 @@
>  #include "qemu/error-report.h"
>  #include "qemu/timer.h"
>  #include "hw/sparc/sun4m_iommu.h"
> -#include "hw/timer/m48t59.h"
> +#include "hw/rtc/m48t59.h"
>  #include "migration/vmstate.h"
>  #include "hw/sparc/sparc32_dma.h"
>  #include "hw/block/fdc.h"
> diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
> index 1ded2a4c9a..955082773b 100644
> --- a/hw/sparc64/sun4u.c
> +++ b/hw/sparc64/sun4u.c
> @@ -36,7 +36,7 @@
>  #include "hw/pci-host/sabre.h"
>  #include "hw/char/serial.h"
>  

[Qemu-devel] [PATCH] nbd: Grab aio context lock in more places

2019-09-16 Thread Eric Blake
When iothreads are in use, the failure to grab the aio context results
in an assertion failure when trying to unlock things during blk_unref,
when trying to unlock a mutex that was not locked.  In short, all
calls to nbd_export_put need to done while within the correct aio
context.  But since nbd_export_put can recursively reach itself via
nbd_export_close, and recursively grabbing the context would deadlock,
we can't do the context grab directly in those functions, but must do
so in their callers.

Hoist the use of the correct aio_context from nbd_export_new() to its
caller qmp_nbd_server_add().  Then tweak qmp_nbd_server_remove(),
nbd_eject_notifier(), and nbd_esport_close_all() to grab the right
context, so that all callers during qemu now own the context before
nbd_export_put() can call blk_unref().

Remaining uses in qemu-nbd don't matter (since that use case does not
support iothreads).

Suggested-by: Kevin Wolf 
Signed-off-by: Eric Blake 
---

With this in place, my emailed formula [1] for causing an iothread
assertion failure no longer hits, and all the -nbd and -qcow2 iotests
still pass.  I would still like to update iotests to cover things (I
could not quickly figure out how to make iotest 222 use iothreads -
either we modify that one or add a new one), but wanted to get review
started on this first.

[1] https://lists.gnu.org/archive/html/qemu-devel/2019-09/msg03383.html

 include/block/nbd.h |  1 +
 blockdev-nbd.c  | 14 --
 nbd/server.c| 23 +++
 3 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/include/block/nbd.h b/include/block/nbd.h
index 21550747cf35..316fd705a9e4 100644
--- a/include/block/nbd.h
+++ b/include/block/nbd.h
@@ -340,6 +340,7 @@ void nbd_export_put(NBDExport *exp);

 BlockBackend *nbd_export_get_blockdev(NBDExport *exp);

+AioContext *nbd_export_aio_context(NBDExport *exp);
 NBDExport *nbd_export_find(const char *name);
 void nbd_export_close_all(void);

diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index 213f226ac1c4..6a8b206e1d74 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -151,6 +151,7 @@ void qmp_nbd_server_add(const char *device, bool has_name, 
const char *name,
 BlockBackend *on_eject_blk;
 NBDExport *exp;
 int64_t len;
+AioContext *aio_context;

 if (!nbd_server) {
 error_setg(errp, "NBD server not running");
@@ -173,11 +174,13 @@ void qmp_nbd_server_add(const char *device, bool 
has_name, const char *name,
 return;
 }

+aio_context = bdrv_get_aio_context(bs);
+aio_context_acquire(aio_context);
 len = bdrv_getlength(bs);
 if (len < 0) {
 error_setg_errno(errp, -len,
  "Failed to determine the NBD export's length");
-return;
+goto out;
 }

 if (!has_writable) {
@@ -190,13 +193,16 @@ void qmp_nbd_server_add(const char *device, bool 
has_name, const char *name,
 exp = nbd_export_new(bs, 0, len, name, NULL, bitmap, !writable, !writable,
  NULL, false, on_eject_blk, errp);
 if (!exp) {
-return;
+goto out;
 }

 /* The list of named exports has a strong reference to this export now and
  * our only way of accessing it is through nbd_export_find(), so we can 
drop
  * the strong reference that is @exp. */
 nbd_export_put(exp);
+
+ out:
+aio_context_release(aio_context);
 }

 void qmp_nbd_server_remove(const char *name,
@@ -204,6 +210,7 @@ void qmp_nbd_server_remove(const char *name,
Error **errp)
 {
 NBDExport *exp;
+AioContext *aio_context;

 if (!nbd_server) {
 error_setg(errp, "NBD server not running");
@@ -220,7 +227,10 @@ void qmp_nbd_server_remove(const char *name,
 mode = NBD_SERVER_REMOVE_MODE_SAFE;
 }

+aio_context = nbd_export_aio_context(exp);
+aio_context_acquire(aio_context);
 nbd_export_remove(exp, mode, errp);
+aio_context_release(aio_context);
 }

 void qmp_nbd_server_stop(Error **errp)
diff --git a/nbd/server.c b/nbd/server.c
index 378784c1e54a..3003381c86b4 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -1458,7 +1458,12 @@ static void blk_aio_detach(void *opaque)
 static void nbd_eject_notifier(Notifier *n, void *data)
 {
 NBDExport *exp = container_of(n, NBDExport, eject_notifier);
+AioContext *aio_context;
+
+aio_context = exp->ctx;
+aio_context_acquire(aio_context);
 nbd_export_close(exp);
+aio_context_release(aio_context);
 }

 NBDExport *nbd_export_new(BlockDriverState *bs, uint64_t dev_offset,
@@ -1477,12 +1482,11 @@ NBDExport *nbd_export_new(BlockDriverState *bs, 
uint64_t dev_offset,
  * NBD exports are used for non-shared storage migration.  Make sure
  * that BDRV_O_INACTIVE is cleared and the image is ready for write
  * access since the export could be available before migration handover.
+ * ctx was acquired in the caller.
  */
 assert(name);
 ctx = bdrv_get_aio_context(bs);

Re: [Qemu-devel] [Qemu-ppc] [PATCH] target/ppc: fix signal delivery for ppc64abi32

2019-09-16 Thread David Gibson
On Mon, Sep 16, 2019 at 08:22:42AM +0100, Alex Bennée wrote:
> 
> David Gibson  writes:
> 
> > On Wed, Sep 11, 2019 at 10:33:45AM -0400, Richard Henderson wrote:
> >> On 9/11/19 5:39 AM, Alex Bennée wrote:
> >> > We were incorrectly setting NIP resulting in a segfault. This fixes
> >> > linux-test for this ABI.
> >>
> >> Perhaps better:
> >> We were incorrectly using the 64-bit AIX ABI instead of the 32-bit SYSV 
> >> ABI for
> >> setting NIP for the signal handler.
> >
> > Applied to ppc-for-4.2, with Richard's updated description.
> >
> > For future reference, it's better to directly CC me on such patches.
> > I only barely keep on top of the mailing lists, so if you just send it
> > there it's likely to be some time before I pick it up, or even get
> > lost entirely.
> 
> Should you be added to linux-user/ppc/ in MAINTAINERS?

Hm, maybe.  It's not like I know much about the stuff in there, but
it's also not like anyone else is paying any attention to it.


> 
> >
> >>
> >> ?
> >>
> >> >
> >> > Signed-off-by: Alex Bennée 
> >> > ---
> >> >  linux-user/ppc/signal.c | 4 +++-
> >> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >>
> >> Anyway,
> >> Reviewed-by: Richard Henderson 
> >>
> 
> 

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson


signature.asc
Description: PGP signature


Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 0/6] tests/acceptance: Add tests for the PReP/40p machine

2019-09-16 Thread David Gibson
On Mon, Sep 16, 2019 at 11:56:06AM +0200, Philippe Mathieu-Daudé wrote:
> On 9/16/19 11:52 AM, Alex Bennée wrote:
> > 
> > Philippe Mathieu-Daudé  writes:
> > 
> >> Hi David,
> >>
> >> On 9/16/19 2:42 AM, David Gibson wrote:
> >>> On Sun, Sep 15, 2019 at 11:19:34PM +0200, Philippe Mathieu-Daudé wrote:
>  Quick tests worth to avoid regressions with the 40p machine.
>  idea from the "Maintainers, please tell us how to boot your machines"
>  thread:
>  https://lists.gnu.org/archive/html/qemu-devel/2019-03/msg04177.html
> 
>  v2: Split Travis job, added Hervé R-b tag
>  v1: https://lists.gnu.org/archive/html/qemu-devel/2019-06/msg05896.html
> 
>  Regards,
> 
>  Phil.
> >>>
> >>> I'm guessing you're expecting these to go in via the testing tree, in
> >>> which case
> >>>
> >>> Acked-by: David Gibson 
> >>
> >> Thanks, appreciated :)
> >>
> >>> Or do you want me to take them via the ppc tree?
> >>
> >> I think the 'testing tree' should focus on the CI/testing
> >> infrastructure, while each subsystem maintainers should care about the
> >> tests covering their subsystem (the testing tree maintainers might not
> >> have the required knowledge to be sure a test is correctly implemented).
> >>
> >> In this particular case I assume you don't have much knowledge of that
> >> PPC machine, which is a hobbyist one, but since you are the PPC
> >> maintainer, I'd rather see this going via your tree :)
> >>
> >> Alex/Cleber/Eduardo, any comment on this position?
> > 
> > Once we have a .travis.yml I'm happy with it can go in via another tree
> > no problem. See other thread
> 
> Good :)
> 
> David can take patches 1-5 (I tagged patch 6 as RFC but messed something
> with git-publish and lost it when I sent this series).

Ok, I've taken patches 1-5 into my ppc-for-4.2 tree.

> 
> Thanks!
> 
>  Philippe Mathieu-Daudé (6):
>    tests/acceptance: Add test that runs NetBSD 4.0 installer on PRep/40p
>    tests/acceptance: Test Open Firmware on the PReP/40p
>    tests/acceptance: Test OpenBIOS on the PReP/40p
>    tests/acceptance: Test Sandalfoot initrd on the PReP/40p
>    .travis.yml: Let the avocado job run the 40p tests
>    .travis.yml: Split enterprise vs. hobbyist acceptance test job
> 
>   .travis.yml  |  18 +++-
>   MAINTAINERS  |   1 +
>   tests/acceptance/ppc_prep_40p.py | 150 +++
>   3 files changed, 167 insertions(+), 2 deletions(-)
>   create mode 100644 tests/acceptance/ppc_prep_40p.py
> 
> >>>
> > 
> > 
> 

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson


signature.asc
Description: PGP signature


Re: [Qemu-devel] [PATCH] nbd/server: attach client channel to the export's AioContext

2019-09-16 Thread Eric Blake
On 9/12/19 6:31 AM, Kevin Wolf wrote:

>>
>> Yes, I think locking the context during the "if (exp->blk) {" block at
>> nbd/server.c:1646 should do the trick.

That line number has moved over time; which function are you referring to?

> 
> We need to be careful to avoid locking things twice, so maybe
> nbd_export_put() is already too deep inside the NBD server.
> 
> Its callers are:
> 
> * qmp_nbd_server_add(). Like all other QMP handlers in blockdev-nbd.c it
>   neglects to lock the AioContext, but it should do so. The lock is not
>   only needed for the nbd_export_put() call, but even before.
> 
> * nbd_export_close(), which in turn is called from:
> * nbd_eject_notifier(): run in the main thread, not locked
> * nbd_export_remove():
> * qmp_nbd_server_remove(): see above
> * nbd_export_close_all():
> * bdrv_close_all()
> * qmp_nbd_server_stop()

Even weirder: nbd_export_put() calls nbd_export_close(), and
nbd_export_close() calls nbd_export_put().  The mutual recursion is
mind-numbing, and the fact that we use get/put instead of ref/unref like
most other qemu code is not making it any easier to reason about.

> 
> There are also calls from qemu-nbd, but these can be ignored because we
> don't have iothreads there.
> 
> I think the cleanest would be to take the lock in the outermost callers,
> i.e. all QMP handlers that deal with a specific export, in the eject
> notifier and in nbd_export_close_all().

Okay, I'm trying that (I already tried grabbing the aio_context in
nbd_export_close(), but as you predicted, that deadlocked when a nested
call already encountered the lock taken from an outer call).

> 
>> On the other hand, I wonder if there is any situation in which calling
>> to blk_unref() without locking the context could be safe. If there isn't
>> any, perhaps we should assert that the lock is held if blk->ctx != NULL
>> to catch this kind of bugs earlier?
> 
> blk_unref() must be called from the main thread, and if the BlockBackend
> to be unreferenced is not in the main AioContext, the lock must be held.
> 
> I'm not sure how to assert that locks are held, though. I once looked
> for a way to do this, but it involved either looking at the internal
> state of pthreads mutexes or hacking up QemuMutex with debug state.

Even if we can only test that in a debug build but not during normal
builds, could any of our CI builds set up that configuration?

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH 13/13] hw/rtc/xlnx-zynqmp-rtc: Remove unused "ptimer.h" include

2019-09-16 Thread Alistair Francis
On Mon, Sep 16, 2019 at 9:46 AM Philippe Mathieu-Daudé
 wrote:
>
> The "hw/ptimer.h" header is not used, remove it.
>
> Signed-off-by: Philippe Mathieu-Daudé 

Reviewed-by: Alistair Francis 

Alistair

> ---
>  hw/rtc/xlnx-zynqmp-rtc.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/hw/rtc/xlnx-zynqmp-rtc.c b/hw/rtc/xlnx-zynqmp-rtc.c
> index f9f09b7296..2bcd14d779 100644
> --- a/hw/rtc/xlnx-zynqmp-rtc.c
> +++ b/hw/rtc/xlnx-zynqmp-rtc.c
> @@ -32,7 +32,6 @@
>  #include "qemu/log.h"
>  #include "qemu/module.h"
>  #include "hw/irq.h"
> -#include "hw/ptimer.h"
>  #include "qemu/cutils.h"
>  #include "sysemu/sysemu.h"
>  #include "trace.h"
> --
> 2.20.1
>
>



Re: [Qemu-devel] [PATCH 11/13] hw: Move Aspeed RTC from hw/timer/ to hw/rtc/ subdirectory

2019-09-16 Thread Alistair Francis
On Mon, Sep 16, 2019 at 9:17 AM Philippe Mathieu-Daudé
 wrote:
>
> Move RTC devices under the hw/rtc/ subdirectory.
>
> Signed-off-by: Philippe Mathieu-Daudé 

Reviewed-by: Alistair Francis 

Alistair

> ---
>  hw/rtc/Makefile.objs   | 1 +
>  hw/{timer => rtc}/aspeed_rtc.c | 2 +-
>  hw/rtc/trace-events| 4 
>  hw/timer/Makefile.objs | 2 +-
>  hw/timer/trace-events  | 4 
>  include/hw/arm/aspeed_soc.h| 2 +-
>  include/hw/{timer => rtc}/aspeed_rtc.h | 3 ---
>  7 files changed, 8 insertions(+), 10 deletions(-)
>  rename hw/{timer => rtc}/aspeed_rtc.c (99%)
>  rename include/hw/{timer => rtc}/aspeed_rtc.h (92%)
>
> diff --git a/hw/rtc/Makefile.objs b/hw/rtc/Makefile.objs
> index 3d4763fc26..8dc9fcd3a9 100644
> --- a/hw/rtc/Makefile.objs
> +++ b/hw/rtc/Makefile.objs
> @@ -10,3 +10,4 @@ common-obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp-rtc.o
>  common-obj-$(CONFIG_EXYNOS4) += exynos4210_rtc.o
>  obj-$(CONFIG_MC146818RTC) += mc146818rtc.o
>  common-obj-$(CONFIG_SUN4V_RTC) += sun4v-rtc.o
> +common-obj-$(CONFIG_ASPEED_SOC) += aspeed_rtc.o
> diff --git a/hw/timer/aspeed_rtc.c b/hw/rtc/aspeed_rtc.c
> similarity index 99%
> rename from hw/timer/aspeed_rtc.c
> rename to hw/rtc/aspeed_rtc.c
> index 5313017353..3ca1183558 100644
> --- a/hw/timer/aspeed_rtc.c
> +++ b/hw/rtc/aspeed_rtc.c
> @@ -8,7 +8,7 @@
>
>  #include "qemu/osdep.h"
>  #include "qemu-common.h"
> -#include "hw/timer/aspeed_rtc.h"
> +#include "hw/rtc/aspeed_rtc.h"
>  #include "migration/vmstate.h"
>  #include "qemu/log.h"
>  #include "qemu/timer.h"
> diff --git a/hw/rtc/trace-events b/hw/rtc/trace-events
> index 7f1945ad4c..d6749f4616 100644
> --- a/hw/rtc/trace-events
> +++ b/hw/rtc/trace-events
> @@ -13,3 +13,7 @@ pl031_read(uint32_t addr, uint32_t value) "addr 0x%08x 
> value 0x%08x"
>  pl031_write(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x"
>  pl031_alarm_raised(void) "alarm raised"
>  pl031_set_alarm(uint32_t ticks) "alarm set for %u ticks"
> +
> +# aspeed-rtc.c
> +aspeed_rtc_read(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 
> 0x%08" PRIx64
> +aspeed_rtc_write(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 
> 0x%08" PRIx64
> diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs
> index 33191d74cb..83091770df 100644
> --- a/hw/timer/Makefile.objs
> +++ b/hw/timer/Makefile.objs
> @@ -29,7 +29,7 @@ common-obj-$(CONFIG_MIPS_CPS) += mips_gictimer.o
>  common-obj-$(CONFIG_ALLWINNER_A10_PIT) += allwinner-a10-pit.o
>
>  common-obj-$(CONFIG_STM32F2XX_TIMER) += stm32f2xx_timer.o
> -common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o aspeed_rtc.o
> +common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o
>
>  common-obj-$(CONFIG_CMSDK_APB_TIMER) += cmsdk-apb-timer.o
>  common-obj-$(CONFIG_CMSDK_APB_DUALTIMER) += cmsdk-apb-dualtimer.o
> diff --git a/hw/timer/trace-events b/hw/timer/trace-events
> index 1459d07237..e18b87fc96 100644
> --- a/hw/timer/trace-events
> +++ b/hw/timer/trace-events
> @@ -66,10 +66,6 @@ cmsdk_apb_dualtimer_read(uint64_t offset, uint64_t data, 
> unsigned size) "CMSDK A
>  cmsdk_apb_dualtimer_write(uint64_t offset, uint64_t data, unsigned size) 
> "CMSDK APB dualtimer write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
>  cmsdk_apb_dualtimer_reset(void) "CMSDK APB dualtimer: reset"
>
> -# hw/timer/aspeed-rtc.c
> -aspeed_rtc_read(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 
> 0x%08" PRIx64
> -aspeed_rtc_write(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 
> 0x%08" PRIx64
> -
>  # nrf51_timer.c
>  nrf51_timer_read(uint64_t addr, uint32_t value, unsigned size) "read addr 
> 0x%" PRIx64 " data 0x%" PRIx32 " size %u"
>  nrf51_timer_write(uint64_t addr, uint32_t value, unsigned size) "write addr 
> 0x%" PRIx64 " data 0x%" PRIx32 " size %u"
> diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
> index ab5052b12c..5a443006ed 100644
> --- a/include/hw/arm/aspeed_soc.h
> +++ b/include/hw/arm/aspeed_soc.h
> @@ -17,7 +17,7 @@
>  #include "hw/misc/aspeed_sdmc.h"
>  #include "hw/misc/aspeed_xdma.h"
>  #include "hw/timer/aspeed_timer.h"
> -#include "hw/timer/aspeed_rtc.h"
> +#include "hw/rtc/aspeed_rtc.h"
>  #include "hw/i2c/aspeed_i2c.h"
>  #include "hw/ssi/aspeed_smc.h"
>  #include "hw/watchdog/wdt_aspeed.h"
> diff --git a/include/hw/timer/aspeed_rtc.h b/include/hw/rtc/aspeed_rtc.h
> similarity index 92%
> rename from include/hw/timer/aspeed_rtc.h
> rename to include/hw/rtc/aspeed_rtc.h
> index 15ba42912b..156c8faee3 100644
> --- a/include/hw/timer/aspeed_rtc.h
> +++ b/include/hw/rtc/aspeed_rtc.h
> @@ -8,9 +8,6 @@
>  #ifndef ASPEED_RTC_H
>  #define ASPEED_RTC_H
>
> -#include 
> -
> -#include "hw/irq.h"
>  #include "hw/sysbus.h"
>
>  typedef struct AspeedRtcState {
> --
> 2.20.1
>
>



Re: [Qemu-devel] [PATCH 12/13] hw/rtc/mc146818: Include mc146818rtc_regs.h a bit less

2019-09-16 Thread Alistair Francis
On Mon, Sep 16, 2019 at 9:42 AM Philippe Mathieu-Daudé
 wrote:
>
> Only 2 source files require the "mc146818rtc_regs.h" header.
> Instead of having it processed 12 times, by all objects
> using "mc146818rtc.h", include it directly where used.
>
> Signed-off-by: Philippe Mathieu-Daudé 

Reviewed-by: Alistair Francis 

Alistair

> ---
>  hw/rtc/mc146818rtc.c | 1 +
>  hw/timer/hpet.c  | 1 +
>  include/hw/rtc/mc146818rtc.h | 1 -
>  3 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c
> index ced15f764f..9d4ed54f65 100644
> --- a/hw/rtc/mc146818rtc.c
> +++ b/hw/rtc/mc146818rtc.c
> @@ -35,6 +35,7 @@
>  #include "sysemu/reset.h"
>  #include "sysemu/runstate.h"
>  #include "hw/rtc/mc146818rtc.h"
> +#include "hw/rtc/mc146818rtc_regs.h"
>  #include "migration/vmstate.h"
>  #include "qapi/error.h"
>  #include "qapi/qapi-commands-misc-target.h"
> diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
> index 02bf8a8ce8..9f17aaa278 100644
> --- a/hw/timer/hpet.c
> +++ b/hw/timer/hpet.c
> @@ -34,6 +34,7 @@
>  #include "hw/timer/hpet.h"
>  #include "hw/sysbus.h"
>  #include "hw/rtc/mc146818rtc.h"
> +#include "hw/rtc/mc146818rtc_regs.h"
>  #include "migration/vmstate.h"
>  #include "hw/timer/i8254.h"
>
> diff --git a/include/hw/rtc/mc146818rtc.h b/include/hw/rtc/mc146818rtc.h
> index 888e04f9ab..09e273a2a1 100644
> --- a/include/hw/rtc/mc146818rtc.h
> +++ b/include/hw/rtc/mc146818rtc.h
> @@ -26,7 +26,6 @@
>  #define MC146818RTC_H
>
>  #include "hw/isa/isa.h"
> -#include "hw/rtc/mc146818rtc_regs.h"
>
>  #define TYPE_MC146818_RTC "mc146818rtc"
>
> --
> 2.20.1
>
>



Re: [Qemu-devel] [PATCH 10/13] hw: Move Exynos4210 RTC from hw/timer/ to hw/rtc/ subdirectory

2019-09-16 Thread Alistair Francis
On Mon, Sep 16, 2019 at 9:00 AM Philippe Mathieu-Daudé
 wrote:
>
> Move RTC devices under the hw/rtc/ subdirectory.
>
> Signed-off-by: Philippe Mathieu-Daudé 

Reviewed-by: Alistair Francis 

Alistair

> ---
>  hw/rtc/Makefile.objs   | 1 +
>  hw/{timer => rtc}/exynos4210_rtc.c | 0
>  hw/timer/Makefile.objs | 1 -
>  3 files changed, 1 insertion(+), 1 deletion(-)
>  rename hw/{timer => rtc}/exynos4210_rtc.c (100%)
>
> diff --git a/hw/rtc/Makefile.objs b/hw/rtc/Makefile.objs
> index 543a550a0f..3d4763fc26 100644
> --- a/hw/rtc/Makefile.objs
> +++ b/hw/rtc/Makefile.objs
> @@ -7,5 +7,6 @@ endif
>  common-obj-$(CONFIG_PL031) += pl031.o
>  common-obj-$(CONFIG_TWL92230) += twl92230.o
>  common-obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp-rtc.o
> +common-obj-$(CONFIG_EXYNOS4) += exynos4210_rtc.o
>  obj-$(CONFIG_MC146818RTC) += mc146818rtc.o
>  common-obj-$(CONFIG_SUN4V_RTC) += sun4v-rtc.o
> diff --git a/hw/timer/exynos4210_rtc.c b/hw/rtc/exynos4210_rtc.c
> similarity index 100%
> rename from hw/timer/exynos4210_rtc.c
> rename to hw/rtc/exynos4210_rtc.c
> diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs
> index 294465ef47..33191d74cb 100644
> --- a/hw/timer/Makefile.objs
> +++ b/hw/timer/Makefile.objs
> @@ -19,7 +19,6 @@ common-obj-$(CONFIG_NRF51_SOC) += nrf51_timer.o
>  common-obj-$(CONFIG_ALTERA_TIMER) += altera_timer.o
>  common-obj-$(CONFIG_EXYNOS4) += exynos4210_mct.o
>  common-obj-$(CONFIG_EXYNOS4) += exynos4210_pwm.o
> -common-obj-$(CONFIG_EXYNOS4) += exynos4210_rtc.o
>  common-obj-$(CONFIG_OMAP) += omap_gptimer.o
>  common-obj-$(CONFIG_OMAP) += omap_synctimer.o
>  common-obj-$(CONFIG_PXA2XX) += pxa2xx_timer.o
> --
> 2.20.1
>
>



Re: [Qemu-devel] [PATCH 09/13] hw: Move Xilinx ZynqMP RTC from hw/timer/ to hw/rtc/ subdirectory

2019-09-16 Thread Alistair Francis
On Mon, Sep 16, 2019 at 8:56 AM Philippe Mathieu-Daudé
 wrote:
>
> Move RTC devices under the hw/rtc/ subdirectory.
>
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  hw/rtc/Makefile.objs| 1 +
>  hw/rtc/trace-events | 3 +++
>  hw/{timer => rtc}/xlnx-zynqmp-rtc.c | 2 +-
>  hw/timer/Makefile.objs  | 1 -
>  hw/timer/trace-events   | 3 ---
>  include/hw/arm/xlnx-zynqmp.h| 2 +-
>  include/hw/{timer => rtc}/xlnx-zynqmp-rtc.h | 6 +++---
>  7 files changed, 9 insertions(+), 9 deletions(-)
>  rename hw/{timer => rtc}/xlnx-zynqmp-rtc.c (99%)
>  rename include/hw/{timer => rtc}/xlnx-zynqmp-rtc.h (95%)
>
> diff --git a/hw/rtc/Makefile.objs b/hw/rtc/Makefile.objs
> index b195863291..543a550a0f 100644
> --- a/hw/rtc/Makefile.objs
> +++ b/hw/rtc/Makefile.objs
> @@ -6,5 +6,6 @@ common-obj-$(CONFIG_M48T59) += m48t59-isa.o
>  endif
>  common-obj-$(CONFIG_PL031) += pl031.o
>  common-obj-$(CONFIG_TWL92230) += twl92230.o
> +common-obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp-rtc.o
>  obj-$(CONFIG_MC146818RTC) += mc146818rtc.o
>  common-obj-$(CONFIG_SUN4V_RTC) += sun4v-rtc.o
> diff --git a/hw/rtc/trace-events b/hw/rtc/trace-events
> index ac9e0e0fba..7f1945ad4c 100644
> --- a/hw/rtc/trace-events
> +++ b/hw/rtc/trace-events
> @@ -4,6 +4,9 @@
>  sun4v_rtc_read(uint64_t addr, uint64_t value) "read: addr 0x%" PRIx64 " 
> value 0x%" PRIx64
>  sun4v_rtc_write(uint64_t addr, uint64_t value) "write: addr 0x%" PRIx64 " 
> value 0x%" PRIx64
>
> +# xlnx-zynqmp-rtc.c
> +xlnx_zynqmp_rtc_gettime(int year, int month, int day, int hour, int min, int 
> sec) "Get time from host: %d-%d-%d %2d:%02d:%02d"
> +
>  # pl031.c
>  pl031_irq_state(int level) "irq state %d"
>  pl031_read(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x"
> diff --git a/hw/timer/xlnx-zynqmp-rtc.c b/hw/rtc/xlnx-zynqmp-rtc.c
> similarity index 99%
> rename from hw/timer/xlnx-zynqmp-rtc.c
> rename to hw/rtc/xlnx-zynqmp-rtc.c
> index 5692db98c2..f9f09b7296 100644
> --- a/hw/timer/xlnx-zynqmp-rtc.c
> +++ b/hw/rtc/xlnx-zynqmp-rtc.c
> @@ -36,7 +36,7 @@
>  #include "qemu/cutils.h"
>  #include "sysemu/sysemu.h"
>  #include "trace.h"
> -#include "hw/timer/xlnx-zynqmp-rtc.h"
> +#include "hw/rtc/xlnx-zynqmp-rtc.h"
>  #include "migration/vmstate.h"
>
>  #ifndef XLNX_ZYNQMP_RTC_ERR_DEBUG
> diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs
> index 70b61b69c7..294465ef47 100644
> --- a/hw/timer/Makefile.objs
> +++ b/hw/timer/Makefile.objs
> @@ -14,7 +14,6 @@ common-obj-$(CONFIG_IMX) += imx_epit.o
>  common-obj-$(CONFIG_IMX) += imx_gpt.o
>  common-obj-$(CONFIG_LM32) += lm32_timer.o
>  common-obj-$(CONFIG_MILKYMIST) += milkymist-sysctl.o
> -common-obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp-rtc.o
>  common-obj-$(CONFIG_NRF51_SOC) += nrf51_timer.o
>
>  common-obj-$(CONFIG_ALTERA_TIMER) += altera_timer.o
> diff --git a/hw/timer/trace-events b/hw/timer/trace-events
> index ce34b967db..1459d07237 100644
> --- a/hw/timer/trace-events
> +++ b/hw/timer/trace-events
> @@ -70,9 +70,6 @@ cmsdk_apb_dualtimer_reset(void) "CMSDK APB dualtimer: reset"
>  aspeed_rtc_read(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 
> 0x%08" PRIx64
>  aspeed_rtc_write(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 
> 0x%08" PRIx64
>
> -# xlnx-zynqmp-rtc.c
> -xlnx_zynqmp_rtc_gettime(int year, int month, int day, int hour, int min, int 
> sec) "Get time from host: %d-%d-%d %2d:%02d:%02d"
> -
>  # nrf51_timer.c
>  nrf51_timer_read(uint64_t addr, uint32_t value, unsigned size) "read addr 
> 0x%" PRIx64 " data 0x%" PRIx32 " size %u"
>  nrf51_timer_write(uint64_t addr, uint32_t value, unsigned size) "write addr 
> 0x%" PRIx64 " data 0x%" PRIx32 " size %u"
> diff --git a/include/hw/arm/xlnx-zynqmp.h b/include/hw/arm/xlnx-zynqmp.h
> index d7483c3b42..53076fa29a 100644
> --- a/include/hw/arm/xlnx-zynqmp.h
> +++ b/include/hw/arm/xlnx-zynqmp.h
> @@ -29,7 +29,7 @@
>  #include "hw/dma/xlnx-zdma.h"
>  #include "hw/display/xlnx_dp.h"
>  #include "hw/intc/xlnx-zynqmp-ipi.h"
> -#include "hw/timer/xlnx-zynqmp-rtc.h"
> +#include "hw/rtc/xlnx-zynqmp-rtc.h"
>  #include "hw/cpu/cluster.h"
>  #include "target/arm/cpu.h"
>
> diff --git a/include/hw/timer/xlnx-zynqmp-rtc.h 
> b/include/hw/rtc/xlnx-zynqmp-rtc.h
> similarity index 95%
> rename from include/hw/timer/xlnx-zynqmp-rtc.h
> rename to include/hw/rtc/xlnx-zynqmp-rtc.h
> index 97e32322ed..6fa1cb2f43 100644
> --- a/include/hw/timer/xlnx-zynqmp-rtc.h
> +++ b/include/hw/rtc/xlnx-zynqmp-rtc.h
> @@ -3,7 +3,7 @@
>   *
>   * Copyright (c) 2017 Xilinx Inc.
>   *
> - * Written-by: Alistair Francis 
> + * Written-by: Alistair Francis

Why remove the email address?

Otherwise:

Reviewed-by: Alistair Francis 

Alistair

>   *
>   * Permission is hereby granted, free of charge, to any person obtaining a 
> copy
>   * of this software and associated documentation files (the "Software"), to 
> deal
> @@ -24,8 +24,8 @@
>   * THE SOFTWARE.
>   */
>
> -#ifndef 

Re: [Qemu-devel] [PATCH 08/13] hw: Move DS1338 device from hw/timer/ to hw/rtc/ subdirectory

2019-09-16 Thread Alistair Francis
On Mon, Sep 16, 2019 at 9:39 AM Philippe Mathieu-Daudé
 wrote:
>
> The DS1338 is a Real Time Clock, not a timer.
> Move it under the hw/rtc/ subdirectory.
>
> Signed-off-by: Philippe Mathieu-Daudé 

Reviewed-by: Alistair Francis 

Alistair

> ---
>  hw/rtc/Kconfig | 4 
>  hw/rtc/Makefile.objs   | 1 +
>  hw/{timer => rtc}/ds1338.c | 0
>  hw/timer/Kconfig   | 4 
>  hw/timer/Makefile.objs | 1 -
>  5 files changed, 5 insertions(+), 5 deletions(-)
>  rename hw/{timer => rtc}/ds1338.c (100%)
>
> diff --git a/hw/rtc/Kconfig b/hw/rtc/Kconfig
> index dff9d60946..45daa8d655 100644
> --- a/hw/rtc/Kconfig
> +++ b/hw/rtc/Kconfig
> @@ -1,3 +1,7 @@
> +config DS1338
> +bool
> +depends on I2C
> +
>  config M41T80
>  bool
>  depends on I2C
> diff --git a/hw/rtc/Makefile.objs b/hw/rtc/Makefile.objs
> index 810a38ee7b..b195863291 100644
> --- a/hw/rtc/Makefile.objs
> +++ b/hw/rtc/Makefile.objs
> @@ -1,3 +1,4 @@
> +common-obj-$(CONFIG_DS1338) += ds1338.o
>  common-obj-$(CONFIG_M41T80) += m41t80.o
>  common-obj-$(CONFIG_M48T59) += m48t59.o
>  ifeq ($(CONFIG_ISA_BUS),y)
> diff --git a/hw/timer/ds1338.c b/hw/rtc/ds1338.c
> similarity index 100%
> rename from hw/timer/ds1338.c
> rename to hw/rtc/ds1338.c
> diff --git a/hw/timer/Kconfig b/hw/timer/Kconfig
> index 9357875f28..a990f9fe35 100644
> --- a/hw/timer/Kconfig
> +++ b/hw/timer/Kconfig
> @@ -9,10 +9,6 @@ config ARM_MPTIMER
>  config A9_GTIMER
>  bool
>
> -config DS1338
> -bool
> -depends on I2C
> -
>  config HPET
>  bool
>  default y if PC
> diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs
> index 23be70b71d..70b61b69c7 100644
> --- a/hw/timer/Makefile.objs
> +++ b/hw/timer/Makefile.objs
> @@ -3,7 +3,6 @@ common-obj-$(CONFIG_ARM_MPTIMER) += arm_mptimer.o
>  common-obj-$(CONFIG_ARM_V7M) += armv7m_systick.o
>  common-obj-$(CONFIG_A9_GTIMER) += a9gtimer.o
>  common-obj-$(CONFIG_CADENCE) += cadence_ttc.o
> -common-obj-$(CONFIG_DS1338) += ds1338.o
>  common-obj-$(CONFIG_HPET) += hpet.o
>  common-obj-$(CONFIG_I8254) += i8254_common.o i8254.o
>  common-obj-$(CONFIG_PUV3) += puv3_ost.o
> --
> 2.20.1
>
>



Re: [Qemu-devel] [PATCH 07/13] hw: Move TWL92230 device from hw/timer/ to hw/rtc/ subdirectory

2019-09-16 Thread Alistair Francis
On Mon, Sep 16, 2019 at 9:37 AM Philippe Mathieu-Daudé
 wrote:
>
> The TWL92230 is an "energy management device" companion with
> a RTC. Since we mostly model the RTC, move it under the hw/rtc/
> subdirectory.
>
> Signed-off-by: Philippe Mathieu-Daudé 

Reviewed-by: Alistair Francis 

Alistair

> ---
>  MAINTAINERS  | 2 +-
>  hw/rtc/Kconfig   | 4 
>  hw/rtc/Makefile.objs | 1 +
>  hw/{timer => rtc}/twl92230.c | 0
>  hw/timer/Kconfig | 4 
>  hw/timer/Makefile.objs   | 1 -
>  6 files changed, 6 insertions(+), 6 deletions(-)
>  rename hw/{timer => rtc}/twl92230.c (100%)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index fb9a1ed075..d17058264b 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -663,7 +663,7 @@ F: hw/display/blizzard.c
>  F: hw/input/lm832x.c
>  F: hw/input/tsc2005.c
>  F: hw/misc/cbus.c
> -F: hw/timer/twl92230.c
> +F: hw/rtc/twl92230.c
>  F: include/hw/display/blizzard.h
>  F: include/hw/input/tsc2xxx.h
>  F: include/hw/misc/cbus.h
> diff --git a/hw/rtc/Kconfig b/hw/rtc/Kconfig
> index cc7fead764..dff9d60946 100644
> --- a/hw/rtc/Kconfig
> +++ b/hw/rtc/Kconfig
> @@ -8,6 +8,10 @@ config M48T59
>  config PL031
>  bool
>
> +config TWL92230
> +bool
> +depends on I2C
> +
>  config MC146818RTC
>  bool
>
> diff --git a/hw/rtc/Makefile.objs b/hw/rtc/Makefile.objs
> index 4621b37bc2..810a38ee7b 100644
> --- a/hw/rtc/Makefile.objs
> +++ b/hw/rtc/Makefile.objs
> @@ -4,5 +4,6 @@ ifeq ($(CONFIG_ISA_BUS),y)
>  common-obj-$(CONFIG_M48T59) += m48t59-isa.o
>  endif
>  common-obj-$(CONFIG_PL031) += pl031.o
> +common-obj-$(CONFIG_TWL92230) += twl92230.o
>  obj-$(CONFIG_MC146818RTC) += mc146818rtc.o
>  common-obj-$(CONFIG_SUN4V_RTC) += sun4v-rtc.o
> diff --git a/hw/timer/twl92230.c b/hw/rtc/twl92230.c
> similarity index 100%
> rename from hw/timer/twl92230.c
> rename to hw/rtc/twl92230.c
> diff --git a/hw/timer/Kconfig b/hw/timer/Kconfig
> index b04c928136..9357875f28 100644
> --- a/hw/timer/Kconfig
> +++ b/hw/timer/Kconfig
> @@ -20,10 +20,6 @@ config HPET
>  config I8254
>  bool
>
> -config TWL92230
> -bool
> -depends on I2C
> -
>  config ALTERA_TIMER
>  bool
>  select PTIMER
> diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs
> index 034bd30255..23be70b71d 100644
> --- a/hw/timer/Makefile.objs
> +++ b/hw/timer/Makefile.objs
> @@ -7,7 +7,6 @@ common-obj-$(CONFIG_DS1338) += ds1338.o
>  common-obj-$(CONFIG_HPET) += hpet.o
>  common-obj-$(CONFIG_I8254) += i8254_common.o i8254.o
>  common-obj-$(CONFIG_PUV3) += puv3_ost.o
> -common-obj-$(CONFIG_TWL92230) += twl92230.o
>  common-obj-$(CONFIG_XILINX) += xilinx_timer.o
>  common-obj-$(CONFIG_SLAVIO) += slavio_timer.o
>  common-obj-$(CONFIG_ETRAXFS) += etraxfs_timer.o
> --
> 2.20.1
>
>



Re: [Qemu-devel] [PATCH v1] gdbstub: riscv: fix the fflags registers

2019-09-16 Thread Alistair Francis
On Tue, Sep 10, 2019 at 1:16 AM KONRAD Frederic
 wrote:
>
> While debugging an application with GDB the following might happen:
>
> (gdb) return
> Make xxx return now? (y or n) y
> Could not fetch register "fflags"; remote failure reply 'E14'
>
> This is because riscv_gdb_get_fpu calls riscv_csrrw_debug with a wrong csr
> number (8). It should use the csr_register_map in order to reach the
> riscv_cpu_get_fflags callback.
>
> Signed-off-by: KONRAD Frederic 

Reviewed-by: Alistair Francis 

Alistair

> ---
>  target/riscv/gdbstub.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c
> index 27be932..ded140e 100644
> --- a/target/riscv/gdbstub.c
> +++ b/target/riscv/gdbstub.c
> @@ -313,7 +313,8 @@ static int riscv_gdb_get_fpu(CPURISCVState *env, uint8_t 
> *mem_buf, int n)
>   * register 33, so we recalculate the map index.
>   * This also works for CSR_FRM and CSR_FCSR.
>   */
> -result = riscv_csrrw_debug(env, n - 33 +  8, , 0, 0);
> +result = riscv_csrrw_debug(env, n - 33 + csr_register_map[8], ,
> +   0, 0);
>  if (result == 0) {
>  return gdb_get_regl(mem_buf, val);
>  }
> @@ -335,7 +336,8 @@ static int riscv_gdb_set_fpu(CPURISCVState *env, uint8_t 
> *mem_buf, int n)
>   * register 33, so we recalculate the map index.
>   * This also works for CSR_FRM and CSR_FCSR.
>   */
> -result = riscv_csrrw_debug(env, n - 33 + 8, NULL, val, -1);
> +result = riscv_csrrw_debug(env, n - 33 + csr_register_map[8], NULL,
> +   val, -1);
>  if (result == 0) {
>  return sizeof(target_ulong);
>  }
> --
> 1.8.3.1
>
>



Re: [Qemu-devel] [PATCH 06/13] hw: Move sun4v hypervisor RTC from hw/timer/ to hw/rtc/ subdirectory

2019-09-16 Thread Alistair Francis
On Mon, Sep 16, 2019 at 9:30 AM Philippe Mathieu-Daudé
 wrote:
>
> Move RTC devices under the hw/rtc/ subdirectory.
>
> Signed-off-by: Philippe Mathieu-Daudé 

Reviewed-by: Alistair Francis 

Alistair

> ---
>  MAINTAINERS   |  4 ++--
>  hw/rtc/Kconfig|  3 +++
>  hw/rtc/Makefile.objs  |  1 +
>  hw/{timer => rtc}/sun4v-rtc.c |  2 +-
>  hw/rtc/trace-events   |  4 
>  hw/sparc64/niagara.c  |  2 +-
>  hw/timer/Kconfig  |  3 ---
>  hw/timer/Makefile.objs|  1 -
>  hw/timer/trace-events |  4 
>  include/hw/rtc/sun4v-rtc.h| 19 +++
>  include/hw/timer/sun4v-rtc.h  |  1 -
>  11 files changed, 31 insertions(+), 13 deletions(-)
>  rename hw/{timer => rtc}/sun4v-rtc.c (98%)
>  create mode 100644 include/hw/rtc/sun4v-rtc.h
>  delete mode 100644 include/hw/timer/sun4v-rtc.h
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index fd68b2383a..fb9a1ed075 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1165,8 +1165,8 @@ Sun4v
>  M: Artyom Tarasenko 
>  S: Maintained
>  F: hw/sparc64/niagara.c
> -F: hw/timer/sun4v-rtc.c
> -F: include/hw/timer/sun4v-rtc.h
> +F: hw/rtc/sun4v-rtc.c
> +F: include/hw/rtc/sun4v-rtc.h
>
>  Leon3
>  M: Fabien Chouteau 
> diff --git a/hw/rtc/Kconfig b/hw/rtc/Kconfig
> index 434b20b2b1..cc7fead764 100644
> --- a/hw/rtc/Kconfig
> +++ b/hw/rtc/Kconfig
> @@ -10,3 +10,6 @@ config PL031
>
>  config MC146818RTC
>  bool
> +
> +config SUN4V_RTC
> +bool
> diff --git a/hw/rtc/Makefile.objs b/hw/rtc/Makefile.objs
> index 89e8e48c64..4621b37bc2 100644
> --- a/hw/rtc/Makefile.objs
> +++ b/hw/rtc/Makefile.objs
> @@ -5,3 +5,4 @@ common-obj-$(CONFIG_M48T59) += m48t59-isa.o
>  endif
>  common-obj-$(CONFIG_PL031) += pl031.o
>  obj-$(CONFIG_MC146818RTC) += mc146818rtc.o
> +common-obj-$(CONFIG_SUN4V_RTC) += sun4v-rtc.o
> diff --git a/hw/timer/sun4v-rtc.c b/hw/rtc/sun4v-rtc.c
> similarity index 98%
> rename from hw/timer/sun4v-rtc.c
> rename to hw/rtc/sun4v-rtc.c
> index 54272a822f..ada01b5774 100644
> --- a/hw/timer/sun4v-rtc.c
> +++ b/hw/rtc/sun4v-rtc.c
> @@ -13,7 +13,7 @@
>  #include "hw/sysbus.h"
>  #include "qemu/module.h"
>  #include "qemu/timer.h"
> -#include "hw/timer/sun4v-rtc.h"
> +#include "hw/rtc/sun4v-rtc.h"
>  #include "trace.h"
>
>
> diff --git a/hw/rtc/trace-events b/hw/rtc/trace-events
> index 54c94ac557..ac9e0e0fba 100644
> --- a/hw/rtc/trace-events
> +++ b/hw/rtc/trace-events
> @@ -1,5 +1,9 @@
>  # See docs/devel/tracing.txt for syntax documentation.
>
> +# sun4v-rtc.c
> +sun4v_rtc_read(uint64_t addr, uint64_t value) "read: addr 0x%" PRIx64 " 
> value 0x%" PRIx64
> +sun4v_rtc_write(uint64_t addr, uint64_t value) "write: addr 0x%" PRIx64 " 
> value 0x%" PRIx64
> +
>  # pl031.c
>  pl031_irq_state(int level) "irq state %d"
>  pl031_read(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x"
> diff --git a/hw/sparc64/niagara.c b/hw/sparc64/niagara.c
> index 167143bffe..dfa0817eae 100644
> --- a/hw/sparc64/niagara.c
> +++ b/hw/sparc64/niagara.c
> @@ -30,7 +30,7 @@
>  #include "hw/misc/unimp.h"
>  #include "hw/loader.h"
>  #include "hw/sparc/sparc64.h"
> -#include "hw/timer/sun4v-rtc.h"
> +#include "hw/rtc/sun4v-rtc.h"
>  #include "exec/address-spaces.h"
>  #include "sysemu/block-backend.h"
>  #include "qemu/error-report.h"
> diff --git a/hw/timer/Kconfig b/hw/timer/Kconfig
> index a6b668b255..b04c928136 100644
> --- a/hw/timer/Kconfig
> +++ b/hw/timer/Kconfig
> @@ -35,9 +35,6 @@ config ALLWINNER_A10_PIT
>  config STM32F2XX_TIMER
>  bool
>
> -config SUN4V_RTC
> -bool
> -
>  config CMSDK_APB_TIMER
>  bool
>  select PTIMER
> diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs
> index 2fb12162a6..034bd30255 100644
> --- a/hw/timer/Makefile.objs
> +++ b/hw/timer/Makefile.objs
> @@ -35,7 +35,6 @@ common-obj-$(CONFIG_ALLWINNER_A10_PIT) += 
> allwinner-a10-pit.o
>  common-obj-$(CONFIG_STM32F2XX_TIMER) += stm32f2xx_timer.o
>  common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o aspeed_rtc.o
>
> -common-obj-$(CONFIG_SUN4V_RTC) += sun4v-rtc.o
>  common-obj-$(CONFIG_CMSDK_APB_TIMER) += cmsdk-apb-timer.o
>  common-obj-$(CONFIG_CMSDK_APB_DUALTIMER) += cmsdk-apb-dualtimer.o
>  common-obj-$(CONFIG_MSF2) += mss-timer.o
> diff --git a/hw/timer/trace-events b/hw/timer/trace-events
> index 6936fe8573..ce34b967db 100644
> --- a/hw/timer/trace-events
> +++ b/hw/timer/trace-events
> @@ -70,10 +70,6 @@ cmsdk_apb_dualtimer_reset(void) "CMSDK APB dualtimer: 
> reset"
>  aspeed_rtc_read(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 
> 0x%08" PRIx64
>  aspeed_rtc_write(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 
> 0x%08" PRIx64
>
> -# sun4v-rtc.c
> -sun4v_rtc_read(uint64_t addr, uint64_t value) "read: addr 0x%" PRIx64 " 
> value 0x%" PRIx64
> -sun4v_rtc_write(uint64_t addr, uint64_t value) "write: addr 0x%" PRIx64 " 
> value 0x%" PRIx64
> -
>  # xlnx-zynqmp-rtc.c
>  xlnx_zynqmp_rtc_gettime(int year, int month, int day, int hour, int min, int 
> sec) "Get time from 

Re: [Qemu-devel] [PATCH 05/13] hw: Move M41T80 device from hw/timer/ to hw/rtc/ subdirectory

2019-09-16 Thread Alistair Francis
On Mon, Sep 16, 2019 at 9:35 AM Philippe Mathieu-Daudé
 wrote:
>
> The M41T80 is a Real Time Clock, not a timer.
> Move it under the hw/rtc/ subdirectory.
>
> Signed-off-by: Philippe Mathieu-Daudé 

Reviewed-by: Alistair Francis 

Alistair

> ---
>  MAINTAINERS| 2 +-
>  hw/rtc/Kconfig | 4 
>  hw/rtc/Makefile.objs   | 1 +
>  hw/{timer => rtc}/m41t80.c | 0
>  hw/timer/Kconfig   | 4 
>  hw/timer/Makefile.objs | 1 -
>  6 files changed, 6 insertions(+), 6 deletions(-)
>  rename hw/{timer => rtc}/m41t80.c (100%)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 679b026fe0..fd68b2383a 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1113,7 +1113,7 @@ F: hw/ppc/sam460ex.c
>  F: hw/ppc/ppc440_pcix.c
>  F: hw/display/sm501*
>  F: hw/ide/sii3112.c
> -F: hw/timer/m41t80.c
> +F: hw/rtc/m41t80.c
>  F: pc-bios/canyonlands.dt[sb]
>  F: pc-bios/u-boot-sam460ex-20100605.bin
>  F: roms/u-boot-sam460ex
> diff --git a/hw/rtc/Kconfig b/hw/rtc/Kconfig
> index 159c233517..434b20b2b1 100644
> --- a/hw/rtc/Kconfig
> +++ b/hw/rtc/Kconfig
> @@ -1,3 +1,7 @@
> +config M41T80
> +bool
> +depends on I2C
> +
>  config M48T59
>  bool
>
> diff --git a/hw/rtc/Makefile.objs b/hw/rtc/Makefile.objs
> index c87f81405e..89e8e48c64 100644
> --- a/hw/rtc/Makefile.objs
> +++ b/hw/rtc/Makefile.objs
> @@ -1,3 +1,4 @@
> +common-obj-$(CONFIG_M41T80) += m41t80.o
>  common-obj-$(CONFIG_M48T59) += m48t59.o
>  ifeq ($(CONFIG_ISA_BUS),y)
>  common-obj-$(CONFIG_M48T59) += m48t59-isa.o
> diff --git a/hw/timer/m41t80.c b/hw/rtc/m41t80.c
> similarity index 100%
> rename from hw/timer/m41t80.c
> rename to hw/rtc/m41t80.c
> diff --git a/hw/timer/Kconfig b/hw/timer/Kconfig
> index a57e9b59fc..a6b668b255 100644
> --- a/hw/timer/Kconfig
> +++ b/hw/timer/Kconfig
> @@ -20,10 +20,6 @@ config HPET
>  config I8254
>  bool
>
> -config M41T80
> -bool
> -depends on I2C
> -
>  config TWL92230
>  bool
>  depends on I2C
> diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs
> index fe2d1fbc40..2fb12162a6 100644
> --- a/hw/timer/Makefile.objs
> +++ b/hw/timer/Makefile.objs
> @@ -6,7 +6,6 @@ common-obj-$(CONFIG_CADENCE) += cadence_ttc.o
>  common-obj-$(CONFIG_DS1338) += ds1338.o
>  common-obj-$(CONFIG_HPET) += hpet.o
>  common-obj-$(CONFIG_I8254) += i8254_common.o i8254.o
> -common-obj-$(CONFIG_M41T80) += m41t80.o
>  common-obj-$(CONFIG_PUV3) += puv3_ost.o
>  common-obj-$(CONFIG_TWL92230) += twl92230.o
>  common-obj-$(CONFIG_XILINX) += xilinx_timer.o
> --
> 2.20.1
>
>



Re: [Qemu-devel] [PATCH 04/13] hw: Move M48T59 device from hw/timer/ to hw/rtc/ subdirectory

2019-09-16 Thread Alistair Francis
On Mon, Sep 16, 2019 at 9:26 AM Philippe Mathieu-Daudé
 wrote:
>
> The M48T59 is a Real Time Clock, not a timer.
> Move it under the hw/rtc/ subdirectory.
>
> Signed-off-by: Philippe Mathieu-Daudé 

Reviewed-by: Alistair Francis 

Alistair

> ---
>  MAINTAINERS |  4 +-
>  hw/ppc/ppc405_boards.c  |  2 +-
>  hw/ppc/prep.c   |  2 +-
>  hw/rtc/Kconfig  |  3 ++
>  hw/rtc/Makefile.objs|  4 ++
>  hw/{timer => rtc}/m48t59-internal.h |  0
>  hw/{timer => rtc}/m48t59-isa.c  |  4 +-
>  hw/{timer => rtc}/m48t59.c  |  2 +-
>  hw/sparc/sun4m.c|  2 +-
>  hw/sparc64/sun4u.c  |  2 +-
>  hw/timer/Kconfig|  3 --
>  hw/timer/Makefile.objs  |  4 --
>  include/hw/rtc/m48t59.h | 57 +
>  13 files changed, 73 insertions(+), 16 deletions(-)
>  rename hw/{timer => rtc}/m48t59-internal.h (100%)
>  rename hw/{timer => rtc}/m48t59-isa.c (98%)
>  rename hw/{timer => rtc}/m48t59.c (99%)
>  create mode 100644 include/hw/rtc/m48t59.h
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 481f2318cb..679b026fe0 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1064,9 +1064,9 @@ F: hw/pci-host/prep.[hc]
>  F: hw/isa/i82378.c
>  F: hw/isa/pc87312.c
>  F: hw/dma/i82374.c
> -F: hw/timer/m48t59-isa.c
> +F: hw/rtc/m48t59-isa.c
>  F: include/hw/isa/pc87312.h
> -F: include/hw/timer/m48t59.h
> +F: include/hw/rtc/m48t59.h
>  F: pc-bios/ppc_rom.bin
>
>  sPAPR
> diff --git a/hw/ppc/ppc405_boards.c b/hw/ppc/ppc405_boards.c
> index 388cae0b43..1f721feed6 100644
> --- a/hw/ppc/ppc405_boards.c
> +++ b/hw/ppc/ppc405_boards.c
> @@ -29,7 +29,7 @@
>  #include "cpu.h"
>  #include "hw/ppc/ppc.h"
>  #include "ppc405.h"
> -#include "hw/timer/m48t59.h"
> +#include "hw/rtc/m48t59.h"
>  #include "hw/block/flash.h"
>  #include "sysemu/sysemu.h"
>  #include "sysemu/qtest.h"
> diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
> index 3a51536e1a..862345c2ac 100644
> --- a/hw/ppc/prep.c
> +++ b/hw/ppc/prep.c
> @@ -25,7 +25,7 @@
>
>  #include "qemu/osdep.h"
>  #include "cpu.h"
> -#include "hw/timer/m48t59.h"
> +#include "hw/rtc/m48t59.h"
>  #include "hw/char/serial.h"
>  #include "hw/block/fdc.h"
>  #include "net/net.h"
> diff --git a/hw/rtc/Kconfig b/hw/rtc/Kconfig
> index 7ffd702268..159c233517 100644
> --- a/hw/rtc/Kconfig
> +++ b/hw/rtc/Kconfig
> @@ -1,3 +1,6 @@
> +config M48T59
> +bool
> +
>  config PL031
>  bool
>
> diff --git a/hw/rtc/Makefile.objs b/hw/rtc/Makefile.objs
> index 3cac0d5a63..c87f81405e 100644
> --- a/hw/rtc/Makefile.objs
> +++ b/hw/rtc/Makefile.objs
> @@ -1,2 +1,6 @@
> +common-obj-$(CONFIG_M48T59) += m48t59.o
> +ifeq ($(CONFIG_ISA_BUS),y)
> +common-obj-$(CONFIG_M48T59) += m48t59-isa.o
> +endif
>  common-obj-$(CONFIG_PL031) += pl031.o
>  obj-$(CONFIG_MC146818RTC) += mc146818rtc.o
> diff --git a/hw/timer/m48t59-internal.h b/hw/rtc/m48t59-internal.h
> similarity index 100%
> rename from hw/timer/m48t59-internal.h
> rename to hw/rtc/m48t59-internal.h
> diff --git a/hw/timer/m48t59-isa.c b/hw/rtc/m48t59-isa.c
> similarity index 98%
> rename from hw/timer/m48t59-isa.c
> rename to hw/rtc/m48t59-isa.c
> index 5e5432abfd..7fde854c0f 100644
> --- a/hw/timer/m48t59-isa.c
> +++ b/hw/rtc/m48t59-isa.c
> @@ -1,5 +1,5 @@
>  /*
> - * QEMU M48T59 and M48T08 NVRAM emulation (ISA bus interface
> + * QEMU M48T59 and M48T08 NVRAM emulation (ISA bus interface)
>   *
>   * Copyright (c) 2003-2005, 2007 Jocelyn Mayer
>   * Copyright (c) 2013 Hervé Poussineau
> @@ -26,7 +26,7 @@
>  #include "qemu/osdep.h"
>  #include "hw/isa/isa.h"
>  #include "hw/qdev-properties.h"
> -#include "hw/timer/m48t59.h"
> +#include "hw/rtc/m48t59.h"
>  #include "m48t59-internal.h"
>  #include "qemu/module.h"
>
> diff --git a/hw/timer/m48t59.c b/hw/rtc/m48t59.c
> similarity index 99%
> rename from hw/timer/m48t59.c
> rename to hw/rtc/m48t59.c
> index a9fc2f981a..fc592b9fb1 100644
> --- a/hw/timer/m48t59.c
> +++ b/hw/rtc/m48t59.c
> @@ -27,7 +27,7 @@
>  #include "qemu-common.h"
>  #include "hw/irq.h"
>  #include "hw/qdev-properties.h"
> -#include "hw/timer/m48t59.h"
> +#include "hw/rtc/m48t59.h"
>  #include "qemu/timer.h"
>  #include "sysemu/runstate.h"
>  #include "sysemu/sysemu.h"
> diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
> index 6c5a17a020..2aaa5bf1ae 100644
> --- a/hw/sparc/sun4m.c
> +++ b/hw/sparc/sun4m.c
> @@ -31,7 +31,7 @@
>  #include "qemu/error-report.h"
>  #include "qemu/timer.h"
>  #include "hw/sparc/sun4m_iommu.h"
> -#include "hw/timer/m48t59.h"
> +#include "hw/rtc/m48t59.h"
>  #include "migration/vmstate.h"
>  #include "hw/sparc/sparc32_dma.h"
>  #include "hw/block/fdc.h"
> diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
> index 1ded2a4c9a..955082773b 100644
> --- a/hw/sparc64/sun4u.c
> +++ b/hw/sparc64/sun4u.c
> @@ -36,7 +36,7 @@
>  #include "hw/pci-host/sabre.h"
>  #include "hw/char/serial.h"
>  #include "hw/char/parallel.h"
> -#include "hw/timer/m48t59.h"
> 

Re: [Qemu-devel] [PATCH 03/13] hw: Move MC146818 device from hw/timer/ to hw/rtc/ subdirectory

2019-09-16 Thread Alistair Francis
On Mon, Sep 16, 2019 at 9:31 AM Philippe Mathieu-Daudé
 wrote:
>
> The MC146818 is a Real Time Clock, not a timer.
> Move it under the hw/rtc/ subdirectory.
>
> Signed-off-by: Philippe Mathieu-Daudé 

Reviewed-by: Alistair Francis 

Alistair

> ---
>  MAINTAINERS  |  4 +--
>  hw/alpha/dp264.c |  2 +-
>  hw/hppa/machine.c|  2 +-
>  hw/i386/acpi-build.c |  2 +-
>  hw/i386/pc.c |  2 +-
>  hw/i386/pc_q35.c |  2 +-
>  hw/mips/mips_fulong2e.c  |  2 +-
>  hw/mips/mips_jazz.c  |  2 +-
>  hw/mips/mips_malta.c |  2 +-
>  hw/mips/mips_r4k.c   |  2 +-
>  hw/ppc/pnv.c |  2 +-
>  hw/ppc/prep.c|  2 +-
>  hw/rtc/Kconfig   |  3 ++
>  hw/rtc/Makefile.objs |  1 +
>  hw/{timer => rtc}/mc146818rtc.c  |  2 +-
>  hw/timer/Kconfig |  3 --
>  hw/timer/Makefile.objs   |  2 --
>  hw/timer/hpet.c  |  2 +-
>  include/hw/rtc/mc146818rtc.h | 38 
>  include/hw/{timer => rtc}/mc146818rtc_regs.h |  1 +
>  include/hw/timer/mc146818rtc.h   | 14 
>  tests/rtc-test.c |  2 +-
>  22 files changed, 59 insertions(+), 35 deletions(-)
>  rename hw/{timer => rtc}/mc146818rtc.c (99%)
>  create mode 100644 include/hw/rtc/mc146818rtc.h
>  rename include/hw/{timer => rtc}/mc146818rtc_regs.h (98%)
>  delete mode 100644 include/hw/timer/mc146818rtc.h
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 5562d2c6d0..481f2318cb 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1263,7 +1263,7 @@ F: hw/misc/debugexit.c
>  F: hw/misc/pc-testdev.c
>  F: hw/timer/hpet*
>  F: hw/timer/i8254*
> -F: hw/timer/mc146818rtc*
> +F: hw/rtc/mc146818rtc*
>  F: hw/watchdog/wdt_ib700.c
>  F: hw/watchdog/wdt_i6300esb.c
>  F: include/hw/display/vga.h
> @@ -1275,7 +1275,7 @@ F: include/hw/isa/i8259_internal.h
>  F: include/hw/isa/superio.h
>  F: include/hw/timer/hpet.h
>  F: include/hw/timer/i8254*
> -F: include/hw/timer/mc146818rtc*
> +F: include/hw/rtc/mc146818rtc*
>
>  Machine core
>  M: Eduardo Habkost 
> diff --git a/hw/alpha/dp264.c b/hw/alpha/dp264.c
> index 51feee8558..51b3cf7a61 100644
> --- a/hw/alpha/dp264.c
> +++ b/hw/alpha/dp264.c
> @@ -14,7 +14,7 @@
>  #include "alpha_sys.h"
>  #include "qemu/error-report.h"
>  #include "sysemu/sysemu.h"
> -#include "hw/timer/mc146818rtc.h"
> +#include "hw/rtc/mc146818rtc.h"
>  #include "hw/ide.h"
>  #include "hw/timer/i8254.h"
>  #include "hw/isa/superio.h"
> diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
> index 2736ce835e..6598e2469d 100644
> --- a/hw/hppa/machine.c
> +++ b/hw/hppa/machine.c
> @@ -12,7 +12,7 @@
>  #include "qemu/error-report.h"
>  #include "sysemu/reset.h"
>  #include "sysemu/sysemu.h"
> -#include "hw/timer/mc146818rtc.h"
> +#include "hw/rtc/mc146818rtc.h"
>  #include "hw/ide.h"
>  #include "hw/timer/i8254.h"
>  #include "hw/char/serial.h"
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index e54e571a75..44a8073507 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -45,7 +45,7 @@
>  #include "hw/acpi/vmgenid.h"
>  #include "hw/boards.h"
>  #include "sysemu/tpm_backend.h"
> -#include "hw/timer/mc146818rtc_regs.h"
> +#include "hw/rtc/mc146818rtc_regs.h"
>  #include "migration/vmstate.h"
>  #include "hw/mem/memory-device.h"
>  #include "sysemu/numa.h"
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index bad866fe44..beef7a992d 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -42,7 +42,7 @@
>  #include "elf.h"
>  #include "migration/vmstate.h"
>  #include "multiboot.h"
> -#include "hw/timer/mc146818rtc.h"
> +#include "hw/rtc/mc146818rtc.h"
>  #include "hw/dma/i8257.h"
>  #include "hw/timer/i8254.h"
>  #include "hw/input/i8042.h"
> diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
> index d4e8a1cb9f..a976af9a2a 100644
> --- a/hw/i386/pc_q35.c
> +++ b/hw/i386/pc_q35.c
> @@ -33,7 +33,7 @@
>  #include "hw/loader.h"
>  #include "sysemu/arch_init.h"
>  #include "hw/i2c/smbus_eeprom.h"
> -#include "hw/timer/mc146818rtc.h"
> +#include "hw/rtc/mc146818rtc.h"
>  #include "hw/xen/xen.h"
>  #include "sysemu/kvm.h"
>  #include "kvm_i386.h"
> diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c
> index cf537dd7e6..03a27e1767 100644
> --- a/hw/mips/mips_fulong2e.c
> +++ b/hw/mips/mips_fulong2e.c
> @@ -39,7 +39,7 @@
>  #include "hw/ide.h"
>  #include "elf.h"
>  #include "hw/isa/vt82c686.h"
> -#include "hw/timer/mc146818rtc.h"
> +#include "hw/rtc/mc146818rtc.h"
>  #include "hw/timer/i8254.h"
>  #include "exec/address-spaces.h"
>  #include "sysemu/qtest.h"
> diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c
> index c967b97d80..2811a4bd90 

[Qemu-devel] ELF load command alignment not page-aligned

2019-09-16 Thread Niccolò Belli

Hi,
I'm trying to use qemu-user-static to chroot into a foreign amd64 
environment from my ppc64le host.

The host has a 64k page size, while x86_64 uses 4k.
I get those errors while loading shared libraries: "ELF load command 
alignment not page-aligned"
Is there any way to fix this? I cannot simply switch to 4k page size 
because my btrfs filesystem won't mount anymore (it requires the 
sectorsize to be equal to the page size).


Bests,
Niccolo'



Re: [Qemu-devel] [PATCH] nbd/server: attach client channel to the export's AioContext

2019-09-16 Thread Eric Blake
On 9/12/19 1:37 AM, Sergio Lopez wrote:

>> I tried to test this patch, but even with it applied, I still got an
>> aio-context crasher by attempting an nbd-server-start, nbd-server-add,
>> nbd-server-stop (intentionally skipping the nbd-server-remove step) on a
>> domain using iothreads, with a backtrace of:
>>
>> #0  0x7ff09d070e35 in raise () from target:/lib64/libc.so.6
>> #1  0x7ff09d05b895 in abort () from target:/lib64/libc.so.6
>> #2  0x55dd03b9ab86 in error_exit (err=1, msg=0x55dd03d59fb0
>> <__func__.15769> "qemu_mutex_unlock_impl")
>> at util/qemu-thread-posix.c:36
>> #3  0x55dd03b9adcf in qemu_mutex_unlock_impl (mutex=0x55dd062d5090,
>> file=0x55dd03d59041 "util/async.c",
>> line=523) at util/qemu-thread-posix.c:96
>> #4  0x55dd03b93433 in aio_context_release (ctx=0x55dd062d5030) at
>> util/async.c:523

>> #14 0x55dd03748845 in qmp_nbd_server_stop (errp=0x7ffcdf3cb4e8) at
>> blockdev-nbd.c:233
>> ...

Sorry for truncating the initial stackdump report. The rest of the trace
(it is definitely in the main loop):

#15 0x560be491c910 in qmp_marshal_nbd_server_stop
(args=0x560be54c4d00, ret=0x7ffdd832de38,
errp=0x7ffdd832de30) at qapi/qapi-commands-block.c:318
#16 0x560be4a7a306 in do_qmp_dispatch (cmds=0x560be50dc1f0
, request=0x7fbcac009af0,
allow_oob=false, errp=0x7ffdd832ded8) at qapi/qmp-dispatch.c:131
#17 0x560be4a7a507 in qmp_dispatch (cmds=0x560be50dc1f0
, request=0x7fbcac009af0,
allow_oob=false) at qapi/qmp-dispatch.c:174
#18 0x560be48edd81 in monitor_qmp_dispatch (mon=0x560be55d6670,
req=0x7fbcac009af0) at monitor/qmp.c:120
#19 0x560be48ee116 in monitor_qmp_bh_dispatcher (data=0x0) at
monitor/qmp.c:209
#20 0x560be4ad16a2 in aio_bh_call (bh=0x560be53dbe90) at util/async.c:89
#21 0x560be4ad173a in aio_bh_poll (ctx=0x560be53daba0) at
util/async.c:117
#22 0x560be4ad6514 in aio_dispatch (ctx=0x560be53daba0) at
util/aio-posix.c:459
#23 0x560be4ad1ad3 in aio_ctx_dispatch (source=0x560be53daba0,
callback=0x0, user_data=0x0) at util/async.c:260
#24 0x7fbcd7083ecd in g_main_context_dispatch () from
target:/lib64/libglib-2.0.so.0
#25 0x560be4ad4e47 in glib_pollfds_poll () at util/main-loop.c:218
#26 0x560be4ad4ec1 in os_host_main_loop_wait (timeout=10) at
util/main-loop.c:241
#27 0x560be4ad4fc6 in main_loop_wait (nonblocking=0) at
util/main-loop.c:517
--Type  for more, q to quit, c to continue without paging--
#28 0x560be4691266 in main_loop () at vl.c:1806
#29 0x560be46988a9 in main (argc=112, argv=0x7ffdd832e4e8,
envp=0x7ffdd832e870) at vl.c:4488


>>
>> Does that sound familiar to what you were seeing?  Does it mean we
>> missed another spot where the context is set incorrectly?
> 
> It looks like it was trying to release the AioContext while it was still
> held by some other thread. Is this stacktrace from the main thread or an
> iothread? What was the other one doing?

Kevin had some ideas on what it might be; I'm playing with obtaining the
context in the spots he pointed out.

> 
>> I'm happy to work with you on IRC for more real-time debugging of this
>> (I'm woefully behind on understanding how aio contexts are supposed to
>> work).
> 
> I must be missing some step, because I can't reproduce this one
> here. I've tried both with an idle NDB server and one with a client
> generating I/O. Is it reproducible 100% of them time?

Yes, with iothreads.  I took some time today to boil it down to
something that does not require libvirt:

$ file myfile
myfile: QEMU QCOW2 Image (v3), 104857600 bytes
$ qemu-img create -f qcow2 -o backing_file=myfile,backing_fmt=qcow2  \
 myfile.wrap
Formatting 'myfile.wrap', fmt=qcow2 size=104857600 backing_file=myfile
backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16
$ ./x86_64-softmmu/qemu-system-x86_64 -nodefaults \
  -name tmp,debug-threads=on -machine pc-q35-3.1,accel=kvm \
  -object iothread,id=iothread1 \
  -drive
file=myfile,format=qcow2,if=none,id=drive-virtio-disk0,node-name=n \
  -device
virtio-blk-pci,iothread=iothread1,drive=drive-virtio-disk0,id=virtio-disk0 \
  -qmp stdio -nographic
{'execute':'qmp_capabilities'}
{'execute':'nbd-server-start','arguments':{'addr':{'type':'inet',
  'data':{'host':'localhost','port':'10809'
{'execute':'blockdev-add','arguments':{'driver':'qcow2',
 'node-name':'t','file'{'driver':'file',
  'filename':'myfile.wrap'},'backing':'n'}}
{'execute':'blockdev-backup','arguments':{'device':'n',
 'target':'t','sync':'none','job-id':'b'}}
{'execute':'nbd-server-add','arguments':{'device':'t','name':'t'}}
{'execute':'nbd-server-remove','arguments':{'name':'t'}}
Aborted (core dumped)

I'm now playing with Kevin's ideas of grabbing the aiocontext around nbd
unref.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH v2 3/6] tests/acceptance: Test OpenBIOS on the PReP/40p

2019-09-16 Thread Cleber Rosa
On Sun, Sep 15, 2019 at 11:19:37PM +0200, Philippe Mathieu-Daudé wrote:
> User case from:
> https://mail.coreboot.org/pipermail/openbios/2018-May/010360.html
> 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  tests/acceptance/ppc_prep_40p.py | 32 
>  1 file changed, 32 insertions(+)
> 
> diff --git a/tests/acceptance/ppc_prep_40p.py 
> b/tests/acceptance/ppc_prep_40p.py
> index a0eac40d9f..87b5311b89 100644
> --- a/tests/acceptance/ppc_prep_40p.py
> +++ b/tests/acceptance/ppc_prep_40p.py
> @@ -82,3 +82,35 @@ class IbmPrep40pMachine(Test):
>  self.wait_for_console_pattern(fw_banner)
>  prompt_msg = 'Type any key to interrupt automatic startup'
>  self.wait_for_console_pattern(prompt_msg)
> +
> +def test_openbios_192m(self):
> +"""
> +:avocado: tags=arch:ppc
> +:avocado: tags=machine:40p
> +"""
> +self.vm.set_machine('40p')
> +self.vm.set_console()
> +self.vm.add_args('-m', '192')

Is 192 a magic number (some kind of limit)?  Or just a value to check
against later?

> +
> +self.vm.launch()
> +self.wait_for_console_pattern('>> OpenBIOS')
> +self.wait_for_console_pattern('>> Memory: 192M')
> +self.wait_for_console_pattern('>> CPU type PowerPC,604')
> +

On my testing, this is a very stable test, I'm only getting PASSes.

> +def test_openbios_and_netbsd(self):
> +"""
> +:avocado: tags=arch:ppc
> +:avocado: tags=machine:40p
> +"""
> +drive_url = ('https://ftp.netbsd.org/pub/NetBSD/iso/7.1.2/'
> + 'NetBSD-7.1.2-prep.iso')
> +drive_hash = '78734c1bdda79778f0b6f391969ad2458ed8981c'

According to https://ftp.netbsd.org/pub/NetBSD/iso/7.1.2/MD5 :

  MD5 (NetBSD-7.1.2-prep.iso) = ac6fa2707d888b36d6fa64de6e7fe48e

Which would require either:

  drive_hash = 'ac6fa2707d888b36d6fa64de6e7fe48e'
  drive_path = self.fetch_asset(drive_url, asset_hash=drive_hash,
algorithm='md5')

Or, if you want to use sha1:

  drive_hash = '467ba366e4574d32b060532660369542d607ec5d'

- Cleber.

> +drive_path = self.fetch_asset(drive_url, asset_hash=drive_hash)
> +
> +self.vm.set_machine('40p')
> +self.vm.set_console()
> +self.vm.add_args('-cdrom', drive_path,
> + '-boot', 'd')
> +
> +self.vm.launch()
> +self.wait_for_console_pattern('NetBSD/prep BOOT, Revision 1.9')
> -- 
> 2.20.1
> 
> 



Re: [Qemu-devel] [PATCH v3 5/6] docs: start a document to describe D-Bus usage

2019-09-16 Thread Marc-André Lureau
Hi

On Mon, Sep 16, 2019 at 5:15 PM Dr. David Alan Gilbert
 wrote:
>
> * Marc-André Lureau (marcandre.lur...@gmail.com) wrote:
> > Hi
> >
> > On Mon, Sep 16, 2019 at 2:02 PM Dr. David Alan Gilbert
> >  wrote:
> > >
> > > (Copying in Stefan since he was looking at DBus for virtiofs)
> > >
> > > * Marc-André Lureau (marcandre.lur...@redhat.com) wrote:
> > > > Signed-off-by: Marc-André Lureau 
> > > > ---
> > > >  docs/interop/dbus.rst  | 73 ++
> > > >  docs/interop/index.rst |  1 +
> > > >  2 files changed, 74 insertions(+)
> > > >  create mode 100644 docs/interop/dbus.rst
> > > >
> > > > diff --git a/docs/interop/dbus.rst b/docs/interop/dbus.rst
> > > > new file mode 100644
> > > > index 00..c08f026edc
> > > > --- /dev/null
> > > > +++ b/docs/interop/dbus.rst
> > > > @@ -0,0 +1,73 @@
> > > > +=
> > > > +D-Bus
> > > > +=
> > > > +
> > > > +Introduction
> > > > +
> > > > +
> > > > +QEMU may be running with various helper processes involved:
> > > > + - vhost-user* processes (gpu, virtfs, input, etc...)
> > > > + - TPM emulation (or other devices)
> > > > + - user networking (slirp)
> > > > + - network services (DHCP/DNS, samba/ftp etc)
> > > > + - background tasks (compression, streaming etc)
> > > > + - client UI
> > > > + - admin & cli
> > > > +
> > > > +Having several processes allows stricter security rules, as well as
> > > > +greater modularity.
> > > > +
> > > > +While QEMU itself uses QMP as primary IPC (and Spice/VNC for remote
> > > > +display), D-Bus is the de facto IPC of choice on Unix systems. The
> > > > +wire format is machine friendly, good bindings exist for various
> > > > +languages, and there are various tools available.
> > > > +
> > > > +Using a bus, helper processes can discover and communicate with each
> > > > +other easily, without going through QEMU. The bus topology is also
> > > > +easier to apprehend and debug than a mesh. However, it is wise to
> > > > +consider the security aspects of it.
> > > > +
> > > > +Security
> > > > +
> > > > +
> > > > +A QEMU D-Bus bus should be private to a single VM. Thus, only
> > > > +cooperative tasks are running on the same bus to serve the VM.
> > > > +
> > > > +D-Bus, the protocol and standard, doesn't have mechanisms to enforce
> > > > +security between peers once the connection is established. Peers may
> > > > +have additional mechanisms to enforce security rules, based for
> > > > +example on UNIX credentials.
> > > > +
> > > > +dbus-daemon can enforce various policies based on the UID/GID of the
> > > > +processes that are connected to it. It is thus a good idea to run
> > > > +helpers as different UID from QEMU and set appropriate policies (so
> > > > +helper processes are only allowed to talk to qemu for example).
> > > > +
> > > > +For example, this allows only ``qemu`` user to talk to ``qemu-helper``
> > > > +``org.qemu.Helper1`` service:
> > > > +
> > > > +.. code:: xml
> > > > +
> > > > +  
> > > > + 
> > > > + 
> > > > +  
> > > > +
> > > > +  
> > > > + 
> > > > +  
> > > > +
> > > > +
> > > > +dbus-daemon can also perfom SELinux checks based on the security
> > > > +context of the source and the target. For example, ``virtiofs_t``
> > > > +could be allowed to send a message to ``svirt_t``, but ``virtiofs_t``
> > > > +wouldn't be allowed to send a message to ``virtiofs_t``.
> > >
> > > I think we need to start thinking about this more now rather than
> > > 'can'. .
> >
> > Do you have a specific question we can answer or guide for qemu? Is
> > there something we have to document or implement?
> >
> > Since qemu is not managing the extra processes or applying policies, I
> > don't know what else could be done. From qemu pov, it can rely on
> > management layer to trust the bus and the helpers, similar to trusting
> > the system in general.
>
> Well pretty much the same questions I asked in the discussion on v2;
> what is the supported configuration to ensure that one helper that's
> been compromised can't attack the others and qemu?

I thought I gave the answer to that question above. What is missing? I
don't think one can generalize it here, it will be a case by case for
each helper, how they interact with each other and qemu.

>
> Dave
>
> > > Dave
> > >
> > > > +Guidelines
> > > > +==
> > > > +
> > > > +When implementing new D-Bus interfaces, it is recommended to follow
> > > > +the "D-Bus API Design Guidelines":
> > > > +https://dbus.freedesktop.org/doc/dbus-api-design.html
> > > > +
> > > > +The "org.qemu*" prefix is reserved for the QEMU project.
> > > > diff --git a/docs/interop/index.rst b/docs/interop/index.rst
> > > > index b4bfcab417..fa4478ce2e 100644
> > > > --- a/docs/interop/index.rst
> > > > +++ b/docs/interop/index.rst
> > > > @@ -13,6 +13,7 @@ Contents:
> > > > :maxdepth: 2
> > > >
> > > > bitmaps
> > > > +   dbus
> > > > live-block-operations
> > > > pr-helper
> > > > vhost-user
> > > > --
> > > > 

Re: [Qemu-devel] [PATCH v2 2/6] tests/acceptance: Test Open Firmware on the PReP/40p

2019-09-16 Thread Cleber Rosa
On Mon, Sep 16, 2019 at 01:59:22PM -0400, Cleber Rosa wrote:
> On Sun, Sep 15, 2019 at 11:19:36PM +0200, Philippe Mathieu-Daudé wrote:
> > User case from:
> > https://tyom.blogspot.com/2019/04/aixprep-under-qemu-how-to.html
> > 
> > Signed-off-by: Philippe Mathieu-Daudé 
> > ---
> >  tests/acceptance/ppc_prep_40p.py | 21 +
> >  1 file changed, 21 insertions(+)
> > 
> > diff --git a/tests/acceptance/ppc_prep_40p.py 
> > b/tests/acceptance/ppc_prep_40p.py
> > index 53f2d2ecf0..a0eac40d9f 100644
> > --- a/tests/acceptance/ppc_prep_40p.py
> > +++ b/tests/acceptance/ppc_prep_40p.py
> > @@ -61,3 +61,24 @@ class IbmPrep40pMachine(Test):
> >  os_banner = 'NetBSD 4.0 (GENERIC) #0: Sun Dec 16 00:49:40 PST 2007'
> >  self.wait_for_console_pattern(os_banner)
> >  self.wait_for_console_pattern('Model: IBM PPS Model 6015')
> > +
> > +def test_openfirmware(self):
> > +"""
> > +:avocado: tags=arch:ppc
> > +:avocado: tags=machine:40p
> > +"""
> > +bios_url = ('https://github.com/artyom-tarasenko/openfirmware/'
> > +'releases/download/40p-20190413/q40pofw-serial.rom')
> > +bios_hash = '880c80172ea5b2247c0ac2a8bf36bbe385192c72'
> > +bios_path = self.fetch_asset(bios_url, asset_hash=bios_hash)
> > +
> > +self.vm.set_machine('40p')
> > +self.vm.set_console()
> > +self.vm.add_args('-bios', bios_path)
> > +
> > +self.vm.launch()
> > +self.wait_for_console_pattern('QEMU PReP/40p')
> > +fw_banner = 'Open Firmware, built  April 13, 2019 09:29:23'
> > +self.wait_for_console_pattern(fw_banner)
> > +prompt_msg = 'Type any key to interrupt automatic startup'
> > +self.wait_for_console_pattern(prompt_msg)
> > -- 
> > 2.20.1
> > 
> 
> Tested-by: Cleber Rosa 
> Reviewed-by: Cleber Rosa 

Actually, I'm seeing random but consistent failures.  I've tracked
it down to the 'Open Firmware, built  April 13, 2019 09:29:23'.  Out
of 100 executions I got 27 failures, with that line logged as:

  2019-09-16 14:44:54,540 ppc_prep_40p L0033 DEBUG| Firmware, built  April 
13, 2019 09:29:23
  2019-09-16 14:45:00,762 ppc_prep_40p L0033 DEBUG| n Firmware, built  
April 13, 2019 09:29:23
  2019-09-16 14:45:06,575 ppc_prep_40p L0033 DEBUG| Firmware, built  April 
13, 2019 09:29:23
  2019-09-16 14:45:12,859 ppc_prep_40p L0033 DEBUG| n Firmware, built  
April 13, 2019 09:29:23
  2019-09-16 14:45:18,707 ppc_prep_40p L0033 DEBUG| Firmware, built  April 
13, 2019 09:29:23
  2019-09-16 14:45:21,876 ppc_prep_40p L0033 DEBUG| en Firmware, built  
April 13, 2019 09:29:23
  2019-09-16 14:45:28,054 ppc_prep_40p L0033 DEBUG| Firmware, built  April 
13, 2019 09:29:23
  2019-09-16 14:45:31,163 ppc_prep_40p L0033 DEBUG| Firmware, built  April 
13, 2019 09:29:23
  2019-09-16 14:45:34,291 ppc_prep_40p L0033 DEBUG| en Firmware, built  
April 13, 2019 09:29:23
  2019-09-16 14:45:57,719 ppc_prep_40p L0033 DEBUG| Firmware, built  April 
13, 2019 09:29:23
  2019-09-16 14:46:03,610 ppc_prep_40p L0033 DEBUG| Firmware, built  April 
13, 2019 09:29:23
  2019-09-16 14:46:06,795 ppc_prep_40p L0033 DEBUG| n Firmware, built  
April 13, 2019 09:29:23
  2019-09-16 14:46:17,087 ppc_prep_40p L0033 DEBUG| n Firmware, built  
April 13, 2019 09:29:23
  2019-09-16 14:46:21,534 ppc_prep_40p L0033 DEBUG| Firmware, built  April 
13, 2019 09:29:23
  2019-09-16 14:46:24,694 ppc_prep_40p L0033 DEBUG| Firmware, built  April 
13, 2019 09:29:23
  2019-09-16 14:46:38,076 ppc_prep_40p L0033 DEBUG| Firmware, built  April 
13, 2019 09:29:23
  2019-09-16 14:46:49,863 ppc_prep_40p L0033 DEBUG| n Firmware, built  
April 13, 2019 09:29:23
  2019-09-16 14:46:54,435 ppc_prep_40p L0033 DEBUG| Firmware, built  April 
13, 2019 09:29:23
  2019-09-16 14:47:00,672 ppc_prep_40p L0033 DEBUG| Firmware, built  April 
13, 2019 09:29:23
  2019-09-16 14:47:03,834 ppc_prep_40p L0033 DEBUG| n Firmware, built  
April 13, 2019 09:29:23
  2019-09-16 14:47:06,852 ppc_prep_40p L0033 DEBUG| Firmware, built  April 
13, 2019 09:29:23
  2019-09-16 14:47:14,276 ppc_prep_40p L0033 DEBUG| n Firmware, built  
April 13, 2019 09:29:23
  2019-09-16 14:47:17,380 ppc_prep_40p L0033 DEBUG| Firmware, built  April 
13, 2019 09:29:23
  2019-09-16 14:47:34,749 ppc_prep_40p L0033 DEBUG| n Firmware, built  
April 13, 2019 09:29:23
  2019-09-16 14:47:39,217 ppc_prep_40p L0033 DEBUG| n Firmware, built  
April 13, 2019 09:29:23
  2019-09-16 14:47:43,750 ppc_prep_40p L0033 DEBUG| Firmware, built  April 
13, 2019 09:29:23
  2019-09-16 14:48:04,003 ppc_prep_40p L0033 DEBUG| Firmware, built  April 
13, 2019 09:29:23

Given that we're not seeing this behavior in other target/marchine
tests, my first impression is that this is what's being produced
by QEMU, and not what's being badly captured by the Avocado and/or
the test code.

Any ideas?

- Cleber.



Re: [Qemu-devel] [PATCH 1/3] tests/acceptance/migration: fix post migration check

2019-09-16 Thread Dr. David Alan Gilbert
* Balamuruhan S (bal...@linux.ibm.com) wrote:
> assert `query-migrate` in target doesn't give migration
> status and test errors even if migration succeeds.
> 
> In target:
> {'execute': 'query-migrate'}
> {"return": {}}

On which version of qemu?

On the current version I see:

{"QMP": {"version": {"qemu": {"micro": 50, "minor": 1, "major": 4}, "package": 
"v4.1.0-852-g1a0b66e787"}, "capabilities": ["oob"]}}
{ "execute": "qmp_capabilities" }
{"return": {}}
{'execute': 'query-migrate'}
{"return": {"status": "completed"}}

Dave
> Signed-off-by: Balamuruhan S 
> ---
>  tests/acceptance/migration.py | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/acceptance/migration.py b/tests/acceptance/migration.py
> index a44c1ae58f..0f3553c8f0 100644
> --- a/tests/acceptance/migration.py
> +++ b/tests/acceptance/migration.py
> @@ -44,7 +44,8 @@ class Migration(Test):
>  step=0.1,
>  args=(source_vm,)
>  )
> -self.assertEqual(dest_vm.command('query-migrate')['status'], 
> 'completed')
> -self.assertEqual(source_vm.command('query-migrate')['status'], 
> 'completed')
> +self.assertEqual(source_vm.command('query-migrate')['status'],
> + 'completed')
>  self.assertEqual(dest_vm.command('query-status')['status'], 
> 'running')
> -self.assertEqual(source_vm.command('query-status')['status'], 
> 'postmigrate')
> +self.assertEqual(source_vm.command('query-status')['status'],
> + 'postmigrate')
> -- 
> 2.14.5
> 
> 
--
Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK



Re: [Qemu-devel] [PATCH 02/13] hw: Move PL031 device from hw/timer/ to hw/rtc/ subdirectory

2019-09-16 Thread Alistair Francis
On Mon, Sep 16, 2019 at 9:06 AM Philippe Mathieu-Daudé
 wrote:
>
> The PL031 is a Real Time Clock, not a timer.
> Move it under the hw/rtc/ subdirectory.
>
> Signed-off-by: Philippe Mathieu-Daudé 

Reviewed-by: Alistair Francis 

Alistair

> ---
>  MAINTAINERS   | 4 ++--
>  Makefile.objs | 1 +
>  hw/Kconfig| 1 +
>  hw/Makefile.objs  | 1 +
>  hw/arm/musca.c| 2 +-
>  hw/rtc/Kconfig| 2 ++
>  hw/rtc/Makefile.objs  | 1 +
>  hw/{timer => rtc}/pl031.c | 2 +-
>  hw/rtc/trace-events   | 8 
>  hw/timer/Kconfig  | 3 ---
>  hw/timer/Makefile.objs| 1 -
>  hw/timer/trace-events | 7 ---
>  include/hw/{timer => rtc}/pl031.h | 5 +++--
>  13 files changed, 21 insertions(+), 17 deletions(-)
>  create mode 100644 hw/rtc/Kconfig
>  create mode 100644 hw/rtc/Makefile.objs
>  rename hw/{timer => rtc}/pl031.c (99%)
>  create mode 100644 hw/rtc/trace-events
>  rename include/hw/{timer => rtc}/pl031.h (93%)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index f0e30b5248..5562d2c6d0 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -495,8 +495,8 @@ F: hw/intc/pl190.c
>  F: hw/sd/pl181.c
>  F: hw/ssi/pl022.c
>  F: include/hw/ssi/pl022.h
> -F: hw/timer/pl031.c
> -F: include/hw/timer/pl031.h
> +F: hw/rtc/pl031.c
> +F: include/hw/rtc/pl031.h
>  F: include/hw/arm/primecell.h
>  F: hw/timer/cmsdk-apb-timer.c
>  F: include/hw/timer/cmsdk-apb-timer.h
> diff --git a/Makefile.objs b/Makefile.objs
> index 6a143dcd57..1bcde315f7 100644
> --- a/Makefile.objs
> +++ b/Makefile.objs
> @@ -173,6 +173,7 @@ trace-events-subdirs += hw/pci-host
>  trace-events-subdirs += hw/ppc
>  trace-events-subdirs += hw/rdma
>  trace-events-subdirs += hw/rdma/vmw
> +trace-events-subdirs += hw/rtc
>  trace-events-subdirs += hw/s390x
>  trace-events-subdirs += hw/scsi
>  trace-events-subdirs += hw/sd
> diff --git a/hw/Kconfig b/hw/Kconfig
> index b45db3c813..4b53fee4d0 100644
> --- a/hw/Kconfig
> +++ b/hw/Kconfig
> @@ -27,6 +27,7 @@ source pci-host/Kconfig
>  source pcmcia/Kconfig
>  source pci/Kconfig
>  source rdma/Kconfig
> +source rtc/Kconfig
>  source scsi/Kconfig
>  source sd/Kconfig
>  source semihosting/Kconfig
> diff --git a/hw/Makefile.objs b/hw/Makefile.objs
> index ece6cc3755..fd9750e5f2 100644
> --- a/hw/Makefile.objs
> +++ b/hw/Makefile.objs
> @@ -26,6 +26,7 @@ devices-dirs-y += nvram/
>  devices-dirs-y += pci/
>  devices-dirs-$(CONFIG_PCI) += pci-bridge/ pci-host/
>  devices-dirs-y += pcmcia/
> +devices-dirs-y += rtc/
>  devices-dirs-$(CONFIG_SCSI) += scsi/
>  devices-dirs-y += sd/
>  devices-dirs-y += ssi/
> diff --git a/hw/arm/musca.c b/hw/arm/musca.c
> index 68db4b5b38..ba99dd1941 100644
> --- a/hw/arm/musca.c
> +++ b/hw/arm/musca.c
> @@ -32,7 +32,7 @@
>  #include "hw/misc/tz-mpc.h"
>  #include "hw/misc/tz-ppc.h"
>  #include "hw/misc/unimp.h"
> -#include "hw/timer/pl031.h"
> +#include "hw/rtc/pl031.h"
>
>  #define MUSCA_NUMIRQ_MAX 96
>  #define MUSCA_PPC_MAX 3
> diff --git a/hw/rtc/Kconfig b/hw/rtc/Kconfig
> new file mode 100644
> index 00..8a4383bca9
> --- /dev/null
> +++ b/hw/rtc/Kconfig
> @@ -0,0 +1,2 @@
> +config PL031
> +bool
> diff --git a/hw/rtc/Makefile.objs b/hw/rtc/Makefile.objs
> new file mode 100644
> index 00..3e1eb42563
> --- /dev/null
> +++ b/hw/rtc/Makefile.objs
> @@ -0,0 +1 @@
> +common-obj-$(CONFIG_PL031) += pl031.o
> diff --git a/hw/timer/pl031.c b/hw/rtc/pl031.c
> similarity index 99%
> rename from hw/timer/pl031.c
> rename to hw/rtc/pl031.c
> index 2b3e261006..3a982752a2 100644
> --- a/hw/timer/pl031.c
> +++ b/hw/rtc/pl031.c
> @@ -13,7 +13,7 @@
>
>  #include "qemu/osdep.h"
>  #include "qemu-common.h"
> -#include "hw/timer/pl031.h"
> +#include "hw/rtc/pl031.h"
>  #include "migration/vmstate.h"
>  #include "hw/irq.h"
>  #include "hw/qdev-properties.h"
> diff --git a/hw/rtc/trace-events b/hw/rtc/trace-events
> new file mode 100644
> index 00..54c94ac557
> --- /dev/null
> +++ b/hw/rtc/trace-events
> @@ -0,0 +1,8 @@
> +# See docs/devel/tracing.txt for syntax documentation.
> +
> +# pl031.c
> +pl031_irq_state(int level) "irq state %d"
> +pl031_read(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x"
> +pl031_write(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x"
> +pl031_alarm_raised(void) "alarm raised"
> +pl031_set_alarm(uint32_t ticks) "alarm set for %u ticks"
> diff --git a/hw/timer/Kconfig b/hw/timer/Kconfig
> index eefc95f35e..27c5dce09e 100644
> --- a/hw/timer/Kconfig
> +++ b/hw/timer/Kconfig
> @@ -27,9 +27,6 @@ config M41T80
>  config M48T59
>  bool
>
> -config PL031
> -bool
> -
>  config TWL92230
>  bool
>  depends on I2C
> diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs
> index f407523aa4..9f64f6e11e 100644
> --- a/hw/timer/Makefile.objs
> +++ b/hw/timer/Makefile.objs
> @@ -11,7 +11,6 @@ common-obj-$(CONFIG_M48T59) += m48t59.o
>  ifeq 

[Qemu-devel] [PATCH v5 0/5] qcow2: async handling of fragmented io

2019-09-16 Thread Vladimir Sementsov-Ogievskiy
Hi all!

Here is an asynchronous scheme for handling fragmented qcow2
reads and writes. Both qcow2 read and write functions loops through
sequential portions of data. The series aim it to parallelize these
loops iterations.
It improves performance for fragmented qcow2 images, I've tested it
as described below.

v5: fix 026 and rebase on Max's block branch [perf results not updated]:

01: new, prepare 026 to not fail
03: - drop read_encrypted blkdbg event [Kevin]
- assert((x & (BDRV_SECTOR_SIZE - 1)) == 0) -> assert(QEMU_IS_ALIGNED(x, 
BDRV_SECTOR_SIZE)) [rebase]
- full host offset in argument of qcow2_co_decrypt [rebase]
04: - substitute remaining qcow2_co_do_pwritev by qcow2_co_pwritev_task in 
comment [Max]
- full host offset in argument of qcow2_co_encrypt [rebase]
05: - Now patch don't affect 026 iotest, so its output is not changed

Rebase changes seems trivial, so, I've kept r-b marks.

Based-on: https://github.com/XanClic/qemu.git block

About testing:

I have four 4G qcow2 images (with default 64k block size) on my ssd disk:
t-seq.qcow2 - sequentially written qcow2 image
t-reverse.qcow2 - filled by writing 64k portions from end to the start
t-rand.qcow2 - filled by writing 64k portions (aligned) in random order
t-part-rand.qcow2 - filled by shuffling order of 64k writes in 1m clusters
(see source code of image generation in the end for details)

and I've done several runs like the following (sequential io by 1mb chunks):

out=/tmp/block; echo > $out; cat /tmp/files | while read file; do for wr in 
{"","-w"}; do echo "$file" $wr; ./qemu-img bench -c 4096 -d 1 -f qcow2 -n -s 1m 
-t none $wr "$file" | grep 'Run completed in' | awk '{print $4}' >> $out; done; 
done


short info about parameters:
  -w - do writes (otherwise do reads)
  -c - count of blocks
  -s - block size
  -t none - disable cache
  -n - native aio
  -d 1 - don't use parallel requests provided by qemu-img bench itself

results:

+---+-+-+
| file  | master  | async   |
+---+-+-+
| /ssd/t-part-rand.qcow2| 14.671  | 9.193   |
+---+-+-+
| /ssd/t-part-rand.qcow2 -w | 11.434  | 8.621   |
+---+-+-+
| /ssd/t-rand.qcow2 | 20.421  | 10.05   |
+---+-+-+
| /ssd/t-rand.qcow2 -w  | 11.097  | 8.915   |
+---+-+-+
| /ssd/t-reverse.qcow2  | 17.515  | 9.407   |
+---+-+-+
| /ssd/t-reverse.qcow2 -w   | 11.255  | 8.649   |
+---+-+-+
| /ssd/t-seq.qcow2  | 9.081   | 9.072   |
+---+-+-+
| /ssd/t-seq.qcow2 -w   | 8.761   | 8.747   |
+---+-+-+
| /tmp/t-part-rand.qcow2| 41.179  | 41.37   |
+---+-+-+
| /tmp/t-part-rand.qcow2 -w | 54.097  | 55.323  |
+---+-+-+
| /tmp/t-rand.qcow2 | 711.899 | 514.339 |
+---+-+-+
| /tmp/t-rand.qcow2 -w  | 546.259 | 642.114 |
+---+-+-+
| /tmp/t-reverse.qcow2  | 86.065  | 96.522  |
+---+-+-+
| /tmp/t-reverse.qcow2 -w   | 46.557  | 48.499  |
+---+-+-+
| /tmp/t-seq.qcow2  | 33.804  | 33.862  |
+---+-+-+
| /tmp/t-seq.qcow2 -w   | 34.299  | 34.233  |
+---+-+-+


Performance gain is obvious, especially for read and especially for ssd.
For hdd there is a degradation for reverse case, but this is the most
impossible case and seems not critical.

How images are generated:

 gen-writes ==
#!/usr/bin/env python
import random
import sys

size = 4 * 1024 * 1024 * 1024
block = 64 * 1024
block2 = 1024 * 1024

arg = sys.argv[1]

if arg in ('rand', 'reverse', 'seq'):
writes = list(range(0, size, block))

if arg == 'rand':
random.shuffle(writes)
elif arg == 'reverse':
writes.reverse()
elif arg == 'part-rand':
writes = []
for off in range(0, size, block2):
wr = list(range(off, off + block2, block))
random.shuffle(wr)
writes.extend(wr)
elif arg != 'seq':
sys.exit(1)

for w in writes:
print 'write -P 0xff {} {}'.format(w, block)

print 'q'
==

= gen-test-images.sh =
#!/bin/bash

IMG_PATH=/ssd

for name in seq reverse rand part-rand; do
IMG=$IMG_PATH/t-$name.qcow2
echo createing $IMG ...
  

[Qemu-devel] [PATCH v5 5/5] block/qcow2: introduce parallel subrequest handling in read and write

2019-09-16 Thread Vladimir Sementsov-Ogievskiy
It improves performance for fragmented qcow2 images.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
---
 block/qcow2.h  |   3 ++
 block/qcow2.c  | 125 -
 block/trace-events |   1 +
 3 files changed, 117 insertions(+), 12 deletions(-)

diff --git a/block/qcow2.h b/block/qcow2.h
index a488d761ff..f51f478e34 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -65,6 +65,9 @@
 #define QCOW2_MAX_BITMAPS 65535
 #define QCOW2_MAX_BITMAP_DIRECTORY_SIZE (1024 * QCOW2_MAX_BITMAPS)
 
+/* Maximum of parallel sub-request per guest request */
+#define QCOW2_MAX_WORKERS 8
+
 /* indicate that the refcount of the referenced cluster is exactly one. */
 #define QCOW_OFLAG_COPIED (1ULL << 63)
 /* indicate that the cluster is compressed (they never have the copied flag) */
diff --git a/block/qcow2.c b/block/qcow2.c
index 164b22e4a2..7961c05783 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -41,6 +41,7 @@
 #include "qapi/qobject-input-visitor.h"
 #include "qapi/qapi-visit-block-core.h"
 #include "crypto.h"
+#include "block/aio_task.h"
 
 /*
   Differences with QCOW:
@@ -2025,6 +2026,60 @@ fail:
 return ret;
 }
 
+typedef struct Qcow2AioTask {
+AioTask task;
+
+BlockDriverState *bs;
+QCow2ClusterType cluster_type; /* only for read */
+uint64_t file_cluster_offset;
+uint64_t offset;
+uint64_t bytes;
+QEMUIOVector *qiov;
+uint64_t qiov_offset;
+QCowL2Meta *l2meta; /* only for write */
+} Qcow2AioTask;
+
+static coroutine_fn int qcow2_co_preadv_task_entry(AioTask *task);
+static coroutine_fn int qcow2_add_task(BlockDriverState *bs,
+   AioTaskPool *pool,
+   AioTaskFunc func,
+   QCow2ClusterType cluster_type,
+   uint64_t file_cluster_offset,
+   uint64_t offset,
+   uint64_t bytes,
+   QEMUIOVector *qiov,
+   size_t qiov_offset,
+   QCowL2Meta *l2meta)
+{
+Qcow2AioTask local_task;
+Qcow2AioTask *task = pool ? g_new(Qcow2AioTask, 1) : _task;
+
+*task = (Qcow2AioTask) {
+.task.func = func,
+.bs = bs,
+.cluster_type = cluster_type,
+.qiov = qiov,
+.file_cluster_offset = file_cluster_offset,
+.offset = offset,
+.bytes = bytes,
+.qiov_offset = qiov_offset,
+.l2meta = l2meta,
+};
+
+trace_qcow2_add_task(qemu_coroutine_self(), bs, pool,
+ func == qcow2_co_preadv_task_entry ? "read" : "write",
+ cluster_type, file_cluster_offset, offset, bytes,
+ qiov, qiov_offset);
+
+if (!pool) {
+return func(>task);
+}
+
+aio_task_pool_start_task(pool, >task);
+
+return 0;
+}
+
 static coroutine_fn int qcow2_co_preadv_task(BlockDriverState *bs,
  QCow2ClusterType cluster_type,
  uint64_t file_cluster_offset,
@@ -2074,18 +2129,28 @@ static coroutine_fn int 
qcow2_co_preadv_task(BlockDriverState *bs,
 g_assert_not_reached();
 }
 
+static coroutine_fn int qcow2_co_preadv_task_entry(AioTask *task)
+{
+Qcow2AioTask *t = container_of(task, Qcow2AioTask, task);
+
+assert(!t->l2meta);
+
+return qcow2_co_preadv_task(t->bs, t->cluster_type, t->file_cluster_offset,
+t->offset, t->bytes, t->qiov, t->qiov_offset);
+}
+
 static coroutine_fn int qcow2_co_preadv_part(BlockDriverState *bs,
  uint64_t offset, uint64_t bytes,
  QEMUIOVector *qiov,
  size_t qiov_offset, int flags)
 {
 BDRVQcow2State *s = bs->opaque;
-int ret;
+int ret = 0;
 unsigned int cur_bytes; /* number of bytes in current iteration */
 uint64_t cluster_offset = 0;
+AioTaskPool *aio = NULL;
 
-while (bytes != 0) {
-
+while (bytes != 0 && aio_task_pool_status(aio) == 0) {
 /* prepare next request */
 cur_bytes = MIN(bytes, INT_MAX);
 if (s->crypto) {
@@ -2097,7 +2162,7 @@ static coroutine_fn int 
qcow2_co_preadv_part(BlockDriverState *bs,
 ret = qcow2_get_cluster_offset(bs, offset, _bytes, 
_offset);
 qemu_co_mutex_unlock(>lock);
 if (ret < 0) {
-return ret;
+goto out;
 }
 
 if (ret == QCOW2_CLUSTER_ZERO_PLAIN ||
@@ -2106,11 +2171,14 @@ static coroutine_fn int 
qcow2_co_preadv_part(BlockDriverState *bs,
 {
 qemu_iovec_memset(qiov, qiov_offset, 0, cur_bytes);
 } else {
-ret = qcow2_co_preadv_task(bs, ret,
-   cluster_offset, offset, cur_bytes,
-   

Re: [Qemu-devel] [PATCH v2 2/6] tests/acceptance: Test Open Firmware on the PReP/40p

2019-09-16 Thread Cleber Rosa
On Sun, Sep 15, 2019 at 11:19:36PM +0200, Philippe Mathieu-Daudé wrote:
> User case from:
> https://tyom.blogspot.com/2019/04/aixprep-under-qemu-how-to.html
> 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  tests/acceptance/ppc_prep_40p.py | 21 +
>  1 file changed, 21 insertions(+)
> 
> diff --git a/tests/acceptance/ppc_prep_40p.py 
> b/tests/acceptance/ppc_prep_40p.py
> index 53f2d2ecf0..a0eac40d9f 100644
> --- a/tests/acceptance/ppc_prep_40p.py
> +++ b/tests/acceptance/ppc_prep_40p.py
> @@ -61,3 +61,24 @@ class IbmPrep40pMachine(Test):
>  os_banner = 'NetBSD 4.0 (GENERIC) #0: Sun Dec 16 00:49:40 PST 2007'
>  self.wait_for_console_pattern(os_banner)
>  self.wait_for_console_pattern('Model: IBM PPS Model 6015')
> +
> +def test_openfirmware(self):
> +"""
> +:avocado: tags=arch:ppc
> +:avocado: tags=machine:40p
> +"""
> +bios_url = ('https://github.com/artyom-tarasenko/openfirmware/'
> +'releases/download/40p-20190413/q40pofw-serial.rom')
> +bios_hash = '880c80172ea5b2247c0ac2a8bf36bbe385192c72'
> +bios_path = self.fetch_asset(bios_url, asset_hash=bios_hash)
> +
> +self.vm.set_machine('40p')
> +self.vm.set_console()
> +self.vm.add_args('-bios', bios_path)
> +
> +self.vm.launch()
> +self.wait_for_console_pattern('QEMU PReP/40p')
> +fw_banner = 'Open Firmware, built  April 13, 2019 09:29:23'
> +self.wait_for_console_pattern(fw_banner)
> +prompt_msg = 'Type any key to interrupt automatic startup'
> +self.wait_for_console_pattern(prompt_msg)
> -- 
> 2.20.1
> 

Tested-by: Cleber Rosa 
Reviewed-by: Cleber Rosa 



[Qemu-devel] [PATCH v5 4/5] block/qcow2: refactor qcow2_co_pwritev_part

2019-09-16 Thread Vladimir Sementsov-Ogievskiy
Similarly to previous commit, prepare for parallelizing write-loop
iterations.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Reviewed-by: Max Reitz 
---
 block/qcow2.c | 154 +-
 1 file changed, 90 insertions(+), 64 deletions(-)

diff --git a/block/qcow2.c b/block/qcow2.c
index 6feb169f7c..164b22e4a2 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -2242,6 +2242,88 @@ static int handle_alloc_space(BlockDriverState *bs, 
QCowL2Meta *l2meta)
 return 0;
 }
 
+/*
+ * qcow2_co_pwritev_task
+ * Called with s->lock unlocked
+ * l2meta  - if not NULL, qcow2_co_pwritev_task() will consume it. Caller must
+ *   not use it somehow after qcow2_co_pwritev_task() call
+ */
+static coroutine_fn int qcow2_co_pwritev_task(BlockDriverState *bs,
+  uint64_t file_cluster_offset,
+  uint64_t offset, uint64_t bytes,
+  QEMUIOVector *qiov,
+  uint64_t qiov_offset,
+  QCowL2Meta *l2meta)
+{
+int ret;
+BDRVQcow2State *s = bs->opaque;
+void *crypt_buf = NULL;
+int offset_in_cluster = offset_into_cluster(s, offset);
+QEMUIOVector encrypted_qiov;
+
+if (bs->encrypted) {
+assert(s->crypto);
+assert(bytes <= QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size);
+crypt_buf = qemu_try_blockalign(bs->file->bs, bytes);
+if (crypt_buf == NULL) {
+ret = -ENOMEM;
+goto out_unlocked;
+}
+qemu_iovec_to_buf(qiov, qiov_offset, crypt_buf, bytes);
+
+if (qcow2_co_encrypt(bs, file_cluster_offset + offset_in_cluster,
+ offset, crypt_buf, bytes) < 0)
+{
+ret = -EIO;
+goto out_unlocked;
+}
+
+qemu_iovec_init_buf(_qiov, crypt_buf, bytes);
+qiov = _qiov;
+qiov_offset = 0;
+}
+
+/* Try to efficiently initialize the physical space with zeroes */
+ret = handle_alloc_space(bs, l2meta);
+if (ret < 0) {
+goto out_unlocked;
+}
+
+/*
+ * If we need to do COW, check if it's possible to merge the
+ * writing of the guest data together with that of the COW regions.
+ * If it's not possible (or not necessary) then write the
+ * guest data now.
+ */
+if (!merge_cow(offset, bytes, qiov, qiov_offset, l2meta)) {
+BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO);
+trace_qcow2_writev_data(qemu_coroutine_self(),
+file_cluster_offset + offset_in_cluster);
+ret = bdrv_co_pwritev_part(s->data_file,
+   file_cluster_offset + offset_in_cluster,
+   bytes, qiov, qiov_offset, 0);
+if (ret < 0) {
+goto out_unlocked;
+}
+}
+
+qemu_co_mutex_lock(>lock);
+
+ret = qcow2_handle_l2meta(bs, , true);
+goto out_locked;
+
+out_unlocked:
+qemu_co_mutex_lock(>lock);
+
+out_locked:
+qcow2_handle_l2meta(bs, , false);
+qemu_co_mutex_unlock(>lock);
+
+qemu_vfree(crypt_buf);
+
+return ret;
+}
+
 static coroutine_fn int qcow2_co_pwritev_part(
 BlockDriverState *bs, uint64_t offset, uint64_t bytes,
 QEMUIOVector *qiov, size_t qiov_offset, int flags)
@@ -2251,15 +2333,10 @@ static coroutine_fn int qcow2_co_pwritev_part(
 int ret;
 unsigned int cur_bytes; /* number of sectors in current iteration */
 uint64_t cluster_offset;
-QEMUIOVector encrypted_qiov;
-uint64_t bytes_done = 0;
-uint8_t *cluster_data = NULL;
 QCowL2Meta *l2meta = NULL;
 
 trace_qcow2_writev_start_req(qemu_coroutine_self(), offset, bytes);
 
-qemu_co_mutex_lock(>lock);
-
 while (bytes != 0) {
 
 l2meta = NULL;
@@ -2273,6 +2350,8 @@ static coroutine_fn int qcow2_co_pwritev_part(
 - offset_in_cluster);
 }
 
+qemu_co_mutex_lock(>lock);
+
 ret = qcow2_alloc_cluster_offset(bs, offset, _bytes,
  _offset, );
 if (ret < 0) {
@@ -2290,73 +2369,20 @@ static coroutine_fn int qcow2_co_pwritev_part(
 
 qemu_co_mutex_unlock(>lock);
 
-if (bs->encrypted) {
-assert(s->crypto);
-if (!cluster_data) {
-cluster_data = qemu_try_blockalign(bs->file->bs,
-   QCOW_MAX_CRYPT_CLUSTERS
-   * s->cluster_size);
-if (cluster_data == NULL) {
-ret = -ENOMEM;
-goto out_unlocked;
-}
-}
-
-assert(cur_bytes <= QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size);
-qemu_iovec_to_buf(qiov, qiov_offset + bytes_done,
-  cluster_data, cur_bytes);
-
-  

[Qemu-devel] [PATCH v5 3/5] block/qcow2: refactor qcow2_co_preadv_part

2019-09-16 Thread Vladimir Sementsov-Ogievskiy
Further patch will run partial requests of iterations of
qcow2_co_preadv in parallel for performance reasons. To prepare for
this, separate part which may be parallelized into separate function
(qcow2_co_preadv_task).

While being here, also separate encrypted clusters reading to own
function, like it is done for compressed reading.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Reviewed-by: Max Reitz 
---
 block/qcow2.c | 209 +++---
 1 file changed, 113 insertions(+), 96 deletions(-)

diff --git a/block/qcow2.c b/block/qcow2.c
index 4d16393e61..6feb169f7c 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1972,17 +1972,117 @@ out:
 return ret;
 }
 
+static coroutine_fn int
+qcow2_co_preadv_encrypted(BlockDriverState *bs,
+   uint64_t file_cluster_offset,
+   uint64_t offset,
+   uint64_t bytes,
+   QEMUIOVector *qiov,
+   uint64_t qiov_offset)
+{
+int ret;
+BDRVQcow2State *s = bs->opaque;
+uint8_t *buf;
+
+assert(bs->encrypted && s->crypto);
+assert(bytes <= QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size);
+
+/*
+ * For encrypted images, read everything into a temporary
+ * contiguous buffer on which the AES functions can work.
+ * Also, decryption in a separate buffer is better as it
+ * prevents the guest from learning information about the
+ * encrypted nature of the virtual disk.
+ */
+
+buf = qemu_try_blockalign(s->data_file->bs, bytes);
+if (buf == NULL) {
+return -ENOMEM;
+}
+
+BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO);
+ret = bdrv_co_pread(s->data_file,
+file_cluster_offset + offset_into_cluster(s, offset),
+bytes, buf, 0);
+if (ret < 0) {
+goto fail;
+}
+
+assert(QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE));
+assert(QEMU_IS_ALIGNED(bytes, BDRV_SECTOR_SIZE));
+if (qcow2_co_decrypt(bs,
+ file_cluster_offset + offset_into_cluster(s, offset),
+ offset, buf, bytes) < 0)
+{
+ret = -EIO;
+goto fail;
+}
+qemu_iovec_from_buf(qiov, qiov_offset, buf, bytes);
+
+fail:
+qemu_vfree(buf);
+
+return ret;
+}
+
+static coroutine_fn int qcow2_co_preadv_task(BlockDriverState *bs,
+ QCow2ClusterType cluster_type,
+ uint64_t file_cluster_offset,
+ uint64_t offset, uint64_t bytes,
+ QEMUIOVector *qiov,
+ size_t qiov_offset)
+{
+BDRVQcow2State *s = bs->opaque;
+int offset_in_cluster = offset_into_cluster(s, offset);
+
+switch (cluster_type) {
+case QCOW2_CLUSTER_ZERO_PLAIN:
+case QCOW2_CLUSTER_ZERO_ALLOC:
+/* Both zero types are handled in qcow2_co_preadv_part */
+g_assert_not_reached();
+
+case QCOW2_CLUSTER_UNALLOCATED:
+assert(bs->backing); /* otherwise handled in qcow2_co_preadv_part */
+
+BLKDBG_EVENT(bs->file, BLKDBG_READ_BACKING_AIO);
+return bdrv_co_preadv_part(bs->backing, offset, bytes,
+   qiov, qiov_offset, 0);
+
+case QCOW2_CLUSTER_COMPRESSED:
+return qcow2_co_preadv_compressed(bs, file_cluster_offset,
+  offset, bytes, qiov, qiov_offset);
+
+case QCOW2_CLUSTER_NORMAL:
+if ((file_cluster_offset & 511) != 0) {
+return -EIO;
+}
+
+if (bs->encrypted) {
+return qcow2_co_preadv_encrypted(bs, file_cluster_offset,
+ offset, bytes, qiov, qiov_offset);
+}
+
+BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO);
+return bdrv_co_preadv_part(s->data_file,
+   file_cluster_offset + offset_in_cluster,
+   bytes, qiov, qiov_offset, 0);
+
+default:
+g_assert_not_reached();
+}
+
+g_assert_not_reached();
+}
+
 static coroutine_fn int qcow2_co_preadv_part(BlockDriverState *bs,
  uint64_t offset, uint64_t bytes,
  QEMUIOVector *qiov,
  size_t qiov_offset, int flags)
 {
 BDRVQcow2State *s = bs->opaque;
-int offset_in_cluster;
 int ret;
 unsigned int cur_bytes; /* number of bytes in current iteration */
 uint64_t cluster_offset = 0;
-uint8_t *cluster_data = NULL;
 
 while (bytes != 0) {
 
@@ -1997,112 +2097,29 @@ static coroutine_fn int 
qcow2_co_preadv_part(BlockDriverState *bs,
 ret = qcow2_get_cluster_offset(bs, offset, _bytes, 
_offset);
 qemu_co_mutex_unlock(>lock);
 if (ret < 0) {
-goto fail;
+  

[Qemu-devel] [PATCH v5 1/5] qemu-iotests: ignore leaks on failure paths in 026

2019-09-16 Thread Vladimir Sementsov-Ogievskiy
Upcoming asynchronous handling of sub-parts of qcow2 requests will
change number of leaked clusters and even make it racy. As a
preparation, ignore leaks on failure parts in 026.

It's not trivial to just grep or substitute qemu-img output for such
thing. Instead do better: 3 is a error code of qemu-img check, if only
leaks are found. Catch this case and print success output.

Suggested-by: Anton Nefedov 
Signed-off-by: Vladimir Sementsov-Ogievskiy 
---
 tests/qemu-iotests/026 |  6 +--
 tests/qemu-iotests/026.out | 80 --
 tests/qemu-iotests/026.out.nocache | 80 --
 tests/qemu-iotests/common.rc   | 17 +++
 4 files changed, 60 insertions(+), 123 deletions(-)

diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026
index ffb18ab6b5..3430029ed6 100755
--- a/tests/qemu-iotests/026
+++ b/tests/qemu-iotests/026
@@ -107,7 +107,7 @@ if [ "$event" == "l2_load" ]; then
 $QEMU_IO -c "read $vmstate 0 128k " "$BLKDBG_TEST_IMG" | _filter_qemu_io
 fi
 
-_check_test_img 2>&1 | grep -v "refcount=1 reference=0"
+_check_test_img_ignore_leaks 2>&1 | grep -v "refcount=1 reference=0"
 
 done
 done
@@ -152,7 +152,7 @@ echo
 echo "Event: $event; errno: $errno; imm: $imm; once: $once; write $vmstate"
 $QEMU_IO -c "write $vmstate 0 64M" "$BLKDBG_TEST_IMG" | _filter_qemu_io
 
-_check_test_img 2>&1 | grep -v "refcount=1 reference=0"
+_check_test_img_ignore_leaks 2>&1 | grep -v "refcount=1 reference=0"
 
 done
 done
@@ -191,7 +191,7 @@ echo
 echo "Event: $event; errno: $errno; imm: $imm; once: $once"
 $QEMU_IO -c "write -b 0 64k" "$BLKDBG_TEST_IMG" | _filter_qemu_io
 
-_check_test_img 2>&1 | grep -v "refcount=1 reference=0"
+_check_test_img_ignore_leaks 2>&1 | grep -v "refcount=1 reference=0"
 
 done
 done
diff --git a/tests/qemu-iotests/026.out b/tests/qemu-iotests/026.out
index fb89b8480c..ff0817b6f2 100644
--- a/tests/qemu-iotests/026.out
+++ b/tests/qemu-iotests/026.out
@@ -17,18 +17,14 @@ Event: l1_update; errno: 5; imm: off; once: off; write
 qemu-io: Failed to flush the L2 table cache: Input/output error
 qemu-io: Failed to flush the refcount block cache: Input/output error
 write failed: Input/output error
-
-1 leaked clusters were found on the image.
-This means waste of disk space, but no harm to data.
+No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
 Event: l1_update; errno: 5; imm: off; once: off; write -b
 qemu-io: Failed to flush the L2 table cache: Input/output error
 qemu-io: Failed to flush the refcount block cache: Input/output error
 write failed: Input/output error
-
-1 leaked clusters were found on the image.
-This means waste of disk space, but no harm to data.
+No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
 Event: l1_update; errno: 28; imm: off; once: on; write
@@ -45,18 +41,14 @@ Event: l1_update; errno: 28; imm: off; once: off; write
 qemu-io: Failed to flush the L2 table cache: No space left on device
 qemu-io: Failed to flush the refcount block cache: No space left on device
 write failed: No space left on device
-
-1 leaked clusters were found on the image.
-This means waste of disk space, but no harm to data.
+No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
 Event: l1_update; errno: 28; imm: off; once: off; write -b
 qemu-io: Failed to flush the L2 table cache: No space left on device
 qemu-io: Failed to flush the refcount block cache: No space left on device
 write failed: No space left on device
-
-1 leaked clusters were found on the image.
-This means waste of disk space, but no harm to data.
+No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
 Event: l2_load; errno: 5; imm: off; once: on; write
@@ -137,18 +129,14 @@ Event: l2_update; errno: 5; imm: off; once: off; write
 qemu-io: Failed to flush the L2 table cache: Input/output error
 qemu-io: Failed to flush the refcount block cache: Input/output error
 write failed: Input/output error
-
-127 leaked clusters were found on the image.
-This means waste of disk space, but no harm to data.
+No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
 Event: l2_update; errno: 5; imm: off; once: off; write -b
 qemu-io: Failed to flush the L2 table cache: Input/output error
 qemu-io: Failed to flush the refcount block cache: Input/output error
 write failed: Input/output error
-
-127 leaked clusters were found on the image.
-This means waste of disk space, but no harm to data.
+No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
 
 Event: l2_update; errno: 28; imm: off; once: on; write
@@ -165,18 +153,14 @@ Event: l2_update; errno: 28; imm: off; once: off; write
 qemu-io: Failed to flush the L2 table cache: No space left on device
 qemu-io: Failed to flush the refcount block cache: No space left 

Re: [Qemu-devel] [PATCH 1/4] block/dirty-bitmap: drop meta

2019-09-16 Thread John Snow



On 9/16/19 10:19 AM, Vladimir Sementsov-Ogievskiy wrote:
> Drop meta bitmaps, as they are unused.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy 

believe it or not, I had a local patch that does the same :)

Reviewed-by: John Snow 



[Qemu-devel] [PATCH v5 2/5] block: introduce aio task pool

2019-09-16 Thread Vladimir Sementsov-Ogievskiy
Common interface for aio task loops. To be used for improving
performance of synchronous io loops in qcow2, block-stream,
copy-on-read, and may be other places.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Reviewed-by: Max Reitz 
---
 include/block/aio_task.h |  54 +
 block/aio_task.c | 124 +++
 block/Makefile.objs  |   2 +
 3 files changed, 180 insertions(+)
 create mode 100644 include/block/aio_task.h
 create mode 100644 block/aio_task.c

diff --git a/include/block/aio_task.h b/include/block/aio_task.h
new file mode 100644
index 00..50bc1e1817
--- /dev/null
+++ b/include/block/aio_task.h
@@ -0,0 +1,54 @@
+/*
+ * Aio tasks loops
+ *
+ * Copyright (c) 2019 Virtuozzo International GmbH.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef BLOCK_AIO_TASK_H
+#define BLOCK_AIO_TASK_H
+
+#include "qemu/coroutine.h"
+
+typedef struct AioTaskPool AioTaskPool;
+typedef struct AioTask AioTask;
+typedef int coroutine_fn (*AioTaskFunc)(AioTask *task);
+struct AioTask {
+AioTaskPool *pool;
+AioTaskFunc func;
+int ret;
+};
+
+AioTaskPool *coroutine_fn aio_task_pool_new(int max_busy_tasks);
+void aio_task_pool_free(AioTaskPool *);
+
+/* error code of failed task or 0 if all is OK */
+int aio_task_pool_status(AioTaskPool *pool);
+
+bool aio_task_pool_empty(AioTaskPool *pool);
+
+/* User provides filled @task, however task->pool will be set automatically */
+void coroutine_fn aio_task_pool_start_task(AioTaskPool *pool, AioTask *task);
+
+void coroutine_fn aio_task_pool_wait_slot(AioTaskPool *pool);
+void coroutine_fn aio_task_pool_wait_one(AioTaskPool *pool);
+void coroutine_fn aio_task_pool_wait_all(AioTaskPool *pool);
+
+#endif /* BLOCK_AIO_TASK_H */
diff --git a/block/aio_task.c b/block/aio_task.c
new file mode 100644
index 00..88989fa248
--- /dev/null
+++ b/block/aio_task.c
@@ -0,0 +1,124 @@
+/*
+ * Aio tasks loops
+ *
+ * Copyright (c) 2019 Virtuozzo International GmbH.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "qemu/osdep.h"
+#include "block/aio.h"
+#include "block/aio_task.h"
+
+struct AioTaskPool {
+Coroutine *main_co;
+int status;
+int max_busy_tasks;
+int busy_tasks;
+bool waiting;
+};
+
+static void coroutine_fn aio_task_co(void *opaque)
+{
+AioTask *task = opaque;
+AioTaskPool *pool = task->pool;
+
+assert(pool->busy_tasks < pool->max_busy_tasks);
+pool->busy_tasks++;
+
+task->ret = task->func(task);
+
+pool->busy_tasks--;
+
+if (task->ret < 0 && pool->status == 0) {
+pool->status = task->ret;
+}
+
+g_free(task);
+
+if (pool->waiting) {
+pool->waiting = false;
+aio_co_wake(pool->main_co);
+}
+}
+
+void coroutine_fn aio_task_pool_wait_one(AioTaskPool *pool)
+{
+assert(pool->busy_tasks > 0);
+assert(qemu_coroutine_self() == pool->main_co);

Re: [Qemu-devel] [PATCH 01/13] hw/timer: Compile devices not target-dependent as common object

2019-09-16 Thread Alistair Francis
On Mon, Sep 16, 2019 at 9:02 AM Philippe Mathieu-Daudé
 wrote:
>
> All these devices do not contain any target-specific. While most
> of them are arch-specific, they are shared between different
> targets of the same arch family (ARM and AArch64, MIPS32/MIPS64,
> endianess, ...).
> Put them into common-obj-y to compile them once for all targets.
>
> Signed-off-by: Philippe Mathieu-Daudé 

Reviewed-by: Alistair Francis 

Alistair

> ---
>  hw/timer/Makefile.objs | 22 +++---
>  1 file changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs
> index 123d92c969..f407523aa4 100644
> --- a/hw/timer/Makefile.objs
> +++ b/hw/timer/Makefile.objs
> @@ -25,20 +25,20 @@ common-obj-$(CONFIG_MILKYMIST) += milkymist-sysctl.o
>  common-obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp-rtc.o
>  common-obj-$(CONFIG_NRF51_SOC) += nrf51_timer.o
>
> -obj-$(CONFIG_ALTERA_TIMER) += altera_timer.o
> -obj-$(CONFIG_EXYNOS4) += exynos4210_mct.o
> -obj-$(CONFIG_EXYNOS4) += exynos4210_pwm.o
> -obj-$(CONFIG_EXYNOS4) += exynos4210_rtc.o
> -obj-$(CONFIG_OMAP) += omap_gptimer.o
> -obj-$(CONFIG_OMAP) += omap_synctimer.o
> -obj-$(CONFIG_PXA2XX) += pxa2xx_timer.o
> -obj-$(CONFIG_SH4) += sh_timer.o
> -obj-$(CONFIG_DIGIC) += digic-timer.o
> -obj-$(CONFIG_MIPS_CPS) += mips_gictimer.o
> +common-obj-$(CONFIG_ALTERA_TIMER) += altera_timer.o
> +common-obj-$(CONFIG_EXYNOS4) += exynos4210_mct.o
> +common-obj-$(CONFIG_EXYNOS4) += exynos4210_pwm.o
> +common-obj-$(CONFIG_EXYNOS4) += exynos4210_rtc.o
> +common-obj-$(CONFIG_OMAP) += omap_gptimer.o
> +common-obj-$(CONFIG_OMAP) += omap_synctimer.o
> +common-obj-$(CONFIG_PXA2XX) += pxa2xx_timer.o
> +common-obj-$(CONFIG_SH4) += sh_timer.o
> +common-obj-$(CONFIG_DIGIC) += digic-timer.o
> +common-obj-$(CONFIG_MIPS_CPS) += mips_gictimer.o
>
>  obj-$(CONFIG_MC146818RTC) += mc146818rtc.o
>
> -obj-$(CONFIG_ALLWINNER_A10_PIT) += allwinner-a10-pit.o
> +common-obj-$(CONFIG_ALLWINNER_A10_PIT) += allwinner-a10-pit.o
>
>  common-obj-$(CONFIG_STM32F2XX_TIMER) += stm32f2xx_timer.o
>  common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o aspeed_rtc.o
> --
> 2.20.1
>
>



Re: [Qemu-devel] [PATCH 11/13] hw: Move Aspeed RTC from hw/timer/ to hw/rtc/ subdirectory

2019-09-16 Thread Cédric Le Goater
On 16/09/2019 17:48, Philippe Mathieu-Daudé wrote:
> Move RTC devices under the hw/rtc/ subdirectory.
> 
> Signed-off-by: Philippe Mathieu-Daudé 

I suppose the removal of the header files in "aspeed_rtc.h" is OK.  

Reviewed-by: Cédric Le Goater 

Thanks,

C.

> ---
>  hw/rtc/Makefile.objs   | 1 +
>  hw/{timer => rtc}/aspeed_rtc.c | 2 +-
>  hw/rtc/trace-events| 4 
>  hw/timer/Makefile.objs | 2 +-
>  hw/timer/trace-events  | 4 
>  include/hw/arm/aspeed_soc.h| 2 +-
>  include/hw/{timer => rtc}/aspeed_rtc.h | 3 ---
>  7 files changed, 8 insertions(+), 10 deletions(-)
>  rename hw/{timer => rtc}/aspeed_rtc.c (99%)
>  rename include/hw/{timer => rtc}/aspeed_rtc.h (92%)
> 
> diff --git a/hw/rtc/Makefile.objs b/hw/rtc/Makefile.objs
> index 3d4763fc26..8dc9fcd3a9 100644
> --- a/hw/rtc/Makefile.objs
> +++ b/hw/rtc/Makefile.objs
> @@ -10,3 +10,4 @@ common-obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp-rtc.o
>  common-obj-$(CONFIG_EXYNOS4) += exynos4210_rtc.o
>  obj-$(CONFIG_MC146818RTC) += mc146818rtc.o
>  common-obj-$(CONFIG_SUN4V_RTC) += sun4v-rtc.o
> +common-obj-$(CONFIG_ASPEED_SOC) += aspeed_rtc.o
> diff --git a/hw/timer/aspeed_rtc.c b/hw/rtc/aspeed_rtc.c
> similarity index 99%
> rename from hw/timer/aspeed_rtc.c
> rename to hw/rtc/aspeed_rtc.c
> index 5313017353..3ca1183558 100644
> --- a/hw/timer/aspeed_rtc.c
> +++ b/hw/rtc/aspeed_rtc.c
> @@ -8,7 +8,7 @@
>  
>  #include "qemu/osdep.h"
>  #include "qemu-common.h"
> -#include "hw/timer/aspeed_rtc.h"
> +#include "hw/rtc/aspeed_rtc.h"
>  #include "migration/vmstate.h"
>  #include "qemu/log.h"
>  #include "qemu/timer.h"
> diff --git a/hw/rtc/trace-events b/hw/rtc/trace-events
> index 7f1945ad4c..d6749f4616 100644
> --- a/hw/rtc/trace-events
> +++ b/hw/rtc/trace-events
> @@ -13,3 +13,7 @@ pl031_read(uint32_t addr, uint32_t value) "addr 0x%08x 
> value 0x%08x"
>  pl031_write(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x"
>  pl031_alarm_raised(void) "alarm raised"
>  pl031_set_alarm(uint32_t ticks) "alarm set for %u ticks"
> +
> +# aspeed-rtc.c
> +aspeed_rtc_read(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 
> 0x%08" PRIx64
> +aspeed_rtc_write(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 
> 0x%08" PRIx64
> diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs
> index 33191d74cb..83091770df 100644
> --- a/hw/timer/Makefile.objs
> +++ b/hw/timer/Makefile.objs
> @@ -29,7 +29,7 @@ common-obj-$(CONFIG_MIPS_CPS) += mips_gictimer.o
>  common-obj-$(CONFIG_ALLWINNER_A10_PIT) += allwinner-a10-pit.o
>  
>  common-obj-$(CONFIG_STM32F2XX_TIMER) += stm32f2xx_timer.o
> -common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o aspeed_rtc.o
> +common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o
>  
>  common-obj-$(CONFIG_CMSDK_APB_TIMER) += cmsdk-apb-timer.o
>  common-obj-$(CONFIG_CMSDK_APB_DUALTIMER) += cmsdk-apb-dualtimer.o
> diff --git a/hw/timer/trace-events b/hw/timer/trace-events
> index 1459d07237..e18b87fc96 100644
> --- a/hw/timer/trace-events
> +++ b/hw/timer/trace-events
> @@ -66,10 +66,6 @@ cmsdk_apb_dualtimer_read(uint64_t offset, uint64_t data, 
> unsigned size) "CMSDK A
>  cmsdk_apb_dualtimer_write(uint64_t offset, uint64_t data, unsigned size) 
> "CMSDK APB dualtimer write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
>  cmsdk_apb_dualtimer_reset(void) "CMSDK APB dualtimer: reset"
>  
> -# hw/timer/aspeed-rtc.c
> -aspeed_rtc_read(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 
> 0x%08" PRIx64
> -aspeed_rtc_write(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 
> 0x%08" PRIx64
> -
>  # nrf51_timer.c
>  nrf51_timer_read(uint64_t addr, uint32_t value, unsigned size) "read addr 
> 0x%" PRIx64 " data 0x%" PRIx32 " size %u"
>  nrf51_timer_write(uint64_t addr, uint32_t value, unsigned size) "write addr 
> 0x%" PRIx64 " data 0x%" PRIx32 " size %u"
> diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
> index ab5052b12c..5a443006ed 100644
> --- a/include/hw/arm/aspeed_soc.h
> +++ b/include/hw/arm/aspeed_soc.h
> @@ -17,7 +17,7 @@
>  #include "hw/misc/aspeed_sdmc.h"
>  #include "hw/misc/aspeed_xdma.h"
>  #include "hw/timer/aspeed_timer.h"
> -#include "hw/timer/aspeed_rtc.h"
> +#include "hw/rtc/aspeed_rtc.h"
>  #include "hw/i2c/aspeed_i2c.h"
>  #include "hw/ssi/aspeed_smc.h"
>  #include "hw/watchdog/wdt_aspeed.h"
> diff --git a/include/hw/timer/aspeed_rtc.h b/include/hw/rtc/aspeed_rtc.h
> similarity index 92%
> rename from include/hw/timer/aspeed_rtc.h
> rename to include/hw/rtc/aspeed_rtc.h
> index 15ba42912b..156c8faee3 100644
> --- a/include/hw/timer/aspeed_rtc.h
> +++ b/include/hw/rtc/aspeed_rtc.h
> @@ -8,9 +8,6 @@
>  #ifndef ASPEED_RTC_H
>  #define ASPEED_RTC_H
>  
> -#include 
> -
> -#include "hw/irq.h"
>  #include "hw/sysbus.h"
>  
>  typedef struct AspeedRtcState {
> 




Re: [Qemu-devel] [PATCH v4 1/4] iotests: add script_initialize

2019-09-16 Thread John Snow



On 9/16/19 12:39 PM, Vladimir Sementsov-Ogievskiy wrote:
> 16.09.2019 19:32, John Snow wrote:
>>
>>
>> On 9/16/19 10:56 AM, Vladimir Sementsov-Ogievskiy wrote:
>>> 12.09.2019 3:16, John Snow wrote:
 Like script_main, but doesn't require a single point of entry.
 Replace all existing initialization sections with this drop-in replacement.

 This brings debug support to all existing script-style iotests.

 Note: supported_oses=['linux'] was omitted, as it is a default argument.
>>>
>>> But after this patch all test which didn't check os start to check linux
>>> (as it's default).. So all tests which worked on other platforms will now
>>> be skipped on these other platforms?
>>>
>>
>> def verify_platform(supported_oses=['linux']):
>>  if True not in [sys.platform.startswith(x) for x in supported_oses]:
>>  notrun('not suitable for this OS: %s' % sys.platform)
>>
>>
>> It was already the default. I didn't *make* it the default.
> 
> Yes. But for some tests, verify_platform wasn't called before this patch at 
> all.
> And now it is called and checks "linux". It's the change. Or what I miss?
> 

I guess there are more than I thought.
(I thought it was just one, based on a discussion with Philippe.)

So, you're right: there are more tests now that will refuse to run on
non-Linux platforms.

Those tests are:
206
207
208
209
210
211
212
213
218
219
235
236
237
238
242
246
248
254
255
256

What sets these apart from the other python-based tests? Nothing in
particular? Just depends on who copied from whom that day. I don't think
there's any rhyme or reason to any of it.

I don't really have a BSD or OSX machine to test which ones should and
should not be limited, either.

Kevin, do you remember why we added these checks?

--js



Re: [Qemu-devel] [PATCH v2] target/s390x/kvm: Officially require at least kernel 3.15

2019-09-16 Thread Cornelia Huck
On Fri, 13 Sep 2019 11:14:43 +0200
Thomas Huth  wrote:

Modified the subject, as suggested by David.

> Since QEMU v2.10, the KVM acceleration does not work on older kernels
> anymore since the code accidentally requires the KVM_CAP_DEVICE_CTRL
> capability now - it should have been optional instead.
> Instead of fixing the bug, we asked in the ChangeLog of QEMU 2.11 - 3.0
> that people should speak up if they still need support of QEMU running
> with KVM on older kernels, but seems like nobody really complained.
> Thus let's make this official now and turn it into a proper error
> message, telling the users to use at least kernel 3.15 now.
> 
> Signed-off-by: Thomas Huth 
> ---
>  v2: Remove also the entry in trace-events
> 
>  hw/intc/s390_flic_kvm.c | 6 --
>  hw/intc/trace-events| 1 -
>  target/s390x/kvm.c  | 7 +++
>  3 files changed, 7 insertions(+), 7 deletions(-)

(...)

> diff --git a/hw/intc/trace-events b/hw/intc/trace-events
> index 90c9d07c1a..719f46b516 100644
> --- a/hw/intc/trace-events
> +++ b/hw/intc/trace-events
> @@ -75,7 +75,6 @@ xics_ics_simple_eoi(int nr) "ics_eoi: irq 0x%x"
>  
>  # s390_flic_kvm.c
>  flic_create_device(int err) "flic: create device failed %d"
> -flic_no_device_api(int err) "flic: no Device Contral API support %d"

Nice, this also gets rid of a typo :)

>  flic_reset_failed(int err) "flic: reset failed %d"
>  
>  # s390_flic.c

(...)

Thanks, applied.



Re: [Qemu-devel] [PATCH v8 18/32] riscv: sifive_u: Set the minimum number of cpus to 2

2019-09-16 Thread Alistair Francis
On Sun, Sep 15, 2019 at 6:07 AM Bin Meng  wrote:
>
> Hi Palmer,
>
> On Sun, Sep 15, 2019 at 3:00 AM Palmer Dabbelt  wrote:
> >
> > On Fri, 13 Sep 2019 08:25:21 PDT (-0700), bmeng...@gmail.com wrote:
> > > Hi Palmer,
> > >
> > > On Fri, Sep 13, 2019 at 10:33 PM Palmer Dabbelt  wrote:
> > >>
> > >> On Fri, 06 Sep 2019 09:20:05 PDT (-0700), bmeng...@gmail.com wrote:
> > >> > It is not useful if we only have one management CPU.
> > >> >
> > >> > Signed-off-by: Bin Meng 
> > >> > Reviewed-by: Alistair Francis 
> > >> >
> > >> > ---
> > >> >
> > >> > Changes in v8: None
> > >> > Changes in v7: None
> > >> > Changes in v6: None
> > >> > Changes in v5: None
> > >> > Changes in v4: None
> > >> > Changes in v3:
> > >> > - use management cpu count + 1 for the min_cpus
> > >> >
> > >> > Changes in v2:
> > >> > - update the file header to indicate at least 2 harts are created
> > >> >
> > >> >  hw/riscv/sifive_u.c | 4 +++-
> > >> >  include/hw/riscv/sifive_u.h | 2 ++
> > >> >  2 files changed, 5 insertions(+), 1 deletion(-)
> > >> >
> > >> > diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
> > >> > index 2947e06..2023b71 100644
> > >> > --- a/hw/riscv/sifive_u.c
> > >> > +++ b/hw/riscv/sifive_u.c
> > >> > @@ -10,7 +10,8 @@
> > >> >   * 1) CLINT (Core Level Interruptor)
> > >> >   * 2) PLIC (Platform Level Interrupt Controller)
> > >> >   *
> > >> > - * This board currently uses a hardcoded devicetree that indicates 
> > >> > one hart.
> > >> > + * This board currently generates devicetree dynamically that 
> > >> > indicates at least
> > >> > + * two harts.
> > >> >   *
> > >> >   * This program is free software; you can redistribute it and/or 
> > >> > modify it
> > >> >   * under the terms and conditions of the GNU General Public License,
> > >> > @@ -433,6 +434,7 @@ static void 
> > >> > riscv_sifive_u_machine_init(MachineClass *mc)
> > >> >   * management CPU.
> > >> >   */
> > >> >  mc->max_cpus = 4;
> > >> > +mc->min_cpus = SIFIVE_U_MANAGEMENT_CPU_COUNT + 1;
> > >> >  }
> > >> >
> > >> >  DEFINE_MACHINE("sifive_u", riscv_sifive_u_machine_init)
> > >> > diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h
> > >> > index f25bad8..6d22741 100644
> > >> > --- a/include/hw/riscv/sifive_u.h
> > >> > +++ b/include/hw/riscv/sifive_u.h
> > >> > @@ -69,6 +69,8 @@ enum {
> > >> >  SIFIVE_U_GEM_CLOCK_FREQ = 12500
> > >> >  };
> > >> >
> > >> > +#define SIFIVE_U_MANAGEMENT_CPU_COUNT   1
> > >> > +
> > >> >  #define SIFIVE_U_PLIC_HART_CONFIG "MS"
> > >> >  #define SIFIVE_U_PLIC_NUM_SOURCES 54
> > >> >  #define SIFIVE_U_PLIC_NUM_PRIORITIES 7
> > >>
> > >> This fails "make check", so I'm going to squash in this
> > >>
> > >> diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
> > >> index ca9f7fea41..adecbf1dd9 100644
> > >> --- a/hw/riscv/sifive_u.c
> > >> +++ b/hw/riscv/sifive_u.c
> > >> @@ -528,6 +528,7 @@ static void riscv_sifive_u_machine_init(MachineClass 
> > >> *mc)
> > >>  mc->init = riscv_sifive_u_init;
> > >>  mc->max_cpus = SIFIVE_U_MANAGEMENT_CPU_COUNT + 
> > >> SIFIVE_U_COMPUTE_CPU_COUNT;
> > >>  mc->min_cpus = SIFIVE_U_MANAGEMENT_CPU_COUNT + 1;
> > >> +mc->default_cpus = mc->max_cpus;
> > >
> > > Thank you for fixing the 'make check'. Shouldn't it be:
> > >
> > > mc->default_cpus = mc->min_cpus;
> >
> > We have 5 harts on the board that this matches, so I figured that'd be the
> > better default.
> >
>
> Per my understanding mc->default_cpus is used when invoking QEMU
> without passing '-smp n' (that's what 'make check' uses), and with the
> updated sifive_u machine, '-smp 2' is the actual useful configuration
> to boot Linux. For consistency with user experience on other machines,
> without '-smp' means we want a uni-processor machine hence I would
> suggest we set "mc->default_cpus = mc->min_cpus".

Agreed!

Alistair

>
> Regards,
> Bin
>



[Qemu-devel] [PATCH v2 1/2] ppc: Add support for 'mffscrn', 'mffscrni' instructions

2019-09-16 Thread Paul A. Clarke
From: "Paul A. Clarke" 

ISA 3.0B added a set of Floating-Point Status and Control Register (FPSCR)
instructions: mffsce, mffscdrn, mffscdrni, mffscrn, mffscrni, mffsl.
This patch adds support for 'mffscrn' and 'mffscrni' instructions.

'mffscrn' and 'mffscrni' are similar to 'mffsl', except they do not return
the status bits (FI, FR, FPRF) and they also set the rounding mode in the
FPSCR.

On CPUs without support for 'mffscrn'/'mffscrni' (below ISA 3.0), the
instructions will execute identically to 'mffs'.

Signed-off-by: Paul A. Clarke 
---
v2:
- Add DRN to returned FPSCR value.
- Add DRN defines to target/ppc/cpu.h.

 target/ppc/cpu.h   | 10 +-
 target/ppc/dfp_helper.c|  2 +-
 target/ppc/internal.h  |  3 ++
 target/ppc/translate/fp-impl.inc.c | 67 ++
 target/ppc/translate/fp-ops.inc.c  |  4 +++
 5 files changed, 84 insertions(+), 2 deletions(-)

diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
index eaee1a5..dcea2f0 100644
--- a/target/ppc/cpu.h
+++ b/target/ppc/cpu.h
@@ -559,6 +559,9 @@ enum {
 
 /*/
 /* Floating point status and control register*/
+#define FPSCR_DRN2   34 /* Decimal Floating-Point rounding control   */
+#define FPSCR_DRN1   33 /* Decimal Floating-Point rounding control   */
+#define FPSCR_DRN0   32 /* Decimal Floating-Point rounding control   */
 #define FPSCR_FX 31 /* Floating-point exception summary  */
 #define FPSCR_FEX30 /* Floating-point enabled exception summary  */
 #define FPSCR_VX 29 /* Floating-point invalid operation exception summ.  */
@@ -592,6 +595,7 @@ enum {
 #define FPSCR_NI 2  /* Floating-point non-IEEE mode  */
 #define FPSCR_RN11
 #define FPSCR_RN00  /* Floating-point rounding control   */
+#define fpscr_drn(((env->fpscr) & FP_DRN) >> FPSCR_DRN0)
 #define fpscr_fex(((env->fpscr) >> FPSCR_FEX)& 0x1)
 #define fpscr_vx (((env->fpscr) >> FPSCR_VX) & 0x1)
 #define fpscr_ox (((env->fpscr) >> FPSCR_OX) & 0x1)
@@ -627,6 +631,10 @@ enum {
 #define fpscr_eex (((env->fpscr) >> FPSCR_XX) & ((env->fpscr) >> FPSCR_XE) &  \
0x1F)
 
+#define FP_DRN2 (1ull << FPSCR_DRN2)
+#define FP_DRN1 (1ull << FPSCR_DRN1)
+#define FP_DRN0 (1ull << FPSCR_DRN0)
+#define FP_DRN  (FP_DRN2 | FP_DRN1 | FP_DRN0)
 #define FP_FX   (1ull << FPSCR_FX)
 #define FP_FEX  (1ull << FPSCR_FEX)
 #define FP_VX   (1ull << FPSCR_VX)
@@ -662,7 +670,7 @@ enum {
 #define FP_RN0  (1ull << FPSCR_RN0)
 #define FP_RN   (FP_RN1 | FP_RN0)
 
-#define FP_MODE FP_RN
+#define FP_MODE (FP_DRN | FP_RN)
 #define FP_ENABLES  (FP_VE | FP_OE | FP_UE | FP_ZE | FP_XE)
 #define FP_STATUS   (FP_FR | FP_FI | FP_FPRF)
 
diff --git a/target/ppc/dfp_helper.c b/target/ppc/dfp_helper.c
index f102177..da8e08a 100644
--- a/target/ppc/dfp_helper.c
+++ b/target/ppc/dfp_helper.c
@@ -48,7 +48,7 @@ static void dfp_prepare_rounding_mode(decContext *context, 
uint64_t fpscr)
 {
 enum rounding rnd;
 
-switch ((fpscr >> 32) & 0x7) {
+switch ((fpscr & FP_DRN) >> FPSCR_DRN0) {
 case 0:
 rnd = DEC_ROUND_HALF_EVEN;
 break;
diff --git a/target/ppc/internal.h b/target/ppc/internal.h
index d3d327e..15d655b 100644
--- a/target/ppc/internal.h
+++ b/target/ppc/internal.h
@@ -157,6 +157,9 @@ EXTRACT_HELPER(FPL, 25, 1);
 EXTRACT_HELPER(FPFLM, 17, 8);
 EXTRACT_HELPER(FPW, 16, 1);
 
+/* mffscrni */
+EXTRACT_HELPER(RM, 11, 2);
+
 /* addpcis */
 EXTRACT_HELPER_SPLIT_3(DX, 10, 6, 6, 5, 16, 1, 1, 0, 0)
 #if defined(TARGET_PPC64)
diff --git a/target/ppc/translate/fp-impl.inc.c 
b/target/ppc/translate/fp-impl.inc.c
index 7cd9d8d..59a4faf 100644
--- a/target/ppc/translate/fp-impl.inc.c
+++ b/target/ppc/translate/fp-impl.inc.c
@@ -639,6 +639,73 @@ static void gen_mffsl(DisasContext *ctx)
 tcg_temp_free_i64(t0);
 }
 
+static void gen_helper_mffscrn(DisasContext *ctx, TCGv_i64 t1)
+{
+TCGv_i64 t0 = tcg_temp_new_i64();
+TCGv_i32 mask = tcg_const_i32(0x0001);
+
+gen_reset_fpstatus();
+tcg_gen_extu_tl_i64(t0, cpu_fpscr);
+tcg_gen_andi_i64(t0, t0, FP_MODE | FP_ENABLES);
+set_fpr(rD(ctx->opcode), t0);
+
+/* Mask FPSCR value to clear RN.  */
+tcg_gen_andi_i64(t0, t0, ~FP_MODE);
+
+/* Merge RN into FPSCR value.  */
+tcg_gen_or_i64(t0, t0, t1);
+
+gen_helper_store_fpscr(cpu_env, t0, mask);
+
+tcg_temp_free_i32(mask);
+tcg_temp_free_i64(t0);
+}
+
+/* mffscrn */
+static void gen_mffscrn(DisasContext *ctx)
+{
+TCGv_i64 t1;
+
+if (unlikely(!(ctx->insns_flags2 & PPC2_ISA300))) {
+return gen_mffs(ctx);
+}
+
+if (unlikely(!ctx->fpu_enabled)) {
+gen_exception(ctx, POWERPC_EXCP_FPU);
+return;
+}
+
+t1 = tcg_temp_new_i64();
+

[Qemu-devel] [PATCH v2 2/2] ppc: Add support for 'mffsce' instruction

2019-09-16 Thread Paul A. Clarke
From: "Paul A. Clarke" 

ISA 3.0B added a set of Floating-Point Status and Control Register (FPSCR)
instructions: mffsce, mffscdrn, mffscdrni, mffscrn, mffscrni, mffsl.
This patch adds support for 'mffsce' instruction.

'mffsce' is identical to 'mffs', except that it also clears the exception
enable bits in the FPSCR.

On CPUs without support for 'mffsce' (below ISA 3.0), the
instruction will execute identically to 'mffs'.

Signed-off-by: Paul A. Clarke 
---
v2: no changes.

 target/ppc/translate/fp-impl.inc.c | 30 ++
 target/ppc/translate/fp-ops.inc.c  |  2 ++
 2 files changed, 32 insertions(+)

diff --git a/target/ppc/translate/fp-impl.inc.c 
b/target/ppc/translate/fp-impl.inc.c
index 59a4faf..34edc45 100644
--- a/target/ppc/translate/fp-impl.inc.c
+++ b/target/ppc/translate/fp-impl.inc.c
@@ -639,6 +639,36 @@ static void gen_mffsl(DisasContext *ctx)
 tcg_temp_free_i64(t0);
 }
 
+/* mffsce */
+static void gen_mffsce(DisasContext *ctx)
+{
+TCGv_i64 t0;
+TCGv_i32 mask;
+
+if (unlikely(!(ctx->insns_flags2 & PPC2_ISA300))) {
+return gen_mffs(ctx);
+}
+
+if (unlikely(!ctx->fpu_enabled)) {
+gen_exception(ctx, POWERPC_EXCP_FPU);
+return;
+}
+
+t0 = tcg_temp_new_i64();
+
+gen_reset_fpstatus();
+tcg_gen_extu_tl_i64(t0, cpu_fpscr);
+set_fpr(rD(ctx->opcode), t0);
+
+/* Clear exception enable bits in the FPSCR.  */
+tcg_gen_andi_i64(t0, t0, ~FP_ENABLES);
+mask = tcg_const_i32(0x0003);
+gen_helper_store_fpscr(cpu_env, t0, mask);
+
+tcg_temp_free_i32(mask);
+tcg_temp_free_i64(t0);
+}
+
 static void gen_helper_mffscrn(DisasContext *ctx, TCGv_i64 t1)
 {
 TCGv_i64 t0 = tcg_temp_new_i64();
diff --git a/target/ppc/translate/fp-ops.inc.c 
b/target/ppc/translate/fp-ops.inc.c
index f2bcf0e..88fab65 100644
--- a/target/ppc/translate/fp-ops.inc.c
+++ b/target/ppc/translate/fp-ops.inc.c
@@ -105,6 +105,8 @@ GEN_HANDLER_E(fmrgew, 0x3F, 0x06, 0x1E, 0x0001, 
PPC_NONE, PPC2_VSX207),
 GEN_HANDLER_E(fmrgow, 0x3F, 0x06, 0x1A, 0x0001, PPC_NONE, PPC2_VSX207),
 GEN_HANDLER(mcrfs, 0x3F, 0x00, 0x02, 0x0063F801, PPC_FLOAT),
 GEN_HANDLER_E_2(mffs, 0x3F, 0x07, 0x12, 0x00, 0x, PPC_FLOAT, PPC_NONE),
+GEN_HANDLER_E_2(mffsce, 0x3F, 0x07, 0x12, 0x01, 0x, PPC_FLOAT,
+PPC2_ISA300),
 GEN_HANDLER_E_2(mffsl, 0x3F, 0x07, 0x12, 0x18, 0x, PPC_FLOAT,
 PPC2_ISA300),
 GEN_HANDLER_E_2(mffscrn, 0x3F, 0x07, 0x12, 0x16, 0x, PPC_FLOAT,
-- 
1.8.3.1




[Qemu-devel] [PATCH] Acceptance tests: refactor wait_for_console_pattern

2019-09-16 Thread Cleber Rosa
The same utility method is already present in two different test
files, so let's consolidate it into a single utility function.

Signed-off-by: Cleber Rosa 
---
 tests/acceptance/avocado_qemu/__init__.py | 26 +
 tests/acceptance/boot_linux_console.py| 47 +++
 tests/acceptance/linux_ssh_mips_malta.py  | 18 ++---
 3 files changed, 42 insertions(+), 49 deletions(-)

diff --git a/tests/acceptance/avocado_qemu/__init__.py 
b/tests/acceptance/avocado_qemu/__init__.py
index bd41e0443c..a0fe16e47f 100644
--- a/tests/acceptance/avocado_qemu/__init__.py
+++ b/tests/acceptance/avocado_qemu/__init__.py
@@ -8,6 +8,7 @@
 # This work is licensed under the terms of the GNU GPL, version 2 or
 # later.  See the COPYING file in the top-level directory.
 
+import logging
 import os
 import sys
 import uuid
@@ -53,6 +54,31 @@ def pick_default_qemu_bin(arch=None):
 return qemu_bin_from_src_dir_path
 
 
+def wait_for_console_pattern(test, success_message,
+ failure_message='Kernel panic - not syncing'):
+"""
+Waits for messages to appear on the console, while logging the content
+
+:param test: an Avocado test containing a VM that will have its console
+ read and probed for a success or failure message
+:type test: :class:`avocado_qemu.Test`
+:param success_message: if this message appears, test succeeds
+:param failure_message: if this message appears, test fails
+"""
+console = test.vm.console_socket.makefile()
+console_logger = logging.getLogger('console')
+while True:
+msg = console.readline().strip()
+if not msg:
+continue
+console_logger.debug(msg)
+if success_message in msg:
+break
+if failure_message in msg:
+fail = 'Failure message found in console: %s' % failure_message
+test.fail(fail)
+
+
 class Test(avocado.Test):
 def setUp(self):
 self._vms = {}
diff --git a/tests/acceptance/boot_linux_console.py 
b/tests/acceptance/boot_linux_console.py
index 8a9a314ab4..9ff2213874 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -9,12 +9,12 @@
 # later.  See the COPYING file in the top-level directory.
 
 import os
-import logging
 import lzma
 import gzip
 import shutil
 
 from avocado_qemu import Test
+from avocado_qemu import wait_for_console_pattern
 from avocado.utils import process
 from avocado.utils import archive
 
@@ -29,31 +29,10 @@ class BootLinuxConsole(Test):
 
 KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
 
-def wait_for_console_pattern(self, success_message,
- failure_message='Kernel panic - not syncing'):
-"""
-Waits for messages to appear on the console, while logging the content
-
-:param success_message: if this message appears, test succeeds
-:param failure_message: if this message appears, test fails
-"""
-console = self.vm.console_socket.makefile()
-console_logger = logging.getLogger('console')
-while True:
-msg = console.readline().strip()
-if not msg:
-continue
-console_logger.debug(msg)
-if success_message in msg:
-break
-if failure_message in msg:
-fail = 'Failure message found in console: %s' % failure_message
-self.fail(fail)
-
 def exec_command_and_wait_for_pattern(self, command, success_message):
 command += '\n'
 self.vm.console_socket.sendall(command.encode())
-self.wait_for_console_pattern(success_message)
+wait_for_console_pattern(self, success_message)
 
 def extract_from_deb(self, deb, path):
 """
@@ -89,7 +68,7 @@ class BootLinuxConsole(Test):
  '-append', kernel_command_line)
 self.vm.launch()
 console_pattern = 'Kernel command line: %s' % kernel_command_line
-self.wait_for_console_pattern(console_pattern)
+wait_for_console_pattern(self, console_pattern)
 
 def test_mips_malta(self):
 """
@@ -112,7 +91,7 @@ class BootLinuxConsole(Test):
  '-append', kernel_command_line)
 self.vm.launch()
 console_pattern = 'Kernel command line: %s' % kernel_command_line
-self.wait_for_console_pattern(console_pattern)
+wait_for_console_pattern(self, console_pattern)
 
 def test_mips64el_malta(self):
 """
@@ -145,7 +124,7 @@ class BootLinuxConsole(Test):
  '-append', kernel_command_line)
 self.vm.launch()
 console_pattern = 'Kernel command line: %s' % kernel_command_line
-self.wait_for_console_pattern(console_pattern)
+wait_for_console_pattern(self, console_pattern)
 
 def test_mips_malta_cpio(self):
 """
@@ -181,7 +160,7 @@ class BootLinuxConsole(Test):
 

Re: [Qemu-devel] [PATCH v4 1/4] iotests: add script_initialize

2019-09-16 Thread Vladimir Sementsov-Ogievskiy
16.09.2019 19:32, John Snow wrote:
> 
> 
> On 9/16/19 10:56 AM, Vladimir Sementsov-Ogievskiy wrote:
>> 12.09.2019 3:16, John Snow wrote:
>>> Like script_main, but doesn't require a single point of entry.
>>> Replace all existing initialization sections with this drop-in replacement.
>>>
>>> This brings debug support to all existing script-style iotests.
>>>
>>> Note: supported_oses=['linux'] was omitted, as it is a default argument.
>>
>> But after this patch all test which didn't check os start to check linux
>> (as it's default).. So all tests which worked on other platforms will now
>> be skipped on these other platforms?
>>
> 
> def verify_platform(supported_oses=['linux']):
>  if True not in [sys.platform.startswith(x) for x in supported_oses]:
>  notrun('not suitable for this OS: %s' % sys.platform)
> 
> 
> It was already the default. I didn't *make* it the default.

Yes. But for some tests, verify_platform wasn't called before this patch at all.
And now it is called and checks "linux". It's the change. Or what I miss?

> There is no
> change here. Feel free to propose a fix, but I don't think it's within
> the scope of this series.
> 
>> Finally do we support something except linux for iotests?
>> for bash tests _supported_os also used only with "Linux" in 87 tests..
>>
> 
> Evidently, not really. See bc521696607c5348fcd8a9e57b408d0ac0dbe2f8
> 
>> May be we'd better drop both _supported_os and supported_oses alltogether,
>> and don't care?
>>
> 
> Beyond the scope of this series.
> 
>> Anyway, if we support only linux, any reason to skip almost all tests,
>> if someone tries to run test on other platform? Let him run what he wants.
> 
> Maybe true, maybe not.
> 
>>
>>> Signed-off-by: John Snow 
>>> ---
>>
>> [..]
>>
>>> +def execute_test(test_function=None, *args, **kwargs):
>>> +"""Run either unittest or script-style tests."""
>>> +
>>> +debug = execute_setup_common(*args, **kwargs)
>>>if not test_function:
>>> -execute_unittest(output, verbosity, debug)
>>> +execute_unittest(debug)
>>>else:
>>>test_function()
>>>
>>> +# This is called from script-style iotests without a single point of entry
>>> +def script_initialize(*args, **kwargs):
>>> +"""Initialize script-style tests without running any tests."""
>>> +execute_setup_common(*args, **kwargs)
>>> +
>>> +# This is called from script-style iotests with a single point of entry
>>>def script_main(test_function, *args, **kwargs):
>>>"""Run script-style tests outside of the unittest framework"""
>>>execute_test(test_function, *args, **kwargs)
>>>
>>> +# This is called from unittest style iotests
>>>def main(*args, **kwargs):
>>>"""Run tests using the unittest framework"""
>>
>>
>> Hmm, now two different styles of code documenting used: comment and 
>> doc-string,
>> both containing almost equal meaning.. I don't like it, still don't really 
>> mind.
> 
> I think I was trying to document what the function /does/ separately
> from a note about explaining how and where it is used. It's quite nearly
> redundant and if it's distracting I can remove it.
> 


-- 
Best regards,
Vladimir


Re: [Qemu-devel] [PATCH v2] util/hbitmap: strict hbitmap_reset

2019-09-16 Thread John Snow



On 9/16/19 4:00 AM, Kevin Wolf wrote:
> Am 13.09.2019 um 20:49 hat John Snow geschrieben:
>> On 9/12/19 4:20 AM, Vladimir Sementsov-Ogievskiy wrote:
>>> Also, I'm not sure about "are" suggested by Max. "are" is for plural, but 
>>> here I meant
>>> one object: sum of @start and @count.
>>>
>>
>> There's not great agreement universally about how to treat things like
>> collective nouns. Sometimes "Data" is singular, but sometimes it's
>> plural. "It depends."
>>
>> In this case, "start + count" refers to one sum, but two constituent
>> pieces, so it's functioning like a collective noun.
>>
>> We might say "a + b (together) /are/ ..." but also "the sum of a + b /is/".
>>
>>> So, you may use exactly "Sum of @start and @count is" or "(@start + @count) 
>>> sum is" or
>>> just "(@start + @count) is", whichever you like more.
>>>
>>
>> I like using "the sum of @x and @y is" for being grammatically unambiguous.
>>
>> updated and pushed.
>>
>> (Sorry about my language again! --js)
> 
> Time to revive https://patchwork.kernel.org/patch/8725621/? ;-)
> 
> Kevin
> 

Ja, bitte.



Re: [Qemu-devel] [PATCH v2 0/1] Handle /proc/self/exe in execve

2019-09-16 Thread no-reply
Patchew URL: 
https://patchew.org/QEMU/20190916155545.29928-1-olivier.d...@polymtl.ca/



Hi,

This series failed build test on FreeBSD host. Please find the details below.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
# Testing script will be invoked under the git checkout with
# HEAD pointing to a commit that has the patches applied on top of "base"
# branch
if qemu-system-x86_64 --help >/dev/null 2>&1; then
  QEMU=qemu-system-x86_64
elif /usr/libexec/qemu-kvm --help >/dev/null 2>&1; then
  QEMU=/usr/libexec/qemu-kvm
else
  exit 1
fi
make vm-build-freebsd J=21 QEMU=$QEMU
exit 0
=== TEST SCRIPT END ===




The full log is available at
http://patchew.org/logs/20190916155545.29928-1-olivier.d...@polymtl.ca/testing.FreeBSD/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-de...@redhat.com

Re: [Qemu-devel] [PATCH v2 1/2] trace: Remove trailing newline in events

2019-09-16 Thread Eric Blake
On 9/16/19 4:51 AM, Philippe Mathieu-Daudé wrote:
> While the tracing frawework does not forbid trailing newline in

framework

> events format string, using them lead to confuse output.
> It is the responsibility of the backend to properly end an event
> line.

Why just trailing newline? Should we not forbid ALL use of newline in a
trace message?

> 
> Some of our formats have trailing newlines, remove them.
> 
> Reviewed-by: John Snow 
> Reviewed-by: Kevin Wolf 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---


-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH v4 1/4] iotests: add script_initialize

2019-09-16 Thread John Snow



On 9/16/19 10:56 AM, Vladimir Sementsov-Ogievskiy wrote:
> 12.09.2019 3:16, John Snow wrote:
>> Like script_main, but doesn't require a single point of entry.
>> Replace all existing initialization sections with this drop-in replacement.
>>
>> This brings debug support to all existing script-style iotests.
>>
>> Note: supported_oses=['linux'] was omitted, as it is a default argument.
> 
> But after this patch all test which didn't check os start to check linux
> (as it's default).. So all tests which worked on other platforms will now
> be skipped on these other platforms?
> 

def verify_platform(supported_oses=['linux']):
if True not in [sys.platform.startswith(x) for x in supported_oses]:
notrun('not suitable for this OS: %s' % sys.platform)


It was already the default. I didn't *make* it the default. There is no
change here. Feel free to propose a fix, but I don't think it's within
the scope of this series.

> Finally do we support something except linux for iotests?
> for bash tests _supported_os also used only with "Linux" in 87 tests..
> 

Evidently, not really. See bc521696607c5348fcd8a9e57b408d0ac0dbe2f8

> May be we'd better drop both _supported_os and supported_oses alltogether,
> and don't care?
> 

Beyond the scope of this series.

> Anyway, if we support only linux, any reason to skip almost all tests,
> if someone tries to run test on other platform? Let him run what he wants.

Maybe true, maybe not.

> 
>> Signed-off-by: John Snow 
>> ---
> 
> [..]
> 
>> +def execute_test(test_function=None, *args, **kwargs):
>> +"""Run either unittest or script-style tests."""
>> +
>> +debug = execute_setup_common(*args, **kwargs)
>>   if not test_function:
>> -execute_unittest(output, verbosity, debug)
>> +execute_unittest(debug)
>>   else:
>>   test_function()
>>   
>> +# This is called from script-style iotests without a single point of entry
>> +def script_initialize(*args, **kwargs):
>> +"""Initialize script-style tests without running any tests."""
>> +execute_setup_common(*args, **kwargs)
>> +
>> +# This is called from script-style iotests with a single point of entry
>>   def script_main(test_function, *args, **kwargs):
>>   """Run script-style tests outside of the unittest framework"""
>>   execute_test(test_function, *args, **kwargs)
>>   
>> +# This is called from unittest style iotests
>>   def main(*args, **kwargs):
>>   """Run tests using the unittest framework"""
> 
> 
> Hmm, now two different styles of code documenting used: comment and 
> doc-string,
> both containing almost equal meaning.. I don't like it, still don't really 
> mind.

I think I was trying to document what the function /does/ separately
from a note about explaining how and where it is used. It's quite nearly
redundant and if it's distracting I can remove it.



Re: [Qemu-devel] [PATCH v2 1/6] tests/acceptance: Add test that runs NetBSD 4.0 installer on PRep/40p

2019-09-16 Thread Philippe Mathieu-Daudé
On 9/16/19 6:08 PM, Cleber Rosa wrote:
> On Sun, Sep 15, 2019 at 11:19:35PM +0200, Philippe Mathieu-Daudé wrote:
>> As of this commit, NetBSD 4.0 is very old. However it is enough to
>> test the PRep/40p machine.
>>
>> User case from:
>> http://mail-index.netbsd.org/port-prep/2017/04/11/msg000112.html
>>
>> Reviewed-by: Hervé Poussineau 
>> Signed-off-by: Philippe Mathieu-Daudé 
>> ---
>> Installers after 4.0 doesn't work anymore, not sure if this is a
>> problem from the QEMU model or from NetBSD.
>> ---
>>  MAINTAINERS  |  1 +
>>  tests/acceptance/ppc_prep_40p.py | 63 
>>  2 files changed, 64 insertions(+)
>>  create mode 100644 tests/acceptance/ppc_prep_40p.py
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index 50eaf005f4..ce809c7dee 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -1068,6 +1068,7 @@ F: hw/timer/m48t59-isa.c
>>  F: include/hw/isa/pc87312.h
>>  F: include/hw/timer/m48t59.h
>>  F: pc-bios/ppc_rom.bin
>> +F: tests/acceptance/machine_ppc_prep_40p.py
>>  
>>  sPAPR
>>  M: David Gibson 
>> diff --git a/tests/acceptance/ppc_prep_40p.py 
>> b/tests/acceptance/ppc_prep_40p.py
>> new file mode 100644
>> index 00..53f2d2ecf0
>> --- /dev/null
>> +++ b/tests/acceptance/ppc_prep_40p.py
>> @@ -0,0 +1,63 @@
>> +# Functional test that boots a PReP/40p machine and checks its serial 
>> console.
>> +#
>> +# Copyright (c) Philippe Mathieu-Daudé 
>> +#
>> +# This work is licensed under the terms of the GNU GPL, version 2 or
>> +# later. See the COPYING file in the top-level directory.
>> +
>> +import os
>> +import logging
>> +
>> +from avocado import skipIf
>> +from avocado_qemu import Test
>> +
>> +
>> +class IbmPrep40pMachine(Test):
>> +
>> +timeout = 60
>> +
>> +# TODO refactor to MachineTest
> 
> Your TODO is a clear sign of awareness of the duplicated code that
> follows.  The mention of a MachineTest points into the direction that
> I can see as the best final solution (that is, test classes that target
> specific test scenarions).
> 
> But, it may be a more effective refactor strategy, to simply turn the
> `wait_for_console_pattern` from a method into a utility function, and
> then the discussion of the common test classes (say MachineTest,
> GuestTest, MigrationTest) can follow later.

Yes, I'd like we clean this and make it robust, but for now, the more
tests we have, the better we can see how the common MachineTest should
be. Let's do this in another follow-up series.

>> +def wait_for_console_pattern(self, success_message, 
>> failure_message=None):
> 
> Following the previous suggestion, `self` would become something like `test`.
> 
>> +"""
>> +Waits for messages to appear on the console, while logging the 
>> content
>> +
> 
> Documented as something like:
> 
>   :param test: an Avocado test containing a VM that will have its console
>read and probed for a success or failure message
>   :type test: :class:`avocado_qemu.Test`
> 
>> +:param success_message: if this message appears, test succeeds
>> +:param failure_message: if this message appears, test fails
>> +"""
>> +console = self.vm.console_socket.makefile()
>> +console_logger = logging.getLogger('console')
>> +while True:
>> +msg = console.readline().strip()
>> +if not msg:
>> +continue
>> +console_logger.debug(msg)
>> +if success_message in msg:
>> +break
>> +if failure_message and failure_message in msg:
>> +fail = 'Failure message found in console: %s' % 
>> failure_message
>> +self.fail(fail)
>> +
>> +@skipIf(os.getenv('CONTINUOUS_INTEGRATION'), 'Running on Travis-CI')
>> +def test_factory_firmware_and_netbsd(self):
>> +"""
>> +:avocado: tags=arch:ppc
>> +:avocado: tags=machine:40p
>> +:avocado: tags=slowness:high
> 
> This is certainly a discussion in itself, but I wonder what is your
> criteria for definising the slowness level of a test.  FOY, this one
> takes me ~17 seconds on my local machine.

Ah, I was running this in my --enable-debug --enable-tcg-debug
out-of-tree directory, it takes >2min here.

>> +"""
>> +bios_url = ('ftp://ftp.boulder.ibm.com/rs6000/firmware/'
>> +'7020-40p/P12H0456.IMG')
>> +bios_hash = '1775face4e6dc27f3a6ed955ef6eb331bf817f03'
>> +bios_path = self.fetch_asset(bios_url, asset_hash=bios_hash)
>> +drive_url = ('https://ftp.netbsd.org/pub/NetBSD/NetBSD-archive/'
>> + 'NetBSD-4.0/prep/installation/floppy/generic_com0.fs')
>> +drive_hash = 'dbcfc09912e71bd5f0d82c7c1ee43082fb596ceb'
>> +drive_path = self.fetch_asset(drive_url, asset_hash=drive_hash)
>> +
>> +self.vm.set_machine('40p')
> 
> FIY, Avocado 72.0 (due Tomorrow) will have relaxed strictness for tags
> values.  That will allow us 

[Qemu-devel] [PATCH v2 0/1] Handle /proc/self/exe in execve

2019-09-16 Thread Olivier Dion
* Changes from v1

  - Introduce the patch as a bug fix, rather than a security fix
  - Use do_openat and safe_execveat instead of copying exec_path
  - Extensive test case example
  
* Test case

  I will present a short program that demonstrated the bug, i.e. what
  is the expected behavior and what really happens.  Then, I will
  explain how this patch fixes this bug.

** The program

   ---
   #include 
   #include 
   #include 


   static char *ARG0 = "STOP";
   static char *ARG1 = "-this-is-not-an-option";


   int main(int argc, char *argv[], char *envp[])
   {
   (void)argc;
   if (0 == strcmp(argv[0], ARG0))
   return 0;
   argv[0] = ARG0;
   argv[1] = ARG1;
   execve("/proc/self/exe", 
  (char **const)argv,
  (char **const)envp);
   return errno;
   }
   ---

   Note that in every cases, this program should be run with at least
   one argument, so that argv[1] points to something.

*** Expected behavior

   This program when run normally, i.e. without an emulator or with
   this patch applied, will run two times.  The first time, it will
   change its argv[0] and argv[1] and recursively call itself.  The
   second time, it will stop at the string comparaison between argv[0]
   and the sentinel ARG0, returning 0.  Thus, we expect the program to
   finish with error code 0 and nothing is printed to stdout

*** What really happens

   When emulated by qemu-user, this program will fail to call itself
   recursively and will instead call qemu-user.  This is where ARG1
   becomes useful.  It's indeed set to an option that is not supported
   by qemu-user, and thus we expected two things

   1) A message will be printed to stdout&|stderr
   2) A error code different from 0 will be returned

   For example, I get the following output with error code 1
   ---
   qemu: unknown option 'this-is-not-an-option'
   ---

*** Automated testing

The following is a quick bash script that demonstrates how to use
this test case.  I suppose here that qemu-user is the correct
emulator for the arch of the compiled program a.out.
--
#!/bin/bash
out=$(qemu-user ./a.out foo)
ret=0
if [[ $out != "" || $? != 0 ]]; then
ret=1
fi
exit $ret
--

* Fixing the bug

   This patch introduces the use of safe_execveat instead of
   safe_execve for the emulation of execve.  By using the do_openat
   function, we ensure that the executable file descriptor is really
   the one the user wants.


Olivier Dion (1):
  Handle /proc/self/exe in syscall execve

 linux-user/syscall.c | 16 +---
 1 file changed, 13 insertions(+), 3 deletions(-)

-- 
2.23.0




[Qemu-devel] [PATCH 13/13] hw/rtc/xlnx-zynqmp-rtc: Remove unused "ptimer.h" include

2019-09-16 Thread Philippe Mathieu-Daudé
The "hw/ptimer.h" header is not used, remove it.

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/rtc/xlnx-zynqmp-rtc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/rtc/xlnx-zynqmp-rtc.c b/hw/rtc/xlnx-zynqmp-rtc.c
index f9f09b7296..2bcd14d779 100644
--- a/hw/rtc/xlnx-zynqmp-rtc.c
+++ b/hw/rtc/xlnx-zynqmp-rtc.c
@@ -32,7 +32,6 @@
 #include "qemu/log.h"
 #include "qemu/module.h"
 #include "hw/irq.h"
-#include "hw/ptimer.h"
 #include "qemu/cutils.h"
 #include "sysemu/sysemu.h"
 #include "trace.h"
-- 
2.20.1




[Qemu-devel] [PATCH 12/13] hw/rtc/mc146818: Include mc146818rtc_regs.h a bit less

2019-09-16 Thread Philippe Mathieu-Daudé
Only 2 source files require the "mc146818rtc_regs.h" header.
Instead of having it processed 12 times, by all objects
using "mc146818rtc.h", include it directly where used.

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/rtc/mc146818rtc.c | 1 +
 hw/timer/hpet.c  | 1 +
 include/hw/rtc/mc146818rtc.h | 1 -
 3 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c
index ced15f764f..9d4ed54f65 100644
--- a/hw/rtc/mc146818rtc.c
+++ b/hw/rtc/mc146818rtc.c
@@ -35,6 +35,7 @@
 #include "sysemu/reset.h"
 #include "sysemu/runstate.h"
 #include "hw/rtc/mc146818rtc.h"
+#include "hw/rtc/mc146818rtc_regs.h"
 #include "migration/vmstate.h"
 #include "qapi/error.h"
 #include "qapi/qapi-commands-misc-target.h"
diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
index 02bf8a8ce8..9f17aaa278 100644
--- a/hw/timer/hpet.c
+++ b/hw/timer/hpet.c
@@ -34,6 +34,7 @@
 #include "hw/timer/hpet.h"
 #include "hw/sysbus.h"
 #include "hw/rtc/mc146818rtc.h"
+#include "hw/rtc/mc146818rtc_regs.h"
 #include "migration/vmstate.h"
 #include "hw/timer/i8254.h"
 
diff --git a/include/hw/rtc/mc146818rtc.h b/include/hw/rtc/mc146818rtc.h
index 888e04f9ab..09e273a2a1 100644
--- a/include/hw/rtc/mc146818rtc.h
+++ b/include/hw/rtc/mc146818rtc.h
@@ -26,7 +26,6 @@
 #define MC146818RTC_H
 
 #include "hw/isa/isa.h"
-#include "hw/rtc/mc146818rtc_regs.h"
 
 #define TYPE_MC146818_RTC "mc146818rtc"
 
-- 
2.20.1




Re: [Qemu-devel] [PATCH v2 1/2] trace: Remove trailing newline in events

2019-09-16 Thread Philippe Mathieu-Daudé
On 9/16/19 6:36 PM, Eric Blake wrote:
> On 9/16/19 4:51 AM, Philippe Mathieu-Daudé wrote:
>> While the tracing frawework does not forbid trailing newline in
> 
> framework
> 
>> events format string, using them lead to confuse output.
>> It is the responsibility of the backend to properly end an event
>> line.
> 
> Why just trailing newline? Should we not forbid ALL use of newline in a
> trace message?

I thought about it and forgot to add a comment when respining.
Yes, I think this is the right thing to enforce.
However it requires more cleanup, affecting more subsystems, so I'd
rather keep it for a follow-up series.

>>
>> Some of our formats have trailing newlines, remove them.
>>
>> Reviewed-by: John Snow 
>> Reviewed-by: Kevin Wolf 
>> Signed-off-by: Philippe Mathieu-Daudé 
>> ---



Re: [Qemu-devel] [PATCH v2 1/2] trace: Remove trailing newline in events

2019-09-16 Thread John Snow



On 9/16/19 12:40 PM, Philippe Mathieu-Daudé wrote:
> On 9/16/19 6:36 PM, Eric Blake wrote:
>> On 9/16/19 4:51 AM, Philippe Mathieu-Daudé wrote:
>>> While the tracing frawework does not forbid trailing newline in
>>
>> framework
>>
>>> events format string, using them lead to confuse output.
>>> It is the responsibility of the backend to properly end an event
>>> line.
>>
>> Why just trailing newline? Should we not forbid ALL use of newline in a
>> trace message?
> 
> I thought about it and forgot to add a comment when respining.
> Yes, I think this is the right thing to enforce.
> However it requires more cleanup, affecting more subsystems, so I'd
> rather keep it for a follow-up series.

What's the problem with using multi-line trace statements?
Does it interfere with non-printf backends?

(I think I intentionally use these for AHCI in a few places.)

--js



[Qemu-devel] [PATCH 08/13] hw: Move DS1338 device from hw/timer/ to hw/rtc/ subdirectory

2019-09-16 Thread Philippe Mathieu-Daudé
The DS1338 is a Real Time Clock, not a timer.
Move it under the hw/rtc/ subdirectory.

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/rtc/Kconfig | 4 
 hw/rtc/Makefile.objs   | 1 +
 hw/{timer => rtc}/ds1338.c | 0
 hw/timer/Kconfig   | 4 
 hw/timer/Makefile.objs | 1 -
 5 files changed, 5 insertions(+), 5 deletions(-)
 rename hw/{timer => rtc}/ds1338.c (100%)

diff --git a/hw/rtc/Kconfig b/hw/rtc/Kconfig
index dff9d60946..45daa8d655 100644
--- a/hw/rtc/Kconfig
+++ b/hw/rtc/Kconfig
@@ -1,3 +1,7 @@
+config DS1338
+bool
+depends on I2C
+
 config M41T80
 bool
 depends on I2C
diff --git a/hw/rtc/Makefile.objs b/hw/rtc/Makefile.objs
index 810a38ee7b..b195863291 100644
--- a/hw/rtc/Makefile.objs
+++ b/hw/rtc/Makefile.objs
@@ -1,3 +1,4 @@
+common-obj-$(CONFIG_DS1338) += ds1338.o
 common-obj-$(CONFIG_M41T80) += m41t80.o
 common-obj-$(CONFIG_M48T59) += m48t59.o
 ifeq ($(CONFIG_ISA_BUS),y)
diff --git a/hw/timer/ds1338.c b/hw/rtc/ds1338.c
similarity index 100%
rename from hw/timer/ds1338.c
rename to hw/rtc/ds1338.c
diff --git a/hw/timer/Kconfig b/hw/timer/Kconfig
index 9357875f28..a990f9fe35 100644
--- a/hw/timer/Kconfig
+++ b/hw/timer/Kconfig
@@ -9,10 +9,6 @@ config ARM_MPTIMER
 config A9_GTIMER
 bool
 
-config DS1338
-bool
-depends on I2C
-
 config HPET
 bool
 default y if PC
diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs
index 23be70b71d..70b61b69c7 100644
--- a/hw/timer/Makefile.objs
+++ b/hw/timer/Makefile.objs
@@ -3,7 +3,6 @@ common-obj-$(CONFIG_ARM_MPTIMER) += arm_mptimer.o
 common-obj-$(CONFIG_ARM_V7M) += armv7m_systick.o
 common-obj-$(CONFIG_A9_GTIMER) += a9gtimer.o
 common-obj-$(CONFIG_CADENCE) += cadence_ttc.o
-common-obj-$(CONFIG_DS1338) += ds1338.o
 common-obj-$(CONFIG_HPET) += hpet.o
 common-obj-$(CONFIG_I8254) += i8254_common.o i8254.o
 common-obj-$(CONFIG_PUV3) += puv3_ost.o
-- 
2.20.1




[Qemu-devel] [PATCH 07/13] hw: Move TWL92230 device from hw/timer/ to hw/rtc/ subdirectory

2019-09-16 Thread Philippe Mathieu-Daudé
The TWL92230 is an "energy management device" companion with
a RTC. Since we mostly model the RTC, move it under the hw/rtc/
subdirectory.

Signed-off-by: Philippe Mathieu-Daudé 
---
 MAINTAINERS  | 2 +-
 hw/rtc/Kconfig   | 4 
 hw/rtc/Makefile.objs | 1 +
 hw/{timer => rtc}/twl92230.c | 0
 hw/timer/Kconfig | 4 
 hw/timer/Makefile.objs   | 1 -
 6 files changed, 6 insertions(+), 6 deletions(-)
 rename hw/{timer => rtc}/twl92230.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index fb9a1ed075..d17058264b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -663,7 +663,7 @@ F: hw/display/blizzard.c
 F: hw/input/lm832x.c
 F: hw/input/tsc2005.c
 F: hw/misc/cbus.c
-F: hw/timer/twl92230.c
+F: hw/rtc/twl92230.c
 F: include/hw/display/blizzard.h
 F: include/hw/input/tsc2xxx.h
 F: include/hw/misc/cbus.h
diff --git a/hw/rtc/Kconfig b/hw/rtc/Kconfig
index cc7fead764..dff9d60946 100644
--- a/hw/rtc/Kconfig
+++ b/hw/rtc/Kconfig
@@ -8,6 +8,10 @@ config M48T59
 config PL031
 bool
 
+config TWL92230
+bool
+depends on I2C
+
 config MC146818RTC
 bool
 
diff --git a/hw/rtc/Makefile.objs b/hw/rtc/Makefile.objs
index 4621b37bc2..810a38ee7b 100644
--- a/hw/rtc/Makefile.objs
+++ b/hw/rtc/Makefile.objs
@@ -4,5 +4,6 @@ ifeq ($(CONFIG_ISA_BUS),y)
 common-obj-$(CONFIG_M48T59) += m48t59-isa.o
 endif
 common-obj-$(CONFIG_PL031) += pl031.o
+common-obj-$(CONFIG_TWL92230) += twl92230.o
 obj-$(CONFIG_MC146818RTC) += mc146818rtc.o
 common-obj-$(CONFIG_SUN4V_RTC) += sun4v-rtc.o
diff --git a/hw/timer/twl92230.c b/hw/rtc/twl92230.c
similarity index 100%
rename from hw/timer/twl92230.c
rename to hw/rtc/twl92230.c
diff --git a/hw/timer/Kconfig b/hw/timer/Kconfig
index b04c928136..9357875f28 100644
--- a/hw/timer/Kconfig
+++ b/hw/timer/Kconfig
@@ -20,10 +20,6 @@ config HPET
 config I8254
 bool
 
-config TWL92230
-bool
-depends on I2C
-
 config ALTERA_TIMER
 bool
 select PTIMER
diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs
index 034bd30255..23be70b71d 100644
--- a/hw/timer/Makefile.objs
+++ b/hw/timer/Makefile.objs
@@ -7,7 +7,6 @@ common-obj-$(CONFIG_DS1338) += ds1338.o
 common-obj-$(CONFIG_HPET) += hpet.o
 common-obj-$(CONFIG_I8254) += i8254_common.o i8254.o
 common-obj-$(CONFIG_PUV3) += puv3_ost.o
-common-obj-$(CONFIG_TWL92230) += twl92230.o
 common-obj-$(CONFIG_XILINX) += xilinx_timer.o
 common-obj-$(CONFIG_SLAVIO) += slavio_timer.o
 common-obj-$(CONFIG_ETRAXFS) += etraxfs_timer.o
-- 
2.20.1




[Qemu-devel] [PATCH 05/13] hw: Move M41T80 device from hw/timer/ to hw/rtc/ subdirectory

2019-09-16 Thread Philippe Mathieu-Daudé
The M41T80 is a Real Time Clock, not a timer.
Move it under the hw/rtc/ subdirectory.

Signed-off-by: Philippe Mathieu-Daudé 
---
 MAINTAINERS| 2 +-
 hw/rtc/Kconfig | 4 
 hw/rtc/Makefile.objs   | 1 +
 hw/{timer => rtc}/m41t80.c | 0
 hw/timer/Kconfig   | 4 
 hw/timer/Makefile.objs | 1 -
 6 files changed, 6 insertions(+), 6 deletions(-)
 rename hw/{timer => rtc}/m41t80.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 679b026fe0..fd68b2383a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1113,7 +1113,7 @@ F: hw/ppc/sam460ex.c
 F: hw/ppc/ppc440_pcix.c
 F: hw/display/sm501*
 F: hw/ide/sii3112.c
-F: hw/timer/m41t80.c
+F: hw/rtc/m41t80.c
 F: pc-bios/canyonlands.dt[sb]
 F: pc-bios/u-boot-sam460ex-20100605.bin
 F: roms/u-boot-sam460ex
diff --git a/hw/rtc/Kconfig b/hw/rtc/Kconfig
index 159c233517..434b20b2b1 100644
--- a/hw/rtc/Kconfig
+++ b/hw/rtc/Kconfig
@@ -1,3 +1,7 @@
+config M41T80
+bool
+depends on I2C
+
 config M48T59
 bool
 
diff --git a/hw/rtc/Makefile.objs b/hw/rtc/Makefile.objs
index c87f81405e..89e8e48c64 100644
--- a/hw/rtc/Makefile.objs
+++ b/hw/rtc/Makefile.objs
@@ -1,3 +1,4 @@
+common-obj-$(CONFIG_M41T80) += m41t80.o
 common-obj-$(CONFIG_M48T59) += m48t59.o
 ifeq ($(CONFIG_ISA_BUS),y)
 common-obj-$(CONFIG_M48T59) += m48t59-isa.o
diff --git a/hw/timer/m41t80.c b/hw/rtc/m41t80.c
similarity index 100%
rename from hw/timer/m41t80.c
rename to hw/rtc/m41t80.c
diff --git a/hw/timer/Kconfig b/hw/timer/Kconfig
index a57e9b59fc..a6b668b255 100644
--- a/hw/timer/Kconfig
+++ b/hw/timer/Kconfig
@@ -20,10 +20,6 @@ config HPET
 config I8254
 bool
 
-config M41T80
-bool
-depends on I2C
-
 config TWL92230
 bool
 depends on I2C
diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs
index fe2d1fbc40..2fb12162a6 100644
--- a/hw/timer/Makefile.objs
+++ b/hw/timer/Makefile.objs
@@ -6,7 +6,6 @@ common-obj-$(CONFIG_CADENCE) += cadence_ttc.o
 common-obj-$(CONFIG_DS1338) += ds1338.o
 common-obj-$(CONFIG_HPET) += hpet.o
 common-obj-$(CONFIG_I8254) += i8254_common.o i8254.o
-common-obj-$(CONFIG_M41T80) += m41t80.o
 common-obj-$(CONFIG_PUV3) += puv3_ost.o
 common-obj-$(CONFIG_TWL92230) += twl92230.o
 common-obj-$(CONFIG_XILINX) += xilinx_timer.o
-- 
2.20.1




[Qemu-devel] [PATCH v2 1/1] Handle /proc/self/exe in syscall execve

2019-09-16 Thread Olivier Dion
If not handled, QEMU will execve itself instead of the emulated
process.  The function do_openat already solves the /proc/self/exe
problem, so we can use it to get the executable file descriptor.  We
then make a safe call to execveat.

Note that safe_execve has been replaced by safe_execveat, since the
former is now useless.

Signed-off-by: Olivier Dion 
---
 linux-user/syscall.c | 16 +---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index e2af3c1494..68340bcb67 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -736,7 +736,7 @@ safe_syscall4(pid_t, wait4, pid_t, pid, int *, status, int, 
options, \
   struct rusage *, rusage)
 safe_syscall5(int, waitid, idtype_t, idtype, id_t, id, siginfo_t *, infop, \
   int, options, struct rusage *, rusage)
-safe_syscall3(int, execve, const char *, filename, char **, argv, char **, 
envp)
+safe_syscall5(int, execveat, int, dirfd, const char *, pathname, char **, 
argv, char **, envp, int, flags)
 safe_syscall6(int, pselect6, int, nfds, fd_set *, readfds, fd_set *, writefds, 
\
   fd_set *, exceptfds, struct timespec *, timeout, void *, sig)
 safe_syscall5(int, ppoll, struct pollfd *, ufds, unsigned int, nfds,
@@ -7507,8 +7507,18 @@ static abi_long do_syscall1(void *cpu_env, int num, 
abi_long arg1,
  * before the execve completes and makes it the other
  * program's problem.
  */
-ret = get_errno(safe_execve(p, argp, envp));
-unlock_user(p, arg1, 0);
+{
+int execfd = get_errno(do_openat(cpu_env, AT_FDCWD, p, O_PATH, 
0));
+unlock_user(p, arg1, 0);
+if (is_error(execfd)) {
+ret = execfd;
+goto execve_end;
+}
+ret = get_errno(safe_execveat(execfd, "",
+  argp, envp,
+  AT_EMPTY_PATH));
+close(execfd);
+}
 
 goto execve_end;
 
-- 
2.23.0




[Qemu-devel] [PATCH 03/13] hw: Move MC146818 device from hw/timer/ to hw/rtc/ subdirectory

2019-09-16 Thread Philippe Mathieu-Daudé
The MC146818 is a Real Time Clock, not a timer.
Move it under the hw/rtc/ subdirectory.

Signed-off-by: Philippe Mathieu-Daudé 
---
 MAINTAINERS  |  4 +--
 hw/alpha/dp264.c |  2 +-
 hw/hppa/machine.c|  2 +-
 hw/i386/acpi-build.c |  2 +-
 hw/i386/pc.c |  2 +-
 hw/i386/pc_q35.c |  2 +-
 hw/mips/mips_fulong2e.c  |  2 +-
 hw/mips/mips_jazz.c  |  2 +-
 hw/mips/mips_malta.c |  2 +-
 hw/mips/mips_r4k.c   |  2 +-
 hw/ppc/pnv.c |  2 +-
 hw/ppc/prep.c|  2 +-
 hw/rtc/Kconfig   |  3 ++
 hw/rtc/Makefile.objs |  1 +
 hw/{timer => rtc}/mc146818rtc.c  |  2 +-
 hw/timer/Kconfig |  3 --
 hw/timer/Makefile.objs   |  2 --
 hw/timer/hpet.c  |  2 +-
 include/hw/rtc/mc146818rtc.h | 38 
 include/hw/{timer => rtc}/mc146818rtc_regs.h |  1 +
 include/hw/timer/mc146818rtc.h   | 14 
 tests/rtc-test.c |  2 +-
 22 files changed, 59 insertions(+), 35 deletions(-)
 rename hw/{timer => rtc}/mc146818rtc.c (99%)
 create mode 100644 include/hw/rtc/mc146818rtc.h
 rename include/hw/{timer => rtc}/mc146818rtc_regs.h (98%)
 delete mode 100644 include/hw/timer/mc146818rtc.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 5562d2c6d0..481f2318cb 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1263,7 +1263,7 @@ F: hw/misc/debugexit.c
 F: hw/misc/pc-testdev.c
 F: hw/timer/hpet*
 F: hw/timer/i8254*
-F: hw/timer/mc146818rtc*
+F: hw/rtc/mc146818rtc*
 F: hw/watchdog/wdt_ib700.c
 F: hw/watchdog/wdt_i6300esb.c
 F: include/hw/display/vga.h
@@ -1275,7 +1275,7 @@ F: include/hw/isa/i8259_internal.h
 F: include/hw/isa/superio.h
 F: include/hw/timer/hpet.h
 F: include/hw/timer/i8254*
-F: include/hw/timer/mc146818rtc*
+F: include/hw/rtc/mc146818rtc*
 
 Machine core
 M: Eduardo Habkost 
diff --git a/hw/alpha/dp264.c b/hw/alpha/dp264.c
index 51feee8558..51b3cf7a61 100644
--- a/hw/alpha/dp264.c
+++ b/hw/alpha/dp264.c
@@ -14,7 +14,7 @@
 #include "alpha_sys.h"
 #include "qemu/error-report.h"
 #include "sysemu/sysemu.h"
-#include "hw/timer/mc146818rtc.h"
+#include "hw/rtc/mc146818rtc.h"
 #include "hw/ide.h"
 #include "hw/timer/i8254.h"
 #include "hw/isa/superio.h"
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index 2736ce835e..6598e2469d 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -12,7 +12,7 @@
 #include "qemu/error-report.h"
 #include "sysemu/reset.h"
 #include "sysemu/sysemu.h"
-#include "hw/timer/mc146818rtc.h"
+#include "hw/rtc/mc146818rtc.h"
 #include "hw/ide.h"
 #include "hw/timer/i8254.h"
 #include "hw/char/serial.h"
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index e54e571a75..44a8073507 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -45,7 +45,7 @@
 #include "hw/acpi/vmgenid.h"
 #include "hw/boards.h"
 #include "sysemu/tpm_backend.h"
-#include "hw/timer/mc146818rtc_regs.h"
+#include "hw/rtc/mc146818rtc_regs.h"
 #include "migration/vmstate.h"
 #include "hw/mem/memory-device.h"
 #include "sysemu/numa.h"
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index bad866fe44..beef7a992d 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -42,7 +42,7 @@
 #include "elf.h"
 #include "migration/vmstate.h"
 #include "multiboot.h"
-#include "hw/timer/mc146818rtc.h"
+#include "hw/rtc/mc146818rtc.h"
 #include "hw/dma/i8257.h"
 #include "hw/timer/i8254.h"
 #include "hw/input/i8042.h"
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index d4e8a1cb9f..a976af9a2a 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -33,7 +33,7 @@
 #include "hw/loader.h"
 #include "sysemu/arch_init.h"
 #include "hw/i2c/smbus_eeprom.h"
-#include "hw/timer/mc146818rtc.h"
+#include "hw/rtc/mc146818rtc.h"
 #include "hw/xen/xen.h"
 #include "sysemu/kvm.h"
 #include "kvm_i386.h"
diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c
index cf537dd7e6..03a27e1767 100644
--- a/hw/mips/mips_fulong2e.c
+++ b/hw/mips/mips_fulong2e.c
@@ -39,7 +39,7 @@
 #include "hw/ide.h"
 #include "elf.h"
 #include "hw/isa/vt82c686.h"
-#include "hw/timer/mc146818rtc.h"
+#include "hw/rtc/mc146818rtc.h"
 #include "hw/timer/i8254.h"
 #include "exec/address-spaces.h"
 #include "sysemu/qtest.h"
diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c
index c967b97d80..2811a4bd90 100644
--- a/hw/mips/mips_jazz.c
+++ b/hw/mips/mips_jazz.c
@@ -39,7 +39,7 @@
 #include "hw/scsi/esp.h"
 #include "hw/mips/bios.h"
 #include "hw/loader.h"
-#include "hw/timer/mc146818rtc.h"
+#include "hw/rtc/mc146818rtc.h"
 #include "hw/timer/i8254.h"
 #include "hw/display/vga.h"
 #include "hw/audio/pcspk.h"
diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
index 

[Qemu-devel] [PATCH 06/13] hw: Move sun4v hypervisor RTC from hw/timer/ to hw/rtc/ subdirectory

2019-09-16 Thread Philippe Mathieu-Daudé
Move RTC devices under the hw/rtc/ subdirectory.

Signed-off-by: Philippe Mathieu-Daudé 
---
 MAINTAINERS   |  4 ++--
 hw/rtc/Kconfig|  3 +++
 hw/rtc/Makefile.objs  |  1 +
 hw/{timer => rtc}/sun4v-rtc.c |  2 +-
 hw/rtc/trace-events   |  4 
 hw/sparc64/niagara.c  |  2 +-
 hw/timer/Kconfig  |  3 ---
 hw/timer/Makefile.objs|  1 -
 hw/timer/trace-events |  4 
 include/hw/rtc/sun4v-rtc.h| 19 +++
 include/hw/timer/sun4v-rtc.h  |  1 -
 11 files changed, 31 insertions(+), 13 deletions(-)
 rename hw/{timer => rtc}/sun4v-rtc.c (98%)
 create mode 100644 include/hw/rtc/sun4v-rtc.h
 delete mode 100644 include/hw/timer/sun4v-rtc.h

diff --git a/MAINTAINERS b/MAINTAINERS
index fd68b2383a..fb9a1ed075 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1165,8 +1165,8 @@ Sun4v
 M: Artyom Tarasenko 
 S: Maintained
 F: hw/sparc64/niagara.c
-F: hw/timer/sun4v-rtc.c
-F: include/hw/timer/sun4v-rtc.h
+F: hw/rtc/sun4v-rtc.c
+F: include/hw/rtc/sun4v-rtc.h
 
 Leon3
 M: Fabien Chouteau 
diff --git a/hw/rtc/Kconfig b/hw/rtc/Kconfig
index 434b20b2b1..cc7fead764 100644
--- a/hw/rtc/Kconfig
+++ b/hw/rtc/Kconfig
@@ -10,3 +10,6 @@ config PL031
 
 config MC146818RTC
 bool
+
+config SUN4V_RTC
+bool
diff --git a/hw/rtc/Makefile.objs b/hw/rtc/Makefile.objs
index 89e8e48c64..4621b37bc2 100644
--- a/hw/rtc/Makefile.objs
+++ b/hw/rtc/Makefile.objs
@@ -5,3 +5,4 @@ common-obj-$(CONFIG_M48T59) += m48t59-isa.o
 endif
 common-obj-$(CONFIG_PL031) += pl031.o
 obj-$(CONFIG_MC146818RTC) += mc146818rtc.o
+common-obj-$(CONFIG_SUN4V_RTC) += sun4v-rtc.o
diff --git a/hw/timer/sun4v-rtc.c b/hw/rtc/sun4v-rtc.c
similarity index 98%
rename from hw/timer/sun4v-rtc.c
rename to hw/rtc/sun4v-rtc.c
index 54272a822f..ada01b5774 100644
--- a/hw/timer/sun4v-rtc.c
+++ b/hw/rtc/sun4v-rtc.c
@@ -13,7 +13,7 @@
 #include "hw/sysbus.h"
 #include "qemu/module.h"
 #include "qemu/timer.h"
-#include "hw/timer/sun4v-rtc.h"
+#include "hw/rtc/sun4v-rtc.h"
 #include "trace.h"
 
 
diff --git a/hw/rtc/trace-events b/hw/rtc/trace-events
index 54c94ac557..ac9e0e0fba 100644
--- a/hw/rtc/trace-events
+++ b/hw/rtc/trace-events
@@ -1,5 +1,9 @@
 # See docs/devel/tracing.txt for syntax documentation.
 
+# sun4v-rtc.c
+sun4v_rtc_read(uint64_t addr, uint64_t value) "read: addr 0x%" PRIx64 " value 
0x%" PRIx64
+sun4v_rtc_write(uint64_t addr, uint64_t value) "write: addr 0x%" PRIx64 " 
value 0x%" PRIx64
+
 # pl031.c
 pl031_irq_state(int level) "irq state %d"
 pl031_read(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x"
diff --git a/hw/sparc64/niagara.c b/hw/sparc64/niagara.c
index 167143bffe..dfa0817eae 100644
--- a/hw/sparc64/niagara.c
+++ b/hw/sparc64/niagara.c
@@ -30,7 +30,7 @@
 #include "hw/misc/unimp.h"
 #include "hw/loader.h"
 #include "hw/sparc/sparc64.h"
-#include "hw/timer/sun4v-rtc.h"
+#include "hw/rtc/sun4v-rtc.h"
 #include "exec/address-spaces.h"
 #include "sysemu/block-backend.h"
 #include "qemu/error-report.h"
diff --git a/hw/timer/Kconfig b/hw/timer/Kconfig
index a6b668b255..b04c928136 100644
--- a/hw/timer/Kconfig
+++ b/hw/timer/Kconfig
@@ -35,9 +35,6 @@ config ALLWINNER_A10_PIT
 config STM32F2XX_TIMER
 bool
 
-config SUN4V_RTC
-bool
-
 config CMSDK_APB_TIMER
 bool
 select PTIMER
diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs
index 2fb12162a6..034bd30255 100644
--- a/hw/timer/Makefile.objs
+++ b/hw/timer/Makefile.objs
@@ -35,7 +35,6 @@ common-obj-$(CONFIG_ALLWINNER_A10_PIT) += allwinner-a10-pit.o
 common-obj-$(CONFIG_STM32F2XX_TIMER) += stm32f2xx_timer.o
 common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o aspeed_rtc.o
 
-common-obj-$(CONFIG_SUN4V_RTC) += sun4v-rtc.o
 common-obj-$(CONFIG_CMSDK_APB_TIMER) += cmsdk-apb-timer.o
 common-obj-$(CONFIG_CMSDK_APB_DUALTIMER) += cmsdk-apb-dualtimer.o
 common-obj-$(CONFIG_MSF2) += mss-timer.o
diff --git a/hw/timer/trace-events b/hw/timer/trace-events
index 6936fe8573..ce34b967db 100644
--- a/hw/timer/trace-events
+++ b/hw/timer/trace-events
@@ -70,10 +70,6 @@ cmsdk_apb_dualtimer_reset(void) "CMSDK APB dualtimer: reset"
 aspeed_rtc_read(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 
0x%08" PRIx64
 aspeed_rtc_write(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 
0x%08" PRIx64
 
-# sun4v-rtc.c
-sun4v_rtc_read(uint64_t addr, uint64_t value) "read: addr 0x%" PRIx64 " value 
0x%" PRIx64
-sun4v_rtc_write(uint64_t addr, uint64_t value) "write: addr 0x%" PRIx64 " 
value 0x%" PRIx64
-
 # xlnx-zynqmp-rtc.c
 xlnx_zynqmp_rtc_gettime(int year, int month, int day, int hour, int min, int 
sec) "Get time from host: %d-%d-%d %2d:%02d:%02d"
 
diff --git a/include/hw/rtc/sun4v-rtc.h b/include/hw/rtc/sun4v-rtc.h
new file mode 100644
index 00..fd868f6ed2
--- /dev/null
+++ b/include/hw/rtc/sun4v-rtc.h
@@ -0,0 +1,19 @@
+/*
+ * QEMU sun4v Real Time Clock device
+ *
+ * The sun4v_rtc device (sun4v tod clock)
+ *
+ * Copyright (c) 2016 Artyom Tarasenko
+ *
+ * This code is licensed under 

Re: [Qemu-devel] [PATCH v2 0/6] tests/acceptance: Add tests for the PReP/40p machine

2019-09-16 Thread Eduardo Habkost
On Mon, Sep 16, 2019 at 11:28:23AM +0200, Philippe Mathieu-Daudé wrote:
> Hi David,
> 
> On 9/16/19 2:42 AM, David Gibson wrote:
> > On Sun, Sep 15, 2019 at 11:19:34PM +0200, Philippe Mathieu-Daudé wrote:
> >> Quick tests worth to avoid regressions with the 40p machine.
> >> idea from the "Maintainers, please tell us how to boot your machines"
> >> thread:
> >> https://lists.gnu.org/archive/html/qemu-devel/2019-03/msg04177.html
> >>
> >> v2: Split Travis job, added Hervé R-b tag
> >> v1: https://lists.gnu.org/archive/html/qemu-devel/2019-06/msg05896.html
> >>
> >> Regards,
> >>
> >> Phil.
> > 
> > I'm guessing you're expecting these to go in via the testing tree, in
> > which case
> > 
> > Acked-by: David Gibson 
> 
> Thanks, appreciated :)
> 
> > Or do you want me to take them via the ppc tree?
> 
> I think the 'testing tree' should focus on the CI/testing
> infrastructure, while each subsystem maintainers should care about the
> tests covering their subsystem (the testing tree maintainers might not
> have the required knowledge to be sure a test is correctly implemented).
> 
> In this particular case I assume you don't have much knowledge of that
> PPC machine, which is a hobbyist one, but since you are the PPC
> maintainer, I'd rather see this going via your tree :)
> 
> Alex/Cleber/Eduardo, any comment on this position?

This makes sense to me.  We don't need all new tests to go
through the same tree.

-- 
Eduardo



[Qemu-devel] [PATCH 04/13] hw: Move M48T59 device from hw/timer/ to hw/rtc/ subdirectory

2019-09-16 Thread Philippe Mathieu-Daudé
The M48T59 is a Real Time Clock, not a timer.
Move it under the hw/rtc/ subdirectory.

Signed-off-by: Philippe Mathieu-Daudé 
---
 MAINTAINERS |  4 +-
 hw/ppc/ppc405_boards.c  |  2 +-
 hw/ppc/prep.c   |  2 +-
 hw/rtc/Kconfig  |  3 ++
 hw/rtc/Makefile.objs|  4 ++
 hw/{timer => rtc}/m48t59-internal.h |  0
 hw/{timer => rtc}/m48t59-isa.c  |  4 +-
 hw/{timer => rtc}/m48t59.c  |  2 +-
 hw/sparc/sun4m.c|  2 +-
 hw/sparc64/sun4u.c  |  2 +-
 hw/timer/Kconfig|  3 --
 hw/timer/Makefile.objs  |  4 --
 include/hw/rtc/m48t59.h | 57 +
 13 files changed, 73 insertions(+), 16 deletions(-)
 rename hw/{timer => rtc}/m48t59-internal.h (100%)
 rename hw/{timer => rtc}/m48t59-isa.c (98%)
 rename hw/{timer => rtc}/m48t59.c (99%)
 create mode 100644 include/hw/rtc/m48t59.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 481f2318cb..679b026fe0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1064,9 +1064,9 @@ F: hw/pci-host/prep.[hc]
 F: hw/isa/i82378.c
 F: hw/isa/pc87312.c
 F: hw/dma/i82374.c
-F: hw/timer/m48t59-isa.c
+F: hw/rtc/m48t59-isa.c
 F: include/hw/isa/pc87312.h
-F: include/hw/timer/m48t59.h
+F: include/hw/rtc/m48t59.h
 F: pc-bios/ppc_rom.bin
 
 sPAPR
diff --git a/hw/ppc/ppc405_boards.c b/hw/ppc/ppc405_boards.c
index 388cae0b43..1f721feed6 100644
--- a/hw/ppc/ppc405_boards.c
+++ b/hw/ppc/ppc405_boards.c
@@ -29,7 +29,7 @@
 #include "cpu.h"
 #include "hw/ppc/ppc.h"
 #include "ppc405.h"
-#include "hw/timer/m48t59.h"
+#include "hw/rtc/m48t59.h"
 #include "hw/block/flash.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/qtest.h"
diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index 3a51536e1a..862345c2ac 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -25,7 +25,7 @@
 
 #include "qemu/osdep.h"
 #include "cpu.h"
-#include "hw/timer/m48t59.h"
+#include "hw/rtc/m48t59.h"
 #include "hw/char/serial.h"
 #include "hw/block/fdc.h"
 #include "net/net.h"
diff --git a/hw/rtc/Kconfig b/hw/rtc/Kconfig
index 7ffd702268..159c233517 100644
--- a/hw/rtc/Kconfig
+++ b/hw/rtc/Kconfig
@@ -1,3 +1,6 @@
+config M48T59
+bool
+
 config PL031
 bool
 
diff --git a/hw/rtc/Makefile.objs b/hw/rtc/Makefile.objs
index 3cac0d5a63..c87f81405e 100644
--- a/hw/rtc/Makefile.objs
+++ b/hw/rtc/Makefile.objs
@@ -1,2 +1,6 @@
+common-obj-$(CONFIG_M48T59) += m48t59.o
+ifeq ($(CONFIG_ISA_BUS),y)
+common-obj-$(CONFIG_M48T59) += m48t59-isa.o
+endif
 common-obj-$(CONFIG_PL031) += pl031.o
 obj-$(CONFIG_MC146818RTC) += mc146818rtc.o
diff --git a/hw/timer/m48t59-internal.h b/hw/rtc/m48t59-internal.h
similarity index 100%
rename from hw/timer/m48t59-internal.h
rename to hw/rtc/m48t59-internal.h
diff --git a/hw/timer/m48t59-isa.c b/hw/rtc/m48t59-isa.c
similarity index 98%
rename from hw/timer/m48t59-isa.c
rename to hw/rtc/m48t59-isa.c
index 5e5432abfd..7fde854c0f 100644
--- a/hw/timer/m48t59-isa.c
+++ b/hw/rtc/m48t59-isa.c
@@ -1,5 +1,5 @@
 /*
- * QEMU M48T59 and M48T08 NVRAM emulation (ISA bus interface
+ * QEMU M48T59 and M48T08 NVRAM emulation (ISA bus interface)
  *
  * Copyright (c) 2003-2005, 2007 Jocelyn Mayer
  * Copyright (c) 2013 Hervé Poussineau
@@ -26,7 +26,7 @@
 #include "qemu/osdep.h"
 #include "hw/isa/isa.h"
 #include "hw/qdev-properties.h"
-#include "hw/timer/m48t59.h"
+#include "hw/rtc/m48t59.h"
 #include "m48t59-internal.h"
 #include "qemu/module.h"
 
diff --git a/hw/timer/m48t59.c b/hw/rtc/m48t59.c
similarity index 99%
rename from hw/timer/m48t59.c
rename to hw/rtc/m48t59.c
index a9fc2f981a..fc592b9fb1 100644
--- a/hw/timer/m48t59.c
+++ b/hw/rtc/m48t59.c
@@ -27,7 +27,7 @@
 #include "qemu-common.h"
 #include "hw/irq.h"
 #include "hw/qdev-properties.h"
-#include "hw/timer/m48t59.h"
+#include "hw/rtc/m48t59.h"
 #include "qemu/timer.h"
 #include "sysemu/runstate.h"
 #include "sysemu/sysemu.h"
diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index 6c5a17a020..2aaa5bf1ae 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -31,7 +31,7 @@
 #include "qemu/error-report.h"
 #include "qemu/timer.h"
 #include "hw/sparc/sun4m_iommu.h"
-#include "hw/timer/m48t59.h"
+#include "hw/rtc/m48t59.h"
 #include "migration/vmstate.h"
 #include "hw/sparc/sparc32_dma.h"
 #include "hw/block/fdc.h"
diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index 1ded2a4c9a..955082773b 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -36,7 +36,7 @@
 #include "hw/pci-host/sabre.h"
 #include "hw/char/serial.h"
 #include "hw/char/parallel.h"
-#include "hw/timer/m48t59.h"
+#include "hw/rtc/m48t59.h"
 #include "migration/vmstate.h"
 #include "hw/input/i8042.h"
 #include "hw/block/fdc.h"
diff --git a/hw/timer/Kconfig b/hw/timer/Kconfig
index af415c8ef8..a57e9b59fc 100644
--- a/hw/timer/Kconfig
+++ b/hw/timer/Kconfig
@@ -24,9 +24,6 @@ config M41T80
 bool
 depends on I2C
 
-config M48T59
-bool
-
 config TWL92230
 bool
 depends on I2C
diff --git 

Re: [Qemu-devel] test-aio-multithread assertion

2019-09-16 Thread Stefan Hajnoczi
On Wed, Sep 04, 2019 at 12:50:21PM +0100, Peter Maydell wrote:
> Hi; I've been seeing intermittently on the BSDs this assertion
> running test-aio-multithread as part of 'make check':
> 
> MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}
> tests/test-aio-multithread -m=quick -k --tap < /dev/null |
> ./scripts/tap-drive
> r.pl --test-name="test-aio-multithread"
> PASS 1 test-aio-multithread /aio/multi/lifecycle
> PASS 2 test-aio-multithread /aio/multi/schedule
> ERROR - too few tests run (expected 5, got 2)
> Assertion failed: (!qemu_lockcnt_count(>list_lock)), function
> aio_ctx_finalize, file /home/qemu/qemu-test.kaRA0o/src/util/async.c,
> line 283.
> Abort trap (core dumped)
> gmake: *** [/home/qemu/qemu-test.kaRA0o/src/tests/Makefile.include:905:
> check-unit] Error 1
> 
> Anybody got any ideas?
> 
> (this is with the tests/vm setups; I've seen this on FreeBSD
> and NetBSD.)

Last week I triaged a ppc64le test-aio-multithread test_multi_fair_mutex
failure (race condition but reproduces after a few minutes) and sent it
on to Paolo.

I don't have time to investigate additional failures right now but
please keep reminding us if you encounter failures.

Stefan


signature.asc
Description: PGP signature


Re: [Qemu-devel] [PULL 00/16] Block patches

2019-09-16 Thread no-reply
Patchew URL: https://patchew.org/QEMU/20190916142246.31474-1-mre...@redhat.com/



Hi,

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

=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1
=== TEST SCRIPT END ===




The full log is available at
http://patchew.org/logs/20190916142246.31474-1-mre...@redhat.com/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-de...@redhat.com

Re: [Qemu-devel] [RFC v2 1/2] docs: vhost-user: add in-band kick/call messages

2019-09-16 Thread Michael S. Tsirkin
On Mon, Sep 16, 2019 at 01:40:35PM +0200, Johannes Berg wrote:
> Hi Michael,
> 
> I had just wanted to prepare a resend, but
> 
> > > Hmm I don't like this. I propose that with 
> > > VHOST_USER_PROTOCOL_F_IN_BAND_NOTIFICATIONS
> > > we just don't allow VHOST_USER_SET_VRING_CALL (if you think it's
> > > important to allow them, we can say that we do not require them).
> > 
> > You can't actually skip SET_VRING_CALL, it's necessary to start a vring,
> > so libvhost-user for example calls dev->iface->queue_set_started() only
> > in this case. The docs in the "Starting and stopping rings" section also
> > explain this.
> 
> [...]
> 
> > See above. But I guess we could put a flag into bit 9 indicating that
> > you want to use messages instead of polling or a file descriptor, if you
> > prefer.
> 
> Personally, I don't think it matters since right now I can see the in-
> band notification as being really necessary/useful only for simulation
> work, and in that case no polling will be doable.
> 
> If you do think it's important to not make the two mutually exclusive,
> how would you prefer to have this handled? With a new flag, e.g. in bit
> 9, indicating "use inband signalling instead of polling or eventfd"?
> 
> Thanks,
> johannes


So first we really need to fix up Starting and stopping section,
explaining that if the FD is invalid, this means ring
is immediately started, right?

If we want to keep it simple, my proposal is this, if
VHOST_USER_PROTOCOL_F_IN_BAND_NOTIFICATIONS is set then
VHOST_USER_SET_VRING_CALL and VHOST_USER_SET_VRING_KICK are not valid.
Starting/stopping ring needs to be updated, teaching it
that ring is started after it gets a kick.


-- 
MST




[Qemu-devel] [PATCH 11/13] hw: Move Aspeed RTC from hw/timer/ to hw/rtc/ subdirectory

2019-09-16 Thread Philippe Mathieu-Daudé
Move RTC devices under the hw/rtc/ subdirectory.

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/rtc/Makefile.objs   | 1 +
 hw/{timer => rtc}/aspeed_rtc.c | 2 +-
 hw/rtc/trace-events| 4 
 hw/timer/Makefile.objs | 2 +-
 hw/timer/trace-events  | 4 
 include/hw/arm/aspeed_soc.h| 2 +-
 include/hw/{timer => rtc}/aspeed_rtc.h | 3 ---
 7 files changed, 8 insertions(+), 10 deletions(-)
 rename hw/{timer => rtc}/aspeed_rtc.c (99%)
 rename include/hw/{timer => rtc}/aspeed_rtc.h (92%)

diff --git a/hw/rtc/Makefile.objs b/hw/rtc/Makefile.objs
index 3d4763fc26..8dc9fcd3a9 100644
--- a/hw/rtc/Makefile.objs
+++ b/hw/rtc/Makefile.objs
@@ -10,3 +10,4 @@ common-obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp-rtc.o
 common-obj-$(CONFIG_EXYNOS4) += exynos4210_rtc.o
 obj-$(CONFIG_MC146818RTC) += mc146818rtc.o
 common-obj-$(CONFIG_SUN4V_RTC) += sun4v-rtc.o
+common-obj-$(CONFIG_ASPEED_SOC) += aspeed_rtc.o
diff --git a/hw/timer/aspeed_rtc.c b/hw/rtc/aspeed_rtc.c
similarity index 99%
rename from hw/timer/aspeed_rtc.c
rename to hw/rtc/aspeed_rtc.c
index 5313017353..3ca1183558 100644
--- a/hw/timer/aspeed_rtc.c
+++ b/hw/rtc/aspeed_rtc.c
@@ -8,7 +8,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu-common.h"
-#include "hw/timer/aspeed_rtc.h"
+#include "hw/rtc/aspeed_rtc.h"
 #include "migration/vmstate.h"
 #include "qemu/log.h"
 #include "qemu/timer.h"
diff --git a/hw/rtc/trace-events b/hw/rtc/trace-events
index 7f1945ad4c..d6749f4616 100644
--- a/hw/rtc/trace-events
+++ b/hw/rtc/trace-events
@@ -13,3 +13,7 @@ pl031_read(uint32_t addr, uint32_t value) "addr 0x%08x value 
0x%08x"
 pl031_write(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x"
 pl031_alarm_raised(void) "alarm raised"
 pl031_set_alarm(uint32_t ticks) "alarm set for %u ticks"
+
+# aspeed-rtc.c
+aspeed_rtc_read(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 
0x%08" PRIx64
+aspeed_rtc_write(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 
0x%08" PRIx64
diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs
index 33191d74cb..83091770df 100644
--- a/hw/timer/Makefile.objs
+++ b/hw/timer/Makefile.objs
@@ -29,7 +29,7 @@ common-obj-$(CONFIG_MIPS_CPS) += mips_gictimer.o
 common-obj-$(CONFIG_ALLWINNER_A10_PIT) += allwinner-a10-pit.o
 
 common-obj-$(CONFIG_STM32F2XX_TIMER) += stm32f2xx_timer.o
-common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o aspeed_rtc.o
+common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o
 
 common-obj-$(CONFIG_CMSDK_APB_TIMER) += cmsdk-apb-timer.o
 common-obj-$(CONFIG_CMSDK_APB_DUALTIMER) += cmsdk-apb-dualtimer.o
diff --git a/hw/timer/trace-events b/hw/timer/trace-events
index 1459d07237..e18b87fc96 100644
--- a/hw/timer/trace-events
+++ b/hw/timer/trace-events
@@ -66,10 +66,6 @@ cmsdk_apb_dualtimer_read(uint64_t offset, uint64_t data, 
unsigned size) "CMSDK A
 cmsdk_apb_dualtimer_write(uint64_t offset, uint64_t data, unsigned size) 
"CMSDK APB dualtimer write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
 cmsdk_apb_dualtimer_reset(void) "CMSDK APB dualtimer: reset"
 
-# hw/timer/aspeed-rtc.c
-aspeed_rtc_read(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 
0x%08" PRIx64
-aspeed_rtc_write(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 
0x%08" PRIx64
-
 # nrf51_timer.c
 nrf51_timer_read(uint64_t addr, uint32_t value, unsigned size) "read addr 0x%" 
PRIx64 " data 0x%" PRIx32 " size %u"
 nrf51_timer_write(uint64_t addr, uint32_t value, unsigned size) "write addr 
0x%" PRIx64 " data 0x%" PRIx32 " size %u"
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
index ab5052b12c..5a443006ed 100644
--- a/include/hw/arm/aspeed_soc.h
+++ b/include/hw/arm/aspeed_soc.h
@@ -17,7 +17,7 @@
 #include "hw/misc/aspeed_sdmc.h"
 #include "hw/misc/aspeed_xdma.h"
 #include "hw/timer/aspeed_timer.h"
-#include "hw/timer/aspeed_rtc.h"
+#include "hw/rtc/aspeed_rtc.h"
 #include "hw/i2c/aspeed_i2c.h"
 #include "hw/ssi/aspeed_smc.h"
 #include "hw/watchdog/wdt_aspeed.h"
diff --git a/include/hw/timer/aspeed_rtc.h b/include/hw/rtc/aspeed_rtc.h
similarity index 92%
rename from include/hw/timer/aspeed_rtc.h
rename to include/hw/rtc/aspeed_rtc.h
index 15ba42912b..156c8faee3 100644
--- a/include/hw/timer/aspeed_rtc.h
+++ b/include/hw/rtc/aspeed_rtc.h
@@ -8,9 +8,6 @@
 #ifndef ASPEED_RTC_H
 #define ASPEED_RTC_H
 
-#include 
-
-#include "hw/irq.h"
 #include "hw/sysbus.h"
 
 typedef struct AspeedRtcState {
-- 
2.20.1




Re: [Qemu-devel] [PATCH v2 1/6] tests/acceptance: Add test that runs NetBSD 4.0 installer on PRep/40p

2019-09-16 Thread Cleber Rosa
On Sun, Sep 15, 2019 at 11:19:35PM +0200, Philippe Mathieu-Daudé wrote:
> As of this commit, NetBSD 4.0 is very old. However it is enough to
> test the PRep/40p machine.
> 
> User case from:
> http://mail-index.netbsd.org/port-prep/2017/04/11/msg000112.html
> 
> Reviewed-by: Hervé Poussineau 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
> Installers after 4.0 doesn't work anymore, not sure if this is a
> problem from the QEMU model or from NetBSD.
> ---
>  MAINTAINERS  |  1 +
>  tests/acceptance/ppc_prep_40p.py | 63 
>  2 files changed, 64 insertions(+)
>  create mode 100644 tests/acceptance/ppc_prep_40p.py
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 50eaf005f4..ce809c7dee 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1068,6 +1068,7 @@ F: hw/timer/m48t59-isa.c
>  F: include/hw/isa/pc87312.h
>  F: include/hw/timer/m48t59.h
>  F: pc-bios/ppc_rom.bin
> +F: tests/acceptance/machine_ppc_prep_40p.py
>  
>  sPAPR
>  M: David Gibson 
> diff --git a/tests/acceptance/ppc_prep_40p.py 
> b/tests/acceptance/ppc_prep_40p.py
> new file mode 100644
> index 00..53f2d2ecf0
> --- /dev/null
> +++ b/tests/acceptance/ppc_prep_40p.py
> @@ -0,0 +1,63 @@
> +# Functional test that boots a PReP/40p machine and checks its serial 
> console.
> +#
> +# Copyright (c) Philippe Mathieu-Daudé 
> +#
> +# This work is licensed under the terms of the GNU GPL, version 2 or
> +# later. See the COPYING file in the top-level directory.
> +
> +import os
> +import logging
> +
> +from avocado import skipIf
> +from avocado_qemu import Test
> +
> +
> +class IbmPrep40pMachine(Test):
> +
> +timeout = 60
> +
> +# TODO refactor to MachineTest

Your TODO is a clear sign of awareness of the duplicated code that
follows.  The mention of a MachineTest points into the direction that
I can see as the best final solution (that is, test classes that target
specific test scenarions).

But, it may be a more effective refactor strategy, to simply turn the
`wait_for_console_pattern` from a method into a utility function, and
then the discussion of the common test classes (say MachineTest,
GuestTest, MigrationTest) can follow later.

> +def wait_for_console_pattern(self, success_message, 
> failure_message=None):

Following the previous suggestion, `self` would become something like `test`.

> +"""
> +Waits for messages to appear on the console, while logging the 
> content
> +

Documented as something like:

  :param test: an Avocado test containing a VM that will have its console
   read and probed for a success or failure message
  :type test: :class:`avocado_qemu.Test`

> +:param success_message: if this message appears, test succeeds
> +:param failure_message: if this message appears, test fails
> +"""
> +console = self.vm.console_socket.makefile()
> +console_logger = logging.getLogger('console')
> +while True:
> +msg = console.readline().strip()
> +if not msg:
> +continue
> +console_logger.debug(msg)
> +if success_message in msg:
> +break
> +if failure_message and failure_message in msg:
> +fail = 'Failure message found in console: %s' % 
> failure_message
> +self.fail(fail)
> +
> +@skipIf(os.getenv('CONTINUOUS_INTEGRATION'), 'Running on Travis-CI')
> +def test_factory_firmware_and_netbsd(self):
> +"""
> +:avocado: tags=arch:ppc
> +:avocado: tags=machine:40p
> +:avocado: tags=slowness:high

This is certainly a discussion in itself, but I wonder what is your
criteria for definising the slowness level of a test.  FOY, this one
takes me ~17 seconds on my local machine.

> +"""
> +bios_url = ('ftp://ftp.boulder.ibm.com/rs6000/firmware/'
> +'7020-40p/P12H0456.IMG')
> +bios_hash = '1775face4e6dc27f3a6ed955ef6eb331bf817f03'
> +bios_path = self.fetch_asset(bios_url, asset_hash=bios_hash)
> +drive_url = ('https://ftp.netbsd.org/pub/NetBSD/NetBSD-archive/'
> + 'NetBSD-4.0/prep/installation/floppy/generic_com0.fs')
> +drive_hash = 'dbcfc09912e71bd5f0d82c7c1ee43082fb596ceb'
> +drive_path = self.fetch_asset(drive_url, asset_hash=drive_hash)
> +
> +self.vm.set_machine('40p')

FIY, Avocado 72.0 (due Tomorrow) will have relaxed strictness for tags
values.  That will allow us to represent all current machine type
names in ":avocado: tags=machine:$VALUE" (such as "s390-ccw-virtio").
Then we'll be able to reuse them here, avoiding a bit of boiler plate
code.

> +self.vm.set_console()
> +self.vm.add_args('-bios', bios_path,
> + '-fda', drive_path)
> +self.vm.launch()
> +os_banner = 'NetBSD 4.0 (GENERIC) #0: Sun Dec 16 00:49:40 PST 2007'
> +self.wait_for_console_pattern(os_banner)
> +

[Qemu-devel] [PULL v2 00/29] Misc patches for 2019-09-16

2019-09-16 Thread Paolo Bonzini
The following changes since commit 138985c1ef8b66e4e5b383354e133e05d01d0b5f:

  Merge remote-tracking branch 'remotes/amarkovic/tags/mips-queue-sep-12-2019' 
into staging (2019-09-13 16:04:46 +0100)

are available in the git repository at:


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

for you to fetch changes up to 149c50cabcc4ea46a460d35fc876346ed441304c:

  hw/i386/pc: Extract the x86 generic fw_cfg code (2019-09-16 17:13:09 +0200)


* Fix Patchew CI failures (myself)
* i386 fw_cfg refactoring (Philippe)
* pmem bugfix (Stefan)
* Support for accessing cstate MSRs (Wanpeng)
* exec.c cleanups (Wei Yang)
* Improved throttling (Yury)
* elf-ops.h coverity fix (Stefano)


v1->v2: missing S-o-b lines

Cole Robinson (1):
  hw/i386: Move CONFIG_ACPI_PCI to CONFIG_PC

Paolo Bonzini (4):
  win32: fix README file in NSIS installer
  test-char: fix AddressSanitizer failure
  memory: inline and optimize devend_memop
  hw/i386/pc: Replace PCMachineState argument with MachineState in 
fw_cfg_arch_create

Philippe Mathieu-Daudé (14):
  hw/i386/pc: Use e820_get_num_entries() to access e820_entries
  hw/i386/pc: Extract e820 memory layout code
  hw/i386/pc: Use address_space_memory in place
  hw/i386/pc: Rename bochs_bios_init as more generic fw_cfg_arch_create
  hw/i386/pc: Pass the boot_cpus value by argument
  hw/i386/pc: Pass the apic_id_limit value by argument
  hw/i386/pc: Pass the CPUArchIdList array by argument
  hw/i386/pc: Let pc_build_smbios() take a FWCfgState argument
  hw/i386/pc: Let pc_build_smbios() take a generic MachineState argument
  hw/i386/pc: Rename pc_build_smbios() as generic fw_cfg_build_smbios()
  hw/i386/pc: Let pc_build_feature_control() take a FWCfgState argument
  hw/i386/pc: Let pc_build_feature_control() take a MachineState argument
  hw/i386/pc: Rename pc_build_feature_control() as generic fw_cfg_build_*
  hw/i386/pc: Extract the x86 generic fw_cfg code

Stefan Hajnoczi (1):
  memory: fetch pmem size in get_file_size()

Stefano Garzarella (1):
  elf-ops.h: fix int overflow in load_elf()

Wanpeng Li (1):
  i386/kvm: support guest access CORE cstate

Wei Yang (5):
  exec.c: replace hwaddr with uint64_t for better understanding
  exec.c: get nodes_nb_alloc with one MAX calculation
  exec.c: subpage->sub_section is already initialized to 0
  exec.c: correct the maximum skip value during compact
  exec.c: add a check between constants to see whether we could skip

Yury Kotov (2):
  qemu-thread: Add qemu_cond_timedwait
  cpus: Fix throttling during vm_stop

 backends/hostmem-file.c  |  22 -
 cpus.c   |  25 +++--
 default-configs/i386-softmmu.mak |   1 -
 exec.c   |  54 ---
 hw/core/loader.c |   2 +
 hw/i386/Kconfig  |   1 +
 hw/i386/Makefile.objs|   2 +-
 hw/i386/e820_memory_layout.c |  59 +++
 hw/i386/e820_memory_layout.h |  42 
 hw/i386/fw_cfg.c | 137 ++
 hw/i386/fw_cfg.h |   7 ++
 hw/i386/pc.c | 204 ++-
 include/exec/memory.h|  19 +++-
 include/hw/elf_ops.h |   5 +
 include/hw/i386/pc.h |  11 ---
 include/hw/loader.h  |   1 +
 include/qemu/osdep.h |  13 ---
 include/qemu/thread.h|  19 
 linux-headers/linux/kvm.h|   4 +-
 memory.c |  18 
 qemu.nsi |   4 +-
 target/i386/kvm.c|   4 +-
 tests/test-char.c|  44 -
 util/oslib-posix.c   |  54 ---
 util/oslib-win32.c   |   6 --
 util/qemu-thread-posix.c |  41 +---
 util/qemu-thread-win32.c |  17 
 util/qsp.c   |  20 
 28 files changed, 456 insertions(+), 380 deletions(-)
 create mode 100644 hw/i386/e820_memory_layout.c
 create mode 100644 hw/i386/e820_memory_layout.h
-- 
1.8.3.1



Re: [Qemu-devel] [PATCH v4 1/4] iotests: add script_initialize

2019-09-16 Thread Vladimir Sementsov-Ogievskiy
12.09.2019 3:16, John Snow wrote:
> Like script_main, but doesn't require a single point of entry.
> Replace all existing initialization sections with this drop-in replacement.
> 
> This brings debug support to all existing script-style iotests.
> 
> Note: supported_oses=['linux'] was omitted, as it is a default argument.

But after this patch all test which didn't check os start to check linux
(as it's default).. So all tests which worked on other platforms will now
be skipped on these other platforms?

Finally do we support something except linux for iotests?
for bash tests _supported_os also used only with "Linux" in 87 tests..

May be we'd better drop both _supported_os and supported_oses alltogether,
and don't care?

Anyway, if we support only linux, any reason to skip almost all tests,
if someone tries to run test on other platform? Let him run what he wants.

> Signed-off-by: John Snow 
> ---

[..]

> +def execute_test(test_function=None, *args, **kwargs):
> +"""Run either unittest or script-style tests."""
> +
> +debug = execute_setup_common(*args, **kwargs)
>   if not test_function:
> -execute_unittest(output, verbosity, debug)
> +execute_unittest(debug)
>   else:
>   test_function()
>   
> +# This is called from script-style iotests without a single point of entry
> +def script_initialize(*args, **kwargs):
> +"""Initialize script-style tests without running any tests."""
> +execute_setup_common(*args, **kwargs)
> +
> +# This is called from script-style iotests with a single point of entry
>   def script_main(test_function, *args, **kwargs):
>   """Run script-style tests outside of the unittest framework"""
>   execute_test(test_function, *args, **kwargs)
>   
> +# This is called from unittest style iotests
>   def main(*args, **kwargs):
>   """Run tests using the unittest framework"""


Hmm, now two different styles of code documenting used: comment and doc-string,
both containing almost equal meaning.. I don't like it, still don't really mind.

>   execute_test(None, *args, **kwargs)
> 


-- 
Best regards,
Vladimir


Re: [Qemu-devel] [PATCH v1 02/28] target/riscv: Add the virtulisation mode

2019-09-16 Thread Alistair Francis
On Tue, Sep 10, 2019 at 6:44 AM Palmer Dabbelt  wrote:
>
> On Fri, 23 Aug 2019 16:37:54 PDT (-0700), Alistair Francis wrote:
> > Signed-off-by: Alistair Francis 
> > ---
> >  target/riscv/cpu.h|  4 
> >  target/riscv/cpu_bits.h   |  6 ++
> >  target/riscv/cpu_helper.c | 23 +++
> >  3 files changed, 33 insertions(+)
> >
> > diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
> > index 7f54fb8c87..0ef1ecb0e0 100644
> > --- a/target/riscv/cpu.h
> > +++ b/target/riscv/cpu.h
> > @@ -117,6 +117,8 @@ struct CPURISCVState {
> >
> >  #ifndef CONFIG_USER_ONLY
> >  target_ulong priv;
> > +/* This contains QEMU specific information about the virt state. */
> > +target_ulong virt;
> >  target_ulong resetvec;
> >
> >  target_ulong mhartid;
> > @@ -257,6 +259,8 @@ int riscv_cpu_gdb_read_register(CPUState *cpu, uint8_t 
> > *buf, int reg);
> >  int riscv_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
> >  bool riscv_cpu_exec_interrupt(CPUState *cs, int interrupt_request);
> >  bool riscv_cpu_fp_enabled(CPURISCVState *env);
> > +bool riscv_cpu_virt_enabled(CPURISCVState *env);
> > +void riscv_cpu_set_virt_enabled(CPURISCVState *env, bool enable);
> >  int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch);
> >  hwaddr riscv_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
> >  void  riscv_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
> > diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h
> > index e99834856c..1fbde516be 100644
> > --- a/target/riscv/cpu_bits.h
> > +++ b/target/riscv/cpu_bits.h
> > @@ -422,6 +422,12 @@
> >  #define PRV_H 2 /* Reserved */
> >  #define PRV_M 3
> >
> > +/* Virtulisation modes */
> > +#define VIRT_OFF0
> > +#define VIRT_ON 1
> > +#define VIRT_MODE_SHIFT 0
> > +#define VIRT_MODE_MASK  (1 << VIRT_MODE_SHIFT)
> > +
> >  /* RV32 satp CSR field masks */
> >  #define SATP32_MODE 0x8000
> >  #define SATP32_ASID 0x7fc0
> > diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
> > index 225e407cff..7b0bb14c01 100644
> > --- a/target/riscv/cpu_helper.c
> > +++ b/target/riscv/cpu_helper.c
> > @@ -81,6 +81,29 @@ bool riscv_cpu_fp_enabled(CPURISCVState *env)
> >  return false;
> >  }
> >
> > +bool riscv_cpu_virt_enabled(CPURISCVState *env)
> > +{
> > +bool tmp;
> > +
> > +if (!riscv_has_ext(env, RVH)) {
> > +return false;
> > +}
> > +
> > +tmp = (env->virt & VIRT_MODE_MASK) >> VIRT_MODE_SHIFT;
> > +
> > +return tmp == VIRT_ON;
> > +}
>
> extract64() is a bit cleaner.

I have already changed it to get_field() and set_field().

>
> > +
> > +void riscv_cpu_set_virt_enabled(CPURISCVState *env, bool enable)
> > +{
> > +if (!riscv_has_ext(env, RVH)) {
> > +return;
> > +}
> > +
> > +env->virt &= ~VIRT_MODE_MASK;
> > +env->virt |= enable << VIRT_MODE_SHIFT;
> > +}
> > +
> >  int riscv_cpu_claim_interrupts(RISCVCPU *cpu, uint32_t interrupts)
> >  {
> >  CPURISCVState *env = >env;
>
> Reviewed-by: Palmer Dabbelt 

This patch is a little out of date, so I'll not include your RB line in the v2.

Alistair



Re: [Qemu-devel] [PATCH qemu] loader: Trace loaded images

2019-09-16 Thread Stefan Hajnoczi
On Thu, Jun 13, 2019 at 03:09:37PM +1000, Alexey Kardashevskiy wrote:
> This adds a trace point which prints every loaded image. This includes
> bios/firmware/kernel/initradmdisk/pcirom.
> 
> Signed-off-by: Alexey Kardashevskiy 
> ---
> 
> The example for a pseries guest:
> 
> loader_write_rom slof.bin: @0x0 size=0xe22e0 ROM=0
> loader_write_rom phdr #0: /home/aik/t/vml4120le: @0x40 size=0x13df000 
> ROM=0
> loader_write_rom /home/aik/t/le.cpio: @0x1ad size=0x9463a00 ROM=0
> 
> Sadly "spapr-rtas.bin" does not show up because it is loaded from
> the spapr machine reset handler rather than via rom_reset(), may be needs
> to be fixed.
> 
> ---
>  Makefile.objs| 1 +
>  hw/core/loader.c | 3 +++
>  hw/core/trace-events | 2 ++
>  3 files changed, 6 insertions(+)
>  create mode 100644 hw/core/trace-events

Thanks, applied to my tracing tree:
https://github.com/stefanha/qemu/commits/tracing

Stefan


signature.asc
Description: PGP signature


Re: [Qemu-devel] [RFC v3 3/3] ARM: KVM: Check KVM_CAP_ARM_IRQ_LINE_LAYOUT_2 for smp_cpus > 256

2019-09-16 Thread Andrew Jones
On Fri, Sep 13, 2019 at 11:56:39AM +0200, Eric Auger wrote:
> Host kernel within [4.18, 5.3] report an erroneous KVM_MAX_VCPUS=512
> for ARM. The actual capability to instantiate more than 256 vcpus
> was fixed in 5.4 with the upgrade of the KVM_IRQ_LINE ABI to support
> vcpu id encoded on 12 bits instead of 8 and a redistributor consuming
> a single KVM IO device instead of 2.
> 
> So let's check this capability when attempting to use more than 256
> vcpus within any ARM kvm accelerated machine.
> 
> Signed-off-by: Eric Auger 
> 
> ---
> 
> v2 -> v3:
> - Implement the check in kvm_arch_init as suggested by Peter
> ---
>  target/arm/kvm.c | 10 +-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/target/arm/kvm.c b/target/arm/kvm.c
> index b10581fa06..b473c63edb 100644
> --- a/target/arm/kvm.c
> +++ b/target/arm/kvm.c
> @@ -182,6 +182,7 @@ int kvm_arm_get_max_vm_ipa_size(MachineState *ms)
>  
>  int kvm_arch_init(MachineState *ms, KVMState *s)
>  {
> +int ret = 0;
>  /* For ARM interrupt delivery is always asynchronous,
>   * whether we are using an in-kernel VGIC or not.
>   */
> @@ -195,7 +196,14 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
>  
>  cap_has_mp_state = kvm_check_extension(s, KVM_CAP_MP_STATE);
>  
> -return 0;
> +if (ms->smp.cpus > 256 &&
> +!kvm_check_extension(s, KVM_CAP_ARM_IRQ_LINE_LAYOUT_2)) {
> +error_report("Using more than 256 vcpus requires a host kernel "
> + "with KVM_CAP_ARM_IRQ_LINE_LAYOUT_2");
> +ret = -EINVAL;
> +}
> +
> +return ret;
>  }
>  
>  unsigned long kvm_arch_vcpu_id(CPUState *cpu)
> -- 
> 2.20.1
> 
>

Reviewed-by: Andrew Jones 



[Qemu-devel] [PATCH 02/13] hw: Move PL031 device from hw/timer/ to hw/rtc/ subdirectory

2019-09-16 Thread Philippe Mathieu-Daudé
The PL031 is a Real Time Clock, not a timer.
Move it under the hw/rtc/ subdirectory.

Signed-off-by: Philippe Mathieu-Daudé 
---
 MAINTAINERS   | 4 ++--
 Makefile.objs | 1 +
 hw/Kconfig| 1 +
 hw/Makefile.objs  | 1 +
 hw/arm/musca.c| 2 +-
 hw/rtc/Kconfig| 2 ++
 hw/rtc/Makefile.objs  | 1 +
 hw/{timer => rtc}/pl031.c | 2 +-
 hw/rtc/trace-events   | 8 
 hw/timer/Kconfig  | 3 ---
 hw/timer/Makefile.objs| 1 -
 hw/timer/trace-events | 7 ---
 include/hw/{timer => rtc}/pl031.h | 5 +++--
 13 files changed, 21 insertions(+), 17 deletions(-)
 create mode 100644 hw/rtc/Kconfig
 create mode 100644 hw/rtc/Makefile.objs
 rename hw/{timer => rtc}/pl031.c (99%)
 create mode 100644 hw/rtc/trace-events
 rename include/hw/{timer => rtc}/pl031.h (93%)

diff --git a/MAINTAINERS b/MAINTAINERS
index f0e30b5248..5562d2c6d0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -495,8 +495,8 @@ F: hw/intc/pl190.c
 F: hw/sd/pl181.c
 F: hw/ssi/pl022.c
 F: include/hw/ssi/pl022.h
-F: hw/timer/pl031.c
-F: include/hw/timer/pl031.h
+F: hw/rtc/pl031.c
+F: include/hw/rtc/pl031.h
 F: include/hw/arm/primecell.h
 F: hw/timer/cmsdk-apb-timer.c
 F: include/hw/timer/cmsdk-apb-timer.h
diff --git a/Makefile.objs b/Makefile.objs
index 6a143dcd57..1bcde315f7 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -173,6 +173,7 @@ trace-events-subdirs += hw/pci-host
 trace-events-subdirs += hw/ppc
 trace-events-subdirs += hw/rdma
 trace-events-subdirs += hw/rdma/vmw
+trace-events-subdirs += hw/rtc
 trace-events-subdirs += hw/s390x
 trace-events-subdirs += hw/scsi
 trace-events-subdirs += hw/sd
diff --git a/hw/Kconfig b/hw/Kconfig
index b45db3c813..4b53fee4d0 100644
--- a/hw/Kconfig
+++ b/hw/Kconfig
@@ -27,6 +27,7 @@ source pci-host/Kconfig
 source pcmcia/Kconfig
 source pci/Kconfig
 source rdma/Kconfig
+source rtc/Kconfig
 source scsi/Kconfig
 source sd/Kconfig
 source semihosting/Kconfig
diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index ece6cc3755..fd9750e5f2 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -26,6 +26,7 @@ devices-dirs-y += nvram/
 devices-dirs-y += pci/
 devices-dirs-$(CONFIG_PCI) += pci-bridge/ pci-host/
 devices-dirs-y += pcmcia/
+devices-dirs-y += rtc/
 devices-dirs-$(CONFIG_SCSI) += scsi/
 devices-dirs-y += sd/
 devices-dirs-y += ssi/
diff --git a/hw/arm/musca.c b/hw/arm/musca.c
index 68db4b5b38..ba99dd1941 100644
--- a/hw/arm/musca.c
+++ b/hw/arm/musca.c
@@ -32,7 +32,7 @@
 #include "hw/misc/tz-mpc.h"
 #include "hw/misc/tz-ppc.h"
 #include "hw/misc/unimp.h"
-#include "hw/timer/pl031.h"
+#include "hw/rtc/pl031.h"
 
 #define MUSCA_NUMIRQ_MAX 96
 #define MUSCA_PPC_MAX 3
diff --git a/hw/rtc/Kconfig b/hw/rtc/Kconfig
new file mode 100644
index 00..8a4383bca9
--- /dev/null
+++ b/hw/rtc/Kconfig
@@ -0,0 +1,2 @@
+config PL031
+bool
diff --git a/hw/rtc/Makefile.objs b/hw/rtc/Makefile.objs
new file mode 100644
index 00..3e1eb42563
--- /dev/null
+++ b/hw/rtc/Makefile.objs
@@ -0,0 +1 @@
+common-obj-$(CONFIG_PL031) += pl031.o
diff --git a/hw/timer/pl031.c b/hw/rtc/pl031.c
similarity index 99%
rename from hw/timer/pl031.c
rename to hw/rtc/pl031.c
index 2b3e261006..3a982752a2 100644
--- a/hw/timer/pl031.c
+++ b/hw/rtc/pl031.c
@@ -13,7 +13,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu-common.h"
-#include "hw/timer/pl031.h"
+#include "hw/rtc/pl031.h"
 #include "migration/vmstate.h"
 #include "hw/irq.h"
 #include "hw/qdev-properties.h"
diff --git a/hw/rtc/trace-events b/hw/rtc/trace-events
new file mode 100644
index 00..54c94ac557
--- /dev/null
+++ b/hw/rtc/trace-events
@@ -0,0 +1,8 @@
+# See docs/devel/tracing.txt for syntax documentation.
+
+# pl031.c
+pl031_irq_state(int level) "irq state %d"
+pl031_read(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x"
+pl031_write(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x"
+pl031_alarm_raised(void) "alarm raised"
+pl031_set_alarm(uint32_t ticks) "alarm set for %u ticks"
diff --git a/hw/timer/Kconfig b/hw/timer/Kconfig
index eefc95f35e..27c5dce09e 100644
--- a/hw/timer/Kconfig
+++ b/hw/timer/Kconfig
@@ -27,9 +27,6 @@ config M41T80
 config M48T59
 bool
 
-config PL031
-bool
-
 config TWL92230
 bool
 depends on I2C
diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs
index f407523aa4..9f64f6e11e 100644
--- a/hw/timer/Makefile.objs
+++ b/hw/timer/Makefile.objs
@@ -11,7 +11,6 @@ common-obj-$(CONFIG_M48T59) += m48t59.o
 ifeq ($(CONFIG_ISA_BUS),y)
 common-obj-$(CONFIG_M48T59) += m48t59-isa.o
 endif
-common-obj-$(CONFIG_PL031) += pl031.o
 common-obj-$(CONFIG_PUV3) += puv3_ost.o
 common-obj-$(CONFIG_TWL92230) += twl92230.o
 common-obj-$(CONFIG_XILINX) += xilinx_timer.o
diff --git a/hw/timer/trace-events b/hw/timer/trace-events
index db02a9142c..6936fe8573 100644
--- a/hw/timer/trace-events
+++ b/hw/timer/trace-events
@@ -80,10 +80,3 @@ 

Re: [Qemu-devel] [PATCH 3/3] tests/acceptance/migration: test to migrate will all machine types

2019-09-16 Thread Dr. David Alan Gilbert
* Balamuruhan S (bal...@linux.ibm.com) wrote:
> add migration test to query machine types supported by qemu binary
> and migrate vm will all supported type.
> 
> Signed-off-by: Balamuruhan S 

Depending on the architecture you might find that some machine types
aren't migratable while some are.

Dave

> ---
>  tests/acceptance/migration.py | 26 ++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/tests/acceptance/migration.py b/tests/acceptance/migration.py
> index 0f3553c8f0..74416ccc21 100644
> --- a/tests/acceptance/migration.py
> +++ b/tests/acceptance/migration.py
> @@ -49,3 +49,29 @@ class Migration(Test):
>  self.assertEqual(dest_vm.command('query-status')['status'], 
> 'running')
>  self.assertEqual(source_vm.command('query-status')['status'],
>   'postmigrate')
> +
> +
> +def test_migration_with_machine_types(self):
> +migration_port = self._get_free_port()
> +for machine in self.get_machine_types():
> +if 'pseries' in machine:
> +print("migrating with machine type - {}".format(machine))
> +source_vm = self.get_vm('-M', 
> '{},cap-htm=off'.format(machine))
> +dest_uri = 'tcp:localhost:%u' % migration_port
> +dest_vm = self.get_vm('-M', '{},cap-htm=off'.format(machine),
> +  '-incoming', dest_uri)
> +dest_vm.launch()
> +source_vm.launch()
> +source_vm.qmp('migrate', uri=dest_uri)
> +wait.wait_for(
> +self.migration_finished,
> +timeout=self.timeout,
> +step=0.1,
> +args=(source_vm,)
> +)
> +
> self.assertEqual(source_vm.command('query-migrate')['status'],
> +   'completed')
> +self.assertEqual(dest_vm.command('query-status')['status'],
> + 'running')
> +self.assertEqual(source_vm.command('query-status')['status'],
> +   'postmigrate')
> -- 
> 2.14.5
> 
> 
--
Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK



Re: [Qemu-devel] Is network backend netmap worth keeping?

2019-09-16 Thread Giuseppe Lettieri

Il 13/09/19 15:04, Markus Armbruster ha scritto:


What happens when I build with --enable-netmap=system on host A, then
run the resulting binary on some host B that doesn't have netmap
installed?



Qemu will fail at startup, complaining that /dev/netmap does not exists.




Yes.  We default to netmap=system, though.  If you break things by
passing arcane arguments to configure, you get to keep the pieces :)


If the option is only useful for developers to check that some qemu
change does not break anything, then probably it should be enabled in
some other, less visible way. What do you think?


I think an --enable-netmap patterned after --enable-capstone and
--enable-slirp has sufficiently low visibility as long as the default is
sane.

We clearly want configure to pick netmap=system when the system provides
netmap.

What shall configure pick when the system doesn't provide it?  If you
think netmap=git is too dangerous for general audience, consider
disabling netmap then.  Experts can still compile-test with
--enable-netmap=git.  Our CI certainly should.



OK, sounds reasonable. The attached patch will select system if netmap 
is available, and git only if explicitly requested.


Cheers,
Giuseppe

--
Dr. Ing. Giuseppe Lettieri
Dipartimento di Ingegneria della Informazione
Universita' di Pisa
Largo Lucio Lazzarino 1, 56122 Pisa - Italy
Ph. : (+39) 050-2217.649 (direct) .599 (switch)
Fax : (+39) 050-2217.600
e-mail: g.letti...@iet.unipi.it
>From 4e93b5cc3ad68d92bc3562df3745e1d10dc08fc0 Mon Sep 17 00:00:00 2001
From: Giuseppe Lettieri 
Date: Mon, 2 Sep 2019 17:35:33 +0200
Subject: [PATCH] netmap: support git-submodule build otption

With this patch, netmap support can be enabled with
the following options to the configure script:

  --enable-netmap[=system]

	Use the host system netmap installation.
	Fail if not found.

  --enable-netmap=git

	clone the official netmap repository on
	github (mostly useful for CI)

system will also be automatically used if no option is
passed and netmap is available in the host system.

Signed-off-by: Giuseppe Lettieri 
---
 .gitmodules |  3 +++
 configure   | 68 -
 netmap  |  1 +
 3 files changed, 61 insertions(+), 11 deletions(-)
 create mode 16 netmap

diff --git a/.gitmodules b/.gitmodules
index c5c474169d..bf75dbc5e3 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -58,3 +58,6 @@
 [submodule "roms/opensbi"]
 	path = roms/opensbi
 	url = 	https://git.qemu.org/git/opensbi.git
+[submodule "netmap"]
+	path = netmap
+	url = https://github.com/luigirizzo/netmap.git
diff --git a/configure b/configure
index 30aad233d1..5cb924985c 100755
--- a/configure
+++ b/configure
@@ -1133,6 +1133,10 @@ for opt do
   ;;
   --enable-netmap) netmap="yes"
   ;;
+  --enable-netmap=git) netmap="git"
+  ;;
+  --enable-netmap=system) netmap="system"
+  ;;
   --disable-xen) xen="no"
   ;;
   --enable-xen) xen="yes"
@@ -3314,8 +3318,9 @@ fi
 # a minor/major version number. Minor new features will be marked with values up
 # to 15, and if something happens that requires a change to the backend we will
 # move above 15, submit the backend fixes and modify this two bounds.
-if test "$netmap" != "no" ; then
-  cat > $TMPC << EOF
+case "$netmap" in
+"" | yes | system)
+  cat > $TMPC << EOF
 #include 
 #include 
 #include 
@@ -3325,15 +3330,56 @@ if test "$netmap" != "no" ; then
 #endif
 int main(void) { return 0; }
 EOF
-  if compile_prog "" "" ; then
-netmap=yes
-  else
-if test "$netmap" = "yes" ; then
-  feature_not_found "netmap"
+  if compile_prog "" "" ; then
+netmap_system=yes
+  else
+netmap_system=no
+  fi
+  ;;
+esac
+
+case "$netmap" in
+  "" | yes)
+if test "$netmap_system" = "yes"; then
+  netmap=system
+elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
+  netmap=git
+elif test -e "${source_path}/netmap/configure" ; then
+  netmap=internal
+elif test -z "$netmap" ; then
+  netmap=no
+else
+  feature_not_found "netmap" "Install netmap or git submodule"
 fi
-netmap=no
-  fi
-fi
+;;
+
+  system)
+if test "$netmap_system" = "no"; then
+  feature_not_found "netmap" "Install netmap"
+fi
+;;
+esac
+
+case "$netmap" in
+  git | internal)
+if test "$netmap" = git; then
+  git_submodules="${git_submodules} netmap"
+fi
+mkdir -p netmap
+QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/netmap/sys"
+;;
+
+  system)
+;;
+
+  no)
+;;
+  *)
+error_exit "Unknown state for netmap: $netmap"
+;;
+esac
+
+##
 
 ##
 # libcap-ng library probe
@@ -6582,7 +6628,7 @@ if test "$vde" = "yes" ; then
   echo "CONFIG_VDE=y" >> $config_host_mak
   echo "VDE_LIBS=$vde_libs" >> $config_host_mak
 fi
-if test "$netmap" = "yes" ; then
+if test "$netmap" != "no" ; then
   echo "CONFIG_NETMAP=y" >> $config_host_mak
 fi
 if 

[Qemu-devel] [PATCH 01/13] hw/timer: Compile devices not target-dependent as common object

2019-09-16 Thread Philippe Mathieu-Daudé
All these devices do not contain any target-specific. While most
of them are arch-specific, they are shared between different
targets of the same arch family (ARM and AArch64, MIPS32/MIPS64,
endianess, ...).
Put them into common-obj-y to compile them once for all targets.

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/timer/Makefile.objs | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs
index 123d92c969..f407523aa4 100644
--- a/hw/timer/Makefile.objs
+++ b/hw/timer/Makefile.objs
@@ -25,20 +25,20 @@ common-obj-$(CONFIG_MILKYMIST) += milkymist-sysctl.o
 common-obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp-rtc.o
 common-obj-$(CONFIG_NRF51_SOC) += nrf51_timer.o
 
-obj-$(CONFIG_ALTERA_TIMER) += altera_timer.o
-obj-$(CONFIG_EXYNOS4) += exynos4210_mct.o
-obj-$(CONFIG_EXYNOS4) += exynos4210_pwm.o
-obj-$(CONFIG_EXYNOS4) += exynos4210_rtc.o
-obj-$(CONFIG_OMAP) += omap_gptimer.o
-obj-$(CONFIG_OMAP) += omap_synctimer.o
-obj-$(CONFIG_PXA2XX) += pxa2xx_timer.o
-obj-$(CONFIG_SH4) += sh_timer.o
-obj-$(CONFIG_DIGIC) += digic-timer.o
-obj-$(CONFIG_MIPS_CPS) += mips_gictimer.o
+common-obj-$(CONFIG_ALTERA_TIMER) += altera_timer.o
+common-obj-$(CONFIG_EXYNOS4) += exynos4210_mct.o
+common-obj-$(CONFIG_EXYNOS4) += exynos4210_pwm.o
+common-obj-$(CONFIG_EXYNOS4) += exynos4210_rtc.o
+common-obj-$(CONFIG_OMAP) += omap_gptimer.o
+common-obj-$(CONFIG_OMAP) += omap_synctimer.o
+common-obj-$(CONFIG_PXA2XX) += pxa2xx_timer.o
+common-obj-$(CONFIG_SH4) += sh_timer.o
+common-obj-$(CONFIG_DIGIC) += digic-timer.o
+common-obj-$(CONFIG_MIPS_CPS) += mips_gictimer.o
 
 obj-$(CONFIG_MC146818RTC) += mc146818rtc.o
 
-obj-$(CONFIG_ALLWINNER_A10_PIT) += allwinner-a10-pit.o
+common-obj-$(CONFIG_ALLWINNER_A10_PIT) += allwinner-a10-pit.o
 
 common-obj-$(CONFIG_STM32F2XX_TIMER) += stm32f2xx_timer.o
 common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o aspeed_rtc.o
-- 
2.20.1




[Qemu-devel] [PULL 29/29] hw/i386/pc: Extract the x86 generic fw_cfg code

2019-09-16 Thread Paolo Bonzini
From: Philippe Mathieu-Daudé 

Extract all the functions that are not PC-machine specific into
the (arch-specific) fw_cfg.c file. This will allow other X86-machine
to reuse these functions.

Suggested-by: Samuel Ortiz 
Signed-off-by: Philippe Mathieu-Daudé 
Message-Id: <20190818225414.22590-16-phi...@redhat.com>
Signed-off-by: Paolo Bonzini 
---
 hw/i386/fw_cfg.c | 137 +++
 hw/i386/fw_cfg.h |   7 +++
 hw/i386/pc.c | 132 +
 3 files changed, 145 insertions(+), 131 deletions(-)

diff --git a/hw/i386/fw_cfg.c b/hw/i386/fw_cfg.c
index 380a819..39b6bc6 100644
--- a/hw/i386/fw_cfg.c
+++ b/hw/i386/fw_cfg.c
@@ -13,8 +13,15 @@
  */
 
 #include "qemu/osdep.h"
+#include "sysemu/numa.h"
+#include "hw/acpi/acpi.h"
+#include "hw/firmware/smbios.h"
+#include "hw/i386/pc.h"
 #include "hw/i386/fw_cfg.h"
+#include "hw/timer/hpet.h"
 #include "hw/nvram/fw_cfg.h"
+#include "e820_memory_layout.h"
+#include "kvm_i386.h"
 
 const char *fw_cfg_arch_key_name(uint16_t key)
 {
@@ -36,3 +43,133 @@ const char *fw_cfg_arch_key_name(uint16_t key)
 }
 return NULL;
 }
+
+void fw_cfg_build_smbios(MachineState *ms, FWCfgState *fw_cfg)
+{
+uint8_t *smbios_tables, *smbios_anchor;
+size_t smbios_tables_len, smbios_anchor_len;
+struct smbios_phys_mem_area *mem_array;
+unsigned i, array_count;
+X86CPU *cpu = X86_CPU(ms->possible_cpus->cpus[0].cpu);
+
+/* tell smbios about cpuid version and features */
+smbios_set_cpuid(cpu->env.cpuid_version, cpu->env.features[FEAT_1_EDX]);
+
+smbios_tables = smbios_get_table_legacy(ms, _tables_len);
+if (smbios_tables) {
+fw_cfg_add_bytes(fw_cfg, FW_CFG_SMBIOS_ENTRIES,
+ smbios_tables, smbios_tables_len);
+}
+
+/* build the array of physical mem area from e820 table */
+mem_array = g_malloc0(sizeof(*mem_array) * e820_get_num_entries());
+for (i = 0, array_count = 0; i < e820_get_num_entries(); i++) {
+uint64_t addr, len;
+
+if (e820_get_entry(i, E820_RAM, , )) {
+mem_array[array_count].address = addr;
+mem_array[array_count].length = len;
+array_count++;
+}
+}
+smbios_get_tables(ms, mem_array, array_count,
+  _tables, _tables_len,
+  _anchor, _anchor_len);
+g_free(mem_array);
+
+if (smbios_anchor) {
+fw_cfg_add_file(fw_cfg, "etc/smbios/smbios-tables",
+smbios_tables, smbios_tables_len);
+fw_cfg_add_file(fw_cfg, "etc/smbios/smbios-anchor",
+smbios_anchor, smbios_anchor_len);
+}
+}
+
+FWCfgState *fw_cfg_arch_create(MachineState *ms,
+  uint16_t boot_cpus,
+  uint16_t apic_id_limit)
+{
+FWCfgState *fw_cfg;
+uint64_t *numa_fw_cfg;
+int i;
+MachineClass *mc = MACHINE_GET_CLASS(ms);
+const CPUArchIdList *cpus = mc->possible_cpu_arch_ids(ms);
+int nb_numa_nodes = ms->numa_state->num_nodes;
+
+fw_cfg = fw_cfg_init_io_dma(FW_CFG_IO_BASE, FW_CFG_IO_BASE + 4,
+_space_memory);
+fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, boot_cpus);
+
+/* FW_CFG_MAX_CPUS is a bit confusing/problematic on x86:
+ *
+ * For machine types prior to 1.8, SeaBIOS needs FW_CFG_MAX_CPUS for
+ * building MPTable, ACPI MADT, ACPI CPU hotplug and ACPI SRAT table,
+ * that tables are based on xAPIC ID and QEMU<->SeaBIOS interface
+ * for CPU hotplug also uses APIC ID and not "CPU index".
+ * This means that FW_CFG_MAX_CPUS is not the "maximum number of CPUs",
+ * but the "limit to the APIC ID values SeaBIOS may see".
+ *
+ * So for compatibility reasons with old BIOSes we are stuck with
+ * "etc/max-cpus" actually being apic_id_limit
+ */
+fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, apic_id_limit);
+fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
+fw_cfg_add_bytes(fw_cfg, FW_CFG_ACPI_TABLES,
+ acpi_tables, acpi_tables_len);
+fw_cfg_add_i32(fw_cfg, FW_CFG_IRQ0_OVERRIDE, kvm_allows_irq0_override());
+
+fw_cfg_add_bytes(fw_cfg, FW_CFG_E820_TABLE,
+ _reserve, sizeof(e820_reserve));
+fw_cfg_add_file(fw_cfg, "etc/e820", e820_table,
+sizeof(struct e820_entry) * e820_get_num_entries());
+
+fw_cfg_add_bytes(fw_cfg, FW_CFG_HPET, _cfg, sizeof(hpet_cfg));
+/* allocate memory for the NUMA channel: one (64bit) word for the number
+ * of nodes, one word for each VCPU->node and one word for each node to
+ * hold the amount of memory.
+ */
+numa_fw_cfg = g_new0(uint64_t, 1 + apic_id_limit + nb_numa_nodes);
+numa_fw_cfg[0] = cpu_to_le64(nb_numa_nodes);
+for (i = 0; i < cpus->len; i++) {
+unsigned int apic_id = cpus->cpus[i].arch_id;
+assert(apic_id < apic_id_limit);
+

[Qemu-devel] [PATCH 10/13] hw: Move Exynos4210 RTC from hw/timer/ to hw/rtc/ subdirectory

2019-09-16 Thread Philippe Mathieu-Daudé
Move RTC devices under the hw/rtc/ subdirectory.

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/rtc/Makefile.objs   | 1 +
 hw/{timer => rtc}/exynos4210_rtc.c | 0
 hw/timer/Makefile.objs | 1 -
 3 files changed, 1 insertion(+), 1 deletion(-)
 rename hw/{timer => rtc}/exynos4210_rtc.c (100%)

diff --git a/hw/rtc/Makefile.objs b/hw/rtc/Makefile.objs
index 543a550a0f..3d4763fc26 100644
--- a/hw/rtc/Makefile.objs
+++ b/hw/rtc/Makefile.objs
@@ -7,5 +7,6 @@ endif
 common-obj-$(CONFIG_PL031) += pl031.o
 common-obj-$(CONFIG_TWL92230) += twl92230.o
 common-obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp-rtc.o
+common-obj-$(CONFIG_EXYNOS4) += exynos4210_rtc.o
 obj-$(CONFIG_MC146818RTC) += mc146818rtc.o
 common-obj-$(CONFIG_SUN4V_RTC) += sun4v-rtc.o
diff --git a/hw/timer/exynos4210_rtc.c b/hw/rtc/exynos4210_rtc.c
similarity index 100%
rename from hw/timer/exynos4210_rtc.c
rename to hw/rtc/exynos4210_rtc.c
diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs
index 294465ef47..33191d74cb 100644
--- a/hw/timer/Makefile.objs
+++ b/hw/timer/Makefile.objs
@@ -19,7 +19,6 @@ common-obj-$(CONFIG_NRF51_SOC) += nrf51_timer.o
 common-obj-$(CONFIG_ALTERA_TIMER) += altera_timer.o
 common-obj-$(CONFIG_EXYNOS4) += exynos4210_mct.o
 common-obj-$(CONFIG_EXYNOS4) += exynos4210_pwm.o
-common-obj-$(CONFIG_EXYNOS4) += exynos4210_rtc.o
 common-obj-$(CONFIG_OMAP) += omap_gptimer.o
 common-obj-$(CONFIG_OMAP) += omap_synctimer.o
 common-obj-$(CONFIG_PXA2XX) += pxa2xx_timer.o
-- 
2.20.1




[Qemu-devel] [PULL 23/29] hw/i386/pc: Let pc_build_smbios() take a FWCfgState argument

2019-09-16 Thread Paolo Bonzini
From: Philippe Mathieu-Daudé 

Pass the FWCfgState object by argument, this will
allow us to remove the PCMachineState argument later.

Suggested-by: Samuel Ortiz 
Signed-off-by: Philippe Mathieu-Daudé 
Message-Id: <20190818225414.22590-10-phi...@redhat.com>
---
 hw/i386/pc.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 8d2e600..612d676 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -894,7 +894,7 @@ static uint32_t x86_cpu_apic_id_from_index(PCMachineState 
*pcms,
 }
 }
 
-static void pc_build_smbios(PCMachineState *pcms)
+static void pc_build_smbios(PCMachineState *pcms, FWCfgState *fw_cfg)
 {
 uint8_t *smbios_tables, *smbios_anchor;
 size_t smbios_tables_len, smbios_anchor_len;
@@ -908,7 +908,7 @@ static void pc_build_smbios(PCMachineState *pcms)
 
 smbios_tables = smbios_get_table_legacy(ms, _tables_len);
 if (smbios_tables) {
-fw_cfg_add_bytes(pcms->fw_cfg, FW_CFG_SMBIOS_ENTRIES,
+fw_cfg_add_bytes(fw_cfg, FW_CFG_SMBIOS_ENTRIES,
  smbios_tables, smbios_tables_len);
 }
 
@@ -929,9 +929,9 @@ static void pc_build_smbios(PCMachineState *pcms)
 g_free(mem_array);
 
 if (smbios_anchor) {
-fw_cfg_add_file(pcms->fw_cfg, "etc/smbios/smbios-tables",
+fw_cfg_add_file(fw_cfg, "etc/smbios/smbios-tables",
 smbios_tables, smbios_tables_len);
-fw_cfg_add_file(pcms->fw_cfg, "etc/smbios/smbios-anchor",
+fw_cfg_add_file(fw_cfg, "etc/smbios/smbios-anchor",
 smbios_anchor, smbios_anchor_len);
 }
 }
@@ -1695,7 +1695,7 @@ void pc_machine_done(Notifier *notifier, void *data)
 
 acpi_setup();
 if (pcms->fw_cfg) {
-pc_build_smbios(pcms);
+pc_build_smbios(pcms, pcms->fw_cfg);
 pc_build_feature_control_file(pcms);
 /* update FW_CFG_NB_CPUS to account for -device added CPUs */
 fw_cfg_modify_i16(pcms->fw_cfg, FW_CFG_NB_CPUS, pcms->boot_cpus);
-- 
1.8.3.1





Re: [Qemu-devel] [PATCH v4 0/5] qcow2: async handling of fragmented io

2019-09-16 Thread Vladimir Sementsov-Ogievskiy
16.09.2019 16:26, Max Reitz wrote:
> On 13.09.19 10:58, Max Reitz wrote:
>> On 16.08.19 17:30, Vladimir Sementsov-Ogievskiy wrote:
>>> Hi all!
>>>
>>> Here is an asynchronous scheme for handling fragmented qcow2
>>> reads and writes. Both qcow2 read and write functions loops through
>>> sequential portions of data. The series aim it to parallelize these
>>> loops iterations.
>>> It improves performance for fragmented qcow2 images, I've tested it
>>> as described below.
>>
>> Thanks, I’ve changed two things:
>> - Replaced assert((x & (BDRV_SECTOR_SIZE - 1)) == 0) by
>>assert(QEMU_IS_ALIGNED(x, BDRV_SECTOR_SIZE)) in patch 3 (conflict with
>>“block: Use QEMU_IS_ALIGNED”), and
>> - Replaced the remaining instance of “qcow2_co_do_pwritev()” by
>>“qcow2_co_pwritev_task()” in a comment in patch 4
>>
>> and applied the series to my block branch:
>>
>> https://git.xanclic.moe/XanClic/qemu/commits/branch/block
> 
> Unfortunately, I’ll have to unstage the series for now because the fix
> to 026’s reference output isn’t stable.
> 
> When running the test in parallel (I can reproduce it with four
> instances on my machine with two cores + HT), I get failures like:
> 
> 026  fail   [15:21:09] [15:21:37]  (last: 18s)   output
> mismatch (see 026.out.bad)
> --- tests/qemu-iotests/026.out 2019-09-16 14:49:20.720410701 +0200
> +++ tests/qemu-iotests/026.out.bad   2019-09-16 15:21:37.180711936 +0200
> @@ -563,7 +563,7 @@
>   qemu-io: Failed to flush the refcount block cache: No space left on device
>   write failed: No space left on device
> 
> -74 leaked clusters were found on the image.
> +522 leaked clusters were found on the image.
>   This means waste of disk space, but no harm to data.
>   Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
> 
> Failures: 026
> Failed 1 of 1 iotests
> 

Unfortunate enough:)

Hmm, can't reproduce, but I tend to fix this by just filtering out information 
about
leaked clusters in this test, as no sense in tracking it for failure paths, 
keeping
in mind newly introduced async handling of request parts.

-- 
Best regards,
Vladimir


[Qemu-devel] [PULL 24/29] hw/i386/pc: Let pc_build_smbios() take a generic MachineState argument

2019-09-16 Thread Paolo Bonzini
From: Philippe Mathieu-Daudé 

Let the pc_build_smbios() function take a generic MachineState
argument.

Suggested-by: Samuel Ortiz 
Signed-off-by: Philippe Mathieu-Daudé 
Message-Id: <20190818225414.22590-11-phi...@redhat.com>
---
 hw/i386/pc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 612d676..14ad611 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -894,13 +894,12 @@ static uint32_t x86_cpu_apic_id_from_index(PCMachineState 
*pcms,
 }
 }
 
-static void pc_build_smbios(PCMachineState *pcms, FWCfgState *fw_cfg)
+static void pc_build_smbios(MachineState *ms, FWCfgState *fw_cfg)
 {
 uint8_t *smbios_tables, *smbios_anchor;
 size_t smbios_tables_len, smbios_anchor_len;
 struct smbios_phys_mem_area *mem_array;
 unsigned i, array_count;
-MachineState *ms = MACHINE(pcms);
 X86CPU *cpu = X86_CPU(ms->possible_cpus->cpus[0].cpu);
 
 /* tell smbios about cpuid version and features */
@@ -1695,7 +1694,7 @@ void pc_machine_done(Notifier *notifier, void *data)
 
 acpi_setup();
 if (pcms->fw_cfg) {
-pc_build_smbios(pcms, pcms->fw_cfg);
+pc_build_smbios(MACHINE(pcms), pcms->fw_cfg);
 pc_build_feature_control_file(pcms);
 /* update FW_CFG_NB_CPUS to account for -device added CPUs */
 fw_cfg_modify_i16(pcms->fw_cfg, FW_CFG_NB_CPUS, pcms->boot_cpus);
-- 
1.8.3.1





[Qemu-devel] [PATCH 09/13] hw: Move Xilinx ZynqMP RTC from hw/timer/ to hw/rtc/ subdirectory

2019-09-16 Thread Philippe Mathieu-Daudé
Move RTC devices under the hw/rtc/ subdirectory.

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/rtc/Makefile.objs| 1 +
 hw/rtc/trace-events | 3 +++
 hw/{timer => rtc}/xlnx-zynqmp-rtc.c | 2 +-
 hw/timer/Makefile.objs  | 1 -
 hw/timer/trace-events   | 3 ---
 include/hw/arm/xlnx-zynqmp.h| 2 +-
 include/hw/{timer => rtc}/xlnx-zynqmp-rtc.h | 6 +++---
 7 files changed, 9 insertions(+), 9 deletions(-)
 rename hw/{timer => rtc}/xlnx-zynqmp-rtc.c (99%)
 rename include/hw/{timer => rtc}/xlnx-zynqmp-rtc.h (95%)

diff --git a/hw/rtc/Makefile.objs b/hw/rtc/Makefile.objs
index b195863291..543a550a0f 100644
--- a/hw/rtc/Makefile.objs
+++ b/hw/rtc/Makefile.objs
@@ -6,5 +6,6 @@ common-obj-$(CONFIG_M48T59) += m48t59-isa.o
 endif
 common-obj-$(CONFIG_PL031) += pl031.o
 common-obj-$(CONFIG_TWL92230) += twl92230.o
+common-obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp-rtc.o
 obj-$(CONFIG_MC146818RTC) += mc146818rtc.o
 common-obj-$(CONFIG_SUN4V_RTC) += sun4v-rtc.o
diff --git a/hw/rtc/trace-events b/hw/rtc/trace-events
index ac9e0e0fba..7f1945ad4c 100644
--- a/hw/rtc/trace-events
+++ b/hw/rtc/trace-events
@@ -4,6 +4,9 @@
 sun4v_rtc_read(uint64_t addr, uint64_t value) "read: addr 0x%" PRIx64 " value 
0x%" PRIx64
 sun4v_rtc_write(uint64_t addr, uint64_t value) "write: addr 0x%" PRIx64 " 
value 0x%" PRIx64
 
+# xlnx-zynqmp-rtc.c
+xlnx_zynqmp_rtc_gettime(int year, int month, int day, int hour, int min, int 
sec) "Get time from host: %d-%d-%d %2d:%02d:%02d"
+
 # pl031.c
 pl031_irq_state(int level) "irq state %d"
 pl031_read(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x"
diff --git a/hw/timer/xlnx-zynqmp-rtc.c b/hw/rtc/xlnx-zynqmp-rtc.c
similarity index 99%
rename from hw/timer/xlnx-zynqmp-rtc.c
rename to hw/rtc/xlnx-zynqmp-rtc.c
index 5692db98c2..f9f09b7296 100644
--- a/hw/timer/xlnx-zynqmp-rtc.c
+++ b/hw/rtc/xlnx-zynqmp-rtc.c
@@ -36,7 +36,7 @@
 #include "qemu/cutils.h"
 #include "sysemu/sysemu.h"
 #include "trace.h"
-#include "hw/timer/xlnx-zynqmp-rtc.h"
+#include "hw/rtc/xlnx-zynqmp-rtc.h"
 #include "migration/vmstate.h"
 
 #ifndef XLNX_ZYNQMP_RTC_ERR_DEBUG
diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs
index 70b61b69c7..294465ef47 100644
--- a/hw/timer/Makefile.objs
+++ b/hw/timer/Makefile.objs
@@ -14,7 +14,6 @@ common-obj-$(CONFIG_IMX) += imx_epit.o
 common-obj-$(CONFIG_IMX) += imx_gpt.o
 common-obj-$(CONFIG_LM32) += lm32_timer.o
 common-obj-$(CONFIG_MILKYMIST) += milkymist-sysctl.o
-common-obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp-rtc.o
 common-obj-$(CONFIG_NRF51_SOC) += nrf51_timer.o
 
 common-obj-$(CONFIG_ALTERA_TIMER) += altera_timer.o
diff --git a/hw/timer/trace-events b/hw/timer/trace-events
index ce34b967db..1459d07237 100644
--- a/hw/timer/trace-events
+++ b/hw/timer/trace-events
@@ -70,9 +70,6 @@ cmsdk_apb_dualtimer_reset(void) "CMSDK APB dualtimer: reset"
 aspeed_rtc_read(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 
0x%08" PRIx64
 aspeed_rtc_write(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 
0x%08" PRIx64
 
-# xlnx-zynqmp-rtc.c
-xlnx_zynqmp_rtc_gettime(int year, int month, int day, int hour, int min, int 
sec) "Get time from host: %d-%d-%d %2d:%02d:%02d"
-
 # nrf51_timer.c
 nrf51_timer_read(uint64_t addr, uint32_t value, unsigned size) "read addr 0x%" 
PRIx64 " data 0x%" PRIx32 " size %u"
 nrf51_timer_write(uint64_t addr, uint32_t value, unsigned size) "write addr 
0x%" PRIx64 " data 0x%" PRIx32 " size %u"
diff --git a/include/hw/arm/xlnx-zynqmp.h b/include/hw/arm/xlnx-zynqmp.h
index d7483c3b42..53076fa29a 100644
--- a/include/hw/arm/xlnx-zynqmp.h
+++ b/include/hw/arm/xlnx-zynqmp.h
@@ -29,7 +29,7 @@
 #include "hw/dma/xlnx-zdma.h"
 #include "hw/display/xlnx_dp.h"
 #include "hw/intc/xlnx-zynqmp-ipi.h"
-#include "hw/timer/xlnx-zynqmp-rtc.h"
+#include "hw/rtc/xlnx-zynqmp-rtc.h"
 #include "hw/cpu/cluster.h"
 #include "target/arm/cpu.h"
 
diff --git a/include/hw/timer/xlnx-zynqmp-rtc.h 
b/include/hw/rtc/xlnx-zynqmp-rtc.h
similarity index 95%
rename from include/hw/timer/xlnx-zynqmp-rtc.h
rename to include/hw/rtc/xlnx-zynqmp-rtc.h
index 97e32322ed..6fa1cb2f43 100644
--- a/include/hw/timer/xlnx-zynqmp-rtc.h
+++ b/include/hw/rtc/xlnx-zynqmp-rtc.h
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2017 Xilinx Inc.
  *
- * Written-by: Alistair Francis 
+ * Written-by: Alistair Francis
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to 
deal
@@ -24,8 +24,8 @@
  * THE SOFTWARE.
  */
 
-#ifndef HW_TIMER_XLNX_ZYNQMP_RTC_H
-#define HW_TIMER_XLNX_ZYNQMP_RTC_H
+#ifndef HW_RTC_XLNX_ZYNQMP_H
+#define HW_RTC_XLNX_ZYNQMP_H
 
 #include "hw/register.h"
 #include "hw/sysbus.h"
-- 
2.20.1




[Qemu-devel] [PULL 19/29] hw/i386/pc: Pass the boot_cpus value by argument

2019-09-16 Thread Paolo Bonzini
From: Philippe Mathieu-Daudé 

The boot_cpus is used once. Pass it by argument, this will
allow us to remove the PCMachineState argument later.

Suggested-by: Samuel Ortiz 
Signed-off-by: Philippe Mathieu-Daudé 
Message-Id: <20190818225414.22590-6-phi...@redhat.com>
---
 hw/i386/pc.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index b15af77..dc2ae6d 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -936,7 +936,8 @@ static void pc_build_smbios(PCMachineState *pcms)
 }
 }
 
-static FWCfgState *fw_cfg_arch_create(PCMachineState *pcms)
+static FWCfgState *fw_cfg_arch_create(PCMachineState *pcms,
+  uint16_t boot_cpus)
 {
 FWCfgState *fw_cfg;
 uint64_t *numa_fw_cfg;
@@ -948,7 +949,7 @@ static FWCfgState *fw_cfg_arch_create(PCMachineState *pcms)
 
 fw_cfg = fw_cfg_init_io_dma(FW_CFG_IO_BASE, FW_CFG_IO_BASE + 4,
 _space_memory);
-fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, pcms->boot_cpus);
+fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, boot_cpus);
 
 /* FW_CFG_MAX_CPUS is a bit confusing/problematic on x86:
  *
@@ -1869,7 +1870,7 @@ void pc_memory_init(PCMachineState *pcms,
 option_rom_mr,
 1);
 
-fw_cfg = fw_cfg_arch_create(pcms);
+fw_cfg = fw_cfg_arch_create(pcms, pcms->boot_cpus);
 
 rom_set_fw(fw_cfg);
 
-- 
1.8.3.1





Re: [Qemu-devel] [PATCH] hw/*/Makefile.objs: Move many .o files to common-objs

2019-09-16 Thread Stefan Hajnoczi
On Thu, Sep 12, 2019 at 03:10:11PM +0200, Thomas Huth wrote:
> We have many files that apparently do not depend on the target CPU
> configuration, i.e. which can be put into common-obj-y instead of
> obj-y. This way, the code can be shared for example between
> qemu-system-arm and qemu-system-aarch64, or the various big and
> little endian variants like qemu-system-sh4 and qemu-system-sh4eb,
> so that we do not have to compile the code multiple times anymore.
> 
> Signed-off-by: Thomas Huth 
> ---
>  hw/adc/Makefile.objs |  2 +-
>  hw/block/Makefile.objs   |  2 +-
>  hw/char/Makefile.objs| 16 
>  hw/core/Makefile.objs|  2 +-
>  hw/display/Makefile.objs |  2 +-
>  hw/dma/Makefile.objs |  6 +++---
>  hw/gpio/Makefile.objs|  8 
>  hw/i2c/Makefile.objs |  4 ++--
>  hw/i2c/ppc4xx_i2c.c  |  1 -
>  hw/input/Makefile.objs   |  6 +++---
>  hw/net/Makefile.objs |  6 +++---
>  hw/nvram/Makefile.objs   |  2 +-
>  hw/pcmcia/Makefile.objs  |  2 +-
>  hw/sd/Makefile.objs  |  8 
>  hw/ssi/Makefile.objs |  4 ++--
>  hw/timer/Makefile.objs   | 22 +++---
>  hw/usb/Makefile.objs |  4 ++--
>  17 files changed, 48 insertions(+), 49 deletions(-)

Nice.  Again, I think the poisoned symbols would break compilation and
CI would tell us if any changes made in this patch were incorrect.
Therefore, looks good:

Reviewed-by: Stefan Hajnoczi 


signature.asc
Description: PGP signature


[Qemu-devel] [PULL 25/29] hw/i386/pc: Rename pc_build_smbios() as generic fw_cfg_build_smbios()

2019-09-16 Thread Paolo Bonzini
From: Philippe Mathieu-Daudé 

Now that the pc_build_smbios() function has been refactored to not
depend of PC specific types, rename it to a more generic name.

Suggested-by: Samuel Ortiz 
Signed-off-by: Philippe Mathieu-Daudé 
Message-Id: <20190818225414.22590-12-phi...@redhat.com>
---
 hw/i386/pc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 14ad611..8f611cb 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -894,7 +894,7 @@ static uint32_t x86_cpu_apic_id_from_index(PCMachineState 
*pcms,
 }
 }
 
-static void pc_build_smbios(MachineState *ms, FWCfgState *fw_cfg)
+static void fw_cfg_build_smbios(MachineState *ms, FWCfgState *fw_cfg)
 {
 uint8_t *smbios_tables, *smbios_anchor;
 size_t smbios_tables_len, smbios_anchor_len;
@@ -1694,7 +1694,7 @@ void pc_machine_done(Notifier *notifier, void *data)
 
 acpi_setup();
 if (pcms->fw_cfg) {
-pc_build_smbios(MACHINE(pcms), pcms->fw_cfg);
+fw_cfg_build_smbios(MACHINE(pcms), pcms->fw_cfg);
 pc_build_feature_control_file(pcms);
 /* update FW_CFG_NB_CPUS to account for -device added CPUs */
 fw_cfg_modify_i16(pcms->fw_cfg, FW_CFG_NB_CPUS, pcms->boot_cpus);
-- 
1.8.3.1





[Qemu-devel] [PULL 18/29] hw/i386/pc: Rename bochs_bios_init as more generic fw_cfg_arch_create

2019-09-16 Thread Paolo Bonzini
From: Philippe Mathieu-Daudé 

The bochs_bios_init() function is not restricted to the Bochs
BIOS and is useful to other BIOS.
Since it is not specific to the PC machine, and can be reused
by other machines of the X86 architecture, rename it as
fw_cfg_arch_create().

Suggested-by: Samuel Ortiz 
Reviewed-by: Li Qiang 
Signed-off-by: Philippe Mathieu-Daudé 
Message-Id: <20190818225414.22590-5-phi...@redhat.com>
---
 hw/i386/pc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index dd5ec2e..b15af77 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -936,7 +936,7 @@ static void pc_build_smbios(PCMachineState *pcms)
 }
 }
 
-static FWCfgState *bochs_bios_init(PCMachineState *pcms)
+static FWCfgState *fw_cfg_arch_create(PCMachineState *pcms)
 {
 FWCfgState *fw_cfg;
 uint64_t *numa_fw_cfg;
@@ -1614,7 +1614,7 @@ void pc_cpus_init(PCMachineState *pcms)
  * Limit for the APIC ID value, so that all
  * CPU APIC IDs are < pcms->apic_id_limit.
  *
- * This is used for FW_CFG_MAX_CPUS. See comments on bochs_bios_init().
+ * This is used for FW_CFG_MAX_CPUS. See comments on fw_cfg_arch_create().
  */
 pcms->apic_id_limit = x86_cpu_apic_id_from_index(pcms,
  ms->smp.max_cpus - 1) + 1;
@@ -1869,7 +1869,7 @@ void pc_memory_init(PCMachineState *pcms,
 option_rom_mr,
 1);
 
-fw_cfg = bochs_bios_init(pcms);
+fw_cfg = fw_cfg_arch_create(pcms);
 
 rom_set_fw(fw_cfg);
 
-- 
1.8.3.1





[Qemu-devel] [PATCH 00/13] hw: Split RTC devices from hw/timer/ to hw/rtc/

2019-09-16 Thread Philippe Mathieu-Daudé
When working on timers, I found it confuse to have RTC devices
mixed in the hw/timer/ directory.

We can see the models use slighly different APIs:

  $ git grep '#include' hw/timer/|cut -d: -f3-|sort|uniq -c|egrep -v '^  1 
'|sort -rn
 33 #include "qemu/osdep.h"
 29 #include "hw/irq.h"
 28 #include "qemu/module.h"
 23 #include "migration/vmstate.h"
 21 #include "hw/sysbus.h"
 20 #include "qemu/timer.h"
 20 #include "qemu/main-loop.h"
 17 #include "qemu/log.h"
 14 #include "hw/qdev-properties.h"
 14 #include "hw/ptimer.h"
  9 #include "trace.h"
  7 #include "qapi/error.h"
  5 #include "hw/hw.h"
  3 #include "sysemu/runstate.h"
  3 #include "qemu/error-report.h"
  3 #include "hw/timer/i8254.h"
  2 #include "qemu/bitops.h"
  2 #include "hw/timer/i8254_internal.h"
  2 #include "hw/registerfields.h"
  2 #include "hw/core/cpu.h"
  2 #include "hw/arm/omap.h"
  2 #include "hw/arm/exynos4210.h"

  $ git grep '#include' hw/rtc/|cut -d: -f3-|sort|uniq -c|egrep -v '^  1 
'|sort -rn
 11 #include "qemu/osdep.h"
 10 #include "qemu/module.h"
  9 #include "qemu-common.h"
  8 #include "qemu/timer.h"
  8 #include "migration/vmstate.h"
  6 #include "qemu/bcd.h"
  6 #include "hw/irq.h"
  5 #include "sysemu/sysemu.h"
  5 #include "qemu/log.h"
  5 #include "hw/sysbus.h"
  4 #include "trace.h"
  4 #include "hw/qdev-properties.h"
  3 #include "qemu/cutils.h"
  3 #include "hw/i2c/i2c.h"
  2 #include "sysemu/runstate.h"
  2 #include "m48t59-internal.h"
  2 #include "hw/rtc/m48t59.h"
  2 #include "exec/address-spaces.h"

Split the RTC-related files in the new hw/rtc/ directory.

Philippe Mathieu-Daudé (13):
  hw/timer: Compile devices not target-dependent as common object
  hw: Move PL031 device from hw/timer/ to hw/rtc/ subdirectory
  hw: Move MC146818 device from hw/timer/ to hw/rtc/ subdirectory
  hw: Move M48T59 device from hw/timer/ to hw/rtc/ subdirectory
  hw: Move M41T80 device from hw/timer/ to hw/rtc/ subdirectory
  hw: Move sun4v hypervisor RTC from hw/timer/ to hw/rtc/ subdirectory
  hw: Move TWL92230 device from hw/timer/ to hw/rtc/ subdirectory
  hw: Move DS1338 device from hw/timer/ to hw/rtc/ subdirectory
  hw: Move Xilinx ZynqMP RTC from hw/timer/ to hw/rtc/ subdirectory
  hw: Move Exynos4210 RTC from hw/timer/ to hw/rtc/ subdirectory
  hw: Move Aspeed RTC from hw/timer/ to hw/rtc/ subdirectory
  hw/rtc/mc146818: Include mc146818rtc_regs.h a bit less
  hw/rtc/xlnx-zynqmp-rtc: Remove unused "ptimer.h" include

 MAINTAINERS  | 20 +++
 Makefile.objs|  1 +
 hw/Kconfig   |  1 +
 hw/Makefile.objs |  1 +
 hw/alpha/dp264.c |  2 +-
 hw/arm/musca.c   |  2 +-
 hw/hppa/machine.c|  2 +-
 hw/i386/acpi-build.c |  2 +-
 hw/i386/pc.c |  2 +-
 hw/i386/pc_q35.c |  2 +-
 hw/mips/mips_fulong2e.c  |  2 +-
 hw/mips/mips_jazz.c  |  2 +-
 hw/mips/mips_malta.c |  2 +-
 hw/mips/mips_r4k.c   |  2 +-
 hw/ppc/pnv.c |  2 +-
 hw/ppc/ppc405_boards.c   |  2 +-
 hw/ppc/prep.c|  4 +-
 hw/rtc/Kconfig   | 23 
 hw/rtc/Makefile.objs | 13 +
 hw/{timer => rtc}/aspeed_rtc.c   |  2 +-
 hw/{timer => rtc}/ds1338.c   |  0
 hw/{timer => rtc}/exynos4210_rtc.c   |  0
 hw/{timer => rtc}/m41t80.c   |  0
 hw/{timer => rtc}/m48t59-internal.h  |  0
 hw/{timer => rtc}/m48t59-isa.c   |  4 +-
 hw/{timer => rtc}/m48t59.c   |  2 +-
 hw/{timer => rtc}/mc146818rtc.c  |  3 +-
 hw/{timer => rtc}/pl031.c|  2 +-
 hw/{timer => rtc}/sun4v-rtc.c|  2 +-
 hw/rtc/trace-events  | 19 +++
 hw/{timer => rtc}/twl92230.c |  0
 hw/{timer => rtc}/xlnx-zynqmp-rtc.c  |  3 +-
 hw/sparc/sun4m.c |  2 +-
 hw/sparc64/niagara.c |  2 +-
 hw/sparc64/sun4u.c   |  2 +-
 hw/timer/Kconfig | 24 -
 hw/timer/Makefile.objs   | 35 
 hw/timer/hpet.c  |  3 +-
 hw/timer/trace-events| 18 ---
 include/hw/arm/aspeed_soc.h  |  2 +-
 include/hw/arm/xlnx-zynqmp.h |  2 +-
 include/hw/{timer => rtc}/aspeed_rtc.h   |  3 --
 include/hw/rtc/m48t59.h  | 57 
 

[Qemu-devel] [PULL 17/29] hw/i386/pc: Use address_space_memory in place

2019-09-16 Thread Paolo Bonzini
From: Philippe Mathieu-Daudé 

The address_space_memory variable is used once.
Use it in place and remove the argument.

Suggested-by: Samuel Ortiz 
Reviewed-by: Li Qiang 
Signed-off-by: Philippe Mathieu-Daudé 
Message-Id: <20190818225414.22590-4-phi...@redhat.com>
---
 hw/i386/pc.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 81e5a59..dd5ec2e 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -936,7 +936,7 @@ static void pc_build_smbios(PCMachineState *pcms)
 }
 }
 
-static FWCfgState *bochs_bios_init(AddressSpace *as, PCMachineState *pcms)
+static FWCfgState *bochs_bios_init(PCMachineState *pcms)
 {
 FWCfgState *fw_cfg;
 uint64_t *numa_fw_cfg;
@@ -946,7 +946,8 @@ static FWCfgState *bochs_bios_init(AddressSpace *as, 
PCMachineState *pcms)
 MachineState *ms = MACHINE(pcms);
 int nb_numa_nodes = ms->numa_state->num_nodes;
 
-fw_cfg = fw_cfg_init_io_dma(FW_CFG_IO_BASE, FW_CFG_IO_BASE + 4, as);
+fw_cfg = fw_cfg_init_io_dma(FW_CFG_IO_BASE, FW_CFG_IO_BASE + 4,
+_space_memory);
 fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, pcms->boot_cpus);
 
 /* FW_CFG_MAX_CPUS is a bit confusing/problematic on x86:
@@ -1868,7 +1869,7 @@ void pc_memory_init(PCMachineState *pcms,
 option_rom_mr,
 1);
 
-fw_cfg = bochs_bios_init(_space_memory, pcms);
+fw_cfg = bochs_bios_init(pcms);
 
 rom_set_fw(fw_cfg);
 
-- 
1.8.3.1





[Qemu-devel] [PULL 16/29] hw/i386/pc: Extract e820 memory layout code

2019-09-16 Thread Paolo Bonzini
From: Philippe Mathieu-Daudé 

Suggested-by: Samuel Ortiz 
Reviewed-by: Li Qiang 
Signed-off-by: Philippe Mathieu-Daudé 
Message-Id: <20190818225414.22590-3-phi...@redhat.com>
---
 hw/i386/Makefile.objs|  2 +-
 hw/i386/e820_memory_layout.c | 59 ++
 hw/i386/e820_memory_layout.h | 42 ++
 hw/i386/pc.c | 61 +---
 include/hw/i386/pc.h | 11 
 target/i386/kvm.c|  1 +
 6 files changed, 104 insertions(+), 72 deletions(-)
 create mode 100644 hw/i386/e820_memory_layout.c
 create mode 100644 hw/i386/e820_memory_layout.h

diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs
index 5d9c9ef..d3374e0 100644
--- a/hw/i386/Makefile.objs
+++ b/hw/i386/Makefile.objs
@@ -1,5 +1,5 @@
 obj-$(CONFIG_KVM) += kvm/
-obj-y += multiboot.o
+obj-y += e820_memory_layout.o multiboot.o
 obj-y += pc.o
 obj-$(CONFIG_I440FX) += pc_piix.o
 obj-$(CONFIG_Q35) += pc_q35.o
diff --git a/hw/i386/e820_memory_layout.c b/hw/i386/e820_memory_layout.c
new file mode 100644
index 000..bcf9eaf
--- /dev/null
+++ b/hw/i386/e820_memory_layout.c
@@ -0,0 +1,59 @@
+/*
+ * QEMU BIOS e820 routines
+ *
+ * Copyright (c) 2003-2004 Fabrice Bellard
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/bswap.h"
+#include "e820_memory_layout.h"
+
+static size_t e820_entries;
+struct e820_table e820_reserve;
+struct e820_entry *e820_table;
+
+int e820_add_entry(uint64_t address, uint64_t length, uint32_t type)
+{
+int index = le32_to_cpu(e820_reserve.count);
+struct e820_entry *entry;
+
+if (type != E820_RAM) {
+/* old FW_CFG_E820_TABLE entry -- reservations only */
+if (index >= E820_NR_ENTRIES) {
+return -EBUSY;
+}
+entry = _reserve.entry[index++];
+
+entry->address = cpu_to_le64(address);
+entry->length = cpu_to_le64(length);
+entry->type = cpu_to_le32(type);
+
+e820_reserve.count = cpu_to_le32(index);
+}
+
+/* new "etc/e820" file -- include ram too */
+e820_table = g_renew(struct e820_entry, e820_table, e820_entries + 1);
+e820_table[e820_entries].address = cpu_to_le64(address);
+e820_table[e820_entries].length = cpu_to_le64(length);
+e820_table[e820_entries].type = cpu_to_le32(type);
+e820_entries++;
+
+return e820_entries;
+}
+
+int e820_get_num_entries(void)
+{
+return e820_entries;
+}
+
+bool e820_get_entry(int idx, uint32_t type, uint64_t *address, uint64_t 
*length)
+{
+if (idx < e820_entries && e820_table[idx].type == cpu_to_le32(type)) {
+*address = le64_to_cpu(e820_table[idx].address);
+*length = le64_to_cpu(e820_table[idx].length);
+return true;
+}
+return false;
+}
diff --git a/hw/i386/e820_memory_layout.h b/hw/i386/e820_memory_layout.h
new file mode 100644
index 000..2a0ceb8
--- /dev/null
+++ b/hw/i386/e820_memory_layout.h
@@ -0,0 +1,42 @@
+/*
+ * QEMU BIOS e820 routines
+ *
+ * Copyright (c) 2003-2004 Fabrice Bellard
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#ifndef HW_I386_E820_H
+#define HW_I386_E820_H
+
+/* e820 types */
+#define E820_RAM1
+#define E820_RESERVED   2
+#define E820_ACPI   3
+#define E820_NVS4
+#define E820_UNUSABLE   5
+
+#define E820_NR_ENTRIES 16
+
+struct e820_entry {
+uint64_t address;
+uint64_t length;
+uint32_t type;
+} QEMU_PACKED __attribute((__aligned__(4)));
+
+struct e820_table {
+uint32_t count;
+struct e820_entry entry[E820_NR_ENTRIES];
+} QEMU_PACKED __attribute((__aligned__(4)));
+
+extern struct e820_table e820_reserve;
+extern struct e820_entry *e820_table;
+
+int e820_add_entry(uint64_t address, uint64_t length, uint32_t type);
+int e820_get_num_entries(void);
+bool e820_get_entry(int index, uint32_t type,
+uint64_t *address, uint64_t *length);
+
+
+
+#endif
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 31e9c1f..81e5a59 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -87,6 +87,7 @@
 #include "sysemu/replay.h"
 #include "qapi/qmp/qerror.h"
 #include "config-devices.h"
+#include "e820_memory_layout.h"
 
 /* debug PC/ISA interrupts */
 //#define DEBUG_IRQ
@@ -98,22 +99,6 @@
 #define DPRINTF(fmt, ...)
 #endif
 
-#define E820_NR_ENTRIES16
-
-struct e820_entry {
-uint64_t address;
-uint64_t length;
-uint32_t type;
-} QEMU_PACKED __attribute((__aligned__(4)));
-
-struct e820_table {
-uint32_t count;
-struct e820_entry entry[E820_NR_ENTRIES];
-} QEMU_PACKED __attribute((__aligned__(4)));
-
-static struct e820_table e820_reserve;
-static struct e820_entry *e820_table;
-static unsigned e820_entries;
 struct hpet_fw_config hpet_cfg = {.count = UINT8_MAX};
 
 /* Physical Address of PVH entry point read from kernel ELF NOTE */
@@ -880,50 +865,6 @@ static void handle_a20_line_change(void *opaque, int irq, 
int level)
 x86_cpu_set_a20(cpu, level);
 }
 
-int 

[Qemu-devel] [PULL 14/29] cpus: Fix throttling during vm_stop

2019-09-16 Thread Paolo Bonzini
From: Yury Kotov 

Throttling thread sleeps in VCPU thread. For high throttle percentage
this sleep is more than 10ms. E.g. for 60% - 15ms, for 99% - 990ms.
vm_stop() kicks all VCPUs and waits for them. It's called at the end of
migration and because of the long sleep the migration downtime might be
more than 100ms even for downtime-limit 1ms.
Use qemu_cond_timedwait for high percentage to wake up during vm_stop.

Signed-off-by: Yury Kotov 
Reviewed-by: Eric Blake 
Message-Id: <20190909131335.16848-3-yury-ko...@yandex-team.ru>
---
 cpus.c | 25 +
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/cpus.c b/cpus.c
index 85cd451..d2c61ff 100644
--- a/cpus.c
+++ b/cpus.c
@@ -77,6 +77,8 @@
 
 #endif /* CONFIG_LINUX */
 
+static QemuMutex qemu_global_mutex;
+
 int64_t max_delay;
 int64_t max_advance;
 
@@ -782,7 +784,7 @@ static void cpu_throttle_thread(CPUState *cpu, 
run_on_cpu_data opaque)
 {
 double pct;
 double throttle_ratio;
-long sleeptime_ns;
+int64_t sleeptime_ns, endtime_ns;
 
 if (!cpu_throttle_get_percentage()) {
 return;
@@ -790,11 +792,20 @@ static void cpu_throttle_thread(CPUState *cpu, 
run_on_cpu_data opaque)
 
 pct = (double)cpu_throttle_get_percentage()/100;
 throttle_ratio = pct / (1 - pct);
-sleeptime_ns = (long)(throttle_ratio * CPU_THROTTLE_TIMESLICE_NS);
-
-qemu_mutex_unlock_iothread();
-g_usleep(sleeptime_ns / 1000); /* Convert ns to us for usleep call */
-qemu_mutex_lock_iothread();
+/* Add 1ns to fix double's rounding error (like 0.999...) */
+sleeptime_ns = (int64_t)(throttle_ratio * CPU_THROTTLE_TIMESLICE_NS + 1);
+endtime_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME) + sleeptime_ns;
+while (sleeptime_ns > 0 && !cpu->stop) {
+if (sleeptime_ns > SCALE_MS) {
+qemu_cond_timedwait(cpu->halt_cond, _global_mutex,
+sleeptime_ns / SCALE_MS);
+} else {
+qemu_mutex_unlock_iothread();
+g_usleep(sleeptime_ns / SCALE_US);
+qemu_mutex_lock_iothread();
+}
+sleeptime_ns = endtime_ns - qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
+}
 atomic_set(>throttle_thread_scheduled, 0);
 }
 
@@ -1172,8 +1183,6 @@ static void qemu_init_sigbus(void)
 }
 #endif /* !CONFIG_LINUX */
 
-static QemuMutex qemu_global_mutex;
-
 static QemuThread io_thread;
 
 /* cpu creation */
-- 
1.8.3.1





Re: [Qemu-devel] [PATCH v7 0/3] Fix qcow2+luks corruption introduced by commit 8ac0f15f335

2019-09-16 Thread Maxim Levitsky
On Mon, 2019-09-16 at 16:59 +0300, Maxim Levitsky wrote:
> On Mon, 2019-09-16 at 15:39 +0200, Max Reitz wrote:
> > On 15.09.19 22:36, Maxim Levitsky wrote:
> > > Commit 8ac0f15f335 accidently broke the COW of non changed areas
> > > of newly allocated clusters, when the write spans multiple clusters,
> > > and needs COW both prior and after the write.
> > > This results in 'after' COW area being encrypted with wrong
> > > sector address, which render it corrupted.
> > > 
> > > Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1745922
> > > 
> > > CC: qemu-stable 
> > > 
> > > V2: grammar, spelling and code style fixes.
> > > V3: more fixes after the review.
> > > V4: addressed review comments from Max Reitz,
> > > and futher refactored the qcow2_co_encrypt to just take full host and 
> > > guest offset
> > > which simplifies everything.
> > > 
> > > V5: reworked the patches so one of them fixes the bug
> > > only and other one is just refactoring
> > > 
> > > V6: removed do_perform_cow_encrypt
> > > 
> > > V7: removed do_perform_cow_encrypt take two, this
> > > time I hopefully did that correctly :-)
> > > Also updated commit names and messages a bit
> > 
> > Luckily for you (maybe), Vladimir’s series doesn‘t quite pass the
> > iotests for me, so unfortunately (I find it unfortunate) I had to remove
> > it from my branch.  Thus, the conflicts are much more tame and I felt
> > comfortable taking the series to my branch (with the remaining trivial
> > conflicts resolved, and with Vladimir’s suggestion applied):
> > 
> > https://git.xanclic.moe/XanClic/qemu/commits/branch/block
> 
> 
> First of all, Thanks!
> 
> I don't know if this is luckily for me since I already rebased my series on 
> top of  
> https://git.xanclic.moe/XanClic/qemu.git,
> and run all qcow2 iotests, and only tests 
> 162 169 194 196 234 262 failed, and I know that 162 always fails
> due to that kernel change I talked about here few days ago,
> and rest for the AF_UNIX path len, which I need to do something
> about in the long term. I sometimes do a separate build in 
> directory which path doesn't trigger this, and sometimes,
> when I know that I haven't done significant changes to the patches,
> I just let these tests fail. In long term, maybe even in a few days
> I'll allocate some time to rethink the build environment here to
> fix that permanently.
> 
> Now I am rerunning the iotests just for fun, in short enough directory
> to see if I can reproduce the failure that you had. After looking
> in your report, that iotest 026 fails, it does pass here, but
> then I am only running these iotests on my laptop so I probably
> don't trigger the race you were able to.

Passed all the tests but 162, not that it matters much to be honest.
Best regards,
Maxim Levitsky




[Qemu-devel] [PULL 15/29] hw/i386/pc: Use e820_get_num_entries() to access e820_entries

2019-09-16 Thread Paolo Bonzini
From: Philippe Mathieu-Daudé 

To be able to extract the e820* code out of this file (in the next
patch), access e820_entries with its correct helper.

Reviewed-by: Li Qiang 
Signed-off-by: Philippe Mathieu-Daudé 
Message-Id: <20190818225414.22590-2-phi...@redhat.com>
---
 hw/i386/pc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index bad866f..31e9c1f 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1029,7 +1029,7 @@ static FWCfgState *bochs_bios_init(AddressSpace *as, 
PCMachineState *pcms)
 fw_cfg_add_bytes(fw_cfg, FW_CFG_E820_TABLE,
  _reserve, sizeof(e820_reserve));
 fw_cfg_add_file(fw_cfg, "etc/e820", e820_table,
-sizeof(struct e820_entry) * e820_entries);
+sizeof(struct e820_entry) * e820_get_num_entries());
 
 fw_cfg_add_bytes(fw_cfg, FW_CFG_HPET, _cfg, sizeof(hpet_cfg));
 /* allocate memory for the NUMA channel: one (64bit) word for the number
-- 
1.8.3.1





Re: [Qemu-devel] [PATCH V7 6/6] hostmem-file: add 'sync' option

2019-09-16 Thread Michael S. Tsirkin
On Mon, Dec 24, 2018 at 04:11:43PM +0800, Yi Zhang wrote:
> On 2018-12-21 at 11:36:07 -0500, Michael S. Tsirkin wrote:
> > On Fri, Dec 21, 2018 at 11:18:18AM +0800, Yi Zhang wrote:
> > > On 2018-12-20 at 09:06:41 -0500, Michael S. Tsirkin wrote:
> > > > On Thu, Dec 20, 2018 at 01:37:40PM +0800, Yi Zhang wrote:
> > > > > On 2018-12-19 at 22:42:07 -0500, Michael S. Tsirkin wrote:
> > > > > > On Thu, Dec 20, 2018 at 11:03:12AM +0800, Yi Zhang wrote:
> > > > > > > On 2018-12-19 at 10:59:10 -0500, Michael S. Tsirkin wrote:
> > > > > > > > On Wed, Dec 19, 2018 at 05:10:18PM +0800, Yi Zhang wrote:
> > > > > > > > > > > +
> > > > > > > > > > > + - 'sync' option of memory-backend-file is not 'off', and
> > > > > > > > > > > +
> > > > > > > > > > > + - 'share' option of memory-backend-file is 'on'.
> > > > > > > > > > > +
> > > > > > > > > > > + - 'pmem' option of memory-backend-file is 'on'
> > > > > > > > > > > +
> > > > > > > > > > 
> > > > > > > > > > Wait isn't this what pmem was supposed to do?
> > > > > > > > > > Doesn't it mean "persistent memory"?
> > > > > > > > > pmem is a option for memory-backend-file, user should know 
> > > > > > > > > the backend
> > > > > > > > > is in host persistent memory, with this flags on, while there 
> > > > > > > > > is a host crash
> > > > > > > > > or a power failures.
> > > > > > > > > 
> > > > > > > > > [1] Qemu will take necessary operations to guarantee the 
> > > > > > > > > persistence.
> > > > > > > > > https://patchwork.ozlabs.org/cover/944749/ 
> > > > > > > > > 
> > > > > > > > > [2] Host kernel also take opretions to consistent filesystem 
> > > > > > > > > metadata.
> > > > > > > > > Add MAP_SYNC flags.
> > > > > > > > 
> > > > > > > > OK so I'm a user. Can you educate me please?  
> > > > > > > We suppose an administrator should know it, what is the back-end 
> > > > > > > region coming from,
> > > > > > > is it persistent? what is the font-end device is? a volatile dimm 
> > > > > > > or an
> > > > > > > nonvolatile dimm? then they can choice put the pmem=on[off] and 
> > > > > > > sync=on[off].
> > > > > > > If he didn't, we encourage that don't set these 2 flags.
> > > > > > > 
> > > > > > > > When should MAP_SYNC not
> > > > > > > > be set? Are there any disadvantages (e.g.  performance?)?
> > > > > > > Not only the performance, sometimes like the front-end device is 
> > > > > > > an
> > > > > > > volatile ram, we don't wanna set such option although the backend 
> > > > > > > is a
> > > > > > > novolatile memory, if power lose, all of thing should lose in 
> > > > > > > this ram.
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > I am not sure how does above answer the questions. If I don't know,
> > > > > > neither will the hypothetical administrator. Looks like a better
> > > > > > interface is needed to make the choice on behalf of the user.
> > > > > > 
> > > > > By default, we have already ignore the 2 flags, unless the 
> > > > > administrator
> > > > > know how to make that use. By-now, seems we don't have a better way 
> > > > > to detect what
> > > > > memory-backend-file is, a persistent memory or not.
> > > > 
> > > > In that case how about an interface where user tells QEMU "this backend
> > > > is in persistent memory"?
> > > 
> > > Actually, [pmem=on] already did this, we can get the backend memory type 
> > > from:
> > > 
> > > file_memory_backend_get_pmem(),
> > > 
> > > That is already being used in the memory_region_init_ram_from_file. that
> > > is why I reuse the RAM_PMEM to identify the region coming from a
> > > persitent memory? correct me if something I misunderstood? 
> > 
> > Right and thus my question: why not set SYNC unconditionally with pmem=on?
> A case is that we set pmem but don't wanna sync in a /dev/dax backend,
> which is direct mapping to physical nvdimm device without filesystem aware,
> SYNC is useless in this condition.

Does it hurt though?

> > 
> > > 
> > > > 
> > > > 
> > > > 
> > > > > > 
> > > > > > > > 
> > > > > > > > -- 
> > > > > > > > MST
> > > > > > > > 
> > > > > > 
> > > > 
> > 



[Qemu-devel] [PULL 11/29] memory: fetch pmem size in get_file_size()

2019-09-16 Thread Paolo Bonzini
From: Stefan Hajnoczi 

Neither stat(2) nor lseek(2) report the size of Linux devdax pmem
character device nodes.  Commit 314aec4a6e06844937f1677f6cba21981005f389
("hostmem-file: reject invalid pmem file sizes") added code to
hostmem-file.c to fetch the size from sysfs and compare against the
user-provided size=NUM parameter:

  if (backend->size > size) {
  error_setg(errp, "size property %" PRIu64 " is larger than "
 "pmem file \"%s\" size %" PRIu64, backend->size,
 fb->mem_path, size);
  return;
  }

It turns out that exec.c:qemu_ram_alloc_from_fd() already has an
equivalent size check but it skips devdax pmem character devices because
lseek(2) returns 0:

  if (file_size > 0 && file_size < size) {
  error_setg(errp, "backing store %s size 0x%" PRIx64
 " does not match 'size' option 0x" RAM_ADDR_FMT,
 mem_path, file_size, size);
  return NULL;
  }

This patch moves the devdax pmem file size code into get_file_size() so
that we check the memory size in a single place:
qemu_ram_alloc_from_fd().  This simplifies the code and makes it more
general.

This also fixes the problem that hostmem-file only checks the devdax
pmem file size when the pmem=on parameter is given.  An unchecked
size=NUM parameter can lead to SIGBUS in QEMU so we must always fetch
the file size for Linux devdax pmem character device nodes.

Signed-off-by: Stefan Hajnoczi 
Message-Id: <20190830093056.12572-1-stefa...@redhat.com>
Reviewed-by: Eduardo Habkost 
Signed-off-by: Paolo Bonzini 
---
 backends/hostmem-file.c | 22 
 exec.c  | 34 ++-
 include/qemu/osdep.h| 13 
 util/oslib-posix.c  | 54 -
 util/oslib-win32.c  |  6 --
 5 files changed, 33 insertions(+), 96 deletions(-)

diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c
index ecc15e3..be64020 100644
--- a/backends/hostmem-file.c
+++ b/backends/hostmem-file.c
@@ -58,28 +58,6 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error 
**errp)
 return;
 }
 
-/*
- * Verify pmem file size since starting a guest with an incorrect size
- * leads to confusing failures inside the guest.
- */
-if (fb->is_pmem) {
-Error *local_err = NULL;
-uint64_t size;
-
-size = qemu_get_pmem_size(fb->mem_path, _err);
-if (local_err) {
-error_propagate(errp, local_err);
-return;
-}
-
-if (size && backend->size > size) {
-error_setg(errp, "size property %" PRIu64 " is larger than "
-   "pmem file \"%s\" size %" PRIu64, backend->size,
-   fb->mem_path, size);
-return;
-}
-}
-
 backend->force_prealloc = mem_prealloc;
 name = host_memory_backend_get_name(backend);
 memory_region_init_ram_from_file(>mr, OBJECT(backend),
diff --git a/exec.c b/exec.c
index b9511be..8b99897 100644
--- a/exec.c
+++ b/exec.c
@@ -1791,7 +1791,39 @@ long qemu_maxrampagesize(void)
 #ifdef CONFIG_POSIX
 static int64_t get_file_size(int fd)
 {
-int64_t size = lseek(fd, 0, SEEK_END);
+int64_t size;
+#if defined(__linux__)
+struct stat st;
+
+if (fstat(fd, ) < 0) {
+return -errno;
+}
+
+/* Special handling for devdax character devices */
+if (S_ISCHR(st.st_mode)) {
+g_autofree char *subsystem_path = NULL;
+g_autofree char *subsystem = NULL;
+
+subsystem_path = g_strdup_printf("/sys/dev/char/%d:%d/subsystem",
+ major(st.st_rdev), minor(st.st_rdev));
+subsystem = g_file_read_link(subsystem_path, NULL);
+
+if (subsystem && g_str_has_suffix(subsystem, "/dax")) {
+g_autofree char *size_path = NULL;
+g_autofree char *size_str = NULL;
+
+size_path = g_strdup_printf("/sys/dev/char/%d:%d/size",
+major(st.st_rdev), minor(st.st_rdev));
+
+if (g_file_get_contents(size_path, _str, NULL, NULL)) {
+return g_ascii_strtoll(size_str, NULL, 0);
+}
+}
+}
+#endif /* defined(__linux__) */
+
+/* st.st_size may be zero for special files yet lseek(2) works */
+size = lseek(fd, 0, SEEK_END);
 if (size < 0) {
 return -errno;
 }
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index af2b91f..c7d242f 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -571,19 +571,6 @@ void os_mem_prealloc(int fd, char *area, size_t sz, int 
smp_cpus,
  Error **errp);
 
 /**
- * qemu_get_pmem_size:
- * @filename: path to a pmem file
- * @errp: pointer to a NULL-initialized error object
- *
- * Determine the size of a persistent memory file.  Besides supporting files on
- * DAX file systems, this function also supports Linux devdax character
- * devices.
- *
- * Returns: 

[Qemu-devel] [PULL 12/29] memory: inline and optimize devend_memop

2019-09-16 Thread Paolo Bonzini
devend_memop can rely on the fact that the result is always either
0 or MO_BSWAP, corresponding respectively to host endianness and
the opposite.  Native (target) endianness in turn can be either
the host endianness, in which case MO_BSWAP is only returned for
host-opposite endianness, or the opposite, in which case 0 is only
returned for host endianness.

With this in mind, devend_memop can be compiled as a setcond+shift
for every target.  Do this and, while at it, move it to
include/exec/memory.h since !NEED_CPU_H files do not (and should not)
need it.

Reviewed-by: Richard Henderson 
Signed-off-by: Paolo Bonzini 
---
 include/exec/memory.h | 19 ++-
 memory.c  | 18 --
 2 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/include/exec/memory.h b/include/exec/memory.h
index 2dd8102..a30245c 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -2201,8 +2201,25 @@ address_space_write_cached(MemoryRegionCache *cache, 
hwaddr addr,
 }
 }
 
+#ifdef NEED_CPU_H
 /* enum device_endian to MemOp.  */
-MemOp devend_memop(enum device_endian end);
+static inline MemOp devend_memop(enum device_endian end)
+{
+QEMU_BUILD_BUG_ON(DEVICE_HOST_ENDIAN != DEVICE_LITTLE_ENDIAN &&
+  DEVICE_HOST_ENDIAN != DEVICE_BIG_ENDIAN);
+
+#if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN)
+/* Swap if non-host endianness or native (target) endianness */
+return (end == DEVICE_HOST_ENDIAN) ? 0 : MO_BSWAP;
+#else
+const int non_host_endianness =
+DEVICE_LITTLE_ENDIAN ^ DEVICE_BIG_ENDIAN ^ DEVICE_HOST_ENDIAN;
+
+/* In this case, native (target) endianness needs no swap.  */
+return (end == non_host_endianness) ? MO_BSWAP : 0;
+#endif
+}
+#endif
 
 #endif
 
diff --git a/memory.c b/memory.c
index 61a254c..b9dd6b9 100644
--- a/memory.c
+++ b/memory.c
@@ -3267,21 +3267,3 @@ static void memory_register_types(void)
 }
 
 type_init(memory_register_types)
-
-MemOp devend_memop(enum device_endian end)
-{
-static MemOp conv[] = {
-[DEVICE_LITTLE_ENDIAN] = MO_LE,
-[DEVICE_BIG_ENDIAN] = MO_BE,
-[DEVICE_NATIVE_ENDIAN] = MO_TE,
-[DEVICE_HOST_ENDIAN] = 0,
-};
-switch (end) {
-case DEVICE_LITTLE_ENDIAN:
-case DEVICE_BIG_ENDIAN:
-case DEVICE_NATIVE_ENDIAN:
-return conv[end];
-default:
-g_assert_not_reached();
-}
-}
-- 
1.8.3.1





[Qemu-devel] [PULL 09/29] hw/i386: Move CONFIG_ACPI_PCI to CONFIG_PC

2019-09-16 Thread Paolo Bonzini
From: Cole Robinson 

CONFIG_ACPI_PCI is a hard requirement of acpi-build.c, which is built
unconditionally for x86 target. Putting it in default-configs/ suggests
that it can be easily disabled, which isn't true.

Relocate the symbol with the other acpi-build.c requirements, under
'config PC'. This is similar to what is done for the arm 'virt' machine
type and CONFIG_ACPI_PCI

Signed-off-by: Cole Robinson 
Message-Id: 

Signed-off-by: Paolo Bonzini 
---
 default-configs/i386-softmmu.mak | 1 -
 hw/i386/Kconfig  | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
index cd5ea39..ba3fb3f 100644
--- a/default-configs/i386-softmmu.mak
+++ b/default-configs/i386-softmmu.mak
@@ -25,4 +25,3 @@
 CONFIG_ISAPC=y
 CONFIG_I440FX=y
 CONFIG_Q35=y
-CONFIG_ACPI_PCI=y
diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig
index 6350438..c7a9d63 100644
--- a/hw/i386/Kconfig
+++ b/hw/i386/Kconfig
@@ -29,6 +29,7 @@ config PC
 select MC146818RTC
 # For ACPI builder:
 select SERIAL_ISA
+select ACPI_PCI
 select ACPI_VMGENID
 select VIRTIO_PMEM_SUPPORTED
 
-- 
1.8.3.1





Re: [Qemu-devel] [RFC v3 2/3] intc/arm_gic: Support IRQ injection for more than 256 vpus

2019-09-16 Thread Andrew Jones
On Fri, Sep 13, 2019 at 11:56:38AM +0200, Eric Auger wrote:
> Host kernels that expose the KVM_CAP_ARM_IRQ_LINE_LAYOUT_2 capability
> allow injection of interrupts along with vcpu ids larger than 255.
> Let's encode the vpcu id on 12 bits according to the upgraded KVM_IRQ_LINE
> ABI when needed.
> 
> Given that we have two callsites that need to assemble
> the value for kvm_set_irq(), a new helper routine, kvm_arm_set_irq
> is introduced.
> 
> Without that patch qemu exits with "kvm_set_irq: Invalid argument"
> message.
> 
> Signed-off-by: Eric Auger 
> Reported-by: Zenghui Yu 
> 
> ---
> 
> v2 -> v3:
> - remove if (cpu !=0), drop mask, as per Drew's suggestions
> ---
>  hw/intc/arm_gic_kvm.c |  7 ++-
>  target/arm/cpu.c  | 10 --
>  target/arm/kvm.c  | 12 
>  target/arm/kvm_arm.h  |  1 +
>  4 files changed, 19 insertions(+), 11 deletions(-)
> 
> diff --git a/hw/intc/arm_gic_kvm.c b/hw/intc/arm_gic_kvm.c
> index b56fda144f..9deb15e7e6 100644
> --- a/hw/intc/arm_gic_kvm.c
> +++ b/hw/intc/arm_gic_kvm.c
> @@ -55,7 +55,7 @@ void kvm_arm_gic_set_irq(uint32_t num_irq, int irq, int 
> level)
>   * has separate fields in the irq number for type,
>   * CPU number and interrupt number.
>   */
> -int kvm_irq, irqtype, cpu;
> +int irqtype, cpu;
>  
>  if (irq < (num_irq - GIC_INTERNAL)) {
>  /* External interrupt. The kernel numbers these like the GIC
> @@ -72,10 +72,7 @@ void kvm_arm_gic_set_irq(uint32_t num_irq, int irq, int 
> level)
>  cpu = irq / GIC_INTERNAL;
>  irq %= GIC_INTERNAL;
>  }
> -kvm_irq = (irqtype << KVM_ARM_IRQ_TYPE_SHIFT)
> -| (cpu << KVM_ARM_IRQ_VCPU_SHIFT) | irq;
> -
> -kvm_set_irq(kvm_state, kvm_irq, !!level);
> +kvm_arm_set_irq(cpu, irqtype, irq, !!level);
>  }
>  
>  static void kvm_arm_gicv2_set_irq(void *opaque, int irq, int level)
> diff --git a/target/arm/cpu.c b/target/arm/cpu.c
> index 2399c14471..13813fb213 100644
> --- a/target/arm/cpu.c
> +++ b/target/arm/cpu.c
> @@ -576,16 +576,16 @@ static void arm_cpu_kvm_set_irq(void *opaque, int irq, 
> int level)
>  ARMCPU *cpu = opaque;
>  CPUARMState *env = >env;
>  CPUState *cs = CPU(cpu);
> -int kvm_irq = KVM_ARM_IRQ_TYPE_CPU << KVM_ARM_IRQ_TYPE_SHIFT;
>  uint32_t linestate_bit;
> +int irq_id;
>  
>  switch (irq) {
>  case ARM_CPU_IRQ:
> -kvm_irq |= KVM_ARM_IRQ_CPU_IRQ;
> +irq_id = KVM_ARM_IRQ_CPU_IRQ;
>  linestate_bit = CPU_INTERRUPT_HARD;
>  break;
>  case ARM_CPU_FIQ:
> -kvm_irq |= KVM_ARM_IRQ_CPU_FIQ;
> +irq_id = KVM_ARM_IRQ_CPU_FIQ;
>  linestate_bit = CPU_INTERRUPT_FIQ;
>  break;
>  default:
> @@ -597,9 +597,7 @@ static void arm_cpu_kvm_set_irq(void *opaque, int irq, 
> int level)
>  } else {
>  env->irq_line_state &= ~linestate_bit;
>  }
> -
> -kvm_irq |= cs->cpu_index << KVM_ARM_IRQ_VCPU_SHIFT;
> -kvm_set_irq(kvm_state, kvm_irq, level ? 1 : 0);
> +kvm_arm_set_irq(cs->cpu_index, KVM_ARM_IRQ_TYPE_CPU, irq_id, !!level);
>  #endif
>  }
>  
> diff --git a/target/arm/kvm.c b/target/arm/kvm.c
> index b2eaa50b8d..b10581fa06 100644
> --- a/target/arm/kvm.c
> +++ b/target/arm/kvm.c
> @@ -744,6 +744,18 @@ int kvm_arm_vgic_probe(void)
>  }
>  }
>  
> +int kvm_arm_set_irq(int cpu, int irqtype, int irq, int level)
> +{
> +int kvm_irq = (irqtype << KVM_ARM_IRQ_TYPE_SHIFT) | irq;
> +int cpu_idx1 = cpu % 256;
> +int cpu_idx2 = cpu / 256;
> +
> +kvm_irq |= (cpu_idx1 << KVM_ARM_IRQ_VCPU_SHIFT) |
> +   (cpu_idx2 << KVM_ARM_IRQ_VCPU2_SHIFT);
> +
> +return kvm_set_irq(kvm_state, kvm_irq, !!level);
> +}
> +
>  int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route,
>   uint64_t address, uint32_t data, PCIDevice *dev)
>  {
> diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h
> index b3106c8600..b4e19457a0 100644
> --- a/target/arm/kvm_arm.h
> +++ b/target/arm/kvm_arm.h
> @@ -253,6 +253,7 @@ int kvm_arm_vgic_probe(void);
>  
>  void kvm_arm_pmu_set_irq(CPUState *cs, int irq);
>  void kvm_arm_pmu_init(CPUState *cs);
> +int kvm_arm_set_irq(int cpu, int irqtype, int irq, int level);
>  
>  #else
>  
> -- 
> 2.20.1
> 
>

Reviewed-by: Andrew Jones 



[Qemu-devel] [PULL 01/29] i386/kvm: support guest access CORE cstate

2019-09-16 Thread Paolo Bonzini
From: Wanpeng Li 

Allow guest reads CORE cstate when exposing host CPU power management 
capabilities
to the guest. PKG cstate is restricted to avoid a guest to get the whole package
information in multi-tenant scenario.

Cc: Eduardo Habkost 
Cc: Paolo Bonzini 
Cc: Radim Krčmář 
Signed-off-by: Wanpeng Li 
Message-Id: <1563154124-18579-1-git-send-email-wanpen...@tencent.com>
Signed-off-by: Paolo Bonzini 
---
 linux-headers/linux/kvm.h | 4 +++-
 target/i386/kvm.c | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
index c8423e7..18892d6 100644
--- a/linux-headers/linux/kvm.h
+++ b/linux-headers/linux/kvm.h
@@ -696,9 +696,11 @@ struct kvm_ioeventfd {
 #define KVM_X86_DISABLE_EXITS_MWAIT  (1 << 0)
 #define KVM_X86_DISABLE_EXITS_HLT(1 << 1)
 #define KVM_X86_DISABLE_EXITS_PAUSE  (1 << 2)
+#define KVM_X86_DISABLE_EXITS_CSTATE (1 << 3)
 #define KVM_X86_DISABLE_VALID_EXITS  (KVM_X86_DISABLE_EXITS_MWAIT | \
   KVM_X86_DISABLE_EXITS_HLT | \
-  KVM_X86_DISABLE_EXITS_PAUSE)
+  KVM_X86_DISABLE_EXITS_PAUSE | \
+  KVM_X86_DISABLE_EXITS_CSTATE)
 
 /* for KVM_ENABLE_CAP */
 struct kvm_enable_cap {
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index 8023c67..3435fc4 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -2076,7 +2076,8 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
 if (disable_exits) {
 disable_exits &= (KVM_X86_DISABLE_EXITS_MWAIT |
   KVM_X86_DISABLE_EXITS_HLT |
-  KVM_X86_DISABLE_EXITS_PAUSE);
+  KVM_X86_DISABLE_EXITS_PAUSE |
+  KVM_X86_DISABLE_EXITS_CSTATE);
 }
 
 ret = kvm_vm_enable_cap(s, KVM_CAP_X86_DISABLE_EXITS, 0,
-- 
1.8.3.1





[Qemu-devel] [PULL 06/29] exec.c: add a check between constants to see whether we could skip

2019-09-16 Thread Paolo Bonzini
From: Wei Yang 

The maximum level is defined as P_L2_LEVELS and skip is defined with 6
bits, which means if P_L2_LEVELS < (1 << 6), skip never exceeds the
boundary.

Since this check is between two constants, which leverages compiler
to optimize the code based on different configuration.

Signed-off-by: Wei Yang 
Message-Id: <20190321082555.21118-7-richardw.y...@linux.intel.com>
Signed-off-by: Paolo Bonzini 
---
 exec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/exec.c b/exec.c
index d1969bb..b9511be 100644
--- a/exec.c
+++ b/exec.c
@@ -324,7 +324,8 @@ static void phys_page_compact(PhysPageEntry *lp, Node 
*nodes)
 assert(valid_ptr < P_L2_SIZE);
 
 /* Don't compress if it won't fit in the # of bits we have. */
-if (lp->skip + p[valid_ptr].skip >= (1 << 6)) {
+if (P_L2_LEVELS >= (1 << 6) &&
+lp->skip + p[valid_ptr].skip >= (1 << 6)) {
 return;
 }
 
-- 
1.8.3.1





Re: [Qemu-devel] [PATCH v6 28/42] stream: Deal with filters

2019-09-16 Thread Kevin Wolf
Am 16.09.2019 um 11:52 hat Max Reitz geschrieben:
> On 13.09.19 16:16, Kevin Wolf wrote:
> > Am 09.08.2019 um 18:13 hat Max Reitz geschrieben:
> >> @@ -261,16 +272,19 @@ void stream_start(const char *job_id, 
> >> BlockDriverState *bs,
> >>   * disappear from the chain after this operation. The streaming job 
> >> reads
> >>   * every block only once, assuming that it doesn't change, so forbid 
> >> writes
> >>   * and resizes. Reassign the base node pointer because the backing BS 
> >> of the
> >> - * bottom node might change after the call to 
> >> bdrv_reopen_set_read_only()
> >> - * due to parallel block jobs running.
> >> + * above_base node might change after the call to
> >> + * bdrv_reopen_set_read_only() due to parallel block jobs running.
> >>   */
> >> -base = backing_bs(bottom);
> >> -for (iter = backing_bs(bs); iter && iter != base; iter = 
> >> backing_bs(iter)) {
> >> +base = bdrv_filtered_bs(above_base);
> > 
> > We just calculated above_base such that it's the parent of base. Why
> > would base not already have the value we're assigning it again here?
> 
> That’s no change to existing code, whose reasoning is explained in the
> comment above: bdrv_reopen_set_read_only() can yield, which might lead
> to children of the bottom node changing.
> 
> If you feel like either that’s superfluous, or that if something like
> that were to happen we’d have much bigger problems, be my guest to drop
> both.
> 
> But in this series I’d rather just not change it.

Ah, you mean comments are there to be read?

But actually, I think iterating down to base is too much anyway. The
reasoning in the comment for block_job_add_bdrv() is that the nodes will
be dropped at the end. But base with all of its filter will be kept
after this patch.

So I think the for loop should stop after bs->base_overlay. And then
concurrently changing links aren't even a problem any more because
that's exactly the place up to which we've frozen the chain.

Kevin


signature.asc
Description: PGP signature


  1   2   3   >