Re: [Qemu-devel] [RFC 00/17] multi-phase reset mechanism

2019-05-03 Thread Peter Maydell
On Mon, 29 Apr 2019 at 10:41, Peter Maydell  wrote:
>
> On Mon, 29 Apr 2019 at 10:36, Damien Hedde  wrote:
> >
> > Hi All,
> >
> > Any comment about this ?
>
> Sorry we haven't got to this yet. This is on my to-review list,
> but so are 23 other series, and I've been on holiday for the
> past week or so. I will try to get to it this week.

I made a start on this, but it's going to take me some time
to wrap my head around the design and the issues you raise
in the cover letter. Given the bank holiday on Monday and
some other commitments I have on Tuesday I think it's going
to be the second half of next week at best before I can
do a proper response.

In general I like the code (though as you say we may not
have got the interface quite right -- I had not appreciated
some of the nested-reset cases when I proposed it I think).

I think we could use a document (which would eventually live
in docs/devel) that describes the reset system and provides some
how-to style documentation for
 * what you need to do if you're writing a device
 * what you need to do if you are an external user of
   a device model and you want to reset it
plus some notes on whatever we still have left over as
remnants of the old reset scheme and any intended transitions
to try to remove those remnants. I'll have a go at writing
something because I think that will help me personally in
trying to understand the problem domain and what the new
design is doing.

thanks
-- PMM



Re: [Qemu-devel] [PATCH v4] hw/virtio/virtio-mmio: Convert DPRINTF to trace and log

2019-05-03 Thread Philippe Mathieu-Daudé
On 5/3/19 5:44 PM, Boxuan Li wrote:
> Use traces for debug message and qemu_log_mask for errors.
> 
> Signed-off-by: Boxuan Li 

Reviewed-by: Philippe Mathieu-Daudé 
Tested-by: Philippe Mathieu-Daudé 

Thanks for all your iterations!

> ---
> v1: https://patchew.org/QEMU/20190428110258.86681-1-libox...@connect.hku.hk/
> v2: https://patchew.org/QEMU/20190501081039.58938-1-libox...@connect.hku.hk/
> v3: https://patchew.org/QEMU/20190503084654.18413-1-libox...@connect.hku.hk/
> v4: Fix indentation and do not convert uint64_t to int
> ---
>  hw/virtio/trace-events  |  7 +++
>  hw/virtio/virtio-mmio.c | 44 +---
>  2 files changed, 28 insertions(+), 23 deletions(-)
> 
> diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events
> index 60c649c4bc..e28ba48da6 100644
> --- a/hw/virtio/trace-events
> +++ b/hw/virtio/trace-events
> @@ -46,3 +46,10 @@ virtio_balloon_handle_output(const char *name, uint64_t 
> gpa) "section name: %s g
>  virtio_balloon_get_config(uint32_t num_pages, uint32_t actual) "num_pages: 
> %d actual: %d"
>  virtio_balloon_set_config(uint32_t actual, uint32_t oldactual) "actual: %d 
> oldactual: %d"
>  virtio_balloon_to_target(uint64_t target, uint32_t num_pages) "balloon 
> target: 0x%"PRIx64" num_pages: %d"
> +
> +# virtio-mmio.c
> +virtio_mmio_read(uint64_t offset) "virtio_mmio_read offset 0x%" PRIx64
> +virtio_mmio_write_offset(uint64_t offset, uint64_t value) "virtio_mmio_write 
> offset 0x%" PRIx64 " value 0x%" PRIx64
> +virtio_mmio_guest_page(uint64_t size, int shift) "guest page size 0x%" 
> PRIx64 " shift %d"
> +virtio_mmio_queue_write(uint64_t value, int max_size) "mmio_queue write 0x%" 
> PRIx64 " max %d"
> +virtio_mmio_setting_irq(int level) "virtio_mmio setting IRQ %d"
> diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c
> index 5807aa87fe..96c762f0bf 100644
> --- a/hw/virtio/virtio-mmio.c
> +++ b/hw/virtio/virtio-mmio.c
> @@ -27,16 +27,8 @@
>  #include "sysemu/kvm.h"
>  #include "hw/virtio/virtio-bus.h"
>  #include "qemu/error-report.h"
> -
> -/* #define DEBUG_VIRTIO_MMIO */
> -
> -#ifdef DEBUG_VIRTIO_MMIO
> -
> -#define DPRINTF(fmt, ...) \
> -do { printf("virtio_mmio: " fmt , ## __VA_ARGS__); } while (0)
> -#else
> -#define DPRINTF(fmt, ...) do {} while (0)
> -#endif
> +#include "qemu/log.h"
> +#include "trace.h"
>  
>  /* QOM macros */
>  /* virtio-mmio-bus */
> @@ -107,7 +99,7 @@ static uint64_t virtio_mmio_read(void *opaque, hwaddr 
> offset, unsigned size)
>  VirtIOMMIOProxy *proxy = (VirtIOMMIOProxy *)opaque;
>  VirtIODevice *vdev = virtio_bus_get_device(>bus);
>  
> -DPRINTF("virtio_mmio_read offset 0x%x\n", (int)offset);
> +trace_virtio_mmio_read(offset);
>  
>  if (!vdev) {
>  /* If no backend is present, we treat most registers as
> @@ -144,7 +136,9 @@ static uint64_t virtio_mmio_read(void *opaque, hwaddr 
> offset, unsigned size)
>  }
>  }
>  if (size != 4) {
> -DPRINTF("wrong size access to register!\n");
> +qemu_log_mask(LOG_GUEST_ERROR,
> +  "%s: wrong size access to register!\n",
> +  __func__);
>  return 0;
>  }
>  switch (offset) {
> @@ -182,10 +176,12 @@ static uint64_t virtio_mmio_read(void *opaque, hwaddr 
> offset, unsigned size)
>  case VIRTIO_MMIO_QUEUE_ALIGN:
>  case VIRTIO_MMIO_QUEUE_NOTIFY:
>  case VIRTIO_MMIO_INTERRUPT_ACK:
> -DPRINTF("read of write-only register\n");
> +qemu_log_mask(LOG_GUEST_ERROR,
> +  "%s: read of write-only register\n",
> +  __func__);
>  return 0;
>  default:
> -DPRINTF("bad register offset\n");
> +qemu_log_mask(LOG_GUEST_ERROR, "%s: bad register offset\n", 
> __func__);
>  return 0;
>  }
>  return 0;
> @@ -197,8 +193,7 @@ static void virtio_mmio_write(void *opaque, hwaddr 
> offset, uint64_t value,
>  VirtIOMMIOProxy *proxy = (VirtIOMMIOProxy *)opaque;
>  VirtIODevice *vdev = virtio_bus_get_device(>bus);
>  
> -DPRINTF("virtio_mmio_write offset 0x%x value 0x%" PRIx64 "\n",
> -(int)offset, value);
> +trace_virtio_mmio_write_offset(offset, value);
>  
>  if (!vdev) {
>  /* If no backend is present, we just make all registers
> @@ -226,7 +221,9 @@ static void virtio_mmio_write(void *opaque, hwaddr 
> offset, uint64_t value,
>  return;
>  }
>  if (size != 4) {
> -DPRINTF("wrong size access to register!\n");
> +qemu_log_mask(LOG_GUEST_ERROR,
> +  "%s: wrong size access to register!\n",
> +  __func__);
>  return;
>  }
>  switch (offset) {
> @@ -246,8 +243,7 @@ static void virtio_mmio_write(void *opaque, hwaddr 
> offset, uint64_t value,
>  if (proxy->guest_page_shift > 31) {
>  proxy->guest_page_shift = 0;
>  }
> -DPRINTF("guest page size %" PRIx64 " shift %d\n", value,
> -

Re: [Qemu-devel] [PATCH v3 1/4] QEMU_PACKED: Remove gcc_struct attribute in Windows non x86 targets

2019-05-03 Thread Marc-André Lureau
Hi

Le ven. 3 mai 2019 à 17:23, Peter Maydell  a
écrit :

> On Fri, 3 May 2019 at 06:07, Thomas Huth  wrote:
> >
> > On 03/05/2019 02.36, Cao Jiaxi wrote:
> > > gcc_struct is for x86 only, and it generates an warning on ARM64
> Clang/MinGW targets.
> > >
> > > Signed-off-by: Cao Jiaxi 
> > > ---
> > >  contrib/libvhost-user/libvhost-user.h | 2 +-
> > >  include/qemu/compiler.h   | 2 +-
> > >  scripts/cocci-macro-file.h| 7 ++-
> > >  slirp/src/util.h  | 2 +-
> > >  4 files changed, 9 insertions(+), 4 deletions(-)
>
> > > diff --git a/slirp/src/util.h b/slirp/src/util.h
> > > index 01f1e0e068..278828fe3f 100644
> > > --- a/slirp/src/util.h
> > > +++ b/slirp/src/util.h
> > > @@ -43,7 +43,7 @@
> > >  #include 
> > >  #endif
> > >
> > > -#if defined(_WIN32)
> > > +#if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__))
> > >  # define SLIRP_PACKED __attribute__((gcc_struct, packed))
> > >  #else
> > >  # define SLIRP_PACKED __attribute__((packed))
> > >
> >
> > The slirp code is currently on its way into a separate module, so you
> > might need to provide that hunk to the libslirp folks again... I'm
> > putting the slirp maintainers on CC:, maybe they can pick it up from
> here.
>
> Yes, the slirp module has now landed in master, so this patch
> definitely needs to be split into two. I've kept in my
> target-arm.next tree the parts which are applicable to
> the QEMU repo itself (ie everything except the slirp/ change),
> so we just need a new patch for the slirp submodule part.
>
> Marc-André, Samuel -- what's the process for submitting and
> getting reviewed changes to the slirp submodule now it's a
> separate project ?
>

It's hosted on gitlab.freedesktop.org, with some CI. It's fine to send
patches on qemu devel, as long as Samuel or I are in CC. But in the long
term, I think gitlab MR will be favoured (after a while using it, I think
gitlab is better than ML for patches & bug tracking tbh)

>


Re: [Qemu-devel] [PATCH RFC v8 04/12] target/rx: RX disassembler

2019-05-03 Thread Alex Bennée


Yoshinori Sato  writes:

> Signed-off-by: Yoshinori Sato 
> ---
>  include/disas/dis-asm.h |5 +
>  target/rx/disas.c   | 1481 
> +++
>  2 files changed, 1486 insertions(+)
>  create mode 100644 target/rx/disas.c
>
> diff --git a/include/disas/dis-asm.h b/include/disas/dis-asm.h
> index 9240ec32c2..de17792e88 100644
> --- a/include/disas/dis-asm.h
> +++ b/include/disas/dis-asm.h
> @@ -226,6 +226,10 @@ enum bfd_architecture
>  #define bfd_mach_nios2r22
>bfd_arch_lm32,   /* Lattice Mico32 */
>  #define bfd_mach_lm32 1
> +  bfd_arch_rx,   /* Renesas RX */
> +#define bfd_mach_rx0x75
> +#define bfd_mach_rx_v2 0x76
> +#define bfd_mach_rx_v3 0x77
>bfd_arch_last
>};
>  #define bfd_mach_s390_31 31
> @@ -433,6 +437,7 @@ int print_insn_little_nios2 (bfd_vma, 
> disassemble_info*);
>  int print_insn_xtensa   (bfd_vma, disassemble_info*);
>  int print_insn_riscv32  (bfd_vma, disassemble_info*);
>  int print_insn_riscv64  (bfd_vma, disassemble_info*);
> +int print_insn_rx(bfd_vma, disassemble_info *);
>
>  #if 0
>  /* Fetch the disassembler for a given BFD, if that support is available.  */
> diff --git a/target/rx/disas.c b/target/rx/disas.c
> new file mode 100644
> index 00..014fadfca3
> --- /dev/null
> +++ b/target/rx/disas.c
> @@ -0,0 +1,1481 @@
> +/*
> + * Renesas RX Disassembler
> + *
> + * Copyright (c) 2019 Yoshinori Sato 
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2 or later, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope it will be useful, but WITHOUT
> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
> + * more details.
> + *
> + * You should have received a copy of the GNU General Public License along 
> with
> + * this program.  If not, see .
> + */
> +
> +#include "qemu/osdep.h"
> +#include "disas/dis-asm.h"
> +#include "qemu/bitops.h"
> +#include "cpu.h"
> +
> +typedef struct DisasContext {
> +disassemble_info *dis;
> +uint32_t addr;
> +uint32_t pc;
> +} DisasContext;
> +
> +
> +static uint32_t decode_load_bytes(DisasContext *ctx, uint32_t insn,
> +   int i, int n)
> +{
> +bfd_byte buf;
> +while (++i <= n) {
> +ctx->dis->read_memory_func(ctx->addr++, , 1, ctx->dis);
> +insn |= buf << (32 - i * 8);
> +}
> +return insn;
> +}
> +
> +static int32_t li(DisasContext *ctx, int sz)
> +{
> +int32_t addr;
> +bfd_byte buf[4];
> +addr = ctx->addr;
> +
> +switch (sz) {
> +case 1:
> +ctx->addr += 1;
> +ctx->dis->read_memory_func(addr, buf, 1, ctx->dis);
> +return buf[0];
> +case 2:
> +ctx->addr += 2;
> +ctx->dis->read_memory_func(addr, buf, 2, ctx->dis);
> +return buf[1] << 8 | buf[0];
> +case 3:
> +ctx->addr += 3;
> +ctx->dis->read_memory_func(addr, buf, 3, ctx->dis);
> +return buf[2] << 16 | buf[1] << 8 | buf[0];
> +case 0:
> +ctx->addr += 4;
> +ctx->dis->read_memory_func(addr, buf, 4, ctx->dis);
> +return buf[3] << 24 | buf[2] << 16 | buf[1] << 8 | buf[0];
> +default:
> +g_assert_not_reached();
> +}
> +}
> +
> +static int bdsp_s(DisasContext *ctx, int d)
> +{
> +/*
> + * 0 -> 8
> + * 1 -> 9
> + * 2 -> 10
> + * 3 -> 3
> + * :
> + * 7 -> 7
> + */
> +if (d < 3) {
> +d += 8;
> +}
> +return d;
> +}
> +
> +/* Include the auto-generated decoder.  */
> +#include "decode.inc.c"

This introduces a dependency on a generated file so you'll need:

target/rx/disas.o: target/rx/decode.inc.c

in Makefile.objs

--
Alex Bennée



Re: [Qemu-devel] [PATCH RFC v8 06/12] hw/intc: RX62N interrupt controller (ICUa)

2019-05-03 Thread Alex Bennée


Yoshinori Sato  writes:

> This implementation supported only ICUa.
> Hardware manual.
> https://www.renesas.com/us/en/doc/products/mpumcu/doc/rx_family/r01uh0033ej0140_rx62n.pdf
>
> Signed-off-by: Yoshinori Sato 
> ---
>  include/hw/intc/rx_icu.h |  49 +++
>  hw/intc/rx_icu.c | 373 
> +++
>  hw/intc/Makefile.objs|   1 +
>  3 files changed, 423 insertions(+)
>  create mode 100644 include/hw/intc/rx_icu.h
>  create mode 100644 hw/intc/rx_icu.c
>
> diff --git a/include/hw/intc/rx_icu.h b/include/hw/intc/rx_icu.h
> new file mode 100644
> index 00..bc46b3079b
> --- /dev/null
> +++ b/include/hw/intc/rx_icu.h
> @@ -0,0 +1,49 @@
> +#ifndef RX_ICU_H
> +#define RX_ICU_H
> +
> +#include "qemu-common.h"
> +#include "hw/irq.h"
> +
> +struct IRQSource {
> +int sense;
> +int level;
> +};
> +
> +struct RXICUState {
> +SysBusDevice parent_obj;
> +
> +MemoryRegion memory;
> +struct IRQSource src[256];
> +char *icutype;
> +uint32_t nr_irqs;
> +uint32_t *map;
> +uint32_t nr_sense;
> +uint32_t *init_sense;
> +
> +uint8_t ir[256];
> +uint8_t dtcer[256];
> +uint8_t ier[32];
> +uint8_t ipr[142];
> +uint8_t dmasr[4];
> +uint16_t fir;
> +uint8_t nmisr;
> +uint8_t nmier;
> +uint8_t nmiclr;
> +uint8_t nmicr;
> +int req_irq;
> +qemu_irq _irq;
> +qemu_irq _fir;
> +qemu_irq _swi;
> +};
> +typedef struct RXICUState RXICUState;
> +
> +#define TYPE_RXICU "rxicu"
> +#define RXICU(obj) OBJECT_CHECK(RXICUState, (obj), TYPE_RXICU)
> +
> +#define SWI 27
> +#define TRG_LEVEL 0
> +#define TRG_NEDGE 1
> +#define TRG_PEDGE 2
> +#define TRG_BEDGE 3
> +
> +#endif /* RX_ICU_H */
> diff --git a/hw/intc/rx_icu.c b/hw/intc/rx_icu.c
> new file mode 100644
> index 00..7c7336960d
> --- /dev/null
> +++ b/hw/intc/rx_icu.c
> @@ -0,0 +1,373 @@
> +/*
> + * RX Interrupt control unit
> + *
> + * Datasheet: RX62N Group, RX621 Group User's Manual: Hardware
> + * (Rev.1.40 R01UH0033EJ0140)
> + *
> + * Copyright (c) 2019 Yoshinori Sato
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2 or later, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope it will be useful, but WITHOUT
> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
> + * more details.
> + *
> + * You should have received a copy of the GNU General Public License along 
> with
> + * this program.  If not, see .
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qemu-common.h"
> +#include "qemu/log.h"
> +#include "qapi/error.h"
> +#include "cpu.h"
> +#include "hw/hw.h"
> +#include "hw/sysbus.h"
> +#include "hw/registerfields.h"
> +#include "hw/intc/rx_icu.h"
> +#include "qemu/error-report.h"
> +
> +REG8(IR, 0)
> +  FIELD(IR, IR,  0, 1)
> +REG8(DTCER, 0x100)
> +  FIELD(DTCER, DTCE,  0, 1)
> +REG8(IER, 0x200)
> +REG8(SWINTR, 0x2e0)
> +  FIELD(SWINTR, SWINT, 0, 1)
> +REG16(FIR, 0x2f0)
> +  FIELD(FIR, FVCT, 0, 8)
> +  FIELD(FIR, FIEN, 15, 1)
> +REG8(IPR, 0x300)
> +  FIELD(IPR, IPR, 0, 4)
> +REG8(DMRSR, 0x400)
> +REG8(IRQCR, 0x500)
> +  FIELD(IRQCR, IRQMD, 2, 2)
> +REG8(NMISR, 0x580)
> +  FIELD(NMISR, NMIST, 0, 1)
> +  FIELD(NMISR, LVDST, 1, 1)
> +  FIELD(NMISR, OSTST, 2, 1)
> +REG8(NMIER, 0x581)
> +  FIELD(NMIER, NMIEN, 0, 1)
> +  FIELD(NMIER, LVDEN, 1, 1)
> +  FIELD(NMIER, OSTEN, 2, 1)
> +REG8(NMICLR, 0x582)
> +  FIELD(NMICLR, NMICLR, 0, 1)
> +  FIELD(NMICLR, OSTCLR, 2, 1)
> +REG8(NMICR, 0x583)
> +  FIELD(NMICR, NMIMD, 3, 1)
> +
> +#define request(icu, n) (icu->ipr[icu->map[n]] << 8 | n)
> +
> +static qemu_irq *rxicu_pin(RXICUState *icu, int n_IRQ)
> +{
> +if ((icu->fir & R_FIR_FIEN_MASK) &&
> +(icu->fir & R_FIR_FVCT_MASK) == n_IRQ) {
> +return >_fir;
> +} else {
> +return >_irq;
> +}
> +}
> +
> +static void rxicu_request(RXICUState *icu, int n_IRQ)
> +{
> +int enable;
> +
> +enable = icu->ier[n_IRQ / 8] & (1 << (n_IRQ & 7));
> +if (n_IRQ > 0 && enable != 0 && atomic_read(>req_irq) < 0) {
> +atomic_set(>req_irq, n_IRQ);
> +qemu_set_irq(*rxicu_pin(icu, n_IRQ), request(icu, n_IRQ));
> +}
> +}
> +
> +static void rxicu_set_irq(void *opaque, int n_IRQ, int level)
> +{
> +RXICUState *icu = opaque;
> +struct IRQSource *src;
> +int issue;
> +
> +if (n_IRQ >= 256) {
> +error_report("%s: IRQ %d out of range", __func__, n_IRQ);
> +return;
> +}
> +
> +src = >src[n_IRQ];
> +
> +level = (level != 0);
> +switch (src->sense) {
> +case TRG_LEVEL:
> +/* level-sensitive irq */
> +issue = level;
> +src->level = level;
> +break;
> +case TRG_NEDGE:
> +issue = (level == 0 && src->level == 1);
> +

Re: [Qemu-devel] [PATCH] VirtIO-RNG: Update default entropy source to `/dev/urandom`

2019-05-03 Thread Daniel P . Berrangé
On Fri, May 03, 2019 at 05:46:13PM +0200, Kashyap Chamarthy wrote:
> When QEMU exposes a VirtIO-RNG device to the guest, that device needs a
> source of entropy, and that source needs to be "non-blocking", like
> `/dev/urandom`.  However, currently QEMU defaults to the problematic
> `/dev/random`, which is "blocking" (as in, it waits until sufficient
> entropy is available).
> 
> So change the entropy source to the recommended `/dev/urandom`.
> 
> Related discussion in these[1][2] past threads.
> 
> [1] https://lists.nongnu.org/archive/html/qemu-devel/2018-06/msg08335.html
> -- "RNG: Any reason QEMU doesn't default to `/dev/urandom`?"
> [2] https://lists.nongnu.org/archive/html/qemu-devel/2018-09/msg02724.html
> -- "[RFC] Virtio RNG: Consider changing the default entropy source to
>/dev/urandom"
> 
> Signed-off-by: Kashyap Chamarthy 
> ---
>  backends/rng-random.c | 2 +-
>  qemu-options.hx   | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Daniel P. Berrangé 

Regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|



[Qemu-devel] [PATCH] VirtIO-RNG: Update default entropy source to `/dev/urandom`

2019-05-03 Thread Kashyap Chamarthy
When QEMU exposes a VirtIO-RNG device to the guest, that device needs a
source of entropy, and that source needs to be "non-blocking", like
`/dev/urandom`.  However, currently QEMU defaults to the problematic
`/dev/random`, which is "blocking" (as in, it waits until sufficient
entropy is available).

So change the entropy source to the recommended `/dev/urandom`.

Related discussion in these[1][2] past threads.

[1] https://lists.nongnu.org/archive/html/qemu-devel/2018-06/msg08335.html
-- "RNG: Any reason QEMU doesn't default to `/dev/urandom`?"
[2] https://lists.nongnu.org/archive/html/qemu-devel/2018-09/msg02724.html
-- "[RFC] Virtio RNG: Consider changing the default entropy source to
   /dev/urandom"

Signed-off-by: Kashyap Chamarthy 
---
 backends/rng-random.c | 2 +-
 qemu-options.hx   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/backends/rng-random.c b/backends/rng-random.c
index e2a49b0571..eff36ef140 100644
--- a/backends/rng-random.c
+++ b/backends/rng-random.c
@@ -112,7 +112,7 @@ static void rng_random_init(Object *obj)
 rng_random_set_filename,
 NULL);
 
-s->filename = g_strdup("/dev/random");
+s->filename = g_strdup("/dev/urandom");
 s->fd = -1;
 }
 
diff --git a/qemu-options.hx b/qemu-options.hx
index 51802cbb26..a525609149 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -4276,7 +4276,7 @@ Creates a random number generator backend which obtains 
entropy from
 a device on the host. The @option{id} parameter is a unique ID that
 will be used to reference this entropy backend from the @option{virtio-rng}
 device. The @option{filename} parameter specifies which file to obtain
-entropy from and if omitted defaults to @option{/dev/random}.
+entropy from and if omitted defaults to @option{/dev/urandom}.
 
 @item -object rng-egd,id=@var{id},chardev=@var{chardevid}
 
-- 
2.17.2




[Qemu-devel] [PATCH] VirtIO-RNG: Update default entropy source to `/dev/urandom`

2019-05-03 Thread Kashyap Chamarthy
When QEMU exposes a VirtIO-RNG device to the guest, that device needs a
source of entropy, and that source needs to be "non-blocking", like
`/dev/urandom`.  However, currently QEMU defaults to the problematic
`/dev/random`, which is "blocking" (as in, it waits until sufficient
entropy is available).

So change the entropy source to the recommended `/dev/urandom`.

Related discussion in these[1][2] past threads.

[1] https://lists.nongnu.org/archive/html/qemu-devel/2018-06/msg08335.html
-- "RNG: Any reason QEMU doesn't default to `/dev/urandom`?"
[2] https://lists.nongnu.org/archive/html/qemu-devel/2018-09/msg02724.html
-- "[RFC] Virtio RNG: Consider changing the default entropy source to
   /dev/urandom"

Signed-off-by: Kashyap Chamarthy 
---
 backends/rng-random.c | 2 +-
 qemu-options.hx   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/backends/rng-random.c b/backends/rng-random.c
index 
e2a49b0571d79eab335d5a74841d92c50a727b6a..eff36ef14084bccaad1eabe952e2cf6ffa9a2529
 100644
--- a/backends/rng-random.c
+++ b/backends/rng-random.c
@@ -112,7 +112,7 @@ static void rng_random_init(Object *obj)
 rng_random_set_filename,
 NULL);
 
-s->filename = g_strdup("/dev/random");
+s->filename = g_strdup("/dev/urandom");
 s->fd = -1;
 }
 
diff --git a/qemu-options.hx b/qemu-options.hx
index 
51802cbb266a208d70989c4f0ab3317a76edc1ea..a525609149e4d0e4bb60959f029a1a16eb36900d
 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -4276,7 +4276,7 @@ Creates a random number generator backend which obtains 
entropy from
 a device on the host. The @option{id} parameter is a unique ID that
 will be used to reference this entropy backend from the @option{virtio-rng}
 device. The @option{filename} parameter specifies which file to obtain
-entropy from and if omitted defaults to @option{/dev/random}.
+entropy from and if omitted defaults to @option{/dev/urandom}.
 
 @item -object rng-egd,id=@var{id},chardev=@var{chardevid}
 
-- 
2.17.2




Re: [Qemu-devel] [PATCH RFC v8 03/12] target/rx: CPU definition

2019-05-03 Thread Alex Bennée


Yoshinori Sato  writes:

> Signed-off-by: Yoshinori Sato 

