[Qemu-devel] [PATCH] target/arm: v8M MPU should use background region as default, not always

2019-02-14 Thread Peter Maydell
The "background region" for a v8M MPU is a default which will be used
(if enabled, and if the access is privileged) if the access does
not match any specific MPU region. We were incorrectly using it
always (by putting the condition at the wrong nesting level). This
meant that we would always return the default background permissions
rather than the correct permissions for a specific region, and also
that we would not return the right information in response to a
TT instruction.

Move the check for the background region to the same place in the
logic as the equivalent v8M MPUCheck() pseudocode puts it.
This in turn means we must adjust the condition we use to detect
matches in multiple regions to avoid false-positives.

Signed-off-by: Peter Maydell 
---
I found this because the incorrect TT response eventually resulted
in the Zephyr RTOS writing an invalid region number back to the
NVIC and tripping the guest_errors logging.
---
 target/arm/helper.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/target/arm/helper.c b/target/arm/helper.c
index 0f5eb3229b7..d3e15585c25 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -11291,9 +11291,11 @@ static bool pmsav8_mpu_lookup(CPUARMState *env, 
uint32_t address,
 hit = true;
 } else if (m_is_ppb_region(env, address)) {
 hit = true;
-} else if (pmsav7_use_background_region(cpu, mmu_idx, is_user)) {
-hit = true;
 } else {
+if (pmsav7_use_background_region(cpu, mmu_idx, is_user)) {
+hit = true;
+}
+
 for (n = (int)cpu->pmsav7_dregion - 1; n >= 0; n--) {
 /* region search */
 /* Note that the base address is bits [31:5] from the register
@@ -11331,7 +11333,7 @@ static bool pmsav8_mpu_lookup(CPUARMState *env, 
uint32_t address,
 *is_subpage = true;
 }
 
-if (hit) {
+if (matchregion != -1) {
 /* Multiple regions match -- always a failure (unlike
  * PMSAv7 where highest-numbered-region wins)
  */
-- 
2.20.1




Re: [Qemu-devel] [Issues] PCI hotplug does not work well on pc platform?

2019-02-14 Thread Igor Mammedov
On Wed, 13 Feb 2019 15:40:57 +0800
"Liu, Jing2"  wrote:

> Hi Igor,
> 
> Thanks for your reply!
> 
> On 2/5/2019 11:47 PM, Igor Mammedov wrote:
> > On Wed, 30 Jan 2019 21:02:10 +0800
> > "Liu, Jing2"  wrote:
> >   
> >> Hi everyone,
> >>
> >> I have two questions.
> >> 1. PCI hotplug on pci.0 must manually rescan in guest. The ACPI hotplug
> >> handler sends the GPE event to guest but it seems guest doesn't receive
> >> it? I tried to open ACPI debug level/layer to 0x, in order to
> >> see if there is any message after device_add in monitor, but no message
> >> comes out until I manually rescan. Also tried printk in
> >> acpi_ev_gpe_xrupt_handler() and acpi_ev_sci_xrupt_handler(). No output
> >> in dmesg.
> >> (I'm sure that CONFIG_HOTPLUG_PCI_PCIE=y, CONFIG_HOTPLUG_PCI_CPCI=y,
> >> CONFIG_HOTPLUG_PCI=y, CONFIG_HOTPLUG_PCI_ACPI=y)
> >>
> >> Whether this is a kind of design or a known issue? Does guest receive
> >> the request, where can I find the  
> > does it work with known to work kernels (RHEL7)?
> > 
> > Also sharing used QEMU version and command line could help.
> >   
> Is there any key config of kernel in guest, besides those I listed above?
Maybe Marcel knows something about it
(CCed)

> 
> I used guest kernel v4.18 and qemu upstream v3.1.0
> Command line:
> sudo /home/xxx/qemu/x86_64-softmmu/qemu-system-x86_64  \
> -machine pc,accel=kvm,kernel_irqchip -cpu host -m 1G,slots=2,maxmem=10G \
> -nographic -no-user-config -nodefaults -vga none \
> -drive file=/home/xxx/image/clear-24690-kvm.img,if=virtio,format=raw \
>   -smp sockets=1,cpus=4,cores=2,maxcpus=8 \
> -device virtio-serial-pci,id=virtio-serial0,disable-modern,addr=0x5 \
> -monitor tcp:0.0.0.0:5000,nowait,server \
> -chardev stdio,id=charconsole0 -device 
> virtconsole,chardev=charconsole0,id=console0  \
> -kernel /home/xxx/linux-stable/arch/x86/boot/bzImage \
> -append 'root=/dev/vda3 rw rootfstype=ext4 data=ordered 
> rcupdate.rcu_expedited=1 pci=lastbus=0 pci=realloc=on tsc=reliable 
> no_timer_check reboot=t noapictimer console=hvc0 iommu=off  panic=1 
> initcall_debug acpi.debug_layer=0x4 acpi.debug_level=4 ' \
> -device pci-bridge,bus=pci.0,id=br1,chassis_nr=1,shpc=on,addr=6  \
> 
> >>
> >> 2. I want to try hotplugging on pci-bridge on pc platform, using shpc. I
> >> set shpc=on, but when I do device_add, qemu still calls
> >> acpi_pcihp_device_plug_cb? Why it does not call pci_bridge_dev_hotplug_cb?
> >> (CONFIG_HOTPLUG_PCI_SHPC=y)  
> > 
> > try to disable ACPI hotplug for bridges
> >   -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off
> >   
> I'll try it!
> 
> Thanks!
> Jing
> >   
> 




Re: [Qemu-devel] [PULL 00/24] target/hppa patch queue

2019-02-14 Thread Philippe Mathieu-Daudé
Hi Peter,

On 2/14/19 11:04 AM, Peter Maydell wrote:
> On Wed, 13 Feb 2019 at 18:40, Philippe Mathieu-Daudé  
> wrote:
>> What Clang version is that?
>>
>> I can not reproduce using:
>>
>> clang version 7.0.1 (Fedora 7.0.1-1.fc29)
> 
> OSX: Apple LLVM version 10.0.0 (clang-1000.11.45.5)> and Ubuntu bionic: clang 
> version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)

I can not reproduce on Bionic:

$ clang --version
clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu

./configure --host-cc=clang \
--cxx=clang++ \
--cc=clang \
--extra-cflags=-Werror=typedef-redefinition
Host C compiler   clang
C++ compiler  clang++
Objective-C compiler clang
QEMU_CFLAGS   -I/usr/include/pixman-1 -I$(SRC_PATH)/dtc/libfdt
-Werror  -pthread -I/usr/include/glib-2.0
-I/usr/lib/x86_64-linux-gnu/glib-2.0/include -fPIE -DPIE -m64 -mcx16
-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
-Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings
-Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -std=gnu99
 -Werror=typedef-redefinition -Wno-error=address-of-packed-member
-Wno-string-plus-int -Wno-initializer-overrides -Wexpansion-to-defined
-Wendif-labels -Wno-shift-negative-value -Wno-missing-include-dirs
-Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self
-Wignored-qualifiers -Wold-style-definition -Wtype-limits
-fstack-protector-strong  -I/usr/include/p11-kit-1
-I/usr/include/libpng16 -I/usr/include/spice-server
-I/usr/include/spice-1 -I$(SRC_PATH)/capstone/include
[...]

$ make subdir-hppa-softmmu
[...]

$ hppa-softmmu/qemu-system-hppa --version
QEMU emulator version 3.1.50 (v3.1.0-1733-gcb82c5728c-dirty)

I don't have handy OSX setup except Travis, I'll see what I can do.

Regards,

Phil.



Re: [Qemu-devel] [PATCH] i386, acpi: check acpi_memory_hotplug capacity in pre_plug

2019-02-14 Thread Igor Mammedov
On Thu, 14 Feb 2019 08:52:25 +0800
Wei Yang  wrote:

> Currently we do device realization like below:
> 
>hotplug_handler_pre_plug()
>dc->realize()
>hotplug_handler_plug()
> 
> Before we do device realization and plug, we would allocate necessary
> resources and check the capacity.
'capacity' probably is not right word to use here
maybe s/the capacity/if 'memory-hotplug-support' property is enabled/

> 
> While we leave acpi_memory_hotplug capacity check in the last step. This
wouldn't use 'leave' and 'capacity' here either, pls rephrase.

> looks not comply with current architecture and does some unnecessary
s/looks not/doesn't/
> work.
add more explanation about 'unnecessary work'.
problem as I see it, is that after successful pc_dimm_plug()
we get into piix4_device_plug_cb() and since
 s->acpi_memory_hotplug.is_enabled == false
and all other 'if' conditions also false we would endup
at g_assert_not_reached() causing QEMU crash in piix4 case
and with error_abort up the call chain in case of ich9.

> This patch abstract the check on acpi_memory_hotplug capacity in
> pre_plug stage.
> 
> Signed-off-by: Wei Yang 
> ---
>  hw/acpi/piix4.c | 14 --
>  hw/i386/pc.c|  8 
doesn't look complete, why did you skip on similar code in ich9
(Q35 machine)?

>  2 files changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
> index e330f24c71..c97b747496 100644
> --- a/hw/acpi/piix4.c
> +++ b/hw/acpi/piix4.c
> @@ -370,13 +370,22 @@ static void piix4_pm_powerdown_req(Notifier *n, void 
> *opaque)
>  acpi_pm1_evt_power_down(&s->ar);
>  }
>  
> +static void piix4_device_pre_plug_cb(HotplugHandler *hotplug_dev,
> + DeviceState *dev, Error **errp)
> +{
> +PIIX4PMState *s = PIIX4_PM(hotplug_dev);
> +
> +if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) &&
> +!s->acpi_memory_hotplug.is_enabled)
> +error_setg(errp,
> +"memory hotplug is not enabled: PIIX4 memory hotplug disabled");
> +}
>  static void piix4_device_plug_cb(HotplugHandler *hotplug_dev,
>   DeviceState *dev, Error **errp)
>  {
>  PIIX4PMState *s = PIIX4_PM(hotplug_dev);
>  
> -if (s->acpi_memory_hotplug.is_enabled &&
> -object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
> +if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
>  if (object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)) {
>  nvdimm_acpi_plug_cb(hotplug_dev, dev);
>  } else {
> @@ -702,6 +711,7 @@ static void piix4_pm_class_init(ObjectClass *klass, void 
> *data)
>   */
>  dc->user_creatable = false;
>  dc->hotpluggable = false;
> +hc->pre_plug = piix4_device_pre_plug_cb;
>  hc->plug = piix4_device_plug_cb;
>  hc->unplug_request = piix4_device_unplug_request_cb;
>  hc->unplug = piix4_device_unplug_cb;
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index 734d3268fa..3c6eed0cd3 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -1662,6 +1662,7 @@ static void pc_memory_pre_plug(HotplugHandler 
> *hotplug_dev, DeviceState *dev,
>  const PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
>  const bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM);
>  const uint64_t legacy_align = TARGET_PAGE_SIZE;
> +HotplugHandlerClass *hhc;
>  
>  /*
>   * When -no-acpi is used with Q35 machine type, no ACPI is built,
> @@ -1674,6 +1675,13 @@ static void pc_memory_pre_plug(HotplugHandler 
> *hotplug_dev, DeviceState *dev,
>  return;
>  }
>  
> +/*
> + * Check acpi_dev memory hotplug capacity
> + */
> +hhc = HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev);
> +if (hcc->pre_plug)
> +hhc->pre_plug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, errp);
use hotplug_handler_pre_plug() instead of open-coding check