> +{
> +*pc = env->pc;
> +*cs_base = 0;
> +*flags = FIELD_DP32(*flags, PSW, PM, env->psw_pm);

You can't reference flags here, the caller expect you to be setting it's
value. Otherwise the compiler will rightfully complain you've just
accessed unitialised data.

  *flags = FIELD_DP32(0, PSW, PM, env->psw_pm);


--
Alex Bennée



[Qemu-devel] [PATCH v4] hw/virtio/virtio-mmio: Convert DPRINTF to trace and log

2019-05-03 Thread Boxuan Li
Use traces for debug message and qemu_log_mask for errors.

Signed-off-by: Boxuan Li 
---
v1: https://patchew.org/QEMU/20190428110258.86681-1-libox...@connect.hku.hk/
v2: https://patchew.org/QEMU/20190501081039.58938-1-libox...@connect.hku.hk/
v3: https://patchew.org/QEMU/20190503084654.18413-1-libox...@connect.hku.hk/
v4: Fix indentation and do not convert uint64_t to int
---
 hw/virtio/trace-events  |  7 +++
 hw/virtio/virtio-mmio.c | 44 +---
 2 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events
index 60c649c4bc..e28ba48da6 100644
--- a/hw/virtio/trace-events
+++ b/hw/virtio/trace-events
@@ -46,3 +46,10 @@ virtio_balloon_handle_output(const char *name, uint64_t gpa) 
"section name: %s g
 virtio_balloon_get_config(uint32_t num_pages, uint32_t actual) "num_pages: %d 
actual: %d"
 virtio_balloon_set_config(uint32_t actual, uint32_t oldactual) "actual: %d 
oldactual: %d"
 virtio_balloon_to_target(uint64_t target, uint32_t num_pages) "balloon target: 
0x%"PRIx64" num_pages: %d"
+
+# virtio-mmio.c
+virtio_mmio_read(uint64_t offset) "virtio_mmio_read offset 0x%" PRIx64
+virtio_mmio_write_offset(uint64_t offset, uint64_t value) "virtio_mmio_write 
offset 0x%" PRIx64 " value 0x%" PRIx64
+virtio_mmio_guest_page(uint64_t size, int shift) "guest page size 0x%" PRIx64 
" shift %d"
+virtio_mmio_queue_write(uint64_t value, int max_size) "mmio_queue write 0x%" 
PRIx64 " max %d"
+virtio_mmio_setting_irq(int level) "virtio_mmio setting IRQ %d"
diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c
index 5807aa87fe..96c762f0bf 100644
--- a/hw/virtio/virtio-mmio.c
+++ b/hw/virtio/virtio-mmio.c
@@ -27,16 +27,8 @@
 #include "sysemu/kvm.h"
 #include "hw/virtio/virtio-bus.h"
 #include "qemu/error-report.h"
-
-/* #define DEBUG_VIRTIO_MMIO */
-
-#ifdef DEBUG_VIRTIO_MMIO
-
-#define DPRINTF(fmt, ...) \
-do { printf("virtio_mmio: " fmt , ## __VA_ARGS__); } while (0)
-#else
-#define DPRINTF(fmt, ...) do {} while (0)
-#endif
+#include "qemu/log.h"
+#include "trace.h"
 
 /* QOM macros */
 /* virtio-mmio-bus */
@@ -107,7 +99,7 @@ static uint64_t virtio_mmio_read(void *opaque, hwaddr 
offset, unsigned size)
 VirtIOMMIOProxy *proxy = (VirtIOMMIOProxy *)opaque;
 VirtIODevice *vdev = virtio_bus_get_device(>bus);
 
-DPRINTF("virtio_mmio_read offset 0x%x\n", (int)offset);
+trace_virtio_mmio_read(offset);
 
 if (!vdev) {
 /* If no backend is present, we treat most registers as
@@ -144,7 +136,9 @@ static uint64_t virtio_mmio_read(void *opaque, hwaddr 
offset, unsigned size)
 }
 }
 if (size != 4) {
-DPRINTF("wrong size access to register!\n");
+qemu_log_mask(LOG_GUEST_ERROR,
+  "%s: wrong size access to register!\n",
+  __func__);
 return 0;
 }
 switch (offset) {
@@ -182,10 +176,12 @@ static uint64_t virtio_mmio_read(void *opaque, hwaddr 
offset, unsigned size)
 case VIRTIO_MMIO_QUEUE_ALIGN:
 case VIRTIO_MMIO_QUEUE_NOTIFY:
 case VIRTIO_MMIO_INTERRUPT_ACK:
-DPRINTF("read of write-only register\n");
+qemu_log_mask(LOG_GUEST_ERROR,
+  "%s: read of write-only register\n",
+  __func__);
 return 0;
 default:
-DPRINTF("bad register offset\n");
+qemu_log_mask(LOG_GUEST_ERROR, "%s: bad register offset\n", __func__);
 return 0;
 }
 return 0;
@@ -197,8 +193,7 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, 
uint64_t value,
 VirtIOMMIOProxy *proxy = (VirtIOMMIOProxy *)opaque;
 VirtIODevice *vdev = virtio_bus_get_device(>bus);
 
-DPRINTF("virtio_mmio_write offset 0x%x value 0x%" PRIx64 "\n",
-(int)offset, value);
+trace_virtio_mmio_write_offset(offset, value);
 
 if (!vdev) {
 /* If no backend is present, we just make all registers
@@ -226,7 +221,9 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, 
uint64_t value,
 return;
 }
 if (size != 4) {
-DPRINTF("wrong size access to register!\n");
+qemu_log_mask(LOG_GUEST_ERROR,
+  "%s: wrong size access to register!\n",
+  __func__);
 return;
 }
 switch (offset) {
@@ -246,8 +243,7 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, 
uint64_t value,
 if (proxy->guest_page_shift > 31) {
 proxy->guest_page_shift = 0;
 }
-DPRINTF("guest page size %" PRIx64 " shift %d\n", value,
-proxy->guest_page_shift);
+trace_virtio_mmio_guest_page(value, proxy->guest_page_shift);
 break;
 case VIRTIO_MMIO_QUEUE_SEL:
 if (value < VIRTIO_QUEUE_MAX) {
@@ -255,7 +251,7 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, 
uint64_t value,
 }
 break;
 case VIRTIO_MMIO_QUEUE_NUM:
-DPRINTF("mmio_queue write %d max %d\n", 

Re: [Qemu-devel] [PATCH v2] target/arm: Stop using variable length array in dc_zva

2019-05-03 Thread Richard Henderson
On 5/3/19 5:04 AM, Peter Maydell wrote:
> Currently the dc_zva helper function uses a variable length
> array. In fact we know (as the comment above remarks) that
> the length of this array is bounded because the architecture
> limits the block size and QEMU limits the target page size.
> Use a fixed array size and assert that we don't run off it.
> 
> Signed-off-by: Peter Maydell 
> ---
> Changes v1->v2:
>  * use ARRAY_SIZE() instead of sizeof()
>  * add a comment to make it a bit clearer that the
>expected size of hostaddr[] is only 2 entries
> ---
>  target/arm/helper.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)


Reviewed-by: Richard Henderson 

r~



Re: [Qemu-devel] [PATCH RFC v8 09/12] hw/rx: RX Target hardware definition

2019-05-03 Thread Alex Bennée


Yoshinori Sato  writes:

> rx62n - RX62N cpu.
> rxqemu - QEMU virtual target.
>
> Signed-off-by: Yoshinori Sato 
> ---
>  include/hw/rx/rx.h|   7 ++
>  include/hw/rx/rx62n.h |  54 
>  hw/rx/rx62n.c | 226 
> ++
>  hw/rx/rxqemu.c| 100 ++
>  hw/rx/Kconfig |   2 +
>  hw/rx/Makefile.objs   |   1 +
>  6 files changed, 390 insertions(+)
>  create mode 100644 include/hw/rx/rx.h
>  create mode 100644 include/hw/rx/rx62n.h
>  create mode 100644 hw/rx/rx62n.c
>  create mode 100644 hw/rx/rxqemu.c
>  create mode 100644 hw/rx/Kconfig
>  create mode 100644 hw/rx/Makefile.objs
>
> diff --git a/include/hw/rx/rx.h b/include/hw/rx/rx.h
> new file mode 100644
> index 00..ff5924b81f
> --- /dev/null
> +++ b/include/hw/rx/rx.h
> @@ -0,0 +1,7 @@
> +#ifndef QEMU_RX_H
> +#define QEMU_RX_H
> +/* Definitions for RX board emulation.  */
> +
> +#include "target/rx/cpu-qom.h"
> +
> +#endif
> diff --git a/include/hw/rx/rx62n.h b/include/hw/rx/rx62n.h
> new file mode 100644
> index 00..8c15399ce0
> --- /dev/null
> +++ b/include/hw/rx/rx62n.h
> @@ -0,0 +1,54 @@
> +/*
> + * RX62N Object
> + *
> + * Copyright (c) 2019 Yoshinori Sato
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2 or later, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope it will be useful, but WITHOUT
> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
> + * more details.
> + *
> + * You should have received a copy of the GNU General Public License along 
> with
> + * this program.  If not, see .
> + */
> +
> +#ifndef HW_RX_RX62N_H
> +#define HW_RX_RX62N_H
> +
> +#include "hw/sysbus.h"
> +#include "hw/rx/rx.h"
> +#include "hw/intc/rx_icu.h"
> +#include "hw/timer/renesas_tmr.h"
> +#include "hw/timer/renesas_cmt.h"
> +#include "hw/char/renesas_sci.h"
> +
> +#define TYPE_RX62N "rx62n"
> +#define TYPE_RX62N_CPU RX_CPU_TYPE_NAME(TYPE_RX62N)
> +#define RX62N(obj) OBJECT_CHECK(RX62NState, (obj), TYPE_RX62N)
> +
> +typedef struct RX62NState {
> +SysBusDevice parent_obj;
> +
> +RXCPU *cpu;
> +RXICUState *icu;
> +RTMRState *tmr[2];
> +RCMTState *cmt[2];
> +RSCIState *sci[6];
> +
> +MemoryRegion *sysmem;
> +bool kernel;
> +
> +MemoryRegion iram;
> +MemoryRegion iomem1;
> +MemoryRegion d_flash;
> +MemoryRegion iomem2;
> +MemoryRegion iomem3;
> +MemoryRegion c_flash;
> +qemu_irq irq[256];
> +} RX62NState;
> +
> +#endif
> diff --git a/hw/rx/rx62n.c b/hw/rx/rx62n.c
> new file mode 100644
> index 00..b303aefe8c
> --- /dev/null
> +++ b/hw/rx/rx62n.c
> @@ -0,0 +1,226 @@
> +/*
> + * RX62N device
> + *
> + * Copyright (c) 2019 Yoshinori Sato
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2 or later, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope it will be useful, but WITHOUT
> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
> + * more details.
> + *
> + * You should have received a copy of the GNU General Public License along 
> with
> + * this program.  If not, see .
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qapi/error.h"
> +#include "hw/hw.h"
> +#include "hw/rx/rx62n.h"
> +#include "hw/loader.h"
> +#include "hw/sysbus.h"
> +#include "sysemu/sysemu.h"
> +#include "cpu.h"
> +#include "exec/exec-all.h"
> +#include "exec/address-spaces.h"
> +
> +static const int ipr_table[] = {

This could probably do with a little comment above explaining what the
magic table is and where the data in it is referenced.

Is there any particular reason this is exposed as a property? That could
be explained as well.

> +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 15 */
> +0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0xff, 0x02,
> +0xff, 0xff, 0xff, 0x03, 0x04, 0x05, 0x06, 0x07, /* 31 */
> +0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
> +0x10, 0x11, 0x12, 0x13, 0x14, 0x14, 0x14, 0x14, /* 47 */
> +0x15, 0x15, 0x15, 0x15, 0xff, 0xff, 0xff, 0xff,
> +0x18, 0x18, 0x18, 0x18, 0x18, 0x1d, 0x1e, 0x1f, /* 63 */
> +0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
> +0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 79 */
> +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> +0xff, 0xff, 0x3a, 0x3b, 0x3c, 0xff, 0xff, 0xff, /* 95 */
> +0x40, 0xff, 0x44, 0x45, 0xff, 0xff, 0x48, 0xff,
> +0xff, 0xff, 0xff, 0xff, 0xff, 

Re: [Qemu-devel] [PATCH RFC v8 12/12] hw/registerfields.h: Add 8bit and 16bit register macros.

2019-05-03 Thread Alex Bennée


Yoshinori Sato  writes:

> Some RX peripheral using 8bit and 16bit registers.
> Added 8bit and 16bit APIs.

Doesn't this mean the build breaks at some point? Features used by other
patches should be introduced first so the build remains bisectable.

>
> Signed-off-by: Yoshinori Sato 
> ---
>  include/hw/registerfields.h | 28 +++-
>  1 file changed, 27 insertions(+), 1 deletion(-)
>
> diff --git a/include/hw/registerfields.h b/include/hw/registerfields.h
> index 2659a58737..51bfd0cf67 100644
> --- a/include/hw/registerfields.h
> +++ b/include/hw/registerfields.h
> @@ -22,6 +22,14 @@
>  enum { A_ ## reg = (addr) };  \
>  enum { R_ ## reg = (addr) / 4 };
>
> +#define REG8(reg, addr)  \
> +enum { A_ ## reg = (addr) };  \
> +enum { R_ ## reg = (addr) };
> +
> +#define REG16(reg, addr)  \
> +enum { A_ ## reg = (addr) };  \
> +enum { R_ ## reg = (addr) / 2 };
> +
>  /* Define SHIFT, LENGTH and MASK constants for a field within a register */
>
>  /* This macro will define R_FOO_BAR_MASK, R_FOO_BAR_SHIFT and 
> R_FOO_BAR_LENGTH
> @@ -40,6 +48,8 @@
>  #define FIELD_EX64(storage, reg, field)   \
>  extract64((storage), R_ ## reg ## _ ## field ## _SHIFT,   \
>R_ ## reg ## _ ## field ## _LENGTH)
> +#define FIELD_EX8  FIELD_EX32
> +#define FIELD_EX16 FIELD_EX32

Hmm maybe we should be defining extract16/extract8 in bitops so things
are a) properly types and b) bounds checked to catch errors.

>
>  /* Extract a field from an array of registers */
>  #define ARRAY_FIELD_EX32(regs, reg, field)\
> @@ -49,6 +59,22 @@
>   * Assigning values larger then the target field will result in
>   * compilation warnings.
>   */
> +#define FIELD_DP8(storage, reg, field, val) ({\
> +struct {  \
> +unsigned int v:R_ ## reg ## _ ## field ## _LENGTH;\
> +} v = { .v = val };   \
> +uint8_t d;\
> +d = deposit32((storage), R_ ## reg ## _ ## field ## _SHIFT,   \
> +  R_ ## reg ## _ ## field ## _LENGTH, v.v);   \
> +d; })
> +#define FIELD_DP16(storage, reg, field, val) ({   \
> +struct {  \
> +unsigned int v:R_ ## reg ## _ ## field ## _LENGTH;\
> +} v = { .v = val };   \
> +uint16_t d;   \
> +d = deposit32((storage), R_ ## reg ## _ ## field ## _SHIFT,   \
> +  R_ ## reg ## _ ## field ## _LENGTH, v.v);   \
> +d; })
>  #define FIELD_DP32(storage, reg, field, val) ({   \
>  struct {  \
>  unsigned int v:R_ ## reg ## _ ## field ## _LENGTH;\
> @@ -57,7 +83,7 @@
>  d = deposit32((storage), R_ ## reg ## _ ## field ## _SHIFT,   \
>R_ ## reg ## _ ## field ## _LENGTH, v.v);   \
>  d; })
> -#define FIELD_DP64(storage, reg, field, val) ({   \
> +#define FIELD_DP64(storage, reg, field, val) ({ \
>  struct {  \
>  unsigned int v:R_ ## reg ## _ ## field ## _LENGTH;\
>  } v = { .v = val };   \


--
Alex Bennée



Re: [Qemu-devel] [Qemu-arm] [PATCH v6 00/30] Kconfig dependencies for ARM machines

2019-05-03 Thread Peter Maydell
On Fri, 3 May 2019 at 16:15, Thomas Huth  wrote:
>
> On 30/04/2019 09.13, Thomas Huth wrote:
> > This series reworks the default-configs/arm-softmmu.mak and
> > default-configs/aarch64-softmmu.mak files to use the new Kconfig-style
> > dependencies instead.
> >
> > Some of the patches are slightly based on the work by Ákos Kovács:
> >
> >  https://lists.nongnu.org/archive/html/qemu-devel/2013-08/msg03730.html
> >
> > The other patches have been created by looking at the sources and finding
> > out the dependencies the hard way via trial-and-error (i.e. by enabling
> > only one machine at a time and checking whether it can be compiled and
> > started).
>
>  Hi Peter,
>
> the two usb-ohci patches have now been merged to master via Gerd's tree
> already, the pci patch has an Ack from Michael and the AHCI patch one
> from John. All patches have been reviewed and/or tested ... so I think
> this series should now be good to go. Could you take it through your Arm
> tree? Or shall I send a separate PULL request for this?

I think it will be easier for me if you just send a pullreq for it.

thanks
-- PMM



Re: [Qemu-devel] [PATCH v3 1/4] QEMU_PACKED: Remove gcc_struct attribute in Windows non x86 targets

2019-05-03 Thread Peter Maydell
On Fri, 3 May 2019 at 06:07, Thomas Huth  wrote:
>
> On 03/05/2019 02.36, Cao Jiaxi wrote:
> > gcc_struct is for x86 only, and it generates an warning on ARM64 
> > Clang/MinGW targets.
> >
> > Signed-off-by: Cao Jiaxi 
> > ---
> >  contrib/libvhost-user/libvhost-user.h | 2 +-
> >  include/qemu/compiler.h   | 2 +-
> >  scripts/cocci-macro-file.h| 7 ++-
> >  slirp/src/util.h  | 2 +-
> >  4 files changed, 9 insertions(+), 4 deletions(-)

> > diff --git a/slirp/src/util.h b/slirp/src/util.h
> > index 01f1e0e068..278828fe3f 100644
> > --- a/slirp/src/util.h
> > +++ b/slirp/src/util.h
> > @@ -43,7 +43,7 @@
> >  #include 
> >  #endif
> >
> > -#if defined(_WIN32)
> > +#if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__))
> >  # define SLIRP_PACKED __attribute__((gcc_struct, packed))
> >  #else
> >  # define SLIRP_PACKED __attribute__((packed))
> >
>
> The slirp code is currently on its way into a separate module, so you
> might need to provide that hunk to the libslirp folks again... I'm
> putting the slirp maintainers on CC:, maybe they can pick it up from here.

Yes, the slirp module has now landed in master, so this patch
definitely needs to be split into two. I've kept in my
target-arm.next tree the parts which are applicable to
the QEMU repo itself (ie everything except the slirp/ change),
so we just need a new patch for the slirp submodule part.

Marc-André, Samuel -- what's the process for submitting and
getting reviewed changes to the slirp submodule now it's a
separate project ?

thanks
-- PMM



Re: [Qemu-devel] [PATCH RFC v8 08/12] hw/char: RX62N serical communication interface (SCI)

2019-05-03 Thread Alex Bennée


Yoshinori Sato  writes:


nit: typo in subject (serical->serial)

> This module supported only non FIFO type.
> Hardware manual.
> https://www.renesas.com/us/en/doc/products/mpumcu/doc/rx_family/r01uh0033ej0140_rx62n.pdf
>
> Signed-off-by: Yoshinori Sato 
> ---
>  include/hw/char/renesas_sci.h |  45 ++
>  hw/char/renesas_sci.c | 341 
> ++
>  hw/char/Kconfig   |   3 +
>  hw/char/Makefile.objs |   2 +-
>  4 files changed, 390 insertions(+), 1 deletion(-)
>  create mode 100644 include/hw/char/renesas_sci.h
>  create mode 100644 hw/char/renesas_sci.c
>
> diff --git a/include/hw/char/renesas_sci.h b/include/hw/char/renesas_sci.h
> new file mode 100644
> index 00..50d1336944
> --- /dev/null
> +++ b/include/hw/char/renesas_sci.h
> @@ -0,0 +1,45 @@
> +/*
> + * Renesas Serial Communication Interface
> + *
> + * Copyright (c) 2018 Yoshinori Sato
> + *
> + * This code is licensed under the GPL version 2 or later.
> + *
> + */
> +
> +#include "chardev/char-fe.h"
> +#include "qemu/timer.h"
> +#include "hw/sysbus.h"
> +
> +#define TYPE_RENESAS_SCI "renesas-sci"
> +#define RSCI(obj) OBJECT_CHECK(RSCIState, (obj), TYPE_RENESAS_SCI)
> +
> +enum {
> +ERI = 0,
> +RXI = 1,
> +TXI = 2,
> +TEI = 3,
> +SCI_NR_IRQ = 4,
> +};
> +
> +typedef struct {
> +SysBusDevice parent_obj;
> +MemoryRegion memory;
> +
> +uint8_t smr;
> +uint8_t brr;
> +uint8_t scr;
> +uint8_t tdr;
> +uint8_t ssr;
> +uint8_t rdr;
> +uint8_t scmr;
> +uint8_t semr;
> +
> +uint8_t read_ssr;
> +int64_t trtime;
> +int64_t rx_next;
> +QEMUTimer *timer;
> +CharBackend chr;
> +uint64_t input_freq;
> +qemu_irq irq[SCI_NR_IRQ];
> +} RSCIState;
> diff --git a/hw/char/renesas_sci.c b/hw/char/renesas_sci.c
> new file mode 100644
> index 00..719fa2f938
> --- /dev/null
> +++ b/hw/char/renesas_sci.c
> @@ -0,0 +1,341 @@
> +/*
> + * Renesas Serial Communication Interface
> + *
> + * Datasheet: RX62N Group, RX621 Group User's Manual: Hardware
> + * (Rev.1.40 R01UH0033EJ0140)
> + *
> + * Copyright (c) 2019 Yoshinori Sato
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2 or later, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope it will be useful, but WITHOUT
> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
> + * more details.
> + *
> + * You should have received a copy of the GNU General Public License along 
> with
> + * this program.  If not, see .
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qemu/log.h"
> +#include "qapi/error.h"
> +#include "qemu-common.h"
> +#include "cpu.h"
> +#include "hw/hw.h"
> +#include "hw/sysbus.h"
> +#include "hw/registerfields.h"
> +#include "hw/char/renesas_sci.h"
> +#include "qemu/error-report.h"
> +
> +/* SCI register map */
> +REG8(SMR, 0)
> +  FIELD(SMR, CKS,  0, 2)
> +  FIELD(SMR, MP,   2, 1)
> +  FIELD(SMR, STOP, 3, 1)
> +  FIELD(SMR, PM,   4, 1)
> +  FIELD(SMR, PE,   5, 1)
> +  FIELD(SMR, CHR,  6, 1)
> +  FIELD(SMR, CM,   7, 1)
> +REG8(BRR, 1)
> +REG8(SCR, 2)
> +  FIELD(SCR, CKE, 0, 2)
> +  FIELD(SCR, TEIE, 2, 1)
> +  FIELD(SCR, MPIE, 3, 1)
> +  FIELD(SCR, RE,   4, 1)
> +  FIELD(SCR, TE,   5, 1)
> +  FIELD(SCR, RIE,  6, 1)
> +  FIELD(SCR, TIE,  7, 1)
> +REG8(TDR, 3)
> +REG8(SSR, 4)
> +  FIELD(SSR, MPBT, 0, 1)
> +  FIELD(SSR, MPB,  1, 1)
> +  FIELD(SSR, TEND, 2, 1)
> +  FIELD(SSR, ERR, 3, 3)
> +FIELD(SSR, PER,  3, 1)
> +FIELD(SSR, FER,  4, 1)
> +FIELD(SSR, ORER, 5, 1)
> +  FIELD(SSR, RDRF, 6, 1)
> +  FIELD(SSR, TDRE, 7, 1)
> +REG8(RDR, 5)
> +REG8(SCMR, 6)
> +  FIELD(SCMR, SMIF, 0, 1)
> +  FIELD(SCMR, SINV, 2, 1)
> +  FIELD(SCMR, SDIR, 3, 1)
> +  FIELD(SCMR, BCP2, 7, 1)
> +REG8(SEMR, 7)
> +  FIELD(SEMR, ACS0, 0, 1)
> +  FIELD(SEMR, ABCS, 4, 1)
> +
> +static int can_receive(void *opaque)
> +{
> +RSCIState *sci = RSCI(opaque);
> +if (sci->rx_next > qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)) {
> +return 0;
> +} else {
> +return FIELD_EX8(sci->scr, SCR, RE);
> +}
> +}
> +
> +static void receive(void *opaque, const uint8_t *buf, int size)
> +{
> +RSCIState *sci = RSCI(opaque);
> +sci->rx_next = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + sci->trtime;
> +if (FIELD_EX8(sci->ssr, SSR, RDRF) || size > 1) {
> +sci->ssr = FIELD_DP8(sci->ssr, SSR, ORER, 1);
> +if (FIELD_EX8(sci->scr, SCR, RIE)) {
> +qemu_set_irq(sci->irq[ERI], 1);
> +}
> +} else {
> +sci->rdr = buf[0];
> +sci->ssr = FIELD_DP8(sci->ssr, SSR, RDRF, 1);
> +if (FIELD_EX8(sci->scr, SCR, RIE)) {
> +qemu_irq_pulse(sci->irq[RXI]);
> +}
> +}
> +}
> +
> +static void 

Re: [Qemu-devel] [PATCH RFC v8 07/12] hw/timer: RX62N internal timer modules

2019-05-03 Thread Alex Bennée


Yoshinori Sato  writes:

> renesas_tmr: 8bit timer modules.
> renesas_cmt: 16bit compare match timer modules.
> This part use many renesas's CPU.
> Hardware manual.
> https://www.renesas.com/us/en/doc/products/mpumcu/doc/rx_family/r01uh0033ej0140_rx62n.pdf
>
> Signed-off-by: Yoshinori Sato 
> ---
>  include/hw/timer/renesas_cmt.h |  33 +++
>  include/hw/timer/renesas_tmr.h |  46 +
>  hw/timer/renesas_cmt.c | 277 +
>  hw/timer/renesas_tmr.c | 458 
> +
>  hw/timer/Kconfig   |   6 +
>  hw/timer/Makefile.objs |   3 +
>  6 files changed, 823 insertions(+)
>  create mode 100644 include/hw/timer/renesas_cmt.h
>  create mode 100644 include/hw/timer/renesas_tmr.h
>  create mode 100644 hw/timer/renesas_cmt.c
>  create mode 100644 hw/timer/renesas_tmr.c
>
> diff --git a/include/hw/timer/renesas_cmt.h b/include/hw/timer/renesas_cmt.h
> new file mode 100644
> index 00..7e393d7ad3
> --- /dev/null
> +++ b/include/hw/timer/renesas_cmt.h
> @@ -0,0 +1,33 @@
> +/*
> + * Renesas Compare-match timer Object
> + *
> + * Copyright (c) 2019 Yoshinori Sato
> + *
> + * This code is licensed under the GPL version 2 or later.
> + *
> + */
> +
> +#ifndef HW_RENESAS_CMT_H
> +#define HW_RENESAS_CMT_H
> +
> +#include "hw/sysbus.h"
> +
> +#define TYPE_RENESAS_CMT "renesas-cmt"
> +#define RCMT(obj) OBJECT_CHECK(RCMTState, (obj), TYPE_RENESAS_CMT)
> +
> +typedef struct RCMTState {
> +SysBusDevice parent_obj;
> +
> +uint64_t input_freq;
> +MemoryRegion memory;
> +
> +uint16_t cmstr;
> +uint16_t cmcr[2];
> +uint16_t cmcnt[2];
> +uint16_t cmcor[2];
> +int64_t tick[2];
> +qemu_irq cmi[2];
> +QEMUTimer *timer[2];
> +} RCMTState;
> +
> +#endif
> diff --git a/include/hw/timer/renesas_tmr.h b/include/hw/timer/renesas_tmr.h
> new file mode 100644
> index 00..718d9dc4ff
> --- /dev/null
> +++ b/include/hw/timer/renesas_tmr.h
> @@ -0,0 +1,46 @@
> +/*
> + * Renesas 8bit timer Object
> + *
> + * Copyright (c) 2018 Yoshinori Sato
> + *
> + * This code is licensed under the GPL version 2 or later.
> + *
> + */
> +
> +#ifndef HW_RENESAS_TMR_H
> +#define HW_RENESAS_TMR_H
> +
> +#include "hw/sysbus.h"
> +
> +#define TYPE_RENESAS_TMR "renesas-tmr"
> +#define RTMR(obj) OBJECT_CHECK(RTMRState, (obj), TYPE_RENESAS_TMR)
> +
> +enum timer_event {cmia = 0,
> +  cmib = 1,
> +  ovi = 2,
> +  none = 3,
> +  TMR_NR_EVENTS = 4};
> +enum {CH = 2};
> +typedef struct RTMRState {
> +SysBusDevice parent_obj;
> +
> +uint64_t input_freq;
> +MemoryRegion memory;
> +
> +uint8_t tcnt[CH];
> +uint8_t tcora[CH];
> +uint8_t tcorb[CH];
> +uint8_t tcr[CH];
> +uint8_t tccr[CH];
> +uint8_t tcor[CH];
> +uint8_t tcsr[CH];
> +int64_t tick;
> +int64_t div_round[CH];
> +enum timer_event next[CH];
> +qemu_irq cmia[CH];
> +qemu_irq cmib[CH];
> +qemu_irq ovi[CH];
> +QEMUTimer *timer[CH];
> +} RTMRState;
> +
> +#endif
> diff --git a/hw/timer/renesas_cmt.c b/hw/timer/renesas_cmt.c
> new file mode 100644
> index 00..b82250dbc2
> --- /dev/null
> +++ b/hw/timer/renesas_cmt.c
> @@ -0,0 +1,277 @@
> +/*
> + * Renesas 16bit Compare-match timer
> + *
> + * Datasheet: RX62N Group, RX621 Group User's Manual: Hardware
> + * (Rev.1.40 R01UH0033EJ0140)
> + *
> + * Copyright (c) 2019 Yoshinori Sato
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2 or later, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope it will be useful, but WITHOUT
> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
> + * more details.
> + *
> + * You should have received a copy of the GNU General Public License along 
> with
> + * this program.  If not, see .
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qemu-common.h"
> +#include "qemu/log.h"
> +#include "qapi/error.h"
> +#include "qemu/timer.h"
> +#include "cpu.h"
> +#include "hw/hw.h"
> +#include "hw/sysbus.h"
> +#include "hw/registerfields.h"
> +#include "hw/timer/renesas_cmt.h"
> +#include "qemu/error-report.h"
> +
> +/*
> + *  +0 CMSTR - common control
> + *  +2 CMCR  - ch0
> + *  +4 CMCNT - ch0
> + *  +6 CMCOR - ch0
> + *  +8 CMCR  - ch1
> + * +10 CMCNT - ch1
> + * +12 CMCOR - ch1
> + * If we think that the address of CH 0 has an offset of +2,
> + * we can treat it with the same address as CH 1, so define it like that.
> + */
> +REG16(CMSTR, 0)
> +  FIELD(CMSTR, STR0, 0, 1)
> +  FIELD(CMSTR, STR1, 1, 1)
> +  FIELD(CMSTR, STR,  0, 2)
> +/* This addeess is channel offset */
> +REG16(CMCR, 0)
> +  FIELD(CMCR, CKS, 0, 2)
> +  FIELD(CMCR, CMIE, 6, 1)
> +REG16(CMCNT, 2)
> +REG16(CMCOR, 4)

Re: [Qemu-devel] [PATCH v6 00/30] Kconfig dependencies for ARM machines

2019-05-03 Thread Thomas Huth
On 30/04/2019 09.13, Thomas Huth wrote:
> This series reworks the default-configs/arm-softmmu.mak and
> default-configs/aarch64-softmmu.mak files to use the new Kconfig-style
> dependencies instead.
> 
> Some of the patches are slightly based on the work by Ákos Kovács:
> 
>  https://lists.nongnu.org/archive/html/qemu-devel/2013-08/msg03730.html
> 
> The other patches have been created by looking at the sources and finding
> out the dependencies the hard way via trial-and-error (i.e. by enabling
> only one machine at a time and checking whether it can be compiled and
> started).

 Hi Peter,

the two usb-ohci patches have now been merged to master via Gerd's tree
already, the pci patch has an Ack from Michael and the AHCI patch one
from John. All patches have been reviewed and/or tested ... so I think
this series should now be good to go. Could you take it through your Arm
tree? Or shall I send a separate PULL request for this?

 Thomas



Re: [Qemu-devel] [PULL 0/2] slirp: move slirp as git submodule project

2019-05-03 Thread Peter Maydell
On Fri, 3 May 2019 at 16:05, Philippe Mathieu-Daudé  wrote:
> FYI I was running MinGW tests with "make docker-test-mingw@fedora
> SHOW_ENV=1 J=8 NETWORK=1" and ran "git pull" to refresh my local repo,
> and got:
>
> $ make docker-test-mingw@fedora SHOW_ENV=1 J=8 NETWORK=1
> make[1]: Entering directory '/home/phil/source/qemu'
>   GEN
> /home/phil/source/qemu/docker-src.2019-05-03-16.55.51.7157/qemu.tar
> slirp: unmerged (59a1b1f165458c2acb7ff0525b543945f7416225)
> fatal: git-write-tree: error building trees
> Cannot save the current index state
> Cloning into
> '/home/phil/source/qemu/docker-src.2019-05-03-16.55.51.7157/qemu.tar.vroot'...
> done.
> error: pathspec 'slirp:' did not match any file(s) known to git.
> error: pathspec 'needs' did not match any file(s) known to git.
> error: pathspec 'merge' did not match any file(s) known to git.
> failed to checkout slirp: needs merge revision
> tar: /var/tmp/qemu/qemu.tar: Cannot open: No such file or directory
> tar: Error is not recoverable: exiting now
> Failed to untar source
> tests/docker/Makefile.include:203: recipe for target 'docker-run' failed
> make[1]: *** [docker-run] Error 1

This weird set of errors is demonstrating a bug in
scripts/archive-source.sh where it is not checking
for errors from git. Specifically it does:

if git diff-index --quiet HEAD -- &>/dev/null
then
HEAD=HEAD
else
HEAD=$(git stash create)
fi

and git prints "slirp: needs merge revision", which we
blindly put into the HEAD variable, and then later do:

git checkout $HEAD

which is what's causing the weird pathspec errors, because
(a) we're trying to check out an error message and (b) our
shell quoting is nonexistent and so we don't even treat it
as a single argument...

thanks
-- PMM



Re: [Qemu-devel] [PATCH v4 3/8] hw/acpi: Add ACPI Generic Event Device Support

2019-05-03 Thread Igor Mammedov
On Fri, 3 May 2019 12:45:52 +
Shameerali Kolothum Thodi  wrote:

> Hi Igor,
> 
> > -Original Message-
> > From: Igor Mammedov [mailto:imamm...@redhat.com]
> > Sent: 02 May 2019 17:13
> > To: Shameerali Kolothum Thodi 
> > Cc: qemu-devel@nongnu.org; qemu-...@nongnu.org;
> > eric.au...@redhat.com; peter.mayd...@linaro.org;
> > shannon.zha...@gmail.com; sa...@linux.intel.com;
> > sebastien.bo...@intel.com; xuwei (O) ;
> > ler...@redhat.com; ard.biesheu...@linaro.org; Linuxarm
> > 
> > Subject: Re: [PATCH v4 3/8] hw/acpi: Add ACPI Generic Event Device Support
> > 
> > On Tue, 9 Apr 2019 11:29:30 +0100
> > Shameer Kolothum  wrote:
> > 
> > > From: Samuel Ortiz 
> > >
> > > The ACPI Generic Event Device (GED) is a hardware-reduced specific
> > > device[ACPI v6.1 Section 5.6.9] that handles all platform events,
> > > including the hotplug ones.This patch generates the AML code that
> > > defines GEDs.
> > >
> > > Platforms need to specify their own GedEvent array to describe what
> > > kind of events they want to support through GED.  Also this uses a
> > > a single interrupt for the  GED device, relying on IO memory region
> > > to communicate the type of device affected by the interrupt. This
> > > way, we can support up to 32 events with a unique interrupt.
> > >
> > > This supports only memory hotplug for now.
> > >
> > > Signed-off-by: Samuel Ortiz 
> > > Signed-off-by: Sebastien Boeuf 
> > > Signed-off-by: Shameer Kolothum 
> > > ---
> > >  hw/acpi/Kconfig|   4 +
> > >  hw/acpi/Makefile.objs  |   1 +
> > >  hw/acpi/generic_event_device.c | 311
> > +
> > >  include/hw/acpi/generic_event_device.h | 121 +
> > >  4 files changed, 437 insertions(+)
> > >  create mode 100644 hw/acpi/generic_event_device.c
> > >  create mode 100644 include/hw/acpi/generic_event_device.h
> > >
> > > diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig
> > > index eca3bee..01a8b41 100644
> > > --- a/hw/acpi/Kconfig
> > > +++ b/hw/acpi/Kconfig
> > > @@ -27,3 +27,7 @@ config ACPI_VMGENID
> > >  bool
> > >  default y
> > >  depends on PC
> > > +
> > > +config ACPI_HW_REDUCED
> > > +bool
> > > +depends on ACPI
> > > diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
> > > index 2d46e37..b753232 100644
> > > --- a/hw/acpi/Makefile.objs
> > > +++ b/hw/acpi/Makefile.objs
> > > @@ -6,6 +6,7 @@ common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) +=
> > memory_hotplug.o
> > >  common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu.o
> > >  common-obj-$(CONFIG_ACPI_NVDIMM) += nvdimm.o
> > >  common-obj-$(CONFIG_ACPI_VMGENID) += vmgenid.o
> > > +common-obj-$(CONFIG_ACPI_HW_REDUCED) += generic_event_device.o
> > >  common-obj-$(call lnot,$(CONFIG_ACPI_X86)) += acpi-stub.o
> > >
> > >  common-obj-y += acpi_interface.o
> > > diff --git a/hw/acpi/generic_event_device.c
> > b/hw/acpi/generic_event_device.c
> > > new file mode 100644
> > > index 000..856ca04
> > > --- /dev/null
> > > +++ b/hw/acpi/generic_event_device.c
> > > @@ -0,0 +1,311 @@
> > > +/*
> > > + *
> > > + * Copyright (c) 2018 Intel Corporation
> > > + *
> > > + * This program is free software; you can redistribute it and/or modify 
> > > it
> > > + * under the terms and conditions of the GNU General Public License,
> > > + * version 2 or later, as published by the Free Software Foundation.
> > > + *
> > > + * This program is distributed in the hope it will be useful, but WITHOUT
> > > + * ANY WARRANTY; without even the implied warranty of
> > MERCHANTABILITY or
> > > + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
> > License for
> > > + * more details.
> > > + *
> > > + * You should have received a copy of the GNU General Public License 
> > > along
> > with
> > > + * this program.  If not, see .
> > > + */
> > > +
> > > +#include "qemu/osdep.h"
> > > +#include "qapi/error.h"
> > > +#include "exec/address-spaces.h"
> > > +#include "hw/sysbus.h"
> > > +#include "hw/acpi/acpi.h"
> > > +#include "hw/acpi/generic_event_device.h"
> > > +#include "hw/mem/pc-dimm.h"
> > > +
> > > +static Aml *ged_event_aml(const GedEvent *event)
> > > +{
> > > +
> > > +if (!event) {
> > In general, I prefer to check condition for calling something before doing 
> > call.
> > This way one can see in caller why and what is called, which is more clear.
> 
> Ok. I will move it then.
> 
> > 
> > > +return NULL;
> > > +}
> > > +
> > > +switch (event->event) {
> > > +case GED_MEMORY_HOTPLUG:
> > > +/* We run a complete memory SCAN when getting a memory
> > hotplug event */
> > > +return aml_call0(MEMORY_DEVICES_CONTAINER "."
> > MEMORY_SLOT_SCAN_METHOD);
> > > +default:
> > > +break;
> > > +}
> > > +
> > > +return NULL;
> > > +}
> > > +
> > > +/*
> > > + * The ACPI Generic Event Device (GED) is a hardware-reduced specific
> > > + * device[ACPI v6.1 Section 5.6.9] that handles all platform events,
> > 

Re: [Qemu-devel] [PATCH v2] arm: aspeed: Set SDRAM size

2019-05-03 Thread Philippe Mathieu-Daudé
On 5/3/19 4:29 AM, Joel Stanley wrote:
> We currently use Qemu's default of 128MB. As we know how much ram each
> machine ships with, make it easier on users by setting a default.
> 
> It can still be overridden with -m on the command line.
> 
> Signed-off-by: Joel Stanley 
> Reviewed-by: Andrew Jeffery 
> Reviewed-by: Richard Henderson 

I did review this patch:
https://lists.gnu.org/archive/html/qemu-devel/2019-05/msg00109.html

So:
Reviewed-by: Philippe Mathieu-Daudé 

> ---
> v2:
>  - Fix 'if' style issue. Thanks patchew
>  - Use units.h defines
> 
>  hw/arm/aspeed.c | 8 
>  include/hw/arm/aspeed.h | 1 +
>  2 files changed, 9 insertions(+)
> 
> diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
> index 1c23ebd99252..29d225ed1405 100644
> --- a/hw/arm/aspeed.c
> +++ b/hw/arm/aspeed.c
> @@ -25,6 +25,7 @@
>  #include "sysemu/block-backend.h"
>  #include "hw/loader.h"
>  #include "qemu/error-report.h"
> +#include "qemu/units.h"
>  
>  static struct arm_boot_info aspeed_board_binfo = {
>  .board_id = -1, /* device-tree-only board */
> @@ -331,6 +332,9 @@ static void aspeed_machine_class_init(ObjectClass *oc, 
> void *data)
>  mc->no_floppy = 1;
>  mc->no_cdrom = 1;
>  mc->no_parallel = 1;
> +if (board->ram) {
> +mc->default_ram_size = board->ram;
> +}
>  amc->board = board;
>  }
>  
> @@ -352,6 +356,7 @@ static const AspeedBoardConfig aspeed_boards[] = {
>  .spi_model = "mx25l25635e",
>  .num_cs= 1,
>  .i2c_init  = palmetto_bmc_i2c_init,
> +.ram   = 256 * MiB,
>  }, {
>  .name  = MACHINE_TYPE_NAME("ast2500-evb"),
>  .desc  = "Aspeed AST2500 EVB (ARM1176)",
> @@ -361,6 +366,7 @@ static const AspeedBoardConfig aspeed_boards[] = {
>  .spi_model = "mx25l25635e",
>  .num_cs= 1,
>  .i2c_init  = ast2500_evb_i2c_init,
> +.ram   = 512 * MiB,
>  }, {
>  .name  = MACHINE_TYPE_NAME("romulus-bmc"),
>  .desc  = "OpenPOWER Romulus BMC (ARM1176)",
> @@ -370,6 +376,7 @@ static const AspeedBoardConfig aspeed_boards[] = {
>  .spi_model = "mx66l1g45g",
>  .num_cs= 2,
>  .i2c_init  = romulus_bmc_i2c_init,
> +.ram   = 512 * MiB,
>  }, {
>  .name  = MACHINE_TYPE_NAME("witherspoon-bmc"),
>  .desc  = "OpenPOWER Witherspoon BMC (ARM1176)",
> @@ -379,6 +386,7 @@ static const AspeedBoardConfig aspeed_boards[] = {
>  .spi_model = "mx66l1g45g",
>  .num_cs= 2,
>  .i2c_init  = witherspoon_bmc_i2c_init,
> +.ram   = 512 * MiB,
>  },
>  };
>  
> diff --git a/include/hw/arm/aspeed.h b/include/hw/arm/aspeed.h
> index 325c091d09e4..02073a6b4d61 100644
> --- a/include/hw/arm/aspeed.h
> +++ b/include/hw/arm/aspeed.h
> @@ -22,6 +22,7 @@ typedef struct AspeedBoardConfig {
>  const char *spi_model;
>  uint32_t num_cs;
>  void (*i2c_init)(AspeedBoardState *bmc);
> +uint32_t ram;
>  } AspeedBoardConfig;
>  
>  #define TYPE_ASPEED_MACHINE   MACHINE_TYPE_NAME("aspeed")
> 



Re: [Qemu-devel] [PULL 0/2] slirp: move slirp as git submodule project

2019-05-03 Thread Philippe Mathieu-Daudé
On 5/3/19 2:54 PM, Peter Maydell wrote:
> On Thu, 2 May 2019 at 23:30, Samuel Thibault
>  wrote:
>>
>> The following changes since commit 8482ff2eb3bb95020eb2f370a9b3ea26511e41df:
>>
>>   Merge remote-tracking branch 'remotes/jnsnow/tags/bitmaps-pull-request' 
>> into staging (2019-05-02 12:04:51 +0100)
>>
>> are available in the Git repository at:
>>
>>   https://people.debian.org/~sthibault/qemu.git tags/samuel-thibault
>>
>> for you to fetch changes up to 7c57bdd82026ba03f3158bbcd841afde7c2dc43a:
>>
>>   build-sys: move slirp as git submodule project (2019-05-03 00:15:37 +0200)
>>
>> 
>> slirp: move slirp as git submodule project
>>
>> Marc-André Lureau (2):
>>   build-sys: pass CFLAGS & LDFLAGS to subdir-slirp
>>   build-sys: move slirp as git submodule project
>>
>> 
>> Marc-André Lureau (2):
>>   build-sys: pass CFLAGS & LDFLAGS to subdir-slirp
>>   build-sys: move slirp as git submodule project
>>
> 
> 
> Applied, thanks.

TL;DR: You might need to run 'git submodule deinit --force slirp' if ou
get errors after merging this.

--

FYI I was running MinGW tests with "make docker-test-mingw@fedora
SHOW_ENV=1 J=8 NETWORK=1" and ran "git pull" to refresh my local repo,
and got:

$ make docker-test-mingw@fedora SHOW_ENV=1 J=8 NETWORK=1
make[1]: Entering directory '/home/phil/source/qemu'
  GEN
/home/phil/source/qemu/docker-src.2019-05-03-16.55.51.7157/qemu.tar
slirp: unmerged (59a1b1f165458c2acb7ff0525b543945f7416225)
fatal: git-write-tree: error building trees
Cannot save the current index state
Cloning into
'/home/phil/source/qemu/docker-src.2019-05-03-16.55.51.7157/qemu.tar.vroot'...
done.
error: pathspec 'slirp:' did not match any file(s) known to git.
error: pathspec 'needs' did not match any file(s) known to git.
error: pathspec 'merge' did not match any file(s) known to git.
failed to checkout slirp: needs merge revision
tar: /var/tmp/qemu/qemu.tar: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
Failed to untar source
tests/docker/Makefile.include:203: recipe for target 'docker-run' failed
make[1]: *** [docker-run] Error 1

I don't run builds on this host (no tools installed) but everything via
Docker, so (re-)running ./configure is not an option.

$ git status
Unmerged paths:
  (use "git reset HEAD ..." to unstage)
  (use "git add ..." to mark resolution)

added by us: slirp

$ ls -la slirp/
total 8
drwxr-xr-x  2 phil phil 4096 May  3 16:49 .
drwxr-xr-x 56 phil phil 4096 May  3 16:55 ..

$ git submodule status slirp
U slirp

Daniel suggested on IRC to run:

$ git submodule deinit --force slirp

It worked fine after running it.

Regards,

Phil.



Re: [Qemu-devel] [PULL 00/19] Python queue, 2019-05-02

2019-05-03 Thread Peter Maydell
On Fri, 3 May 2019 at 01:41, Eduardo Habkost  wrote:
>
> The following changes since commit 8482ff2eb3bb95020eb2f370a9b3ea26511e41df:
>
>   Merge remote-tracking branch 'remotes/jnsnow/tags/bitmaps-pull-request' 
> into staging (2019-05-02 12:04:51 +0100)
>
> are available in the Git repository at:
>
>   git://github.com/ehabkost/qemu.git tags/python-next-pull-request
>
> for you to fetch changes up to faf441429adfe5767be52c5dcdb8bc03161d064f:
>
>   configure: automatically pick python3 is available (2019-05-02 21:33:27 
> -0300)
>
> 
> Python queue, 2019-05-02
>
> * configure: automatically pick python3 is available
>   (Daniel P. Berrangé)
>
> * tests/acceptance (Cleber Rosa, Philippe Mathieu-Daudé):
>   * Multi-architecture test support
>   * Multiple arch-specific boot_linux_console test cases
>   * Increase verbosity of avocado by default
>   * docstring improvements
>


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/4.1
for any user-visible changes.

-- PMM



Re: [Qemu-devel] [RFC PATCH] tests/qemu-iotests: re-format output to for make check-block

2019-05-03 Thread Thomas Huth
On 03/05/2019 16.39, Alex Bennée wrote:
> This attempts to clean-up the output to better match the output of the
> rest of the QEMU check system. This includes:
> 
>   - formatting as "  TESTiotest: nnn"
>   - calculating time diff at the end
>   - only dumping config on failure
> 
> Signed-off-by: Alex Bennée 
> ---
>  tests/qemu-iotests/check | 71 +++-
>  1 file changed, 34 insertions(+), 37 deletions(-)

Thanks for tackling this! The output now looks nicer indeed if you run
"make check-qtest check-block -j8". However, if you add a "V=1" at the
end of the command line, the outputs look quite different again...

That's why I thought that having a TAP mode for the check script could
be a good idea, too. Then we could pipe the output through the
tap-driver.pl script, too, so we get uniform output for all tests...?

 Thomas



Re: [Qemu-devel] [PATCH RFC v8 06/12] hw/intc: RX62N interrupt controller (ICUa)

2019-05-03 Thread Alex Bennée


Yoshinori Sato  writes:

> This implementation supported only ICUa.
> Hardware manual.
> https://www.renesas.com/us/en/doc/products/mpumcu/doc/rx_family/r01uh0033ej0140_rx62n.pdf
>
> Signed-off-by: Yoshinori Sato 

Without going into detail matching up to documented behaviour to the
code the structure and layout looks fine to me:

Reviewed-by: Alex Bennée 

> ---
>  include/hw/intc/rx_icu.h |  49 +++
>  hw/intc/rx_icu.c | 373 
> +++
>  hw/intc/Makefile.objs|   1 +
>  3 files changed, 423 insertions(+)
>  create mode 100644 include/hw/intc/rx_icu.h
>  create mode 100644 hw/intc/rx_icu.c
>
> diff --git a/include/hw/intc/rx_icu.h b/include/hw/intc/rx_icu.h
> new file mode 100644
> index 00..bc46b3079b
> --- /dev/null
> +++ b/include/hw/intc/rx_icu.h
> @@ -0,0 +1,49 @@
> +#ifndef RX_ICU_H
> +#define RX_ICU_H
> +
> +#include "qemu-common.h"
> +#include "hw/irq.h"
> +
> +struct IRQSource {
> +int sense;
> +int level;
> +};
> +
> +struct RXICUState {
> +SysBusDevice parent_obj;
> +
> +MemoryRegion memory;
> +struct IRQSource src[256];
> +char *icutype;
> +uint32_t nr_irqs;
> +uint32_t *map;
> +uint32_t nr_sense;
> +uint32_t *init_sense;
> +
> +uint8_t ir[256];
> +uint8_t dtcer[256];
> +uint8_t ier[32];
> +uint8_t ipr[142];
> +uint8_t dmasr[4];
> +uint16_t fir;
> +uint8_t nmisr;
> +uint8_t nmier;
> +uint8_t nmiclr;
> +uint8_t nmicr;
> +int req_irq;
> +qemu_irq _irq;
> +qemu_irq _fir;
> +qemu_irq _swi;
> +};
> +typedef struct RXICUState RXICUState;
> +
> +#define TYPE_RXICU "rxicu"
> +#define RXICU(obj) OBJECT_CHECK(RXICUState, (obj), TYPE_RXICU)
> +
> +#define SWI 27
> +#define TRG_LEVEL 0
> +#define TRG_NEDGE 1
> +#define TRG_PEDGE 2
> +#define TRG_BEDGE 3
> +
> +#endif /* RX_ICU_H */
> diff --git a/hw/intc/rx_icu.c b/hw/intc/rx_icu.c
> new file mode 100644
> index 00..7c7336960d
> --- /dev/null
> +++ b/hw/intc/rx_icu.c
> @@ -0,0 +1,373 @@
> +/*
> + * RX Interrupt control unit
> + *
> + * Datasheet: RX62N Group, RX621 Group User's Manual: Hardware
> + * (Rev.1.40 R01UH0033EJ0140)
> + *
> + * Copyright (c) 2019 Yoshinori Sato
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2 or later, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope it will be useful, but WITHOUT
> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
> + * more details.
> + *
> + * You should have received a copy of the GNU General Public License along 
> with
> + * this program.  If not, see .
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qemu-common.h"
> +#include "qemu/log.h"
> +#include "qapi/error.h"
> +#include "cpu.h"
> +#include "hw/hw.h"
> +#include "hw/sysbus.h"
> +#include "hw/registerfields.h"
> +#include "hw/intc/rx_icu.h"
> +#include "qemu/error-report.h"
> +
> +REG8(IR, 0)
> +  FIELD(IR, IR,  0, 1)
> +REG8(DTCER, 0x100)
> +  FIELD(DTCER, DTCE,  0, 1)
> +REG8(IER, 0x200)
> +REG8(SWINTR, 0x2e0)
> +  FIELD(SWINTR, SWINT, 0, 1)
> +REG16(FIR, 0x2f0)
> +  FIELD(FIR, FVCT, 0, 8)
> +  FIELD(FIR, FIEN, 15, 1)
> +REG8(IPR, 0x300)
> +  FIELD(IPR, IPR, 0, 4)
> +REG8(DMRSR, 0x400)
> +REG8(IRQCR, 0x500)
> +  FIELD(IRQCR, IRQMD, 2, 2)
> +REG8(NMISR, 0x580)
> +  FIELD(NMISR, NMIST, 0, 1)
> +  FIELD(NMISR, LVDST, 1, 1)
> +  FIELD(NMISR, OSTST, 2, 1)
> +REG8(NMIER, 0x581)
> +  FIELD(NMIER, NMIEN, 0, 1)
> +  FIELD(NMIER, LVDEN, 1, 1)
> +  FIELD(NMIER, OSTEN, 2, 1)
> +REG8(NMICLR, 0x582)
> +  FIELD(NMICLR, NMICLR, 0, 1)
> +  FIELD(NMICLR, OSTCLR, 2, 1)
> +REG8(NMICR, 0x583)
> +  FIELD(NMICR, NMIMD, 3, 1)
> +
> +#define request(icu, n) (icu->ipr[icu->map[n]] << 8 | n)
> +
> +static qemu_irq *rxicu_pin(RXICUState *icu, int n_IRQ)
> +{
> +if ((icu->fir & R_FIR_FIEN_MASK) &&
> +(icu->fir & R_FIR_FVCT_MASK) == n_IRQ) {
> +return >_fir;
> +} else {
> +return >_irq;
> +}
> +}
> +
> +static void rxicu_request(RXICUState *icu, int n_IRQ)
> +{
> +int enable;
> +
> +enable = icu->ier[n_IRQ / 8] & (1 << (n_IRQ & 7));
> +if (n_IRQ > 0 && enable != 0 && atomic_read(>req_irq) < 0) {
> +atomic_set(>req_irq, n_IRQ);
> +qemu_set_irq(*rxicu_pin(icu, n_IRQ), request(icu, n_IRQ));
> +}
> +}
> +
> +static void rxicu_set_irq(void *opaque, int n_IRQ, int level)
> +{
> +RXICUState *icu = opaque;
> +struct IRQSource *src;
> +int issue;
> +
> +if (n_IRQ >= 256) {
> +error_report("%s: IRQ %d out of range", __func__, n_IRQ);
> +return;
> +}
> +
> +src = >src[n_IRQ];
> +
> +level = (level != 0);
> +switch (src->sense) {
> +case TRG_LEVEL:
> +/* level-sensitive irq */
> +issue 

[Qemu-devel] [RFC PATCH] tests/qemu-iotests: re-format output to for make check-block

2019-05-03 Thread Alex Bennée
This attempts to clean-up the output to better match the output of the
rest of the QEMU check system. This includes:

  - formatting as "  TESTiotest: nnn"
  - calculating time diff at the end
  - only dumping config on failure

Signed-off-by: Alex Bennée 
---
 tests/qemu-iotests/check | 71 +++-
 1 file changed, 34 insertions(+), 37 deletions(-)

diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
index 922c5d1d3d..2ffc14113e 100755
--- a/tests/qemu-iotests/check
+++ b/tests/qemu-iotests/check
@@ -633,12 +633,6 @@ _wallclock()
 date "+%H %M %S" | awk '{ print $1*3600 + $2*60 + $3 }'
 }
 
-_timestamp()
-{
-now=$(date "+%T")
-printf %s " [$now]"
-}
-
 _wrapup()
 {
 if $showme
@@ -709,19 +703,6 @@ trap "_wrapup; exit \$status" 0 1 2 3 15
 FULL_IMGFMT_DETAILS=$(_full_imgfmt_details)
 FULL_HOST_DETAILS=$(_full_platform_details)
 
-cat < $TESTS_REMAINING_LOG
@@ -729,7 +710,9 @@ seq="check"
 for seq in $list
 do
 err=false
-printf %s "$seq"
+reason=""
+times=""
+
 if [ -n "$TESTS_REMAINING_LOG" ] ; then
 sed -e "s/$seq//" -e 's/  / /' -e 's/^ *//' $TESTS_REMAINING_LOG > 
$TESTS_REMAINING_LOG.tmp
 mv $TESTS_REMAINING_LOG.tmp $TESTS_REMAINING_LOG
@@ -738,7 +721,7 @@ do
 
 if $showme
 then
-echo
+echo "  TESTiotest: $seq (not actually run)"
 continue
 elif [ -f expunged ] && $expunge && egrep "^$seq([ ]|\$)" expunged 
>/dev/null
 then
@@ -753,17 +736,11 @@ do
 # really going to try and run this one
 #
 rm -f $seq.out.bad
-lasttime=$(sed -n -e "/^$seq /s/.* //p" <$TIMESTAMP_FILE)
-if [ "X$lasttime" != X ]; then
-printf %s " ${lasttime}s ..."
-else
-printf ""# prettier output with timestamps.
-fi
 rm -f core $seq.notrun
 rm -f $seq.casenotrun
 
 start=$(_wallclock)
-$timestamp && printf %s "[$(date "+%T")]"
+$timestamp && times="[$(date "+%T")]"
 
 if [ "$(head -n 1 "$source_iotests/$seq")" == "#!/usr/bin/env python" 
]; then
 run_command="$PYTHON $seq"
@@ -781,26 +758,26 @@ do
 $run_command >$tmp.out 2>&1)
 fi
 sts=$?
-$timestamp && _timestamp
+$timestamp && times="$times -> [$(date "+%T")]"
 stop=$(_wallclock)
 
 if [ -f core ]
 then
-printf " [dumped core]"
 mv core $seq.core
+reason="dumped core $seq.core"
 err=true
 fi
 
 if [ -f $seq.notrun ]
 then
-$timestamp || printf " [not run] "
-$timestamp && echo " [not run]" && printf %s "$seq -- "
+$timestamp || reason="[not run]"
+$timestamp && reason="[not run] $seq -- "
 cat $seq.notrun
 notrun="$notrun $seq"
 else
 if [ $sts -ne 0 ]
 then
-printf %s " [failed, exit status $sts]"
+reason=$(printf %s "[failed, exit status $sts]")
 err=true
 fi
 
@@ -821,22 +798,27 @@ do
 
 if [ ! -f "$reference" ]
 then
-echo " - no qualified output"
+reason=" - no qualified output"
 err=true
 else
 if diff -w "$reference" $tmp.out >/dev/null 2>&1
 then
-echo ""
 if $err
 then
 :
 else
-echo "$seq $(expr $stop - $start)" >>$tmp.time
+lasttime=$(sed -n -e "/^$seq /s/.* //p" 
<$TIMESTAMP_FILE)
+thistime=$(expr $stop - $start)
+echo "$seq $thistime" >>$tmp.time
+
+if [ "X$lasttime" != X ]; then
+times="$times ${thistime}s (last ${lasttime}s)"
+fi
 fi
 else
-echo " - output mismatch (see $seq.out.bad)"
 mv $tmp.out $seq.out.bad
 $diff -w "$reference" "$PWD"/$seq.out.bad
+reason=" - output mismatch (see $seq.out.bad)"
 err=true
 fi
 fi
@@ -852,9 +834,24 @@ do
 #
 if $err
 then
+echo "  TESTiotest: $seq FAILED $reason"
+cat <

Re: [Qemu-devel] [PATCH v2] vmdk: Set vmdk parent backing_format to vmdk

2019-05-03 Thread Max Reitz
On 03.05.19 13:34, Thomas Huth wrote:
>  Hi Sam,
> 
> On 02/05/2019 15.08, Sam Eiderman wrote:
>> Commit b69864e ("vmdk: Support version=3 in VMDK descriptor files")
>> fixed the probe function to correctly guess vmdk descriptors with
>> version=3.
>>
>> This solves the issue where vmdk snapshot with parent vmdk descriptor
>> containing "version=3" would be treated as raw instead vmdk.
>>
>> In the future case where a new vmdk version is introduced, we will again
>> experience this issue, even if the user will provide "-f vmdk" it will
>> only apply to the tip image and not to the underlying "misprobed" parent
>> image.
>>
>> The code in vmdk.c already assumes that the backing file of vmdk must be
>> vmdk (see vmdk_is_cid_valid which returns 0 if backing file is not
>> vmdk).
>>
>> So let's make it official by supplying the backing_format as vmdk.
>>
>> Reviewed-by: Mark Kanda 
>> Reviewed-By: Liran Alon 
>> Reviewed-by: Arbel Moshe 
>> Signed-off-by: Shmuel Eiderman 
>> ---
>>  block/vmdk.c   | 2 ++
>>  tests/qemu-iotests/110 | 6 +++---
>>  tests/qemu-iotests/126 | 4 ++--
>>  3 files changed, 7 insertions(+), 5 deletions(-)
>>
>> diff --git a/block/vmdk.c b/block/vmdk.c
>> index 8dec6ef767..de8cb859f8 100644
>> --- a/block/vmdk.c
>> +++ b/block/vmdk.c
>> @@ -397,6 +397,8 @@ static int vmdk_parent_open(BlockDriverState *bs)
>>  pstrcpy(bs->auto_backing_file, end_name - p_name + 1, p_name);
>>  pstrcpy(bs->backing_file, sizeof(bs->backing_file),
>>  bs->auto_backing_file);
>> +pstrcpy(bs->backing_format, sizeof(bs->backing_format),
>> +"vmdk");
>>  }
> 
> Your patch with this change has already been merged into the QEMU master
> branch...
> 
>> diff --git a/tests/qemu-iotests/110 b/tests/qemu-iotests/110
>> index fad672c1ae..982569dbc5 100755
>> --- a/tests/qemu-iotests/110
>> +++ b/tests/qemu-iotests/110
>> @@ -54,7 +54,7 @@ _make_test_img -b "$TEST_IMG_REL.base" 64M
>>  # qemu should be able to reconstruct the filename, so relative backing names
>>  # should work
>>  
>> TEST_IMG="json:{'driver':'$IMGFMT','file':{'driver':'file','filename':'$TEST_IMG'}}"
>>  \
>> -_img_info | _filter_img_info
>> +_img_info | _filter_img_info | grep -v "backing file format"
>>  
>>  echo
>>  echo '=== Non-reconstructable filename ==='
>> @@ -78,7 +78,7 @@ TEST_IMG="json:{
>>  }
>>  ]
>>  }
>> -}" _img_info | _filter_img_info
>> +}" _img_info | _filter_img_info | grep -v "backing file format"
>>  
>>  echo
>>  echo '=== Backing name is always relative to the backed image ==='
>> @@ -110,7 +110,7 @@ TEST_IMG="json:{
>>  }
>>  ]
>>  }
>> -}" _img_info | _filter_img_info
>> +}" _img_info | _filter_img_info | grep -v "backing file format"
>>  
>>  
>>  # success, all done
>> diff --git a/tests/qemu-iotests/126 b/tests/qemu-iotests/126
>> index 96dc048d59..1f7618c8a5 100755
>> --- a/tests/qemu-iotests/126
>> +++ b/tests/qemu-iotests/126
>> @@ -63,7 +63,7 @@ TEST_IMG=$BASE_IMG _make_test_img 64M
>>  TEST_IMG=$TOP_IMG _make_test_img -b ./image:base.$IMGFMT
>>  
>>  # The default cluster size depends on the image format
>> -TEST_IMG=$TOP_IMG _img_info | grep -v 'cluster_size'
>> +TEST_IMG=$TOP_IMG _img_info | grep -v 'cluster_size\|backing file format'
>>  
>>  _rm_test_img "$BASE_IMG"
>>  _rm_test_img "$TOP_IMG"
>> @@ -79,7 +79,7 @@ TOP_IMG="file:image:top.$IMGFMT"
>>  TEST_IMG=$BASE_IMG _make_test_img 64M
>>  TEST_IMG=$TOP_IMG _make_test_img -b "$BASE_IMG"
>>  
>> -TEST_IMG=$TOP_IMG _img_info | grep -v 'cluster_size'
>> +TEST_IMG=$TOP_IMG _img_info | grep -v 'cluster_size\|backing file format'
>>  
>>  _rm_test_img "$BASE_IMG"
>>  _rm_test_img "image:top.$IMGFMT"
>>
> 
> ... so please just send a patch with these fixes!

I already did, it's here:

http://lists.nongnu.org/archive/html/qemu-block/2019-04/msg00442.html

Max



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [RFC PATCH v1 08/10] KVM: X86: Introduce KVM_HC_PAGE_ENC_STATUS hypercall

2019-05-03 Thread Singh, Brijesh


On 4/26/19 4:39 PM, Lendacky, Thomas wrote:
> On 4/24/19 11:10 AM, Singh, Brijesh wrote:
>> The hypercall can be used by the SEV guest to notify the page encryption
> 
> This hyercall is used by the SEV guest to notify a change in the page...
> 
>> status to the hypervisor. The hypercall should be invoked only when
>> the encryption attribute is changed from encrypted -> decrypted and vice
>> versa. By default all the guest pages should be considered encrypted.
> 
> By default all guest page are considered
> 
>>
>> Cc: Thomas Gleixner 
>> Cc: Ingo Molnar 
>> Cc: "H. Peter Anvin" 
>> Cc: Paolo Bonzini 
>> Cc: "Radim Krčmář" 
>> Cc: Joerg Roedel 
>> Cc: Borislav Petkov 
>> Cc: Tom Lendacky 
>> Cc: x...@kernel.org
>> Cc: k...@vger.kernel.org
>> Cc: linux-ker...@vger.kernel.org
>> Signed-off-by: Brijesh Singh 
>> ---
>>   Documentation/virtual/kvm/hypercalls.txt | 14 +
>>   arch/x86/include/asm/kvm_host.h  |  2 +
>>   arch/x86/kvm/svm.c   | 69 
>>   arch/x86/kvm/vmx/vmx.c   |  1 +
>>   arch/x86/kvm/x86.c   |  5 ++
>>   include/uapi/linux/kvm_para.h|  1 +
>>   6 files changed, 92 insertions(+)
>>
>> diff --git a/Documentation/virtual/kvm/hypercalls.txt 
>> b/Documentation/virtual/kvm/hypercalls.txt
>> index da24c138c8d1..ecd44e488679 100644
>> --- a/Documentation/virtual/kvm/hypercalls.txt
>> +++ b/Documentation/virtual/kvm/hypercalls.txt
>> @@ -141,3 +141,17 @@ a0 corresponds to the APIC ID in the third argument 
>> (a2), bit 1
>>   corresponds to the APIC ID a2+1, and so on.
>>   
>>   Returns the number of CPUs to which the IPIs were delivered successfully.
>> +
>> +7. KVM_HC_PAGE_ENC_STATUS
>> +-
>> +Architecture: x86
>> +Status: active
>> +Purpose: Notify the encryption status changes in guest page table (SEV 
>> guest)
>> +
>> +a0: the guest physical address of the start page
>> +a1: the number of pages
>> +a2: set or clear the encryption attribute
> 
> a2: encryption attribute
> 
>> +
>> +   Where:
>> +* 1: Encryption attribute is set
>> +* 0: Encryption attribute is cleared
>> diff --git a/arch/x86/include/asm/kvm_host.h 
>> b/arch/x86/include/asm/kvm_host.h
>> index a9d03af34030..adb0ca035b97 100644
>> --- a/arch/x86/include/asm/kvm_host.h
>> +++ b/arch/x86/include/asm/kvm_host.h
>> @@ -1196,6 +1196,8 @@ struct kvm_x86_ops {
>>  uint16_t (*nested_get_evmcs_version)(struct kvm_vcpu *vcpu);
>>   
>>  bool (*need_emulation_on_page_fault)(struct kvm_vcpu *vcpu);
>> +int (*page_enc_status_hc)(struct kvm *kvm, unsigned long gpa,
>> +  unsigned long sz, unsigned long mode);
>>   };
>>   
>>   struct kvm_arch_async_pf {
>> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
>> index 74b57ab742ad..f024f208b052 100644
>> --- a/arch/x86/kvm/svm.c
>> +++ b/arch/x86/kvm/svm.c
>> @@ -138,6 +138,8 @@ struct kvm_sev_info {
>>  int fd; /* SEV device fd */
>>  unsigned long pages_locked; /* Number of pages locked */
>>  struct list_head regions_list;  /* List of registered regions */
>> +unsigned long *page_enc_bmap;
>> +unsigned long page_enc_bmap_size;
>>   };
>>   
>>   struct kvm_svm {
>> @@ -1911,6 +1913,8 @@ static void sev_vm_destroy(struct kvm *kvm)
>>   
>>  sev_unbind_asid(kvm, sev->handle);
>>  sev_asid_free(kvm);
>> +
>> +kvfree(sev->page_enc_bmap);
>>   }
>>   
>>   static void avic_vm_destroy(struct kvm *kvm)
>> @@ -7370,6 +7374,69 @@ static int sev_receive_finish(struct kvm *kvm, struct 
>> kvm_sev_cmd *argp)
>>  return ret;
>>   }
>>   
>> +static int sev_resize_page_enc_bitmap(struct kvm *kvm, unsigned long 
>> new_size)
>> +{
>> +struct kvm_sev_info *sev = _kvm_svm(kvm)->sev_info;
>> +unsigned long *map;
>> +unsigned long sz;
>> +
>> +if (sev->page_enc_bmap_size >= new_size)
>> +return 0;
>> +
>> +sz = ALIGN(new_size, BITS_PER_LONG) / 8;
>> +
>> +if (sz > PAGE_SIZE)
>> +map = vmalloc(sz);
>> +else
>> +map = kmalloc(sz, GFP_KERNEL);
> 
> Any reason this can't always be vmalloc()?
> 

Yes, we can use vmalloc() unconditionally. The bitmap size will be
mostly greater than PAGE_SIZE hence the above is useless anyway.


>> +
>> +if (!map) {
>> +pr_err_once("Failed to allocate decrypted bitmap size %lx\n", 
>> sz);
>> +return 1;
> 
> Should this be -ENOMEM?
> 
>> +}
>> +
>> +/* mark the page encrypted (by default) */
>> +memset(map, 0xff, sz);
>> +
>> +bitmap_copy(map, sev->page_enc_bmap, sev->page_enc_bmap_size);
>> +kvfree(sev->page_enc_bmap);
>> +
>> +sev->page_enc_bmap = map;
>> +sev->page_enc_bmap_size = new_size;
>> +
>> +return 0;
>> +}
>> +
>> +static int svm_page_enc_status_hc(struct kvm *kvm, unsigned long gpa,
>> +  unsigned long npages, unsigned long enc)
>> +{
>> +struct kvm_sev_info *sev = _kvm_svm(kvm)->sev_info;

Re: [Qemu-devel] [PULL 0/2] tests/uefi-test-tools: report the SMBIOS entry point structures

2019-05-03 Thread Peter Maydell
On Fri, 3 May 2019 at 10:33, Laszlo Ersek  wrote:
>
> No changes relative to the original posting at
> <20190425104326.12835-1-lersek@redhat.com">http://mid.mail-archive.com/20190425104326.12835-1-lersek@redhat.com>,
> except for picking up the review/testing tags (also noted separately on
> each patch).
>
> Cc: "Philippe Mathieu-Daudé" 
> Cc: Igor Mammedov 


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/4.1
for any user-visible changes.

-- PMM



Re: [Qemu-devel] [RFC 0/3] target/m68k: convert to transaction_failed hook

2019-05-03 Thread Peter Maydell
On Wed, 12 Dec 2018 at 20:43, Laurent Vivier  wrote:
>
> On 10/12/2018 17:56, Peter Maydell wrote:
> > This patchset converts the m68k target from the deprecated
> > unassigned_access hook to the new transaction_failed hook.
> > It's RFC for a couple of reasons:
> >  * it's untested, since I don't have an m68k test image
> >  * the second patch just makes "bus error while trying to
> >read page tables" be treated as a page fault, when it
> >should probably cause a fault reporting it as a bus error
> >of some kind
> >  * I don't understand why the old unassigned_access hook
> >set the ATC bit in the MMU SSW, since the docs I have say
> >this should be set if the fault happened during a table
> >search, but cleared if it's just an ordinary bus-errored
> >data or insn access. Probably this is a pre-existing bug?
> >
> > Anyway, I send it out as a skeleton for comments, because
> > it would be nice to get rid of the old unassigned_access
> > hook, which is fundamentally broken (it's still used by m68k,
> > microblaze, mips and sparc).
> >
> > thanks
> > -- PMM
> >
> > Peter Maydell (3):
> >   target/m68k: In dump_address_map() check for memory access failures
> >   target/m68k: In get_physical_address() check for memory access
> > failures
> >   target/m68k: Switch to transaction_failed hook
> >
> >  target/m68k/cpu.h   |  7 ++--
> >  target/m68k/cpu.c   |  2 +-
> >  target/m68k/helper.c| 84 -
> >  target/m68k/op_helper.c | 20 --
> >  4 files changed, 80 insertions(+), 33 deletions(-)
> >
>
> Tested-by: Laurent Vivier 
>
> I'll try to review this later...

Ping! Are we at "later" yet ? :-)