>  if (is_nvdimm && !pcms->acpi_nvdimm_state.is_enabled) {
>  error_setg(errp, "nvdimm is not enabled: missing 'nvdimm' in '-M'");
>  return;




Re: [Qemu-devel] [PATCH 00/11] Enable build and install of our rST docs

2019-02-14 Thread Peter Maydell
Ping! Thanks to Alex for doing low-level review of this patchset.
I'm particularly interested in high-level review:
 * is this the right way to be going?
 * if we committed this and then did a release with the
   docs as they are like this, would that be ok?
 * what's the most important next step after this?

thanks
-- PMM

On Fri, 1 Feb 2019 at 14:50, Peter Maydell  wrote:
>
> This patchset enables building and installing the various rST
> docs we have started to accumulate in our docs/ directory.
> It does this using Sphinx (which is the docs tooling that the
> Linux kernel uses). The series is not trying to take us in one
> giant leap to a brave new Sphinx-powered world -- it is simply
> setting up a framework so that we are at least building and
> shipping these documents and can gradually migrate other parts
> of our documentation to it.
>
> The approach I've used here is that we will have multiple "manuals",
> as proposed by Paolo here:
>   https://wiki.qemu.org/Features/Documentation
> For the moment I've only created 'interop' and 'devel' as we don't
> yet have any rST files for 'user', 'system' or 'specs'.
>
> One slightly awkward mismatch between how Sphinx naturally wants
> to work and our requirements is that when Sphinx generates a
> documentation set all in one go it creates hyperlinks between
> all the docs, they all appear in a single top level table of
> contents, and so on. But for QEMU's docs we don't want to
> ship the "devel" manual to end-users. I've taken an approach
> suggested to me on sphinx-users
> (https://www.mail-archive.com/sphinx-users@googlegroups.com/msg03224.html)
> where we run Sphinx once per manual, and treat them as
> entirely separate documents. The config/tooling in this patchset
> also supports building everything in a single run, for compatibility
> with third-party docs sites like readthedocs.org.
>
> To see the results:
>
> What you get in the docs/ subdir of your build directory
> when you do a local build:
>  http://people.linaro.org/~peter.maydell/build-dir-docs/
> (follow the links to 'devel' and 'interop' for the two manuals)
>
> What we'll ship in 'make install' in /usr/local/share/doc/qemu/
> http://people.linaro.org/~peter.maydell/installed-docs/
> (should be same as the build dir except we don't ship 'devel')
>
> What you get with a standalone single-run docs build:
>  http://people.linaro.org/~peter.maydell/standalone-docs/index.html
>
> These use the default 'alabaster' theme from Sphinx. I
> also experimented with the 'read_the_docs' theme, which I
> do think looks nicer. Unfortunately it also requires the
> docs we install to include about 3MB of TrueType font files
> per manual, which is awkward licensing-wise as the TTFs are
> under the Open Font License and it's not completely clear to
> me that it's OK to ship those to use with a doc file that is
> GPLed. Alabaster doesn't ship fonts, which sidesteps both
> those problems.
>
> Other notes:
>  * this does not build the two .rst files that are directly
>in docs/ (cpu-hotplug.rst and pr-manager.rst) -- we should
>move these to whichever of the five manuals is the best place
>  * I do have some prototype patches which integrate the kernel's
>kerneldoc Sphinx extension to parse doc comments in source
>code. I haven't included them here because I think the 'devel'
>manual is the lowest priority of the five. They might be
>useful if we want to try things like building documentation
>of supported machine models from in-code comments/etc, though.
>  * as noted in a previous email thread, the configure changes
>now mean that building docs depends on build-sphinx being
>available, so this is a new build-dep for --enable-docs.
>
> thanks
> -- PMM
>
> Peter Maydell (11):
>   docs/cpu-hotplug.rst: Fix rST markup issues
>   docs: Convert memory.txt to rst format
>   docs: Commit initial files from sphinx-quickstart
>   docs/conf.py: Disable unused _static directory
>   docs/conf.py: Configure the 'alabaster' theme
>   docs/conf.py: Don't include rST sources in HTML build
>   docs/conf.py: Disable option warnings
>   Separate conf.py for each manual we want
>   Makefile, configure: Support building rST documentation
>   Makefile: Abstract out "identify the pkgversion" code
>   docs/conf.py: Don't hard-code QEMU version
>
>  configure |   4 +-
>  Makefile  |  78 +++---
>  docs/conf.py  | 215 ++
>  docs/cpu-hotplug.rst  |   2 +-
>  docs/devel/conf.py|  15 ++
>  docs/devel/index.rst  |  21 +++
>  docs/devel/{memory.txt => memory.rst} | 128 ---
>  docs/index.rst|  15 ++
>  docs/interop/conf.py  |  15 ++
>  docs/interop/index.rst|  18 +++
>  10 files changed, 430 insertions(+), 81 deletions(-)
>  create mode 100644 docs/conf.py
>  create mode 100644 docs/de

[Qemu-devel] [PATCH v3 7/9] tests/tcg: target/mips: Add tests for MSA interleave instructions

2019-02-14 Thread Aleksandar Markovic
From: Aleksandar Markovic 

Add tests for MSA interleave instructions. This includes following
instructions:

* ILVEV.B - interleave even (bytes)
* ILVEV.H - interleave even (halfwords)
* ILVEV.W - interleave even (words)
* ILVEV.D - interleave even (doublewords)
* ILVOD.B - interleave odd (bytes)
* ILVOD.H - interleave odd (halfwords)
* ILVOD.W - interleave odd (words)
* ILVOD.D - interleave odd (doublewords)
* ILVL.B - interleave left (bytes)
* ILVL.H - interleave left (halfwords)
* ILVL.W - interleave left (words)
* ILVL.D - interleave left (doublewords)
* ILVR.B - interleave right (bytes)
* ILVR.H - interleave right (halfwords)
* ILVR.W - interleave right (words)
* ILVR.D - interleave right (doublewords)

Each test consists of 80 test cases, so altogether there are 1280
test cases.

Signed-off-by: Aleksandar Markovic 
---
 .../user/ase/msa/interleave/test_msa_ilvev_b.c | 153 +
 .../user/ase/msa/interleave/test_msa_ilvev_d.c | 153 +
 .../user/ase/msa/interleave/test_msa_ilvev_h.c | 153 +
 .../user/ase/msa/interleave/test_msa_ilvev_w.c | 153 +
 .../mips/user/ase/msa/interleave/test_msa_ilvl_b.c | 153 +
 .../mips/user/ase/msa/interleave/test_msa_ilvl_d.c | 153 +
 .../mips/user/ase/msa/interleave/test_msa_ilvl_h.c | 153 +
 .../mips/user/ase/msa/interleave/test_msa_ilvl_w.c | 153 +
 .../user/ase/msa/interleave/test_msa_ilvod_b.c | 153 +
 .../user/ase/msa/interleave/test_msa_ilvod_d.c | 153 +
 .../user/ase/msa/interleave/test_msa_ilvod_h.c | 153 +
 .../user/ase/msa/interleave/test_msa_ilvod_w.c | 153 +
 .../mips/user/ase/msa/interleave/test_msa_ilvr_b.c | 153 +
 .../mips/user/ase/msa/interleave/test_msa_ilvr_d.c | 153 +
 .../mips/user/ase/msa/interleave/test_msa_ilvr_h.c | 153 +
 .../mips/user/ase/msa/interleave/test_msa_ilvr_w.c | 153 +
 16 files changed, 2448 insertions(+)
 create mode 100644 tests/tcg/mips/user/ase/msa/interleave/test_msa_ilvev_b.c
 create mode 100644 tests/tcg/mips/user/ase/msa/interleave/test_msa_ilvev_d.c
 create mode 100644 tests/tcg/mips/user/ase/msa/interleave/test_msa_ilvev_h.c
 create mode 100644 tests/tcg/mips/user/ase/msa/interleave/test_msa_ilvev_w.c
 create mode 100644 tests/tcg/mips/user/ase/msa/interleave/test_msa_ilvl_b.c
 create mode 100644 tests/tcg/mips/user/ase/msa/interleave/test_msa_ilvl_d.c
 create mode 100644 tests/tcg/mips/user/ase/msa/interleave/test_msa_ilvl_h.c
 create mode 100644 tests/tcg/mips/user/ase/msa/interleave/test_msa_ilvl_w.c
 create mode 100644 tests/tcg/mips/user/ase/msa/interleave/test_msa_ilvod_b.c
 create mode 100644 tests/tcg/mips/user/ase/msa/interleave/test_msa_ilvod_d.c
 create mode 100644 tests/tcg/mips/user/ase/msa/interleave/test_msa_ilvod_h.c
 create mode 100644 tests/tcg/mips/user/ase/msa/interleave/test_msa_ilvod_w.c
 create mode 100644 tests/tcg/mips/user/ase/msa/interleave/test_msa_ilvr_b.c
 create mode 100644 tests/tcg/mips/user/ase/msa/interleave/test_msa_ilvr_d.c
 create mode 100644 tests/tcg/mips/user/ase/msa/interleave/test_msa_ilvr_h.c
 create mode 100644 tests/tcg/mips/user/ase/msa/interleave/test_msa_ilvr_w.c

diff --git a/tests/tcg/mips/user/ase/msa/interleave/test_msa_ilvev_b.c 
b/tests/tcg/mips/user/ase/msa/interleave/test_msa_ilvev_b.c
new file mode 100644
index 000..5cf8627
--- /dev/null
+++ b/tests/tcg/mips/user/ase/msa/interleave/test_msa_ilvev_b.c
@@ -0,0 +1,153 @@
+/*
+ *  Test program for MSA instruction ILVEV.B
+ *
+ *  Copyright (C) 2018  Wave Computing, Inc.
+ *  Copyright (C) 2018  Aleksandar Markovic 
+ *
+ *  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 .
+ *
+ */
+
+#include 
+#include 
+
+#include "../../../../include/wrappers_msa.h"
+#include "../../../../include/test_inputs.h"
+#include "../../../../include/test_utils.h"
+
+#define TEST_COUNT_TOTAL (\
+(PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \
+(RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT))
+
+
+int32_t main(void)
+{
+char *instruction_name = "*ILVEV.B";
+int32_t ret;
+uint32_t i, j;
+  

[Qemu-devel] [PATCH v3 9/9] tests/tcg: target/mips: Add tests for MSA logic instructions

2019-02-14 Thread Aleksandar Markovic
From: Aleksandar Markovic 

Add tests for MSA logic instructions. This includes following
instructions:

* AND.V - logical AND
* NOR.V - logical NOR
* OR.V - logical OR
* XOR.V - logical XOR

Each test consists of 80 test cases, so altogether there are 320
test cases.

Signed-off-by: Aleksandar Markovic 
---
 tests/tcg/mips/user/ase/msa/logic/test_msa_and_v.c | 153 +
 tests/tcg/mips/user/ase/msa/logic/test_msa_nor_v.c | 153 +
 tests/tcg/mips/user/ase/msa/logic/test_msa_or_v.c  | 153 +
 tests/tcg/mips/user/ase/msa/logic/test_msa_xor_v.c | 153 +
 4 files changed, 612 insertions(+)
 create mode 100644 tests/tcg/mips/user/ase/msa/logic/test_msa_and_v.c
 create mode 100644 tests/tcg/mips/user/ase/msa/logic/test_msa_nor_v.c
 create mode 100644 tests/tcg/mips/user/ase/msa/logic/test_msa_or_v.c
 create mode 100644 tests/tcg/mips/user/ase/msa/logic/test_msa_xor_v.c

diff --git a/tests/tcg/mips/user/ase/msa/logic/test_msa_and_v.c 
b/tests/tcg/mips/user/ase/msa/logic/test_msa_and_v.c
new file mode 100644
index 000..51b256f
--- /dev/null
+++ b/tests/tcg/mips/user/ase/msa/logic/test_msa_and_v.c
@@ -0,0 +1,153 @@
+/*
+ *  Test program for MSA instruction AND.V
+ *
+ *  Copyright (C) 2018  Wave Computing, Inc.
+ *  Copyright (C) 2018  Aleksandar Markovic 
+ *
+ *  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 .
+ *
+ */
+
+#include 
+#include 
+
+#include "../../../../include/wrappers_msa.h"
+#include "../../../../include/test_inputs.h"
+#include "../../../../include/test_utils.h"
+
+#define TEST_COUNT_TOTAL (\
+(PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \
+(RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT))
+
+
+int32_t main(void)
+{
+char *instruction_name = "AND.V";
+int32_t ret;
+uint32_t i, j;
+struct timeval start, end;
+double elapsed_time;
+
+uint64_t b128_result[TEST_COUNT_TOTAL][2];
+uint64_t b128_expect[TEST_COUNT_TOTAL][2] = {
+{ 0xULL, 0xULL, },/*   0  */
+{ 0xULL, 0xULL, },
+{ 0xULL, 0xULL, },
+{ 0xULL, 0xULL, },
+{ 0xULL, 0xULL, },
+{ 0xULL, 0xULL, },
+{ 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, },
+{ 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, },
+{ 0xULL, 0xULL, },/*   8  */
+{ 0xULL, 0xULL, },
+{ 0xULL, 0xULL, },
+{ 0xULL, 0xULL, },
+{ 0xULL, 0xULL, },
+{ 0xULL, 0xULL, },
+{ 0xULL, 0xULL, },
+{ 0xULL, 0xULL, },
+{ 0xULL, 0xULL, },/*  16  */
+{ 0xULL, 0xULL, },
+{ 0xULL, 0xULL, },
+{ 0xULL, 0xULL, },
+{ 0xULL, 0xULL, },
+{ 0xULL, 0xULL, },
+{ 0xa28a28a28a28a28aULL, 0x28a28a28a28a28a2ULL, },
+{ 0x0820820820820820ULL, 0x8208208208208208ULL, },
+{ 0xULL, 0xULL, },/*  24  */
+{ 0xULL, 0xULL, },
+{ 0xULL, 0xULL, },
+{ 0xULL, 0xULL, },
+{ 0xULL, 0xULL, },
+{ 0xULL, 0xULL, },
+{ 0x4104104104104104ULL, 0x1041041041041041ULL, },
+{ 0x1451451451451451ULL, 0x4514514514514514ULL, },
+{ 0xULL, 0xULL, },/*  32  */
+{ 0xULL, 0xULL, },
+{ 0xULL, 0xULL, },
+{ 0xULL, 0xULL, },
+{ 0xULL, 0xULL, },
+{ 0x00

[Qemu-devel] [PATCH v3 2/9] tests/tcg: target/mips: Add a header with test inputs

2019-02-14 Thread Aleksandar Markovic
From: Aleksandar Markovic 

The file tests/tcg/mips/include/test_inputs.h is planned to
contain various test inputs. For now, it contains 64 128-bit
pattern inputs (alternating groups od ones and zeroes) and
16 128-bit random inputs.

Signed-off-by: Aleksandar Markovic 
---
 tests/tcg/mips/include/test_inputs.h | 122 +++
 1 file changed, 122 insertions(+)
 create mode 100644 tests/tcg/mips/include/test_inputs.h

diff --git a/tests/tcg/mips/include/test_inputs.h 
b/tests/tcg/mips/include/test_inputs.h
new file mode 100644
index 000..c173d58
--- /dev/null
+++ b/tests/tcg/mips/include/test_inputs.h
@@ -0,0 +1,122 @@
+/*
+ *  Header file for pattern and random test inputs
+ *
+ *  Copyright (C) 2018  Wave Computing, Inc.
+ *  Copyright (C) 2018  Aleksandar Markovic 
+ *
+ *  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 .
+ *
+ */
+
+#ifndef TEST_INPUTS_H
+#define TEST_INPUTS_H
+
+#include 
+
+
+#define PATTERN_INPUTS_COUNT  64
+#define PATTERN_INPUTS_SHORT_COUNT 8
+
+uint64_t b128_pattern[PATTERN_INPUTS_COUNT][2] = {
+{ 0xULL, 0xULL, },   /*   0 */
+{ 0xULL, 0xULL, },
+{ 0xULL, 0xULL, },
+{ 0xULL, 0xULL, },
+{ 0xULL, 0xULL, },
+{ 0xULL, 0xULL, },
+{ 0xE38E38E38E38E38EULL, 0x38E38E38E38E38E3ULL, },
+{ 0x1C71C71C71C71C71ULL, 0xC71C71C71C71C71CULL, },
+{ 0xF0F0F0F0F0F0F0F0ULL, 0xF0F0F0F0F0F0F0F0ULL, },   /*   8 */
+{ 0x0F0F0F0F0F0F0F0FULL, 0x0F0F0F0F0F0F0F0FULL, },
+{ 0xF83E0F83E0F83E0FULL, 0x83E0F83E0F83E0F8ULL, },
+{ 0x07C1F07C1F07C1F0ULL, 0x7C1F07C1F07C1F07ULL, },
+{ 0xFC0FC0FC0FC0FC0FULL, 0xC0FC0FC0FC0FC0FCULL, },
+{ 0x03F03F03F03F03F0ULL, 0x3F03F03F03F03F03ULL, },
+{ 0xFE03F80FE03F80FEULL, 0x03F80FE03F80FE03ULL, },
+{ 0x01FC07F01FC07F01ULL, 0xFC07F01FC07F01FCULL, },
+{ 0xFF00FF00FF00FF00ULL, 0xFF00FF00FF00FF00ULL, },   /*  16 */
+{ 0x00FF00FF00FF00FFULL, 0x00FF00FF00FF00FFULL, },
+{ 0xFF803FE00FF803FEULL, 0x00FF803FE00FF803ULL, },
+{ 0x007FC01FF007FC01ULL, 0xFF007FC01FF007FCULL, },
+{ 0xFFC00FFC00FFC00FULL, 0xFC00FFC00FFC00FFULL, },
+{ 0x003FF003FF003FF0ULL, 0x03FF003FF003FF00ULL, },
+{ 0xFFE003FF800FFE00ULL, 0x3FF800FFE003FF80ULL, },
+{ 0x001FFC007FF001FFULL, 0xC007FF001FFC007FULL, },
+{ 0xFFF000FFF000FFF0ULL, 0x00FFF000FFF000FFULL, },   /*  24 */
+{ 0x000FFF000FFF000FULL, 0xFF000FFF000FFF00ULL, },
+{ 0xFFF8003FFE000FFFULL, 0x8003FFE000FFF800ULL, },
+{ 0x0007FFC001FFF000ULL, 0x7FFC001FFF0007FFULL, },
+{ 0xFFFC000FFFC000FFULL, 0xFC000FFFC000FFFCULL, },
+{ 0x0003FFF0003FFF00ULL, 0x03FFF0003FFF0003ULL, },
+{ 0xFFFE0003FFF8000FULL, 0xFFE0003FFF8000FFULL, },
+{ 0x0001FFFC0007FFF0ULL, 0x001FFFC0007FFF00ULL, },
+{ 0xULL, 0xULL, },   /*  32 */
+{ 0xULL, 0xULL, },
+{ 0x80003FFFE000ULL, 0x080003FFFE00ULL, },
+{ 0x7FFFC0001FFFULL, 0xF7FFFC0001FFULL, },
+{ 0xCC00ULL, 0x00CCULL, },
+{ 0x33FFULL, 0xFF33ULL, },
+{ 0xE380ULL, 0x000E3FFFULL, },
+{ 0x1C7FULL, 0xFFF1C000ULL, },
+{ 0xF0F0ULL, 0xF0FFULL, },   /*  40 */
+{ 0x0F0FULL, 0x0F00ULL, },
+{ 0xF83EULL, 0x0F83ULL, },
+{ 0x07C1ULL, 0xF07CULL, },
+{ 0xFC0FULL, 0xC0FCULL, },
+{ 0x03F0ULL, 0x3F03ULL, },
+{ 0xFE03ULL, 0xF80FE000ULL, },
+{ 0x01FCULL, 0x07F01FFFULL, },
+{ 0xFF00ULL, 0xFF00FF00ULL, },   /*  48 */
+{ 0x00FFULL, 0x00FF00FFULL, },
+{ 0xFF803FFFULL, 0xFFE00FF8ULL, },
+{ 0x007FC000ULL, 0x001FF007ULL, },
+{ 0xFFC00FFFULL, 0xFFFC00FFULL, },
+{ 0x003FF000ULL, 0x0003FF00ULL, },
+{ 0xFFE003FFULL, 0x800FULL, },
+{ 0x001FFC00ULL, 0x7FF0ULL, },
+{ 0xFFF000FFULL, 0xF000ULL, },   /*  56 */
+{ 0x000F

[Qemu-devel] [PATCH v3 4/9] tests/tcg: target/mips: Add wrappers for MSA bit counting instructions

2019-02-14 Thread Aleksandar Markovic
From: Aleksandar Markovic 

Add a header that contains wrappers around MSA instructions assembler
invocations. For now, only bit counting instructions (NLOC, NLZC, and
PCNT; each in four data format flavors) are supported.

Signed-off-by: Aleksandar Markovic 
---
 tests/tcg/mips/include/wrappers_msa.h | 57 +++
 1 file changed, 57 insertions(+)
 create mode 100644 tests/tcg/mips/include/wrappers_msa.h

diff --git a/tests/tcg/mips/include/wrappers_msa.h 
b/tests/tcg/mips/include/wrappers_msa.h
new file mode 100644
index 000..8f8d00b
--- /dev/null
+++ b/tests/tcg/mips/include/wrappers_msa.h
@@ -0,0 +1,57 @@
+/*
+ *  Header file for wrappers around MSA instructions assembler invocations
+ *
+ *  Copyright (C) 2018  Wave Computing, Inc.
+ *  Copyright (C) 2018  Aleksandar Markovic 
+ *
+ *  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 .
+ *
+ */
+
+#ifndef WRAPPERS_MSA_H
+#define WRAPPERS_MSA_H
+
+
+#define DO_MSA__WD__WS(suffix, mnemonic)   \
+static inline void do_msa_##suffix(void *input, void *output)  \
+{  \
+   __asm__ volatile (  \
+  "move $t0, %0\n\t"   \
+  "ld.d $w11, 0($t0)\n\t"  \
+  #mnemonic " $w10, $w11\n\t"  \
+  "move $t0, %1\n\t"   \
+  "st.d $w10, 0($t0)\n\t"  \
+  :\
+  : "r" (input), "r" (output)  \
+  : "t0", "memory" \
+   );  \
+}
+
+DO_MSA__WD__WS(NLOC_B, nloc.b)
+DO_MSA__WD__WS(NLOC_H, nloc.h)
+DO_MSA__WD__WS(NLOC_W, nloc.w)
+DO_MSA__WD__WS(NLOC_D, nloc.d)
+
+DO_MSA__WD__WS(NLZC_B, nlzc.b)
+DO_MSA__WD__WS(NLZC_H, nlzc.h)
+DO_MSA__WD__WS(NLZC_W, nlzc.w)
+DO_MSA__WD__WS(NLZC_D, nlzc.d)
+
+DO_MSA__WD__WS(PCNT_B, pcnt.b)
+DO_MSA__WD__WS(PCNT_H, pcnt.h)
+DO_MSA__WD__WS(PCNT_W, pcnt.w)
+DO_MSA__WD__WS(PCNT_D, pcnt.d)
+
+
+#endif
-- 
2.7.4




[Qemu-devel] [PATCH v3 3/9] tests/tcg: target/mips: Add a header with test utilities

2019-02-14 Thread Aleksandar Markovic
From: Aleksandar Markovic 

Add a header that contains test utilities. For now, it contains
only a function for checking and printing test results for bit
counting and similar MSA instructions.

Signed-off-by: Aleksandar Markovic 
---
 tests/tcg/mips/include/test_utils.h | 84 +
 1 file changed, 84 insertions(+)
 create mode 100644 tests/tcg/mips/include/test_utils.h

diff --git a/tests/tcg/mips/include/test_utils.h 
b/tests/tcg/mips/include/test_utils.h
new file mode 100644
index 000..03f3191
--- /dev/null
+++ b/tests/tcg/mips/include/test_utils.h
@@ -0,0 +1,84 @@
+/*
+ *  Header file for test utilities
+ *
+ *  Copyright (C) 2018  Wave Computing, Inc.
+ *  Copyright (C) 2018  Aleksandar Markovic 
+ *
+ *  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 .
+ *
+ */
+
+#ifndef TEST_UTILS_H
+#define TEST_UTILS_H
+
+#include 
+#include 
+#include 
+#include 
+
+#define PRINT_RESULTS 0
+
+static inline int32_t check_results(char *instruction_name,
+uint32_t test_count,
+double elapsed_time,
+uint64_t *b128_result,
+uint64_t *b128_expect)
+{
+#if PRINT_RESULTS
+
+uint32_t i;
+printf("\n");
+for (i = 0; i < test_count; i++) {
+uint64_t a, b;
+memcpy(&a, (b128_result + 2 * i), 8);
+memcpy(&b, (b128_result + 2 * i + 1), 8);
+if (i % 8 != 0) {
+printf("{ 0x%016llxULL, 0x%016llxULL, },\n", a, b);
+} else {
+printf("{ 0x%016llxULL, 0x%016llxULL, },/* %3d  */\n",
+   a, b, i);
+}
+}
+printf("\n");
+
+return 0;
+
+#else
+
+uint32_t i;
+uint32_t pass_count = 0;
+uint32_t fail_count = 0;
+
+printf("%s:   ", instruction_name);
+for (i = 0; i < test_count; i++) {
+if (b128_result[i] == b128_expect[i]) {
+pass_count++;
+} else {
+fail_count++;
+}
+}
+
+printf("PASS: %3d   FAIL: %3d   elapsed time: %5.2f ms\n",
+   pass_count, fail_count, elapsed_time);
+
+if (fail_count > 0) {
+return -1;
+} else {
+return 0;
+}
+
+#endif
+}
+
+#endif
-- 
2.7.4




[Qemu-devel] [PATCH v3 6/9] tests/tcg: target/mips: Add wrappers for MSA interleave instructions

2019-02-14 Thread Aleksandar Markovic
From: Aleksandar Markovic 

Add wrappers for MSA interleave instructions.

Signed-off-by: Aleksandar Markovic 
---
 tests/tcg/mips/include/wrappers_msa.h | 39 +++
 1 file changed, 39 insertions(+)

diff --git a/tests/tcg/mips/include/wrappers_msa.h 
b/tests/tcg/mips/include/wrappers_msa.h
index 8f8d00b..3017ed5 100644
--- a/tests/tcg/mips/include/wrappers_msa.h
+++ b/tests/tcg/mips/include/wrappers_msa.h
@@ -54,4 +54,43 @@ DO_MSA__WD__WS(PCNT_W, pcnt.w)
 DO_MSA__WD__WS(PCNT_D, pcnt.d)
 
 
+#define DO_MSA__WD__WS_WT(suffix, mnemonic)\
+static inline void do_msa_##suffix(void *input1, void *input2, \
+   void *output)   \
+{  \
+   __asm__ volatile (  \
+  "move $t0, %0\n\t"   \
+  "ld.d $w11, 0($t0)\n\t"  \
+  "move $t0, %1\n\t"   \
+  "ld.d $w12, 0($t0)\n\t"  \
+  #mnemonic " $w10, $w11, $w12\n\t"\
+  "move $t0, %2\n\t"   \
+  "st.d $w10, 0($t0)\n\t"  \
+  :\
+  : "r" (input1), "r" (input2), "r" (output)   \
+  : "t0", "memory" \
+   );  \
+}
+
+DO_MSA__WD__WS_WT(ILVEV_B, ilvev.b)
+DO_MSA__WD__WS_WT(ILVEV_H, ilvev.h)
+DO_MSA__WD__WS_WT(ILVEV_W, ilvev.w)
+DO_MSA__WD__WS_WT(ILVEV_D, ilvev.d)
+
+DO_MSA__WD__WS_WT(ILVOD_B, ilvod.b)
+DO_MSA__WD__WS_WT(ILVOD_H, ilvod.h)
+DO_MSA__WD__WS_WT(ILVOD_W, ilvod.w)
+DO_MSA__WD__WS_WT(ILVOD_D, ilvod.d)
+
+DO_MSA__WD__WS_WT(ILVL_B, ilvl.b)
+DO_MSA__WD__WS_WT(ILVL_H, ilvl.h)
+DO_MSA__WD__WS_WT(ILVL_W, ilvl.w)
+DO_MSA__WD__WS_WT(ILVL_D, ilvl.d)
+
+DO_MSA__WD__WS_WT(ILVR_B, ilvr.b)
+DO_MSA__WD__WS_WT(ILVR_H, ilvr.h)
+DO_MSA__WD__WS_WT(ILVR_W, ilvr.w)
+DO_MSA__WD__WS_WT(ILVR_D, ilvr.d)
+
+
 #endif
-- 
2.7.4




[Qemu-devel] [PATCH v3 8/9] tests/tcg: target/mips: Add wrappers for MSA logic instructions

2019-02-14 Thread Aleksandar Markovic
From: Aleksandar Markovic 

Add wrappers for MSA logic instructions.

Signed-off-by: Aleksandar Markovic 
---
 tests/tcg/mips/include/wrappers_msa.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/tests/tcg/mips/include/wrappers_msa.h 
b/tests/tcg/mips/include/wrappers_msa.h
index 3017ed5..7a77fb9 100644
--- a/tests/tcg/mips/include/wrappers_msa.h
+++ b/tests/tcg/mips/include/wrappers_msa.h
@@ -92,5 +92,10 @@ DO_MSA__WD__WS_WT(ILVR_H, ilvr.h)
 DO_MSA__WD__WS_WT(ILVR_W, ilvr.w)
 DO_MSA__WD__WS_WT(ILVR_D, ilvr.d)
 
+DO_MSA__WD__WS_WT(AND_V, and.v)
+DO_MSA__WD__WS_WT(NOR_V, nor.v)
+DO_MSA__WD__WS_WT(OR_V, or.v)
+DO_MSA__WD__WS_WT(XOR_V, xor.v)
+
 
 #endif
-- 
2.7.4




[Qemu-devel] [PATCH v3 1/9] tests/tcg: target/mips: Remove an unnecessary file

2019-02-14 Thread Aleksandar Markovic
From: Aleksandar Markovic 

Remove a file that was added long time ago by mistake. The commit
that introduced this file was commit d70080c4 (from 2012).

Acked-by: Alex Bennée 
Reviewed-by: Eric Blake 
Signed-off-by: Aleksandar Markovic 
---
 tests/tcg/mips/mips64-dspr2/.directory | 2 --
 1 file changed, 2 deletions(-)
 delete mode 100644 tests/tcg/mips/mips64-dspr2/.directory

diff --git a/tests/tcg/mips/mips64-dspr2/.directory 
b/tests/tcg/mips/mips64-dspr2/.directory
deleted file mode 100644
index c75a914..000
--- a/tests/tcg/mips/mips64-dspr2/.directory
+++ /dev/null
@@ -1,2 +0,0 @@
-[Dolphin]
-Timestamp=2012,8,3,16,41,52
-- 
2.7.4




[Qemu-devel] [PATCH v3 5/9] tests/tcg: target/mips: Add tests for MSA bit counting instructions

2019-02-14 Thread Aleksandar Markovic
From: Aleksandar Markovic 

Add tests for MSA bit counting instructions. This includes following
instructions:

* NLOC.B - number of leading ones (bytes)
* NLOC.H - number of leading ones (halfwords)
* NLOC.W - number of leading ones (words)
* NLOC.D - number of leading ones (doublewords)
* NLZC.B - number of leading zeros (bytes)
* NLZC.H - number of leading zeros (halfwords)
* NLZC.W - number of leading zeros (words)
* NLZC.D - number of leading zeros (doublewords)
* PCNT.B - population count / number of ones (bytes)
* PCNT.H - population count / number of ones (halfwords)
* PCNT.W - population count / number of ones (words)
* PCNT.D - population count / number of ones (doublewords)

Each test consists of 80 test cases, so altogether there are 960 test
cases.

Signed-off-by: Aleksandar Markovic 
---
 .../user/ase/msa/bit-counting/test_msa_nloc_b.c| 144 +
 .../user/ase/msa/bit-counting/test_msa_nloc_d.c| 144 +
 .../user/ase/msa/bit-counting/test_msa_nloc_h.c| 144 +
 .../user/ase/msa/bit-counting/test_msa_nloc_w.c| 144 +
 .../user/ase/msa/bit-counting/test_msa_nlzc_b.c| 144 +
 .../user/ase/msa/bit-counting/test_msa_nlzc_d.c| 144 +
 .../user/ase/msa/bit-counting/test_msa_nlzc_h.c| 144 +
 .../user/ase/msa/bit-counting/test_msa_nlzc_w.c| 144 +
 .../user/ase/msa/bit-counting/test_msa_pcnt_b.c| 144 +
 .../user/ase/msa/bit-counting/test_msa_pcnt_d.c| 144 +
 .../user/ase/msa/bit-counting/test_msa_pcnt_h.c| 144 +
 .../user/ase/msa/bit-counting/test_msa_pcnt_w.c| 144 +
 12 files changed, 1728 insertions(+)
 create mode 100644 tests/tcg/mips/user/ase/msa/bit-counting/test_msa_nloc_b.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit-counting/test_msa_nloc_d.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit-counting/test_msa_nloc_h.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit-counting/test_msa_nloc_w.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit-counting/test_msa_nlzc_b.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit-counting/test_msa_nlzc_d.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit-counting/test_msa_nlzc_h.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit-counting/test_msa_nlzc_w.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit-counting/test_msa_pcnt_b.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit-counting/test_msa_pcnt_d.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit-counting/test_msa_pcnt_h.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit-counting/test_msa_pcnt_w.c

diff --git a/tests/tcg/mips/user/ase/msa/bit-counting/test_msa_nloc_b.c 
b/tests/tcg/mips/user/ase/msa/bit-counting/test_msa_nloc_b.c
new file mode 100644
index 000..eb46290
--- /dev/null
+++ b/tests/tcg/mips/user/ase/msa/bit-counting/test_msa_nloc_b.c
@@ -0,0 +1,144 @@
+/*
+ *  Test program for MSA instruction NLOC.B
+ *
+ *  Copyright (C) 2018  Wave Computing, Inc.
+ *  Copyright (C) 2018  Aleksandar Markovic 
+ *
+ *  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 .
+ *
+ */
+
+#include 
+#include 
+
+#include "../../../include/wrappers_msa.h"
+#include "../../../include/test_inputs.h"
+#include "../../../include/test_utils.h"
+
+#define TEST_COUNT_TOTAL (PATTERN_INPUTS_COUNT + RANDOM_INPUTS_COUNT)
+
+
+int32_t main(void)
+{
+char *instruction_name = "NLOC.B";
+int32_t ret;
+uint32_t i;
+struct timeval start, end;
+double elapsed_time;
+
+uint64_t b128_result[TEST_COUNT_TOTAL][2];
+uint64_t b128_expect[TEST_COUNT_TOTAL][2] = {
+{ 0x0808080808080808ULL, 0x0808080808080808ULL, },/*   0  */
+{ 0xULL, 0xULL, },
+{ 0x0101010101010101ULL, 0x0101010101010101ULL, },
+{ 0xULL, 0xULL, },
+{ 0x0202020202020202ULL, 0x0202020202020202ULL, },
+{ 0xULL, 0xULL, },
+{ 0x0301000301000301ULL, 0x0003010003010003ULL, },
+{ 0x0202ULL, 0x02020200ULL, },
+{ 0x0404040404040404ULL, 0x0404040404040404ULL, },/*   8  */
+{ 0xULL, 0xULL, },
+{ 0x050

[Qemu-devel] [PATCH v3 0/9] target/mips: Add MSA ASE tests

2019-02-14 Thread Aleksandar Markovic
From: Aleksandar Markovic 

v2->v3:

  - minor cosmetic changes
  - added wrappers and tests for MSA logic instructions

v1->v2:

  - added refference to the original commit in patch #1
  - corrected copy-and-paste error in comments in 12 new source files
  - renamed "bit_counting" subdirectory to "bit-counting"
  - added wrappers and tests for MSA interleave instructions

This series begins to add unit tests (aka tcg tests) for MIPS'
MSA ASE. More tests and related test infrastructure will be added
in subsequent version of this series.

There are several checkpatch warnings that are all false positives
for given circumstances.

Aleksandar Markovic (9):
  tests/tcg: target/mips: Remove an unnecessary file
  tests/tcg: target/mips: Add a header with test inputs
  tests/tcg: target/mips: Add a header with test utilities
  tests/tcg: target/mips: Add wrappers for MSA bit counting instructions
  tests/tcg: target/mips: Add tests for MSA bit counting instructions
  tests/tcg: target/mips: Add wrappers for MSA interleave instructions
  tests/tcg: target/mips: Add tests for MSA interleave instructions
  tests/tcg: target/mips: Add wrappers for MSA logic instructions
  tests/tcg: target/mips: Add tests for MSA logic instructions

 tests/tcg/mips/include/test_inputs.h   | 122 
 tests/tcg/mips/include/test_utils.h|  84 +++
 tests/tcg/mips/include/wrappers_msa.h  | 101 ++
 tests/tcg/mips/mips64-dspr2/.directory |   2 -
 .../user/ase/msa/bit-counting/test_msa_nloc_b.c| 144 +++
 .../user/ase/msa/bit-counting/test_msa_nloc_d.c| 144 +++
 .../user/ase/msa/bit-counting/test_msa_nloc_h.c| 144 +++
 .../user/ase/msa/bit-counting/test_msa_nloc_w.c| 144 +++
 .../user/ase/msa/bit-counting/test_msa_nlzc_b.c| 144 +++
 .../user/ase/msa/bit-counting/test_msa_nlzc_d.c| 144 +++
 .../user/ase/msa/bit-counting/test_msa_nlzc_h.c| 144 +++
 .../user/ase/msa/bit-counting/test_msa_nlzc_w.c| 144 +++
 .../user/ase/msa/bit-counting/test_msa_pcnt_b.c| 144 +++
 .../user/ase/msa/bit-counting/test_msa_pcnt_d.c| 144 +++
 .../user/ase/msa/bit-counting/test_msa_pcnt_h.c| 144 +++
 .../user/ase/msa/bit-counting/test_msa_pcnt_w.c| 144 +++
 .../user/ase/msa/interleave/test_msa_ilvev_b.c | 153 +
 .../user/ase/msa/interleave/test_msa_ilvev_d.c | 153 +
 .../user/ase/msa/interleave/test_msa_ilvev_h.c | 153 +
 .../user/ase/msa/interleave/test_msa_ilvev_w.c | 153 +
 .../mips/user/ase/msa/interleave/test_msa_ilvl_b.c | 153 +
 .../mips/user/ase/msa/interleave/test_msa_ilvl_d.c | 153 +
 .../mips/user/ase/msa/interleave/test_msa_ilvl_h.c | 153 +
 .../mips/user/ase/msa/interleave/test_msa_ilvl_w.c | 153 +
 .../user/ase/msa/interleave/test_msa_ilvod_b.c | 153 +
 .../user/ase/msa/interleave/test_msa_ilvod_d.c | 153 +
 .../user/ase/msa/interleave/test_msa_ilvod_h.c | 153 +
 .../user/ase/msa/interleave/test_msa_ilvod_w.c | 153 +
 .../mips/user/ase/msa/interleave/test_msa_ilvr_b.c | 153 +
 .../mips/user/ase/msa/interleave/test_msa_ilvr_d.c | 153 +
 .../mips/user/ase/msa/interleave/test_msa_ilvr_h.c | 153 +
 .../mips/user/ase/msa/interleave/test_msa_ilvr_w.c | 153 +
 tests/tcg/mips/user/ase/msa/logic/test_msa_and_v.c | 153 +
 tests/tcg/mips/user/ase/msa/logic/test_msa_nor_v.c | 153 +
 tests/tcg/mips/user/ase/msa/logic/test_msa_or_v.c  | 153 +
 tests/tcg/mips/user/ase/msa/logic/test_msa_xor_v.c | 153 +
 36 files changed, 5095 insertions(+), 2 deletions(-)
 create mode 100644 tests/tcg/mips/include/test_inputs.h
 create mode 100644 tests/tcg/mips/include/test_utils.h
 create mode 100644 tests/tcg/mips/include/wrappers_msa.h
 delete mode 100644 tests/tcg/mips/mips64-dspr2/.directory
 create mode 100644 tests/tcg/mips/user/ase/msa/bit-counting/test_msa_nloc_b.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit-counting/test_msa_nloc_d.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit-counting/test_msa_nloc_h.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit-counting/test_msa_nloc_w.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit-counting/test_msa_nlzc_b.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit-counting/test_msa_nlzc_d.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit-counting/test_msa_nlzc_h.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit-counting/test_msa_nlzc_w.c
 create mode 100644 tests/t

[Qemu-devel] [PATCH v2] hostmem: fix crash when querying empty host-nodes property via QMP

2019-02-14 Thread Igor Mammedov
QEMU will crashes with
 qapi/qobject-output-visitor.c:210: qobject_output_complete: Assertion 
`qov->root && ((&qov->stack)->slh_first == ((void *)0))' failed
when trying to get value of not set hostmem's "host-nodes"
property, HostMemoryBackend::host_nodes bitmap doesn't have
any bits set in it, which leads to find_first_bit() returning
MAX_NODES and consequently to an early return from
host_memory_backend_get_host_nodes() without calling visitor.

Fix it by calling visitor even if "host-nodes" property wasn't
set before exiting from property getter to return valid empty
list.

Signed-off-by: Igor Mammedov 
---
v2:
  * fixup commit message to put emphasis on property instead
local variable host_nodes and make explanation more hopefully
more clear. (Markus Armbruster )
---
 backends/hostmem.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/backends/hostmem.c b/backends/hostmem.c
index 87b19d2111..04baf479a1 100644
--- a/backends/hostmem.c
+++ b/backends/hostmem.c
@@ -88,7 +88,7 @@ host_memory_backend_get_host_nodes(Object *obj, Visitor *v, 
const char *name,
 
 value = find_first_bit(backend->host_nodes, MAX_NODES);
 if (value == MAX_NODES) {
-return;
+goto ret;
 }
 
 *node = g_malloc0(sizeof(**node));
@@ -106,6 +106,7 @@ host_memory_backend_get_host_nodes(Object *obj, Visitor *v, 
const char *name,
 node = &(*node)->next;
 } while (true);
 
+ret:
 visit_type_uint16List(v, name, &host_nodes, errp);
 }
 
-- 
2.18.1




Re: [Qemu-devel] [PATCH] softfloat: Support float_round_to_odd more places

2019-02-14 Thread Alex Bennée


Richard Henderson  writes:

> Previously this was only supported for roundAndPackFloat64.
> Include support in round_canonical, round_to_int, roundAndPackFloat32,
> roundAndPackInt32, roundAndPackInt64, roundAndPackUint64.

If we extend the fp-test case we can exercise these routines:

  ./fp-test f16_roundToInt f32_roundToInt f64_roundToInt -r odd
  >> Testing f16_roundToInt, rounding odd, exact
  Not implemented.
  >> Testing f32_roundToInt, rounding odd, exact
  Not implemented.
  >> Testing f64_roundToInt, rounding odd, exact
  Not implemented.

See 4cb780920 for an example...

>
> This does not include any of the floatx80 routines, as we
> do not have users for that rounding mode there.
>
> Signed-off-by: Richard Henderson 
> ---
>
> David, if you could test this vs your s390 patches, vs real s390
> hardware, that would be lovely.
>
>
> r~
>
> ---
>  fpu/softfloat.c | 40 ++--
>  1 file changed, 38 insertions(+), 2 deletions(-)
>
> diff --git a/fpu/softfloat.c b/fpu/softfloat.c
> index 9132d7a0b0..325c6e4e79 100644
> --- a/fpu/softfloat.c
> +++ b/fpu/softfloat.c
> @@ -696,6 +696,7 @@ static FloatParts sf_canonicalize(FloatParts part, const 
> FloatFmt *parm,
>  static FloatParts round_canonical(FloatParts p, float_status *s,
>const FloatFmt *parm)
>  {
> +const uint64_t frac_lsb = parm->frac_lsb;
>  const uint64_t frac_lsbm1 = parm->frac_lsbm1;
>  const uint64_t round_mask = parm->round_mask;
>  const uint64_t roundeven_mask = parm->roundeven_mask;
> @@ -731,6 +732,10 @@ static FloatParts round_canonical(FloatParts p, 
> float_status *s,
>  inc = p.sign ? round_mask : 0;
>  overflow_norm = !p.sign;
>  break;
> +case float_round_to_odd:
> +overflow_norm = true;
> +inc = frac & frac_lsb ? 0 : frac_lsbm1;
> +break;
>  default:
>  g_assert_not_reached();
>  }
> @@ -778,9 +783,14 @@ static FloatParts round_canonical(FloatParts p, 
> float_status *s,
>  shift64RightJamming(frac, 1 - exp, &frac);
>  if (frac & round_mask) {
>  /* Need to recompute round-to-even.  */
> -if (s->float_rounding_mode == float_round_nearest_even) {
> +switch (s->float_rounding_mode) {
> +case float_round_nearest_even:
>  inc = ((frac & roundeven_mask) != frac_lsbm1
> ? frac_lsbm1 : 0);
> +break;
> +case float_round_to_odd:
> +inc = frac & frac_lsb ? 0 : frac_lsbm1;
> +break;
>  }
>  flags |= float_flag_inexact;
>  frac += inc;
> @@ -1988,6 +1998,9 @@ static FloatParts round_to_int(FloatParts a, int rmode,
>  case float_round_down:
>  one = a.sign;
>  break;
> +case float_round_to_odd:
> +one = true;
> +break;
>  default:
>  g_assert_not_reached();
>  }
> @@ -2021,6 +2034,9 @@ static FloatParts round_to_int(FloatParts a, int rmode,
>  case float_round_down:
>  inc = a.sign ? rnd_mask : 0;
>  break;
> +case float_round_to_odd:
> +inc = a.frac & frac_lsb ? 0 : frac_lsbm1;
> +break;
>  default:
>  g_assert_not_reached();
>  }
> @@ -3314,6 +3330,9 @@ static int32_t roundAndPackInt32(flag zSign, uint64_t 
> absZ, float_status *status
>  case float_round_down:
>  roundIncrement = zSign ? 0x7f : 0;
>  break;
> +case float_round_to_odd:
> +roundIncrement = absZ & 0x80 ? 0 : 0x7f;
> +break;
>  default:
>  abort();
>  }
> @@ -3368,6 +3387,9 @@ static int64_t roundAndPackInt64(flag zSign, uint64_t 
> absZ0, uint64_t absZ1,
>  case float_round_down:
>  increment = zSign && absZ1;
>  break;
> +case float_round_to_odd:
> +increment = !(absZ0 & 1) && absZ1;
> +break;
>  default:
>  abort();
>  }
> @@ -3424,6 +3446,9 @@ static int64_t roundAndPackUint64(flag zSign, uint64_t 
> absZ0,
>  case float_round_down:
>  increment = zSign && absZ1;
>  break;
> +case float_round_to_odd:
> +increment = !(absZ0 & 1) && absZ1;
> +break;
>  default:
>  abort();
>  }
> @@ -3526,6 +3551,8 @@ static float32 roundAndPackFloat32(flag zSign, int 
> zExp, uint32_t zSig,
>  case float_round_down:
>  roundIncrement = zSign ? 0x7f : 0;
>  break;
> +case float_round_to_odd:
> +roundIncrement = zSig & 0x80 ? 0 : 0x7f;
>  default:
>  abort();
>  break;
> @@ -3536,8 +3563,10 @@ static float32 roundAndPackFloat32(flag zSign, int 
> zExp, uint32_t zSig,
>   

Re: [Qemu-devel] [PATCH v2 0/7] ui/cocoa: Use OSX's main loop

2019-02-14 Thread no-reply
Patchew URL: 
https://patchew.org/QEMU/20190214102816.3393-1-peter.mayd...@linaro.org/



Hi,

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

Subject: [Qemu-devel] [PATCH v2 0/7] ui/cocoa: Use OSX's main loop
Message-id: 20190214102816.3393-1-peter.mayd...@linaro.org
Type: series

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 - [tag update]  
patchew/20190212074840.13542-1-richard.hender...@linaro.org -> 
patchew/20190212074840.13542-1-richard.hender...@linaro.org
 - [tag update]  patchew/20190212134758.10514-1-dgilb...@redhat.com -> 
patchew/20190212134758.10514-1-dgilb...@redhat.com
 - [tag update]  patchew/20190214031004.32522-1-stefa...@redhat.com -> 
patchew/20190214031004.32522-1-stefa...@redhat.com
 * [new tag] 
patchew/20190214084939.20640-1-richardw.y...@linux.intel.com -> 
patchew/20190214084939.20640-1-richardw.y...@linux.intel.com
 * [new tag] patchew/20190214093053.1400-1-arm...@redhat.com -> 
patchew/20190214093053.1400-1-arm...@redhat.com
 * [new tag] patchew/20190214102816.3393-1-peter.mayd...@linaro.org -> 
patchew/20190214102816.3393-1-peter.mayd...@linaro.org
Submodule 'capstone' (https://git.qemu.org/git/capstone.git) registered for 
path 'capstone'
Submodule 'dtc' (https://git.qemu.org/git/dtc.git) registered for path 'dtc'
Submodule 'roms/QemuMacDrivers' (https://git.qemu.org/git/QemuMacDrivers.git) 
registered for path 'roms/QemuMacDrivers'
Submodule 'roms/SLOF' (https://git.qemu.org/git/SLOF.git) registered for path 
'roms/SLOF'
Submodule 'roms/ipxe' (https://git.qemu.org/git/ipxe.git) registered for path 
'roms/ipxe'
Submodule 'roms/openbios' (https://git.qemu.org/git/openbios.git) registered 
for path 'roms/openbios'
Submodule 'roms/openhackware' (https://git.qemu.org/git/openhackware.git) 
registered for path 'roms/openhackware'
Submodule 'roms/qemu-palcode' (https://git.qemu.org/git/qemu-palcode.git) 
registered for path 'roms/qemu-palcode'
Submodule 'roms/seabios' (https://git.qemu.org/git/seabios.git/) registered for 
path 'roms/seabios'
Submodule 'roms/seabios-hppa' (https://github.com/hdeller/seabios-hppa.git) 
registered for path 'roms/seabios-hppa'
Submodule 'roms/sgabios' (https://git.qemu.org/git/sgabios.git) registered for 
path 'roms/sgabios'
Submodule 'roms/skiboot' (https://git.qemu.org/git/skiboot.git) registered for 
path 'roms/skiboot'
Submodule 'roms/u-boot' (https://git.qemu.org/git/u-boot.git) registered for 
path 'roms/u-boot'
Submodule 'roms/u-boot-sam460ex' (https://git.qemu.org/git/u-boot-sam460ex.git) 
registered for path 'roms/u-boot-sam460ex'
Submodule 'tests/fp/berkeley-softfloat-3' 
(https://github.com/cota/berkeley-softfloat-3) registered for path 
'tests/fp/berkeley-softfloat-3'
Submodule 'tests/fp/berkeley-testfloat-3' 
(https://github.com/cota/berkeley-testfloat-3) registered for path 
'tests/fp/berkeley-testfloat-3'
Submodule 'ui/keycodemapdb' (https://git.qemu.org/git/keycodemapdb.git) 
registered for path 'ui/keycodemapdb'
Cloning into 'capstone'...
Submodule path 'capstone': checked out 
'22ead3e0bfdb87516656453336160e0a37b066bf'
Cloning into 'dtc'...
Submodule path 'dtc': checked out '88f18909db731a627456f26d779445f84e449536'
Cloning into 'roms/QemuMacDrivers'...
Submodule path 'roms/QemuMacDrivers': checked out 
'90c488d5f4a407342247b9ea869df1c2d9c8e266'
Cloning into 'roms/SLOF'...
Submodule path 'roms/SLOF': checked out 
'a5b428e1c1eae703bdd62a3f527223c291ee3fdc'
Cloning into 'roms/ipxe'...
Submodule path 'roms/ipxe': checked out 
'de4565cbe76ea9f7913a01f331be3ee901bb6e17'
Cloning into 'roms/openbios'...
Submodule path 'roms/openbios': checked out 
'441a84d3a642a10b948369c63f32367e8ff6395b'
Cloning into 'roms/openhackware'...
Submodule path 'roms/openhackware': checked out 
'c559da7c8eec5e45ef1f67978827af6f0b9546f5'
Cloning into 'roms/qemu-palcode'...
Submodule path 'roms/qemu-palcode': checked out 
'51c237d7e20d05100eacadee2f61abc17e6bc097'
Cloning into 'roms/seabios'...
Submodule path 'roms/seabios': checked out 
'a698c8995ffb2838296ec284fe3c4ad33dfca307'
Cloning into 'roms/seabios-hppa'...
Submodule path 'roms/seabios-hppa': checked out 
'1ef99a01572c2581c30e16e6fe69e9ea2ef92ce0'
Cloning into 'roms/sgabios'...
Submodule path 'roms/sgabios': checked out 
'cbaee52287e5f32373181cff50a00b6c4ac9015a'
Cloning into 'roms/skiboot'...
Submodule path 'roms/skiboot': checked out 
'e0ee24c27a172bcf482f6f2bc905e6211c134bcc'
Cloning into 'roms/u-boot'...
Submodule path 'roms/u-boot': checked out 
'd85ca029f257b53a96da6c2fb421e78a003a9943'
Cloning into 'roms/u-boot-sam460ex'...
Submodule path 'roms/u-boot-sam460ex': checked out 
'60b3916f33e617a815973c5a6df77055b2e3a588'
Cloning into 'tests/fp/berkeley-

Re: [Qemu-devel] [PATCH v4 07/18] build: Deal with all of QAPI's .o in qapi/Makefile.objs

2019-02-14 Thread Marc-André Lureau
Hi

On Thu, Feb 14, 2019 at 10:44 AM Markus Armbruster  wrote:
>
> Adding QAPI's .o to util-obj-y, common-obj-y and obj-y is spread over
> three places: Makefile.objs takes care of target-independent generated
> code, Makefile.target of target-dependent generated code, and
> qapi/Makefile.objs of (target-independent) hand-written code.
>
> Do everything in qapi/Makefile.objs.
>
> Suggested-by: Paolo Bonzini 
> Signed-off-by: Markus Armbruster 
> ---
>  Makefile   |  1 -
>  Makefile.objs  | 13 -
>  Makefile.target|  3 +--
>  qapi/Makefile.objs | 19 +++
>  4 files changed, 20 insertions(+), 16 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 53d161b65f..a6de28677f 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -89,7 +89,6 @@ include $(SRC_PATH)/rules.mak
>
>  GENERATED_FILES = qemu-version.h config-host.h qemu-options.def
>
> -#see Makefile.objs for the definition of QAPI_MODULES
>  GENERATED_QAPI_FILES = qapi/qapi-builtin-types.h qapi/qapi-builtin-types.c
>  GENERATED_QAPI_FILES += qapi/qapi-types.h qapi/qapi-types.c
>  GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-types-%.h)
> diff --git a/Makefile.objs b/Makefile.objs
> index bc78e26f55..4a266357a2 100644
> --- a/Makefile.objs
> +++ b/Makefile.objs
> @@ -1,20 +1,7 @@
> -QAPI_MODULES = block-core block char common crypto introspect job migration
> -QAPI_MODULES += misc net rdma rocker run-state sockets tpm trace transaction
> -QAPI_MODULES += ui
> -
>  ###
>  # Common libraries for tools and emulators
>  stub-obj-y = stubs/ crypto/
>  util-obj-y = util/ qobject/ qapi/
> -util-obj-y += qapi/qapi-builtin-types.o
> -util-obj-y += qapi/qapi-types.o
> -util-obj-y += $(QAPI_MODULES:%=qapi/qapi-types-%.o)
> -util-obj-y += qapi/qapi-builtin-visit.o
> -util-obj-y += qapi/qapi-visit.o
> -util-obj-y += $(QAPI_MODULES:%=qapi/qapi-visit-%.o)
> -util-obj-y += qapi/qapi-emit-events.o
> -util-obj-y += qapi/qapi-events.o
> -util-obj-y += $(QAPI_MODULES:%=qapi/qapi-events-%.o)
>
>  chardev-obj-y = chardev/
>  slirp-obj-$(CONFIG_SLIRP) = slirp/
> diff --git a/Makefile.target b/Makefile.target
> index d8af835890..d6ce549388 100644
> --- a/Makefile.target
> +++ b/Makefile.target
> @@ -148,6 +148,7 @@ ifdef CONFIG_SOFTMMU
>  obj-y += arch_init.o cpus.o monitor.o gdbstub.o balloon.o ioport.o numa.o
>  obj-y += qtest.o
>  obj-y += hw/
> +obj-y += qapi/
>  obj-y += memory.o
>  obj-y += memory_mapping.o
>  obj-y += dump.o
> @@ -164,8 +165,6 @@ endif
>
>  GENERATED_FILES += hmp-commands.h hmp-commands-info.h
>
> -obj-y += qapi/qapi-introspect.o
> -
>  endif # CONFIG_SOFTMMU
>
>  dummy := $(call unnest-vars,,obj-y)
> diff --git a/qapi/Makefile.objs b/qapi/Makefile.objs
> index 33906ff321..dacbae 100644
> --- a/qapi/Makefile.objs
> +++ b/qapi/Makefile.objs
> @@ -4,3 +4,22 @@ util-obj-y += string-input-visitor.o string-output-visitor.o
>  util-obj-y += opts-visitor.o qapi-clone-visitor.o
>  util-obj-y += qmp-event.o
>  util-obj-y += qapi-util.o
> +
> +QAPI_MODULES = block-core block char common crypto introspect job migration
> +QAPI_MODULES += misc net rdma rocker run-state sockets tpm trace transaction
> +QAPI_MODULES += ui
> +
> +util-obj-y += qapi-builtin-types.o
> +util-obj-y += qapi-types.o
> +util-obj-y += $(QAPI_MODULES:%=qapi-types-%.o)
> +util-obj-y += qapi-builtin-visit.o
> +util-obj-y += qapi-visit.o
> +util-obj-y += $(QAPI_MODULES:%=qapi-visit-%.o)
> +util-obj-y += qapi-emit-events.o
> +util-obj-y += qapi-events.o
> +util-obj-y += $(QAPI_MODULES:%=qapi-events-%.o)
> +
> +common-obj-y += qapi-commands.o
> +common-obj-y += $(QAPI_MODULES:%=qapi-commands-%.o)

You meant to remove it from /Makefile.objs I suppose?

Other than that,
Reviewed-by: Marc-André Lureau 

> +
> +obj-y += qapi-introspect.o
> --
> 2.17.2
>
>


-- 
Marc-André Lureau



Re: [Qemu-devel] [PATCH] hostmem: fix crash when querying empty host-nodes property via QMP

2019-02-14 Thread Igor Mammedov
On Wed, 13 Feb 2019 14:30:55 +0100
Markus Armbruster  wrote:

> Igor Mammedov  writes:
> 
> > QEMU will crashes with
> >  qapi/qobject-output-visitor.c:210: qobject_output_complete: Assertion 
> > `qov->root && ((&qov->stack)->slh_first == ((void *)0))' failed
> > when trying to get value of empty hostmem.host-nodes property.
> >
> > Fix it by calling visitor even if host-nodes wasn't set
> > before exiting from property getter to return empty list.  
> 
> host-nodes or host_nodes?
> 
> If local variable host_nodes: that one's always set.  The case you fix
> has it set to NULL.

it's about property host-nodes:

  value = find_first_bit(backend->host_nodes, MAX_NODES);  
  if (value == MAX_NODES) {
goto ret;
  }

when no bits set, it exits without visiting being returned list.

I'll send v2 with commit message giving more explanation to make
it clearer.

> > Signed-off-by: Igor Mammedov 
> > ---
> >  backends/hostmem.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/backends/hostmem.c b/backends/hostmem.c
> > index 0c8ef17..fe14be5 100644
> > --- a/backends/hostmem.c
> > +++ b/backends/hostmem.c
> > @@ -86,7 +86,7 @@ host_memory_backend_get_host_nodes(Object *obj, Visitor 
> > *v, const char *name,
> >  
> >  value = find_first_bit(backend->host_nodes, MAX_NODES);
> >  if (value == MAX_NODES) {
> > -return;
> > +goto ret;
> >  }
> >  
> >  *node = g_malloc0(sizeof(**node));
> > @@ -104,6 +104,7 @@ host_memory_backend_get_host_nodes(Object *obj, Visitor 
> > *v, const char *name,
> >  node = &(*node)->next;
> >  } while (true);
> >  
> > +ret:
> >  visit_type_uint16List(v, name, &host_nodes, errp);
> >  }  
> 
> Yes, an empty list needs to be visited just like a non-empty list.
> 
> Patch looks good.
> 




Re: [Qemu-devel] [PATCH v3 2/2] hostmem-file: reject invalid pmem file sizes

2019-02-14 Thread Igor Mammedov
On Thu, 14 Feb 2019 11:10:04 +0800
Stefan Hajnoczi  wrote:

> Guests started with NVDIMMs larger than the underlying host file produce
> confusing errors inside the guest.  This happens because the guest
> accesses pages beyond the end of the file.
> 
> Check the pmem file size on startup and print a clear error message if
> the size is invalid.
> 
> Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1669053
> Cc: Wei Yang 
> Cc: Zhang Yi 
> Cc: Eduardo Habkost 
> Cc: Igor Mammedov 
> Signed-off-by: Stefan Hajnoczi 

Reviewed-by: Igor Mammedov 

> ---
>  include/qemu/osdep.h| 13 ++
>  backends/hostmem-file.c | 23 ++
>  util/oslib-posix.c  | 53 +
>  util/oslib-win32.c  |  5 
>  4 files changed, 94 insertions(+)
> 
> diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
> index 840af09cb0..303d315c5d 100644
> --- a/include/qemu/osdep.h
> +++ b/include/qemu/osdep.h
> @@ -570,6 +570,19 @@ void qemu_set_tty_echo(int fd, bool echo);
>  void os_mem_prealloc(int fd, char *area, size_t sz, int smp_cpus,
>   Error **errp);
>  
> +/**
> + * qemu_get_pmem_size:
> + * @filename: path to a pmem file
> + * @errp: pointer to a NULL-initialized error object
> + *
> + * Determine the size of a persistent memory file.  Besides supporting files 
> on
> + * DAX file systems, this function also supports Linux devdax character
> + * devices.
> + *
> + * Returns: the size or 0 on failure
> + */
> +uint64_t qemu_get_pmem_size(const char *filename, Error **errp);
> +
>  /**
>   * qemu_get_pid_name:
>   * @pid: pid of a process
> diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c
> index ce54788048..37ac6445d2 100644
> --- a/backends/hostmem-file.c
> +++ b/backends/hostmem-file.c
> @@ -56,6 +56,29 @@ file_backend_memory_alloc(HostMemoryBackend *backend, 
> Error **errp)
>  error_setg(errp, "mem-path property not set");
>  return;
>  }
> +
> +/*
> + * Verify pmem file size since starting a guest with an incorrect size
> + * leads to confusing failures inside the guest.
> + */
> +if (fb->is_pmem) {
> +Error *local_err = NULL;
> +uint64_t size;
> +
> +size = qemu_get_pmem_size(fb->mem_path, &local_err);
> +if (!size) {
> +error_propagate(errp, local_err);
> +return;
> +}
> +
> +if (backend->size > size) {
> +error_setg(errp, "size property %" PRIu64 " is larger than "
> +   "pmem file \"%s\" size %" PRIu64, backend->size,
> +   fb->mem_path, size);
> +return;
> +}
> +}
> +
>  backend->force_prealloc = mem_prealloc;
>  name = host_memory_backend_get_name(backend);
>  memory_region_init_ram_from_file(&backend->mr, OBJECT(backend),
> diff --git a/util/oslib-posix.c b/util/oslib-posix.c
> index 37c5854b9c..10d90d1783 100644
> --- a/util/oslib-posix.c
> +++ b/util/oslib-posix.c
> @@ -500,6 +500,59 @@ void os_mem_prealloc(int fd, char *area, size_t memory, 
> int smp_cpus,
>  }
>  }
>  
> +uint64_t qemu_get_pmem_size(const char *filename, Error **errp)
> +{
> +struct stat st;
> +
> +if (stat(filename, &st) < 0) {
> +error_setg(errp, "unable to stat pmem file \"%s\"", filename);
> +return 0;
> +}
> +
> +#if defined(__linux__)
> +/* Special handling for devdax character devices */
> +if (S_ISCHR(st.st_mode)) {
> +char *subsystem_path = NULL;
> +char *subsystem = NULL;
> +char *size_path = NULL;
> +char *size_str = NULL;
> +uint64_t ret = 0;
> +
> +subsystem_path = g_strdup_printf("/sys/dev/char/%d:%d/subsystem",
> + major(st.st_rdev), 
> minor(st.st_rdev));
> +subsystem = g_file_read_link(subsystem_path, NULL);
> +if (!subsystem) {
> +error_setg(errp, "unable to read subsystem for pmem file \"%s\"",
> +   filename);
> +goto devdax_err;
> +}
> +
> +if (!g_str_has_suffix(subsystem, "/dax")) {
> +error_setg(errp, "pmem file \"%s\" is not a dax device", 
> filename);
> +goto devdax_err;
> +}
> +
> +size_path = g_strdup_printf("/sys/dev/char/%d:%d/size",
> +major(st.st_rdev), minor(st.st_rdev));
> +if (!g_file_get_contents(size_path, &size_str, NULL, NULL)) {
> +error_setg(errp, "unable to read size for pmem file \"%s\"",
> +   size_path);
> +goto devdax_err;
> +}
> +
> +ret = g_ascii_strtoull(size_str, NULL, 0);
> +
> +devdax_err:
> +g_free(size_str);
> +g_free(size_path);
> +g_free(subsystem);
> +g_free(subsystem_path);
> +return ret;
> +}
> +#endif /* defined(__linux__) */
> +
> +return st.st_size;
> +}
>  
>  char *qemu_get_pid_name(pid_t pid)
>  

Re: [Qemu-devel] [PATCH v4 08/18] qapi: New module target.json

2019-02-14 Thread Marc-André Lureau
Hi

On Thu, Feb 14, 2019 at 10:50 AM Markus Armbruster  wrote:
>
> We can't add appropriate target-specific conditionals to misc.json,
> because that would make all of misc.json unusable in
> target-independent code.  To keep misc.json target-independent, we
> need to split off target-dependent target.json.
>
> This commit doesn't actually split off anything, it merely creates the
> empty module.  The next few patches will move stuff from misc.json
> there.
>
> Signed-off-by: Markus Armbruster 

Reviewed-by: Marc-André Lureau 

> ---
>  Makefile.objs |  3 +--
>  qapi/Makefile.objs| 28 +---
>  qapi/qapi-schema.json |  1 +
>  qapi/target.json  | 13 +
>  4 files changed, 32 insertions(+), 13 deletions(-)
>  create mode 100644 qapi/target.json
>
> diff --git a/Makefile.objs b/Makefile.objs
> index 4a266357a2..95150d7173 100644
> --- a/Makefile.objs
> +++ b/Makefile.objs
> @@ -79,8 +79,7 @@ common-obj-$(CONFIG_FDT) += device_tree.o
>  ##
>  # qapi
>
> -common-obj-y += qapi/qapi-commands.o
> -common-obj-y += $(QAPI_MODULES:%=qapi/qapi-commands-%.o)
> +common-obj-y += $(QAPI_COMMON_MODULES:%=qapi/qapi-commands-%.o)
>  common-obj-y += qmp.o hmp.o
>  endif
>
> diff --git a/qapi/Makefile.objs b/qapi/Makefile.objs
> index dacbae..654321de94 100644
> --- a/qapi/Makefile.objs
> +++ b/qapi/Makefile.objs
> @@ -5,21 +5,27 @@ util-obj-y += opts-visitor.o qapi-clone-visitor.o
>  util-obj-y += qmp-event.o
>  util-obj-y += qapi-util.o
>
> -QAPI_MODULES = block-core block char common crypto introspect job migration
> -QAPI_MODULES += misc net rdma rocker run-state sockets tpm trace transaction
> -QAPI_MODULES += ui
> +QAPI_COMMON_MODULES = block-core block char common crypto introspect
> +QAPI_COMMON_MODULES += job migration misc net rdma rocker run-state
> +QAPI_COMMON_MODULES += sockets tpm trace transaction ui
> +QAPI_TARGET_MODULES = target
> +QAPI_MODULES = $(QAPI_COMMON_MODULES) $(QAPI_TARGET_MODULES)
>
>  util-obj-y += qapi-builtin-types.o
> -util-obj-y += qapi-types.o
> -util-obj-y += $(QAPI_MODULES:%=qapi-types-%.o)
> +util-obj-y += $(QAPI_COMMON_MODULES:%=qapi-types-%.o)
>  util-obj-y += qapi-builtin-visit.o
> -util-obj-y += qapi-visit.o
> -util-obj-y += $(QAPI_MODULES:%=qapi-visit-%.o)
> +util-obj-y += $(QAPI_COMMON_MODULES:%=qapi-visit-%.o)
>  util-obj-y += qapi-emit-events.o
> -util-obj-y += qapi-events.o
> -util-obj-y += $(QAPI_MODULES:%=qapi-events-%.o)
> +util-obj-y += $(QAPI_COMMON_MODULES:%=qapi-events-%.o)
>
> -common-obj-y += qapi-commands.o
> -common-obj-y += $(QAPI_MODULES:%=qapi-commands-%.o)
> +common-obj-y += $(QAPI_COMMON_MODULES:%=qapi-commands-%.o)
>
> +obj-y += $(QAPI_TARGET_MODULES:%=qapi-types-%.o)
> +obj-y += qapi-types.o
> +obj-y += $(QAPI_TARGET_MODULES:%=qapi-visit-%.o)
> +obj-y += qapi-visit.o
> +obj-y += $(QAPI_TARGET_MODULES:%=qapi-events-%.o)
> +obj-y += qapi-events.o
> +obj-y += $(QAPI_TARGET_MODULES:%=qapi-commands-%.o)
> +obj-y += qapi-commands.o
>  obj-y += qapi-introspect.o
> diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json
> index 1845aa78ff..db61bfd688 100644
> --- a/qapi/qapi-schema.json
> +++ b/qapi/qapi-schema.json
> @@ -97,3 +97,4 @@
>  { 'include': 'trace.json' }
>  { 'include': 'introspect.json' }
>  { 'include': 'misc.json' }
> +{ 'include': 'target.json' }
> diff --git a/qapi/target.json b/qapi/target.json
> new file mode 100644
> index 00..8054926293
> --- /dev/null
> +++ b/qapi/target.json
> @@ -0,0 +1,13 @@
> +# -*- Mode: Python -*-
> +#
> +
> +##
> +# = Target-specific commands & events
> +##
> +
> +##
> +# @TARGET-TEMPORARY-DUMMY:
> +# Will go away in the next commit.  Needed in this one because empty
> +# modules don't generate anything, defeating this commit's purpose.
> +##
> +{ 'event': 'TARGET-TEMPORARY-DUMMY' }
> --
> 2.17.2
>
>


-- 
Marc-André Lureau



Re: [Qemu-devel] [PATCH 0/4] target/arm: Reduce overhead of cpu_get_tb_cpu_state

2019-02-14 Thread Alex Bennée


Richard Henderson  writes:

> We've talked about this before, caching state to reduce the
> amount of computation that happens looking up each TB.
>
> I know that Peter has been concerned that we would not be able to
> reliably maintain all of the places that need to be updates to
> keep this up-to-date.
>
> Well, modulo dirty tricks within linux-user, it appears as if
> exception delivery and return, plus after every TB-ending write
> to a system register is sufficient.
>
> There seems to be a noticable improvement, although wall-time
> is harder to come by -- all of my system-level measurements
> include user input, and my user-level measurements seem to be
> too small to matter.

I'll run some of my benchmarks on it but I'm almost certain it will help
as it is one of the highest hits on "perf top" when running a loaded
guest.

>
>
> r~
>
>
> Richard Henderson (4):
>   target/arm: Split out recompute_hflags et al
>   target/arm: Rebuild hflags at el changes and MSR writes
>   target/arm: Assert hflags is correct in cpu_get_tb_cpu_state
>   target/arm: Rely on hflags correct in cpu_get_tb_cpu_state
>
>  target/arm/cpu.h   |  22 ++-
>  target/arm/helper.h|   3 +
>  target/arm/internals.h |   4 +
>  linux-user/syscall.c   |   1 +
>  target/arm/cpu.c   |   1 +
>  target/arm/helper-a64.c|   3 +
>  target/arm/helper.c| 267 ++---
>  target/arm/machine.c   |   1 +
>  target/arm/op_helper.c |   1 +
>  target/arm/translate-a64.c |   6 +-
>  target/arm/translate.c |  14 +-
>  11 files changed, 204 insertions(+), 119 deletions(-)


--
Alex Bennée



[Qemu-devel] [PULL 03/14] qemu-options: Remove deprecated option -clock

2019-02-14 Thread Laurent Vivier
From: Thomas Huth 

The option is only a dummy since a long time. We've finally deprecated
it in QEMU v3.0, so it's time to remove it now.

Signed-off-by: Thomas Huth 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <1549545296-18903-3-git-send-email-th...@redhat.com>
Signed-off-by: Laurent Vivier 
---
 qemu-deprecated.texi | 5 -
 qemu-options.hx  | 3 ---
 vl.c | 6 --
 3 files changed, 14 deletions(-)

diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi
index 90e5860fd1a6..fe905551c598 100644
--- a/qemu-deprecated.texi
+++ b/qemu-deprecated.texi
@@ -37,11 +37,6 @@ would automatically enable USB support on the machine type.
 If using the new syntax, USB support must be explicitly
 enabled via the ``-machine usb=on'' argument.
 
-@subsection -clock (since 3.0.0)
-
-The @code{-clock} option is ignored since QEMU version 1.7.0. There is no
-replacement since it is not needed anymore.
-
 @subsection -drive file=json:@{...@{'driver':'file'@}@} (since 3.0)
 
 The 'file' driver for drives is no longer appropriate for character or host
diff --git a/qemu-options.hx b/qemu-options.hx
index 06ef1a7c5c72..77bd98e20b14 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -3444,9 +3444,6 @@ Load the contents of @var{file} as an option ROM.
 This option is useful to load things like EtherBoot.
 ETEXI
 
-HXCOMM Silently ignored for compatibility
-DEF("clock", HAS_ARG, QEMU_OPTION_clock, "", QEMU_ARCH_ALL)
-
 DEF("rtc", HAS_ARG, QEMU_OPTION_rtc, \
 "-rtc 
[base=utc|localtime|][,clock=host|rt|vm][,driftfix=none|slew]\n" \
 "set the RTC base and clock, enable drift fix for clock 
ticks (x86 only)\n",
diff --git a/vl.c b/vl.c
index 9e4dba7f92f2..90ff2dd9 100644
--- a/vl.c
+++ b/vl.c
@@ -3735,12 +3735,6 @@ int main(int argc, char **argv, char **envp)
 case QEMU_OPTION_old_param:
 old_param = 1;
 break;
-case QEMU_OPTION_clock:
-/* Clock options no longer exist.  Keep this option for
- * backward compatibility.
- */
-warn_report("This option is ignored and will be removed soon");
-break;
 case QEMU_OPTION_rtc:
 opts = qemu_opts_parse_noisily(qemu_find_opts("rtc"), optarg,
false);
-- 
2.20.1




[Qemu-devel] [PULL 11/14] wavcapture: Convert to error_report

2019-02-14 Thread Laurent Vivier
From: "Dr. David Alan Gilbert" 

Kill off a pile of monitor_printf's and cur_mon usage.
The only one left in wavcapture.c is the info case.

Signed-off-by: Dr. David Alan Gilbert 
Reviewed-by: Gerd Hoffmann 
Reviewed-by: Michael S. Tsirkin 
Message-Id: <20170320173840.3626-3-dgilb...@redhat.com>
Signed-off-by: Laurent Vivier 
---
 audio/wavcapture.c | 39 +--
 1 file changed, 17 insertions(+), 22 deletions(-)

diff --git a/audio/wavcapture.c b/audio/wavcapture.c
index cf31ed652c2b..cd24570aa70c 100644
--- a/audio/wavcapture.c
+++ b/audio/wavcapture.c
@@ -38,30 +38,29 @@ static void wav_destroy (void *opaque)
 uint8_t dlen[4];
 uint32_t datalen = wav->bytes;
 uint32_t rifflen = datalen + 36;
-Monitor *mon = cur_mon;
 
 if (wav->f) {
 le_store (rlen, rifflen, 4);
 le_store (dlen, datalen, 4);
 
 if (fseek (wav->f, 4, SEEK_SET)) {
-monitor_printf (mon, "wav_destroy: rlen fseek failed\nReason: 
%s\n",
-strerror (errno));
+error_report("wav_destroy: rlen fseek failed: %s",
+ strerror(errno));
 goto doclose;
 }
 if (fwrite (rlen, 4, 1, wav->f) != 1) {
-monitor_printf (mon, "wav_destroy: rlen fwrite failed\nReason 
%s\n",
-strerror (errno));
+error_report("wav_destroy: rlen fwrite failed: %s",
+ strerror(errno));
 goto doclose;
 }
 if (fseek (wav->f, 32, SEEK_CUR)) {
-monitor_printf (mon, "wav_destroy: dlen fseek failed\nReason %s\n",
-strerror (errno));
+error_report("wav_destroy: dlen fseek failed: %s",
+ strerror(errno));
 goto doclose;
 }
 if (fwrite (dlen, 1, 4, wav->f) != 4) {
-monitor_printf (mon, "wav_destroy: dlen fwrite failed\nReason 
%s\n",
-strerror (errno));
+error_report("wav_destroy: dlen fwrite failed: %s",
+ strerror(errno));
 goto doclose;
 }
 doclose:
@@ -78,8 +77,7 @@ static void wav_capture (void *opaque, void *buf, int size)
 WAVState *wav = opaque;
 
 if (fwrite (buf, size, 1, wav->f) != 1) {
-monitor_printf (cur_mon, "wav_capture: fwrite error\nReason: %s",
-strerror (errno));
+error_report("wav_capture: fwrite error: %s", strerror(errno));
 }
 wav->bytes += size;
 }
@@ -110,7 +108,6 @@ static struct capture_ops wav_capture_ops = {
 int wav_start_capture (CaptureState *s, const char *path, int freq,
int bits, int nchannels)
 {
-Monitor *mon = cur_mon;
 WAVState *wav;
 uint8_t hdr[] = {
 0x52, 0x49, 0x46, 0x46, 0x00, 0x00, 0x00, 0x00, 0x57, 0x41, 0x56,
@@ -124,13 +121,13 @@ int wav_start_capture (CaptureState *s, const char *path, 
int freq,
 CaptureVoiceOut *cap;
 
 if (bits != 8 && bits != 16) {
-monitor_printf (mon, "incorrect bit count %d, must be 8 or 16\n", 
bits);
+error_report("incorrect bit count %d, must be 8 or 16", bits);
 return -1;
 }
 
 if (nchannels != 1 && nchannels != 2) {
-monitor_printf (mon, "incorrect channel count %d, must be 1 or 2\n",
-nchannels);
+error_report("incorrect channel count %d, must be 1 or 2",
+ nchannels);
 return -1;
 }
 
@@ -158,8 +155,8 @@ int wav_start_capture (CaptureState *s, const char *path, 
int freq,
 
 wav->f = fopen (path, "wb");
 if (!wav->f) {
-monitor_printf (mon, "Failed to open wave file `%s'\nReason: %s\n",
-path, strerror (errno));
+error_report("Failed to open wave file `%s': %s",
+ path, strerror(errno));
 g_free (wav);
 return -1;
 }
@@ -170,14 +167,13 @@ int wav_start_capture (CaptureState *s, const char *path, 
int freq,
 wav->freq = freq;
 
 if (fwrite (hdr, sizeof (hdr), 1, wav->f) != 1) {
-monitor_printf (mon, "Failed to write header\nReason: %s\n",
-strerror (errno));
+error_report("Failed to write header: %s", strerror(errno));
 goto error_free;
 }
 
 cap = AUD_add_capture (&as, &ops, wav);
 if (!cap) {
-monitor_printf (mon, "Failed to add audio capture\n");
+error_report("Failed to add audio capture");
 goto error_free;
 }
 
@@ -189,8 +185,7 @@ int wav_start_capture (CaptureState *s, const char *path, 
int freq,
 error_free:
 g_free (wav->path);
 if (fclose (wav->f)) {
-monitor_printf (mon, "Failed to close wave file\nReason: %s\n",
-strerror (errno));
+error_report("Failed to close wave file: %s", strerror(errno));
 }
 g_free (wav);
 return -1;
-- 
2.20.1




[Qemu-devel] [PULL 13/14] hw/sparc64: Explicitly set default_display = "std"

2019-02-14 Thread Laurent Vivier
From: Thomas Huth 

The sun4uv_init() function expects vga_interface_type to be either
VGA_STD or VGA_NONE and sets up a stdvga device or no vga card
accordingly.
However, the code in vl.c prefers the Cirrus VGA card to stdvga if
it is available and the user and the machine did not specify anything
else.
So far this has not been a problem, since the Cirrus VGA was not linked
into the sparc64 target. But with the upcoming Kconfig build system,
all theoretically possible PCI cards will be enabled by default, so the
Cirrus VGA card might become available on the sparc64 target, too. vl.c
then picks the wrong card, causing sun4uv_init() to abort.
Thus let's make it explicit that we always want stdvga for sparc64 and
so set default_display = "std" for these machines.

Signed-off-by: Thomas Huth 
Reviewed-by: Philippe Mathieu-Daudé 
Reviewed-by: Mark Cave-Ayland 
Message-Id: <1550041639-10232-1-git-send-email-th...@redhat.com>
Signed-off-by: Laurent Vivier 
---
 hw/sparc64/sun4u.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index ff24d9b35016..399f2d73c814 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -797,6 +797,7 @@ static void sun4u_class_init(ObjectClass *oc, void *data)
 mc->default_boot_order = "c";
 mc->default_cpu_type = SPARC_CPU_TYPE_NAME("TI-UltraSparc-IIi");
 mc->ignore_boot_device_suffixes = true;
+mc->default_display = "std";
 fwc->get_dev_path = sun4u_fw_dev_path;
 }
 
@@ -820,6 +821,7 @@ static void sun4v_class_init(ObjectClass *oc, void *data)
 mc->max_cpus = 1; /* XXX for now */
 mc->default_boot_order = "c";
 mc->default_cpu_type = SPARC_CPU_TYPE_NAME("Sun-UltraSparc-T1");
+mc->default_display = "std";
 }
 
 static const TypeInfo sun4v_type = {
-- 
2.20.1




[Qemu-devel] [PULL 00/14] Trivial branch patches

2019-02-14 Thread Laurent Vivier
The following changes since commit 0b5e750bea635b167eb03d86c3d9a09bbd43bc06:

  Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into 
staging (2019-02-12 10:53:37 +)

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 96566d09aa105ee04cbc1c9539cf8a9a40e8e422:

  configure: improve usbfs check (2019-02-14 11:46:30 +0100)


- some configure updates (HAX/NetBSD, remove "wav", -Waddress-of-packed-member)
- remove deprecated options
- some trace and error cleanup
- typo fixes



Cleber Rosa (2):
  configure: remove handling of "wav" audio driver
  configure: fix qemu-img name

Dr. David Alan Gilbert (4):
  pckbd: Convert DPRINTF->trace
  HMP: Prepend errors with 'Error:'
  kvm: Add kvm_set_ioeventfd* traces
  wavcapture: Convert to error_report

Eric Blake (1):
  qapi: Fix qcow2 encryption doc typo

Kamil Rytarowski (1):
  configure: Add HAX support in NetBSD

Peter Maydell (1):
  configure: Make -Waddress-of-packed-member warnings be errors

Philippe Mathieu-Daudé (1):
  hw/dma/i8257: Use qemu_log_mask(UNIMP) instead of fprintf

Thomas Huth (3):
  qemu-deprecated: Remove -virtioconsole and -no-frame for good
  qemu-options: Remove deprecated option -clock
  hw/sparc64: Explicitly set default_display = "std"

Thomas Petazzoni (1):
  configure: improve usbfs check

 accel/kvm/kvm-all.c|  3 +++
 accel/kvm/trace-events |  2 ++
 audio/wavcapture.c | 39 +--
 configure  | 27 +++
 hmp.c  |  2 +-
 hw/dma/i8257.c |  4 +++-
 hw/input/pckbd.c   | 19 ++-
 hw/input/trace-events  |  7 +++
 hw/sparc64/sun4u.c |  2 ++
 qapi/block-core.json   |  2 +-
 qemu-deprecated.texi   | 17 -
 qemu-options.hx|  3 ---
 vl.c   |  6 --
 13 files changed, 61 insertions(+), 72 deletions(-)

-- 
2.20.1




[Qemu-devel] [PULL 06/14] configure: Add HAX support in NetBSD

2019-02-14 Thread Laurent Vivier
From: Kamil Rytarowski 

The NetBSD support in Intel HAXM has beem merged upstream and is functional.

Signed-off-by: Kamil Rytarowski 
Message-Id: <20190207233704.29978-1-...@gmx.com>
Signed-off-by: Laurent Vivier 
---
 configure | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configure b/configure
index c8fc1647fe69..649ef1b158d1 100755
--- a/configure
+++ b/configure
@@ -817,6 +817,7 @@ DragonFly)
 ;;
 NetBSD)
   bsd="yes"
+  hax="yes"
   make="${MAKE-gmake}"
   audio_drv_list="oss try-sdl"
   audio_possible_drivers="oss sdl"
-- 
2.20.1




[Qemu-devel] [PULL 01/14] qapi: Fix qcow2 encryption doc typo

2019-02-14 Thread Laurent Vivier
From: Eric Blake 

Present since commit b25b387f (2.10).

Signed-off-by: Eric Blake 
Reviewed-by: Thomas Huth 
Message-Id: <20190206202848.16999-1-ebl...@redhat.com>
Signed-off-by: Laurent Vivier 
---
 qapi/block-core.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qapi/block-core.json b/qapi/block-core.json
index 0f349d460336..ee1ab7a8a259 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -2998,7 +2998,7 @@
 
 ##
 # @BlockdevQcow2EncryptionFormat:
-# @aes: AES-CBC with plain64 initialization venctors
+# @aes: AES-CBC with plain64 initialization vectors
 #
 # Since: 2.10
 ##
-- 
2.20.1




[Qemu-devel] [PULL 10/14] kvm: Add kvm_set_ioeventfd* traces

2019-02-14 Thread Laurent Vivier
From: "Dr. David Alan Gilbert" 

Add a couple of traces around the kvm_set_ioeventfd* calls.

Signed-off-by: Dr. David Alan Gilbert 
Reviewed-by: Philippe Mathieu-Daudé 
Reviewed-by: Cornelia Huck 
Reviewed-by: Michael S. Tsirkin 
Message-Id: <20190212134758.10514-4-dgilb...@redhat.com>
Signed-off-by: Laurent Vivier 
---
 accel/kvm/kvm-all.c| 3 +++
 accel/kvm/trace-events | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 4e1de942ce55..fd92b6f37547 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -657,6 +657,8 @@ static int kvm_set_ioeventfd_mmio(int fd, hwaddr addr, 
uint32_t val,
 .fd = fd,
 };
 
+trace_kvm_set_ioeventfd_mmio(fd, (uint64_t)addr, val, assign, size,
+ datamatch);
 if (!kvm_enabled()) {
 return -ENOSYS;
 }
@@ -688,6 +690,7 @@ static int kvm_set_ioeventfd_pio(int fd, uint16_t addr, 
uint16_t val,
 .fd = fd,
 };
 int r;
+trace_kvm_set_ioeventfd_pio(fd, addr, val, assign, size, datamatch);
 if (!kvm_enabled()) {
 return -ENOSYS;
 }
diff --git a/accel/kvm/trace-events b/accel/kvm/trace-events
index 58e98efe5dea..8841025d6895 100644
--- a/accel/kvm/trace-events
+++ b/accel/kvm/trace-events
@@ -12,5 +12,7 @@ kvm_irqchip_commit_routes(void) ""
 kvm_irqchip_add_msi_route(char *name, int vector, int virq) "dev %s vector %d 
virq %d"
 kvm_irqchip_update_msi_route(int virq) "Updating MSI route virq=%d"
 kvm_irqchip_release_virq(int virq) "virq %d"
+kvm_set_ioeventfd_mmio(int fd, uint64_t addr, uint32_t val, bool assign, 
uint32_t size, bool datamatch) "fd: %d @0x%" PRIx64 " val=0x%x assign: %d size: 
%d match: %d"
+kvm_set_ioeventfd_pio(int fd, uint16_t addr, uint32_t val, bool assign, 
uint32_t size, bool datamatch) "fd: %d @0x%x val=0x%x assign: %d size: %d 
match: %d"
 kvm_set_user_memory(uint32_t slot, uint32_t flags, uint64_t guest_phys_addr, 
uint64_t memory_size, uint64_t userspace_addr, int ret) "Slot#%d flags=0x%x 
gpa=0x%"PRIx64 " size=0x%"PRIx64 " ua=0x%"PRIx64 " ret=%d"
 
-- 
2.20.1




[Qemu-devel] [PULL 02/14] qemu-deprecated: Remove -virtioconsole and -no-frame for good

2019-02-14 Thread Laurent Vivier
From: Thomas Huth 

The two sections have accidentally been added again during the
merge of Paolo's and Gerd's trees.

Fixes: 3e29da9fd81002a0c03041aaa26dea6d9dd9bd65
Signed-off-by: Thomas Huth 
Reviewed-by: Peter Maydell 
Message-Id: <1549545296-18903-2-git-send-email-th...@redhat.com>
Signed-off-by: Laurent Vivier 
---
 qemu-deprecated.texi | 12 
 1 file changed, 12 deletions(-)

diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi
index 80b0702ad5b2..90e5860fd1a6 100644
--- a/qemu-deprecated.texi
+++ b/qemu-deprecated.texi
@@ -37,18 +37,6 @@ would automatically enable USB support on the machine type.
 If using the new syntax, USB support must be explicitly
 enabled via the ``-machine usb=on'' argument.
 
-@subsection -virtioconsole (since 3.0.0)
-
-Option @option{-virtioconsole} has been replaced by
-@option{-device virtconsole}.
-
-@subsection -no-frame (since 2.12.0)
-
-The @code{--no-frame} argument works with SDL 1.2 only. The other user
-interfaces never implemented this in the first place. So this will be
-removed together with SDL 1.2 support.
->>> remotes/bonzini/tags/for-upstream
-
 @subsection -clock (since 3.0.0)
 
 The @code{-clock} option is ignored since QEMU version 1.7.0. There is no
-- 
2.20.1




[Qemu-devel] [PULL 05/14] configure: fix qemu-img name

2019-02-14 Thread Laurent Vivier
From: Cleber Rosa 

Signed-off-by: Cleber Rosa 
Reviewed-by: Laurent Vivier 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20190207193605.25676-3-cr...@redhat.com>
Signed-off-by: Laurent Vivier 
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index ff55e2273e9a..c8fc1647fe69 100755
--- a/configure
+++ b/configure
@@ -1768,7 +1768,7 @@ disabled with --disable-FEATURE, default is enabled if 
available:
   virglrenderer   virgl rendering support
   xfsctl  xfsctl support
   qom-cast-debug  cast debugging support
-  tools   build qemu-io, qemu-nbd and qemu-image tools
+  tools   build qemu-io, qemu-nbd and qemu-img tools
   vxhsVeritas HyperScale vDisk backend support
   bochs   bochs image format support
   cloop   cloop image format support
-- 
2.20.1




[Qemu-devel] [PULL 14/14] configure: improve usbfs check

2019-02-14 Thread Laurent Vivier
From: Thomas Petazzoni 

The current check to test if usbfs support should be compiled or not
solely relies on the presence of , without
actually checking that all definition used by Qemu are provided by
this header file.

With sufficiently old kernel headers,  may be
present, but some of the definitions needed by Qemu may not be
available.

This commit improves the check by building a small program that
actually tests whether the necessary definitions are available.

In addition, it fixes a bug where have_usbfs was set to "yes"
regardless of the result of the test.

Signed-off-by: Thomas Petazzoni 
Reviewed-by: Thomas Huth 
Message-Id: <20190213211827.20300-1-thomas.petazz...@bootlin.com>
Signed-off-by: Laurent Vivier 
---
 configure | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index c0f278141823..90b9e2fa3c05 100755
--- a/configure
+++ b/configure
@@ -4262,10 +4262,25 @@ fi
 # check for usbfs
 have_usbfs=no
 if test "$linux_user" = "yes"; then
-  if check_include linux/usbdevice_fs.h; then
+  cat > $TMPC << EOF
+#include 
+
+#ifndef USBDEVFS_GET_CAPABILITIES
+#error "USBDEVFS_GET_CAPABILITIES undefined"
+#endif
+
+#ifndef USBDEVFS_DISCONNECT_CLAIM
+#error "USBDEVFS_DISCONNECT_CLAIM undefined"
+#endif
+
+int main(void)
+{
+return 0;
+}
+EOF
+  if compile_prog "" ""; then
 have_usbfs=yes
   fi
-  have_usbfs=yes
 fi
 
 # check for fallocate
-- 
2.20.1




[Qemu-devel] [PULL 09/14] HMP: Prepend errors with 'Error:'

2019-02-14 Thread Laurent Vivier
From: "Dr. David Alan Gilbert" 

Always make error messages start with 'Error:' as a fallback
to make sure that anything parsing them can tell it failed.

Note: Some places don't use hmp_handle_error

Signed-off-by: Dr. David Alan Gilbert 
Reviewed-by: Philippe Mathieu-Daudé 
Reviewed-by: Michael S. Tsirkin 
Message-Id: <20190212134758.10514-3-dgilb...@redhat.com>
Signed-off-by: Laurent Vivier 
---
 hmp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hmp.c b/hmp.c
index b2a2b1f84e33..4d14718fea4a 100644
--- a/hmp.c
+++ b/hmp.c
@@ -62,7 +62,7 @@ static void hmp_handle_error(Monitor *mon, Error **errp)
 {
 assert(errp);
 if (*errp) {
-error_report_err(*errp);
+error_reportf_err(*errp, "Error: ");
 }
 }
 
-- 
2.20.1




[Qemu-devel] [PULL 12/14] hw/dma/i8257: Use qemu_log_mask(UNIMP) instead of fprintf

2019-02-14 Thread Laurent Vivier
From: Philippe Mathieu-Daudé 

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

  $ qemu-system-mips64el -M fulong2e -bios pmon_2e.bin
  dma: command df not supported
  dma: command df not supported
  dma: command df not supported
  dma: command df not supported

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

diff --git a/hw/dma/i8257.c b/hw/dma/i8257.c
index 52675e97c9e7..3e1f13a4aaf4 100644
--- a/hw/dma/i8257.c
+++ b/hw/dma/i8257.c
@@ -26,6 +26,7 @@
 #include "hw/isa/isa.h"
 #include "hw/dma/i8257.h"
 #include "qemu/main-loop.h"
+#include "qemu/log.h"
 #include "trace.h"
 
 #define I8257(obj) \
@@ -185,7 +186,8 @@ static void i8257_write_cont(void *opaque, hwaddr nport, 
uint64_t data,
 switch (iport) {
 case 0x00:  /* command */
 if ((data != 0) && (data & CMD_NOT_SUPPORTED)) {
-dolog("command %"PRIx64" not supported\n", data);
+qemu_log_mask(LOG_UNIMP, "%s: cmd 0x%02"PRIx64" not supported\n",
+  __func__, data);
 return;
 }
 d->command = data;
-- 
2.20.1




[Qemu-devel] [PULL 07/14] configure: Make -Waddress-of-packed-member warnings be errors

2019-02-14 Thread Laurent Vivier
From: Peter Maydell 

We have now managed to eradicate all the places in the codebase
that triggered clang's -Waddress-of-packed-member warning. Remove
the compiler flag that exempted it from our usual -Werror policy.
This will prevent any new problematic code being added in future.

Signed-off-by: Peter Maydell 
Reviewed-by: Thomas Huth 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20190208132112.31493-1-peter.mayd...@linaro.org>
Signed-off-by: Laurent Vivier 
---
 configure | 1 -
 1 file changed, 1 deletion(-)

diff --git a/configure b/configure
index 649ef1b158d1..c0f278141823 100755
--- a/configure
+++ b/configure
@@ -1882,7 +1882,6 @@ gcc_flags="-Wno-missing-include-dirs -Wempty-body 
-Wnested-externs $gcc_flags"
 gcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
 gcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
 gcc_flags="-Wno-string-plus-int $gcc_flags"
-gcc_flags="-Wno-error=address-of-packed-member $gcc_flags"
 # Note that we do not add -Werror to gcc_flags here, because that would
 # enable it for all configure tests. If a configure test failed due
 # to -Werror this would just silently disable some features,
-- 
2.20.1




[Qemu-devel] [PULL 04/14] configure: remove handling of "wav" audio driver

2019-02-14 Thread Laurent Vivier
From: Cleber Rosa 

This looks like a leftover that was never implemented.

Signed-off-by: Cleber Rosa 
Reviewed-by: Laurent Vivier 
Reviewed-by: Philippe Mathieu-Daudé 
Message-Id: <20190207193605.25676-2-cr...@redhat.com>
Signed-off-by: Laurent Vivier 
---
 configure | 4 
 1 file changed, 4 deletions(-)

diff --git a/configure b/configure
index fbd0825488c6..ff55e2273e9a 100755
--- a/configure
+++ b/configure
@@ -3350,10 +3350,6 @@ for drv in $audio_drv_list; do
   oss_libs="$oss_lib"
 ;;
 
-wav)
-# XXX: Probes for CoreAudio, DirectSound
-;;
-
 *)
 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
 error_exit "Unknown driver '$drv' selected" \
-- 
2.20.1




[Qemu-devel] [PULL 08/14] pckbd: Convert DPRINTF->trace

2019-02-14 Thread Laurent Vivier
From: "Dr. David Alan Gilbert" 

Signed-off-by: Dr. David Alan Gilbert 
Reviewed-by: Philippe Mathieu-Daudé 
Reviewed-by: Stefan Hajnoczi 
Reviewed-by: Michael S. Tsirkin 
Message-Id: <20181016112232.23241-1-dgilb...@redhat.com>
Signed-off-by: Laurent Vivier 
---
 hw/input/pckbd.c  | 19 ++-
 hw/input/trace-events |  7 +++
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c
index 72e7d5f6cc50..47a606f5e3a0 100644
--- a/hw/input/pckbd.c
+++ b/hw/input/pckbd.c
@@ -30,14 +30,7 @@
 #include "hw/input/i8042.h"
 #include "sysemu/sysemu.h"
 
-/* debug PC keyboard */
-//#define DEBUG_KBD
-#ifdef DEBUG_KBD
-#define DPRINTF(fmt, ...)   \
-do { printf("KBD: " fmt , ## __VA_ARGS__); } while (0)
-#else
-#define DPRINTF(fmt, ...)
-#endif
+#include "trace.h"
 
 /* Keyboard Controller Commands */
 #define KBD_CCMD_READ_MODE 0x20/* Read mode bits */
@@ -210,7 +203,7 @@ static uint64_t kbd_read_status(void *opaque, hwaddr addr,
 KBDState *s = opaque;
 int val;
 val = s->status;
-DPRINTF("kbd: read status=0x%02x\n", val);
+trace_pckbd_kbd_read_status(val);
 return val;
 }
 
@@ -224,7 +217,7 @@ static void kbd_queue(KBDState *s, int b, int aux)
 
 static void outport_write(KBDState *s, uint32_t val)
 {
-DPRINTF("kbd: write outport=0x%02x\n", val);
+trace_pckbd_outport_write(val);
 s->outport = val;
 qemu_set_irq(s->a20_out, (val >> 1) & 1);
 if (!(val & 1)) {
@@ -237,7 +230,7 @@ static void kbd_write_command(void *opaque, hwaddr addr,
 {
 KBDState *s = opaque;
 
-DPRINTF("kbd: write cmd=0x%02" PRIx64 "\n", val);
+trace_pckbd_kbd_write_command(val);
 
 /* Bits 3-0 of the output port P2 of the keyboard controller may be pulsed
  * low for approximately 6 micro seconds. Bits 3-0 of the KBD_CCMD_PULSE
@@ -326,7 +319,7 @@ static uint64_t kbd_read_data(void *opaque, hwaddr addr,
 else
 val = ps2_read_data(s->kbd);
 
-DPRINTF("kbd: read data=0x%02x\n", val);
+trace_pckbd_kbd_read_data(val);
 return val;
 }
 
@@ -335,7 +328,7 @@ static void kbd_write_data(void *opaque, hwaddr addr,
 {
 KBDState *s = opaque;
 
-DPRINTF("kbd: write data=0x%02" PRIx64 "\n", val);
+trace_pckbd_kbd_write_data(val);
 
 switch(s->write_cmd) {
 case 0:
diff --git a/hw/input/trace-events b/hw/input/trace-events
index 3965a842aee5..8e53ae5bbf15 100644
--- a/hw/input/trace-events
+++ b/hw/input/trace-events
@@ -14,6 +14,13 @@ adb_mouse_readreg(int reg, uint8_t val0, uint8_t val1) "reg 
%d obuf[0] 0x%2.2x o
 adb_mouse_request_change_addr(int devaddr) "change addr to 0x%x"
 adb_mouse_request_change_addr_and_handler(int devaddr, int handler) "change 
addr and handler to 0x%x, 0x%x"
 
+# hw/input/pckbd.c
+pckbd_kbd_read_data(uint32_t val) "0x%02x"
+pckbd_kbd_read_status(int status) "0x%02x"
+pckbd_outport_write(uint32_t val) "0x%02x"
+pckbd_kbd_write_command(uint64_t val) "0x%02"PRIx64
+pckbd_kbd_write_data(uint64_t val) "0x%02"PRIx64
+
 # hw/input/ps2.c
 ps2_put_keycode(void *opaque, int keycode) "%p keycode 0x%02x"
 ps2_keyboard_event(void *opaque, int qcode, int down, unsigned int modifier, 
unsigned int modifiers) "%p qcode %d down %d modifier 0x%x modifiers 0x%x"
-- 
2.20.1




Re: [Qemu-devel] [PATCH] s390x/kvm: add tracepoint to ioeventfd interface

2019-02-14 Thread Cornelia Huck
On Tue, 12 Feb 2019 16:30:25 +0100
Cornelia Huck  wrote:

> Trace when assigning/unassigning.
> 
> Signed-off-by: Cornelia Huck 
> ---
>  target/s390x/kvm.c| 2 ++
>  target/s390x/trace-events | 1 +
>  2 files changed, 3 insertions(+)

Queued to s390-next (without the 's390' infix).



[Qemu-devel] [PATCH v2 7/7] ui/cocoa: Perform UI operations only on the main thread

2019-02-14 Thread Peter Maydell
The OSX Mojave release is more picky about enforcing the Cocoa API
restriction that only the main thread may perform UI calls. To
accommodate this we need to restructure the Cocoa code:
 * the special OSX main() creates a second thread and uses
   that to call the vl.c qemu_main(); the original main
   thread goes into the OSX event loop
 * the refresh, switch and update callbacks asynchronously
   tell the main thread to do the necessary work
 * the refresh callback no longer does the "get events from the
   UI event queue and handle them" loop, since we now use
   the stock OSX event loop. Instead our NSApplication sendEvent
   method will either deal with them or pass them on to OSX

All these things have to be changed in one commit, to avoid
breaking bisection.

Note that since we use dispatch_get_main_queue(), this bumps
our minimum version requirement to OSX 10.10 Yosemite (released
in 2014, unsupported by Apple since 2017).

Signed-off-by: Peter Maydell 
---
v2 changes: call handleEvent from sendEvent
---
 ui/cocoa.m | 191 +++--
 1 file changed, 113 insertions(+), 78 deletions(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 184fbd877d..201a294ed4 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -129,6 +129,9 @@
 NSTextField *pauseLabel;
 NSArray * supportedImageFileTypes;
 
+QemuSemaphore display_init_sem;
+QemuSemaphore app_started_sem;
+
 // Utility functions to run specified code block with iothread lock held
 typedef void (^CodeBlock)(void);
 typedef bool (^BoolCodeBlock)(void);
@@ -325,6 +328,7 @@ @interface QemuCocoaView : NSView
 NSWindow *fullScreenWindow;
 float cx,cy,cw,ch,cdx,cdy;
 CGDataProviderRef dataProviderRef;
+pixman_image_t *pixman_image;
 BOOL modifiers_state[256];
 BOOL isMouseGrabbed;
 BOOL isFullscreen;
@@ -535,13 +539,16 @@ - (void) switchSurface:(pixman_image_t *)image
 }
 
 // update screenBuffer
-if (dataProviderRef)
+if (dataProviderRef) {
 CGDataProviderRelease(dataProviderRef);
+pixman_image_unref(pixman_image);
+}
 
 //sync host window color space with guests
 screen.bitsPerPixel = PIXMAN_FORMAT_BPP(image_format);
 screen.bitsPerComponent = DIV_ROUND_UP(screen.bitsPerPixel, 8) * 2;
 
+pixman_image = image;
 dataProviderRef = CGDataProviderCreateWithData(NULL, 
pixman_image_get_data(image), w * 4 * h, NULL);
 
 // update windows
@@ -1013,7 +1020,6 @@ @interface QemuCocoaAppController : NSObject
 #endif
 {
 }
-- (void)startEmulationWithArgc:(int)argc argv:(char**)argv;
 - (void)doToggleFullScreen:(id)sender;
 - (void)toggleFullScreen:(id)sender;
 - (void)showQEMUDoc:(id)sender;
@@ -1101,8 +1107,8 @@ - (void) dealloc
 - (void)applicationDidFinishLaunching: (NSNotification *) note
 {
 COCOA_DEBUG("QemuCocoaAppController: applicationDidFinishLaunching\n");
-// launch QEMU, with the global args
-[self startEmulationWithArgc:gArgc argv:(char **)gArgv];
+/* Tell cocoa_display_init to proceed */
+qemu_sem_post(&app_started_sem);
 }
 
 - (void)applicationWillTerminate:(NSNotification *)aNotification
@@ -1145,15 +1151,6 @@ - (void) applicationWillResignActive: (NSNotification 
*)aNotification
 [cocoaView raiseAllKeys];
 }
 
-- (void)startEmulationWithArgc:(int)argc argv:(char**)argv
-{
-COCOA_DEBUG("QemuCocoaAppController: startEmulationWithArgc\n");
-
-int status;
-status = qemu_main(argc, argv, *_NSGetEnviron());
-exit(status);
-}
-
 /* We abstract the method called by the Enter Fullscreen menu item
  * because Mac OS 10.7 and higher disables it. This is because of the
  * menu item's old selector's name toggleFullScreen:
@@ -1485,7 +1482,9 @@ @implementation QemuApplication
 - (void)sendEvent:(NSEvent *)event
 {
 COCOA_DEBUG("QemuApplication: sendEvent\n");
-[super sendEvent: event];
+if (!cocoaView || ![cocoaView handleEvent:event]) {
+[super sendEvent: event];
+}
 }
 @end
 
@@ -1668,32 +1667,59 @@ static void addRemovableDevicesMenuItems(void)
 qapi_free_BlockInfoList(pointerToFree);
 }
 
-int main (int argc, const char * argv[]) {
+/*
+ * The startup process for the OSX/Cocoa UI is complicated, because
+ * OSX insists that the UI runs on the initial main thread, and so we
+ * need to start a second thread which runs the vl.c qemu_main():
+ *
+ * Initial thread:2nd thread:
+ * in main():
+ *  create qemu-main thread
+ *  wait on display_init semaphore
+ *call qemu_main()
+ *...
+ *in cocoa_display_init():
+ * post the display_init semaphore
+ * wait on app_started semaphore
+ *  create application, menus, etc
+ *  enter OSX run loop
+ * in applicationDidFinishLaunching:
+ *  post app_started semaphore
+ * tell main thread to fullscreen if needed
+ *

Re: [Qemu-devel] Crash when booting KDE Neon using qxl-vga

2019-02-14 Thread Dr. David Alan Gilbert
* Leonardo Soares Müller (leozinho29...@hotmail.com) wrote:
> I can confirm this, KDE Neon using the command line similar to yours
> crashes QEMU to me too. I will test with Mageia 7 later to see if it
> behaves differently.
> 
> But this is a completely different crash. This crash is happening
> earlier, what I reported first is a crash when the login screen should
> load, this is happening earlier on boot.
> 
> The command line I used this time:
> 
> qemu-system-x86_64 -M pc,accel=kvm -smp 3 -m 4G -drive
> if=virtio,file=neonbroken.qcow2 -vga qxl -bios /usr/share/ovmf/OVMF.fd

Yes, this was: https://bugs.launchpad.net/qemu/+bug/1813940

Dave

> The backtrace:
> 
> (gdb) bt
> #0  0x70371e97 in __GI_raise (sig=sig@entry=6) at
> ../sysdeps/unix/sysv/linux/raise.c:51
> #1  0x70373801 in __GI_abort () at abort.c:79
> #2  0x5589eac9 in kvm_mem_ioeventfd_add
> (listener=0x56a1fdc8, section=0x7fffc7ffba90, match_data=false,
> data=0, e=0x578c7fc8) at
> /home/usuario/Documentos/qemu/accel/kvm/kvm-all.c:866
> #3  0x5588300a in address_space_add_del_ioeventfds
> (as=0x567e5a00 , fds_new=0x7fffbc000d30,
> fds_new_nb=1, fds_old=0x0, fds_old_nb=0) at
> /home/usuario/Documentos/qemu/memory.c:793
> #4  0x558832f4 in address_space_update_ioeventfds
> (as=0x567e5a00 ) at
> /home/usuario/Documentos/qemu/memory.c:843
> #5  0x5588415b in memory_region_transaction_commit () at
> /home/usuario/Documentos/qemu/memory.c:1094
> #6  0x558871c8 in memory_region_add_eventfd (mr=0x578b6420,
> addr=0, size=0, match_data=false, data=0, e=0x578c7fc8) at
> /home/usuario/Documentos/qemu/memory.c:2303
> #7  0x55c26cd0 in virtio_pci_ioeventfd_assign (d=0x578b5750,
> notifier=0x578c7fc8, n=0, assign=true) at hw/virtio/virtio-pci.c:243
> #8  0x55c24dd5 in virtio_bus_set_host_notifier
> (bus=0x578bd848, n=0, assign=true) at hw/virtio/virtio-bus.c:283
> #9  0x558ce648 in virtio_blk_data_plane_start
> (vdev=0x578bd8c0) at
> /home/usuario/Documentos/qemu/hw/block/dataplane/virtio-blk.c:200
> #10 0x55c24af2 in virtio_bus_start_ioeventfd
> (bus=0x578bd848) at hw/virtio/virtio-bus.c:223
> #11 0x55c26e57 in virtio_pci_start_ioeventfd
> (proxy=0x578b5750) at hw/virtio/virtio-pci.c:282
> #12 0x55c29285 in virtio_pci_common_write
> (opaque=0x578b5750, addr=20, val=15, size=1) at
> hw/virtio/virtio-pci.c:1233
> #13 0x55881ebd in memory_region_write_accessor
> (mr=0x578b6120, addr=20, value=0x7fffc7ffbf38, size=1, shift=0,
> mask=255, attrs=...) at /home/usuario/Documentos/qemu/memory.c:502
> #14 0x558820cd in access_with_adjusted_size (addr=20,
> value=0x7fffc7ffbf38, size=1, access_size_min=1, access_size_max=4,
> access_fn=0x55881dd4 ,
> mr=0x578b6120, attrs=...) at /home/usuario/Documentos/qemu/memory.c:568
> #15 0x55885100 in memory_region_dispatch_write
> (mr=0x578b6120, addr=20, data=15, size=1, attrs=...) at
> /home/usuario/Documentos/qemu/memory.c:1499
> #16 0x5581bca9 in flatview_write_continue (fv=0x7fffcc50f4f0,
> addr=34359738388, attrs=..., buf=0x77fee028 "\017", len=1, addr1=20,
> l=1, mr=0x578b6120) at /home/usuario/Documentos/qemu/exec.c:3234
> #17 0x5581bdf3 in flatview_write (fv=0x7fffcc50f4f0,
> addr=34359738388, attrs=..., buf=0x77fee028 "\017", len=1) at
> /home/usuario/Documentos/qemu/exec.c:3273
> #18 0x5581c0f9 in address_space_write (as=0x567e5a00
> , addr=34359738388, attrs=..., buf=0x77fee028
> "\017", len=1) at /home/usuario/Documentos/qemu/exec.c:3363
> #19 0x5581c14a in address_space_rw (as=0x567e5a00
> , addr=34359738388, attrs=..., buf=0x77fee028
> "\017", len=1, is_write=true) at /home/usuario/Documentos/qemu/exec.c:3374
> #20 0x558a146f in kvm_cpu_exec (cpu=0x56afe140) at
> /home/usuario/Documentos/qemu/accel/kvm/kvm-all.c:2031
> #21 0x55865a3e in qemu_kvm_cpu_thread_fn (arg=0x56afe140) at
> /home/usuario/Documentos/qemu/cpus.c:1281
> #22 0x55e1ba02 in qemu_thread_start (args=0x56b20440) at
> util/qemu-thread-posix.c:502
> #23 0x7072b6db in start_thread (arg=0x7fffc7fff700) at
> pthread_create.c:463
> #24 0x7045488f in clone () at
> ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
> 
> 
> Às 11:36 de 01/02/2019, Dr. David Alan Gilbert escreveu:
> > 
> > Hmm, I'm also getting a crash, but I think it's very different from
> > yours:
> > 
> > ./x86_64-softmmu/qemu-system-x86_64 -M pc,accel=kvm -smp 3 -m 8G -cdrom 
> > /home/vmimages/neon-useredition-current.iso -drive 
> > if=virtio,file=/home/vmimages/kde-neon.qcow2 -vga qxl
> > 
> > kvm_mem_ioeventfd_add: error adding ioeventfd: No space left on device
> > Aborted (core dumped)
> > --
> > Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK
> > 
--
Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK



[Qemu-devel] [PATCH v2 0/7] ui/cocoa: Use OSX's main loop

2019-02-14 Thread Peter Maydell
This set of patches rearranges how we handle events on
the OSX Cocoa UI so that we use the main thread to run
the OSX event loop, and we don't do a long blocking
operation from the applicationDidFinishLaunching callback.
Instead we create a second thread which runs qemu_main()
and becomes the QEMU main-loop thread. The callbacks from
QEMU into the cocoa code asynchronously dispatch their
work to the main thread, and the main thread takes the
iothread lock before calling into QEMU code.

NB: the code to asynchronously run code blocks on the
main thread uses dispatch_get_main_queue(), which is a
10.10-or-later function. I think the benefit in
clarity-of-code is a worthwhile gain for dropping support
for ancient OSX versions.

The change from v1 is that we actually wire up input events
from OSX to the handleEvent method. There are a couple of
plausible ways we could do this:

 * most OSX apps do this by implementing event handling
   methods on their NSView. This won't work for us, because
   these only get called after OSX has dealt with some events
   like menu bar accelerator keystrokes, and we would like to
   send those to the guest instead in some situations.
 * we could use addLocalMonitorForEventsMatchingMask to
   add a "local event monitor", which gets to examine/filter
   events before the usual OSX event processing. I think this
   would work, but it's not what I chose
 * we can subclass NSApplication and implement a custom
   sendEvent method in our subclass. This gets all events
   first and can either handle them or call the superclass
   sendEvent to hand them to OSX as usual. This is what I
   ended up going for.
 * It is also possible to implement sendEvent on NSWindow,
   but I think this has the "only called after OSX has done
   menu keystroke processing" issue.

I've tested this a bit better than the v1 RFC, and it seems
to work OK for me.

Patchset structure:
 * patch 1 does the "make sure we have the iothread lock for
   calls into QEMU" (which is effectively a no-op initially
   since we'll already be holding that lock when our refresh
   etc callbacks are called)
 * patch 2 makes switchSurface directly take the pixman image
   (which is refcounted) rather than the DisplaySurface (which
   is not), so we can make the calls to it asynchronous later
 * patches 3 and 4 are just trivial code motion
 * patch 5 (new in v2) restructures handleEvent so it doesn't
   directly call sendEvent but instead returns a flag indicating
   whether it consumed the event or not
 * patch 6 (new in v2) subclasses NSApplication
 * patch 7 (the old patch 5) does the bulk of the work (and can't
   really be split further without the UI being broken at the
   intermediate point)

thanks
-- PMM


Peter Maydell (7):
  ui/cocoa: Ensure we have the iothread lock when calling into QEMU
  ui/cocoa: Use the pixman image directly in switchSurface
  ui/cocoa: Factor out initial menu creation
  ui/cocoa: Move console/device menu creation code up in file
  ui/cocoa: Don't call NSApp sendEvent directly from handleEvent
  ui/cocoa: Subclass NSApplication so we can implement sendEvent
  ui/cocoa: Perform UI operations only on the main thread

 ui/cocoa.m | 483 -
 1 file changed, 294 insertions(+), 189 deletions(-)

-- 
2.17.2 (Apple Git-113)




[Qemu-devel] [PATCH v2 4/7] ui/cocoa: Move console/device menu creation code up in file

2019-02-14 Thread Peter Maydell
Move the console/device menu creation code functions
further up in the source file, next to the code which
creates the initial menus. We're going to want to
change the location we call these functions from in
the next patch.

This commit is a pure code move with no other changes.

Signed-off-by: Peter Maydell 
---
 ui/cocoa.m | 184 ++---
 1 file changed, 92 insertions(+), 92 deletions(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 0b1cd31543..2d943b6e2a 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -1548,6 +1548,98 @@ static void create_initial_menus(void)
 [[NSApp mainMenu] addItem:menuItem];
 }
 
+/* Returns a name for a given console */
+static NSString * getConsoleName(QemuConsole * console)
+{
+return [NSString stringWithFormat: @"%s", qemu_console_get_label(console)];
+}
+
+/* Add an entry to the View menu for each console */
+static void add_console_menu_entries(void)
+{
+NSMenu *menu;
+NSMenuItem *menuItem;
+int index = 0;
+
+menu = [[[NSApp mainMenu] itemWithTitle:@"View"] submenu];
+
+[menu addItem:[NSMenuItem separatorItem]];
+
+while (qemu_console_lookup_by_index(index) != NULL) {
+menuItem = [[[NSMenuItem alloc] initWithTitle: 
getConsoleName(qemu_console_lookup_by_index(index))
+   action: 
@selector(displayConsole:) keyEquivalent: @""] autorelease];
+[menuItem setTag: index];
+[menu addItem: menuItem];
+index++;
+}
+}
+
+/* Make menu items for all removable devices.
+ * Each device is given an 'Eject' and 'Change' menu item.
+ */
+static void addRemovableDevicesMenuItems(void)
+{
+NSMenu *menu;
+NSMenuItem *menuItem;
+BlockInfoList *currentDevice, *pointerToFree;
+NSString *deviceName;
+
+currentDevice = qmp_query_block(NULL);
+pointerToFree = currentDevice;
+if(currentDevice == NULL) {
+NSBeep();
+QEMU_Alert(@"Failed to query for block devices!");
+return;
+}
+
+menu = [[[NSApp mainMenu] itemWithTitle:@"Machine"] submenu];
+
+// Add a separator between related groups of menu items
+[menu addItem:[NSMenuItem separatorItem]];
+
+// Set the attributes to the "Removable Media" menu item
+NSString *titleString = @"Removable Media";
+NSMutableAttributedString *attString=[[NSMutableAttributedString alloc] 
initWithString:titleString];
+NSColor *newColor = [NSColor blackColor];
+NSFontManager *fontManager = [NSFontManager sharedFontManager];
+NSFont *font = [fontManager fontWithFamily:@"Helvetica"
+  
traits:NSBoldFontMask|NSItalicFontMask
+  weight:0
+size:14];
+[attString addAttribute:NSFontAttributeName value:font 
range:NSMakeRange(0, [titleString length])];
+[attString addAttribute:NSForegroundColorAttributeName value:newColor 
range:NSMakeRange(0, [titleString length])];
+[attString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber 
numberWithInt: 1] range:NSMakeRange(0, [titleString length])];
+
+// Add the "Removable Media" menu item
+menuItem = [NSMenuItem new];
+[menuItem setAttributedTitle: attString];
+[menuItem setEnabled: NO];
+[menu addItem: menuItem];
+
+/* Loop through all the block devices in the emulator */
+while (currentDevice) {
+deviceName = [[NSString stringWithFormat: @"%s", 
currentDevice->value->device] retain];
+
+if(currentDevice->value->removable) {
+menuItem = [[NSMenuItem alloc] initWithTitle: [NSString 
stringWithFormat: @"Change %s...", currentDevice->value->device]
+  action: 
@selector(changeDeviceMedia:)
+   keyEquivalent: @""];
+[menu addItem: menuItem];
+[menuItem setRepresentedObject: deviceName];
+[menuItem autorelease];
+
+menuItem = [[NSMenuItem alloc] initWithTitle: [NSString 
stringWithFormat: @"Eject %s", currentDevice->value->device]
+  action: 
@selector(ejectDeviceMedia:)
+   keyEquivalent: @""];
+[menu addItem: menuItem];
+[menuItem setRepresentedObject: deviceName];
+[menuItem autorelease];
+}
+currentDevice = currentDevice->next;
+}
+qapi_free_BlockInfoList(pointerToFree);
+}
+
 int main (int argc, const char * argv[]) {
 
 gArgc = argc;
@@ -1676,98 +1768,6 @@ static void cocoa_cleanup(void)
 .dpy_refresh = cocoa_refresh,
 };
 
-/* Returns a name for a given console */
-static NSString * getConsoleName(QemuConsole * console)
-{
-return [NSString stringWithFormat: @"%s", qemu_console_get_label(console)];
-}
-
-/* Add an entry to the View menu for each console */
-static void add_console_menu_entries(void)
-{
-NS

[Qemu-devel] [PATCH v2 3/7] ui/cocoa: Factor out initial menu creation

2019-02-14 Thread Peter Maydell
Factor out the long code sequence in main() which creates
the initial set of menus. This will make later patches
which move initialization code around a bit clearer.

Signed-off-by: Peter Maydell 
---
 ui/cocoa.m | 78 --
 1 file changed, 41 insertions(+), 37 deletions(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 9d23732ff9..0b1cd31543 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -1461,43 +1461,8 @@ - (void)adjustSpeed:(id)sender
 
 @end
 
-
-int main (int argc, const char * argv[]) {
-
-gArgc = argc;
-gArgv = (char **)argv;
-int i;
-
-/* In case we don't need to display a window, let's not do that */
-for (i = 1; i < argc; i++) {
-const char *opt = argv[i];
-
-if (opt[0] == '-') {
-/* Treat --foo the same as -foo.  */
-if (opt[1] == '-') {
-opt++;
-}
-if (!strcmp(opt, "-h") || !strcmp(opt, "-help") ||
-!strcmp(opt, "-vnc") ||
-!strcmp(opt, "-nographic") ||
-!strcmp(opt, "-version") ||
-!strcmp(opt, "-curses") ||
-!strcmp(opt, "-display") ||
-!strcmp(opt, "-qtest")) {
-return qemu_main(gArgc, gArgv, *_NSGetEnviron());
-}
-}
-}
-
-NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
-
-// Pull this console process up to being a fully-fledged graphical
-// app with a menubar and Dock icon
-ProcessSerialNumber psn = { 0, kCurrentProcess };
-TransformProcessType(&psn, kProcessTransformToForegroundApplication);
-
-[NSApplication sharedApplication];
-
+static void create_initial_menus(void)
+{
 // Add menus
 NSMenu  *menu;
 NSMenuItem  *menuItem;
@@ -1581,6 +1546,45 @@ int main (int argc, const char * argv[]) {
 menuItem = [[[NSMenuItem alloc] initWithTitle:@"Window" action:nil 
keyEquivalent:@""] autorelease];
 [menuItem setSubmenu:menu];
 [[NSApp mainMenu] addItem:menuItem];
+}
+
+int main (int argc, const char * argv[]) {
+
+gArgc = argc;
+gArgv = (char **)argv;
+int i;
+
+/* In case we don't need to display a window, let's not do that */
+for (i = 1; i < argc; i++) {
+const char *opt = argv[i];
+
+if (opt[0] == '-') {
+/* Treat --foo the same as -foo.  */
+if (opt[1] == '-') {
+opt++;
+}
+if (!strcmp(opt, "-h") || !strcmp(opt, "-help") ||
+!strcmp(opt, "-vnc") ||
+!strcmp(opt, "-nographic") ||
+!strcmp(opt, "-version") ||
+!strcmp(opt, "-curses") ||
+!strcmp(opt, "-display") ||
+!strcmp(opt, "-qtest")) {
+return qemu_main(gArgc, gArgv, *_NSGetEnviron());
+}
+}
+}
+
+NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+
+// Pull this console process up to being a fully-fledged graphical
+// app with a menubar and Dock icon
+ProcessSerialNumber psn = { 0, kCurrentProcess };
+TransformProcessType(&psn, kProcessTransformToForegroundApplication);
+
+[NSApplication sharedApplication];
+
+create_initial_menus();
 
 // Create an Application controller
 QemuCocoaAppController *appController = [[QemuCocoaAppController alloc] 
init];
-- 
2.17.2 (Apple Git-113)




[Qemu-devel] [PATCH v2 5/7] ui/cocoa: Don't call NSApp sendEvent directly from handleEvent

2019-02-14 Thread Peter Maydell
Currently the handleEvent method will directly call the NSApp
sendEvent method for any events that we want to let OSX deal
with. When we rearrange the event handling code, the way that
we say "let OSX have this event" is going to change. Prepare
for that by refactoring so that handleEvent returns a flag
indicating whether it consumed the event.

Suggested-by: BALATON Zoltan 
Signed-off-by: Peter Maydell 
---
New patch in v2
---
 ui/cocoa.m | 49 ++---
 1 file changed, 34 insertions(+), 15 deletions(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 2d943b6e2a..5a84e1aea7 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -129,8 +129,9 @@
 NSTextField *pauseLabel;
 NSArray * supportedImageFileTypes;
 
-// Utility function to run specified code block with iothread lock held
+// Utility functions to run specified code block with iothread lock held
 typedef void (^CodeBlock)(void);
+typedef bool (^BoolCodeBlock)(void);
 
 static void with_iothread_lock(CodeBlock block)
 {
@@ -144,6 +145,21 @@ static void with_iothread_lock(CodeBlock block)
 }
 }
 
+static bool bool_with_iothread_lock(BoolCodeBlock block)
+{
+bool locked = qemu_mutex_iothread_locked();
+bool val;
+
+if (!locked) {
+qemu_mutex_lock_iothread();
+}
+val = block();
+if (!locked) {
+qemu_mutex_unlock_iothread();
+}
+return val;
+}
+
 // Mac to QKeyCode conversion
 const int mac_to_qkeycode_map[] = {
 [kVK_ANSI_A] = Q_KEY_CODE_A,
@@ -320,8 +336,8 @@ - (void) grabMouse;
 - (void) ungrabMouse;
 - (void) toggleFullScreen:(id)sender;
 - (void) handleMonitorInput:(NSEvent *)event;
-- (void) handleEvent:(NSEvent *)event;
-- (void) handleEventLocked:(NSEvent *)event;
+- (bool) handleEvent:(NSEvent *)event;
+- (bool) handleEventLocked:(NSEvent *)event;
 - (void) setAbsoluteEnabled:(BOOL)tIsAbsoluteEnabled;
 /* The state surrounding mouse grabbing is potentially confusing.
  * isAbsoluteEnabled tracks qemu_input_is_absolute() [ie "is the emulated
@@ -664,15 +680,16 @@ - (void) handleMonitorInput:(NSEvent *)event
 }
 }
 
-- (void) handleEvent:(NSEvent *)event
+- (bool) handleEvent:(NSEvent *)event
 {
-with_iothread_lock(^{
-[self handleEventLocked:event];
+return bool_with_iothread_lock(^{
+return [self handleEventLocked:event];
 });
 }
 
-- (void) handleEventLocked:(NSEvent *)event
+- (bool) handleEventLocked:(NSEvent *)event
 {
+/* Return true if we handled the event, false if it should be given to OSX 
*/
 COCOA_DEBUG("QemuCocoaView: handleEvent\n");
 int buttons = 0;
 int keycode = 0;
@@ -743,8 +760,7 @@ - (void) handleEventLocked:(NSEvent *)event
 if (keycode == Q_KEY_CODE_F) {
 switched_to_fullscreen = true;
 }
-[NSApp sendEvent:event];
-return;
+return false;
 }
 
 // default
@@ -759,12 +775,12 @@ - (void) handleEventLocked:(NSEvent *)event
 // enable graphic console
 case '1' ... '9':
 console_select(key - '0' - 1); /* ascii math */
-return;
+return true;
 
 // release the mouse grab
 case 'g':
 [self ungrabMouse];
-return;
+return true;
 }
 }
 }
@@ -781,7 +797,7 @@ - (void) handleEventLocked:(NSEvent *)event
 // don't pass the guest a spurious key-up if we treated this
 // command-key combo as a host UI action
 if (!isMouseGrabbed && ([event modifierFlags] & 
NSEventModifierFlagCommand)) {
-return;
+return true;
 }
 
 if (qemu_console_is_graphic(NULL)) {
@@ -875,7 +891,7 @@ - (void) handleEventLocked:(NSEvent *)event
 mouse_event = false;
 break;
 default:
-[NSApp sendEvent:event];
+return false;
 }
 
 if (mouse_event) {
@@ -911,10 +927,11 @@ - (void) handleEventLocked:(NSEvent *)event
 qemu_input_queue_rel(dcl->con, INPUT_AXIS_Y, (int)[event 
deltaY]);
 }
 } else {
-[NSApp sendEvent:event];
+return false;
 }
 qemu_input_event_sync();
 }
+return true;
 }
 
 - (void) grabMouse
@@ -1749,7 +1766,9 @@ static void cocoa_refresh(DisplayChangeListener *dcl)
 event = [NSApp nextEventMatchingMask:NSEventMaskAny 
untilDate:distantPast
 inMode: NSDefaultRunLoopMode dequeue:YES];
 if (event != nil) {
-[cocoaView handleEvent:event];
+if (![cocoaView handleEvent:event]) {
+[NSApp sendEvent:event];
+}
 }
 } while(event != nil);
 [pool release];
-- 
2.17.2 (App

[Qemu-devel] [PATCH v2 1/7] ui/cocoa: Ensure we have the iothread lock when calling into QEMU

2019-02-14 Thread Peter Maydell
The Cocoa UI should run on the main thread; this is enforced
in OSX Mojave. In order to be able to run on the main thread,
we need to make sure we hold the iothread lock whenever we
call into various QEMU UI midlayer functions.

Signed-off-by: Peter Maydell 
---
 ui/cocoa.m | 83 ++
 1 file changed, 59 insertions(+), 24 deletions(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index e2567d6946..2931c751fd 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -129,6 +129,21 @@
 NSTextField *pauseLabel;
 NSArray * supportedImageFileTypes;
 
+// Utility function to run specified code block with iothread lock held
+typedef void (^CodeBlock)(void);
+
+static void with_iothread_lock(CodeBlock block)
+{
+bool locked = qemu_mutex_iothread_locked();
+if (!locked) {
+qemu_mutex_lock_iothread();
+}
+block();
+if (!locked) {
+qemu_mutex_unlock_iothread();
+}
+}
+
 // Mac to QKeyCode conversion
 const int mac_to_qkeycode_map[] = {
 [kVK_ANSI_A] = Q_KEY_CODE_A,
@@ -306,6 +321,7 @@ - (void) ungrabMouse;
 - (void) toggleFullScreen:(id)sender;
 - (void) handleMonitorInput:(NSEvent *)event;
 - (void) handleEvent:(NSEvent *)event;
+- (void) handleEventLocked:(NSEvent *)event;
 - (void) setAbsoluteEnabled:(BOOL)tIsAbsoluteEnabled;
 /* The state surrounding mouse grabbing is potentially confusing.
  * isAbsoluteEnabled tracks qemu_input_is_absolute() [ie "is the emulated
@@ -649,8 +665,14 @@ - (void) handleMonitorInput:(NSEvent *)event
 
 - (void) handleEvent:(NSEvent *)event
 {
-COCOA_DEBUG("QemuCocoaView: handleEvent\n");
+with_iothread_lock(^{
+[self handleEventLocked:event];
+});
+}
 
+- (void) handleEventLocked:(NSEvent *)event
+{
+COCOA_DEBUG("QemuCocoaView: handleEvent\n");
 int buttons = 0;
 int keycode = 0;
 bool mouse_event = false;
@@ -945,15 +967,18 @@ - (QEMUScreen) gscreen {return screen;}
  */
 - (void) raiseAllKeys
 {
-int index;
 const int max_index = ARRAY_SIZE(modifiers_state);
 
-   for (index = 0; index < max_index; index++) {
-   if (modifiers_state[index]) {
-   modifiers_state[index] = 0;
-   qemu_input_event_send_key_qcode(dcl->con, index, false);
-   }
-   }
+with_iothread_lock(^{
+int index;
+
+for (index = 0; index < max_index; index++) {
+if (modifiers_state[index]) {
+modifiers_state[index] = 0;
+qemu_input_event_send_key_qcode(dcl->con, index, false);
+}
+}
+});
 }
 @end
 
@@ -1215,13 +1240,17 @@ - (void)removePause
 /* Restarts QEMU */
 - (void)restartQEMU:(id)sender
 {
-qmp_system_reset(NULL);
+with_iothread_lock(^{
+qmp_system_reset(NULL);
+});
 }
 
 /* Powers down QEMU */
 - (void)powerDownQEMU:(id)sender
 {
-qmp_system_powerdown(NULL);
+with_iothread_lock(^{
+qmp_system_powerdown(NULL);
+});
 }
 
 /* Ejects the media.
@@ -1237,9 +1266,11 @@ - (void)ejectDeviceMedia:(id)sender
 return;
 }
 
-Error *err = NULL;
-qmp_eject(true, [drive cStringUsingEncoding: NSASCIIStringEncoding],
-  false, NULL, false, false, &err);
+__block Error *err = NULL;
+with_iothread_lock(^{
+qmp_eject(true, [drive cStringUsingEncoding: NSASCIIStringEncoding],
+  false, NULL, false, false, &err);
+});
 handleAnyDeviceErrors(err);
 }
 
@@ -1271,16 +1302,18 @@ - (void)changeDeviceMedia:(id)sender
 return;
 }
 
-Error *err = NULL;
-qmp_blockdev_change_medium(true,
-   [drive cStringUsingEncoding:
-  NSASCIIStringEncoding],
-   false, NULL,
-   [file cStringUsingEncoding:
- NSASCIIStringEncoding],
-   true, "raw",
-   false, 0,
-   &err);
+__block Error *err = NULL;
+with_iothread_lock(^{
+qmp_blockdev_change_medium(true,
+   [drive cStringUsingEncoding:
+  NSASCIIStringEncoding],
+   false, NULL,
+   [file cStringUsingEncoding:
+ NSASCIIStringEncoding],
+   true, "raw",
+   false, 0,
+   &err);
+});
 handleAnyDeviceErrors(err);
 }
 }
@@ -1419,7 +1452,9 @@ - (void)adjustSpeed:(id)sender
 // get the throttle percentage
 throttle_pct = [sender tag];
 
-cpu_throttle_set(throttle_pct);
+with_iothread_lock(^{
+cpu_throttle_set(throttle_pct);
+});
 COCOA_DEBUG("cpu throttling at %d%c\n", cpu_throttle_ge

Re: [Qemu-devel] [PATCH 0/4] target/arm: Reduce overhead of cpu_get_tb_cpu_state

2019-02-14 Thread Laurent Desnogues
Hi Richard,

On Thu, Feb 14, 2019 at 5:07 AM Richard Henderson
 wrote:
>
> We've talked about this before, caching state to reduce the
> amount of computation that happens looking up each TB.
>
> I know that Peter has been concerned that we would not be able to
> reliably maintain all of the places that need to be updates to
> keep this up-to-date.
>
> Well, modulo dirty tricks within linux-user, it appears as if
> exception delivery and return, plus after every TB-ending write
> to a system register is sufficient.
>
> There seems to be a noticable improvement, although wall-time
> is harder to come by -- all of my system-level measurements
> include user input, and my user-level measurements seem to be
> too small to matter.

FWIW this patch series made a run of linux-user AArch64 176.gcc 166.i
go from 29.5s down to 24.5s (on an E5-2650 v2).  Though that'd need
more benchmarks, that looks quite good to me.

Thanks,

Laurent

>
> r~
>
>
> Richard Henderson (4):
>   target/arm: Split out recompute_hflags et al
>   target/arm: Rebuild hflags at el changes and MSR writes
>   target/arm: Assert hflags is correct in cpu_get_tb_cpu_state
>   target/arm: Rely on hflags correct in cpu_get_tb_cpu_state
>
>  target/arm/cpu.h   |  22 ++-
>  target/arm/helper.h|   3 +
>  target/arm/internals.h |   4 +
>  linux-user/syscall.c   |   1 +
>  target/arm/cpu.c   |   1 +
>  target/arm/helper-a64.c|   3 +
>  target/arm/helper.c| 267 ++---
>  target/arm/machine.c   |   1 +
>  target/arm/op_helper.c |   1 +
>  target/arm/translate-a64.c |   6 +-
>  target/arm/translate.c |  14 +-
>  11 files changed, 204 insertions(+), 119 deletions(-)
>
> --
> 2.17.1
>
>



[Qemu-devel] [PATCH v2 2/7] ui/cocoa: Use the pixman image directly in switchSurface

2019-02-14 Thread Peter Maydell
Currently the switchSurface method takes a DisplaySurface. We want
to change our DisplayChangeListener's dpy_gfx_switch callback
to do this work asynchronously on a different thread. The caller
of the switch callback will free the old DisplaySurface
immediately the callback returns, so to ensure that the
other thread doesn't access freed data we need to switch
to using the underlying pixman image instead. The pixman
image is reference counted, so we will be able to take
a reference to it to avoid it vanishing too early.

In this commit we only change the switchSurface method
to take a pixman image, and keep the flow of control
synchronous for now.

Signed-off-by: Peter Maydell 
---
 ui/cocoa.m | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 2931c751fd..9d23732ff9 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -315,7 +315,7 @@ @interface QemuCocoaView : NSView
 BOOL isAbsoluteEnabled;
 BOOL isMouseDeassociated;
 }
-- (void) switchSurface:(DisplaySurface *)surface;
+- (void) switchSurface:(pixman_image_t *)image;
 - (void) grabMouse;
 - (void) ungrabMouse;
 - (void) toggleFullScreen:(id)sender;
@@ -495,12 +495,13 @@ - (void) setContentDimensions
 }
 }
 
-- (void) switchSurface:(DisplaySurface *)surface
+- (void) switchSurface:(pixman_image_t *)image
 {
 COCOA_DEBUG("QemuCocoaView: switchSurface\n");
 
-int w = surface_width(surface);
-int h = surface_height(surface);
+int w = pixman_image_get_width(image);
+int h = pixman_image_get_height(image);
+pixman_format_code_t image_format = pixman_image_get_format(image);
 /* cdx == 0 means this is our very first surface, in which case we need
  * to recalculate the content dimensions even if it happens to be the size
  * of the initial empty window.
@@ -522,10 +523,10 @@ - (void) switchSurface:(DisplaySurface *)surface
 CGDataProviderRelease(dataProviderRef);
 
 //sync host window color space with guests
-screen.bitsPerPixel = surface_bits_per_pixel(surface);
-screen.bitsPerComponent = surface_bytes_per_pixel(surface) * 2;
+screen.bitsPerPixel = PIXMAN_FORMAT_BPP(image_format);
+screen.bitsPerComponent = DIV_ROUND_UP(screen.bitsPerPixel, 8) * 2;
 
-dataProviderRef = CGDataProviderCreateWithData(NULL, 
surface_data(surface), w * 4 * h, NULL);
+dataProviderRef = CGDataProviderCreateWithData(NULL, 
pixman_image_get_data(image), w * 4 * h, NULL);
 
 // update windows
 if (isFullscreen) {
@@ -1625,7 +1626,7 @@ static void cocoa_switch(DisplayChangeListener *dcl,
 NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
 
 COCOA_DEBUG("qemu_cocoa: cocoa_switch\n");
-[cocoaView switchSurface:surface];
+[cocoaView switchSurface:surface->image];
 [pool release];
 }
 
-- 
2.17.2 (Apple Git-113)




[Qemu-devel] [PATCH v2 6/7] ui/cocoa: Subclass NSApplication so we can implement sendEvent

2019-02-14 Thread Peter Maydell
When we switch away from our custom event handling, we still want to
be able to have first go at any events our application receives,
because in full-screen mode we want to send key events to the guest,
even if they would be menu item activation events. There are several
ways we could do that, but one simple approach is to subclass
NSApplication so we can implement a custom sendEvent method.
Do that, but for the moment have our sendEvent just invoke the
superclass method.

Signed-off-by: Peter Maydell 
---
New patch in v2
---
 ui/cocoa.m | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 5a84e1aea7..184fbd877d 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -1478,6 +1478,17 @@ - (void)adjustSpeed:(id)sender
 
 @end
 
+@interface QemuApplication : NSApplication
+@end
+
+@implementation QemuApplication
+- (void)sendEvent:(NSEvent *)event
+{
+COCOA_DEBUG("QemuApplication: sendEvent\n");
+[super sendEvent: event];
+}
+@end
+
 static void create_initial_menus(void)
 {
 // Add menus
@@ -1691,7 +1702,7 @@ int main (int argc, const char * argv[]) {
 ProcessSerialNumber psn = { 0, kCurrentProcess };
 TransformProcessType(&psn, kProcessTransformToForegroundApplication);
 
-[NSApplication sharedApplication];
+[QemuApplication sharedApplication];
 
 create_initial_menus();
 
-- 
2.17.2 (Apple Git-113)




Re: [Qemu-devel] [PATCH v2 12/15] s390x/tcg: Implement XxC and checks for most FP instructions

2019-02-14 Thread David Hildenbrand
On 14.02.19 06:25, Richard Henderson wrote:
> On 2/13/19 11:53 AM, David Hildenbrand wrote:
>> On 13.02.19 20:31, Richard Henderson wrote:
>>> On 2/13/19 6:33 AM, David Hildenbrand wrote:
 With the floating-point extension facility
 - CONVERT FROM LOGICAL
 - CONVERT TO LOGICAL
 - CONVERT TO FIXED
 - CONVERT FROM FIXED
 - LOAD FP INTEGER
 have both, a rounding mode specification and the inexact-exception control
 (XxC). Other instructions will be handled separatly.

 Check for valid rounding modes and forward also the XxC (via m4). To avoid
 a lot of boilerplate code and changes to the helpers, combine both, the
 m3 and m4 field in a combined 32 bit TCG variable. Perform checks at
 a central place, taking in account if the m3 or m4 field was ignore
 before the floating-point extension facility was introduced.

 Signed-off-by: David Hildenbrand 
>>>
>>> Reviewed-by: Richard Henderson 
>>>
 +static inline bool xxc_from_m34(uint32_t m34)
 +{
 +/* XxC is bit 1 of m4 */
 +return (extract32(m34, 4, 4) & 0x4) != 0;
>>>
>>> Better as extract32(m32, 6, 1);
>>
>> Is it "better as" that or "better written as" that?
>>
>> I think "extract32(m34, 4, 4) & 0x4" is slightly easier to understand.
>> (get m4 field and take the bit number 1)
> 
> I don't like not extracting the bit that you want.  Do you prefer to let the
> compiler fold the constant?  E.g.  4 + 3 - 1?

Yes, that looks better.

> 
> I hate big-endian bit numbering...
> 
> 
> r~
> 


-- 

Thanks,

David / dhildenb



Re: [Qemu-devel] [PATCH 4/4] wavcapture: Convert to error_report

2019-02-14 Thread Markus Armbruster
"Dr. David Alan Gilbert (git)"  writes:

> From: "Dr. David Alan Gilbert" 
>
> Kill off a pile of monitor_printf's and cur_mon usage.

You also switch from the two line error format


Reason: 

to the more common

: 

Suggest to mention that you're changing error messages in the commit
message.

> The only one left in wavcapture.c is the info case.
>
> Signed-off-by: Dr. David Alan Gilbert 

Reviewed-by: Markus Armbruster 



Re: [Qemu-devel] [Qemu-trivial] [PATCH] configure: improve usbfs check

2019-02-14 Thread Laurent Vivier
On 14/02/2019 08:00, Thomas Huth wrote:
> On 2019-02-13 22:18, Thomas Petazzoni wrote:
>> The current check to test if usbfs support should be compiled or not
>> solely relies on the presence of , without
>> actually checking that all definition used by Qemu are provided by
>> this header file.
>>
>> With sufficiently old kernel headers,  may be
>> present, but some of the definitions needed by Qemu may not be
>> available.
>>
>> This commit improves the check by building a small program that
>> actually tests whether the necessary definitions are available.
>>
>> In addition, it fixes a bug where have_usbfs was set to "yes"
>> regardless of the result of the test.
>>
>> Signed-off-by: Thomas Petazzoni 
>> ---
>>  configure | 19 +--
>>  1 file changed, 17 insertions(+), 2 deletions(-)
>>
>> diff --git a/configure b/configure
>> index 3d89870d99..799c8e3b08 100755
>> --- a/configure
>> +++ b/configure
>> @@ -4266,10 +4266,25 @@ fi
>>  # check for usbfs
>>  have_usbfs=no
>>  if test "$linux_user" = "yes"; then
>> -  if check_include linux/usbdevice_fs.h; then
>> +  cat > $TMPC << EOF
>> +#include 
>> +
>> +#ifndef USBDEVFS_GET_CAPABILITIES
>> +#error "USBDEVFS_GET_CAPABILITIES undefined"
>> +#endif
>> +
>> +#ifndef USBDEVFS_DISCONNECT_CLAIM
>> +#error "USBDEVFS_DISCONNECT_CLAIM undefined"
>> +#endif
>> +
>> +int main(void)
>> +{
>> +return 0;
>> +}
>> +EOF
>> +  if compile_prog "" ""; then
>>  have_usbfs=yes
>>fi
>> -  have_usbfs=yes
>>  fi
>>  
>>  # check for fallocate
> 
> Reviewed-by: Thomas Huth 
> 


Applied to my trivial-patches branch.

Thanks,
Laurent



Re: [Qemu-devel] [Qemu-trivial] [PATCH 4/4] wavcapture: Convert to error_report

2019-02-14 Thread Laurent Vivier
On 12/02/2019 14:47, Dr. David Alan Gilbert (git) wrote:
> From: "Dr. David Alan Gilbert" 
> 
> Kill off a pile of monitor_printf's and cur_mon usage.
> The only one left in wavcapture.c is the info case.
> 
> Signed-off-by: Dr. David Alan Gilbert 
> ---
>  audio/wavcapture.c | 39 +--
>  1 file changed, 17 insertions(+), 22 deletions(-)
> 
> diff --git a/audio/wavcapture.c b/audio/wavcapture.c
> index cf31ed652c..cd24570aa7 100644
> --- a/audio/wavcapture.c
> +++ b/audio/wavcapture.c
> @@ -38,30 +38,29 @@ static void wav_destroy (void *opaque)
>  uint8_t dlen[4];
>  uint32_t datalen = wav->bytes;
>  uint32_t rifflen = datalen + 36;
> -Monitor *mon = cur_mon;
>  
>  if (wav->f) {
>  le_store (rlen, rifflen, 4);
>  le_store (dlen, datalen, 4);
>  
>  if (fseek (wav->f, 4, SEEK_SET)) {
> -monitor_printf (mon, "wav_destroy: rlen fseek failed\nReason: 
> %s\n",
> -strerror (errno));
> +error_report("wav_destroy: rlen fseek failed: %s",
> + strerror(errno));
>  goto doclose;
>  }
>  if (fwrite (rlen, 4, 1, wav->f) != 1) {
> -monitor_printf (mon, "wav_destroy: rlen fwrite failed\nReason 
> %s\n",
> -strerror (errno));
> +error_report("wav_destroy: rlen fwrite failed: %s",
> + strerror(errno));
>  goto doclose;
>  }
>  if (fseek (wav->f, 32, SEEK_CUR)) {
> -monitor_printf (mon, "wav_destroy: dlen fseek failed\nReason 
> %s\n",
> -strerror (errno));
> +error_report("wav_destroy: dlen fseek failed: %s",
> + strerror(errno));
>  goto doclose;
>  }
>  if (fwrite (dlen, 1, 4, wav->f) != 4) {
> -monitor_printf (mon, "wav_destroy: dlen fwrite failed\nReason 
> %s\n",
> -strerror (errno));
> +error_report("wav_destroy: dlen fwrite failed: %s",
> + strerror(errno));
>  goto doclose;
>  }
>  doclose:
> @@ -78,8 +77,7 @@ static void wav_capture (void *opaque, void *buf, int size)
>  WAVState *wav = opaque;
>  
>  if (fwrite (buf, size, 1, wav->f) != 1) {
> -monitor_printf (cur_mon, "wav_capture: fwrite error\nReason: %s",
> -strerror (errno));
> +error_report("wav_capture: fwrite error: %s", strerror(errno));
>  }
>  wav->bytes += size;
>  }
> @@ -110,7 +108,6 @@ static struct capture_ops wav_capture_ops = {
>  int wav_start_capture (CaptureState *s, const char *path, int freq,
> int bits, int nchannels)
>  {
> -Monitor *mon = cur_mon;
>  WAVState *wav;
>  uint8_t hdr[] = {
>  0x52, 0x49, 0x46, 0x46, 0x00, 0x00, 0x00, 0x00, 0x57, 0x41, 0x56,
> @@ -124,13 +121,13 @@ int wav_start_capture (CaptureState *s, const char 
> *path, int freq,
>  CaptureVoiceOut *cap;
>  
>  if (bits != 8 && bits != 16) {
> -monitor_printf (mon, "incorrect bit count %d, must be 8 or 16\n", 
> bits);
> +error_report("incorrect bit count %d, must be 8 or 16", bits);
>  return -1;
>  }
>  
>  if (nchannels != 1 && nchannels != 2) {
> -monitor_printf (mon, "incorrect channel count %d, must be 1 or 2\n",
> -nchannels);
> +error_report("incorrect channel count %d, must be 1 or 2",
> + nchannels);
>  return -1;
>  }
>  
> @@ -158,8 +155,8 @@ int wav_start_capture (CaptureState *s, const char *path, 
> int freq,
>  
>  wav->f = fopen (path, "wb");
>  if (!wav->f) {
> -monitor_printf (mon, "Failed to open wave file `%s'\nReason: %s\n",
> -path, strerror (errno));
> +error_report("Failed to open wave file `%s': %s",
> + path, strerror(errno));
>  g_free (wav);
>  return -1;
>  }
> @@ -170,14 +167,13 @@ int wav_start_capture (CaptureState *s, const char 
> *path, int freq,
>  wav->freq = freq;
>  
>  if (fwrite (hdr, sizeof (hdr), 1, wav->f) != 1) {
> -monitor_printf (mon, "Failed to write header\nReason: %s\n",
> -strerror (errno));
> +error_report("Failed to write header: %s", strerror(errno));
>  goto error_free;
>  }
>  
>  cap = AUD_add_capture (&as, &ops, wav);
>  if (!cap) {
> -monitor_printf (mon, "Failed to add audio capture\n");
> +error_report("Failed to add audio capture");
>  goto error_free;
>  }
>  
> @@ -189,8 +185,7 @@ int wav_start_capture (CaptureState *s, const char *path, 
> int freq,
>  error_free:
>  g_free (wav->path);
>  if (fclose (wav->f)) {
> -monitor_printf (mon, "Failed to close wave file\nReason: %s\n",
> -strerror (errn

Re: [Qemu-devel] [PULL 00/24] target/hppa patch queue

2019-02-14 Thread Peter Maydell
On Wed, 13 Feb 2019 at 18:40, Philippe Mathieu-Daudé  wrote:
> What Clang version is that?
>
> I can not reproduce using:
>
> clang version 7.0.1 (Fedora 7.0.1-1.fc29)

OSX: Apple LLVM version 10.0.0 (clang-1000.11.45.5)
and Ubuntu bionic: clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)

thanks
-- PMM



Re: [Qemu-devel] [PATCH 2/4] HMP: Prepend errors with 'Error:'

2019-02-14 Thread Markus Armbruster
"Dr. David Alan Gilbert (git)"  writes:

> From: "Dr. David Alan Gilbert" 
>
> Always make error messages start with 'Error:' as a fallback
> to make sure that anything parsing them can tell it failed.

Feeding HMP output to programs is a bad idea to begin with.  

> Note: Some places don't use hmp_handle_error

True.  A more honest subject would be "HMP: Prepend some errors with
'Error:'".

Several distinct reasons for not using hmp_handle_error():

* Handling an error that isn't transmitted as an Error object

  HMP command handlers generally wrap around QMP command handlers, which
  always use Error objects.  Still, there are other sources of errors
  when the HMP command does more than the wrapped QMP command (typically
  convenience features for humans), or there is no wrapped QMP command.

* Augmenting the error message

  Reporting with error_reportf_err() is easier than first messing with
  the Error object, then passing it to hmp_handle_error().  Example:
  hmp_delvm().

* hmp_handle_error() is static, and we're outside hmp.c

  Tolerable as long as hmp_handle_error() is trivial.  Your patch makes
  it a bit less trivial.

If we truly want to "Prepend errors with 'Error:'", then we should make
hmp command handlers take an Error ** argument, and leave the reporting
to the HMP core.

If you think prepending some errors is useful (and I guess you do), go
right ahead with this patch.  I'd recommend to use the more honest
subject, though.



Re: [Qemu-devel] [Qemu-trivial] [PATCH] hw/sparc64: Explicitly set default_display = "std"

2019-02-14 Thread Laurent Vivier
On 13/02/2019 08:07, Thomas Huth wrote:
> The sun4uv_init() function expects vga_interface_type to be either
> VGA_STD or VGA_NONE and sets up a stdvga device or no vga card
> accordingly.
> However, the code in vl.c prefers the Cirrus VGA card to stdvga if
> it is available and the user and the machine did not specify anything
> else.
> So far this has not been a problem, since the Cirrus VGA was not linked
> into the sparc64 target. But with the upcoming Kconfig build system,
> all theoretically possible PCI cards will be enabled by default, so the
> Cirrus VGA card might become available on the sparc64 target, too. vl.c
> then picks the wrong card, causing sun4uv_init() to abort.
> Thus let's make it explicit that we always want stdvga for sparc64 and
> so set default_display = "std" for these machines.
> 
> Signed-off-by: Thomas Huth 
> ---
>  hw/sparc64/sun4u.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
> index ff24d9b..399f2d7 100644
> --- a/hw/sparc64/sun4u.c
> +++ b/hw/sparc64/sun4u.c
> @@ -797,6 +797,7 @@ static void sun4u_class_init(ObjectClass *oc, void *data)
>  mc->default_boot_order = "c";
>  mc->default_cpu_type = SPARC_CPU_TYPE_NAME("TI-UltraSparc-IIi");
>  mc->ignore_boot_device_suffixes = true;
> +mc->default_display = "std";
>  fwc->get_dev_path = sun4u_fw_dev_path;
>  }
>  
> @@ -820,6 +821,7 @@ static void sun4v_class_init(ObjectClass *oc, void *data)
>  mc->max_cpus = 1; /* XXX for now */
>  mc->default_boot_order = "c";
>  mc->default_cpu_type = SPARC_CPU_TYPE_NAME("Sun-UltraSparc-T1");
> +mc->default_display = "std";
>  }
>  
>  static const TypeInfo sun4v_type = {
> 

Applied to my trivial-patches branch.

Thanks,
Laurent



Re: [Qemu-devel] [Qemu-trivial] [PATCH] hw/dma/i8257: Use qemu_log_mask(UNIMP) instead of fprintf

2019-02-14 Thread Laurent Vivier
On 12/02/2019 15:53, Philippe Mathieu-Daudé wrote:
> Avoid to clutter stdout until explicitly requested (with -d unimp):
> 
>   $ qemu-system-mips64el -M fulong2e -bios pmon_2e.bin
>   dma: command df not supported
>   dma: command df not supported
>   dma: command df not supported
>   dma: command df not supported
> 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  hw/dma/i8257.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/dma/i8257.c b/hw/dma/i8257.c
> index 52675e97c9..3e1f13a4aa 100644
> --- a/hw/dma/i8257.c
> +++ b/hw/dma/i8257.c
> @@ -26,6 +26,7 @@
>  #include "hw/isa/isa.h"
>  #include "hw/dma/i8257.h"
>  #include "qemu/main-loop.h"
> +#include "qemu/log.h"
>  #include "trace.h"
>  
>  #define I8257(obj) \
> @@ -185,7 +186,8 @@ static void i8257_write_cont(void *opaque, hwaddr nport, 
> uint64_t data,
>  switch (iport) {
>  case 0x00:  /* command */
>  if ((data != 0) && (data & CMD_NOT_SUPPORTED)) {
> -dolog("command %"PRIx64" not supported\n", data);
> +qemu_log_mask(LOG_UNIMP, "%s: cmd 0x%02"PRIx64" not supported\n",
> +  __func__, data);
>  return;
>  }
>  d->command = data;
> 


Applied to my trivial-patches branch.

Thanks,
Laurent



Re: [Qemu-devel] [Qemu-trivial] [PATCH 0/4] Trivial fixes for configure and Python scripts

2019-02-14 Thread Laurent Vivier
On 07/02/2019 20:36, Cleber Rosa wrote:
> This is just a small collection of trivial fixes for configure
> and some Python scripts (missing/unused import statements).
> 
> Cleber Rosa (4):
>   configure: remove handling of "wav" audio driver
>   configure: fix qemu-img name
>   scripts/render_block_graph.py: add a missing import
>   tests/migration/guestperf/engine.py: remove unused import
> 
>  configure   | 6 +-
>  scripts/render_block_graph.py   | 1 +
>  tests/migration/guestperf/engine.py | 1 -
>  3 files changed, 2 insertions(+), 6 deletions(-)
> 

I've applied to my trivial-patches branchi patches 1 and 2, but not 3
and 4 as I don't know python and no one has reviewed them.

Thanks,
Laurent



Re: [Qemu-devel] [Qemu-trivial] [PATCH 2/4] configure: fix qemu-img name

2019-02-14 Thread Laurent Vivier
On 07/02/2019 20:36, Cleber Rosa wrote:
> Signed-off-by: Cleber Rosa 
> ---
>  configure | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/configure b/configure
> index ff55e2273e..c8fc1647fe 100755
> --- a/configure
> +++ b/configure
> @@ -1768,7 +1768,7 @@ disabled with --disable-FEATURE, default is enabled if 
> available:
>virglrenderer   virgl rendering support
>xfsctl  xfsctl support
>qom-cast-debug  cast debugging support
> -  tools   build qemu-io, qemu-nbd and qemu-image tools
> +  tools   build qemu-io, qemu-nbd and qemu-img tools
>vxhsVeritas HyperScale vDisk backend support
>bochs   bochs image format support
>cloop   cloop image format support
> 

Applied to my trivial-patches branch.

Thanks,
Laurent



Re: [Qemu-devel] [Qemu-trivial] [PATCH] qapi: Fix qcow2 encryption doc typo

2019-02-14 Thread Laurent Vivier
On 06/02/2019 21:28, Eric Blake wrote:
> Present since commit b25b387f (2.10).
> 
> Signed-off-by: Eric Blake 
> ---
>  qapi/block-core.json | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/qapi/block-core.json b/qapi/block-core.json
> index 0f349d46033..ee1ab7a8a25 100644
> --- a/qapi/block-core.json
> +++ b/qapi/block-core.json
> @@ -2998,7 +2998,7 @@
> 
>  ##
>  # @BlockdevQcow2EncryptionFormat:
> -# @aes: AES-CBC with plain64 initialization venctors
> +# @aes: AES-CBC with plain64 initialization vectors
>  #
>  # Since: 2.10
>  ##
> 

Applied to my trivial-patches branch.

Thanks,
Laurent



Re: [Qemu-devel] [Qemu-trivial] [PATCH 1/4] pckbd: Convert DPRINTF->trace

2019-02-14 Thread Laurent Vivier
On 12/02/2019 15:10, Philippe Mathieu-Daudé wrote:
> On 2/12/19 2:47 PM, Dr. David Alan Gilbert (git) wrote:
>> From: "Dr. David Alan Gilbert" 
>>
>> Signed-off-by: Dr. David Alan Gilbert 
> 
> Per https://lists.gnu.org/archive/html/qemu-devel/2018-10/msg03186.html
> this one already has:
> 
> Reviewed-by: Philippe Mathieu-Daudé 
> Reviewed-by: Stefan Hajnoczi 
> 


Applied the one from 2018-10
(20181016112232.23241-1-dgilb...@redhat.com), as it is identical and has
the R-b, to my trivial-patches branch.

Thanks,
Laurent




Re: [Qemu-devel] [Qemu-trivial] [PATCH 1/4] configure: remove handling of "wav" audio driver

2019-02-14 Thread Laurent Vivier
On 07/02/2019 20:36, Cleber Rosa wrote:
> This looks like a leftover that was never implemented.
> 
> Signed-off-by: Cleber Rosa 
> ---
>  configure | 4 
>  1 file changed, 4 deletions(-)
> 
> diff --git a/configure b/configure
> index fbd0825488..ff55e2273e 100755
> --- a/configure
> +++ b/configure
> @@ -3350,10 +3350,6 @@ for drv in $audio_drv_list; do
>oss_libs="$oss_lib"
>  ;;
>  
> -wav)
> -# XXX: Probes for CoreAudio, DirectSound
> -;;
> -
>  *)
>  echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
>  error_exit "Unknown driver '$drv' selected" \
> 

Applied to my trivial-patches branch.

Thanks,
Laurent



Re: [Qemu-devel] [Qemu-trivial] [PATCH 2/4] HMP: Prepend errors with 'Error:'

2019-02-14 Thread Laurent Vivier
On 12/02/2019 14:47, Dr. David Alan Gilbert (git) wrote:
> From: "Dr. David Alan Gilbert" 
> 
> Always make error messages start with 'Error:' as a fallback
> to make sure that anything parsing them can tell it failed.
> 
> Note: Some places don't use hmp_handle_error
> 
> Signed-off-by: Dr. David Alan Gilbert 
> ---
>  hmp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hmp.c b/hmp.c
> index b2a2b1f84e..4d14718fea 100644
> --- a/hmp.c
> +++ b/hmp.c
> @@ -62,7 +62,7 @@ static void hmp_handle_error(Monitor *mon, Error **errp)
>  {
>  assert(errp);
>  if (*errp) {
> -error_report_err(*errp);
> +error_reportf_err(*errp, "Error: ");
>  }
>  }
>  
> 

Applied to my trivial-patches branch.

Thanks,
Laurent



[Qemu-devel] [PATCH v4 03/18] qapi: Clean up modular built-in code generation a bit

2019-02-14 Thread Markus Armbruster
We neglect to call .visit_module() for the special module we use for
built-ins.  Harmless, but clean it up anyway.  The
tests/qapi-schema/*.out now show the built-in module as 'module None'.

Subclasses of QAPISchemaModularCVisitor need to ._add_module() this
special module to enable code generation for built-ins.  When this
hasn't been done, QAPISchemaModularCVisitor.visit_module() does
nothing for the special module.  That looks like built-ins could
accidentally be generated into the wrong module when a subclass
neglects to call ._add_module().  Can't happen, because built-ins are
all visited before any other module.  But that's non-obvious.  Switch
off code generation explicitly.

Rename QAPISchemaModularCVisitor._begin_module() to
._begin_user_module().

New QAPISchemaModularCVisitor._is_builtin_module(), for clarity.

Signed-off-by: Markus Armbruster 
Reviewed-by: Marc-André Lureau 
---
 scripts/qapi/commands.py |  2 +-
 scripts/qapi/common.py   | 24 ++--
 scripts/qapi/events.py   |  2 +-
 scripts/qapi/types.py|  2 +-
 scripts/qapi/visit.py|  2 +-
 tests/qapi-schema/comments.out   |  1 +
 tests/qapi-schema/doc-bad-section.out|  1 +
 tests/qapi-schema/doc-good.out   |  1 +
 tests/qapi-schema/empty.out  |  1 +
 tests/qapi-schema/event-case.out |  1 +
 tests/qapi-schema/ident-with-escape.out  |  1 +
 tests/qapi-schema/include-relpath.out|  1 +
 tests/qapi-schema/include-repetition.out |  1 +
 tests/qapi-schema/include-simple.out |  1 +
 tests/qapi-schema/indented-expr.out  |  1 +
 tests/qapi-schema/qapi-schema-test.out   |  1 +
 16 files changed, 33 insertions(+), 10 deletions(-)

diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py
index 0f3c991918..ebf488953d 100644
--- a/scripts/qapi/commands.py
+++ b/scripts/qapi/commands.py
@@ -242,7 +242,7 @@ class 
QAPISchemaGenCommandVisitor(QAPISchemaModularCVisitor):
 self._regy = QAPIGenCCode()
 self._visited_ret_types = {}
 
-def _begin_module(self, name):
+def _begin_user_module(self, name):
 self._visited_ret_types[self._genc] = set()
 commands = self._module_basename('qapi-commands', name)
 types = self._module_basename('qapi-types', name)
diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
index c89edc0cb0..0e3ec598a4 100644
--- a/scripts/qapi/common.py
+++ b/scripts/qapi/common.py
@@ -1868,6 +1868,7 @@ class QAPISchema(object):
 def visit(self, visitor):
 visitor.visit_begin(self)
 module = None
+visitor.visit_module(module)
 for entity in self._entity_list:
 if visitor.visit_needed(entity):
 if entity.module != module:
@@ -2321,9 +2322,15 @@ class QAPISchemaModularCVisitor(QAPISchemaVisitor):
 self._what = what
 self._blurb = blurb
 self._pydoc = pydoc
+self._genc = None
+self._genh = None
 self._module = {}
 self._main_module = None
 
+@staticmethod
+def _is_builtin_module(name):
+return not name
+
 def _module_basename(self, what, name):
 if name is None:
 return re.sub(r'-', '-builtin-', what)
@@ -2334,7 +2341,7 @@ class QAPISchemaModularCVisitor(QAPISchemaVisitor):
 return basename + '-' + os.path.splitext(os.path.basename(name))[0]
 
 def _add_module(self, name, blurb):
-if self._main_module is None and name is not None:
+if self._main_module is None and not self._is_builtin_module(name):
 self._main_module = name
 genc = QAPIGenC(blurb, self._pydoc)
 genh = QAPIGenH(blurb, self._pydoc)
@@ -2346,22 +2353,27 @@ class QAPISchemaModularCVisitor(QAPISchemaVisitor):
 
 def write(self, output_dir, opt_builtins=False):
 for name in self._module:
-if name is None and not opt_builtins:
+if self._is_builtin_module(name) and not opt_builtins:
 continue
 basename = self._module_basename(self._what, name)
 (genc, genh) = self._module[name]
 genc.write(output_dir, basename + '.c')
 genh.write(output_dir, basename + '.h')
 
-def _begin_module(self, name):
+def _begin_user_module(self, name):
 pass
 
 def visit_module(self, name):
 if name in self._module:
 self._set_module(name)
-return
-self._add_module(name, self._blurb)
-self._begin_module(name)
+elif self._is_builtin_module(name):
+# The built-in module has not been created.  No code may
+# be generated.
+self._genc = None
+self._genh = None
+else:
+self._add_module(name, self._blurb)
+self._begin_user_module(name)
 
 def visit_include(self, name, info):
 basename = self._module_basename(self._what, name)
diff

Re: [Qemu-devel] [Qemu-trivial] [PATCH] configure: Make -Waddress-of-packed-member warnings be errors

2019-02-14 Thread Laurent Vivier
On 08/02/2019 14:33, Thomas Huth wrote:
> On 2019-02-08 14:21, Peter Maydell wrote:
>> We have now managed to eradicate all the places in the codebase
>> that triggered clang's -Waddress-of-packed-member warning. Remove
>> the compiler flag that exempted it from our usual -Werror policy.
>> This will prevent any new problematic code being added in future.
>>
>> Signed-off-by: Peter Maydell 
>> ---
>>  configure | 1 -
>>  1 file changed, 1 deletion(-)
>>
>> diff --git a/configure b/configure
>> index fbd0825488c..50ac5d90f2e 100755
>> --- a/configure
>> +++ b/configure
>> @@ -1881,7 +1881,6 @@ gcc_flags="-Wno-missing-include-dirs -Wempty-body 
>> -Wnested-externs $gcc_flags"
>>  gcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
>>  gcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
>>  gcc_flags="-Wno-string-plus-int $gcc_flags"
>> -gcc_flags="-Wno-error=address-of-packed-member $gcc_flags"
>>  # Note that we do not add -Werror to gcc_flags here, because that would
>>  # enable it for all configure tests. If a configure test failed due
>>  # to -Werror this would just silently disable some features,
> 
> Great!
> 
> Reviewed-by: Thomas Huth 
> 

Applied to my trivial-patches branch.

Thanks,
Laurent



[Qemu-devel] [PATCH v4 17/18] qmp: Deprecate query-events in favor of query-qmp-schema

2019-02-14 Thread Markus Armbruster
query-events doesn't reflect compile-time configuration.  Instead of
fixing that, deprecate the command in favor of query-qmp-schema.

Libvirt prefers query-qmp-schema as of commit 22d7222ec0 "qemu: caps:
Don't call 'query-events' when we probe events from QMP schema".
It'll be in the next release.

Signed-off-by: Markus Armbruster 
Reviewed-by: Marc-André Lureau 
---
 monitor.c| 5 +
 qapi/misc.json   | 7 +--
 qemu-deprecated.texi | 5 +
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/monitor.c b/monitor.c
index 1673db7015..33ccbf3957 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1099,6 +1099,11 @@ CommandInfoList *qmp_query_commands(Error **errp)
 
 EventInfoList *qmp_query_events(Error **errp)
 {
+/*
+ * TODO This deprecated command is the only user of
+ * QAPIEvent_str() and QAPIEvent_lookup[].  When the command goes,
+ * they should go, too.
+ */
 EventInfoList *info, *ev_list = NULL;
 QAPIEvent e;
 
diff --git a/qapi/misc.json b/qapi/misc.json
index 82f9147353..98f59f828a 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -318,12 +318,15 @@
 ##
 # @query-events:
 #
-# Return a list of supported QMP events by this server
+# Return information on QMP events.
 #
-# Returns: A list of @EventInfo for all supported events
+# Returns: A list of @EventInfo.
 #
 # Since: 1.2.0
 #
+# Note: This command is deprecated, because its output doesn't reflect
+# compile-time configuration.  Use query-qmp-schema instead.
+#
 # Example:
 #
 # -> { "execute": "query-events" }
diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi
index 80b0702ad5..fe1a914cae 100644
--- a/qemu-deprecated.texi
+++ b/qemu-deprecated.texi
@@ -99,6 +99,11 @@ Use ``device_add'' for hotplugging vCPUs instead of 
``cpu-add''.  See
 documentation of ``query-hotpluggable-cpus'' for additional
 details.
 
+@subsection query-events (since 4.0)
+
+The ``query-events'' command has been superseded by the more powerful
+and accurate ``query-qmp-schema'' command.
+
 @section Human Monitor Protocol (HMP) commands
 
 @subsection The hub_id parameter of 'hostfwd_add' / 'hostfwd_remove' (since 
3.1)
-- 
2.17.2




Re: [Qemu-devel] [PATCH] softfloat: Support float_round_to_odd more places

2019-02-14 Thread David Hildenbrand
On 14.02.19 07:11, Richard Henderson wrote:
> Previously this was only supported for roundAndPackFloat64.
> Include support in round_canonical, round_to_int, roundAndPackFloat32,
> roundAndPackInt32, roundAndPackInt64, roundAndPackUint64.
> 
> This does not include any of the floatx80 routines, as we
> do not have users for that rounding mode there.
> 
> Signed-off-by: Richard Henderson 
> ---
> 
> David, if you could test this vs your s390 patches, vs real s390
> hardware, that would be lovely.

I wrote a quick test for LOAD FP INTEGER to test some of the code paths.

Real HW

PASS: selftest: fidbra(0.5) == 1 with RSP
PASS: selftest: fidbra(-0.5) == -1 with RSP
PASS: selftest: fidbra(9.5) == 9 with RSP
PASS: selftest: fidbra(-9.5) == -9 with RSP
PASS: selftest: fidbra(2.5) == 3 with RSP
PASS: selftest: fidbra(-2.5) == -3 with RSP
PASS: selftest: fiebra(0.5) == 1 with RSP
PASS: selftest: fiebra(-0.5) == -1 with RSP
PASS: selftest: fiebra(9.5) == 9 with RSP
PASS: selftest: fiebra(-9.5) == -9 with RSP
PASS: selftest: fiebra(2.5) == 3 with RSP
PASS: selftest: fiebra(-2.5) == -3 with RSP
PASS: selftest: fixbra(0.5) == 1 with RSP
PASS: selftest: fixbra(-0.5) == -1 with RSP
PASS: selftest: fixbra(9.5) == 9 with RSP
PASS: selftest: fixbra(-9.5) == -9 with RSP
PASS: selftest: fixbra(2.5) == 3 with RSP
PASS: selftest: fixbra(-2.5) == -3 with RSP


With round_to_zero

FAIL: selftest: fidbra(0.5) == 1 with RSP
FAIL: selftest: fidbra(-0.5) == -1 with RSP
PASS: selftest: fidbra(9.5) == 9 with RSP
PASS: selftest: fidbra(-9.5) == -9 with RSP
FAIL: selftest: fidbra(2.5) == 3 with RSP
FAIL: selftest: fidbra(-2.5) == -3 with RSP
FAIL: selftest: fiebra(0.5) == 1 with RSP
FAIL: selftest: fiebra(-0.5) == -1 with RSP
PASS: selftest: fiebra(9.5) == 9 with RSP
PASS: selftest: fiebra(-9.5) == -9 with RSP
FAIL: selftest: fiebra(2.5) == 3 with RSP
FAIL: selftest: fiebra(-2.5) == -3 with RSP
FAIL: selftest: fixbra(0.5) == 1 with RSP
FAIL: selftest: fixbra(-0.5) == -1 with RSP
PASS: selftest: fixbra(9.5) == 9 with RSP
PASS: selftest: fixbra(-9.5) == -9 with RSP
FAIL: selftest: fixbra(2.5) == 3 with RSP
FAIL: selftest: fixbra(-2.5) == -3 with RSP

With round_to_odd

PASS: selftest: fidbra(0.5) == 0 with RTZ
PASS: selftest: fidbra(0.5) == 1 with RSP
PASS: selftest: fidbra(-0.5) == -1 with RSP
PASS: selftest: fidbra(9.5) == 9 with RSP
PASS: selftest: fidbra(-9.5) == -9 with RSP
PASS: selftest: fidbra(2.5) == 3 with RSP
PASS: selftest: fidbra(-2.5) == -3 with RSP
PASS: selftest: fiebra(0.5) == 1 with RSP
PASS: selftest: fiebra(-0.5) == -1 with RSP
PASS: selftest: fiebra(9.5) == 9 with RSP
PASS: selftest: fiebra(-9.5) == -9 with RSP
PASS: selftest: fiebra(2.5) == 3 with RSP
PASS: selftest: fiebra(-2.5) == -3 with RSP
FAIL: selftest: fixbra(0.5) == 1 with RSP
FAIL: selftest: fixbra(-0.5) == -1 with RSP
QEMU Aborted

So something seems to go wrong when trying to round 9.5 in 128bit.

The 32/64 bit stuff seems to work :)

> 
> 
> r~
> 
> ---
>  fpu/softfloat.c | 40 ++--
>  1 file changed, 38 insertions(+), 2 deletions(-)
> 
> diff --git a/fpu/softfloat.c b/fpu/softfloat.c
> index 9132d7a0b0..325c6e4e79 100644
> --- a/fpu/softfloat.c
> +++ b/fpu/softfloat.c
> @@ -696,6 +696,7 @@ static FloatParts sf_canonicalize(FloatParts part, const 
> FloatFmt *parm,
>  static FloatParts round_canonical(FloatParts p, float_status *s,
>const FloatFmt *parm)
>  {
> +const uint64_t frac_lsb = parm->frac_lsb;
>  const uint64_t frac_lsbm1 = parm->frac_lsbm1;
>  const uint64_t round_mask = parm->round_mask;
>  const uint64_t roundeven_mask = parm->roundeven_mask;
> @@ -731,6 +732,10 @@ static FloatParts round_canonical(FloatParts p, 
> float_status *s,
>  inc = p.sign ? round_mask : 0;
>  overflow_norm = !p.sign;
>  break;
> +case float_round_to_odd:
> +overflow_norm = true;
> +inc = frac & frac_lsb ? 0 : frac_lsbm1;
> +break;
>  default:
>  g_assert_not_reached();
>  }
> @@ -778,9 +783,14 @@ static FloatParts round_canonical(FloatParts p, 
> float_status *s,
>  shift64RightJamming(frac, 1 - exp, &frac);
>  if (frac & round_mask) {
>  /* Need to recompute round-to-even.  */
> -if (s->float_rounding_mode == float_round_nearest_even) {
> +switch (s->float_rounding_mode) {
> +case float_round_nearest_even:
>  inc = ((frac & roundeven_mask) != frac_lsbm1
> ? frac_lsbm1 : 0);
> +break;
> +case float_round_to_odd:
> +inc = frac & frac_lsb ? 0 : frac_lsbm1;
> +break;
>  }
>  flags |= float_flag_inexact;
>  frac += inc;
> @@ -1988,6 +1998,9 @@ static FloatParts round_to_int(FloatParts a, int rmode,
>  case float

Re: [Qemu-devel] [Qemu-trivial] [PATCH] configure: Add HAX support in NetBSD

2019-02-14 Thread Laurent Vivier
On 08/02/2019 00:37, Kamil Rytarowski wrote:
> The NetBSD support in Intel HAXM has beem merged upstream and is functional.
> 
> Signed-off-by: Kamil Rytarowski 
> ---
>  configure | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/configure b/configure
> index b18281c61f..89b889072d 100755
> --- a/configure
> +++ b/configure
> @@ -819,6 +819,7 @@ DragonFly)
>  ;;
>  NetBSD)
>bsd="yes"
> +  hax="yes"
>make="${MAKE-gmake}"
>audio_drv_list="oss try-sdl"
>audio_possible_drivers="oss sdl"
> 

Applied to my trivial-patches branch.

Thanks,
Laurent



[Qemu-devel] [PATCH v4 08/18] qapi: New module target.json

2019-02-14 Thread Markus Armbruster
We can't add appropriate target-specific conditionals to misc.json,
because that would make all of misc.json unusable in
target-independent code.  To keep misc.json target-independent, we
need to split off target-dependent target.json.

This commit doesn't actually split off anything, it merely creates the
empty module.  The next few patches will move stuff from misc.json
there.

Signed-off-by: Markus Armbruster 
---
 Makefile.objs |  3 +--
 qapi/Makefile.objs| 28 +---
 qapi/qapi-schema.json |  1 +
 qapi/target.json  | 13 +
 4 files changed, 32 insertions(+), 13 deletions(-)
 create mode 100644 qapi/target.json

diff --git a/Makefile.objs b/Makefile.objs
index 4a266357a2..95150d7173 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -79,8 +79,7 @@ common-obj-$(CONFIG_FDT) += device_tree.o
 ##
 # qapi
 
-common-obj-y += qapi/qapi-commands.o
-common-obj-y += $(QAPI_MODULES:%=qapi/qapi-commands-%.o)
+common-obj-y += $(QAPI_COMMON_MODULES:%=qapi/qapi-commands-%.o)
 common-obj-y += qmp.o hmp.o
 endif
 
diff --git a/qapi/Makefile.objs b/qapi/Makefile.objs
index dacbae..654321de94 100644
--- a/qapi/Makefile.objs
+++ b/qapi/Makefile.objs
@@ -5,21 +5,27 @@ util-obj-y += opts-visitor.o qapi-clone-visitor.o
 util-obj-y += qmp-event.o
 util-obj-y += qapi-util.o
 
-QAPI_MODULES = block-core block char common crypto introspect job migration
-QAPI_MODULES += misc net rdma rocker run-state sockets tpm trace transaction
-QAPI_MODULES += ui
+QAPI_COMMON_MODULES = block-core block char common crypto introspect
+QAPI_COMMON_MODULES += job migration misc net rdma rocker run-state
+QAPI_COMMON_MODULES += sockets tpm trace transaction ui
+QAPI_TARGET_MODULES = target
+QAPI_MODULES = $(QAPI_COMMON_MODULES) $(QAPI_TARGET_MODULES)
 
 util-obj-y += qapi-builtin-types.o
-util-obj-y += qapi-types.o
-util-obj-y += $(QAPI_MODULES:%=qapi-types-%.o)
+util-obj-y += $(QAPI_COMMON_MODULES:%=qapi-types-%.o)
 util-obj-y += qapi-builtin-visit.o
-util-obj-y += qapi-visit.o
-util-obj-y += $(QAPI_MODULES:%=qapi-visit-%.o)
+util-obj-y += $(QAPI_COMMON_MODULES:%=qapi-visit-%.o)
 util-obj-y += qapi-emit-events.o
-util-obj-y += qapi-events.o
-util-obj-y += $(QAPI_MODULES:%=qapi-events-%.o)
+util-obj-y += $(QAPI_COMMON_MODULES:%=qapi-events-%.o)
 
-common-obj-y += qapi-commands.o
-common-obj-y += $(QAPI_MODULES:%=qapi-commands-%.o)
+common-obj-y += $(QAPI_COMMON_MODULES:%=qapi-commands-%.o)
 
+obj-y += $(QAPI_TARGET_MODULES:%=qapi-types-%.o)
+obj-y += qapi-types.o
+obj-y += $(QAPI_TARGET_MODULES:%=qapi-visit-%.o)
+obj-y += qapi-visit.o
+obj-y += $(QAPI_TARGET_MODULES:%=qapi-events-%.o)
+obj-y += qapi-events.o
+obj-y += $(QAPI_TARGET_MODULES:%=qapi-commands-%.o)
+obj-y += qapi-commands.o
 obj-y += qapi-introspect.o
diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json
index 1845aa78ff..db61bfd688 100644
--- a/qapi/qapi-schema.json
+++ b/qapi/qapi-schema.json
@@ -97,3 +97,4 @@
 { 'include': 'trace.json' }
 { 'include': 'introspect.json' }
 { 'include': 'misc.json' }
+{ 'include': 'target.json' }
diff --git a/qapi/target.json b/qapi/target.json
new file mode 100644
index 00..8054926293
--- /dev/null
+++ b/qapi/target.json
@@ -0,0 +1,13 @@
+# -*- Mode: Python -*-
+#
+
+##
+# = Target-specific commands & events
+##
+
+##
+# @TARGET-TEMPORARY-DUMMY:
+# Will go away in the next commit.  Needed in this one because empty
+# modules don't generate anything, defeating this commit's purpose.
+##
+{ 'event': 'TARGET-TEMPORARY-DUMMY' }
-- 
2.17.2




Re: [Qemu-devel] [Qemu-trivial] [PATCH 1/2] qemu-deprecated: Remove -virtioconsole and -no-frame for good

2019-02-14 Thread Laurent Vivier
On 07/02/2019 14:14, Thomas Huth wrote:
> The two sections have accidentally been added again during the
> merge of Paolo's and Gerd's trees.
> 
> Fixes: 3e29da9fd81002a0c03041aaa26dea6d9dd9bd65
> Signed-off-by: Thomas Huth 
> ---
>  qemu-deprecated.texi | 12 
>  1 file changed, 12 deletions(-)
> 
> diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi
> index 80b0702..90e5860 100644
> --- a/qemu-deprecated.texi
> +++ b/qemu-deprecated.texi
> @@ -37,18 +37,6 @@ would automatically enable USB support on the machine type.
>  If using the new syntax, USB support must be explicitly
>  enabled via the ``-machine usb=on'' argument.
>  
> -@subsection -virtioconsole (since 3.0.0)
> -
> -Option @option{-virtioconsole} has been replaced by
> -@option{-device virtconsole}.
> -
> -@subsection -no-frame (since 2.12.0)
> -
> -The @code{--no-frame} argument works with SDL 1.2 only. The other user
> -interfaces never implemented this in the first place. So this will be
> -removed together with SDL 1.2 support.
> ->>> remotes/bonzini/tags/for-upstream
> -
>  @subsection -clock (since 3.0.0)
>  
>  The @code{-clock} option is ignored since QEMU version 1.7.0. There is no
> 

Applied to my trivial-patches branch.

Thanks,
Laurent



[Qemu-devel] [PATCH v4 13/18] qapi: make query-cpu-model-expansion depend on s390 or x86

2019-02-14 Thread Markus Armbruster
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Reviewed-by: Eduardo Habkost 
Acked-by: Cornelia Huck 
Reviewed-by: Markus Armbruster 
Signed-off-by: Markus Armbruster 
---
 include/sysemu/arch_init.h |  3 --
 monitor.c  |  3 --
 qapi/misc.json | 51 -
 qapi/target.json   | 52 ++
 qmp.c  |  7 
 stubs/Makefile.objs|  1 -
 stubs/arch-query-cpu-model-expansion.c | 13 ---
 target/i386/cpu.c  |  5 ++-
 target/s390x/cpu_models.c  |  2 +-
 9 files changed, 57 insertions(+), 80 deletions(-)
 delete mode 100644 stubs/arch-query-cpu-model-expansion.c

diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h
index f0ef652b2a..2497fd3351 100644
--- a/include/sysemu/arch_init.h
+++ b/include/sysemu/arch_init.h
@@ -33,7 +33,4 @@ int kvm_available(void);
 int xen_available(void);
 
 CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp);
-CpuModelExpansionInfo *arch_query_cpu_model_expansion(CpuModelExpansionType 
type,
-  CpuModelInfo *mode,
-  Error **errp);
 #endif
diff --git a/monitor.c b/monitor.c
index 33a0d81677..22a551b16b 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1145,9 +1145,6 @@ static void qmp_query_qmp_schema(QDict *qdict, QObject 
**ret_data,
  */
 static void qmp_unregister_commands_hack(void)
 {
-#if !defined(TARGET_S390X) && !defined(TARGET_I386)
-qmp_unregister_command(&qmp_commands, "query-cpu-model-expansion");
-#endif
 #if !defined(TARGET_PPC) && !defined(TARGET_ARM) && !defined(TARGET_I386) \
 && !defined(TARGET_S390X)
 qmp_unregister_command(&qmp_commands, "query-cpu-definitions");
diff --git a/qapi/misc.json b/qapi/misc.json
index 9df45a27ca..1255201267 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -2199,57 +2199,6 @@
   'data': [ 'static', 'full' ] }
 
 
-##
-# @CpuModelExpansionInfo:
-#
-# The result of a cpu model expansion.
-#
-# @model: the expanded CpuModelInfo.
-#
-# Since: 2.8.0
-##
-{ 'struct': 'CpuModelExpansionInfo',
-  'data': { 'model': 'CpuModelInfo' } }
-
-
-##
-# @query-cpu-model-expansion:
-#
-# Expands a given CPU model (or a combination of CPU model + additional 
options)
-# to different granularities, allowing tooling to get an understanding what a
-# specific CPU model looks like in QEMU under a certain configuration.
-#
-# This interface can be used to query the "host" CPU model.
-#
-# The data returned by this command may be affected by:
-#
-# * QEMU version: CPU models may look different depending on the QEMU version.
-#   (Except for CPU models reported as "static" in query-cpu-definitions.)
-# * machine-type: CPU model  may look different depending on the machine-type.
-#   (Except for CPU models reported as "static" in query-cpu-definitions.)
-# * machine options (including accelerator): in some architectures, CPU models
-#   may look different depending on machine and accelerator options. (Except 
for
-#   CPU models reported as "static" in query-cpu-definitions.)
-# * "-cpu" arguments and global properties: arguments to the -cpu option and
-#   global properties may affect expansion of CPU models. Using
-#   query-cpu-model-expansion while using these is not advised.
-#
-# Some architectures may not support all expansion types. s390x supports
-# "full" and "static".
-#
-# Returns: a CpuModelExpansionInfo. Returns an error if expanding CPU models is
-#  not supported, if the model cannot be expanded, if the model 
contains
-#  an unknown CPU definition name, unknown properties or properties
-#  with a wrong type. Also returns an error if an expansion type is
-#  not supported.
-#
-# Since: 2.8.0
-##
-{ 'command': 'query-cpu-model-expansion',
-  'data': { 'type': 'CpuModelExpansionType',
-'model': 'CpuModelInfo' },
-  'returns': 'CpuModelExpansionInfo' }
-
 ##
 # @CpuModelCompareResult:
 #
diff --git a/qapi/target.json b/qapi/target.json
index f4a7054921..35653648bb 100644
--- a/qapi/target.json
+++ b/qapi/target.json
@@ -373,3 +373,55 @@
 ##
 { 'command': 'query-gic-capabilities', 'returns': ['GICCapability'],
   'if': 'defined(TARGET_ARM)' }
+
+##
+# @CpuModelExpansionInfo:
+#
+# The result of a cpu model expansion.
+#
+# @model: the expanded CpuModelInfo.
+#
+# Since: 2.8.0
+##
+{ 'struct': 'CpuModelExpansionInfo',
+  'data': { 'model': 'CpuModelInfo' },
+  'if': 'defined(TARGET_S390X) || defined(TARGET_I386)' }
+
+##
+# @query-cpu-model-expansion:
+#
+# Expands a given CPU model (or a combination of CPU model + additional 
options)
+# to different granularities, allowing tooling to get an understanding what a
+# specific CPU model looks like in QEMU under a certain configuration.
+#
+# This interface can be used to query the "host" CPU model.
+#
+# The

[Qemu-devel] [PATCH v4 14/18] qapi: make query-cpu-definitions depend on specific targets

2019-02-14 Thread Markus Armbruster
From: Marc-André Lureau 

It depends on TARGET_PPC || TARGET_ARM || TARGET_I386 || TARGET_S390X.

Signed-off-by: Marc-André Lureau 
Reviewed-by: Eduardo Habkost 
Acked-by: Cornelia Huck 
Reviewed-by: Markus Armbruster 
Signed-off-by: Markus Armbruster 
---
 include/sysemu/arch_init.h  |  1 -
 monitor.c   | 22 
 qapi/misc.json  | 58 --
 qapi/target.json| 64 +
 qmp.c   |  5 ---
 stubs/Makefile.objs |  1 -
 stubs/arch-query-cpu-def.c  | 11 --
 target/arm/helper.c |  3 +-
 target/i386/cpu.c   |  2 +-
 target/ppc/translate_init.inc.c |  3 +-
 target/s390x/cpu_models.c   |  2 +-
 11 files changed, 70 insertions(+), 102 deletions(-)
 delete mode 100644 stubs/arch-query-cpu-def.c

diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h
index 2497fd3351..10cbafe970 100644
--- a/include/sysemu/arch_init.h
+++ b/include/sysemu/arch_init.h
@@ -32,5 +32,4 @@ extern const uint32_t arch_type;
 int kvm_available(void);
 int xen_available(void);
 
-CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp);
 #endif
diff --git a/monitor.c b/monitor.c
index 22a551b16b..1673db7015 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1131,26 +1131,6 @@ static void qmp_query_qmp_schema(QDict *qdict, QObject 
**ret_data,
 *ret_data = qobject_from_qlit(&qmp_schema_qlit);
 }
 
-/*
- * We used to define commands in qmp-commands.hx in addition to the
- * QAPI schema.  This permitted defining some of them only in certain
- * configurations.  query-commands has always reflected that (good,
- * because it lets QMP clients figure out what's actually available),
- * while query-qmp-schema never did (not so good).  This function is a
- * hack to keep the configuration-specific commands defined exactly as
- * before, even though qmp-commands.hx is gone.
- *
- * FIXME Educate the QAPI schema on configuration-specific commands,
- * and drop this hack.
- */
-static void qmp_unregister_commands_hack(void)
-{
-#if !defined(TARGET_PPC) && !defined(TARGET_ARM) && !defined(TARGET_I386) \
-&& !defined(TARGET_S390X)
-qmp_unregister_command(&qmp_commands, "query-cpu-definitions");
-#endif
-}
-
 static void monitor_init_qmp_commands(void)
 {
 /*
@@ -1169,8 +1149,6 @@ static void monitor_init_qmp_commands(void)
 qmp_register_command(&qmp_commands, "netdev_add", qmp_netdev_add,
  QCO_NO_OPTIONS);
 
-qmp_unregister_commands_hack();
-
 QTAILQ_INIT(&qmp_cap_negotiation_commands);
 qmp_register_command(&qmp_cap_negotiation_commands, "qmp_capabilities",
  qmp_marshal_qmp_capabilities, QCO_ALLOW_PRECONFIG);
diff --git a/qapi/misc.json b/qapi/misc.json
index 1255201267..82f9147353 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -2057,54 +2057,6 @@
 ##
 { 'command': 'query-current-machine', 'returns': 'CurrentMachineParams' }
 
-##
-# @CpuDefinitionInfo:
-#
-# Virtual CPU definition.
-#
-# @name: the name of the CPU definition
-#
-# @migration-safe: whether a CPU definition can be safely used for
-#  migration in combination with a QEMU compatibility machine
-#  when migrating between different QEMU versions and between
-#  hosts with different sets of (hardware or software)
-#  capabilities. If not provided, information is not available
-#  and callers should not assume the CPU definition to be
-#  migration-safe. (since 2.8)
-#
-# @static: whether a CPU definition is static and will not change depending on
-#  QEMU version, machine type, machine options and accelerator options.
-#  A static model is always migration-safe. (since 2.8)
-#
-# @unavailable-features: List of properties that prevent
-#the CPU model from running in the current
-#host. (since 2.8)
-# @typename: Type name that can be used as argument to @device-list-properties,
-#to introspect properties configurable using -cpu or -global.
-#(since 2.9)
-#
-# @unavailable-features is a list of QOM property names that
-# represent CPU model attributes that prevent the CPU from running.
-# If the QOM property is read-only, that means there's no known
-# way to make the CPU model run in the current host. Implementations
-# that choose not to provide specific information return the
-# property name "type".
-# If the property is read-write, it means that it MAY be possible
-# to run the CPU model in the current host if that property is
-# changed. Management software can use it as hints to suggest or
-# choose an alternative for the user, or just to generate meaningful
-# error messages explaining why the CPU model can't be used.
-# If @unavailable-features is an empty list, the CPU model is
-# runnable using the current host and machine-t

[Qemu-devel] [PATCH v4 07/18] build: Deal with all of QAPI's .o in qapi/Makefile.objs

2019-02-14 Thread Markus Armbruster
Adding QAPI's .o to util-obj-y, common-obj-y and obj-y is spread over
three places: Makefile.objs takes care of target-independent generated
code, Makefile.target of target-dependent generated code, and
qapi/Makefile.objs of (target-independent) hand-written code.

Do everything in qapi/Makefile.objs.

Suggested-by: Paolo Bonzini 
Signed-off-by: Markus Armbruster 
---
 Makefile   |  1 -
 Makefile.objs  | 13 -
 Makefile.target|  3 +--
 qapi/Makefile.objs | 19 +++
 4 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/Makefile b/Makefile
index 53d161b65f..a6de28677f 100644
--- a/Makefile
+++ b/Makefile
@@ -89,7 +89,6 @@ include $(SRC_PATH)/rules.mak
 
 GENERATED_FILES = qemu-version.h config-host.h qemu-options.def
 
-#see Makefile.objs for the definition of QAPI_MODULES
 GENERATED_QAPI_FILES = qapi/qapi-builtin-types.h qapi/qapi-builtin-types.c
 GENERATED_QAPI_FILES += qapi/qapi-types.h qapi/qapi-types.c
 GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-types-%.h)
diff --git a/Makefile.objs b/Makefile.objs
index bc78e26f55..4a266357a2 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -1,20 +1,7 @@
-QAPI_MODULES = block-core block char common crypto introspect job migration
-QAPI_MODULES += misc net rdma rocker run-state sockets tpm trace transaction
-QAPI_MODULES += ui
-
 ###
 # Common libraries for tools and emulators
 stub-obj-y = stubs/ crypto/
 util-obj-y = util/ qobject/ qapi/
-util-obj-y += qapi/qapi-builtin-types.o
-util-obj-y += qapi/qapi-types.o
-util-obj-y += $(QAPI_MODULES:%=qapi/qapi-types-%.o)
-util-obj-y += qapi/qapi-builtin-visit.o
-util-obj-y += qapi/qapi-visit.o
-util-obj-y += $(QAPI_MODULES:%=qapi/qapi-visit-%.o)
-util-obj-y += qapi/qapi-emit-events.o
-util-obj-y += qapi/qapi-events.o
-util-obj-y += $(QAPI_MODULES:%=qapi/qapi-events-%.o)
 
 chardev-obj-y = chardev/
 slirp-obj-$(CONFIG_SLIRP) = slirp/
diff --git a/Makefile.target b/Makefile.target
index d8af835890..d6ce549388 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -148,6 +148,7 @@ ifdef CONFIG_SOFTMMU
 obj-y += arch_init.o cpus.o monitor.o gdbstub.o balloon.o ioport.o numa.o
 obj-y += qtest.o
 obj-y += hw/
+obj-y += qapi/
 obj-y += memory.o
 obj-y += memory_mapping.o
 obj-y += dump.o
@@ -164,8 +165,6 @@ endif
 
 GENERATED_FILES += hmp-commands.h hmp-commands-info.h
 
-obj-y += qapi/qapi-introspect.o
-
 endif # CONFIG_SOFTMMU
 
 dummy := $(call unnest-vars,,obj-y)
diff --git a/qapi/Makefile.objs b/qapi/Makefile.objs
index 33906ff321..dacbae 100644
--- a/qapi/Makefile.objs
+++ b/qapi/Makefile.objs
@@ -4,3 +4,22 @@ util-obj-y += string-input-visitor.o string-output-visitor.o
 util-obj-y += opts-visitor.o qapi-clone-visitor.o
 util-obj-y += qmp-event.o
 util-obj-y += qapi-util.o
+
+QAPI_MODULES = block-core block char common crypto introspect job migration
+QAPI_MODULES += misc net rdma rocker run-state sockets tpm trace transaction
+QAPI_MODULES += ui
+
+util-obj-y += qapi-builtin-types.o
+util-obj-y += qapi-types.o
+util-obj-y += $(QAPI_MODULES:%=qapi-types-%.o)
+util-obj-y += qapi-builtin-visit.o
+util-obj-y += qapi-visit.o
+util-obj-y += $(QAPI_MODULES:%=qapi-visit-%.o)
+util-obj-y += qapi-emit-events.o
+util-obj-y += qapi-events.o
+util-obj-y += $(QAPI_MODULES:%=qapi-events-%.o)
+
+common-obj-y += qapi-commands.o
+common-obj-y += $(QAPI_MODULES:%=qapi-commands-%.o)
+
+obj-y += qapi-introspect.o
-- 
2.17.2




[Qemu-devel] [PATCH v4 12/18] qapi: make query-gic-capabilities depend on TARGET_ARM

2019-02-14 Thread Markus Armbruster
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Reviewed-by: Markus Armbruster 
Signed-off-by: Markus Armbruster 
---
 monitor.c| 11 ---
 qapi/misc.json   | 43 --
 qapi/target.json | 45 
 target/arm/monitor.c |  2 +-
 4 files changed, 46 insertions(+), 55 deletions(-)

diff --git a/monitor.c b/monitor.c
index 621e26cc94..33a0d81677 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1145,9 +1145,6 @@ static void qmp_query_qmp_schema(QDict *qdict, QObject 
**ret_data,
  */
 static void qmp_unregister_commands_hack(void)
 {
-#ifndef TARGET_ARM
-qmp_unregister_command(&qmp_commands, "query-gic-capabilities");
-#endif
 #if !defined(TARGET_S390X) && !defined(TARGET_I386)
 qmp_unregister_command(&qmp_commands, "query-cpu-model-expansion");
 #endif
@@ -4657,14 +4654,6 @@ QemuOptsList qemu_mon_opts = {
 },
 };
 
-#ifndef TARGET_ARM
-GICCapabilityList *qmp_query_gic_capabilities(Error **errp)
-{
-error_setg(errp, QERR_FEATURE_DISABLED, "query-gic-capabilities");
-return NULL;
-}
-#endif
-
 HotpluggableCPUList *qmp_query_hotpluggable_cpus(Error **errp)
 {
 MachineState *ms = MACHINE(qdev_get_machine());
diff --git a/qapi/misc.json b/qapi/misc.json
index 431de64590..9df45a27ca 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -3044,49 +3044,6 @@
 ##
 { 'command': 'xen-load-devices-state', 'data': {'filename': 'str'} }
 
-##
-# @GICCapability:
-#
-# The struct describes capability for a specific GIC (Generic
-# Interrupt Controller) version. These bits are not only decided by
-# QEMU/KVM software version, but also decided by the hardware that
-# the program is running upon.
-#
-# @version:  version of GIC to be described. Currently, only 2 and 3
-#are supported.
-#
-# @emulated: whether current QEMU/hardware supports emulated GIC
-#device in user space.
-#
-# @kernel:   whether current QEMU/hardware supports hardware
-#accelerated GIC device in kernel.
-#
-# Since: 2.6
-##
-{ 'struct': 'GICCapability',
-  'data': { 'version': 'int',
-'emulated': 'bool',
-'kernel': 'bool' } }
-
-##
-# @query-gic-capabilities:
-#
-# This command is ARM-only. It will return a list of GICCapability
-# objects that describe its capability bits.
-#
-# Returns: a list of GICCapability objects.
-#
-# Since: 2.6
-#
-# Example:
-#
-# -> { "execute": "query-gic-capabilities" }
-# <- { "return": [{ "version": 2, "emulated": true, "kernel": false },
-# { "version": 3, "emulated": false, "kernel": true } ] }
-#
-##
-{ 'command': 'query-gic-capabilities', 'returns': ['GICCapability'] }
-
 ##
 # @CpuInstanceProperties:
 #
diff --git a/qapi/target.json b/qapi/target.json
index 010df35ebb..f4a7054921 100644
--- a/qapi/target.json
+++ b/qapi/target.json
@@ -328,3 +328,48 @@
 'modelb': 'CpuModelInfo' },
   'returns': 'CpuModelBaselineInfo',
   'if': 'defined(TARGET_S390X)' }
+
+##
+# @GICCapability:
+#
+# The struct describes capability for a specific GIC (Generic
+# Interrupt Controller) version. These bits are not only decided by
+# QEMU/KVM software version, but also decided by the hardware that
+# the program is running upon.
+#
+# @version:  version of GIC to be described. Currently, only 2 and 3
+#are supported.
+#
+# @emulated: whether current QEMU/hardware supports emulated GIC
+#device in user space.
+#
+# @kernel:   whether current QEMU/hardware supports hardware
+#accelerated GIC device in kernel.
+#
+# Since: 2.6
+##
+{ 'struct': 'GICCapability',
+  'data': { 'version': 'int',
+'emulated': 'bool',
+'kernel': 'bool' },
+  'if': 'defined(TARGET_ARM)' }
+
+##
+# @query-gic-capabilities:
+#
+# This command is ARM-only. It will return a list of GICCapability
+# objects that describe its capability bits.
+#
+# Returns: a list of GICCapability objects.
+#
+# Since: 2.6
+#
+# Example:
+#
+# -> { "execute": "query-gic-capabilities" }
+# <- { "return": [{ "version": 2, "emulated": true, "kernel": false },
+# { "version": 3, "emulated": false, "kernel": true } ] }
+#
+##
+{ 'command': 'query-gic-capabilities', 'returns': ['GICCapability'],
+  'if': 'defined(TARGET_ARM)' }
diff --git a/target/arm/monitor.c b/target/arm/monitor.c
index 4cdd2676dd..41b32b94b2 100644
--- a/target/arm/monitor.c
+++ b/target/arm/monitor.c
@@ -23,7 +23,7 @@
 #include "qemu/osdep.h"
 #include "hw/boards.h"
 #include "kvm_arm.h"
-#include "qapi/qapi-commands-misc.h"
+#include "qapi/qapi-commands-target.h"
 
 static GICCapability *gic_cap_new(int version)
 {
-- 
2.17.2




[Qemu-devel] [PATCH v4 06/18] build-sys: move qmp-introspect per target

2019-02-14 Thread Markus Armbruster
From: Marc-André Lureau 

The following patches are going to introduce per-target #ifdef in the
schemas.

The introspection data is statically generated once, and must thus be
built per-target to reflect target-specific configuration.

Drop "do_test_visitor_in_qmp_introspect(&qmp_schema_qlit)" since the
schema is no longer in a common object. It is covered by the per-target
query-qmp-schema test instead.

Signed-off-by: Marc-André Lureau 
Reviewed-by: Markus Armbruster 
Signed-off-by: Markus Armbruster 
---
 Makefile.objs  | 2 --
 Makefile.target| 2 ++
 tests/test-qobject-input-visitor.c | 1 -
 3 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/Makefile.objs b/Makefile.objs
index ec11a0f55b..bc78e26f55 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -15,7 +15,6 @@ util-obj-y += $(QAPI_MODULES:%=qapi/qapi-visit-%.o)
 util-obj-y += qapi/qapi-emit-events.o
 util-obj-y += qapi/qapi-events.o
 util-obj-y += $(QAPI_MODULES:%=qapi/qapi-events-%.o)
-util-obj-y += qapi/qapi-introspect.o
 
 chardev-obj-y = chardev/
 slirp-obj-$(CONFIG_SLIRP) = slirp/
@@ -95,7 +94,6 @@ common-obj-$(CONFIG_FDT) += device_tree.o
 
 common-obj-y += qapi/qapi-commands.o
 common-obj-y += $(QAPI_MODULES:%=qapi/qapi-commands-%.o)
-common-obj-y += qapi/qapi-introspect.o
 common-obj-y += qmp.o hmp.o
 endif
 
diff --git a/Makefile.target b/Makefile.target
index 401dc1ea6f..d8af835890 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -164,6 +164,8 @@ endif
 
 GENERATED_FILES += hmp-commands.h hmp-commands-info.h
 
+obj-y += qapi/qapi-introspect.o
+
 endif # CONFIG_SOFTMMU
 
 dummy := $(call unnest-vars,,obj-y)
diff --git a/tests/test-qobject-input-visitor.c 
b/tests/test-qobject-input-visitor.c
index caa90b3d7e..609334adf6 100644
--- a/tests/test-qobject-input-visitor.c
+++ b/tests/test-qobject-input-visitor.c
@@ -1271,7 +1271,6 @@ static void 
test_visitor_in_qmp_introspect(TestInputVisitorData *data,
const void *unused)
 {
 do_test_visitor_in_qmp_introspect(data, &test_qmp_schema_qlit);
-do_test_visitor_in_qmp_introspect(data, &qmp_schema_qlit);
 }
 
 int main(int argc, char **argv)
-- 
2.17.2




Re: [Qemu-devel] [Qemu-trivial] [PATCH 2/2] qemu-options: Remove deprecated option -clock

2019-02-14 Thread Laurent Vivier
On 07/02/2019 14:14, Thomas Huth wrote:
> The option is only a dummy since a long time. We've finally deprecated
> it in QEMU v3.0, so it's time to remove it now.
> 
> Signed-off-by: Thomas Huth 
> ---
>  qemu-deprecated.texi | 5 -
>  qemu-options.hx  | 3 ---
>  vl.c | 6 --
>  3 files changed, 14 deletions(-)
> 
> diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi
> index 90e5860..fe90555 100644
> --- a/qemu-deprecated.texi
> +++ b/qemu-deprecated.texi
> @@ -37,11 +37,6 @@ would automatically enable USB support on the machine type.
>  If using the new syntax, USB support must be explicitly
>  enabled via the ``-machine usb=on'' argument.
>  
> -@subsection -clock (since 3.0.0)
> -
> -The @code{-clock} option is ignored since QEMU version 1.7.0. There is no
> -replacement since it is not needed anymore.
> -
>  @subsection -drive file=json:@{...@{'driver':'file'@}@} (since 3.0)
>  
>  The 'file' driver for drives is no longer appropriate for character or host
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 06ef1a7..77bd98e 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -3444,9 +3444,6 @@ Load the contents of @var{file} as an option ROM.
>  This option is useful to load things like EtherBoot.
>  ETEXI
>  
> -HXCOMM Silently ignored for compatibility
> -DEF("clock", HAS_ARG, QEMU_OPTION_clock, "", QEMU_ARCH_ALL)
> -
>  DEF("rtc", HAS_ARG, QEMU_OPTION_rtc, \
>  "-rtc 
> [base=utc|localtime|][,clock=host|rt|vm][,driftfix=none|slew]\n" \
>  "set the RTC base and clock, enable drift fix for clock 
> ticks (x86 only)\n",
> diff --git a/vl.c b/vl.c
> index 9e4dba7..90ff233 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -3735,12 +3735,6 @@ int main(int argc, char **argv, char **envp)
>  case QEMU_OPTION_old_param:
>  old_param = 1;
>  break;
> -case QEMU_OPTION_clock:
> -/* Clock options no longer exist.  Keep this option for
> - * backward compatibility.
> - */
> -warn_report("This option is ignored and will be removed 
> soon");
> -break;
>  case QEMU_OPTION_rtc:
>  opts = qemu_opts_parse_noisily(qemu_find_opts("rtc"), optarg,
> false);
> 

Applied to my trivial-patches branch.

Thanks,
Laurent



[Qemu-devel] [PATCH v4 09/18] qapi: make rtc-reset-reinjection and SEV depend on TARGET_I386

2019-02-14 Thread Markus Armbruster
From: Marc-André Lureau 

Move rtc-reset-reinjection and SEV in target.json and make them
conditional on TARGET_I386.

Signed-off-by: Marc-André Lureau 
Reviewed-by: Markus Armbruster 
Signed-off-by: Markus Armbruster 
---
 hw/timer/mc146818rtc.c |   2 +-
 monitor.c  |  31 
 qapi/misc.json | 166 --
 qapi/target.json   | 177 -
 target/i386/sev_i386.h |   2 +-
 5 files changed, 175 insertions(+), 203 deletions(-)

diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c
index 69483152c3..bc1862b6fc 100644
--- a/hw/timer/mc146818rtc.c
+++ b/hw/timer/mc146818rtc.c
@@ -31,7 +31,7 @@
 #include "sysemu/replay.h"
 #include "hw/timer/mc146818rtc.h"
 #include "qapi/error.h"
-#include "qapi/qapi-commands-misc.h"
+#include "qapi/qapi-commands-target.h"
 #include "qapi/qapi-events-misc.h"
 #include "qapi/visitor.h"
 #include "exec/address-spaces.h"
diff --git a/monitor.c b/monitor.c
index 8e02a001a3..ec901fbb47 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1145,12 +1145,6 @@ static void qmp_query_qmp_schema(QDict *qdict, QObject 
**ret_data,
  */
 static void qmp_unregister_commands_hack(void)
 {
-#ifndef TARGET_I386
-qmp_unregister_command(&qmp_commands, "rtc-reset-reinjection");
-qmp_unregister_command(&qmp_commands, "query-sev");
-qmp_unregister_command(&qmp_commands, "query-sev-launch-measure");
-qmp_unregister_command(&qmp_commands, "query-sev-capabilities");
-#endif
 #ifndef TARGET_S390X
 qmp_unregister_command(&qmp_commands, "dump-skeys");
 #endif
@@ -4670,31 +4664,6 @@ QemuOptsList qemu_mon_opts = {
 },
 };
 
-#ifndef TARGET_I386
-void qmp_rtc_reset_reinjection(Error **errp)
-{
-error_setg(errp, QERR_FEATURE_DISABLED, "rtc-reset-reinjection");
-}
-
-SevInfo *qmp_query_sev(Error **errp)
-{
-error_setg(errp, QERR_FEATURE_DISABLED, "query-sev");
-return NULL;
-}
-
-SevLaunchMeasureInfo *qmp_query_sev_launch_measure(Error **errp)
-{
-error_setg(errp, QERR_FEATURE_DISABLED, "query-sev-launch-measure");
-return NULL;
-}
-
-SevCapability *qmp_query_sev_capabilities(Error **errp)
-{
-error_setg(errp, QERR_FEATURE_DISABLED, "query-sev-capabilities");
-return NULL;
-}
-#endif
-
 #ifndef TARGET_S390X
 void qmp_dump_skeys(const char *filename, Error **errp)
 {
diff --git a/qapi/misc.json b/qapi/misc.json
index 426274ecf8..0d9682ba4c 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -3119,24 +3119,6 @@
 { 'event': 'ACPI_DEVICE_OST',
  'data': { 'info': 'ACPIOSTInfo' } }
 
-##
-# @rtc-reset-reinjection:
-#
-# This command will reset the RTC interrupt reinjection backlog.
-# Can be used if another mechanism to synchronize guest time
-# is in effect, for example QEMU guest agent's guest-set-time
-# command.
-#
-# Since: 2.1
-#
-# Example:
-#
-# -> { "execute": "rtc-reset-reinjection" }
-# <- { "return": {} }
-#
-##
-{ 'command': 'rtc-reset-reinjection' }
-
 ##
 # @RTC_CHANGE:
 #
@@ -3365,154 +3347,6 @@
 ##
 { 'command': 'query-vm-generation-id', 'returns': 'GuidInfo' }
 
-
-##
-# @SevState:
-#
-# An enumeration of SEV state information used during @query-sev.
-#
-# @uninit: The guest is uninitialized.
-#
-# @launch-update: The guest is currently being launched; plaintext data and
-# register state is being imported.
-#
-# @launch-secret: The guest is currently being launched; ciphertext data
-# is being imported.
-#
-# @running: The guest is fully launched or migrated in.
-#
-# @send-update: The guest is currently being migrated out to another machine.
-#
-# @receive-update: The guest is currently being migrated from another machine.
-#
-# Since: 2.12
-##
-{ 'enum': 'SevState',
-  'data': ['uninit', 'launch-update', 'launch-secret', 'running',
-   'send-update', 'receive-update' ] }
-
-##
-# @SevInfo:
-#
-# Information about Secure Encrypted Virtualization (SEV) support
-#
-# @enabled: true if SEV is active
-#
-# @api-major: SEV API major version
-#
-# @api-minor: SEV API minor version
-#
-# @build-id: SEV FW build id
-#
-# @policy: SEV policy value
-#
-# @state: SEV guest state
-#
-# @handle: SEV firmware handle
-#
-# Since: 2.12
-##
-{ 'struct': 'SevInfo',
-'data': { 'enabled': 'bool',
-  'api-major': 'uint8',
-  'api-minor' : 'uint8',
-  'build-id' : 'uint8',
-  'policy' : 'uint32',
-  'state' : 'SevState',
-  'handle' : 'uint32'
-}
-}
-
-##
-# @query-sev:
-#
-# Returns information about SEV
-#
-# Returns: @SevInfo
-#
-# Since: 2.12
-#
-# Example:
-#
-# -> { "execute": "query-sev" }
-# <- { "return": { "enabled": true, "api-major" : 0, "api-minor" : 0,
-#  "build-id" : 0, "policy" : 0, "state" : "running",
-#  "handle" : 1 } }
-#
-##
-{ 'command': 'query-sev', 'returns': 'SevInfo' }
-
-##
-# @SevLaunchMeasureInfo:
-#
-# SEV Guest Launch measurement information
-#
-# @data: the measurement value encoded 

Re: [Qemu-devel] [PATCH 1/4] target/arm: Add helpers for FMLAL and FMLSL

2019-02-14 Thread Laurent Desnogues
Hello,

On Thu, Feb 14, 2019 at 5:00 AM Richard Henderson
 wrote:
>
> Note that float16_to_float32 rightly squashes SNaN to QNaN.
> But of course pickNaNMulAdd, for ARM, selects SNaNs first.
> So we have to preserve SNaN long enough for the correct NaN
> to be selected.  Thus float16_to_float32_by_bits.
>
> Signed-off-by: Richard Henderson 
> ---
>  target/arm/helper.h |   9 +++
>  target/arm/vec_helper.c | 154 
>  2 files changed, 163 insertions(+)
>
> diff --git a/target/arm/helper.h b/target/arm/helper.h
> index 53a38188c6..0302e13604 100644
> --- a/target/arm/helper.h
> +++ b/target/arm/helper.h
> @@ -653,6 +653,15 @@ DEF_HELPER_FLAGS_6(gvec_fmla_idx_s, TCG_CALL_NO_RWG,
>  DEF_HELPER_FLAGS_6(gvec_fmla_idx_d, TCG_CALL_NO_RWG,
> void, ptr, ptr, ptr, ptr, ptr, i32)
>
> +DEF_HELPER_FLAGS_5(gvec_fmlal_h, TCG_CALL_NO_RWG,
> +   void, ptr, ptr, ptr, ptr, i32)
> +DEF_HELPER_FLAGS_5(gvec_fmlsl_h, TCG_CALL_NO_RWG,
> +   void, ptr, ptr, ptr, ptr, i32)
> +DEF_HELPER_FLAGS_5(gvec_fmlal_idx_h, TCG_CALL_NO_RWG,
> +   void, ptr, ptr, ptr, ptr, i32)
> +DEF_HELPER_FLAGS_5(gvec_fmlsl_idx_h, TCG_CALL_NO_RWG,
> +   void, ptr, ptr, ptr, ptr, i32)
> +
>  #ifdef TARGET_AARCH64
>  #include "helper-a64.h"
>  #include "helper-sve.h"
> diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c
> index 37f338732e..0c3b3de961 100644
> --- a/target/arm/vec_helper.c
> +++ b/target/arm/vec_helper.c
> @@ -766,3 +766,157 @@ DO_FMLA_IDX(gvec_fmla_idx_s, float32, H4)
>  DO_FMLA_IDX(gvec_fmla_idx_d, float64, )
>
>  #undef DO_FMLA_IDX
> +
> +/*
> + * Convert float16 to float32, raising no exceptions and
> + * preserving exceptional values, including SNaN.
> + * This is effectively an unpack+repack operation.
> + */
> +static float32 float16_to_float32_by_bits(uint32_t f16)
> +{
> +const int f16_bias = 15;
> +const int f32_bias = 127;
> +uint32_t sign = extract32(f16, 15, 1);
> +uint32_t exp = extract32(f16, 10, 5);
> +uint32_t frac = extract32(f16, 0, 10);
> +
> +if (exp == 0x1f) {
> +/* Inf or NaN */
> +exp = 0xff;
> +} else if (exp == 0) {
> +/* Zero or denormal.  */
> +if (frac != 0) {
> +/*
> + * Denormal; these are all normal float32.
> + * Shift the fraction so that the msb is at bit 11,
> + * then remove bit 11 as the implicit bit of the
> + * normalized float32.  Note that we still go through
> + * the shift for normal numbers below, to put the
> + * float32 fraction at the right place.
> + */
> +int shift = clz32(frac) - 21;
> +frac = (frac << shift) & 0x3ff;
> +exp = f32_bias - f16_bias - shift + 1;

If FZ16 is set, this should flush to zero.

This means you will have to use both fp_status (for the muladd) and
fp_status_f16 (for this function) and so you should pass cpu_env to
the helpers rather than the fp_status.

Thanks,

Laurent

> +}
> +} else {
> +/* Normal number; adjust the bias.  */
> +exp += f32_bias - f16_bias;
> +}
> +sign <<= 31;
> +exp <<= 23;
> +frac <<= 23 - 10;
> +
> +return sign | exp | frac;
> +}
> +
> +static float32 fmlal(float32 a, float16 n16, float16 m16, float_status *fpst)
> +{
> +float32 n = float16_to_float32_by_bits(n16);
> +float32 m = float16_to_float32_by_bits(m16);
> +return float32_muladd(n, m, a, 0, fpst);
> +}
> +
> +static float32 fmlsl(float32 a, float16 n16, float16 m16, float_status *fpst)
> +{
> +float32 n = float16_to_float32_by_bits(n16);
> +float32 m = float16_to_float32_by_bits(m16);
> +return float32_muladd(float32_chs(n), m, a, 0, fpst);
> +}
> +
> +static inline uint64_t load4_f16(uint64_t *ptr, int is_q, int is_2)
> +{
> +/*
> + * Branchless load of u32[0], u64[0], u32[1], or u64[1].
> + * Load the 2nd qword iff is_q & is_2.
> + * Shift to the 2nd dword iff !is_q & is_2.
> + * For !is_q & !is_2, the upper bits of the result are garbage.
> + */
> +return ptr[is_q & is_2] >> ((is_2 & ~is_q) << 5);
> +}
> +
> +/*
> + * Note that FMLAL and FMLSL require oprsz == 8 or oprsz == 16,
> + * as there is not yet SVE versions that might use blocking.
> + */
> +
> +void HELPER(gvec_fmlal_h)(void *vd, void *vn, void *vm,
> +  void *fpst, uint32_t desc)
> +{
> +intptr_t i, oprsz = simd_oprsz(desc);
> +int is_2 = extract32(desc, SIMD_DATA_SHIFT, 1);
> +int is_q = oprsz == 16;
> +float32 *d = vd;
> +uint64_t n_4, m_4;
> +
> +/* Pre-load all of the f16 data, avoiding overlap issues.  */
> +n_4 = load4_f16(vn, is_q, is_2);
> +m_4 = load4_f16(vm, is_q, is_2);
> +
> +for (i = 0; i < oprsz / 4; i++) {
> +d[H4(i)] = fmlal(d[H4(i)], extract64(n_4, i*16, 16),
> + extract64(m_4, i*16, 16), fpst);
> +  

[Qemu-devel] [PATCH v4 01/18] qapi: Belatedly document modular code generation

2019-02-14 Thread Markus Armbruster
We generate code for built-ins and sub-modules into separate files
since commit cdb6610ae42 and 252dc3105fc (v2.12.0).  Both commits
neglected to update documentation.  Do that now.

Signed-off-by: Markus Armbruster 
Reviewed-by: Marc-André Lureau 
---
 docs/devel/qapi-code-gen.txt | 38 
 1 file changed, 38 insertions(+)

diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt
index 87183d3a09..b91bde647c 100644
--- a/docs/devel/qapi-code-gen.txt
+++ b/docs/devel/qapi-code-gen.txt
@@ -1113,6 +1113,19 @@ Example:
 
 [Uninteresting stuff omitted...]
 
+For a modular QAPI schema (see section Include directives), code for
+each sub-module SUBDIR/SUBMODULE.json is actually generated into
+
+SUBDIR/$(prefix)qapi-types-SUBMODULE.h
+SUBDIR/$(prefix)qapi-types-SUBMODULE.c
+
+If qapi-gen.py is run with option --builtins, additional files are
+created:
+
+qapi-builtin-types.h - C types corresponding to built-in types
+
+qapi-builtin-types.c - Cleanup functions for the above C types
+
 === Code generated for visiting QAPI types ===
 
 These are the visitor functions used to walk through and convert
@@ -1244,6 +1257,19 @@ Example:
 
 [Uninteresting stuff omitted...]
 
+For a modular QAPI schema (see section Include directives), code for
+each sub-module SUBDIR/SUBMODULE.json is actually generated into
+
+SUBDIR/$(prefix)qapi-visit-SUBMODULE.h
+SUBDIR/$(prefix)qapi-visit-SUBMODULE.c
+
+If qapi-gen.py is run with option --builtins, additional files are
+created:
+
+qapi-builtin-visit.h - Visitor functions for built-in types
+
+qapi-builtin-visit.c - Declarations for these visitor functions
+
 === Code generated for commands ===
 
 These are the marshaling/dispatch functions for the commands defined
@@ -1342,6 +1368,12 @@ Example:
 
 [Uninteresting stuff omitted...]
 
+For a modular QAPI schema (see section Include directives), code for
+each sub-module SUBDIR/SUBMODULE.json is actually generated into
+
+SUBDIR/$(prefix)qapi-commands-SUBMODULE.h
+SUBDIR/$(prefix)qapi-commands-SUBMODULE.c
+
 === Code generated for events ===
 
 This is the code related to events defined in the schema, providing
@@ -1402,6 +1434,12 @@ Example:
 
 [Uninteresting stuff omitted...]
 
+For a modular QAPI schema (see section Include directives), code for
+each sub-module SUBDIR/SUBMODULE.json is actually generated into
+
+SUBDIR/$(prefix)qapi-events-SUBMODULE.h
+SUBDIR/$(prefix)qapi-events-SUBMODULE.c
+
 === Code generated for introspection ===
 
 The following files are created:
-- 
2.17.2




[Qemu-devel] [PATCH v4 04/18] qapi: Prepare for system modules other than 'builtin'

2019-02-14 Thread Markus Armbruster
The next commit wants to generate qapi-emit-events.{c.h}.  To enable
that, extend QAPISchemaModularCVisitor to support additional "system
modules", i.e. modules that don't correspond to a (user-defined) QAPI
schema module.

Signed-off-by: Markus Armbruster 
Reviewed-by: Marc-André Lureau 
---
 scripts/qapi/common.py | 35 +--
 scripts/qapi/types.py  |  2 +-
 scripts/qapi/visit.py  |  2 +-
 3 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
index 0e3ec598a4..c327ae5036 100644
--- a/scripts/qapi/common.py
+++ b/scripts/qapi/common.py
@@ -2327,27 +2327,42 @@ class QAPISchemaModularCVisitor(QAPISchemaVisitor):
 self._module = {}
 self._main_module = None
 
+@staticmethod
+def _is_user_module(name):
+return name and not name.startswith('./')
+
 @staticmethod
 def _is_builtin_module(name):
 return not name
 
 def _module_basename(self, what, name):
-if name is None:
-return re.sub(r'-', '-builtin-', what)
-basename = os.path.join(os.path.dirname(name),
-self._prefix + what)
-if name == self._main_module:
-return basename
-return basename + '-' + os.path.splitext(os.path.basename(name))[0]
+ret = '' if self._is_builtin_module(name) else self._prefix
+if self._is_user_module(name):
+dirname, basename = os.path.split(name)
+ret += what
+if name != self._main_module:
+ret += '-' + os.path.splitext(basename)[0]
+ret = os.path.join(dirname, ret)
+else:
+name = name[2:] if name else 'builtin'
+ret += re.sub(r'-', '-' + name + '-', what)
+return ret
 
 def _add_module(self, name, blurb):
-if self._main_module is None and not self._is_builtin_module(name):
-self._main_module = name
 genc = QAPIGenC(blurb, self._pydoc)
 genh = QAPIGenH(blurb, self._pydoc)
 self._module[name] = (genc, genh)
 self._set_module(name)
 
+def _add_user_module(self, name, blurb):
+assert self._is_user_module(name)
+if self._main_module is None:
+self._main_module = name
+self._add_module(name, blurb)
+
+def _add_system_module(self, name, blurb):
+self._add_module(name and './' + name, blurb)
+
 def _set_module(self, name):
 self._genc, self._genh = self._module[name]
 
@@ -2372,7 +2387,7 @@ class QAPISchemaModularCVisitor(QAPISchemaVisitor):
 self._genc = None
 self._genh = None
 else:
-self._add_module(name, self._blurb)
+self._add_user_module(name, self._blurb)
 self._begin_user_module(name)
 
 def visit_include(self, name, info):
diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py
index 9fa510f7df..2bd6fcd44f 100644
--- a/scripts/qapi/types.py
+++ b/scripts/qapi/types.py
@@ -183,7 +183,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaModularCVisitor):
 QAPISchemaModularCVisitor.__init__(
 self, prefix, 'qapi-types', ' * Schema-defined QAPI types',
 __doc__)
-self._add_module(None, ' * Built-in QAPI types')
+self._add_system_module(None, ' * Built-in QAPI types')
 self._genc.preamble_add(mcgen('''
 #include "qemu/osdep.h"
 #include "qapi/dealloc-visitor.h"
diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py
index ca86009398..826b8066e1 100644
--- a/scripts/qapi/visit.py
+++ b/scripts/qapi/visit.py
@@ -284,7 +284,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaModularCVisitor):
 QAPISchemaModularCVisitor.__init__(
 self, prefix, 'qapi-visit', ' * Schema-defined QAPI visitors',
 __doc__)
-self._add_module(None, ' * Built-in QAPI visitors')
+self._add_system_module(None, ' * Built-in QAPI visitors')
 self._genc.preamble_add(mcgen('''
 #include "qemu/osdep.h"
 #include "qemu-common.h"
-- 
2.17.2




Re: [Qemu-devel] [PATCH] linux-user: fix emulation of accept4/getpeername/getsockname/recvfrom syscalls

2019-02-14 Thread Laurent Vivier
On 07/02/2019 15:51, Andreas Schwab wrote:
> System calls that return a socket address do so by writing the (possibly
> truncated) address into the provided buffer space, but setting the addrlen
> parameter to the actual size of the address.  To determine how much to
> copy back to the target memory the emulation needs to remember the old
> value of the addrlen parameter, so that it doesn't write past the buffer
> limits.
> 
> Signed-off-by: Andreas Schwab 

Andreas,

could you fix the coding style errors reported by patchew?

Thanks,
Laurent

> ---
>  linux-user/syscall.c | 38 ++
>  1 file changed, 22 insertions(+), 16 deletions(-)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 55fa235a56..90bfda3563 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -2884,7 +2884,7 @@ static abi_long do_sendrecvmmsg(int fd, abi_ulong 
> target_msgvec,
>  static abi_long do_accept4(int fd, abi_ulong target_addr,
> abi_ulong target_addrlen_addr, int flags)
>  {
> -socklen_t addrlen;
> +socklen_t addrlen, ret_addrlen;
>  void *addr;
>  abi_long ret;
>  int host_flags;
> @@ -2908,10 +2908,11 @@ static abi_long do_accept4(int fd, abi_ulong 
> target_addr,
>  
>  addr = alloca(addrlen);
>  
> -ret = get_errno(safe_accept4(fd, addr, &addrlen, host_flags));
> +ret_addrlen = addrlen;
> +ret = get_errno(safe_accept4(fd, addr, &ret_addrlen, host_flags));
>  if (!is_error(ret)) {
> -host_to_target_sockaddr(target_addr, addr, addrlen);
> -if (put_user_u32(addrlen, target_addrlen_addr))
> +host_to_target_sockaddr(target_addr, addr, MIN(addrlen, 
> ret_addrlen));
> +if (put_user_u32(ret_addrlen, target_addrlen_addr))
>  ret = -TARGET_EFAULT;
>  }
>  return ret;
> @@ -2921,7 +2922,7 @@ static abi_long do_accept4(int fd, abi_ulong 
> target_addr,
>  static abi_long do_getpeername(int fd, abi_ulong target_addr,
> abi_ulong target_addrlen_addr)
>  {
> -socklen_t addrlen;
> +socklen_t addrlen, ret_addrlen;
>  void *addr;
>  abi_long ret;
>  
> @@ -2937,10 +2938,11 @@ static abi_long do_getpeername(int fd, abi_ulong 
> target_addr,
>  
>  addr = alloca(addrlen);
>  
> -ret = get_errno(getpeername(fd, addr, &addrlen));
> +ret_addrlen = addrlen;
> +ret = get_errno(getpeername(fd, addr, &ret_addrlen));
>  if (!is_error(ret)) {
> -host_to_target_sockaddr(target_addr, addr, addrlen);
> -if (put_user_u32(addrlen, target_addrlen_addr))
> +host_to_target_sockaddr(target_addr, addr, MIN(addrlen, 
> ret_addrlen));
> +if (put_user_u32(ret_addrlen, target_addrlen_addr))
>  ret = -TARGET_EFAULT;
>  }
>  return ret;
> @@ -2950,7 +2952,7 @@ static abi_long do_getpeername(int fd, abi_ulong 
> target_addr,
>  static abi_long do_getsockname(int fd, abi_ulong target_addr,
> abi_ulong target_addrlen_addr)
>  {
> -socklen_t addrlen;
> +socklen_t addrlen, ret_addrlen;
>  void *addr;
>  abi_long ret;
>  
> @@ -2966,10 +2968,11 @@ static abi_long do_getsockname(int fd, abi_ulong 
> target_addr,
>  
>  addr = alloca(addrlen);
>  
> -ret = get_errno(getsockname(fd, addr, &addrlen));
> +ret_addrlen = addrlen;
> +ret = get_errno(getsockname(fd, addr, &ret_addrlen));
>  if (!is_error(ret)) {
> -host_to_target_sockaddr(target_addr, addr, addrlen);
> -if (put_user_u32(addrlen, target_addrlen_addr))
> +host_to_target_sockaddr(target_addr, addr, MIN(addrlen, 
> ret_addrlen));
> +if (put_user_u32(ret_addrlen, target_addrlen_addr))
>  ret = -TARGET_EFAULT;
>  }
>  return ret;
> @@ -3042,7 +3045,7 @@ static abi_long do_recvfrom(int fd, abi_ulong msg, 
> size_t len, int flags,
>  abi_ulong target_addr,
>  abi_ulong target_addrlen)
>  {
> -socklen_t addrlen;
> +socklen_t addrlen, ret_addrlen;
>  void *addr;
>  void *host_msg;
>  abi_long ret;
> @@ -3060,10 +3063,12 @@ static abi_long do_recvfrom(int fd, abi_ulong msg, 
> size_t len, int flags,
>  goto fail;
>  }
>  addr = alloca(addrlen);
> +ret_addrlen = addrlen;
>  ret = get_errno(safe_recvfrom(fd, host_msg, len, flags,
> -  addr, &addrlen));
> +  addr, &ret_addrlen));
>  } else {
>  addr = NULL; /* To keep compiler quiet.  */
> +addrlen = 0; /* To keep compiler quiet.  */
>  ret = get_errno(safe_recvfrom(fd, host_msg, len, flags, NULL, 0));
>  }
>  if (!is_error(ret)) {
> @@ -3076,8 +3081,9 @@ static abi_long do_recvfrom(int fd, abi_ulong msg, 
> size_t len, int flags,
>  }
>  }
>  if (target_addr) {
> -host_to_target_sockaddr(target

[Qemu-devel] [PATCH v4 05/18] qapi: Generate QAPIEvent stuff into separate files

2019-02-14 Thread Markus Armbruster
Having to include qapi-events.h just for QAPIEvent is suboptimal, but
quite tolerable now.  It'll become problematic when we have events
conditional on the target, because then qapi-events.h won't be usable
from target-independent code anymore.  Avoid that by generating it
into separate files.

Signed-off-by: Markus Armbruster 
Reviewed-by: Marc-André Lureau 
---
 .gitignore   |  1 +
 Makefile |  1 +
 Makefile.objs|  1 +
 docs/devel/qapi-code-gen.txt | 48 
 monitor.c|  2 +-
 scripts/qapi/events.py   | 32 +++-
 stubs/monitor.c  |  2 +-
 tests/test-qmp-event.c   |  1 +
 ui/vnc.c |  3 ++-
 9 files changed, 61 insertions(+), 30 deletions(-)

diff --git a/.gitignore b/.gitignore
index 321095bf1a..b66b772551 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,6 +32,7 @@
 /qapi/qapi-builtin-visit.[ch]
 /qapi/qapi-commands-*.[ch]
 /qapi/qapi-commands.[ch]
+/qapi/qapi-emit-events.[ch]
 /qapi/qapi-events-*.[ch]
 /qapi/qapi-events.[ch]
 /qapi/qapi-introspect.[ch]
diff --git a/Makefile b/Makefile
index 3658310b95..53d161b65f 100644
--- a/Makefile
+++ b/Makefile
@@ -101,6 +101,7 @@ GENERATED_QAPI_FILES += 
$(QAPI_MODULES:%=qapi/qapi-visit-%.c)
 GENERATED_QAPI_FILES += qapi/qapi-commands.h qapi/qapi-commands.c
 GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-commands-%.h)
 GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-commands-%.c)
+GENERATED_QAPI_FILES += qapi/qapi-emit-events.h qapi/qapi-emit-events.c
 GENERATED_QAPI_FILES += qapi/qapi-events.h qapi/qapi-events.c
 GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-events-%.h)
 GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-events-%.c)
diff --git a/Makefile.objs b/Makefile.objs
index b7aae33367..ec11a0f55b 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -12,6 +12,7 @@ util-obj-y += $(QAPI_MODULES:%=qapi/qapi-types-%.o)
 util-obj-y += qapi/qapi-builtin-visit.o
 util-obj-y += qapi/qapi-visit.o
 util-obj-y += $(QAPI_MODULES:%=qapi/qapi-visit-%.o)
+util-obj-y += qapi/qapi-emit-events.o
 util-obj-y += qapi/qapi-events.o
 util-obj-y += $(QAPI_MODULES:%=qapi/qapi-events-%.o)
 util-obj-y += qapi/qapi-introspect.o
diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt
index c9ba8ddb2e..b517b0cfbf 100644
--- a/docs/devel/qapi-code-gen.txt
+++ b/docs/devel/qapi-code-gen.txt
@@ -1381,11 +1381,15 @@ qapi_event_send_EVENT().
 
 The following files are created:
 
-$(prefix)qapi-events.h - Function prototypes for each event type, plus an
-enumeration of all event names
+$(prefix)qapi-events.h - Function prototypes for each event type
 
 $(prefix)qapi-events.c - Implementation of functions to send an event
 
+$(prefix)qapi-emit-events.h - Enumeration of all event names, and
+  common event code declarations
+
+$(prefix)qapi-emit-events.c - Common event code definitions
+
 Example:
 
 $ cat qapi-generated/example-qapi-events.h
@@ -1397,9 +1401,32 @@ Example:
 #include "qapi/util.h"
 #include "example-qapi-types.h"
 
-
 void qapi_event_send_my_event(void);
 
+#endif /* EXAMPLE_QAPI_EVENTS_H */
+$ cat qapi-generated/example-qapi-events.c
+[Uninteresting stuff omitted...]
+
+void qapi_event_send_my_event(void)
+{
+QDict *qmp;
+
+qmp = qmp_event_build_dict("MY_EVENT");
+
+example_qapi_event_emit(EXAMPLE_QAPI_EVENT_MY_EVENT, qmp);
+
+qobject_unref(qmp);
+}
+
+[Uninteresting stuff omitted...]
+$ cat qapi-generated/example-qapi-emit-events.h
+[Uninteresting stuff omitted...]
+
+#ifndef EXAMPLE_QAPI_EMIT_EVENTS_H
+#define EXAMPLE_QAPI_EMIT_EVENTS_H
+
+#include "qapi/util.h"
+
 typedef enum example_QAPIEvent {
 EXAMPLE_QAPI_EVENT_MY_EVENT,
 EXAMPLE_QAPI_EVENT__MAX,
@@ -1412,21 +1439,10 @@ Example:
 
 void example_qapi_event_emit(example_QAPIEvent event, QDict *qdict);
 
-#endif /* EXAMPLE_QAPI_EVENTS_H */
-$ cat qapi-generated/example-qapi-events.c
+#endif /* EXAMPLE_QAPI_EMIT_EVENTS_H */
+$ cat qapi-generated/example-qapi-emit-events.c
 [Uninteresting stuff omitted...]
 
-void qapi_event_send_my_event(void)
-{
-QDict *qmp;
-
-qmp = qmp_event_build_dict("MY_EVENT");
-
-example_qapi_event_emit(EXAMPLE_QAPI_EVENT_MY_EVENT, qmp);
-
-qobject_unref(qmp);
-}
-
 const QEnumLookup example_QAPIEvent_lookup = {
 .array = (const char *const[]) {
 [EXAMPLE_QAPI_EVENT_MY_EVENT] = "MY_EVENT",
diff --git a/monitor.c b/monitor.c
index e5de5765b8..8e02a001a3 100644
--- a/monitor.c
+++ b/monitor.c
@@ -75,7 +75,7 @@
 #include "qemu/thread.h"
 #include "block/qapi.h"
 #include "qapi/qapi-commands.h"
-#include "qapi/qapi-events.h"
+#include "qapi/qapi-emit-events.h"
 #include "qapi/error.h"
 #include "qapi/qmp-event.h"
 #include "qapi/qapi-introspect.h"
diff --git a/scripts/qapi/event

[Qemu-devel] [PATCH v4 10/18] qapi: make s390 commands depend on TARGET_S390X

2019-02-14 Thread Markus Armbruster
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Acked-by: Cornelia Huck 
Reviewed-by: Markus Armbruster 
Signed-off-by: Markus Armbruster 
---
 hw/s390x/s390-skeys.c   |   2 +-
 include/sysemu/arch_init.h  |   7 --
 monitor.c   |  14 ---
 qapi/misc.json  | 137 ---
 qapi/target.json| 142 
 qmp.c   |  14 ---
 stubs/Makefile.objs |   2 -
 stubs/arch-query-cpu-model-baseline.c   |  13 ---
 stubs/arch-query-cpu-model-comparison.c |  13 ---
 target/s390x/cpu_models.c   |   5 +-
 10 files changed, 146 insertions(+), 203 deletions(-)
 delete mode 100644 stubs/arch-query-cpu-model-baseline.c
 delete mode 100644 stubs/arch-query-cpu-model-comparison.c

diff --git a/hw/s390x/s390-skeys.c b/hw/s390x/s390-skeys.c
index 15f7ab0e53..daac936698 100644
--- a/hw/s390x/s390-skeys.c
+++ b/hw/s390x/s390-skeys.c
@@ -14,7 +14,7 @@
 #include "hw/boards.h"
 #include "hw/s390x/storage-keys.h"
 #include "qapi/error.h"
-#include "qapi/qapi-commands-misc.h"
+#include "qapi/qapi-commands-target.h"
 #include "qapi/qmp/qdict.h"
 #include "qemu/error-report.h"
 #include "sysemu/kvm.h"
diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h
index 32abdfe6a1..f0ef652b2a 100644
--- a/include/sysemu/arch_init.h
+++ b/include/sysemu/arch_init.h
@@ -36,11 +36,4 @@ CpuDefinitionInfoList *arch_query_cpu_definitions(Error 
**errp);
 CpuModelExpansionInfo *arch_query_cpu_model_expansion(CpuModelExpansionType 
type,
   CpuModelInfo *mode,
   Error **errp);
-CpuModelCompareInfo *arch_query_cpu_model_comparison(CpuModelInfo *modela,
- CpuModelInfo *modelb,
- Error **errp);
-CpuModelBaselineInfo *arch_query_cpu_model_baseline(CpuModelInfo *modela,
-CpuModelInfo *modelb,
-Error **errp);
-
 #endif
diff --git a/monitor.c b/monitor.c
index ec901fbb47..621e26cc94 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1145,19 +1145,12 @@ static void qmp_query_qmp_schema(QDict *qdict, QObject 
**ret_data,
  */
 static void qmp_unregister_commands_hack(void)
 {
-#ifndef TARGET_S390X
-qmp_unregister_command(&qmp_commands, "dump-skeys");
-#endif
 #ifndef TARGET_ARM
 qmp_unregister_command(&qmp_commands, "query-gic-capabilities");
 #endif
 #if !defined(TARGET_S390X) && !defined(TARGET_I386)
 qmp_unregister_command(&qmp_commands, "query-cpu-model-expansion");
 #endif
-#if !defined(TARGET_S390X)
-qmp_unregister_command(&qmp_commands, "query-cpu-model-baseline");
-qmp_unregister_command(&qmp_commands, "query-cpu-model-comparison");
-#endif
 #if !defined(TARGET_PPC) && !defined(TARGET_ARM) && !defined(TARGET_I386) \
 && !defined(TARGET_S390X)
 qmp_unregister_command(&qmp_commands, "query-cpu-definitions");
@@ -4664,13 +4657,6 @@ QemuOptsList qemu_mon_opts = {
 },
 };
 
-#ifndef TARGET_S390X
-void qmp_dump_skeys(const char *filename, Error **errp)
-{
-error_setg(errp, QERR_FEATURE_DISABLED, "dump-skeys");
-}
-#endif
-
 #ifndef TARGET_ARM
 GICCapabilityList *qmp_query_gic_capabilities(Error **errp)
 {
diff --git a/qapi/misc.json b/qapi/misc.json
index 0d9682ba4c..431de64590 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -1907,27 +1907,6 @@
 { 'command': 'query-dump-guest-memory-capability',
   'returns': 'DumpGuestMemoryCapability' }
 
-##
-# @dump-skeys:
-#
-# Dump guest's storage keys
-#
-# @filename: the path to the file to dump to
-#
-# This command is only supported on s390 architecture.
-#
-# Since: 2.5
-#
-# Example:
-#
-# -> { "execute": "dump-skeys",
-#  "arguments": { "filename": "/tmp/skeys" } }
-# <- { "return": {} }
-#
-##
-{ 'command': 'dump-skeys',
-  'data': { 'filename': 'str' } }
-
 ##
 # @object-add:
 #
@@ -2294,122 +2273,6 @@
 { 'enum': 'CpuModelCompareResult',
   'data': [ 'incompatible', 'identical', 'superset', 'subset' ] }
 
-##
-# @CpuModelCompareInfo:
-#
-# The result of a CPU model comparison.
-#
-# @result: The result of the compare operation.
-# @responsible-properties: List of properties that led to the comparison result
-#  not being identical.
-#
-# @responsible-properties is a list of QOM property names that led to
-# both CPUs not being detected as identical. For identical models, this
-# list is empty.
-# If a QOM property is read-only, that means there's no known way to make the
-# CPU models identical. If the special property name "type" is included, the
-# models are by definition not identical and cannot be made identical.
-#
-# Since: 2.8.0
-##
-{ 'struct': 'CpuModelCompareInfo',
-  'data': {'result': 'CpuModelCompareResult',
-

[Qemu-devel] [PATCH v4 15/18] qapi: remove qmp_unregister_command()

2019-02-14 Thread Markus Armbruster
From: Marc-André Lureau 

This command is no longer needed, the schema has compile-time
configuration conditions.

Signed-off-by: Marc-André Lureau 
Reviewed-by: Markus Armbruster 
Signed-off-by: Markus Armbruster 
---
 include/qapi/qmp/dispatch.h | 1 -
 qapi/qmp-registry.c | 8 
 2 files changed, 9 deletions(-)

diff --git a/include/qapi/qmp/dispatch.h b/include/qapi/qmp/dispatch.h
index 68a528a9aa..9aa426a398 100644
--- a/include/qapi/qmp/dispatch.h
+++ b/include/qapi/qmp/dispatch.h
@@ -39,7 +39,6 @@ typedef QTAILQ_HEAD(QmpCommandList, QmpCommand) 
QmpCommandList;
 
 void qmp_register_command(QmpCommandList *cmds, const char *name,
   QmpCommandFunc *fn, QmpCommandOptions options);
-void qmp_unregister_command(QmpCommandList *cmds, const char *name);
 QmpCommand *qmp_find_command(QmpCommandList *cmds, const char *name);
 void qmp_disable_command(QmpCommandList *cmds, const char *name);
 void qmp_enable_command(QmpCommandList *cmds, const char *name);
diff --git a/qapi/qmp-registry.c b/qapi/qmp-registry.c
index 5af484cd9a..ca00f74795 100644
--- a/qapi/qmp-registry.c
+++ b/qapi/qmp-registry.c
@@ -27,14 +27,6 @@ void qmp_register_command(QmpCommandList *cmds, const char 
*name,
 QTAILQ_INSERT_TAIL(cmds, cmd, node);
 }
 
-void qmp_unregister_command(QmpCommandList *cmds, const char *name)
-{
-QmpCommand *cmd = qmp_find_command(cmds, name);
-
-QTAILQ_REMOVE(cmds, cmd, node);
-g_free(cmd);
-}
-
 QmpCommand *qmp_find_command(QmpCommandList *cmds, const char *name)
 {
 QmpCommand *cmd;
-- 
2.17.2




Re: [Qemu-devel] [PATCH] linux-user: check valid address in access_ok()

2019-02-14 Thread Laurent Vivier
On 08/02/2019 19:33, Laurent Vivier wrote:
> On 08/02/2019 18:35, Rémi Denis-Courmont wrote:
>> This works around the LTP crash, but there are problably better ways to
>> go about it.
>>
>> Signed-off-by: Rémi Denis-Courmont 
>> Cc: 
>> ---
>>  linux-user/qemu.h | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/linux-user/qemu.h b/linux-user/qemu.h
>> index ef400cb78a..1d222a0cce 100644
>> --- a/linux-user/qemu.h
>> +++ b/linux-user/qemu.h
>> @@ -457,7 +457,8 @@ extern unsigned long guest_stack_size;
>>  
>>  static inline int access_ok(int type, abi_ulong addr, abi_ulong size)
>>  {
>> -return page_check_range((target_ulong)addr, size,
>> +return guest_addr_valid(addr) && guest_addr_valid(addr + size) &&
> 
> I think it should be guest_addr_valid(addr + size - 1).

In fact (len == 0 || guest_addr_valid(addr + size - 1)).

Could you send a new version of your patch?

I've received several mail delivery system errors regarding your email
address r...@remlab.net.

Thanks,
Laurent




[Qemu-devel] [PATCH v4 00/18] qapi: add #if pre-processor conditions to generated code (part 3)

2019-02-14 Thread Markus Armbruster
Marc-André posted a v1 that relies on a QAPI schema language extension
'top-unit' to permit splitting the generated code.  Here is his cover
letter:

The thrid and last part (of "[PATCH v2 00/54] qapi: add #if
pre-processor conditions to generated code") is about adding schema
conditions based on the target.

For now, the qapi code is compiled in common objects (common to all
targets). This makes it impossible to add #if TARGET_ARM for example.

The patch "RFC: qapi: learn to split the schema by 'top-unit'"
proposes to split the schema by "top-unit", so that generated code can
be built either in common objects or per-target. That patch is a bit
rough, I would like to get some feedback about the approach before
trying to improve it. The following patches demonstrate usage of
target-based #if conditions, and getting rid of the
qmp_unregister_command() hack.

We already have a way to split generated code: QAPI modules.  I took
the liberty to rework Marc-André's series to use a target module
instead.  Less code, no change to the QAPI language.

v4:
* PATCH 03,04,16,17: Commit message improvements
* PATCH 07: New
* PATCH 08: Rebased onto PATCH 07, R-by dropped

v3:
* PATCH v2 01+02 have been merged
* PATCH 01-04: New
* PATCH 05: Rebase of PATCH v2 03
* PATCH 06-17: Trivially rebased, R-by and such retained

Marc-André Lureau (9):
  build-sys: move qmp-introspect per target
  qapi: make rtc-reset-reinjection and SEV depend on TARGET_I386
  qapi: make s390 commands depend on TARGET_S390X
  target.json: add a note about query-cpu* not being s390x-specific
  qapi: make query-gic-capabilities depend on TARGET_ARM
  qapi: make query-cpu-model-expansion depend on s390 or x86
  qapi: make query-cpu-definitions depend on specific targets
  qapi: remove qmp_unregister_command()
  qapi: move RTC_CHANGE to the target schema

Markus Armbruster (9):
  qapi: Belatedly document modular code generation
  qapi: Fix up documentation for recent commit a95291007b2
  qapi: Clean up modular built-in code generation a bit
  qapi: Prepare for system modules other than 'builtin'
  qapi: Generate QAPIEvent stuff into separate files
  build: Deal with all of QAPI's .o in qapi/Makefile.objs
  qapi: New module target.json
  Revert "qapi-events: add 'if' condition to implicit event enum"
  qmp: Deprecate query-events in favor of query-qmp-schema

 .gitignore   |   1 +
 Makefile |   2 +-
 Makefile.objs|  17 +-
 Makefile.target  |   1 +
 docs/devel/qapi-code-gen.txt |  82 +++-
 hw/ppc/spapr_rtc.c   |   2 +-
 hw/s390x/s390-skeys.c|   2 +-
 hw/timer/mc146818rtc.c   |   4 +-
 include/qapi/qmp/dispatch.h  |   1 -
 include/sysemu/arch_init.h   |  11 -
 monitor.c|  88 +---
 qapi/Makefile.objs   |  25 ++
 qapi/misc.json   | 485 +
 qapi/qapi-schema.json|   1 +
 qapi/qmp-registry.c  |   8 -
 qapi/target.json | 514 +++
 qemu-deprecated.texi |   5 +
 qmp.c|  26 --
 scripts/qapi/commands.py |   2 +-
 scripts/qapi/common.py   |  55 ++-
 scripts/qapi/events.py   |  38 +-
 scripts/qapi/types.py|   4 +-
 scripts/qapi/visit.py|   4 +-
 stubs/Makefile.objs  |   4 -
 stubs/arch-query-cpu-def.c   |  11 -
 stubs/arch-query-cpu-model-baseline.c|  13 -
 stubs/arch-query-cpu-model-comparison.c  |  13 -
 stubs/arch-query-cpu-model-expansion.c   |  13 -
 stubs/monitor.c  |   2 +-
 target/arm/helper.c  |   3 +-
 target/arm/monitor.c |   2 +-
 target/i386/cpu.c|   7 +-
 target/i386/sev_i386.h   |   2 +-
 target/ppc/translate_init.inc.c  |   3 +-
 target/s390x/cpu_models.c|   9 +-
 tests/qapi-schema/comments.out   |   1 +
 tests/qapi-schema/doc-bad-section.out|   1 +
 tests/qapi-schema/doc-good.out   |   1 +
 tests/qapi-schema/empty.out  |   1 +
 tests/qapi-schema/event-case.out |   1 +
 tests/qapi-schema/ident-with-escape.out  |   1 +
 tests/qapi-schema/include-relpath.out|   1 +
 tests/qapi-schema/include-repetition.out |   1 +
 tests/qapi-schema/include-simple.out |   1 +
 tests/qapi-schema/indented-expr.out  |   1 +
 tests/qapi-schema/qapi-schema-test.out   |   1 +
 tests/test-qmp-event.c   |   1 +
 tests/test-qobject-input-visitor.c   |   1 -
 ui/vnc.c |   3 +-
 49 files changed, 735 insertions(+), 741 deletions(-)
 create mode 100644 qapi

[Qemu-devel] [PATCH v4 16/18] Revert "qapi-events: add 'if' condition to implicit event enum"

2019-02-14 Thread Markus Armbruster
This reverts commit 7bd263490590ee6fcf34ecb6203437e22f6e5a9c.

The commit applied the events' conditions to the members of enum
QAPIEvent.  Awkward, because it renders QAPIEvent unusable in
target-independent code as soon as we make an event target-dependent.
Reverting this has the following effects:

* ui/vnc.c can remain target independent.

* monitor_qapi_event_conf[] doesn't have to muck around with #ifdef.

* query-events again doesn't reflect conditionals.  I'm going to
  deprecate it in favor of query-qmp-schema.

Another option would be to split target-dependent parts off enum
QAPIEvent into a target-dependent enum.  Doesn't seem worthwhile right
now.

Signed-off-by: Markus Armbruster 
Reviewed-by: Marc-André Lureau 
---
 scripts/qapi/events.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py
index 28bbc3745d..2067660be4 100644
--- a/scripts/qapi/events.py
+++ b/scripts/qapi/events.py
@@ -193,7 +193,9 @@ void %(event_emit)s(%(event_enum)s event, QDict *qdict);
 self._genc.add(gen_event_send(name, arg_type, boxed,
   self._event_enum_name,
   self._event_emit_name))
-self._event_enum_members.append(QAPISchemaMember(name, ifcond))
+# Note: we generate the enum member regardless of @ifcond, to
+# keep the enumeration usable in target-independent code.
+self._event_enum_members.append(QAPISchemaMember(name))
 
 
 def gen_events(schema, output_dir, prefix):
-- 
2.17.2




[Qemu-devel] [PATCH v4 11/18] target.json: add a note about query-cpu* not being s390x-specific

2019-02-14 Thread Markus Armbruster
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Acked-by: Cornelia Huck 
Reviewed-by: Markus Armbruster 
Signed-off-by: Markus Armbruster 
---
 qapi/target.json | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/qapi/target.json b/qapi/target.json
index 17671d77c1..010df35ebb 100644
--- a/qapi/target.json
+++ b/qapi/target.json
@@ -275,6 +275,9 @@
 #  an unknown cpu definition name, unknown properties or properties
 #  with wrong types.
 #
+# Note: this command isn't specific to s390x, but is only implemented
+# on this architecture currently.
+#
 # Since: 2.8.0
 ##
 { 'command': 'query-cpu-model-comparison',
@@ -315,6 +318,9 @@
 #  an unknown cpu definition name, unknown properties or properties
 #  with wrong types.
 #
+# Note: this command isn't specific to s390x, but is only implemented
+# on this architecture currently.
+#
 # Since: 2.8.0
 ##
 { 'command': 'query-cpu-model-baseline',
-- 
2.17.2




Re: [Qemu-devel] [PATCH] linux-user: fix recvmsg emulation

2019-02-14 Thread Laurent Vivier
On 12/02/2019 17:34, Andreas Schwab wrote:
> Set msg_flags in the returned struct msghdr.
> 
> Signed-off-by: Andreas Schwab 
> ---
>  linux-user/syscall.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 90bfda3563..b6b566a6fa 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -2797,6 +2797,7 @@ static abi_long do_sendrecvmsg_locked(int fd, struct 
> target_msghdr *msgp,
>  }
>  if (!is_error(ret)) {
>  msgp->msg_namelen = tswap32(msg.msg_namelen);
> +msgp->msg_flags = tswap32(msg.msg_flags);
>  if (msg.msg_name != NULL && msg.msg_name != (void *)-1) {
>  ret = host_to_target_sockaddr(tswapal(msgp->msg_name),
>  msg.msg_name, msg.msg_namelen);
> 

Applied to my linux-user branch.

Thanks,
Laurent



[Qemu-devel] [PATCH v4 02/18] qapi: Fix up documentation for recent commit a95291007b2

2019-02-14 Thread Markus Armbruster
Signed-off-by: Markus Armbruster 
Reviewed-by: Marc-André Lureau 
---
 docs/devel/qapi-code-gen.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt
index b91bde647c..c9ba8ddb2e 100644
--- a/docs/devel/qapi-code-gen.txt
+++ b/docs/devel/qapi-code-gen.txt
@@ -1410,6 +1410,8 @@ Example:
 
 extern const QEnumLookup example_QAPIEvent_lookup;
 
+void example_qapi_event_emit(example_QAPIEvent event, QDict *qdict);
+
 #endif /* EXAMPLE_QAPI_EVENTS_H */
 $ cat qapi-generated/example-qapi-events.c
 [Uninteresting stuff omitted...]
-- 
2.17.2




[Qemu-devel] [PATCH v4 18/18] qapi: move RTC_CHANGE to the target schema

2019-02-14 Thread Markus Armbruster
From: Marc-André Lureau 

A few targets don't emit RTC_CHANGE, we could restrict the event to
the tagets that do emit it.

Note: There is a lot more of events & commands that we could restrict
to capable targets, with the cost of some additional complexity, but
the benefit of added correctness and better introspection.

Signed-off-by: Marc-André Lureau 
Reviewed-by: Markus Armbruster 
Signed-off-by: Markus Armbruster 
---
 hw/ppc/spapr_rtc.c |  2 +-
 hw/timer/mc146818rtc.c |  2 +-
 qapi/misc.json | 23 ---
 qapi/target.json   | 23 +++
 4 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/hw/ppc/spapr_rtc.c b/hw/ppc/spapr_rtc.c
index cd049f389d..eb95a7077d 100644
--- a/hw/ppc/spapr_rtc.c
+++ b/hw/ppc/spapr_rtc.c
@@ -31,7 +31,7 @@
 #include "sysemu/sysemu.h"
 #include "hw/ppc/spapr.h"
 #include "qapi/error.h"
-#include "qapi/qapi-events-misc.h"
+#include "qapi/qapi-events-target.h"
 #include "qemu/cutils.h"
 
 void spapr_rtc_read(sPAPRRTCState *rtc, struct tm *tm, uint32_t *ns)
diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c
index bc1862b6fc..513f105e62 100644
--- a/hw/timer/mc146818rtc.c
+++ b/hw/timer/mc146818rtc.c
@@ -32,7 +32,7 @@
 #include "hw/timer/mc146818rtc.h"
 #include "qapi/error.h"
 #include "qapi/qapi-commands-target.h"
-#include "qapi/qapi-events-misc.h"
+#include "qapi/qapi-events-target.h"
 #include "qapi/visitor.h"
 #include "exec/address-spaces.h"
 
diff --git a/qapi/misc.json b/qapi/misc.json
index 98f59f828a..8b3ca4fdd3 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -2876,29 +2876,6 @@
 { 'event': 'ACPI_DEVICE_OST',
  'data': { 'info': 'ACPIOSTInfo' } }
 
-##
-# @RTC_CHANGE:
-#
-# Emitted when the guest changes the RTC time.
-#
-# @offset: offset between base RTC clock (as specified by -rtc base), and
-#  new RTC clock value. Note that value will be different depending
-#  on clock chosen to drive RTC (specified by -rtc clock).
-#
-# Note: This event is rate-limited.
-#
-# Since: 0.13.0
-#
-# Example:
-#
-# <-   { "event": "RTC_CHANGE",
-#"data": { "offset": 78 },
-#"timestamp": { "seconds": 1267020223, "microseconds": 435656 } }
-#
-##
-{ 'event': 'RTC_CHANGE',
-  'data': { 'offset': 'int' } }
-
 ##
 # @ReplayMode:
 #
diff --git a/qapi/target.json b/qapi/target.json
index 5c41a0aee7..da7b4be51e 100644
--- a/qapi/target.json
+++ b/qapi/target.json
@@ -7,6 +7,29 @@
 
 { 'include': 'misc.json' }
 
+##
+# @RTC_CHANGE:
+#
+# Emitted when the guest changes the RTC time.
+#
+# @offset: offset between base RTC clock (as specified by -rtc base), and
+#  new RTC clock value
+#
+# Note: This event is rate-limited.
+#
+# Since: 0.13.0
+#
+# Example:
+#
+# <-   { "event": "RTC_CHANGE",
+#"data": { "offset": 78 },
+#"timestamp": { "seconds": 1267020223, "microseconds": 435656 } }
+#
+##
+{ 'event': 'RTC_CHANGE',
+  'data': { 'offset': 'int' },
+  'if': 'defined(TARGET_ALPHA) || defined(TARGET_ARM) || defined(TARGET_HPPA) 
|| defined(TARGET_I386) || defined(TARGET_MIPS) || defined(TARGET_MIPS64) || 
defined(TARGET_MOXIE) || defined(TARGET_PPC) || defined(TARGET_PPC64) || 
defined(TARGET_S390X) || defined(TARGET_SH4) || defined(TARGET_SPARC)' }
+
 ##
 # @rtc-reset-reinjection:
 #
-- 
2.17.2




Re: [Qemu-devel] [PATCH v2 2/2] linux-user: Fix ELF_PLATFORM for aarch64_be-linux-user

2019-02-14 Thread Laurent Vivier
On 12/02/2019 08:48, Richard Henderson wrote:
> Signed-off-by: Richard Henderson 
> ---
>  linux-user/elfload.c | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/linux-user/elfload.c b/linux-user/elfload.c
> index d796d51ec6..5aa0628ae9 100644
> --- a/linux-user/elfload.c
> +++ b/linux-user/elfload.c
> @@ -537,7 +537,11 @@ static const char *get_elf_platform(void)
>  
>  #define ELF_ARCHEM_AARCH64
>  #define ELF_CLASS   ELFCLASS64
> -#define ELF_PLATFORM"aarch64"
> +#ifdef TARGET_WORDS_BIGENDIAN
> +# define ELF_PLATFORM"aarch64_be"
> +#else
> +# define ELF_PLATFORM"aarch64"
> +#endif
>  
>  static inline void init_thread(struct target_pt_regs *regs,
> struct image_info *infop)
> 

Applied to my linux-user branch.

Thanks,
Laurent



Re: [Qemu-devel] [PATCH v2 1/2] linux-user: Add ELF_PLATFORM for arm

2019-02-14 Thread Laurent Vivier
On 12/02/2019 08:48, Richard Henderson wrote:
> The 32-bit kernel has strings for v4, v5, v6, v7, v7m.
> The 64-bit kernel, in compat mode, has strings for v8.
> 
> Fixes: https://bugs.launchpad.net/bugs/1813034
> Signed-off-by: Richard Henderson 
> ---
> v2: Include v8.
> ---
>  linux-user/elfload.c | 31 +++
>  1 file changed, 31 insertions(+)

Applied to my linux-user branch.

Thanks,
Laurent




Re: [Qemu-devel] [PATCH v3 0/3] Trivial cleanup in hw/acpi

2019-02-14 Thread Laurent Vivier
On 14/02/2019 09:51, Wei Yang wrote:
> On Thu, Feb 14, 2019 at 09:23:39AM +0100, Laurent Vivier wrote:
>> On 14/02/2019 09:18, Wei Yang wrote:
>>> On Thu, Feb 14, 2019 at 09:10:14AM +0100, Laurent Vivier wrote:
 On 14/02/2019 08:57, Laurent Vivier wrote:
> On 14/02/2019 01:03, Wei Yang wrote:
>> On Wed, Feb 13, 2019 at 02:45:01PM +0100, Laurent Vivier wrote:
>>> On 13/02/2019 09:56, Philippe Mathieu-Daudé wrote:
 Hi Laurent,

 On 2/13/19 9:49 AM, Laurent Vivier wrote:
> On 12/02/2019 06:34, Michael S. Tsirkin wrote:
>> On Tue, Feb 12, 2019 at 01:22:24PM +0800, Wei Yang wrote:
>>> On Wed, Jan 30, 2019 at 08:06:50AM +0800, Wei Yang wrote:
 There are several functions/variable which are not used anymore.

 This serials just remove those without functional change.

 v3: add ack and repost in a new thread
 v2: change commit log from "is now used in no place" to "in not 
 used anymore"
>>>
>>> Michael,
>>>
>>> Looks this serials is not merged yet.
>>>
>>> Is there any problem I need to fix?
>>
>> Yes pls repost with fixed reviewed-by tags.
>
> Or I can take the series through the trivial branch and update 
> manually
> Philippe's lastname?

 I appreciate the help with manual update, however Wei is not the only
 one having this problem (other developpers has non-ASCII in their name,
 and use such tags).
 I'd rather prefer we find a proper configuration setup to help the
 community.
>>>
>>> I'm wondering if it can be a problem with cut'n'paste rather than with
>>> git-sendemail.
>>>
>>> I think the following tags should cover Latin and Chinese characters:
>>>
>>> Content-Type: text/plain; charset=UTF-8
>>> Content-Transfer-Encoding: 8bit
>>>
>>
>> Looks not work.
>>
>> I have tried this and also with 
>>
>> Content-Language: en-US
>
> Could  you send me a gzipped version of the 0001-XXX.patch in attachment
> so I could see the real content before git-send-email?

 OK, I've got it.

 What I see is it is already corrupted, thus the problem is not with
 git-send-email.

 So either it is corrupted by git-format-patch (which is very unlikely,
 we could see that if you push it to a public git repo) or it has been
 corrupted when you have added it to the commit message.

>>>
>>> Hmm... maybe you are right.
>>>
>>> But I found confused how to fix this.
>>>
>>> When I use git commit --amend to fix it, the character looks good in my
>>> editor. I use vim as my git editor.
>>>
>>> But when I use git show, it display an unknown character.
>>>
>>> And if I use git format-patch, the patch file looks good in my vim editor. 
>>> But
>>> corrupted if I use another editor.
>>>
>>> Do you have any idea on this?
>>
>> What is the result of command "locale" in your terminal?
>> How do you copy the characters to vim?
>>
> 
> Hi, Laurent
> 
> I tried to copied the character directly from Philippe's mail.
> 
> This time looks good from my mutt client. Hope it works for you.

Yes, it's fine.

I let Michael to take the series for the pull request.

Thanks,
Laurent



Re: [Qemu-devel] [PATCH v3 0/3] Trivial cleanup in hw/acpi

2019-02-14 Thread Wei Yang
On Thu, Feb 14, 2019 at 09:23:39AM +0100, Laurent Vivier wrote:
>On 14/02/2019 09:18, Wei Yang wrote:
>> On Thu, Feb 14, 2019 at 09:10:14AM +0100, Laurent Vivier wrote:
>>> On 14/02/2019 08:57, Laurent Vivier wrote:
 On 14/02/2019 01:03, Wei Yang wrote:
> On Wed, Feb 13, 2019 at 02:45:01PM +0100, Laurent Vivier wrote:
>> On 13/02/2019 09:56, Philippe Mathieu-Daudé wrote:
>>> Hi Laurent,
>>>
>>> On 2/13/19 9:49 AM, Laurent Vivier wrote:
 On 12/02/2019 06:34, Michael S. Tsirkin wrote:
> On Tue, Feb 12, 2019 at 01:22:24PM +0800, Wei Yang wrote:
>> On Wed, Jan 30, 2019 at 08:06:50AM +0800, Wei Yang wrote:
>>> There are several functions/variable which are not used anymore.
>>>
>>> This serials just remove those without functional change.
>>>
>>> v3: add ack and repost in a new thread
>>> v2: change commit log from "is now used in no place" to "in not 
>>> used anymore"
>>
>> Michael,
>>
>> Looks this serials is not merged yet.
>>
>> Is there any problem I need to fix?
>
> Yes pls repost with fixed reviewed-by tags.

 Or I can take the series through the trivial branch and update manually
 Philippe's lastname?
>>>
>>> I appreciate the help with manual update, however Wei is not the only
>>> one having this problem (other developpers has non-ASCII in their name,
>>> and use such tags).
>>> I'd rather prefer we find a proper configuration setup to help the
>>> community.
>>
>> I'm wondering if it can be a problem with cut'n'paste rather than with
>> git-sendemail.
>>
>> I think the following tags should cover Latin and Chinese characters:
>>
>> Content-Type: text/plain; charset=UTF-8
>> Content-Transfer-Encoding: 8bit
>>
>
> Looks not work.
>
> I have tried this and also with 
>
> Content-Language: en-US

 Could  you send me a gzipped version of the 0001-XXX.patch in attachment
 so I could see the real content before git-send-email?
>>>
>>> OK, I've got it.
>>>
>>> What I see is it is already corrupted, thus the problem is not with
>>> git-send-email.
>>>
>>> So either it is corrupted by git-format-patch (which is very unlikely,
>>> we could see that if you push it to a public git repo) or it has been
>>> corrupted when you have added it to the commit message.
>>>
>> 
>> Hmm... maybe you are right.
>> 
>> But I found confused how to fix this.
>> 
>> When I use git commit --amend to fix it, the character looks good in my
>> editor. I use vim as my git editor.
>> 
>> But when I use git show, it display an unknown character.
>> 
>> And if I use git format-patch, the patch file looks good in my vim editor. 
>> But
>> corrupted if I use another editor.
>> 
>> Do you have any idea on this?
>
>What is the result of command "locale" in your terminal?
>How do you copy the characters to vim?
>

Hi, Laurent

I tried to copied the character directly from Philippe's mail.

This time looks good from my mutt client. Hope it works for you.

Thanks!

>Thanks,
>Laurent

-- 
Wei Yang
Help you, Help me



[Qemu-devel] [Patch v4 3/3] hw/acpi: remove unnecessary variable acpi_table_builtin

2019-02-14 Thread Wei Yang
acpi_table_builtin is now always false, it is not necessary to check it
again.

This patch just removes it.

Signed-off-by: Wei Yang 
Reviewed-by: Philippe Mathieu-Daudé 
Tested-by: Philippe Mathieu-Daudé 
Reviewed-by: Igor Mammedov 
---
 hw/acpi/core.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/hw/acpi/core.c b/hw/acpi/core.c
index e9b1a85e54..f9c96535d1 100644
--- a/hw/acpi/core.c
+++ b/hw/acpi/core.c
@@ -303,8 +303,6 @@ out:
 error_propagate(errp, err);
 }
 
-static bool acpi_table_builtin = false;
-
 unsigned acpi_table_len(void *current)
 {
 struct acpi_table_header *hdr = current - sizeof(hdr->_length);
@@ -320,7 +318,7 @@ void *acpi_table_hdr(void *h)
 
 uint8_t *acpi_table_first(void)
 {
-if (acpi_table_builtin || !acpi_tables) {
+if (!acpi_tables) {
 return NULL;
 }
 return acpi_table_hdr(acpi_tables + ACPI_TABLE_PFX_SIZE);
-- 
2.19.1




[Qemu-devel] [Patch v4 1/3] hw/i386/pc.c: remove unused function pc_acpi_init()

2019-02-14 Thread Wei Yang
Function pc_acpi_init() is not used anymore.

Remove the definition and declaration.

Signed-off-by: Wei Yang 
Reviewed-by: Philippe Mathieu-Daudé 
Tested-by: Philippe Mathieu-Daudé 
Reviewed-by: Igor Mammedov 
Reviewed-by: Thomas Huth 
---
 hw/i386/pc.c | 27 ---
 include/hw/i386/pc.h |  1 -
 2 files changed, 28 deletions(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 5317e08f60..734d3268fa 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1280,33 +1280,6 @@ void pc_pci_as_mapping_init(Object *owner, MemoryRegion 
*system_memory,
 pci_address_space, -1);
 }
 
-void pc_acpi_init(const char *default_dsdt)
-{
-char *filename;
-
-if (acpi_tables != NULL) {
-/* manually set via -acpitable, leave it alone */
-return;
-}
-
-filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, default_dsdt);
-if (filename == NULL) {
-warn_report("failed to find %s", default_dsdt);
-} else {
-QemuOpts *opts = qemu_opts_create(qemu_find_opts("acpi"), NULL, 0,
-  &error_abort);
-Error *err = NULL;
-
-qemu_opt_set(opts, "file", filename, &error_abort);
-
-acpi_table_add_builtin(opts, &err);
-if (err) {
-warn_reportf_err(err, "failed to load %s: ", filename);
-}
-g_free(filename);
-}
-}
-
 void xen_load_linux(PCMachineState *pcms)
 {
 int i;
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 9d29c4b1df..541124ba6d 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -187,7 +187,6 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int 
level);
 
 void pc_cpus_init(PCMachineState *pcms);
 void pc_hot_add_cpu(const int64_t id, Error **errp);
-void pc_acpi_init(const char *default_dsdt);
 
 void pc_guest_info_init(PCMachineState *pcms);
 
-- 
2.19.1




[Qemu-devel] [Patch v4 2/3] hw/acpi: remove unused function acpi_table_add_builtin()

2019-02-14 Thread Wei Yang
Function acpi_table_add_builtin() is not used anymore.

Remove the definition and declaration.

Signed-off-by: Wei Yang 
Reviewed-by: Philippe Mathieu-Daudé 
Tested-by: Philippe Mathieu-Daudé 
Reviewed-by: Igor Mammedov 
---
 hw/acpi/core.c | 6 --
 include/hw/acpi/acpi.h | 1 -
 2 files changed, 7 deletions(-)

diff --git a/hw/acpi/core.c b/hw/acpi/core.c
index d6f0709691..e9b1a85e54 100644
--- a/hw/acpi/core.c
+++ b/hw/acpi/core.c
@@ -305,12 +305,6 @@ out:
 
 static bool acpi_table_builtin = false;
 
-void acpi_table_add_builtin(const QemuOpts *opts, Error **errp)
-{
-acpi_table_builtin = true;
-acpi_table_add(opts, errp);
-}
-
 unsigned acpi_table_len(void *current)
 {
 struct acpi_table_header *hdr = current - sizeof(hdr->_length);
diff --git a/include/hw/acpi/acpi.h b/include/hw/acpi/acpi.h
index c20ace0d0b..4a8bbaf1b5 100644
--- a/include/hw/acpi/acpi.h
+++ b/include/hw/acpi/acpi.h
@@ -190,7 +190,6 @@ uint8_t *acpi_table_first(void);
 uint8_t *acpi_table_next(uint8_t *current);
 unsigned acpi_table_len(void *current);
 void acpi_table_add(const QemuOpts *opts, Error **errp);
-void acpi_table_add_builtin(const QemuOpts *opts, Error **errp);
 
 typedef struct AcpiSlicOem AcpiSlicOem;
 struct AcpiSlicOem {
-- 
2.19.1




[Qemu-devel] [Patch v4 0/3] Trivial cleanup in hw/acpi

2019-02-14 Thread Wei Yang
There are several functions/variable which are not used anymore.

This serials just remove those without functional change.

v4: fix reviewed-by tags
v3: add ack and repost in a new thread
v2: change commit log from "is now used in no place" to "in not used anymore"

Wei Yang (3):
  hw/i386/pc.c: remove unused function pc_acpi_init()
  hw/acpi: remove unused function acpi_table_add_builtin()
  hw/acpi: remove unnecessary variable acpi_table_builtin

 hw/acpi/core.c | 10 +-
 hw/i386/pc.c   | 27 ---
 include/hw/acpi/acpi.h |  1 -
 include/hw/i386/pc.h   |  1 -
 4 files changed, 1 insertion(+), 38 deletions(-)

-- 
2.19.1




Re: [Qemu-devel] [PATCH v3 0/2] hostmem-file: reject invalid pmem file sizes

2019-02-14 Thread Pankaj Gupta



> 
> v3:
>  * Added Patch 1 by Igor [Wei]
>  * Moved pmem size check after mem_path check [Wei]
> 
> Guests started with NVDIMMs larger than the underlying host file produce
> confusing errors inside the guest.  This happens because the guest
> accesses pages beyond the end of the file.
> 
> Check the pmem file size on startup and print a clear error message if
> the size is invalid.
> 
> Igor Mammedov (1):
>   hostmem: simplify ifdef-s in file_backend_memory_alloc()
> 
> Stefan Hajnoczi (1):
>   hostmem-file: reject invalid pmem file sizes
> 
>  include/qemu/osdep.h| 13 ++
>  backends/hostmem-file.c | 32 +
>  util/oslib-posix.c  | 53 +
>  util/oslib-win32.c  |  5 
>  4 files changed, 98 insertions(+), 5 deletions(-)
> 
> --
> 2.20.1

Both the patches look good to me.
Reviewed-by: Pankaj Gupta 



<    1   2   3   4   5   >