I checked with the mbox of the series from
https://patchew.org/QEMU/20181210165636.28366-1-peter.mayd...@linaro.org/
and it still applies cleanly to master.

thanks
-- PMM



Re: [Qemu-devel] [PATCH v4 8/8] hw/arm/boot: Expose the PC-DIMM nodes in the DT

2019-05-03 Thread Laszlo Ersek
Hi Shameer,

On 05/03/19 15:35, Shameerali Kolothum Thodi wrote:
> 
> 
>> -Original Message-
>> From: Linuxarm [mailto:linuxarm-boun...@huawei.com] On Behalf Of
>> Shameerali Kolothum Thodi
>> Sent: 10 April 2019 09:49
>> To: Laszlo Ersek ; qemu-devel@nongnu.org;
>> qemu-...@nongnu.org; eric.au...@redhat.com; imamm...@redhat.com
>> Cc: peter.mayd...@linaro.org; sa...@linux.intel.com;
>> ard.biesheu...@linaro.org; Linuxarm ;
>> shannon.zha...@gmail.com; sebastien.bo...@intel.com; xuwei (O)
>> 
>> Subject: RE: [PATCH v4 8/8] hw/arm/boot: Expose the PC-DIMM nodes in the
>> DT
>>
>>
>>> -Original Message-
>>> From: Laszlo Ersek [mailto:ler...@redhat.com]
>>> Sent: 09 April 2019 16:09
>>> To: Shameerali Kolothum Thodi ;
>>> qemu-devel@nongnu.org; qemu-...@nongnu.org; eric.au...@redhat.com;
>>> imamm...@redhat.com
>>> Cc: peter.mayd...@linaro.org; shannon.zha...@gmail.com;
>>> sa...@linux.intel.com; sebastien.bo...@intel.com; xuwei (O)
>>> ; ard.biesheu...@linaro.org; Linuxarm
>>> 
>>> Subject: Re: [PATCH v4 8/8] hw/arm/boot: Expose the PC-DIMM nodes in the
>>> DT
>>>
>>> On 04/09/19 12:29, Shameer Kolothum wrote:
 This patch adds memory nodes corresponding to PC-DIMM regions.
 This will enable support for cold plugged device memory for Guests
 with DT boot.

 Signed-off-by: Shameer Kolothum
>> 
 Signed-off-by: Eric Auger 
 ---
  hw/arm/boot.c | 42 ++
  1 file changed, 42 insertions(+)

 diff --git a/hw/arm/boot.c b/hw/arm/boot.c
 index 8c840ba..150e1ed 100644
 --- a/hw/arm/boot.c
 +++ b/hw/arm/boot.c
 @@ -19,6 +19,7 @@
  #include "sysemu/numa.h"
  #include "hw/boards.h"
  #include "hw/loader.h"
 +#include "hw/mem/memory-device.h"
  #include "elf.h"
  #include "sysemu/device_tree.h"
  #include "qemu/config-file.h"
 @@ -538,6 +539,41 @@ static void fdt_add_psci_node(void *fdt)
  qemu_fdt_setprop_cell(fdt, "/psci", "migrate", migrate_fn);
  }

 +static int fdt_add_hotpluggable_memory_nodes(void *fdt,
 + uint32_t acells,
>>> uint32_t scells) {
 +MemoryDeviceInfoList *info, *info_list = qmp_memory_device_list();
 +MemoryDeviceInfo *mi;
 +int ret = 0;
 +
 +for (info = info_list; info != NULL; info = info->next) {
 +mi = info->value;
 +switch (mi->type) {
 +case MEMORY_DEVICE_INFO_KIND_DIMM:
 +{
 +PCDIMMDeviceInfo *di = mi->u.dimm.data;
 +
 +ret = fdt_add_memory_node(fdt, acells, di->addr, scells,
 +  di->size, di->node, true);
 +if (ret) {
 +fprintf(stderr,
 +"couldn't add PCDIMM
>> /memory@%"PRIx64"
>>> node\n",
 +di->addr);
 +goto out;
 +}
 +break;
 +}
 +default:
 +fprintf(stderr, "%s memory nodes are not yet supported\n",
 +MemoryDeviceInfoKind_str(mi->type));
 +ret = -ENOENT;
 +goto out;
 +}
 +}
 +out:
 +qapi_free_MemoryDeviceInfoList(info_list);
 +return ret;
 +}
 +
  int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
   hwaddr addr_limit, AddressSpace *as)
  {
 @@ -637,6 +673,12 @@ int arm_load_dtb(hwaddr addr, const struct
>>> arm_boot_info *binfo,
  }
  }

 +rc = fdt_add_hotpluggable_memory_nodes(fdt, acells, scells);
 +if (rc < 0) {
 +fprintf(stderr, "couldn't add hotpluggable memory nodes\n");
 +goto fail;
 +}
 +
  rc = fdt_path_offset(fdt, "/chosen");
  if (rc < 0) {
  qemu_fdt_add_subnode(fdt, "/chosen");

>>>
>>>
>>> Given patches #7 and #8, as I understand them, the firmware cannot
>>> distinguish hotpluggable & present, from hotpluggable & absent. The
>> firmware
>>> can only skip both hotpluggable cases. That's fine in that the firmware will
>> hog
>>> neither type -- but is that OK for the OS as well, for both ACPI boot and DT
>>> boot?
>>
>> Right. This only handles the hotpluggable-and-present condition.
>>
>>> Consider in particular the "hotpluggable & present, ACPI boot" case.
>> Assuming
>>> we modify the firmware to skip "hotpluggable" altogether, the UEFI memmap
>>> will not include the range despite it being present at boot. Presumably, 
>>> ACPI
>>> will refer to the range somehow, however. Will that not confuse the OS?
>>
>> From my testing so far, without patches #7 and #8(ie, no UEFI memmap entry),
>> ACPI boots fine. I think ACPI only relies on aml and SRAT.
>>
>>> When Igor raised this earlier, I suggested that hotpluggable-and-present
>>> should be added by the firmware, but also 

Re: [Qemu-devel] [PATCH v5 07/10] qcow2: qcow2_co_preadv: improve locking

2019-05-03 Thread Max Reitz
On 30.04.19 11:44, Vladimir Sementsov-Ogievskiy wrote:
> 30.04.2019 11:38, Vladimir Sementsov-Ogievskiy wrote:
>> 29.04.2019 19:37, Max Reitz wrote:
>>> On 02.04.19 17:37, Vladimir Sementsov-Ogievskiy wrote:
 Background: decryption will be done in threads, to take benefit of it,
 we should move it out of the lock first.
>>>
>>> ...which is safe after your commit c972fa123c73501b4, I presume.
>>>
>>> (At first glance, the patched looked a bit weird to me because it
>>> doesn't give a reason why dropping the lock around
>>> qcrypto_block_decrypt() would be OK.)
>>>
 But let's go further: it turns out, that for locking around switch
 cases we have only two variants: when we just do memset(0) not
 releasing the lock (it is useless) and when we actually can handle the
 whole case out of the lock. So, refactor the whole thing to reduce
 locked code region and make it clean.

 Signed-off-by: Vladimir Sementsov-Ogievskiy 
 Reviewed-by: Alberto Garcia 
 ---
   block/qcow2.c | 46 ++
   1 file changed, 22 insertions(+), 24 deletions(-)

 diff --git a/block/qcow2.c b/block/qcow2.c
 index 46e8e39da5..fcf92a7eb6 100644
 --- a/block/qcow2.c
 +++ b/block/qcow2.c
 @@ -1983,6 +1983,7 @@ static coroutine_fn int 
 qcow2_co_preadv(BlockDriverState *bs, uint64_t offset,
   ret = qcow2_get_cluster_offset(bs, offset, _bytes, 
 _offset);
>>>
>>> Isn't this the only function in the loop that actually needs the lock?
>>> Wouldn't it make more sense to just take it around this call?
>>>
>>
>> Hmm, looks correct, I'll resend.
>>
>>
> 
> Or not, actually, we may have several qcow2_get_data_offset calls under one 
> lock,
> if clusters are different kinds of ZERO. So, I think better to keep it as is 
> for now.

Hm, but how is this relevant?  For one thing, if that was a problem if
some other party concurrently changes the image, then that would be a
problem in general.  Keeping the lock would hide it for different kinds
of read-as-zero clusters, but it would still appear if data clusters and
other clusters are interleaved, wouldn’t it?

Also, this is a coroutine.  As long as nothing yields, nothing gets
concurrent access.  I don’t see anything outside of
qcow2_get_cluster_offset() that could yield as long as we only see
read-as-zero clusters.

Max



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH v3 0/4] Initial Windows on ARM (AArch64 64-Bit) host support

2019-05-03 Thread Peter Maydell
On Fri, 3 May 2019 at 11:20, Philippe Mathieu-Daudé  wrote:
>
> On 5/3/19 2:22 AM, Cao Jiaxi wrote:
> > Initial Windows on ARM (AArch64 64-Bit) host support
> >
> > This series of patches is for initial support of Windows 10 on ARM as a 
> > QEMU host.
> > Currently only TCG intepreter is working correctly, it crashes when TCG JIT 
> > is enabled.
> >
> > For now we assume it is built using the clang aarch64-w64-mingw32 toolchain,
> > you can get a prebuilt toolchain at https://github.com/mstorsjo/llvm-mingw.
> >
>
> I'm a bit confused since those patches appear 2 times in my mailbox.
> Assuming this is a git send-email setup mistake, please consider adding
> my Reviewed-by/Tested-by here too.

Thanks -- I've applied these patches to target-arm.next, and have
consolidated the various tags that people have applied to the
two sets of emails (and checked that they actually are the same
patches and not different code :-))

-- PMM



Re: [Qemu-devel] [PATCH v5 01/10] tests/perf: Test qemu-img convert from raw to encrypted qcow2

2019-05-03 Thread Max Reitz
On 30.04.19 10:53, Vladimir Sementsov-Ogievskiy wrote:
> 29.04.2019 1:55, Max Reitz wrote:
>> On 02.04.19 17:37, Vladimir Sementsov-Ogievskiy wrote:
>>> Signed-off-by: Vladimir Sementsov-Ogievskiy 
>>> ---
>>>   tests/perf/block/qcow2/convert-to-encrypted | 48 +
>>>   1 file changed, 48 insertions(+)
>>>   create mode 100755 tests/perf/block/qcow2/convert-to-encrypted
>>
>> Thanks for the test case, but I don’t know whether this is the right way
>> to include it.
>>
>> A concrete problem is that it doesn’t work with out-of-tree builds (I
>> only do out-of-tree builds).  I wonder whether it would be possible and
>> make sense (I have no idea) to add a subdirectory "perf" to the iotests
>> and reuse its infrastructure?  Those tests wouldn’t run by default.
>>
> 
> Honestly, I don't really like existing iotests infrastructure, bound to check
> script, which I don't like too (and any other large script in bash, sorry :(..

Hm, OK.  It would need some modifications, because it’d need to accept
non-numeric test names, and for perf tests, it probably shouldn’t
compare against a reference output.  But I don’t like bash either, and
that doesn’t sound impossible to me.

> What do you mean? You have env variables QEMU_IMG, etc, and want them to be
> accepted by script?

That would work, although it’d be cumbersome.  As for check, you just
run it from the build tree, so it auto-detects the binaries.

> I'd prefer to commit something simple and separate, to be able to build up
> infrastructure around it gradually..

Well, I’d prefer something that works.  I’d also very much prefer
something that is not separate, because that’s just adding complexity
for no good reason.  I don’t see how new infrastructure that works can
be simple.

There are Avocado tests, maybe you prefer using that.

> Finally, I want a simple way to run
> a set of perf tests on a set of git commits and get an html and ascii
> tables of performance comparison between these commits.

That doesn’t sound very simple to me, implementation-wise.  It doesn’t
sound overly complicated either, it sounds useful – but throwing out
check now because you say you just need something simple, and then
intending to make it not-so-simple later makes me raise my eyebrows.

I mean, feel free to rewrite the check script in Python, but having two
separate test infrastructures feels like a bit of waste to me.

(And you don’t have to add these new features like comparison of
performance results between commits to the check script, I think.  For
instance, you can write a wrapper script in e.g. Python or whatever that
just calls check to run the test and then processes the test result
itself.  I don’t want to force you to write more bash code, nobody wants
that, I just think that check works fine as a test launcher.)

Max

>>> diff --git a/tests/perf/block/qcow2/convert-to-encrypted 
>>> b/tests/perf/block/qcow2/convert-to-encrypted
>>> new file mode 100755
>>> index 00..7a6b7b1cab
>>> --- /dev/null
>>> +++ b/tests/perf/block/qcow2/convert-to-encrypted
>>> @@ -0,0 +1,48 @@
>>> +#!/bin/bash
>>> +#
>>> +# Test qemu-img convert from raw to encrypted qcow2
>>> +#
>>> +# Copyright (c) 2019 Virtuozzo International GmbH. All rights reserved.
>>> +#
>>> +# This program is free software; you can redistribute it and/or modify
>>> +# it under the terms of the GNU General Public License as published by
>>> +# the Free Software Foundation; either version 2 of the License, or
>>> +# (at your option) any later version.
>>> +#
>>> +# This program is distributed in the hope that it will be useful,
>>> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
>>> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>>> +# GNU General Public License for more details.
>>> +#
>>> +# You should have received a copy of the GNU General Public License
>>> +# along with this program.  If not, see .
>>> +#
>>> +
>>> +if [ "$#" -lt 2 ]; then
>>> +echo "Usage: $0 SOURCE_FILE DESTINATION_FILE [additional qemu-img 
>>> convert parameters]"
>>> +exit 1
>>> +fi
>>> +
>>> +ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../../../.." >/dev/null 
>>> 2>&1 && pwd )"
>>> +QEMU_IMG="$ROOT_DIR/qemu-img"
>>> +QEMU_IO="$ROOT_DIR/qemu-io"
>>> +
>>> +size=1G
>>> +
>>> +src="$1"
>>> +shift
>>> +
>>> +dst="$1"
>>> +shift
>>> +
>>> +(
>>> +# create source
>>> +$QEMU_IMG create -f raw "$src" $size
>>> +$QEMU_IO -f raw -c "write -P 0xa 0 $size" "$src"
>>> +
>>> +# create target
>>> +$QEMU_IMG create -f qcow2 --object secret,id=sec0,data=test -o 
>>> encrypt.format=luks,encrypt.key-secret=sec0 "$dst" $size
>>> +) > /dev/null
>>> +
>>> +# test with additional parameters left in $@
>>> +/usr/bin/time -f %e $QEMU_IMG convert "$@" -f raw --object 
>>> secret,id=sec0,data=test --target-image-opts -n "$src" 
>>> "driver=qcow2,file.filename=$dst,encrypt.key-secret=sec0"
>>>
>>
>>
> 
> 




signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PULL 0/7] Usb 20190503 v2 patches

2019-05-03 Thread Peter Maydell
On Fri, 3 May 2019 at 08:02, Gerd Hoffmann  wrote:
>
> The following changes since commit f75d15231e56cb0f2bafe19faf1229c459a60731:
>
>   Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging 
> (2019-04-30 17:06:57 +0100)
>
> are available in the Git repository at:
>
>   git://git.kraxel.org/qemu tags/usb-20190503-v2-pull-request
>
> for you to fetch changes up to ccb799313a5926a6aa49018bbc67fe6165fad7f3:
>
>   hw/usb: avoid format truncation warning when formatting port name 
> (2019-05-03 08:56:58 +0200)
>
> 
> usb: bugfixes for mtp and xhci, split ohci-pci.


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/4.1
for any user-visible changes.

-- PMM



Re: [Qemu-devel] [PATCH v1 5/5] hw/arm: Add the Netduino Plus 2

2019-05-03 Thread Peter Maydell
On Thu, 2 May 2019 at 06:41, Alistair Francis  wrote:
>
> Signed-off-by: Alistair Francis 
> ---
>  MAINTAINERS |  6 +++
>  default-configs/arm-softmmu.mak |  1 +
>  hw/arm/Kconfig  |  3 ++
>  hw/arm/Makefile.objs|  1 +
>  hw/arm/netduinoplus2.c  | 77 +
>  5 files changed, 88 insertions(+)
>  create mode 100644 hw/arm/netduinoplus2.c

> +static void netduinoplus2_init(MachineState *machine)
> +{
> +DeviceState *dev;
> +ARMV7MResetArgs reset_args;
> +uint64_t entry;
> +
> +dev = qdev_create(NULL, TYPE_STM32F405_SOC);
> +qdev_prop_set_string(dev, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m4"));
> +object_property_set_bool(OBJECT(dev), true, "realized", _fatal);
> +
> +entry = armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename,
> +   FLASH_SIZE);
> +
> +reset_args = (ARMV7MResetArgs) {
> +.cpu = ARM_CPU(first_cpu),
> +.reset_pc = entry,
> +.reset_sp = (SRAM_BASE_ADDRESS + (SRAM_SIZE * 2) / 3),
> +};
> +qemu_register_reset(armv7m_reset,
> +g_memdup(_args, sizeof(reset_args)));
> +}

I still don't really like having this board interpret -kernel
in a different way to all the other M-profile boards. I'd be
much happier if it just behaved the same way the others do.

thanks
-- PMM



Re: [Qemu-devel] [PATCH v1 4/5] hw/arm: Add the STM32F4xx SoC

2019-05-03 Thread Peter Maydell
On Thu, 2 May 2019 at 06:41, Alistair Francis  wrote:
>
> Signed-off-by: Alistair Francis 
> ---
>  MAINTAINERS |   8 +
>  default-configs/arm-softmmu.mak |   1 +
>  hw/arm/Kconfig  |   3 +
>  hw/arm/Makefile.objs|   1 +
>  hw/arm/stm32f405_soc.c  | 306 
>  include/hw/arm/stm32f405_soc.h  |  74 
>  6 files changed, 393 insertions(+)
>  create mode 100644 hw/arm/stm32f405_soc.c
>  create mode 100644 include/hw/arm/stm32f405_soc.h
>

> +static void stm32f405_soc_realize(DeviceState *dev_soc, Error **errp)
> +{
> +STM32F405State *s = STM32F405_SOC(dev_soc);
> +DeviceState *dev, *armv7m;
> +SysBusDevice *busdev;
> +Error *err = NULL;
> +int i;
> +
> +s->system_memory = get_system_memory();
> +s->sram = g_new(MemoryRegion, 1);
> +s->flash = g_new(MemoryRegion, 1);
> +s->flash_alias = g_new(MemoryRegion, 1);

What I meant by my comment on v1 was that rather than doing
g_new() here you can just have the STM32F405State struct
have
 MemoryRegion sram;
 MemoryRegion flash;
etc

and then instead of
  memory_region_init_ram(s->flash, ...)
you use
  memory_region_init_ram(>flash, ...)
etc

which avoids doing separate memory allocations (which would
need to be freed if you then do an error-exit from the
realize function, I think).

And you don't need to have an s->system_memory -- that
can just be a local variable, because it's just caching
the pointer to the global system memory MemoryRegion.

Otherwise
Reviewed-by: Peter Maydell 

thanks
-- PMM



Re: [Qemu-devel] [PATCH v1 2/5] hw/misc: Add the STM32F4xx EXTI device

2019-05-03 Thread Peter Maydell
On Thu, 2 May 2019 at 06:41, Alistair Francis  wrote:
>
> Signed-off-by: Alistair Francis 
> ---
Reviewed-by: Peter Maydell 

thanks
-- PMM



Re: [Qemu-devel] [PATCH v3 1/2] hw: timer: Add ASPEED RTC device

2019-05-03 Thread Peter Maydell
On Tue, 30 Apr 2019 at 05:40, Joel Stanley  wrote:
>
> The RTC is modeled to provide time and date functionality. It is
> initialised at zero to match the hardware.
>
> There is no modelling of the alarm functionality, which includes the IRQ
> line. As there is no guest code to exercise this function that is
> acceptable for now.
>
> Signed-off-by: Joel Stanley 


Reviewed-by: Peter Maydell 

thanks
-- PMM



Re: [Qemu-devel] [PATCH v2] arm: aspeed: Set SDRAM size

2019-05-03 Thread Peter Maydell
On Fri, 3 May 2019 at 03:30, Joel Stanley  wrote:
>
> We currently use Qemu's default of 128MB. As we know how much ram each
> machine ships with, make it easier on users by setting a default.
>
> It can still be overridden with -m on the command line.
>
> Signed-off-by: Joel Stanley 
> Reviewed-by: Andrew Jeffery 
> Reviewed-by: Richard Henderson 
> ---



Applied to target-arm.next, thanks.

-- PMM



Re: [Qemu-devel] [PATCH v4 8/8] hw/arm/boot: Expose the PC-DIMM nodes in the DT

2019-05-03 Thread Shameerali Kolothum Thodi



> -Original Message-
> From: Linuxarm [mailto:linuxarm-boun...@huawei.com] On Behalf Of
> Shameerali Kolothum Thodi
> Sent: 10 April 2019 09:49
> To: Laszlo Ersek ; qemu-devel@nongnu.org;
> qemu-...@nongnu.org; eric.au...@redhat.com; imamm...@redhat.com
> Cc: peter.mayd...@linaro.org; sa...@linux.intel.com;
> ard.biesheu...@linaro.org; Linuxarm ;
> shannon.zha...@gmail.com; sebastien.bo...@intel.com; xuwei (O)
> 
> Subject: RE: [PATCH v4 8/8] hw/arm/boot: Expose the PC-DIMM nodes in the
> DT
> 
> 
> > -Original Message-
> > From: Laszlo Ersek [mailto:ler...@redhat.com]
> > Sent: 09 April 2019 16:09
> > To: Shameerali Kolothum Thodi ;
> > qemu-devel@nongnu.org; qemu-...@nongnu.org; eric.au...@redhat.com;
> > imamm...@redhat.com
> > Cc: peter.mayd...@linaro.org; shannon.zha...@gmail.com;
> > sa...@linux.intel.com; sebastien.bo...@intel.com; xuwei (O)
> > ; ard.biesheu...@linaro.org; Linuxarm
> > 
> > Subject: Re: [PATCH v4 8/8] hw/arm/boot: Expose the PC-DIMM nodes in the
> > DT
> >
> > On 04/09/19 12:29, Shameer Kolothum wrote:
> > > This patch adds memory nodes corresponding to PC-DIMM regions.
> > > This will enable support for cold plugged device memory for Guests
> > > with DT boot.
> > >
> > > Signed-off-by: Shameer Kolothum
> 
> > > Signed-off-by: Eric Auger 
> > > ---
> > >  hw/arm/boot.c | 42 ++
> > >  1 file changed, 42 insertions(+)
> > >
> > > diff --git a/hw/arm/boot.c b/hw/arm/boot.c
> > > index 8c840ba..150e1ed 100644
> > > --- a/hw/arm/boot.c
> > > +++ b/hw/arm/boot.c
> > > @@ -19,6 +19,7 @@
> > >  #include "sysemu/numa.h"
> > >  #include "hw/boards.h"
> > >  #include "hw/loader.h"
> > > +#include "hw/mem/memory-device.h"
> > >  #include "elf.h"
> > >  #include "sysemu/device_tree.h"
> > >  #include "qemu/config-file.h"
> > > @@ -538,6 +539,41 @@ static void fdt_add_psci_node(void *fdt)
> > >  qemu_fdt_setprop_cell(fdt, "/psci", "migrate", migrate_fn);
> > >  }
> > >
> > > +static int fdt_add_hotpluggable_memory_nodes(void *fdt,
> > > + uint32_t acells,
> > uint32_t scells) {
> > > +MemoryDeviceInfoList *info, *info_list = qmp_memory_device_list();
> > > +MemoryDeviceInfo *mi;
> > > +int ret = 0;
> > > +
> > > +for (info = info_list; info != NULL; info = info->next) {
> > > +mi = info->value;
> > > +switch (mi->type) {
> > > +case MEMORY_DEVICE_INFO_KIND_DIMM:
> > > +{
> > > +PCDIMMDeviceInfo *di = mi->u.dimm.data;
> > > +
> > > +ret = fdt_add_memory_node(fdt, acells, di->addr, scells,
> > > +  di->size, di->node, true);
> > > +if (ret) {
> > > +fprintf(stderr,
> > > +"couldn't add PCDIMM
> /memory@%"PRIx64"
> > node\n",
> > > +di->addr);
> > > +goto out;
> > > +}
> > > +break;
> > > +}
> > > +default:
> > > +fprintf(stderr, "%s memory nodes are not yet supported\n",
> > > +MemoryDeviceInfoKind_str(mi->type));
> > > +ret = -ENOENT;
> > > +goto out;
> > > +}
> > > +}
> > > +out:
> > > +qapi_free_MemoryDeviceInfoList(info_list);
> > > +return ret;
> > > +}
> > > +
> > >  int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
> > >   hwaddr addr_limit, AddressSpace *as)
> > >  {
> > > @@ -637,6 +673,12 @@ int arm_load_dtb(hwaddr addr, const struct
> > arm_boot_info *binfo,
> > >  }
> > >  }
> > >
> > > +rc = fdt_add_hotpluggable_memory_nodes(fdt, acells, scells);
> > > +if (rc < 0) {
> > > +fprintf(stderr, "couldn't add hotpluggable memory nodes\n");
> > > +goto fail;
> > > +}
> > > +
> > >  rc = fdt_path_offset(fdt, "/chosen");
> > >  if (rc < 0) {
> > >  qemu_fdt_add_subnode(fdt, "/chosen");
> > >
> >
> >
> > Given patches #7 and #8, as I understand them, the firmware cannot
> > distinguish hotpluggable & present, from hotpluggable & absent. The
> firmware
> > can only skip both hotpluggable cases. That's fine in that the firmware will
> hog
> > neither type -- but is that OK for the OS as well, for both ACPI boot and DT
> > boot?
> 
> Right. This only handles the hotpluggable-and-present condition.
> 
> > Consider in particular the "hotpluggable & present, ACPI boot" case.
> Assuming
> > we modify the firmware to skip "hotpluggable" altogether, the UEFI memmap
> > will not include the range despite it being present at boot. Presumably, 
> > ACPI
> > will refer to the range somehow, however. Will that not confuse the OS?
> 
> From my testing so far, without patches #7 and #8(ie, no UEFI memmap entry),
> ACPI boots fine. I think ACPI only relies on aml and SRAT.
> 
> > When Igor raised this earlier, I suggested that hotpluggable-and-present
> > should be added by the firmware, but also allocated 

Re: [Qemu-devel] [PATCH v1 1/5] hw/misc: Add the STM32F4xx Sysconfig device

2019-05-03 Thread Peter Maydell
On Thu, 2 May 2019 at 06:40, Alistair Francis  wrote:
>
> Signed-off-by: Alistair Francis 

> +static void stm32f4xx_syscfg_set_irq(void *opaque, int irq, int level)
> +{
> +STM32F4xxSyscfgState *s = opaque;
> +int icrreg = irq / 4;
> +int startbit = (irq & 3) * 4;
> +uint8_t config = config = irq / 16;;

Stray double-semicolon.

Otherwise
Reviewed-by: Peter Maydell 

thanks
-- PMM



Re: [Qemu-devel] [PATCH v2 5/6] util: simplify unix_listen()

2019-05-03 Thread Daniel P . Berrangé
On Fri, May 03, 2019 at 03:00:33PM +0200, Marc-André Lureau wrote:
> The only caller of unix_listen() left is qga/channel-posix.c.
> 
> There is no need to deal with legacy coma-trailing options ",...".
> 
> Signed-off-by: Marc-André Lureau 
> ---
>  util/qemu-sockets.c | 18 ++
>  1 file changed, 2 insertions(+), 16 deletions(-)

Reviewed-by: Daniel P. Berrangé 

Regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|



Re: [Qemu-devel] [PATCH v3 0/2] arm: aspeed: Add RTC Model

2019-05-03 Thread Peter Maydell
On Tue, 30 Apr 2019 at 05:40, Joel Stanley  wrote:
>
> v3: Add some commit messages, resend as v2 didn't send properly
> v2: Minor fixes, added vmstate and reset, and rebased on Cédric's series
>
> Based-on: 20190411161013.4514-4-...@kaod.org
> [PATCH 3/3] aspeed: use sysbus_init_child_obj() to initialize children
>
> A model for the ASPEED BMC real time clock (RTC). The model is sufficient
> for running the guest Linux kernel driver, and ticks in time with the
> host when programmed.
>
> It does not implement the alarm functionality, which includes the
> interrupt.

Hi -- I've reviewed this series, but can't apply it yet as
it's based on Cedric's patchset which needs a respin. If
I forget to apply this when I apply the respin of that one,
please ping me...

thanks
-- PMM



Re: [Qemu-devel] [PATCH v3 2/2] hw/arm/aspeed: Add RTC to SoC

2019-05-03 Thread Peter Maydell
On Tue, 30 Apr 2019 at 05:41, Joel Stanley  wrote:
>
> All systems have an RTC.
>
> The IRQ is hooked up but the model does not use it at this stage. There
> is no guest code that uses it, so this limitation is acceptable.
>
> Signed-off-by: Joel Stanley 

Reviewed-by: Peter Maydell 

thanks
-- PMM



Re: [Qemu-devel] [PATCH] target/arm: Implement NSACR gating of floating point

2019-05-03 Thread Peter Maydell
On Sat, 13 Apr 2019 at 08:07, Richard Henderson
 wrote:
>
> On 4/11/19 5:39 AM, Peter Maydell wrote:
> > +static uint64_t cptr_el2_read(CPUARMState *env, const ARMCPRegInfo *ri)
> > +{
> > +/*
> > + * For A-profile AArch32 EL3, if NSACR.CP10
> > + * is 0 then HCPTR.{TCP11,TCP10} ignore writes and read as 1.
> > + */
> > +uint64_t value = env->cp15.cptr_el[2];
> > +
> > +if (arm_feature(env, ARM_FEATURE_EL3) && !arm_el_is_aa64(env, 3) &&
> > +!arm_is_secure(env) && !extract32(env->cp15.nsacr, 10, 1)) {
> > +value &= ~(0x3 << 10);
>
> Read as 1, and yet you're clearing the value?  Cut-n-paste error from CPACR?
> Surely better to do nothing on read, but set on write (to either HCPTR or 
> NSACR).
>
> > +static uint64_t cpacr_read(CPUARMState *env, const ARMCPRegInfo *ri)
> > +{
> > +/*
> > + * For A-profile AArch32 EL3 (but not M-profile secure mode), if 
> > NSACR.CP10
> > + * is 0 then CPACR.{CP11,CP10} ignore writes and read as 0b00.
> > + */
> > +uint64_t value = env->cp15.cpacr_el1;
> > +
> > +if (arm_feature(env, ARM_FEATURE_EL3) && !arm_el_is_aa64(env, 3) &&
> > +!arm_is_secure(env) && !extract32(env->cp15.nsacr, 10, 1)) {
> > +value &= ~(0xf << 20);
> > +}
>
> This one does do the right thing, but better to clear the bits on write to
> NSACR.  This lets you avoid the change to fp_exception_el, and the missing
> change to sve_exception_el.

Hi Richard -- I was just going through the review comments on this
patchset, and I saw this bit. Could you clarify what you mean by
"the missing change to sve_exception_el" ? Since SVE is AArch64 only,
there can't be any configs where we have SVE and EL3 is AArch32,
so I don't think these two features should be able to interact.

thanks
-- PMM



[Qemu-devel] [PATCH v2 5/6] util: simplify unix_listen()

2019-05-03 Thread Marc-André Lureau
The only caller of unix_listen() left is qga/channel-posix.c.

There is no need to deal with legacy coma-trailing options ",...".

Signed-off-by: Marc-André Lureau 
---
 util/qemu-sockets.c | 18 ++
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 9705051690..d1664e83d6 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -966,26 +966,12 @@ static int unix_connect_saddr(UnixSocketAddress *saddr, 
Error **errp)
 /* compatibility wrapper */
 int unix_listen(const char *str, Error **errp)
 {
-char *path, *optstr;
-int sock, len;
 UnixSocketAddress *saddr;
+int sock;
 
 saddr = g_new0(UnixSocketAddress, 1);
-
-optstr = strchr(str, ',');
-if (optstr) {
-len = optstr - str;
-if (len) {
-path = g_malloc(len+1);
-snprintf(path, len+1, "%.*s", len, str);
-saddr->path = path;
-}
-} else {
-saddr->path = g_strdup(str);
-}
-
+saddr->path = g_strdup(str);
 sock = unix_listen_saddr(saddr, errp);
-
 qapi_free_UnixSocketAddress(saddr);
 return sock;
 }
-- 
2.21.0.777.g83232e3864




[Qemu-devel] [PATCH v2 6/6] contrib: add vhost-user-input

2019-05-03 Thread Marc-André Lureau
Add a vhost-user input backend example, based on virtio-input-host
device. It takes an evdev path as argument, and can be associated with
a vhost-user-input device via a UNIX socket:

$ vhost-user-input -p /dev/input/eventX -s /tmp/vui.sock

$ qemu ... -chardev socket,id=vuic,path=/tmp/vui.sock
  -device vhost-user-input-pci,chardev=vuic

This example is intentionally not included in $TOOLS, and not
installed by default.

Signed-off-by: Marc-André Lureau 
---
 contrib/vhost-user-input/main.c| 393 +
 MAINTAINERS|   1 +
 Makefile   |  11 +
 Makefile.objs  |   1 +
 contrib/vhost-user-input/Makefile.objs |   1 +
 5 files changed, 407 insertions(+)
 create mode 100644 contrib/vhost-user-input/main.c
 create mode 100644 contrib/vhost-user-input/Makefile.objs

diff --git a/contrib/vhost-user-input/main.c b/contrib/vhost-user-input/main.c
new file mode 100644
index 00..8d493f598e
--- /dev/null
+++ b/contrib/vhost-user-input/main.c
@@ -0,0 +1,393 @@
+/*
+ * This work is licensed under the terms of the GNU GPL, version 2 or
+ * (at your option) any later version.  See the COPYING file in the
+ * top-level directory.
+ */
+
+#include "qemu/osdep.h"
+
+#include 
+#include 
+
+#include "qemu/iov.h"
+#include "qemu/bswap.h"
+#include "qemu/sockets.h"
+#include "contrib/libvhost-user/libvhost-user.h"
+#include "contrib/libvhost-user/libvhost-user-glib.h"
+#include "standard-headers/linux/virtio_input.h"
+#include "qapi/error.h"
+
+typedef struct virtio_input_event virtio_input_event;
+typedef struct virtio_input_config virtio_input_config;
+
+typedef struct VuInput {
+VugDev dev;
+GSource *evsrc;
+int evdevfd;
+GArray *config;
+virtio_input_config *sel_config;
+struct {
+virtio_input_event event;
+VuVirtqElement *elem;
+} *queue;
+uint32_t qindex, qsize;
+} VuInput;
+
+static void vi_input_send(VuInput *vi, struct virtio_input_event *event)
+{
+VuDev *dev = >dev.parent;
+VuVirtq *vq = vu_get_queue(dev, 0);
+VuVirtqElement *elem;
+int i, len;
+
+/* queue up events ... */
+if (vi->qindex == vi->qsize) {
+vi->qsize++;
+vi->queue = g_realloc_n(vi->queue, vi->qsize, sizeof(vi->queue[0]));
+}
+vi->queue[vi->qindex++].event = *event;
+
+/* ... until we see a report sync ... */
+if (event->type != htole16(EV_SYN) ||
+event->code != htole16(SYN_REPORT)) {
+return;
+}
+
+/* ... then check available space ... */
+for (i = 0; i < vi->qindex; i++) {
+elem = vu_queue_pop(dev, vq, sizeof(VuVirtqElement));
+if (!elem) {
+while (--i >= 0) {
+vu_queue_unpop(dev, vq, vi->queue[i].elem, 0);
+}
+vi->qindex = 0;
+g_warning("virtio-input queue full");
+return;
+}
+vi->queue[i].elem = elem;
+}
+
+/* ... and finally pass them to the guest */
+for (i = 0; i < vi->qindex; i++) {
+elem = vi->queue[i].elem;
+len = iov_from_buf(elem->in_sg, elem->in_num,
+   0, >queue[i].event, sizeof(virtio_input_event));
+vu_queue_push(dev, vq, elem, len);
+g_free(elem);
+}
+
+vu_queue_notify(>dev.parent, vq);
+vi->qindex = 0;
+}
+
+static void
+vi_evdev_watch(VuDev *dev, int condition, void *data)
+{
+VuInput *vi = data;
+int fd = vi->evdevfd;
+
+g_debug("Got evdev condition %x", condition);
+
+struct virtio_input_event virtio;
+struct input_event evdev;
+int rc;
+
+for (;;) {
+rc = read(fd, , sizeof(evdev));
+if (rc != sizeof(evdev)) {
+break;
+}
+
+g_debug("input %d %d %d", evdev.type, evdev.code, evdev.value);
+
+virtio.type  = htole16(evdev.type);
+virtio.code  = htole16(evdev.code);
+virtio.value = htole32(evdev.value);
+vi_input_send(vi, );
+}
+}
+
+
+static void vi_handle_status(VuInput *vi, virtio_input_event *event)
+{
+struct input_event evdev;
+int rc;
+
+if (gettimeofday(, NULL)) {
+perror("vi_handle_status: gettimeofday");
+return;
+}
+
+evdev.type = le16toh(event->type);
+evdev.code = le16toh(event->code);
+evdev.value = le32toh(event->value);
+
+rc = write(vi->evdevfd, , sizeof(evdev));
+if (rc == -1) {
+perror("vi_host_handle_status: write");
+}
+}
+
+static void vi_handle_sts(VuDev *dev, int qidx)
+{
+VuInput *vi = container_of(dev, VuInput, dev.parent);
+VuVirtq *vq = vu_get_queue(dev, qidx);
+virtio_input_event event;
+VuVirtqElement *elem;
+int len;
+
+g_debug("%s", G_STRFUNC);
+
+for (;;) {
+elem = vu_queue_pop(dev, vq, sizeof(VuVirtqElement));
+if (!elem) {
+break;
+}
+
+memset(, 0, sizeof(event));
+len = iov_to_buf(elem->out_sg, elem->out_num,
+  

[Qemu-devel] [PATCH v2 4/6] Add vhost-user-input-pci

2019-05-03 Thread Marc-André Lureau
Add a new virtio-input device, which connects to a vhost-user
backend.

Instead of reading configuration directly from an input device /
evdev (like virtio-input-host), it reads it over vhost-user protocol
with {SET,GET}_CONFIG messages. The vhost-user-backend handles the
queues & events setup.

Signed-off-by: Marc-André Lureau 
---
 include/hw/virtio/virtio-input.h |  14 
 hw/input/vhost-user-input.c  | 129 +++
 hw/virtio/vhost-user-input-pci.c |  53 +
 MAINTAINERS  |   1 +
 hw/input/Kconfig |   5 ++
 hw/input/Makefile.objs   |   1 +
 hw/virtio/Makefile.objs  |   1 +
 7 files changed, 204 insertions(+)
 create mode 100644 hw/input/vhost-user-input.c
 create mode 100644 hw/virtio/vhost-user-input-pci.c

diff --git a/include/hw/virtio/virtio-input.h b/include/hw/virtio/virtio-input.h
index 054c38836f..4fca03e796 100644
--- a/include/hw/virtio/virtio-input.h
+++ b/include/hw/virtio/virtio-input.h
@@ -2,6 +2,7 @@
 #define QEMU_VIRTIO_INPUT_H
 
 #include "ui/input.h"
+#include "sysemu/vhost-user-backend.h"
 
 /* - */
 /* virtio input protocol */
@@ -42,11 +43,18 @@ typedef struct virtio_input_event virtio_input_event;
 #define VIRTIO_INPUT_HOST_GET_PARENT_CLASS(obj) \
 OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT_HOST)
 
+#define TYPE_VHOST_USER_INPUT   "vhost-user-input"
+#define VHOST_USER_INPUT(obj)  \
+OBJECT_CHECK(VHostUserInput, (obj), TYPE_VHOST_USER_INPUT)
+#define VHOST_USER_INPUT_GET_PARENT_CLASS(obj) \
+OBJECT_GET_PARENT_CLASS(obj, TYPE_VHOST_USER_INPUT)
+
 typedef struct VirtIOInput VirtIOInput;
 typedef struct VirtIOInputClass VirtIOInputClass;
 typedef struct VirtIOInputConfig VirtIOInputConfig;
 typedef struct VirtIOInputHID VirtIOInputHID;
 typedef struct VirtIOInputHost VirtIOInputHost;
+typedef struct VHostUserInput VHostUserInput;
 
 struct VirtIOInputConfig {
 virtio_input_config   config;
@@ -98,6 +106,12 @@ struct VirtIOInputHost {
 int   fd;
 };
 
+struct VHostUserInput {
+VirtIOInput   parent_obj;
+
+VhostUserBackend  *vhost;
+};
+
 void virtio_input_send(VirtIOInput *vinput, virtio_input_event *event);
 void virtio_input_init_config(VirtIOInput *vinput,
   virtio_input_config *config);
diff --git a/hw/input/vhost-user-input.c b/hw/input/vhost-user-input.c
new file mode 100644
index 00..6da497b1a8
--- /dev/null
+++ b/hw/input/vhost-user-input.c
@@ -0,0 +1,129 @@
+/*
+ * This work is licensed under the terms of the GNU GPL, version 2 or
+ * (at your option) any later version.  See the COPYING file in the
+ * top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/error-report.h"
+#include "qapi/error.h"
+#include "qemu-common.h"
+
+#include "hw/qdev.h"
+#include "hw/virtio/virtio-input.h"
+
+static int vhost_input_config_change(struct vhost_dev *dev)
+{
+error_report("vhost-user-input: unhandled backend config change");
+return -1;
+}
+
+static const VhostDevConfigOps config_ops = {
+.vhost_dev_config_notifier = vhost_input_config_change,
+};
+
+static void vhost_input_realize(DeviceState *dev, Error **errp)
+{
+VHostUserInput *vhi = VHOST_USER_INPUT(dev);
+VirtIOInput *vinput = VIRTIO_INPUT(dev);
+VirtIODevice *vdev = VIRTIO_DEVICE(dev);
+
+vhost_dev_set_config_notifier(>vhost->dev, _ops);
+vinput->cfg_size = sizeof_field(virtio_input_config, u);
+if (vhost_user_backend_dev_init(vhi->vhost, vdev, 2, errp) == -1) {
+return;
+}
+}
+
+static void vhost_input_change_active(VirtIOInput *vinput)
+{
+VHostUserInput *vhi = VHOST_USER_INPUT(vinput);
+
+if (vinput->active) {
+vhost_user_backend_start(vhi->vhost);
+} else {
+vhost_user_backend_stop(vhi->vhost);
+}
+}
+
+static void vhost_input_get_config(VirtIODevice *vdev, uint8_t *config_data)
+{
+VirtIOInput *vinput = VIRTIO_INPUT(vdev);
+VHostUserInput *vhi = VHOST_USER_INPUT(vdev);
+int ret;
+
+memset(config_data, 0, vinput->cfg_size);
+
+ret = vhost_dev_get_config(>vhost->dev, config_data, 
vinput->cfg_size);
+if (ret) {
+error_report("vhost-user-input: get device config space failed");
+return;
+}
+}
+
+static void vhost_input_set_config(VirtIODevice *vdev,
+   const uint8_t *config_data)
+{
+VHostUserInput *vhi = VHOST_USER_INPUT(vdev);
+int ret;
+
+ret = vhost_dev_set_config(>vhost->dev, config_data,
+   0, sizeof(virtio_input_config),
+   VHOST_SET_CONFIG_TYPE_MASTER);
+if (ret) {
+error_report("vhost-user-input: set device config space failed");
+return;
+}
+
+virtio_notify_config(vdev);

[Qemu-devel] [PATCH v2 0/6] Add vhost-user-input

2019-05-03 Thread Marc-André Lureau
Hi,

This is the vhost-user-input part of "[PATCH v6 00/11] vhost-user for input & 
GPU".

v2:
- build fixes

v1: (changes since original v6 series)
- add "libvhost-user: fix -Waddress-of-packed-member" & "util: simplify 
unix_listen()"
- use unix_listen()
- build vhost-user-input by default (when applicable)

Marc-André Lureau (6):
  libvhost-user: fix -Waddress-of-packed-member
  libvhost-user: add PROTOCOL_F_CONFIG if {set,get}_config
  Add vhost-user-backend
  Add vhost-user-input-pci
  util: simplify unix_listen()
  contrib: add vhost-user-input

 include/hw/virtio/virtio-input.h   |  14 +
 include/sysemu/vhost-user-backend.h|  57 
 backends/vhost-user.c  | 209 +
 contrib/libvhost-user/libvhost-user.c  |  10 +-
 contrib/vhost-user-input/main.c| 393 +
 hw/input/vhost-user-input.c| 129 
 hw/virtio/vhost-user-input-pci.c   |  53 
 util/qemu-sockets.c|  18 +-
 MAINTAINERS|   4 +
 Makefile   |  11 +
 Makefile.objs  |   1 +
 backends/Makefile.objs |   2 +
 contrib/vhost-user-input/Makefile.objs |   1 +
 hw/input/Kconfig   |   5 +
 hw/input/Makefile.objs |   1 +
 hw/virtio/Makefile.objs|   1 +
 16 files changed, 890 insertions(+), 19 deletions(-)
 create mode 100644 include/sysemu/vhost-user-backend.h
 create mode 100644 backends/vhost-user.c
 create mode 100644 contrib/vhost-user-input/main.c
 create mode 100644 hw/input/vhost-user-input.c
 create mode 100644 hw/virtio/vhost-user-input-pci.c
 create mode 100644 contrib/vhost-user-input/Makefile.objs

-- 
2.21.0.777.g83232e3864




[Qemu-devel] [PATCH v2 1/6] libvhost-user: fix -Waddress-of-packed-member

2019-05-03 Thread Marc-André Lureau
/home/elmarco/src/qemu/contrib/libvhost-user/libvhost-user.c: In function 
‘vu_set_mem_table_exec_postcopy’:
/home/elmarco/src/qemu/contrib/libvhost-user/libvhost-user.c:546:31: warning: 
taking address of packed member of ‘struct VhostUserMsg’ may result in an 
unaligned pointer value [-Waddress-of-packed-member]
  546 | VhostUserMemory *memory = >payload.memory;
  |   ^
/home/elmarco/src/qemu/contrib/libvhost-user/libvhost-user.c: In function 
‘vu_set_mem_table_exec’:
/home/elmarco/src/qemu/contrib/libvhost-user/libvhost-user.c:688:31: warning: 
taking address of packed member of ‘struct VhostUserMsg’ may result in an 
unaligned pointer value [-Waddress-of-packed-member]
  688 | VhostUserMemory *memory = >payload.memory;
  |   ^
/home/elmarco/src/qemu/contrib/libvhost-user/libvhost-user.c: In function 
‘vu_set_vring_addr_exec’:
/home/elmarco/src/qemu/contrib/libvhost-user/libvhost-user.c:817:36: warning: 
taking address of packed member of ‘struct VhostUserMsg’ may result in an 
unaligned pointer value [-Waddress-of-packed-member]
  817 | struct vhost_vring_addr *vra = >payload.addr;
  |^~~

Signed-off-by: Marc-André Lureau 
---
 contrib/libvhost-user/libvhost-user.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/contrib/libvhost-user/libvhost-user.c 
b/contrib/libvhost-user/libvhost-user.c
index e08d6c7b97..dcf4a969f2 100644
--- a/contrib/libvhost-user/libvhost-user.c
+++ b/contrib/libvhost-user/libvhost-user.c
@@ -542,7 +542,7 @@ static bool
 vu_set_mem_table_exec_postcopy(VuDev *dev, VhostUserMsg *vmsg)
 {
 int i;
-VhostUserMemory *memory = >payload.memory;
+VhostUserMemory m = vmsg->payload.memory, *memory = 
 dev->nregions = memory->nregions;
 
 DPRINT("Nregions: %d\n", memory->nregions);
@@ -684,7 +684,7 @@ static bool
 vu_set_mem_table_exec(VuDev *dev, VhostUserMsg *vmsg)
 {
 int i;
-VhostUserMemory *memory = >payload.memory;
+VhostUserMemory m = vmsg->payload.memory, *memory = 
 
 for (i = 0; i < dev->nregions; i++) {
 VuDevRegion *r = >regions[i];
@@ -813,7 +813,7 @@ vu_set_vring_num_exec(VuDev *dev, VhostUserMsg *vmsg)
 static bool
 vu_set_vring_addr_exec(VuDev *dev, VhostUserMsg *vmsg)
 {
-struct vhost_vring_addr *vra = >payload.addr;
+struct vhost_vring_addr addr = vmsg->payload.addr, *vra = 
 unsigned int index = vra->index;
 VuVirtq *vq = >vq[index];
 
-- 
2.21.0.777.g83232e3864




[Qemu-devel] [PATCH v2 3/6] Add vhost-user-backend

2019-05-03 Thread Marc-André Lureau
Create a vhost-user-backend object that holds a connection to a
vhost-user backend (or "slave" process) and can be referenced from
virtio devices that support it. See later patches for input & gpu
usage.

Note: a previous iteration of this object made it user-creatable, and
allowed managed sub-process spawning, but that has been dropped for
now.

Signed-off-by: Marc-André Lureau 
---
 include/sysemu/vhost-user-backend.h |  57 
 backends/vhost-user.c   | 209 
 MAINTAINERS |   2 +
 backends/Makefile.objs  |   2 +
 4 files changed, 270 insertions(+)
 create mode 100644 include/sysemu/vhost-user-backend.h
 create mode 100644 backends/vhost-user.c

diff --git a/include/sysemu/vhost-user-backend.h 
b/include/sysemu/vhost-user-backend.h
new file mode 100644
index 00..9abf8f06a1
--- /dev/null
+++ b/include/sysemu/vhost-user-backend.h
@@ -0,0 +1,57 @@
+/*
+ * QEMU vhost-user backend
+ *
+ * Copyright (C) 2018 Red Hat Inc
+ *
+ * Authors:
+ *  Marc-André Lureau 
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#ifndef QEMU_VHOST_USER_BACKEND_H
+#define QEMU_VHOST_USER_BACKEND_H
+
+#include "qom/object.h"
+#include "exec/memory.h"
+#include "qemu/option.h"
+#include "qemu/bitmap.h"
+#include "hw/virtio/vhost.h"
+#include "hw/virtio/vhost-user.h"
+#include "chardev/char-fe.h"
+#include "io/channel.h"
+
+#define TYPE_VHOST_USER_BACKEND "vhost-user-backend"
+#define VHOST_USER_BACKEND(obj) \
+OBJECT_CHECK(VhostUserBackend, (obj), TYPE_VHOST_USER_BACKEND)
+#define VHOST_USER_BACKEND_GET_CLASS(obj) \
+OBJECT_GET_CLASS(VhostUserBackendClass, (obj), TYPE_VHOST_USER_BACKEND)
+#define VHOST_USER_BACKEND_CLASS(klass) \
+OBJECT_CLASS_CHECK(VhostUserBackendClass, (klass), TYPE_VHOST_USER_BACKEND)
+
+typedef struct VhostUserBackend VhostUserBackend;
+typedef struct VhostUserBackendClass VhostUserBackendClass;
+
+struct VhostUserBackendClass {
+ObjectClass parent_class;
+};
+
+struct VhostUserBackend {
+/* private */
+Object parent;
+
+char *chr_name;
+CharBackend chr;
+VhostUserState vhost_user;
+struct vhost_dev dev;
+VirtIODevice *vdev;
+bool started;
+bool completed;
+};
+
+int vhost_user_backend_dev_init(VhostUserBackend *b, VirtIODevice *vdev,
+unsigned nvqs, Error **errp);
+void vhost_user_backend_start(VhostUserBackend *b);
+void vhost_user_backend_stop(VhostUserBackend *b);
+
+#endif
diff --git a/backends/vhost-user.c b/backends/vhost-user.c
new file mode 100644
index 00..2b055544a7
--- /dev/null
+++ b/backends/vhost-user.c
@@ -0,0 +1,209 @@
+/*
+ * QEMU vhost-user backend
+ *
+ * Copyright (C) 2018 Red Hat Inc
+ *
+ * Authors:
+ *  Marc-André Lureau 
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+
+#include "qemu/osdep.h"
+#include "hw/qdev.h"
+#include "qapi/error.h"
+#include "qapi/qmp/qerror.h"
+#include "qemu/error-report.h"
+#include "qom/object_interfaces.h"
+#include "sysemu/vhost-user-backend.h"
+#include "sysemu/kvm.h"
+#include "io/channel-command.h"
+#include "hw/virtio/virtio-bus.h"
+
+static bool
+ioeventfd_enabled(void)
+{
+return kvm_enabled() && kvm_eventfds_enabled();
+}
+
+int
+vhost_user_backend_dev_init(VhostUserBackend *b, VirtIODevice *vdev,
+unsigned nvqs, Error **errp)
+{
+int ret;
+
+assert(!b->vdev && vdev);
+
+if (!ioeventfd_enabled()) {
+error_setg(errp, "vhost initialization failed: requires kvm");
+return -1;
+}
+
+if (!vhost_user_init(>vhost_user, >chr, errp)) {
+return -1;
+}
+
+b->vdev = vdev;
+b->dev.nvqs = nvqs;
+b->dev.vqs = g_new(struct vhost_virtqueue, nvqs);
+
+ret = vhost_dev_init(>dev, >vhost_user, VHOST_BACKEND_TYPE_USER, 0);
+if (ret < 0) {
+error_setg_errno(errp, -ret, "vhost initialization failed");
+return -1;
+}
+
+return 0;
+}
+
+void
+vhost_user_backend_start(VhostUserBackend *b)
+{
+BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(b->vdev)));
+VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
+int ret, i ;
+
+if (b->started) {
+return;
+}
+
+if (!k->set_guest_notifiers) {
+error_report("binding does not support guest notifiers");
+return;
+}
+
+ret = vhost_dev_enable_notifiers(>dev, b->vdev);
+if (ret < 0) {
+return;
+}
+
+ret = k->set_guest_notifiers(qbus->parent, b->dev.nvqs, true);
+if (ret < 0) {
+error_report("Error binding guest notifier");
+goto err_host_notifiers;
+}
+
+b->dev.acked_features = b->vdev->guest_features;
+ret = vhost_dev_start(>dev, b->vdev);
+if (ret < 0) {
+error_report("Error start vhost dev");
+goto err_guest_notifiers;
+}
+
+/* 

[Qemu-devel] [PATCH v2 2/6] libvhost-user: add PROTOCOL_F_CONFIG if {set, get}_config

2019-05-03 Thread Marc-André Lureau
Add the config protocol feature bit if the set_config & get_config
callbacks are implemented.

Signed-off-by: Marc-André Lureau 
---
 contrib/libvhost-user/libvhost-user.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/contrib/libvhost-user/libvhost-user.c 
b/contrib/libvhost-user/libvhost-user.c
index dcf4a969f2..74d42177c5 100644
--- a/contrib/libvhost-user/libvhost-user.c
+++ b/contrib/libvhost-user/libvhost-user.c
@@ -1157,6 +1157,10 @@ vu_get_protocol_features_exec(VuDev *dev, VhostUserMsg 
*vmsg)
 features |= 1ULL << VHOST_USER_PROTOCOL_F_PAGEFAULT;
 }
 
+if (dev->iface->get_config && dev->iface->set_config) {
+features |= 1ULL << VHOST_USER_PROTOCOL_F_CONFIG;
+}
+
 if (dev->iface->get_protocol_features) {
 features |= dev->iface->get_protocol_features(dev);
 }
-- 
2.21.0.777.g83232e3864




Re: [Qemu-devel] [PATCH v2] gitmodules: use qemu.org git mirrors

2019-05-03 Thread Peter Maydell
On Thu, 2 May 2019 at 11:11, Peter Maydell  wrote:
>
> On Wed, 1 May 2019 at 17:20, Stefan Hajnoczi  wrote:
> >
> > On Thu, Apr 25, 2019 at 03:54:20PM +0100, Stefan Hajnoczi wrote:
> > > qemu.org hosts git repository mirrors of all submodules.  Update
> > > .gitmodules to use the mirrors and not the upstream repositories.
> > >
> > > Mirroring upstream repositories ensures that QEMU continues to build
> > > even when upstream repositories are deleted or temporarily offline.
> > >
> > > Signed-off-by: Stefan Hajnoczi 
> > > Reviewed-by: Philippe Mathieu-Daudé 
> > > Tested-by: Philippe Mathieu-Daudé 
> > > ---
> > >  .gitmodules | 10 +-
> > >  1 file changed, 5 insertions(+), 5 deletions(-)
> >
> > Ping?

> This won't apply because currently master's .gitmodules
> has no [submodule "slirp"] entry. I was assuming you'd
> ping or repost once the slirp changes went in.

The slirp changes are now in master, so I've applied this.

thanks
-- PMM



Re: [Qemu-devel] [PULL 0/2] slirp: move slirp as git submodule project

2019-05-03 Thread Peter Maydell
On Thu, 2 May 2019 at 23:30, Samuel Thibault
 wrote:
>
> The following changes since commit 8482ff2eb3bb95020eb2f370a9b3ea26511e41df:
>
>   Merge remote-tracking branch 'remotes/jnsnow/tags/bitmaps-pull-request' 
> into staging (2019-05-02 12:04:51 +0100)
>
> are available in the Git repository at:
>
>   https://people.debian.org/~sthibault/qemu.git tags/samuel-thibault
>
> for you to fetch changes up to 7c57bdd82026ba03f3158bbcd841afde7c2dc43a:
>
>   build-sys: move slirp as git submodule project (2019-05-03 00:15:37 +0200)
>
> 
> slirp: move slirp as git submodule project
>
> Marc-André Lureau (2):
>   build-sys: pass CFLAGS & LDFLAGS to subdir-slirp
>   build-sys: move slirp as git submodule project
>
> 
> Marc-André Lureau (2):
>   build-sys: pass CFLAGS & LDFLAGS to subdir-slirp
>   build-sys: move slirp as git submodule project
>


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/4.1
for any user-visible changes.

-- PMM



Re: [Qemu-devel] [PATCH RESEND 0/2] ui/cocoa: Fix absolute and relative input issues on Mojave

2019-05-03 Thread Peter Maydell
On Sun, 28 Apr 2019 at 04:30, Chen Zhang  wrote:
>
> The following patches fixed absolute and relative input device issues on 
> macOS Mojave.
>
> Chen Zhang (2):
>   ui/cocoa: Fix absolute input device grabbing issue on Mojave
>   ui/cocoa: Fix mouse grabbing in fullscreen mode for relative input
> device
>
>  ui/cocoa.m | 50 +++---
>  1 file changed, 47 insertions(+), 3 deletions(-)

Hi -- unfortunately your email client seems to have sent
these patches in a way that has confused our patch
handling systems (eg
https://patchwork.kernel.org/patch/10920623/ has
only half of the patch as actual patch, so it doesn't
apply properly, and the 'patches' program has been confused too.

Looking at the headers, your mail client is trying to send the
patches as multipart/alternative with a combined text and HTML
version. You could try configuring it to just send plain text,
which is definitely the preferred format for public mailing lists.
Or alternatively you could try using git-send-email instead.

thanks
-- PMM



Re: [Qemu-devel] [PATCH v4 3/8] hw/acpi: Add ACPI Generic Event Device Support

2019-05-03 Thread Shameerali Kolothum Thodi
Hi Igor,

> -Original Message-
> From: Igor Mammedov [mailto:imamm...@redhat.com]
> Sent: 02 May 2019 17:13
> To: Shameerali Kolothum Thodi 
> Cc: qemu-devel@nongnu.org; qemu-...@nongnu.org;
> eric.au...@redhat.com; peter.mayd...@linaro.org;
> shannon.zha...@gmail.com; sa...@linux.intel.com;
> sebastien.bo...@intel.com; xuwei (O) ;
> ler...@redhat.com; ard.biesheu...@linaro.org; Linuxarm
> 
> Subject: Re: [PATCH v4 3/8] hw/acpi: Add ACPI Generic Event Device Support
> 
> On Tue, 9 Apr 2019 11:29:30 +0100
> Shameer Kolothum  wrote:
> 
> > From: Samuel Ortiz 
> >
> > The ACPI Generic Event Device (GED) is a hardware-reduced specific
> > device[ACPI v6.1 Section 5.6.9] that handles all platform events,
> > including the hotplug ones.This patch generates the AML code that
> > defines GEDs.
> >
> > Platforms need to specify their own GedEvent array to describe what
> > kind of events they want to support through GED.  Also this uses a
> > a single interrupt for the  GED device, relying on IO memory region
> > to communicate the type of device affected by the interrupt. This
> > way, we can support up to 32 events with a unique interrupt.
> >
> > This supports only memory hotplug for now.
> >
> > Signed-off-by: Samuel Ortiz 
> > Signed-off-by: Sebastien Boeuf 
> > Signed-off-by: Shameer Kolothum 
> > ---
> >  hw/acpi/Kconfig|   4 +
> >  hw/acpi/Makefile.objs  |   1 +
> >  hw/acpi/generic_event_device.c | 311
> +
> >  include/hw/acpi/generic_event_device.h | 121 +
> >  4 files changed, 437 insertions(+)
> >  create mode 100644 hw/acpi/generic_event_device.c
> >  create mode 100644 include/hw/acpi/generic_event_device.h
> >
> > diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig
> > index eca3bee..01a8b41 100644
> > --- a/hw/acpi/Kconfig
> > +++ b/hw/acpi/Kconfig
> > @@ -27,3 +27,7 @@ config ACPI_VMGENID
> >  bool
> >  default y
> >  depends on PC
> > +
> > +config ACPI_HW_REDUCED
> > +bool
> > +depends on ACPI
> > diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
> > index 2d46e37..b753232 100644
> > --- a/hw/acpi/Makefile.objs
> > +++ b/hw/acpi/Makefile.objs
> > @@ -6,6 +6,7 @@ common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) +=
> memory_hotplug.o
> >  common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu.o
> >  common-obj-$(CONFIG_ACPI_NVDIMM) += nvdimm.o
> >  common-obj-$(CONFIG_ACPI_VMGENID) += vmgenid.o
> > +common-obj-$(CONFIG_ACPI_HW_REDUCED) += generic_event_device.o
> >  common-obj-$(call lnot,$(CONFIG_ACPI_X86)) += acpi-stub.o
> >
> >  common-obj-y += acpi_interface.o
> > diff --git a/hw/acpi/generic_event_device.c
> b/hw/acpi/generic_event_device.c
> > new file mode 100644
> > index 000..856ca04
> > --- /dev/null
> > +++ b/hw/acpi/generic_event_device.c
> > @@ -0,0 +1,311 @@
> > +/*
> > + *
> > + * Copyright (c) 2018 Intel Corporation
> > + *
> > + * This program is free software; you can redistribute it and/or modify it
> > + * under the terms and conditions of the GNU General Public License,
> > + * version 2 or later, as published by the Free Software Foundation.
> > + *
> > + * This program is distributed in the hope it will be useful, but WITHOUT
> > + * ANY WARRANTY; without even the implied warranty of
> MERCHANTABILITY or
> > + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
> License for
> > + * more details.
> > + *
> > + * You should have received a copy of the GNU General Public License along
> with
> > + * this program.  If not, see .
> > + */
> > +
> > +#include "qemu/osdep.h"
> > +#include "qapi/error.h"
> > +#include "exec/address-spaces.h"
> > +#include "hw/sysbus.h"
> > +#include "hw/acpi/acpi.h"
> > +#include "hw/acpi/generic_event_device.h"
> > +#include "hw/mem/pc-dimm.h"
> > +
> > +static Aml *ged_event_aml(const GedEvent *event)
> > +{
> > +
> > +if (!event) {
> In general, I prefer to check condition for calling something before doing 
> call.
> This way one can see in caller why and what is called, which is more clear.

Ok. I will move it then.

> 
> > +return NULL;
> > +}
> > +
> > +switch (event->event) {
> > +case GED_MEMORY_HOTPLUG:
> > +/* We run a complete memory SCAN when getting a memory
> hotplug event */
> > +return aml_call0(MEMORY_DEVICES_CONTAINER "."
> MEMORY_SLOT_SCAN_METHOD);
> > +default:
> > +break;
> > +}
> > +
> > +return NULL;
> > +}
> > +
> > +/*
> > + * The ACPI Generic Event Device (GED) is a hardware-reduced specific
> > + * device[ACPI v6.1 Section 5.6.9] that handles all platform events,
> > + * including the hotplug ones. Platforms need to specify their own
> > + * GedEvent array to describe what kind of events they want to support
> > + * through GED. This routine uses a single interrupt for the GED device,
> > + * relying on IO memory region to communicate the type of device
> > + * affected by the interrupt. This way, we can support 

Re: [Qemu-devel] [PATCH v4 4/8] hw/arm/virt: Add memory hotplug framework

2019-05-03 Thread Shameerali Kolothum Thodi



> -Original Message-
> From: Igor Mammedov [mailto:imamm...@redhat.com]
> Sent: 02 May 2019 17:19
> To: Shameerali Kolothum Thodi 
> Cc: qemu-devel@nongnu.org; qemu-...@nongnu.org;
> eric.au...@redhat.com; peter.mayd...@linaro.org;
> shannon.zha...@gmail.com; sa...@linux.intel.com;
> sebastien.bo...@intel.com; xuwei (O) ;
> ler...@redhat.com; ard.biesheu...@linaro.org; Linuxarm
> 
> Subject: Re: [PATCH v4 4/8] hw/arm/virt: Add memory hotplug framework
> 
> On Tue, 9 Apr 2019 11:29:31 +0100
> Shameer Kolothum  wrote:
> 
> > From: Eric Auger 
> >
> > This patch adds the memory hot-plug/hot-unplug infrastructure
> > in machvirt. The device memory is not yet exposed to the Guest
> > either though DT or ACPI and hence both cold/hot plug of memory
> s/though/through/

Sure.

> > is explicitly disabled for now.
> >
> > Signed-off-by: Eric Auger 
> > Signed-off-by: Kwangwoo Lee 
> > Signed-off-by: Shameer Kolothum 
> > ---
> >  default-configs/arm-softmmu.mak |  3 +++
> >  hw/arm/virt.c   | 45
> -
> >  2 files changed, 47 insertions(+), 1 deletion(-)
> >
> > diff --git a/default-configs/arm-softmmu.mak
> b/default-configs/arm-softmmu.mak
> > index 613d19a..9f4b803 100644
> > --- a/default-configs/arm-softmmu.mak
> > +++ b/default-configs/arm-softmmu.mak
> > @@ -160,3 +160,6 @@ CONFIG_MUSICPAL=y
> >
> >  # for realview and versatilepb
> >  CONFIG_LSI_SCSI_PCI=y
> > +
> > +CONFIG_MEM_DEVICE=y
> > +CONFIG_DIMM=y
> > diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> > index ce2664a..da516b3 100644
> > --- a/hw/arm/virt.c
> > +++ b/hw/arm/virt.c
> > @@ -61,6 +61,8 @@
> >  #include "hw/arm/smmuv3.h"
> >  #include "hw/acpi/acpi.h"
> >  #include "target/arm/internals.h"
> > +#include "hw/mem/pc-dimm.h"
> > +#include "hw/mem/nvdimm.h"
> >
> >  #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \
> >  static void virt_##major##_##minor##_class_init(ObjectClass *oc, \
> > @@ -1806,6 +1808,34 @@ static const CPUArchIdList
> *virt_possible_cpu_arch_ids(MachineState *ms)
> >  return ms->possible_cpus;
> >  }
> >
> > +static void virt_memory_pre_plug(HotplugHandler *hotplug_dev,
> DeviceState *dev,
> > + Error **errp)
> > +{
> > +if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
> > +error_setg(errp, "memory cold/hot plug is not yet supported");
> > +return;
> > +}
> add comment here why it's needed.

Ok.

> 
> > +
> > +pc_dimm_pre_plug(PC_DIMM(dev), MACHINE(hotplug_dev), NULL,
> errp);
> maybe before calling this there probably should be check if acpi is enabled.
> 
> not sure if arm/virt board honors -no-acpi CLI option.

Ok. I will check this

Thanks,
Shameer
 
> > +}
> > +
> > +static void virt_memory_plug(HotplugHandler *hotplug_dev,
> > + DeviceState *dev, Error **errp)
> > +{
> > +VirtMachineState *vms = VIRT_MACHINE(hotplug_dev);
> > +
> > +pc_dimm_plug(PC_DIMM(dev), MACHINE(vms), NULL);
> > +
> > +}
> > +
> > +static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,
> > +DeviceState *dev,
> Error **errp)
> > +{
> > +if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
> > +virt_memory_pre_plug(hotplug_dev, dev, errp);
> > +}
> > +}
> > +
> >  static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev,
> >  DeviceState *dev, Error
> **errp)
> >  {
> > @@ -1817,12 +1847,23 @@ static void
> virt_machine_device_plug_cb(HotplugHandler *hotplug_dev,
> >   SYS_BUS_DEVICE(dev));
> >  }
> >  }
> > +if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
> > +virt_memory_plug(hotplug_dev, dev, errp);
> > +}
> > +}
> > +
> > +static void virt_machine_device_unplug_request_cb(HotplugHandler
> *hotplug_dev,
> > +  DeviceState *dev, Error
> **errp)
> > +{
> > +error_setg(errp, "device unplug request for unsupported device"
> > +   " type: %s", object_get_typename(OBJECT(dev)));
> >  }
> >
> >  static HotplugHandler *virt_machine_get_hotplug_handler(MachineState
> *machine,
> >
> DeviceState *dev)
> >  {
> > -if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE)) {
> > +if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE) ||
> > +   (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM))) {
> >  return HOTPLUG_HANDLER(machine);
> >  }
> >
> > @@ -1886,7 +1927,9 @@ static void virt_machine_class_init(ObjectClass
> *oc, void *data)
> >  mc->kvm_type = virt_kvm_type;
> >  assert(!mc->get_hotplug_handler);
> >  mc->get_hotplug_handler = virt_machine_get_hotplug_handler;
> > +hc->pre_plug = virt_machine_device_pre_plug_cb;
> >  hc->plug = virt_machine_device_plug_cb;
> > +hc->unplug_request = virt_machine_device_unplug_request_cb;
> >  }
> >
> >  static void 

Re: [Qemu-devel] [PATCH v3 02/40] s390x/tcg: Implement VECTOR ADD COMPUTE CARRY

2019-05-03 Thread David Hildenbrand
On 03.05.19 05:45, Richard Henderson wrote:
> On 5/2/19 7:09 AM, David Hildenbrand wrote:
>> 128-bit handling courtesy of Richard H.
>>
>> Signed-off-by: David Hildenbrand 
>> ---
>>  target/s390x/insn-data.def  |  2 +
>>  target/s390x/translate_vx.inc.c | 94 +
>>  2 files changed, 96 insertions(+)
> 
> Reviewed-by: Richard Henderson 
> 
>> +static void gen_acc(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b, uint8_t es)
>> +{
>> +const uint8_t msb_bit_nr = NUM_VEC_ELEMENT_BITS(es) - 1;
>> +TCGv_i64 msb_mask = tcg_const_i64(dup_const(es, 1ull << msb_bit_nr));
>> +TCGv_i64 t1 = tcg_temp_new_i64();
>> +TCGv_i64 t2 = tcg_temp_new_i64();
>> +TCGv_i64 t3 = tcg_temp_new_i64();
>> +
>> +/* Calculate the carry into the MSB, ignoring the old MSBs */
>> +tcg_gen_andc_i64(t1, a, msb_mask);
>> +tcg_gen_andc_i64(t2, b, msb_mask);
>> +tcg_gen_add_i64(t1, t1, t2);
>> +/* Calculate the MSB without any carry into it */
>> +tcg_gen_xor_i64(t3, a, b);
>> +/* Calculate the carry out of the MSB in the MSB bit position */
>> +tcg_gen_and_i64(d, a, b);
>> +tcg_gen_and_i64(t1, t1, t3);
>> +tcg_gen_or_i64(d, d, t1);
>> +/* Isolate and shift the carry into position */
>> +tcg_gen_and_i64(d, d, msb_mask);
>> +tcg_gen_shri_i64(d, d, msb_bit_nr);
>> +
>> +tcg_temp_free_i64(t1);
>> +tcg_temp_free_i64(t2);
>> +tcg_temp_free_i64(t3);
>> +}
> ...> +static void gen_acc32_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b)
>> +{
>> +gen_acc(d, a, b, ES_32);
>> +}
>> +
>> +static void gen_acc_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b)
>> +{
>> +TCGv_i64 t = tcg_temp_new_i64();
>> +
>> +tcg_gen_add_i64(t, a, b);
>> +tcg_gen_setcond_i64(TCG_COND_LTU, d, t, b);
>> +tcg_temp_free_i64(t);
>> +}
> 
> As an aside, I think the 32-bit version should use 32-bit ops, as per
> gen_acc_i64.  That would be 4 * 2 operations instead of 2 * 9 over the 128-bit
> vector.

Makes sense, thanks!

> 
> 
> r~
> 


-- 

Thanks,

David / dhildenb



[Qemu-devel] [PATCH v2] linux-user: elf: Map empty PT_LOAD segments

2019-05-03 Thread Giuseppe Musacchio
Some PT_LOAD segments may be completely zeroed out and their p_filesize
is zero, in that case the loader should just allocate a page that's at
least p_memsz bytes large (plus eventual alignment padding).

Calling zero_bss does this job for us, all we have to do is make sure we
don't try to mmap a zero-length page.

Signed-off-by: Giuseppe Musacchio 
Reviewed-by: Peter Maydell 
---
 linux-user/elfload.c | 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index c1a2602..138735b 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -2366,11 +2366,19 @@ static void load_elf_image(const char *image_name, int 
image_fd,
 vaddr_ps = TARGET_ELF_PAGESTART(vaddr);
 vaddr_len = TARGET_ELF_PAGELENGTH(eppnt->p_filesz + vaddr_po);
 
-error = target_mmap(vaddr_ps, vaddr_len,
-elf_prot, MAP_PRIVATE | MAP_FIXED,
-image_fd, eppnt->p_offset - vaddr_po);
-if (error == -1) {
-goto exit_perror;
+/*
+ * Some segments may be completely empty without any backing file
+ * segment, in that case just let zero_bss allocate an empty buffer
+ * for it.
+ */
+if (eppnt->p_filesz != 0) {
+error = target_mmap(vaddr_ps, vaddr_len, elf_prot,
+MAP_PRIVATE | MAP_FIXED,
+image_fd, eppnt->p_offset - vaddr_po);
+
+if (error == -1) {
+goto exit_perror;
+}
 }
 
 vaddr_ef = vaddr + eppnt->p_filesz;
-- 
2.20.1




Re: [Qemu-devel] [PATCH for-4.0?] arm: Allow system registers for KVM guests to be changed by QEMU code

2019-05-03 Thread Peter Maydell
On Mon, 25 Mar 2019 at 10:25, Peter Maydell  wrote:
>
> On Mon, 18 Mar 2019 at 15:59, Alex Bennée  wrote:
> >
> >
> > Peter Maydell  writes:
[...]
> > > Support this by making kvm_arch_put_registers() synchronize
> > > CPU state back into the list. We sync only those registers
> > > where the initial write succeeds, which should be sufficient.
> > >
> > > This commit is the same as commit 823e1b3818f9b10b824ddc which we
> > > had to revert in commit 942f99c825fc94c8b1a4, except that the bug
> > > which was preventing EDK2 guest firmware running has been fixed:
> > > kvm_arm_reset_vcpu() now calls write_list_to_cpustate().

> > > Should we try to put this in for rc1? Not sure... Testing
> > > definitely appreciated.
>
> > Hmm so running my testcase:
> >
> >  * gdbstub enabled with an active sw or hw breakpoint
> >  * run userspace program in guest:
> >- sw breakpoint works fine
> >- hw breakpoint never triggers because guest segs
>
> Further testing from Alex suggests this is some unrelated
> bug or regression (ie not caused by this patch), but:
> since the only in-tree use for this patch is to get nested
> debugging working and it would be broken for this other
> reason even with this patch, I'm going to postpone applying
> this patch until the start of the 4.1 cycle.

Since we're now in the 4.1 cycle I'm going to apply this
patch, as I suggested above -- I'm putting it into my
target-arm.next queue to go in in my next pullreq.

We should make sure we investigate the debugging-KVM
breakage Alex described at some point this cycle too.

thanks
-- PMM



Re: [Qemu-devel] [PATCH] block/rbd: implement .bdrv_get_allocated_file_size callback

2019-05-03 Thread Stefano Garzarella
On Fri, May 03, 2019 at 07:55:01AM -0400, Jason Dillaman wrote:
> On Fri, May 3, 2019 at 7:02 AM Stefano Garzarella  wrote:
> >
> > This patch allows 'qemu-img info' to show the 'disk size' for
> > rbd images. We use the rbd_diff_iterate2() API to calculate the
> > allocated size for the image.
> >
> > Signed-off-by: Stefano Garzarella 
> > ---
> >  block/rbd.c | 33 +
> >  1 file changed, 33 insertions(+)
> >
> > diff --git a/block/rbd.c b/block/rbd.c
> > index 0c549c9935..61447bc0cb 100644
> > --- a/block/rbd.c
> > +++ b/block/rbd.c
> > @@ -1046,6 +1046,38 @@ static int64_t qemu_rbd_getlength(BlockDriverState 
> > *bs)
> >  return info.size;
> >  }
> >
> > +static int rbd_allocated_size_cb(uint64_t offset, size_t len, int exists,
> > + void *arg)
> > +{
> > +int64_t *alloc_size = (int64_t *) arg;
> > +
> > +if (exists) {
> > +(*alloc_size) += len;
> > +}
> > +
> > +return 0;
> > +}
> > +
> > +static int64_t qemu_rbd_get_allocated_file_size(BlockDriverState *bs)
> > +{
> > +BDRVRBDState *s = bs->opaque;
> > +int64_t alloc_size = 0;
> > +int r;
> > +
> > +/*
> > + * rbd_diff_iterate2(), if the source snapshot name is NULL, invokes
> > + * the callback on all allocated regions of the image.
> > + */
> > +r = rbd_diff_iterate2(s->image, NULL, 0,
> > +  bs->total_sectors * BDRV_SECTOR_SIZE, 0, 1,
> > +  _allocated_size_cb, _size);
> 
> Is there any concern that running this on very large images will take
> a very long time since it needs to iterate through each individual
> 4MiB (by default) backing object in the image? In libvirt, it only
> attempts to calculate the actual usage if the fast-diff feature is
> enabled, and recently it also got a new control to optionally disable
> the functionality entirely since even with fast-diff it's can be very
> slow to compute over hundreds of images in a libvirt storage pool.
> 

Thank you for pointing that out to me. I'll add check on fast-diff feature
on v2.
Since we only have one image here, do you think it would be reasonable to add
this feature or is it useless?

Thanks,
Stefano



Re: [Qemu-devel] Request for comment - dynamic VNC keyboard mapping

2019-05-03 Thread Daniel P . Berrangé
On Fri, May 03, 2019 at 01:47:15PM +0200, Mario wrote:
> Hi all,
> 
> I have a question related to the VNC server keyboard settings. Currently
> the user of qemu has to decide before VM startup which language is used
> for VNC keyboard mapping. If no keyboard is configured, the en-us keyboard
> will be loaded for keysym to scancode conversion. A later reconfiguration
> of the keyboard is not possible at present.

That isn't actually correct. In fact best practice is to *not* set and
"-k keymap" arg when launching QEMU.

Any kind of keysym to scancode conversion done by QEMU is inherantly
lossy and fragile as it requires a 100% matching keymap between QEMU
and the guest OS. QEMU keymaps are much better than the past, but
they're never going to be guaranteed to match what the guest OS is
using because they're potentialy using completely different data
sources.

By not setting "-k", you let the QEMU VNC server activate its keyboard
scancode VNC protocol extension. With this active, a compatible VNC
client will then send raw hardware scancodes to QEMU alongside keysyms.

QEMU will thus ignore the keysyms and send the scancodes straight to
the guest with no keymap conversion performed at all. 

With this working you can just dynamically change your guest OS keymap
as needed to match your VNC client machine's keyboard and QEMU stays
out of the way entirely. 

Obviously the important thing here is to have a VNC client that supports
this scancode extension. This was originally done in the GTK-VNC widget,
and thus virt-viewer, remote-viewer, vinagre, virt-manager, GNOME Boxes
all support this.  More recently the TigerVNC client app also supports
this, as does the in browser noVNC client.

> So here is my idea:
> 
> The VNC Display context stores a list of loaded keyboards (like
> vs->vd->kbds). If no keyboard was specified, at least the default
> will be added to the list ("en-us"?). If a client connects, a copy
> of the (latest configured) pointer will be stored within the
> VncState structure. For any keys sent by this client the own
> keyboard reference will be used.
> 
> As (in theory) every VNC client may have a differen keyboard layout,
> in my point of view it makes sense to attach the keyboard used for
> keysym2scancode() to the client context rather to the VNC server
> context. However as (most likely) all clients do have the same
> keyboard mapping it would be an overhead to parse and store the
> mapping list each time the client connects.
> 
> Now in my idea two mechanisms may change the behavior of the client
> keyboard.
> 
> 1.) a qmp command was sent, that sets /configures for a particular/
> default keyboard.
> 2.) within the VNC protocol a "VNC_MSG_CLIENT_QEMU/
> VNC_MSG_CLIENT_QEMU_EXT_KEYBOARD_LAYOUT" message arrives
> 
> If the new keyboard was not already loaded and stored inside
> vs->vd->kbds , qemu initializes the new mapping. The affected VNC
> client (VncState) again stores the reference only.
> 
> This enables switching the keyboard layout during runtime as well
> as using multiple different keyboard layouts at atime.
> 
> Together with a corresponding patch I would also add a patch for
> libvncclient to have a reference implmentation for the integrated
> keyboard layout switching.
> 
> What are your thoughts about this kind of improvement?

I don't think it is worth creating a new VNC protocol extension for this,
since any kind of keymap conversion done on the server is inherantly
lossy so can never be bug free. Since a new extension requires modifying
VNC clients regardless, it is better to just modify them to support the
raw scancode extension instead.

Regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|



[Qemu-devel] [PATCH v2] target/arm: Stop using variable length array in dc_zva

2019-05-03 Thread Peter Maydell
Currently the dc_zva helper function uses a variable length
array. In fact we know (as the comment above remarks) that
the length of this array is bounded because the architecture
limits the block size and QEMU limits the target page size.
Use a fixed array size and assert that we don't run off it.

Signed-off-by: Peter Maydell 
---
Changes v1->v2:
 * use ARRAY_SIZE() instead of sizeof()
 * add a comment to make it a bit clearer that the
   expected size of hostaddr[] is only 2 entries
---
 target/arm/helper.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/target/arm/helper.c b/target/arm/helper.c
index 81a92ab4911..10444d12b18 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -1,4 +1,5 @@
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "target/arm/idau.h"
 #include "trace.h"
 #include "cpu.h"
@@ -13099,14 +13100,17 @@ void HELPER(dc_zva)(CPUARMState *env, uint64_t 
vaddr_in)
  * We know that in fact for any v8 CPU the page size is at least 4K
  * and the block size must be 2K or less, but TARGET_PAGE_SIZE is only
  * 1K as an artefact of legacy v5 subpage support being present in the
- * same QEMU executable.
+ * same QEMU executable. So in practice the hostaddr[] array has
+ * two entries, given the current setting of TARGET_PAGE_BITS_MIN.
  */
 int maxidx = DIV_ROUND_UP(blocklen, TARGET_PAGE_SIZE);
-void *hostaddr[maxidx];
+void *hostaddr[DIV_ROUND_UP(2 * KiB, 1 << TARGET_PAGE_BITS_MIN)];
 int try, i;
 unsigned mmu_idx = cpu_mmu_index(env, false);
 TCGMemOpIdx oi = make_memop_idx(MO_UB, mmu_idx);
 
+assert(maxidx <= ARRAY_SIZE(hostaddr));
+
 for (try = 0; try < 2; try++) {
 
 for (i = 0; i < maxidx; i++) {
-- 
2.20.1




Re: [Qemu-devel] [PATCH] block/rbd: implement .bdrv_get_allocated_file_size callback

2019-05-03 Thread Jason Dillaman
On Fri, May 3, 2019 at 7:02 AM Stefano Garzarella  wrote:
>
> This patch allows 'qemu-img info' to show the 'disk size' for
> rbd images. We use the rbd_diff_iterate2() API to calculate the
> allocated size for the image.
>
> Signed-off-by: Stefano Garzarella 
> ---
>  block/rbd.c | 33 +
>  1 file changed, 33 insertions(+)
>
> diff --git a/block/rbd.c b/block/rbd.c
> index 0c549c9935..61447bc0cb 100644
> --- a/block/rbd.c
> +++ b/block/rbd.c
> @@ -1046,6 +1046,38 @@ static int64_t qemu_rbd_getlength(BlockDriverState *bs)
>  return info.size;
>  }
>
> +static int rbd_allocated_size_cb(uint64_t offset, size_t len, int exists,
> + void *arg)
> +{
> +int64_t *alloc_size = (int64_t *) arg;
> +
> +if (exists) {
> +(*alloc_size) += len;
> +}
> +
> +return 0;
> +}
> +
> +static int64_t qemu_rbd_get_allocated_file_size(BlockDriverState *bs)
> +{
> +BDRVRBDState *s = bs->opaque;
> +int64_t alloc_size = 0;
> +int r;
> +
> +/*
> + * rbd_diff_iterate2(), if the source snapshot name is NULL, invokes
> + * the callback on all allocated regions of the image.
> + */
> +r = rbd_diff_iterate2(s->image, NULL, 0,
> +  bs->total_sectors * BDRV_SECTOR_SIZE, 0, 1,
> +  _allocated_size_cb, _size);

Is there any concern that running this on very large images will take
a very long time since it needs to iterate through each individual
4MiB (by default) backing object in the image? In libvirt, it only
attempts to calculate the actual usage if the fast-diff feature is
enabled, and recently it also got a new control to optionally disable
the functionality entirely since even with fast-diff it's can be very
slow to compute over hundreds of images in a libvirt storage pool.

> +if (r < 0) {
> +return r;
> +}
> +
> +return alloc_size;
> +}
> +
>  static int coroutine_fn qemu_rbd_co_truncate(BlockDriverState *bs,
>   int64_t offset,
>   PreallocMode prealloc,
> @@ -1254,6 +1286,7 @@ static BlockDriver bdrv_rbd = {
>  .bdrv_get_info  = qemu_rbd_getinfo,
>  .create_opts= _rbd_create_opts,
>  .bdrv_getlength = qemu_rbd_getlength,
> +.bdrv_get_allocated_file_size = qemu_rbd_get_allocated_file_size,
>  .bdrv_co_truncate   = qemu_rbd_co_truncate,
>  .protocol_name  = "rbd",
>
> --
> 2.20.1
>


-- 
Jason



Re: [Qemu-devel] [PATCH] linux-user: elf: Map empty PT_LOAD sections

2019-05-03 Thread Peter Maydell
On Thu, 18 Apr 2019 at 17:46, Giuseppe Musacchio  wrote:
>
> Some PT_LOAD sections may be completely zeroed out and their p_filesize
> is zero, in that case the loader should just allocate a page that's at
> least p_memsz bytes large (plus eventual alignment padding).

Thanks for this patch -- codewise it looks good, so I just have
a couple of minor tweaks I think we should make to the comment
and commit message:

The things we're iterating through here are segments, not
sections (an ELF section is a different sort of data structure):
could you fix the text in your commit message and comment, please?

> Calling zero_bss does this job for us, all we have to do is make sure we
> don't try to mmap a zero-length page.
>
> Signed-off-by: Giuseppe Musacchio 
> ---
>  linux-user/elfload.c | 16 +++-
>  1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/linux-user/elfload.c b/linux-user/elfload.c
> index c1a2602..e9a0951 100644
> --- a/linux-user/elfload.c
> +++ b/linux-user/elfload.c
> @@ -2366,11 +2366,17 @@ static void load_elf_image(const char *image_name, 
> int image_fd,
>  vaddr_ps = TARGET_ELF_PAGESTART(vaddr);
>  vaddr_len = TARGET_ELF_PAGELENGTH(eppnt->p_filesz + vaddr_po);
>
> -error = target_mmap(vaddr_ps, vaddr_len,
> -elf_prot, MAP_PRIVATE | MAP_FIXED,
> -image_fd, eppnt->p_offset - vaddr_po);
> -if (error == -1) {
> -goto exit_perror;
> +/* Some sections may be completely empty without any backing file
> + * segment, in that case just let zero_bss allocate an empty 
> buffer
> + * for it. */

Our coding style says that multi-line comments should be
 /*
  * like this, with the start and
  * end markers on lines of their own
  */

(if you run your patch through scripts/checkpatch.pl it ought
to detect this sort of minor coding style nit).

> +if (eppnt->p_filesz != 0) {
> +error = target_mmap(vaddr_ps, vaddr_len, elf_prot,
> +MAP_PRIVATE | MAP_FIXED,
> +image_fd, eppnt->p_offset - vaddr_po);
> +
> +if (error == -1) {
> +goto exit_perror;
> +}
>  }
>
>  vaddr_ef = vaddr + eppnt->p_filesz;

Other than those minor things:
Reviewed-by: Peter Maydell 

so if you fix them and send out a v2 patch you can include
my Reviewed-by: tag in the commit message (under your
signed-off-by) in that patch email.

thanks
-- PMM



[Qemu-devel] Request for comment - dynamic VNC keyboard mapping

2019-05-03 Thread Mario
Hi all,

I have a question related to the VNC server keyboard settings. Currently the 
user of qemu has to decide before VM startup which language is used for VNC 
keyboard mapping. If no keyboard is configured, the en-us keyboard will be 
loaded for keysym to scancode conversion. A later reconfiguration of the 
keyboard is not possible at present.

So here is my idea:

The VNC Display context stores a list of loaded keyboards (like vs->vd->kbds). 
If no keyboard was specified, at least the default will be added to the list 
("en-us"?). If a client connects, a copy of the (latest configured) pointer 
will be stored within the VncState structure. For any keys sent by this client 
the own keyboard reference will be used.

As (in theory) every VNC client may have a differen keyboard layout, in my 
point of view it makes sense to attach the keyboard used for keysym2scancode() 
to the client context rather to the VNC server context. However as (most 
likely) all clients do have the same keyboard mapping it would be an overhead 
to parse and store the mapping list each time the client connects.

Now in my idea two mechanisms may change the behavior of the client keyboard.

1.) a qmp command was sent, that sets /configures for a particular/default 
keyboard.
2.) within the VNC protocol a 
"VNC_MSG_CLIENT_QEMU/VNC_MSG_CLIENT_QEMU_EXT_KEYBOARD_LAYOUT" message arrives

If the new keyboard was not already loaded and stored inside vs->vd->kbds , 
qemu initializes the new mapping. The affected VNC client (VncState) again 
stores the reference only.

This enables switching the keyboard layout during runtime as well as using 
multiple different keyboard layouts at atime.

Together with a corresponding patch I would also add a patch for libvncclient 
to have a reference implmentation for the integrated keyboard layout switching.

What are your thoughts about this kind of improvement?

Thanks,
Mario


Re: [Qemu-devel] [PATCH v2] vmdk: Set vmdk parent backing_format to vmdk

2019-05-03 Thread Thomas Huth
 Hi Sam,

On 02/05/2019 15.08, Sam Eiderman wrote:
> Commit b69864e ("vmdk: Support version=3 in VMDK descriptor files")
> fixed the probe function to correctly guess vmdk descriptors with
> version=3.
> 
> This solves the issue where vmdk snapshot with parent vmdk descriptor
> containing "version=3" would be treated as raw instead vmdk.
> 
> In the future case where a new vmdk version is introduced, we will again
> experience this issue, even if the user will provide "-f vmdk" it will
> only apply to the tip image and not to the underlying "misprobed" parent
> image.
> 
> The code in vmdk.c already assumes that the backing file of vmdk must be
> vmdk (see vmdk_is_cid_valid which returns 0 if backing file is not
> vmdk).
> 
> So let's make it official by supplying the backing_format as vmdk.
> 
> Reviewed-by: Mark Kanda 
> Reviewed-By: Liran Alon 
> Reviewed-by: Arbel Moshe 
> Signed-off-by: Shmuel Eiderman 
> ---
>  block/vmdk.c   | 2 ++
>  tests/qemu-iotests/110 | 6 +++---
>  tests/qemu-iotests/126 | 4 ++--
>  3 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/block/vmdk.c b/block/vmdk.c
> index 8dec6ef767..de8cb859f8 100644
> --- a/block/vmdk.c
> +++ b/block/vmdk.c
> @@ -397,6 +397,8 @@ static int vmdk_parent_open(BlockDriverState *bs)
>  pstrcpy(bs->auto_backing_file, end_name - p_name + 1, p_name);
>  pstrcpy(bs->backing_file, sizeof(bs->backing_file),
>  bs->auto_backing_file);
> +pstrcpy(bs->backing_format, sizeof(bs->backing_format),
> +"vmdk");
>  }

Your patch with this change has already been merged into the QEMU master
branch...

> diff --git a/tests/qemu-iotests/110 b/tests/qemu-iotests/110
> index fad672c1ae..982569dbc5 100755
> --- a/tests/qemu-iotests/110
> +++ b/tests/qemu-iotests/110
> @@ -54,7 +54,7 @@ _make_test_img -b "$TEST_IMG_REL.base" 64M
>  # qemu should be able to reconstruct the filename, so relative backing names
>  # should work
>  
> TEST_IMG="json:{'driver':'$IMGFMT','file':{'driver':'file','filename':'$TEST_IMG'}}"
>  \
> -_img_info | _filter_img_info
> +_img_info | _filter_img_info | grep -v "backing file format"
>  
>  echo
>  echo '=== Non-reconstructable filename ==='
> @@ -78,7 +78,7 @@ TEST_IMG="json:{
>  }
>  ]
>  }
> -}" _img_info | _filter_img_info
> +}" _img_info | _filter_img_info | grep -v "backing file format"
>  
>  echo
>  echo '=== Backing name is always relative to the backed image ==='
> @@ -110,7 +110,7 @@ TEST_IMG="json:{
>  }
>  ]
>  }
> -}" _img_info | _filter_img_info
> +}" _img_info | _filter_img_info | grep -v "backing file format"
>  
>  
>  # success, all done
> diff --git a/tests/qemu-iotests/126 b/tests/qemu-iotests/126
> index 96dc048d59..1f7618c8a5 100755
> --- a/tests/qemu-iotests/126
> +++ b/tests/qemu-iotests/126
> @@ -63,7 +63,7 @@ TEST_IMG=$BASE_IMG _make_test_img 64M
>  TEST_IMG=$TOP_IMG _make_test_img -b ./image:base.$IMGFMT
>  
>  # The default cluster size depends on the image format
> -TEST_IMG=$TOP_IMG _img_info | grep -v 'cluster_size'
> +TEST_IMG=$TOP_IMG _img_info | grep -v 'cluster_size\|backing file format'
>  
>  _rm_test_img "$BASE_IMG"
>  _rm_test_img "$TOP_IMG"
> @@ -79,7 +79,7 @@ TOP_IMG="file:image:top.$IMGFMT"
>  TEST_IMG=$BASE_IMG _make_test_img 64M
>  TEST_IMG=$TOP_IMG _make_test_img -b "$BASE_IMG"
>  
> -TEST_IMG=$TOP_IMG _img_info | grep -v 'cluster_size'
> +TEST_IMG=$TOP_IMG _img_info | grep -v 'cluster_size\|backing file format'
>  
>  _rm_test_img "$BASE_IMG"
>  _rm_test_img "image:top.$IMGFMT"
> 

... so please just send a patch with these fixes!

 Thanks,
  Thomas



[Qemu-devel] [PULL v2 09/12] net: Print output of "-net nic, model=help" to stdout instead of stderr

2019-05-03 Thread Laurent Vivier
From: Thomas Huth 

We are printing all other help output to stdout already (e.g. "-help",
"-cpu help" and "-machine help" output). So the "-net nic,model=help"
output should go to stdout instead of stderr, too. And while we're at
it, also print the NICs line by line, like we do it e.g. with the
"-cpu help" or "-M help" output, too.

Buglink: https://bugs.launchpad.net/qemu/+bug/1574327
Signed-off-by: Thomas Huth 
Reviewed-by: Eric Blake 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20190423160608.7519-1-th...@redhat.com>
Signed-off-by: Laurent Vivier 
---
 net/net.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/net.c b/net/net.c
index f3a3c5444cc3..2cf5e7646997 100644
--- a/net/net.c
+++ b/net/net.c
@@ -837,9 +837,10 @@ int qemu_show_nic_models(const char *arg, const char 
*const *models)
 return 0;
 }
 
-fprintf(stderr, "qemu: Supported NIC models: ");
-for (i = 0 ; models[i]; i++)
-fprintf(stderr, "%s%c", models[i], models[i+1] ? ',' : '\n');
+printf("Supported NIC models:\n");
+for (i = 0 ; models[i]; i++) {
+printf("%s\n", models[i]);
+}
 return 1;
 }
 
-- 
2.20.1




[Qemu-devel] [PULL v2 10/12] Makefile: Let the 'clean' rule remove qemu-ga.exe on Windows hosts

2019-05-03 Thread Laurent Vivier
From: Philippe Mathieu-Daudé 

Commit 48ff7a625b36 added the QEMU Guest Agent tool with the
optional ".exe" suffix for Windows hosts, but forgot to use
this suffix in the 'clean' rule. Calling this rule let a dangling
executable in the build directory.
Correct this by using the proper optional suffix.

Fixes: 48ff7a625b36
Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Stefan Weil 
Message-Id: <20190427161322.24642-1-phi...@redhat.com>
Signed-off-by: Laurent Vivier 
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 43a7a047b452..e223bfe2a3a1 100644
--- a/Makefile
+++ b/Makefile
@@ -639,7 +639,7 @@ clean:
! -path ./roms/edk2/BaseTools/Source/Python/UPT/Dll/sqlite3.dll 
\
-exec rm {} +
rm -f $(edk2-decompressed)
-   rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) qemu-ga TAGS cscope.* 
*.pod *~ */*~
+   rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) qemu-ga$(EXESUF) TAGS 
cscope.* *.pod *~ */*~
rm -f fsdev/*.pod scsi/*.pod
rm -f qemu-img-cmds.h
rm -f ui/shader/*-vert.h ui/shader/*-frag.h
-- 
2.20.1




Re: [Qemu-devel] [Qemu-trivial] [PATCH v3] hw/char/escc: Lower irq when transmit buffer is filled

2019-05-03 Thread Mark Cave-Ayland
On 03/05/2019 08:21, Laurent Vivier wrote:

>>> Mark, Artyom, are you OK with this patch?
>>
>> I started testing this with my OpenBIOS test images at the start of the 
>> week, but
>> unfortunately got distracted by real life :)
>>
>> I've now finished and confirmed there are no regressions in my local tests, 
>> so I'll
>> include this in the PR I am planning to send shortly containing the leon3 
>> updates.
> 
> Hi Mark,
> 
> I've already included a leon3 patch ("hw/sparc/leon3: Allow load of
> uImage firmwares") in the PR I sent yesterday for the trivial branch.
> I've removed from my PR this patch about the ESCC, so you can take it.

Hi Laurent,

Understood, and thanks for looking out for the patch. My first week back has 
been
quite busy so I'm still playing catch-up here...


ATB,

Mark.



[Qemu-devel] [PULL v2 05/12] qom: use object_new_with_type in object_new_with_propv

2019-05-03 Thread Laurent Vivier
From: Wei Yang 

Function object_new_with_propv already get the Type of the object, so we
could leverage object_new_with_type here.

Signed-off-by: Wei Yang 
Reviewed-by: Marc-André Lureau 
Reviewed-by: Stefano Garzarella 
Message-Id: <20190311083234.20841-1-richardw.y...@linux.intel.com>
Signed-off-by: Laurent Vivier 
---
 qom/object.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qom/object.c b/qom/object.c
index e3206d6799ee..d3412e7fdca6 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -679,7 +679,7 @@ Object *object_new_with_propv(const char *typename,
 error_setg(errp, "object type '%s' is abstract", typename);
 return NULL;
 }
-obj = object_new(typename);
+obj = object_new_with_type(klass->type);
 
 if (object_set_propv(obj, _err, vargs) < 0) {
 goto error;
-- 
2.20.1




[Qemu-devel] [PULL v2 05/12] qom: use object_new_with_type in object_new_with_propv

2019-05-03 Thread Laurent Vivier
From: Wei Yang 

Function object_new_with_propv already get the Type of the object, so we
could leverage object_new_with_type here.

Signed-off-by: Wei Yang 
Reviewed-by: Marc-André Lureau 
Reviewed-by: Stefano Garzarella 
Message-Id: <20190311083234.20841-1-richardw.y...@linux.intel.com>
Signed-off-by: Laurent Vivier 
---
 qom/object.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qom/object.c b/qom/object.c
index e3206d6799ee..d3412e7fdca6 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -679,7 +679,7 @@ Object *object_new_with_propv(const char *typename,
 error_setg(errp, "object type '%s' is abstract", typename);
 return NULL;
 }
-obj = object_new(typename);
+obj = object_new_with_type(klass->type);
 
 if (object_set_propv(obj, _err, vargs) < 0) {
 goto error;
-- 
2.20.1




[Qemu-devel] [PULL v2 12/12] sockets: avoid string truncation warnings when copying UNIX path

2019-05-03 Thread Laurent Vivier
From: Daniel P. Berrangé 

In file included from /usr/include/string.h:494,
 from include/qemu/osdep.h:101,
 from util/qemu-sockets.c:18:
In function ‘strncpy’,
inlined from ‘unix_connect_saddr.isra.0’ at util/qemu-sockets.c:925:5:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ 
specified bound 108 equals destination size [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
  |  ^~
In function ‘strncpy’,
inlined from ‘unix_listen_saddr.isra.0’ at util/qemu-sockets.c:880:5:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ 
specified bound 108 equals destination size [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
  |  ^~

We are already validating the UNIX socket path length earlier in
the functions. If we save this string length when we first check
it, then we can simply use memcpy instead of strcpy later, avoiding
the gcc truncation warnings.

Signed-off-by: Daniel P. Berrangé 
Reviewed-by: Eric Blake 
Reviewed-by: Stefano Garzarella 
Message-Id: <20190501145052.12579-1-berra...@redhat.com>
Signed-off-by: Laurent Vivier 
---
 util/qemu-sockets.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 970505169000..ba6335e71a95 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -830,6 +830,7 @@ static int unix_listen_saddr(UnixSocketAddress *saddr,
 int sock, fd;
 char *pathbuf = NULL;
 const char *path;
+size_t pathlen;
 
 sock = qemu_socket(PF_UNIX, SOCK_STREAM, 0);
 if (sock < 0) {
@@ -845,7 +846,8 @@ static int unix_listen_saddr(UnixSocketAddress *saddr,
 path = pathbuf = g_strdup_printf("%s/qemu-socket-XX", tmpdir);
 }
 
-if (strlen(path) > sizeof(un.sun_path)) {
+pathlen = strlen(path);
+if (pathlen > sizeof(un.sun_path)) {
 error_setg(errp, "UNIX socket path '%s' is too long", path);
 error_append_hint(errp, "Path must be less than %zu bytes\n",
   sizeof(un.sun_path));
@@ -877,7 +879,7 @@ static int unix_listen_saddr(UnixSocketAddress *saddr,
 
 memset(, 0, sizeof(un));
 un.sun_family = AF_UNIX;
-strncpy(un.sun_path, path, sizeof(un.sun_path));
+memcpy(un.sun_path, path, pathlen);
 
 if (bind(sock, (struct sockaddr*) , sizeof(un)) < 0) {
 error_setg_errno(errp, errno, "Failed to bind socket to %s", path);
@@ -901,6 +903,7 @@ static int unix_connect_saddr(UnixSocketAddress *saddr, 
Error **errp)
 {
 struct sockaddr_un un;
 int sock, rc;
+size_t pathlen;
 
 if (saddr->path == NULL) {
 error_setg(errp, "unix connect: no path specified");
@@ -913,7 +916,8 @@ static int unix_connect_saddr(UnixSocketAddress *saddr, 
Error **errp)
 return -1;
 }
 
-if (strlen(saddr->path) > sizeof(un.sun_path)) {
+pathlen = strlen(saddr->path);
+if (pathlen > sizeof(un.sun_path)) {
 error_setg(errp, "UNIX socket path '%s' is too long", saddr->path);
 error_append_hint(errp, "Path must be less than %zu bytes\n",
   sizeof(un.sun_path));
@@ -922,7 +926,7 @@ static int unix_connect_saddr(UnixSocketAddress *saddr, 
Error **errp)
 
 memset(, 0, sizeof(un));
 un.sun_family = AF_UNIX;
-strncpy(un.sun_path, saddr->path, sizeof(un.sun_path));
+memcpy(un.sun_path, saddr->path, pathlen);
 
 /* connect to peer */
 do {
-- 
2.20.1




[Qemu-devel] [PULL v2 11/12] hw/sparc/leon3: Allow load of uImage firmwares

2019-05-03 Thread Laurent Vivier
From: Philippe Mathieu-Daudé 

Currently the Leon3 machine doesn't allow to load legacy u-boot images:

  $ qemu-system-sparc -M leon3_generic -d in_asm \
  -kernel HelenOS-0.6.0-sparc32-leon3.bin
  qemu-system-sparc: could not load kernel 'HelenOS-0.6.0-sparc32-leon3.bin'

  $ file HelenOS-0.6.0-sparc32-leon3.bin
  HelenOS-0.6.0-sparc32-leon3.bin: u-boot legacy uImage, HelenOS-0.6.0,\
Linux/ARM, OS Kernel Image (Not compressed), 2424229 bytes,\
Sun Dec 21 19:18:09 2014,\
Load Address: 0x4000, Entry Point: 0x4000,\
Header CRC: 0x8BCFA236, Data CRC: 0x37AD87DF

Since QEMU can load uImages, add the necessary code,
so the Leon3 machine can load these images:

  $ qemu-system-sparc -M leon3_generic -d in_asm \
  -kernel HelenOS-0.6.0-sparc32-leon3.bin
  
  IN:
  0x4000:  b  0x47a8
  0x4004:  nop
  
  IN:
  0x47a8:  save  %sp, -136, %sp
  0x47ac:  call  0x4020
  0x47b0:  sethi  %hi(0x4000b800), %i1
  ...

Tested with the following firmware:
http://www.helenos.org/releases/HelenOS-0.6.0-sparc32-leon3.bin

Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: KONRAD Frederic 
Tested-by: KONRAD Frederic 
Message-Id: <20190427162922.4207-1-f4...@amsat.org>
Signed-off-by: Laurent Vivier 
---
 hw/sparc/leon3.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c
index 774639af3393..0383b17c298f 100644
--- a/hw/sparc/leon3.c
+++ b/hw/sparc/leon3.c
@@ -193,6 +193,10 @@ static void leon3_generic_hw_init(MachineState *machine)
 kernel_size = load_elf(kernel_filename, NULL, NULL, NULL,
, NULL, NULL,
1 /* big endian */, EM_SPARC, 0, 0);
+if (kernel_size < 0) {
+kernel_size = load_uimage(kernel_filename, NULL, ,
+  NULL, NULL, NULL);
+}
 if (kernel_size < 0) {
 error_report("could not load kernel '%s'", kernel_filename);
 exit(1);
-- 
2.20.1




[Qemu-devel] [PULL v2 04/12] doc: fix the configuration path

2019-05-03 Thread Laurent Vivier
From: Marc-André Lureau 

Use a CONFDIR variable to show the configured sysconf path in the
generated documentations (html, man pages etc).

Related to:
https://bugzilla.redhat.com/show_bug.cgi?id=1644985

Signed-off-by: Marc-André Lureau 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20181126105125.30973-1-marcandre.lur...@redhat.com>
Signed-off-by: Laurent Vivier 
---
 qemu-ga.texi | 4 ++--
 Makefile | 9 ++---
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/qemu-ga.texi b/qemu-ga.texi
index 4c7a8fd16329..f00ad830f283 100644
--- a/qemu-ga.texi
+++ b/qemu-ga.texi
@@ -30,7 +30,7 @@ set user's password
 @end itemize
 
 qemu-ga will read a system configuration file on startup (located at
-@file{/etc/qemu/qemu-ga.conf} by default), then parse remaining
+@file{@value{CONFDIR}/qemu-ga.conf} by default), then parse remaining
 configuration options on the command line. For the same key, the last
 option wins, but the lists accumulate (see below for configuration
 file format).
@@ -58,7 +58,7 @@ file format).
   Enable fsfreeze hook. Accepts an optional argument that specifies
   script to run on freeze/thaw. Script will be called with
   'freeze'/'thaw' arguments accordingly (default is
-  @samp{/etc/qemu/fsfreeze-hook}). If using -F with an argument, do
+  @samp{@value{CONFDIR}/fsfreeze-hook}). If using -F with an argument, do
   not follow -F with a space (for example:
   @samp{-F/var/run/fsfreezehook.sh}).
 
diff --git a/Makefile b/Makefile
index 1211e78c91ed..43a7a047b452 100644
--- a/Makefile
+++ b/Makefile
@@ -899,11 +899,14 @@ ui/shader.o: $(SRC_PATH)/ui/shader.c \
 MAKEINFO=makeinfo
 MAKEINFOINCLUDES= -I docs -I $( $@,"GEN","$@")
+docs/version.texi: $(SRC_PATH)/VERSION config-host.mak
+   $(call quiet-command,(\
+   echo "@set VERSION $(VERSION)" && \
+   echo "@set CONFDIR $(qemu_confdir)" \
+   )> $@,"GEN","$@")
 
 %.html: %.texi docs/version.texi
$(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers 
\
-- 
2.20.1




[Qemu-devel] [PULL v2 02/12] CODING_STYLE: specify the indent rule for multiline code

2019-05-03 Thread Laurent Vivier
From: Wei Yang 

We didn't specify the indent rule for multiline code here, which may
mislead users. And in current code, the code use various styles.

Add this rule in CODING_STYLE to make sure this is clear to every one.

Signed-off-by: Wei Yang 
Suggested-by: Igor Mammedov 
Reviewed-by: Igor Mammedov 
Reviewed-by: Stefano Garzarella 
Message-Id: <20190304071631.27567-2-richardw.y...@linux.intel.com>
Signed-off-by: Laurent Vivier 
---
 CODING_STYLE | 39 +++
 1 file changed, 39 insertions(+)

diff --git a/CODING_STYLE b/CODING_STYLE
index ec075dedc4a8..90321e9c2821 100644
--- a/CODING_STYLE
+++ b/CODING_STYLE
@@ -29,6 +29,45 @@ Spaces of course are superior to tabs because:
 
 Do not leave whitespace dangling off the ends of lines.
 
+1.1 Multiline Indent
+
+There are several places where indent is necessary:
+
+ - if/else
+ - while/for
+ - function definition & call
+
+When breaking up a long line to fit within line width, we need a proper indent
+for the following lines.
+
+In case of if/else, while/for, align the secondary lines just after the
+opening parenthesis of the first.
+
+For example:
+
+if (a == 1 &&
+b == 2) {
+
+while (a == 1 &&
+   b == 2) {
+
+In case of function, there are several variants:
+
+* 4 spaces indent from the beginning
+* align the secondary lines just after the opening parenthesis of the
+  first
+
+For example:
+
+do_something(x, y,
+z);
+
+do_something(x, y,
+ z);
+
+do_something(x, do_another(y,
+   z));
+
 2. Line width
 
 Lines should be 80 characters; try not to make them longer.
-- 
2.20.1




[Qemu-devel] [PULL v2 01/12] hw/net/pcnet: Use qemu_log_mask(GUEST_ERROR) instead of printf

2019-05-03 Thread Laurent Vivier
From: Philippe Mathieu-Daudé 

Avoid to clutter stdout until explicitly requested
(with -d guest_errors):

  $ qemu-system-mips -M malta -m 512 -kernel vmlinux-3.2.0-4-4kc-malta
  Bad SWSTYLE=0x04

Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Thomas Huth 
Message-Id: <20190311102712.8572-1-phi...@redhat.com>
Signed-off-by: Laurent Vivier 
---
 hw/net/pcnet.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/hw/net/pcnet.c b/hw/net/pcnet.c
index d9ba04bdfc62..16683091c939 100644
--- a/hw/net/pcnet.c
+++ b/hw/net/pcnet.c
@@ -36,6 +36,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/log.h"
 #include "hw/qdev.h"
 #include "net/net.h"
 #include "net/eth.h"
@@ -1501,7 +1502,8 @@ static void pcnet_bcr_writew(PCNetState *s, uint32_t rap, 
uint32_t val)
 val |= 0x0300;
 break;
 default:
-printf("Bad SWSTYLE=0x%02x\n", val & 0xff);
+qemu_log_mask(LOG_GUEST_ERROR, "pcnet: Bad SWSTYLE=0x%02x\n",
+  val & 0xff);
 val = 0x0200;
 break;
 }
-- 
2.20.1




Re: [Qemu-devel] [PULL v2 00/12] Trivial branch patches

2019-05-03 Thread Laurent Vivier
On 03/05/2019 13:19, Laurent Vivier wrote:
> The following changes since commit 8482ff2eb3bb95020eb2f370a9b3ea26511e41df:
> 
>   Merge remote-tracking branch 'remotes/jnsnow/tags/bitmaps-pull-request' 
> into staging (2019-05-02 12:04:51 +0100)
> 
> are available in the Git repository at:
> 
>   git://github.com/vivier/qemu.git tags/trivial-branch-pull-request
> 
> for you to fetch changes up to 2d2023c3b99edb33ad4bb9791f70456ea1a1c049:
> 
>   sockets: avoid string truncation warnings when copying UNIX path 
> (2019-05-03 13:03:04 +0200)
> 
> 
> Pull request trivial branch 2019-05-03
> 
> 
> 
> Aruna Jayasena (1):
>   Header cleanups
> 
> Daniel P. Berrangé (1):
>   sockets: avoid string truncation warnings when copying UNIX path
> 
> Dr. David Alan Gilbert (1):
>   configure: fix pam test warning
> 
> Marc-André Lureau (1):
>   doc: fix the configuration path
> 
> Philippe Mathieu-Daudé (3):
>   hw/net/pcnet: Use qemu_log_mask(GUEST_ERROR) instead of printf
>   Makefile: Let the 'clean' rule remove qemu-ga.exe on Windows hosts
>   hw/sparc/leon3: Allow load of uImage firmwares
> 
> Stefan Weil (1):
>   Update configure
> 
> Thomas Huth (1):
>   net: Print output of "-net nic, model=help" to stdout instead of
> stderr
> 
> Wei Yang (3):
>   CODING_STYLE: specify the indent rule for multiline code
>   CODING_STYLE: indent example code as all others
>   qom: use object_new_with_type in object_new_with_propv
> 
>  qemu-ga.texi  |  4 ++--
>  configure |  5 ++---
>  Makefile  | 11 +
>  include/exec/cpu-common.h |  3 ---
>  hw/net/pcnet.c|  4 +++-
>  hw/sparc/leon3.c  |  4 
>  net/net.c |  7 +++---
>  qom/object.c  |  2 +-
>  util/qemu-sockets.c   | 12 ++
>  CODING_STYLE  | 47 +++
>  10 files changed, 74 insertions(+), 25 deletions(-)
> 


Forget this series, the send has been aborted for an unknown reason.

Thanks,
Laurent




[Qemu-devel] [PULL v2 00/12] Trivial branch patches

2019-05-03 Thread Laurent Vivier
The following changes since commit 8482ff2eb3bb95020eb2f370a9b3ea26511e41df:

  Merge remote-tracking branch 'remotes/jnsnow/tags/bitmaps-pull-request' into 
staging (2019-05-02 12:04:51 +0100)

are available in the Git repository at:

  git://github.com/vivier/qemu.git tags/trivial-branch-pull-request

for you to fetch changes up to 2d2023c3b99edb33ad4bb9791f70456ea1a1c049:

  sockets: avoid string truncation warnings when copying UNIX path (2019-05-03 
13:03:04 +0200)


Pull request trivial branch 2019-05-03



Aruna Jayasena (1):
  Header cleanups

Daniel P. Berrangé (1):
  sockets: avoid string truncation warnings when copying UNIX path

Dr. David Alan Gilbert (1):
  configure: fix pam test warning

Marc-André Lureau (1):
  doc: fix the configuration path

Philippe Mathieu-Daudé (3):
  hw/net/pcnet: Use qemu_log_mask(GUEST_ERROR) instead of printf
  Makefile: Let the 'clean' rule remove qemu-ga.exe on Windows hosts
  hw/sparc/leon3: Allow load of uImage firmwares

Stefan Weil (1):
  Update configure

Thomas Huth (1):
  net: Print output of "-net nic, model=help" to stdout instead of
stderr

Wei Yang (3):
  CODING_STYLE: specify the indent rule for multiline code
  CODING_STYLE: indent example code as all others
  qom: use object_new_with_type in object_new_with_propv

 qemu-ga.texi  |  4 ++--
 configure |  5 ++---
 Makefile  | 11 +
 include/exec/cpu-common.h |  3 ---
 hw/net/pcnet.c|  4 +++-
 hw/sparc/leon3.c  |  4 
 net/net.c |  7 +++---
 qom/object.c  |  2 +-
 util/qemu-sockets.c   | 12 ++
 CODING_STYLE  | 47 +++
 10 files changed, 74 insertions(+), 25 deletions(-)

-- 
2.20.1




[Qemu-devel] [PULL v2 08/12] Header cleanups

2019-05-03 Thread Laurent Vivier
From: Aruna Jayasena 

Removed unwanted includes from cpu-common.h
This task was under https://wiki.qemu.org/Contribute/BiteSizedTasks

Signed-off-by: Aruna Jayasena 
Reviewed-by: Peter Maydell 
Reviewed-by: Thomas Huth 
Message-Id: <20190409155635.10276-1-aruna...@cse.mrt.ac.lk>
[lv: fix conflict on rebase]
Signed-off-by: Laurent Vivier 
---
 include/exec/cpu-common.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index 848a4b94ab73..f7dbe75fbc38 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -7,9 +7,6 @@
 #include "exec/hwaddr.h"
 #endif
 
-#include "qemu/bswap.h"
-#include "qemu/queue.h"
-
 /* The CPU list lock nests outside page_(un)lock or mmap_(un)lock */
 void qemu_init_cpu_list(void);
 void cpu_list_lock(void);
-- 
2.20.1




[Qemu-devel] [PULL v2 03/12] CODING_STYLE: indent example code as all others

2019-05-03 Thread Laurent Vivier
From: Wei Yang 

All the example code are indented with four spaces except this one.

Fix this by adding four spaces here.

Signed-off-by: Wei Yang 
Reviewed-by: Eric Blake 
Reviewed-by: Philippe Mathieu-Daudé 
Reviewed-by: Igor Mammedov 
Reviewed-by: Stefano Garzarella 
Message-Id: <20190304071631.27567-3-richardw.y...@linux.intel.com>
Signed-off-by: Laurent Vivier 
---
 CODING_STYLE | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/CODING_STYLE b/CODING_STYLE
index 90321e9c2821..cb8edcbb3692 100644
--- a/CODING_STYLE
+++ b/CODING_STYLE
@@ -147,10 +147,10 @@ block to a separate function altogether.
 When comparing a variable for (in)equality with a constant, list the
 constant on the right, as in:
 
-if (a == 1) {
-/* Reads like: "If a equals 1" */
-do_something();
-}
+if (a == 1) {
+/* Reads like: "If a equals 1" */
+do_something();
+}
 
 Rationale: Yoda conditions (as in 'if (1 == a)') are awkward to read.
 Besides, good compilers already warn users when '==' is mis-typed as '=',
-- 
2.20.1




[Qemu-devel] [PULL v2 03/12] CODING_STYLE: indent example code as all others

2019-05-03 Thread Laurent Vivier
From: Wei Yang 

All the example code are indented with four spaces except this one.

Fix this by adding four spaces here.

Signed-off-by: Wei Yang 
Reviewed-by: Eric Blake 
Reviewed-by: Philippe Mathieu-Daudé 
Reviewed-by: Igor Mammedov 
Reviewed-by: Stefano Garzarella 
Message-Id: <20190304071631.27567-3-richardw.y...@linux.intel.com>
Signed-off-by: Laurent Vivier 
---
 CODING_STYLE | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/CODING_STYLE b/CODING_STYLE
index 90321e9c2821..cb8edcbb3692 100644
--- a/CODING_STYLE
+++ b/CODING_STYLE
@@ -147,10 +147,10 @@ block to a separate function altogether.
 When comparing a variable for (in)equality with a constant, list the
 constant on the right, as in:
 
-if (a == 1) {
-/* Reads like: "If a equals 1" */
-do_something();
-}
+if (a == 1) {
+/* Reads like: "If a equals 1" */
+do_something();
+}
 
 Rationale: Yoda conditions (as in 'if (1 == a)') are awkward to read.
 Besides, good compilers already warn users when '==' is mis-typed as '=',
-- 
2.20.1




Re: [Qemu-devel] [PULL v2 00/12] Trivial branch patches

2019-05-03 Thread Laurent Vivier
On 03/05/2019 13:18, Laurent Vivier wrote:
> The following changes since commit 8482ff2eb3bb95020eb2f370a9b3ea26511e41df:
> 
>   Merge remote-tracking branch 'remotes/jnsnow/tags/bitmaps-pull-request' 
> into staging (2019-05-02 12:04:51 +0100)
> 
> are available in the Git repository at:
> 
>   git://github.com/vivier/qemu.git tags/trivial-branch-pull-request
> 
> for you to fetch changes up to 2d2023c3b99edb33ad4bb9791f70456ea1a1c049:
> 
>   sockets: avoid string truncation warnings when copying UNIX path 
> (2019-05-03 13:03:04 +0200)
> 
> 
> Pull request trivial branch 2019-05-03
> 
> 
> 
> Aruna Jayasena (1):
>   Header cleanups
> 
> Daniel P. Berrangé (1):
>   sockets: avoid string truncation warnings when copying UNIX path
> 
> Dr. David Alan Gilbert (1):
>   configure: fix pam test warning
> 
> Marc-André Lureau (1):
>   doc: fix the configuration path
> 
> Philippe Mathieu-Daudé (3):
>   hw/net/pcnet: Use qemu_log_mask(GUEST_ERROR) instead of printf
>   Makefile: Let the 'clean' rule remove qemu-ga.exe on Windows hosts
>   hw/sparc/leon3: Allow load of uImage firmwares
> 
> Stefan Weil (1):
>   Update configure
> 
> Thomas Huth (1):
>   net: Print output of "-net nic, model=help" to stdout instead of
> stderr
> 
> Wei Yang (3):
>   CODING_STYLE: specify the indent rule for multiline code
>   CODING_STYLE: indent example code as all others
>   qom: use object_new_with_type in object_new_with_propv
> 
>  qemu-ga.texi  |  4 ++--
>  configure |  5 ++---
>  Makefile  | 11 +
>  include/exec/cpu-common.h |  3 ---
>  hw/net/pcnet.c|  4 +++-
>  hw/sparc/leon3.c  |  4 
>  net/net.c |  7 +++---
>  qom/object.c  |  2 +-
>  util/qemu-sockets.c   | 12 ++
>  CODING_STYLE  | 47 +++
>  10 files changed, 74 insertions(+), 25 deletions(-)
> 

Forget this series, the send has been aborted for an unknown reason.

Thanks,
Laurent



[Qemu-devel] [PULL v2 07/12] Update configure

2019-05-03 Thread Laurent Vivier
From: Stefan Weil 

The last *.aml file was removed in commit 
13b1881aacc7e5018773bd545bbaf8d5476699ee.

Signed-off-by: Stefan Weil 
Reviewed-by: Igor Mammedov 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20190409053320.14612-1...@weilnetz.de>
Signed-off-by: Laurent Vivier 
---
 configure | 1 -
 1 file changed, 1 deletion(-)

diff --git a/configure b/configure
index a2607afb3408..14f02452f9d4 100755
--- a/configure
+++ b/configure
@@ -7880,7 +7880,6 @@ LINKS="$LINKS python"
 for bios_file in \
 $source_path/pc-bios/*.bin \
 $source_path/pc-bios/*.lid \
-$source_path/pc-bios/*.aml \
 $source_path/pc-bios/*.rom \
 $source_path/pc-bios/*.dtb \
 $source_path/pc-bios/*.img \
-- 
2.20.1




[Qemu-devel] [PULL v2 02/12] CODING_STYLE: specify the indent rule for multiline code

2019-05-03 Thread Laurent Vivier
From: Wei Yang 

We didn't specify the indent rule for multiline code here, which may
mislead users. And in current code, the code use various styles.

Add this rule in CODING_STYLE to make sure this is clear to every one.

Signed-off-by: Wei Yang 
Suggested-by: Igor Mammedov 
Reviewed-by: Igor Mammedov 
Reviewed-by: Stefano Garzarella 
Message-Id: <20190304071631.27567-2-richardw.y...@linux.intel.com>
Signed-off-by: Laurent Vivier 
---
 CODING_STYLE | 39 +++
 1 file changed, 39 insertions(+)

diff --git a/CODING_STYLE b/CODING_STYLE
index ec075dedc4a8..90321e9c2821 100644
--- a/CODING_STYLE
+++ b/CODING_STYLE
@@ -29,6 +29,45 @@ Spaces of course are superior to tabs because:
 
 Do not leave whitespace dangling off the ends of lines.
 
+1.1 Multiline Indent
+
+There are several places where indent is necessary:
+
+ - if/else
+ - while/for
+ - function definition & call
+
+When breaking up a long line to fit within line width, we need a proper indent
+for the following lines.
+
+In case of if/else, while/for, align the secondary lines just after the
+opening parenthesis of the first.
+
+For example:
+
+if (a == 1 &&
+b == 2) {
+
+while (a == 1 &&
+   b == 2) {
+
+In case of function, there are several variants:
+
+* 4 spaces indent from the beginning
+* align the secondary lines just after the opening parenthesis of the
+  first
+
+For example:
+
+do_something(x, y,
+z);
+
+do_something(x, y,
+ z);
+
+do_something(x, do_another(y,
+   z));
+
 2. Line width
 
 Lines should be 80 characters; try not to make them longer.
-- 
2.20.1




[Qemu-devel] [PULL v2 05/12] qom: use object_new_with_type in object_new_with_propv

2019-05-03 Thread Laurent Vivier
From: Wei Yang 

Function object_new_with_propv already get the Type of the object, so we
could leverage object_new_with_type here.

Signed-off-by: Wei Yang 
Reviewed-by: Marc-André Lureau 
Reviewed-by: Stefano Garzarella 
Message-Id: <20190311083234.20841-1-richardw.y...@linux.intel.com>
Signed-off-by: Laurent Vivier 
---
 qom/object.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qom/object.c b/qom/object.c
index e3206d6799ee..d3412e7fdca6 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -679,7 +679,7 @@ Object *object_new_with_propv(const char *typename,
 error_setg(errp, "object type '%s' is abstract", typename);
 return NULL;
 }
-obj = object_new(typename);
+obj = object_new_with_type(klass->type);
 
 if (object_set_propv(obj, _err, vargs) < 0) {
 goto error;
-- 
2.20.1




[Qemu-devel] [PULL v2 04/12] doc: fix the configuration path

2019-05-03 Thread Laurent Vivier
From: Marc-André Lureau 

Use a CONFDIR variable to show the configured sysconf path in the
generated documentations (html, man pages etc).

Related to:
https://bugzilla.redhat.com/show_bug.cgi?id=1644985

Signed-off-by: Marc-André Lureau 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20181126105125.30973-1-marcandre.lur...@redhat.com>
Signed-off-by: Laurent Vivier 
---
 qemu-ga.texi | 4 ++--
 Makefile | 9 ++---
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/qemu-ga.texi b/qemu-ga.texi
index 4c7a8fd16329..f00ad830f283 100644
--- a/qemu-ga.texi
+++ b/qemu-ga.texi
@@ -30,7 +30,7 @@ set user's password
 @end itemize
 
 qemu-ga will read a system configuration file on startup (located at
-@file{/etc/qemu/qemu-ga.conf} by default), then parse remaining
+@file{@value{CONFDIR}/qemu-ga.conf} by default), then parse remaining
 configuration options on the command line. For the same key, the last
 option wins, but the lists accumulate (see below for configuration
 file format).
@@ -58,7 +58,7 @@ file format).
   Enable fsfreeze hook. Accepts an optional argument that specifies
   script to run on freeze/thaw. Script will be called with
   'freeze'/'thaw' arguments accordingly (default is
-  @samp{/etc/qemu/fsfreeze-hook}). If using -F with an argument, do
+  @samp{@value{CONFDIR}/fsfreeze-hook}). If using -F with an argument, do
   not follow -F with a space (for example:
   @samp{-F/var/run/fsfreezehook.sh}).
 
diff --git a/Makefile b/Makefile
index 1211e78c91ed..43a7a047b452 100644
--- a/Makefile
+++ b/Makefile
@@ -899,11 +899,14 @@ ui/shader.o: $(SRC_PATH)/ui/shader.c \
 MAKEINFO=makeinfo
 MAKEINFOINCLUDES= -I docs -I $( $@,"GEN","$@")
+docs/version.texi: $(SRC_PATH)/VERSION config-host.mak
+   $(call quiet-command,(\
+   echo "@set VERSION $(VERSION)" && \
+   echo "@set CONFDIR $(qemu_confdir)" \
+   )> $@,"GEN","$@")
 
 %.html: %.texi docs/version.texi
$(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers 
\
-- 
2.20.1




[Qemu-devel] [PULL v2 06/12] configure: fix pam test warning

2019-05-03 Thread Laurent Vivier
From: "Dr. David Alan Gilbert" 

The pam test generates a warning on Fedora 29 with -O3 compilation
because the headers declare that the pam_conversation pointer to
pam_start must be non-NULL.  Change it to use the same 0 initialised
structure as we actually use in qauthz.

Signed-off-by: Dr. David Alan Gilbert 
Acked-by: Daniel P. Berrangé 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20190404091725.20595-1-dgilb...@redhat.com>
Signed-off-by: Laurent Vivier 
---
 configure | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 60719ddcc5b0..a2607afb3408 100755
--- a/configure
+++ b/configure
@@ -2940,9 +2940,9 @@ if test "$auth_pam" != "no"; then
 int main(void) {
const char *service_name = "qemu";
const char *user = "frank";
-   const struct pam_conv *pam_conv = NULL;
+   const struct pam_conv pam_conv = { 0 };
pam_handle_t *pamh = NULL;
-   pam_start(service_name, user, pam_conv, );
+   pam_start(service_name, user, _conv, );
return 0;
 }
 EOF
-- 
2.20.1




[Qemu-devel] [PULL v2 01/12] hw/net/pcnet: Use qemu_log_mask(GUEST_ERROR) instead of printf

2019-05-03 Thread Laurent Vivier
From: Philippe Mathieu-Daudé 

Avoid to clutter stdout until explicitly requested
(with -d guest_errors):

  $ qemu-system-mips -M malta -m 512 -kernel vmlinux-3.2.0-4-4kc-malta
  Bad SWSTYLE=0x04

Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Thomas Huth 
Message-Id: <20190311102712.8572-1-phi...@redhat.com>
Signed-off-by: Laurent Vivier 
---
 hw/net/pcnet.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/hw/net/pcnet.c b/hw/net/pcnet.c
index d9ba04bdfc62..16683091c939 100644
--- a/hw/net/pcnet.c
+++ b/hw/net/pcnet.c
@@ -36,6 +36,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/log.h"
 #include "hw/qdev.h"
 #include "net/net.h"
 #include "net/eth.h"
@@ -1501,7 +1502,8 @@ static void pcnet_bcr_writew(PCNetState *s, uint32_t rap, 
uint32_t val)
 val |= 0x0300;
 break;
 default:
-printf("Bad SWSTYLE=0x%02x\n", val & 0xff);
+qemu_log_mask(LOG_GUEST_ERROR, "pcnet: Bad SWSTYLE=0x%02x\n",
+  val & 0xff);
 val = 0x0200;
 break;
 }
-- 
2.20.1




[Qemu-devel] [PULL v2 06/12] configure: fix pam test warning

2019-05-03 Thread Laurent Vivier
From: "Dr. David Alan Gilbert" 

The pam test generates a warning on Fedora 29 with -O3 compilation
because the headers declare that the pam_conversation pointer to
pam_start must be non-NULL.  Change it to use the same 0 initialised
structure as we actually use in qauthz.

Signed-off-by: Dr. David Alan Gilbert 
Acked-by: Daniel P. Berrangé 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20190404091725.20595-1-dgilb...@redhat.com>
Signed-off-by: Laurent Vivier 
---
 configure | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 60719ddcc5b0..a2607afb3408 100755
--- a/configure
+++ b/configure
@@ -2940,9 +2940,9 @@ if test "$auth_pam" != "no"; then
 int main(void) {
const char *service_name = "qemu";
const char *user = "frank";
-   const struct pam_conv *pam_conv = NULL;
+   const struct pam_conv pam_conv = { 0 };
pam_handle_t *pamh = NULL;
-   pam_start(service_name, user, pam_conv, );
+   pam_start(service_name, user, _conv, );
return 0;
 }
 EOF
-- 
2.20.1




[Qemu-devel] [PULL v2 06/12] configure: fix pam test warning

2019-05-03 Thread Laurent Vivier
From: "Dr. David Alan Gilbert" 

The pam test generates a warning on Fedora 29 with -O3 compilation
because the headers declare that the pam_conversation pointer to
pam_start must be non-NULL.  Change it to use the same 0 initialised
structure as we actually use in qauthz.

Signed-off-by: Dr. David Alan Gilbert 
Acked-by: Daniel P. Berrangé 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20190404091725.20595-1-dgilb...@redhat.com>
Signed-off-by: Laurent Vivier 
---
 configure | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 60719ddcc5b0..a2607afb3408 100755
--- a/configure
+++ b/configure
@@ -2940,9 +2940,9 @@ if test "$auth_pam" != "no"; then
 int main(void) {
const char *service_name = "qemu";
const char *user = "frank";
-   const struct pam_conv *pam_conv = NULL;
+   const struct pam_conv pam_conv = { 0 };
pam_handle_t *pamh = NULL;
-   pam_start(service_name, user, pam_conv, );
+   pam_start(service_name, user, _conv, );
return 0;
 }
 EOF
-- 
2.20.1




[Qemu-devel] [PULL v2 07/12] Update configure

2019-05-03 Thread Laurent Vivier
From: Stefan Weil 

The last *.aml file was removed in commit 
13b1881aacc7e5018773bd545bbaf8d5476699ee.

Signed-off-by: Stefan Weil 
Reviewed-by: Igor Mammedov 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20190409053320.14612-1...@weilnetz.de>
Signed-off-by: Laurent Vivier 
---
 configure | 1 -
 1 file changed, 1 deletion(-)

diff --git a/configure b/configure
index a2607afb3408..14f02452f9d4 100755
--- a/configure
+++ b/configure
@@ -7880,7 +7880,6 @@ LINKS="$LINKS python"
 for bios_file in \
 $source_path/pc-bios/*.bin \
 $source_path/pc-bios/*.lid \
-$source_path/pc-bios/*.aml \
 $source_path/pc-bios/*.rom \
 $source_path/pc-bios/*.dtb \
 $source_path/pc-bios/*.img \
-- 
2.20.1




[Qemu-devel] [PULL v2 04/12] doc: fix the configuration path

2019-05-03 Thread Laurent Vivier
From: Marc-André Lureau 

Use a CONFDIR variable to show the configured sysconf path in the
generated documentations (html, man pages etc).

Related to:
https://bugzilla.redhat.com/show_bug.cgi?id=1644985

Signed-off-by: Marc-André Lureau 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20181126105125.30973-1-marcandre.lur...@redhat.com>
Signed-off-by: Laurent Vivier 
---
 qemu-ga.texi | 4 ++--
 Makefile | 9 ++---
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/qemu-ga.texi b/qemu-ga.texi
index 4c7a8fd16329..f00ad830f283 100644
--- a/qemu-ga.texi
+++ b/qemu-ga.texi
@@ -30,7 +30,7 @@ set user's password
 @end itemize
 
 qemu-ga will read a system configuration file on startup (located at
-@file{/etc/qemu/qemu-ga.conf} by default), then parse remaining
+@file{@value{CONFDIR}/qemu-ga.conf} by default), then parse remaining
 configuration options on the command line. For the same key, the last
 option wins, but the lists accumulate (see below for configuration
 file format).
@@ -58,7 +58,7 @@ file format).
   Enable fsfreeze hook. Accepts an optional argument that specifies
   script to run on freeze/thaw. Script will be called with
   'freeze'/'thaw' arguments accordingly (default is
-  @samp{/etc/qemu/fsfreeze-hook}). If using -F with an argument, do
+  @samp{@value{CONFDIR}/fsfreeze-hook}). If using -F with an argument, do
   not follow -F with a space (for example:
   @samp{-F/var/run/fsfreezehook.sh}).
 
diff --git a/Makefile b/Makefile
index 1211e78c91ed..43a7a047b452 100644
--- a/Makefile
+++ b/Makefile
@@ -899,11 +899,14 @@ ui/shader.o: $(SRC_PATH)/ui/shader.c \
 MAKEINFO=makeinfo
 MAKEINFOINCLUDES= -I docs -I $( $@,"GEN","$@")
+docs/version.texi: $(SRC_PATH)/VERSION config-host.mak
+   $(call quiet-command,(\
+   echo "@set VERSION $(VERSION)" && \
+   echo "@set CONFDIR $(qemu_confdir)" \
+   )> $@,"GEN","$@")
 
 %.html: %.texi docs/version.texi
$(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers 
\
-- 
2.20.1




[Qemu-devel] [PULL v2 07/12] Update configure

2019-05-03 Thread Laurent Vivier
From: Stefan Weil 

The last *.aml file was removed in commit 
13b1881aacc7e5018773bd545bbaf8d5476699ee.

Signed-off-by: Stefan Weil 
Reviewed-by: Igor Mammedov 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20190409053320.14612-1...@weilnetz.de>
Signed-off-by: Laurent Vivier 
---
 configure | 1 -
 1 file changed, 1 deletion(-)

diff --git a/configure b/configure
index a2607afb3408..14f02452f9d4 100755
--- a/configure
+++ b/configure
@@ -7880,7 +7880,6 @@ LINKS="$LINKS python"
 for bios_file in \
 $source_path/pc-bios/*.bin \
 $source_path/pc-bios/*.lid \
-$source_path/pc-bios/*.aml \
 $source_path/pc-bios/*.rom \
 $source_path/pc-bios/*.dtb \
 $source_path/pc-bios/*.img \
-- 
2.20.1




[Qemu-devel] [PULL v2 01/12] hw/net/pcnet: Use qemu_log_mask(GUEST_ERROR) instead of printf

2019-05-03 Thread Laurent Vivier
From: Philippe Mathieu-Daudé 

Avoid to clutter stdout until explicitly requested
(with -d guest_errors):

  $ qemu-system-mips -M malta -m 512 -kernel vmlinux-3.2.0-4-4kc-malta
  Bad SWSTYLE=0x04

Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Thomas Huth 
Message-Id: <20190311102712.8572-1-phi...@redhat.com>
Signed-off-by: Laurent Vivier 
---
 hw/net/pcnet.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/hw/net/pcnet.c b/hw/net/pcnet.c
index d9ba04bdfc62..16683091c939 100644
--- a/hw/net/pcnet.c
+++ b/hw/net/pcnet.c
@@ -36,6 +36,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/log.h"
 #include "hw/qdev.h"
 #include "net/net.h"
 #include "net/eth.h"
@@ -1501,7 +1502,8 @@ static void pcnet_bcr_writew(PCNetState *s, uint32_t rap, 
uint32_t val)
 val |= 0x0300;
 break;
 default:
-printf("Bad SWSTYLE=0x%02x\n", val & 0xff);
+qemu_log_mask(LOG_GUEST_ERROR, "pcnet: Bad SWSTYLE=0x%02x\n",
+  val & 0xff);
 val = 0x0200;
 break;
 }
-- 
2.20.1




[Qemu-devel] [PULL v2 00/12] Trivial branch patches

2019-05-03 Thread Laurent Vivier
The following changes since commit 8482ff2eb3bb95020eb2f370a9b3ea26511e41df:

  Merge remote-tracking branch 'remotes/jnsnow/tags/bitmaps-pull-request' into 
staging (2019-05-02 12:04:51 +0100)

are available in the Git repository at:

  git://github.com/vivier/qemu.git tags/trivial-branch-pull-request

for you to fetch changes up to 2d2023c3b99edb33ad4bb9791f70456ea1a1c049:

  sockets: avoid string truncation warnings when copying UNIX path (2019-05-03 
13:03:04 +0200)


Pull request trivial branch 2019-05-03



Aruna Jayasena (1):
  Header cleanups

Daniel P. Berrangé (1):
  sockets: avoid string truncation warnings when copying UNIX path

Dr. David Alan Gilbert (1):
  configure: fix pam test warning

Marc-André Lureau (1):
  doc: fix the configuration path

Philippe Mathieu-Daudé (3):
  hw/net/pcnet: Use qemu_log_mask(GUEST_ERROR) instead of printf
  Makefile: Let the 'clean' rule remove qemu-ga.exe on Windows hosts
  hw/sparc/leon3: Allow load of uImage firmwares

Stefan Weil (1):
  Update configure

Thomas Huth (1):
  net: Print output of "-net nic, model=help" to stdout instead of
stderr

Wei Yang (3):
  CODING_STYLE: specify the indent rule for multiline code
  CODING_STYLE: indent example code as all others
  qom: use object_new_with_type in object_new_with_propv

 qemu-ga.texi  |  4 ++--
 configure |  5 ++---
 Makefile  | 11 +
 include/exec/cpu-common.h |  3 ---
 hw/net/pcnet.c|  4 +++-
 hw/sparc/leon3.c  |  4 
 net/net.c |  7 +++---
 qom/object.c  |  2 +-
 util/qemu-sockets.c   | 12 ++
 CODING_STYLE  | 47 +++
 10 files changed, 74 insertions(+), 25 deletions(-)

-- 
2.20.1




[Qemu-devel] [PULL v2 03/12] CODING_STYLE: indent example code as all others

2019-05-03 Thread Laurent Vivier
From: Wei Yang 

All the example code are indented with four spaces except this one.

Fix this by adding four spaces here.

Signed-off-by: Wei Yang 
Reviewed-by: Eric Blake 
Reviewed-by: Philippe Mathieu-Daudé 
Reviewed-by: Igor Mammedov 
Reviewed-by: Stefano Garzarella 
Message-Id: <20190304071631.27567-3-richardw.y...@linux.intel.com>
Signed-off-by: Laurent Vivier 
---
 CODING_STYLE | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/CODING_STYLE b/CODING_STYLE
index 90321e9c2821..cb8edcbb3692 100644
--- a/CODING_STYLE
+++ b/CODING_STYLE
@@ -147,10 +147,10 @@ block to a separate function altogether.
 When comparing a variable for (in)equality with a constant, list the
 constant on the right, as in:
 
-if (a == 1) {
-/* Reads like: "If a equals 1" */
-do_something();
-}
+if (a == 1) {
+/* Reads like: "If a equals 1" */
+do_something();
+}
 
 Rationale: Yoda conditions (as in 'if (1 == a)') are awkward to read.
 Besides, good compilers already warn users when '==' is mis-typed as '=',
-- 
2.20.1




[Qemu-devel] [PULL v2 02/12] CODING_STYLE: specify the indent rule for multiline code

2019-05-03 Thread Laurent Vivier
From: Wei Yang 

We didn't specify the indent rule for multiline code here, which may
mislead users. And in current code, the code use various styles.

Add this rule in CODING_STYLE to make sure this is clear to every one.

Signed-off-by: Wei Yang 
Suggested-by: Igor Mammedov 
Reviewed-by: Igor Mammedov 
Reviewed-by: Stefano Garzarella 
Message-Id: <20190304071631.27567-2-richardw.y...@linux.intel.com>
Signed-off-by: Laurent Vivier 
---
 CODING_STYLE | 39 +++
 1 file changed, 39 insertions(+)

diff --git a/CODING_STYLE b/CODING_STYLE
index ec075dedc4a8..90321e9c2821 100644
--- a/CODING_STYLE
+++ b/CODING_STYLE
@@ -29,6 +29,45 @@ Spaces of course are superior to tabs because:
 
 Do not leave whitespace dangling off the ends of lines.
 
+1.1 Multiline Indent
+
+There are several places where indent is necessary:
+
+ - if/else
+ - while/for
+ - function definition & call
+
+When breaking up a long line to fit within line width, we need a proper indent
+for the following lines.
+
+In case of if/else, while/for, align the secondary lines just after the
+opening parenthesis of the first.
+
+For example:
+
+if (a == 1 &&
+b == 2) {
+
+while (a == 1 &&
+   b == 2) {
+
+In case of function, there are several variants:
+
+* 4 spaces indent from the beginning
+* align the secondary lines just after the opening parenthesis of the
+  first
+
+For example:
+
+do_something(x, y,
+z);
+
+do_something(x, y,
+ z);
+
+do_something(x, do_another(y,
+   z));
+
 2. Line width
 
 Lines should be 80 characters; try not to make them longer.
-- 
2.20.1




[Qemu-devel] [PULL v2 00/12] Trivial branch patches

2019-05-03 Thread Laurent Vivier
The following changes since commit 8482ff2eb3bb95020eb2f370a9b3ea26511e41df:

  Merge remote-tracking branch 'remotes/jnsnow/tags/bitmaps-pull-request' into 
staging (2019-05-02 12:04:51 +0100)

are available in the Git repository at:

  git://github.com/vivier/qemu.git tags/trivial-branch-pull-request

for you to fetch changes up to 2d2023c3b99edb33ad4bb9791f70456ea1a1c049:

  sockets: avoid string truncation warnings when copying UNIX path (2019-05-03 
13:03:04 +0200)


Pull request trivial branch 2019-05-03



Aruna Jayasena (1):
  Header cleanups

Daniel P. Berrangé (1):
  sockets: avoid string truncation warnings when copying UNIX path

Dr. David Alan Gilbert (1):
  configure: fix pam test warning

Marc-André Lureau (1):
  doc: fix the configuration path

Philippe Mathieu-Daudé (3):
  hw/net/pcnet: Use qemu_log_mask(GUEST_ERROR) instead of printf
  Makefile: Let the 'clean' rule remove qemu-ga.exe on Windows hosts
  hw/sparc/leon3: Allow load of uImage firmwares

Stefan Weil (1):
  Update configure

Thomas Huth (1):
  net: Print output of "-net nic, model=help" to stdout instead of
stderr

Wei Yang (3):
  CODING_STYLE: specify the indent rule for multiline code
  CODING_STYLE: indent example code as all others
  qom: use object_new_with_type in object_new_with_propv

 qemu-ga.texi  |  4 ++--
 configure |  5 ++---
 Makefile  | 11 +
 include/exec/cpu-common.h |  3 ---
 hw/net/pcnet.c|  4 +++-
 hw/sparc/leon3.c  |  4 
 net/net.c |  7 +++---
 qom/object.c  |  2 +-
 util/qemu-sockets.c   | 12 ++
 CODING_STYLE  | 47 +++
 10 files changed, 74 insertions(+), 25 deletions(-)

-- 
2.20.1




<    1   2   3   >