Re: [Qemu-devel] [PATCH 1/8] hw/input/Kconfig: Rename the 8042 PS/2 Keyboard Controller

2019-03-16 Thread BALATON Zoltan

On Sun, 17 Mar 2019, Philippe Mathieu-Daudé wrote:

The Intel 8042 chipset also includes some functions unrelated to
the keyboard, such the A20-Gate. Rename it using the chipset name.

Signed-off-by: Philippe Mathieu-Daudé 
---
default-configs/mips-softmmu-common.mak | 2 +-
hw/alpha/Kconfig| 2 +-
hw/i386/Kconfig | 2 +-
hw/input/Kconfig| 2 +-
hw/input/Makefile.objs  | 2 +-
hw/sparc64/Kconfig  | 2 +-
hw/unicore32/Kconfig| 2 +-
7 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/default-configs/mips-softmmu-common.mak 
b/default-configs/mips-softmmu-common.mak
index 0795d522db..bad7ee3360 100644
--- a/default-configs/mips-softmmu-common.mak
+++ b/default-configs/mips-softmmu-common.mak
@@ -13,7 +13,7 @@ CONFIG_SERIAL_ISA=y
CONFIG_PARALLEL=y
CONFIG_I8254=y
CONFIG_PCSPK=y
-CONFIG_PCKBD=y
+CONFIG_I8042=y
CONFIG_FDC=y
CONFIG_ACPI=y
CONFIG_ACPI_X86=y
diff --git a/hw/alpha/Kconfig b/hw/alpha/Kconfig
index 22cefd9577..eb99765123 100644
--- a/hw/alpha/Kconfig
+++ b/hw/alpha/Kconfig
@@ -8,5 +8,5 @@ config DP264
select IDE_CMD646
select MC146818RTC
select PCI
-select PCKBD
+select I8042
select SMC37C669
diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig
index 78fd70396a..7fa5395894 100644
--- a/hw/i386/Kconfig
+++ b/hw/i386/Kconfig
@@ -20,7 +20,7 @@ config PC
select FDC
select I8259
select I8254
-select PCKBD
+select I8042
select PCSPK
select I82374
select I8257
diff --git a/hw/input/Kconfig b/hw/input/Kconfig
index e2e66f0858..14e76c5df4 100644
--- a/hw/input/Kconfig
+++ b/hw/input/Kconfig
@@ -5,7 +5,7 @@ config LM832X
bool
depends on I2C

-config PCKBD
+config I8042
bool
default y
depends on ISA_BUS
diff --git a/hw/input/Makefile.objs b/hw/input/Makefile.objs
index c8b00f71ec..6e4c3389be 100644
--- a/hw/input/Makefile.objs
+++ b/hw/input/Makefile.objs
@@ -1,7 +1,7 @@
common-obj-$(CONFIG_ADB) += adb.o adb-mouse.o adb-kbd.o
common-obj-y += hid.o
common-obj-$(CONFIG_LM832X) += lm832x.o
-common-obj-$(CONFIG_PCKBD) += pckbd.o
+common-obj-$(CONFIG_I8042) += pckbd.o


This makes config option different from the filename so I wonder if it's 
worth changing it or better to keep it same as its file like the others? 
A20 gate is controlled by AT keyboard controller but that's probably a 
hack made by the designers of that machine, it's still used mainly as a 
keyboard controller so just to avoid changes we could live with the PCKBD 
name as well (which might even be simpler to understand for people not 
familiar with chip numbers).


Regards,
BALATON Zoltan


common-obj-$(CONFIG_PL050) += pl050.o
common-obj-y += ps2.o
common-obj-$(CONFIG_STELLARIS_INPUT) += stellaris_input.o
diff --git a/hw/sparc64/Kconfig b/hw/sparc64/Kconfig
index 4a8166ebb7..24ccb11c87 100644
--- a/hw/sparc64/Kconfig
+++ b/hw/sparc64/Kconfig
@@ -10,7 +10,7 @@ config SUN4U
select PCI_SABRE
select IDE_CMD646
select PARALLEL
-select PCKBD
+select I8042
select SIMBA

config NIAGARA
diff --git a/hw/unicore32/Kconfig b/hw/unicore32/Kconfig
index 4443a29dd2..67f4c867c1 100644
--- a/hw/unicore32/Kconfig
+++ b/hw/unicore32/Kconfig
@@ -1,5 +1,5 @@
config PUV3
bool
select ISA_BUS
-select PCKBD
+select I8042
select PTIMER



Re: [Qemu-devel] [PATCH] hw/ppc/prep: Drop useless inclusion of "hw/input/i8042.h"

2019-03-16 Thread David Gibson
On Sat, Mar 16, 2019 at 09:15:28PM +0100, Philippe Mathieu-Daudé wrote:
> In commit 47973a2dbf we split the last generic chipset out of
> the PC board, but missed to remove the i8042 keyboard controller.
> This omission was later fixed in commit 7cb00357c1, but here we
> forgot to remove the "i8042.h" include. Do it now.
> 
> Signed-off-by: Philippe Mathieu-Daudé 

Applied to ppc-for-4.1.

> ---
>  hw/ppc/prep.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
> index 847d320465..b7f459d475 100644
> --- a/hw/ppc/prep.c
> +++ b/hw/ppc/prep.c
> @@ -40,7 +40,6 @@
>  #include "hw/ide.h"
>  #include "hw/loader.h"
>  #include "hw/timer/mc146818rtc.h"
> -#include "hw/input/i8042.h"
>  #include "hw/isa/pc87312.h"
>  #include "hw/net/ne2000-isa.h"
>  #include "sysemu/arch_init.h"

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


signature.asc
Description: PGP signature


Re: [Qemu-devel] [PATCH 3/8] hw/acpi: Simplify the Makefile logic

2019-03-16 Thread Philippe Mathieu-Daudé
On 3/17/19 1:22 AM, Philippe Mathieu-Daudé wrote:
> Now that we use Kconfig, we can simplify this Makefile.
> 
> Suggested-by: Paolo Bonzini 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  hw/acpi/Makefile.objs | 10 ++
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
> index 2d46e3789a..c86edfbed9 100644
> --- a/hw/acpi/Makefile.objs
> +++ b/hw/acpi/Makefile.objs
> @@ -1,4 +1,3 @@
> -ifeq ($(CONFIG_ACPI),y)
>  common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o
>  common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o
>  common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o
> @@ -6,16 +5,11 @@ common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o
>  common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu.o
>  common-obj-$(CONFIG_ACPI_NVDIMM) += nvdimm.o
>  common-obj-$(CONFIG_ACPI_VMGENID) += vmgenid.o
> -common-obj-$(call lnot,$(CONFIG_ACPI_X86)) += acpi-stub.o
> -
>  common-obj-y += acpi_interface.o
>  common-obj-y += bios-linker-loader.o
>  common-obj-y += aml-build.o
>  common-obj-$(CONFIG_TPM) += tpm.o
> -
>  common-obj-$(CONFIG_IPMI) += ipmi.o
> +
>  common-obj-$(call lnot,$(CONFIG_IPMI)) += ipmi-stub.o
> -else
> -common-obj-y += acpi-stub.o
> -endif
> -common-obj-$(CONFIG_ALL) += acpi-stub.o ipmi-stub.o
> +common-obj-$(call lnot,$(CONFIG_ACPI)) += acpi-stub.o

MinGW unhappy here :(

make[1]: *** No rule to make target '../hw/acpi/ipmi-stub.o', needed by
'qemu-system-aarch64w.exe'.  Stop.
make[1]: *** Waiting for unfinished jobs
make: *** [Makefile:449: subdir-aarch64-softmmu] Error 2
make: *** Waiting for unfinished jobs
  GEN x86_64-softmmu/qemu-system-x86_64.exe

https://patchew.org/logs/20190317002259.25994-1-phi...@redhat.com/testing.docker-mingw@fedora/?type=message



Re: [Qemu-devel] [PATCH 0/8] hw/isa: Complete the VT82C686B southbridge Kconfig

2019-03-16 Thread no-reply
Patchew URL: https://patchew.org/QEMU/20190317002259.25994-1-phi...@redhat.com/



Hi,

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

=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-mingw@fedora SHOW_ENV=1 J=14 NETWORK=1
=== TEST SCRIPT END ===




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

Re: [Qemu-devel] [RFC PATCH 8/8] hw/isa/Kconfig: Complete the VT82C686B southbridge config

2019-03-16 Thread Philippe Mathieu-Daudé
On 3/17/19 1:22 AM, Philippe Mathieu-Daudé wrote:
> Complete the VT82C686B southbridge Kconfig entry. For clarity, add
> the SuperIO dependencies in an internal config: VT82C686_SUPERIO.
> 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
> RFC because APIC/IOAPIC are still linked to X86

And because I let 'TODO' and Thomas doesn't like TODO ;)

The patch works without the TODO/FIXME fixed. So Paolo, feel free to
take it if you like it :)

Regards,

Phil.

> ---
>  hw/isa/Kconfig | 26 +++---
>  1 file changed, 23 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/isa/Kconfig b/hw/isa/Kconfig
> index 19101d349f..efe0cdedc7 100644
> --- a/hw/isa/Kconfig
> +++ b/hw/isa/Kconfig
> @@ -30,12 +30,32 @@ config PIIX4
>  # for PIIX4.
>  select ISA_BUS
>  
> +config VT82C686_SUPERIO
> +select SERIAL_ISA
> +select PARALLEL
> +select FDC
> +# TODO AC97
> +select SMBUS
> +select APM
> +select ACPI
> +select ACPI_SMBUS
> +# FIXME APIC/IOAPIC requires X86
> +select APIC if PC
> +select IOAPIC if PC
> +
>  config VT82C686
>  bool
> +select PCI
>  select ISA_BUS
> -select ACPI_SMBUS
> -select SERIAL_ISA
> -select FDC
> +select I8257
> +select I8254
> +select I8259
> +select I8042
> +# TODO DS12885 RTC
> +select USB_UHCI
> +select IDE_PCI
> +select IDE_VIA
> +select VT82C686_SUPERIO
>  
>  config SMC37C669
>  bool
> 



[Qemu-devel] [PATCH 7/8] hw/acpi/Kconfig: Add the ACPI_SMBUS depency to ACPI_PIIX4

2019-03-16 Thread Philippe Mathieu-Daudé
The ACPI_SMBUS feature does not come from the I440FX northbridge
but from the PIIX4 southbridge. Move the dependency to the PIIX4
entry, so hardware that use the PIIX4 but do not use the I440FX
can access the SMBus ACPI feature.

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/acpi/Kconfig | 1 +
 hw/i386/Kconfig | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig
index 10f24f3b41..127b678b48 100644
--- a/hw/acpi/Kconfig
+++ b/hw/acpi/Kconfig
@@ -14,6 +14,7 @@ config ACPI_PIIX4
 select ACPI_NVDIMM
 select ACPI_CPU_HOTPLUG
 select ACPI_MEMORY_HOTPLUG
+select ACPI_SMBUS
 
 config ACPI_ICH9
 bool
diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig
index 64f9957047..6e4757e29a 100644
--- a/hw/i386/Kconfig
+++ b/hw/i386/Kconfig
@@ -51,7 +51,6 @@ config I440FX
 bool
 select PC_PCI
 select PC_ACPI
-select ACPI_SMBUS
 select PCI_PIIX
 select IDE_PIIX
 select DIMM
-- 
2.20.1




[Qemu-devel] [RFC PATCH 8/8] hw/isa/Kconfig: Complete the VT82C686B southbridge config

2019-03-16 Thread Philippe Mathieu-Daudé
Complete the VT82C686B southbridge Kconfig entry. For clarity, add
the SuperIO dependencies in an internal config: VT82C686_SUPERIO.

Signed-off-by: Philippe Mathieu-Daudé 
---
RFC because APIC/IOAPIC are still linked to X86
---
 hw/isa/Kconfig | 26 +++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/hw/isa/Kconfig b/hw/isa/Kconfig
index 19101d349f..efe0cdedc7 100644
--- a/hw/isa/Kconfig
+++ b/hw/isa/Kconfig
@@ -30,12 +30,32 @@ config PIIX4
 # for PIIX4.
 select ISA_BUS
 
+config VT82C686_SUPERIO
+select SERIAL_ISA
+select PARALLEL
+select FDC
+# TODO AC97
+select SMBUS
+select APM
+select ACPI
+select ACPI_SMBUS
+# FIXME APIC/IOAPIC requires X86
+select APIC if PC
+select IOAPIC if PC
+
 config VT82C686
 bool
+select PCI
 select ISA_BUS
-select ACPI_SMBUS
-select SERIAL_ISA
-select FDC
+select I8257
+select I8254
+select I8259
+select I8042
+# TODO DS12885 RTC
+select USB_UHCI
+select IDE_PCI
+select IDE_VIA
+select VT82C686_SUPERIO
 
 config SMC37C669
 bool
-- 
2.20.1




[Qemu-devel] [PATCH 6/8] hw/acpi/Kconfig: Introduce the ACPI_PIIX4 config

2019-03-16 Thread Philippe Mathieu-Daudé
The PIIX4 chipset is a generic southbridge and can be used by
non-X86 hardware. Introduce the ACPI_PIIX4 Kconfig.
Hardware that requires ACPI but doesn't need the PIIX4 chipset
won't compile it.

Signed-off-by: Philippe Mathieu-Daudé 
---
 default-configs/mips-softmmu-common.mak | 2 +-
 hw/acpi/Kconfig | 7 +++
 hw/acpi/Makefile.objs   | 3 ++-
 hw/i386/Kconfig | 2 ++
 4 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/default-configs/mips-softmmu-common.mak 
b/default-configs/mips-softmmu-common.mak
index 6f49a3a8c7..21c6e3cbe3 100644
--- a/default-configs/mips-softmmu-common.mak
+++ b/default-configs/mips-softmmu-common.mak
@@ -16,7 +16,7 @@ CONFIG_PCSPK=y
 CONFIG_I8042=y
 CONFIG_FDC=y
 CONFIG_ACPI=y
-CONFIG_ACPI_X86=y
+CONFIG_ACPI_PIIX4=y
 CONFIG_ACPI_MEMORY_HOTPLUG=y
 CONFIG_ACPI_NVDIMM=y
 CONFIG_ACPI_CPU_HOTPLUG=y
diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig
index b18ddb06da..10f24f3b41 100644
--- a/hw/acpi/Kconfig
+++ b/hw/acpi/Kconfig
@@ -8,6 +8,13 @@ config ACPI_X86
 select ACPI_CPU_HOTPLUG
 select ACPI_MEMORY_HOTPLUG
 
+config ACPI_PIIX4
+bool
+select ACPI
+select ACPI_NVDIMM
+select ACPI_CPU_HOTPLUG
+select ACPI_MEMORY_HOTPLUG
+
 config ACPI_ICH9
 bool
 select ACPI
diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
index dff94d35e7..c5c2c1cf03 100644
--- a/hw/acpi/Makefile.objs
+++ b/hw/acpi/Makefile.objs
@@ -1,4 +1,5 @@
-common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o
+common-obj-$(CONFIG_ACPI) += core.o
+common-obj-$(CONFIG_ACPI_PIIX4) += piix4.o pcihp.o
 common-obj-$(CONFIG_ACPI_ICH9) += ich9.o tco.o
 common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o
 common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o
diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig
index 7fa5395894..64f9957047 100644
--- a/hw/i386/Kconfig
+++ b/hw/i386/Kconfig
@@ -69,6 +69,8 @@ config ISAPC
 # FIXME: it is in the same file as i440fx, and does not compile
 # if separated
 depends on I440FX
+# QEMU isapc weirdness: it uses PIIX3 with ACPI features from PIIX4
+select ACPI_PIIX4
 
 config Q35
 bool
-- 
2.20.1




[Qemu-devel] [PATCH 5/8] hw/acpi/Kconfig: Remove ICH9 dependency on X86

2019-03-16 Thread Philippe Mathieu-Daudé
The ICH9 chipset is a generic southbridge and can be used by
non-X86 hardware. Remove the x86 Kconfig dependency.

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/acpi/Kconfig | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig
index e24c895772..b18ddb06da 100644
--- a/hw/acpi/Kconfig
+++ b/hw/acpi/Kconfig
@@ -10,7 +10,10 @@ config ACPI_X86
 
 config ACPI_ICH9
 bool
-select ACPI_X86
+select ACPI
+select ACPI_NVDIMM
+select ACPI_CPU_HOTPLUG
+select ACPI_MEMORY_HOTPLUG
 
 config ACPI_CPU_HOTPLUG
 bool
-- 
2.20.1




[Qemu-devel] [PATCH 3/8] hw/acpi: Simplify the Makefile logic

2019-03-16 Thread Philippe Mathieu-Daudé
Now that we use Kconfig, we can simplify this Makefile.

Suggested-by: Paolo Bonzini 
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/acpi/Makefile.objs | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
index 2d46e3789a..c86edfbed9 100644
--- a/hw/acpi/Makefile.objs
+++ b/hw/acpi/Makefile.objs
@@ -1,4 +1,3 @@
-ifeq ($(CONFIG_ACPI),y)
 common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o
 common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o
 common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o
@@ -6,16 +5,11 @@ common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o
 common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu.o
 common-obj-$(CONFIG_ACPI_NVDIMM) += nvdimm.o
 common-obj-$(CONFIG_ACPI_VMGENID) += vmgenid.o
-common-obj-$(call lnot,$(CONFIG_ACPI_X86)) += acpi-stub.o
-
 common-obj-y += acpi_interface.o
 common-obj-y += bios-linker-loader.o
 common-obj-y += aml-build.o
 common-obj-$(CONFIG_TPM) += tpm.o
-
 common-obj-$(CONFIG_IPMI) += ipmi.o
+
 common-obj-$(call lnot,$(CONFIG_IPMI)) += ipmi-stub.o
-else
-common-obj-y += acpi-stub.o
-endif
-common-obj-$(CONFIG_ALL) += acpi-stub.o ipmi-stub.o
+common-obj-$(call lnot,$(CONFIG_ACPI)) += acpi-stub.o
-- 
2.20.1




[Qemu-devel] [PATCH 4/8] hw/isa/southbridge: Rename ACPI_X86_ICH to ACPI_ICH9

2019-03-16 Thread Philippe Mathieu-Daudé
The ICH9 chipset is a generic southbridge and can be used by
non-X86 hardware. Rename it to make this more obvious.

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/acpi/Kconfig   | 2 +-
 hw/acpi/Makefile.objs | 2 +-
 hw/i2c/Makefile.objs  | 2 +-
 hw/isa/Kconfig| 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig
index eca3beed75..e24c895772 100644
--- a/hw/acpi/Kconfig
+++ b/hw/acpi/Kconfig
@@ -8,7 +8,7 @@ config ACPI_X86
 select ACPI_CPU_HOTPLUG
 select ACPI_MEMORY_HOTPLUG
 
-config ACPI_X86_ICH
+config ACPI_ICH9
 bool
 select ACPI_X86
 
diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
index c86edfbed9..dff94d35e7 100644
--- a/hw/acpi/Makefile.objs
+++ b/hw/acpi/Makefile.objs
@@ -1,5 +1,5 @@
 common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o
-common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o
+common-obj-$(CONFIG_ACPI_ICH9) += ich9.o tco.o
 common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o
 common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o
 common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu.o
diff --git a/hw/i2c/Makefile.objs b/hw/i2c/Makefile.objs
index a98c786918..b632461513 100644
--- a/hw/i2c/Makefile.objs
+++ b/hw/i2c/Makefile.objs
@@ -3,7 +3,7 @@ common-obj-$(CONFIG_SMBUS) += smbus_slave.o smbus_master.o
 common-obj-$(CONFIG_SMBUS_EEPROM) += smbus_eeprom.o
 common-obj-$(CONFIG_DDC) += i2c-ddc.o
 common-obj-$(CONFIG_VERSATILE_I2C) += versatile_i2c.o
-common-obj-$(CONFIG_ACPI_X86_ICH) += smbus_ich9.o
+common-obj-$(CONFIG_ACPI_ICH9) += smbus_ich9.o
 common-obj-$(CONFIG_ACPI_SMBUS) += pm_smbus.o
 common-obj-$(CONFIG_BITBANG_I2C) += bitbang_i2c.o
 common-obj-$(CONFIG_EXYNOS4) += exynos4210_i2c.o
diff --git a/hw/isa/Kconfig b/hw/isa/Kconfig
index 57e09a0cb8..19101d349f 100644
--- a/hw/isa/Kconfig
+++ b/hw/isa/Kconfig
@@ -50,4 +50,4 @@ config LPC_ICH9
 # for ICH9.
 select ISA_BUS
 select ACPI_SMBUS
-select ACPI_X86_ICH
+select ACPI_ICH9
-- 
2.20.1




[Qemu-devel] [PATCH 2/8] hw/i2c/Kconfig: Add an entry for the SMBus

2019-03-16 Thread Philippe Mathieu-Daudé
The System Management Bus is more or less a derivative of the I2C
bus, thus the Kconfig entry depends of I2C.
Not all boards providing an I2C bus support SMBus.
Use two different Kconfig entries to be able to select I2C without
selecting SMBus.

Signed-off-by: Philippe Mathieu-Daudé 
---
 default-configs/mips-softmmu-common.mak | 1 +
 hw/i2c/Kconfig  | 8 ++--
 hw/i2c/Makefile.objs| 3 ++-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/default-configs/mips-softmmu-common.mak 
b/default-configs/mips-softmmu-common.mak
index bad7ee3360..6f49a3a8c7 100644
--- a/default-configs/mips-softmmu-common.mak
+++ b/default-configs/mips-softmmu-common.mak
@@ -36,6 +36,7 @@ CONFIG_MIPS_ITU=y
 CONFIG_R4K=y
 CONFIG_MALTA=y
 CONFIG_MIPSSIM=y
+CONFIG_SMBUS=y
 CONFIG_ACPI_SMBUS=y
 CONFIG_SMBUS_EEPROM=y
 CONFIG_TEST_DEVICES=y
diff --git a/hw/i2c/Kconfig b/hw/i2c/Kconfig
index 820b24de5b..2f9fc2bedd 100644
--- a/hw/i2c/Kconfig
+++ b/hw/i2c/Kconfig
@@ -1,9 +1,13 @@
 config I2C
 bool
 
+config SMBUS
+bool
+select I2C
+
 config SMBUS_EEPROM
 bool
-depends on I2C
+select SMBUS
 
 config DDC
 bool
@@ -16,7 +20,7 @@ config VERSATILE_I2C
 
 config ACPI_SMBUS
 bool
-select I2C
+select SMBUS
 
 config BITBANG_I2C
 bool
diff --git a/hw/i2c/Makefile.objs b/hw/i2c/Makefile.objs
index 5f76b6a990..a98c786918 100644
--- a/hw/i2c/Makefile.objs
+++ b/hw/i2c/Makefile.objs
@@ -1,4 +1,5 @@
-common-obj-$(CONFIG_I2C) += core.o smbus_slave.o smbus_master.o
+common-obj-$(CONFIG_I2C) += core.o
+common-obj-$(CONFIG_SMBUS) += smbus_slave.o smbus_master.o
 common-obj-$(CONFIG_SMBUS_EEPROM) += smbus_eeprom.o
 common-obj-$(CONFIG_DDC) += i2c-ddc.o
 common-obj-$(CONFIG_VERSATILE_I2C) += versatile_i2c.o
-- 
2.20.1




[Qemu-devel] [PATCH 0/8] hw/isa: Complete the VT82C686B southbridge Kconfig

2019-03-16 Thread Philippe Mathieu-Daudé
Hi,

This series is extracted from a bigger Kconfig southbridge cleanup
previous to introduce the MIPS Kconfig.

I send it because Zoltan is having issues building the VT82C686
out of x86:
https://lists.gnu.org/archive/html/qemu-devel/2019-03/msg03067.html

Regards,

Phil.

Philippe Mathieu-Daudé (8):
  hw/input/Kconfig: Rename the 8042 PS/2 Keyboard Controller
  hw/i2c/Kconfig: Add an entry for the SMBus
  hw/acpi: Simplify the Makefile logic
  hw/isa/southbridge: Rename ACPI_X86_ICH to ACPI_ICH9
  hw/acpi/Kconfig: Remove ICH9 dependency on X86
  hw/acpi/Kconfig: Introduce the ACPI_PIIX4 config
  hw/acpi/Kconfig: Add the ACPI_SMBUS depency to ACPI_PIIX4
  RFC hw/isa/Kconfig: Complete the VT82C686B southbridge config

 default-configs/mips-softmmu-common.mak |  5 +++--
 hw/acpi/Kconfig | 15 +++--
 hw/acpi/Makefile.objs   | 15 +
 hw/alpha/Kconfig|  2 +-
 hw/i2c/Kconfig  |  8 +--
 hw/i2c/Makefile.objs|  5 +++--
 hw/i386/Kconfig |  5 +++--
 hw/input/Kconfig|  2 +-
 hw/input/Makefile.objs  |  2 +-
 hw/isa/Kconfig  | 28 +
 hw/sparc64/Kconfig  |  2 +-
 hw/unicore32/Kconfig|  2 +-
 12 files changed, 62 insertions(+), 29 deletions(-)

-- 
2.20.1




[Qemu-devel] [PATCH 1/8] hw/input/Kconfig: Rename the 8042 PS/2 Keyboard Controller

2019-03-16 Thread Philippe Mathieu-Daudé
The Intel 8042 chipset also includes some functions unrelated to
the keyboard, such the A20-Gate. Rename it using the chipset name.

Signed-off-by: Philippe Mathieu-Daudé 
---
 default-configs/mips-softmmu-common.mak | 2 +-
 hw/alpha/Kconfig| 2 +-
 hw/i386/Kconfig | 2 +-
 hw/input/Kconfig| 2 +-
 hw/input/Makefile.objs  | 2 +-
 hw/sparc64/Kconfig  | 2 +-
 hw/unicore32/Kconfig| 2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/default-configs/mips-softmmu-common.mak 
b/default-configs/mips-softmmu-common.mak
index 0795d522db..bad7ee3360 100644
--- a/default-configs/mips-softmmu-common.mak
+++ b/default-configs/mips-softmmu-common.mak
@@ -13,7 +13,7 @@ CONFIG_SERIAL_ISA=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
 CONFIG_PCSPK=y
-CONFIG_PCKBD=y
+CONFIG_I8042=y
 CONFIG_FDC=y
 CONFIG_ACPI=y
 CONFIG_ACPI_X86=y
diff --git a/hw/alpha/Kconfig b/hw/alpha/Kconfig
index 22cefd9577..eb99765123 100644
--- a/hw/alpha/Kconfig
+++ b/hw/alpha/Kconfig
@@ -8,5 +8,5 @@ config DP264
 select IDE_CMD646
 select MC146818RTC
 select PCI
-select PCKBD
+select I8042
 select SMC37C669
diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig
index 78fd70396a..7fa5395894 100644
--- a/hw/i386/Kconfig
+++ b/hw/i386/Kconfig
@@ -20,7 +20,7 @@ config PC
 select FDC
 select I8259
 select I8254
-select PCKBD
+select I8042
 select PCSPK
 select I82374
 select I8257
diff --git a/hw/input/Kconfig b/hw/input/Kconfig
index e2e66f0858..14e76c5df4 100644
--- a/hw/input/Kconfig
+++ b/hw/input/Kconfig
@@ -5,7 +5,7 @@ config LM832X
 bool
 depends on I2C
 
-config PCKBD
+config I8042
 bool
 default y
 depends on ISA_BUS
diff --git a/hw/input/Makefile.objs b/hw/input/Makefile.objs
index c8b00f71ec..6e4c3389be 100644
--- a/hw/input/Makefile.objs
+++ b/hw/input/Makefile.objs
@@ -1,7 +1,7 @@
 common-obj-$(CONFIG_ADB) += adb.o adb-mouse.o adb-kbd.o
 common-obj-y += hid.o
 common-obj-$(CONFIG_LM832X) += lm832x.o
-common-obj-$(CONFIG_PCKBD) += pckbd.o
+common-obj-$(CONFIG_I8042) += pckbd.o
 common-obj-$(CONFIG_PL050) += pl050.o
 common-obj-y += ps2.o
 common-obj-$(CONFIG_STELLARIS_INPUT) += stellaris_input.o
diff --git a/hw/sparc64/Kconfig b/hw/sparc64/Kconfig
index 4a8166ebb7..24ccb11c87 100644
--- a/hw/sparc64/Kconfig
+++ b/hw/sparc64/Kconfig
@@ -10,7 +10,7 @@ config SUN4U
 select PCI_SABRE
 select IDE_CMD646
 select PARALLEL
-select PCKBD
+select I8042
 select SIMBA
 
 config NIAGARA
diff --git a/hw/unicore32/Kconfig b/hw/unicore32/Kconfig
index 4443a29dd2..67f4c867c1 100644
--- a/hw/unicore32/Kconfig
+++ b/hw/unicore32/Kconfig
@@ -1,5 +1,5 @@
 config PUV3
 bool
 select ISA_BUS
-select PCKBD
+select I8042
 select PTIMER
-- 
2.20.1




[Qemu-devel] [PATCH for-4.1 0/2] hw/alpha: Add the CY82C693UB southbridge in Kconfig

2019-03-16 Thread Philippe Mathieu-Daudé
Explicit the CY82C693UB southbridge used by the 264DP.

Philippe Mathieu-Daudé (2):
  hw/isa/southbridge: Add the Cypress 82C693UB chipset
  hw/alpha/Kconfig: The 264DP machine use a CY82C693UB southbridge

 hw/alpha/Kconfig |  5 +
 hw/isa/Kconfig   | 13 +
 2 files changed, 14 insertions(+), 4 deletions(-)

-- 
2.20.1




[Qemu-devel] [PATCH for-4.1 2/2] hw/alpha/Kconfig: The 264DP machine use a CY82C693UB southbridge

2019-03-16 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/alpha/Kconfig | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/hw/alpha/Kconfig b/hw/alpha/Kconfig
index 22cefd9577..437606fd22 100644
--- a/hw/alpha/Kconfig
+++ b/hw/alpha/Kconfig
@@ -1,12 +1,9 @@
 config DP264
 bool
+select CY82C693UB
 imply PCI_DEVICES
 imply TEST_DEVICES
 select I82374
-select I8254
-select I8259
 select IDE_CMD646
-select MC146818RTC
 select PCI
-select PCKBD
 select SMC37C669
-- 
2.20.1




[Qemu-devel] [PATCH for-4.1 1/2] hw/isa/southbridge: Add the Cypress 82C693UB chipset

2019-03-16 Thread Philippe Mathieu-Daudé
The CY82C693UB Peripheral Controller contains the following functional blocks:
•  PCI Interface
•  ISA Interface
•  Reset Logic
•  Keyboard Controller
•  Power Management Logic
•  AT Refresh Logic
•  Pre-Read/Post-Write Buffers
•  BIOS ROM Control
•  Timer/Counter Logic
•  DMA Controllers
•  Dual-Channel Enhanced IDE Controller
•  Real-Time-Clock with 32-kHz Oscillator
•  Interrupt Controllers
•  USB Host Controller

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/isa/Kconfig | 13 +
 1 file changed, 13 insertions(+)

diff --git a/hw/isa/Kconfig b/hw/isa/Kconfig
index 57e09a0cb8..4988f7671a 100644
--- a/hw/isa/Kconfig
+++ b/hw/isa/Kconfig
@@ -37,6 +37,19 @@ config VT82C686
 select SERIAL_ISA
 select FDC
 
+config CY82C693UB
+bool
+select PCI
+select ISA_BUS
+select PCKBD
+select APM
+select I8254
+select I8257
+select IDE_PCI
+select MC146818RTC
+select I8259
+select USB_OHCI
+
 config SMC37C669
 bool
 select ISA_BUS
-- 
2.20.1




[Qemu-devel] [PATCH] nrf51_gpio: reflect pull-up/pull-down to IRQs

2019-03-16 Thread Paolo Bonzini
Some drivers do I2C bitbanging by keeping the output to 0 and flipping
the GPIO direction between input and output (see for example in Linux
gpio_set_open_drain_value_commit, in drivers/gpio/gpiolib.c).
When the GPIO is set to input, the pull-up resistor brings the output
to 1, while when the GPIO is set to output, the output driver brings
the output to 0.

Implement this for the nRF51 GPIO device model.  First, if both input and
output are floating, and there is a pull-up or pull-down resistor
configured, do not just set s->in, but also make any devices listening
on the output qemu_irq receive that value.  Second, if the pin is
driven both internally (output pin) and externally you don't get a
short circuit if the external drive goes through a resistor.

Signed-off-by: Paolo Bonzini 
---
 hw/gpio/nrf51_gpio.c | 38 +++---
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/hw/gpio/nrf51_gpio.c b/hw/gpio/nrf51_gpio.c
index 86e047d649..ffe28a6390 100644
--- a/hw/gpio/nrf51_gpio.c
+++ b/hw/gpio/nrf51_gpio.c
@@ -43,6 +43,17 @@ static bool is_connected(uint32_t config, uint32_t level)
 return state;
 }
 
+static int pull_value(uint32_t config)
+{
+int pull = extract32(config, 2, 2);
+if (pull == NRF51_GPIO_PULLDOWN) {
+return 0;
+} else if (pull == NRF51_GPIO_PULLUP) {
+return 1;
+}
+return -1;
+}
+
 static void update_output_irq(NRF51GPIOState *s, size_t i,
   bool connected, bool level)
 {
@@ -61,34 +72,31 @@ static void update_output_irq(NRF51GPIOState *s, size_t i,
 
 static void update_state(NRF51GPIOState *s)
 {
-uint32_t pull;
+int pull;
 size_t i;
 bool connected_out, dir, connected_in, out, input;
 
 for (i = 0; i < NRF51_GPIO_PINS; i++) {
-pull = extract32(s->cnf[i], 2, 2);
+pull = pull_value(s->cnf[i]);
 dir = extract32(s->cnf[i], 0, 1);
 connected_in = extract32(s->in_mask, i, 1);
 out = extract32(s->out, i, 1);
 input = !extract32(s->cnf[i], 1, 1);
 connected_out = is_connected(s->cnf[i], out) && dir;
 
-update_output_irq(s, i, connected_out, out);
-
 /* Pin both driven externally and internally */
-if (connected_out && connected_in) {
+if (connected_out && connected_in && input && pull == -1) {
 qemu_log_mask(LOG_GUEST_ERROR, "GPIO pin %zu short circuited\n", 
i);
 }
 
-/*
- * Input buffer disconnected from internal/external drives, so
- * pull-up/pull-down becomes relevant
- */
-if (!input || (input && !connected_in && !connected_out)) {
-if (pull == NRF51_GPIO_PULLDOWN) {
-s->in = deposit32(s->in, i, 1, 0);
-} else if (pull == NRF51_GPIO_PULLUP) {
-s->in = deposit32(s->in, i, 1, 1);
+if (pull >= 0) {
+if (!input) {
+/* Input buffer disconnected from external drives */
+s->in = deposit32(s->in, i, 1, pull);
+} else if (!connected_in && !connected_out) {
+/* Floating: pull-up/pull-down is visible on the bus */
+connected_out = true;
+out = pull;
 }
 }
 
@@ -96,8 +104,8 @@ static void update_state(NRF51GPIOState *s)
 if (connected_out && !connected_in && input) {
 s->in = deposit32(s->in, i, 1, out);
 }
+update_output_irq(s, i, connected_out, out);
 }
-
 }
 
 /*
-- 
2.20.1




Re: [Qemu-devel] [PATCH 13/14] hw/hppa/Kconfig: Dino board requires e1000 network card

2019-03-16 Thread Philippe Mathieu-Daudé
On 3/16/19 10:50 PM, Paolo Bonzini wrote:
>> This fixes when configuring with --without-default-devices:
>>
>>   $ qemu-system-hppa
>>   qemu-system-hppa: Unsupported NIC model: e1000
> 
> This is intended.  --without-default-devices does not guarantee that you can 
> start
> the board except with --nodefaults.

Ah! Now I get it...

Thanks,

Phil.



[Qemu-devel] [PATCH v2 5/5] hw/sparc/Kconfig: SPARCstation machine requires the TCX display

2019-03-16 Thread Philippe Mathieu-Daudé
This is the default display device used in sun4m_hw_init():

/* If no display specified, default to TCX */

This fixes when configuring with --without-default-devices:

  $ sparc-softmmu/qemu-system-sparc --nodefaults
  qemu-system-sparc: Unknown device 'SUNW,tcx' for default sysbus
  Aborted (core dumped)

  (gdb) bt
  #0  0x7fc78d19353f in __GI_raise (sig=sig@entry=6) at 
../sysdeps/unix/sysv/linux/raise.c:50
  #1  0x7fc78d17d895 in __GI_abort () at abort.c:79
  #2  0x560beaf637f3 in qdev_create (bus=bus@entry=0x0, 
name=name@entry=0x560beb1be36b "SUNW,tcx") at hw/core/qdev.c:131
  #3  0x560beaf1392d in tcx_init (vram_size=1048576, width=1024, 
height=768, depth=8, irq=0x560bed1a0230, addr=1342177280) at 
hw/sparc/sun4m.c:477
  #4  0x560beaf1392d in sun4m_hw_init (hwdef=0x560beb1be780 , 
machine=0x560becf65f00) at hw/sparc/sun4m.c:943
  #5  0x560beaf6b15b in machine_run_board_init (machine=0x560becf65f00) at 
hw/core/machine.c:1030

Fixes: 8c75eec06d4
Signed-off-by: Philippe Mathieu-Daudé 
---
 default-configs/sparc-softmmu.mak | 1 -
 hw/sparc/Kconfig  | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/default-configs/sparc-softmmu.mak 
b/default-configs/sparc-softmmu.mak
index ee85218115..56509bf263 100644
--- a/default-configs/sparc-softmmu.mak
+++ b/default-configs/sparc-softmmu.mak
@@ -2,7 +2,6 @@
 
 # Uncomment the following lines to disable these optional devices:
 #
-#CONFIG_TCX=n
 #CONFIG_CG3=n
 
 # Boards:
diff --git a/hw/sparc/Kconfig b/hw/sparc/Kconfig
index 2a83a8010e..5383dbd910 100644
--- a/hw/sparc/Kconfig
+++ b/hw/sparc/Kconfig
@@ -1,6 +1,6 @@
 config SUN4M
 bool
-imply TCX
+select TCX
 imply CG3
 select CS4231
 select ECCMEMCTL
-- 
2.20.1




[Qemu-devel] [PATCH v2 3/5] hw/isa/Kconfig: i82378 SuperIO requires PC speaker device

2019-03-16 Thread Philippe Mathieu-Daudé
This fixes when configuring with --without-default-devices:

  $ qemu-system-ppc -M prep --nodefaults
  qemu-system-ppc: Machine type 'prep' is deprecated: use 40p machine type 
instead
  qemu-system-ppc: Unknown device 'isa-pcspk' for bus 'ISA'
  Aborted (core dumped)

  (gdb) bt
  #1  0x75a11895 in __GI_abort () at abort.c:79
  #2  0x55845db3 in qdev_create (bus=0x5641e360, 
name=name@entry=0x55b1f338 "isa-pcspk") at hw/core/qdev.c:131
  #3  0x5586b03e in isa_create (bus=bus@entry=0x5641e360, 
name=name@entry=0x55b1f338 "isa-pcspk") at hw/isa/isa-bus.c:162
  #4  0x5586bf7b in pcspk_init (pit=0x561696b0, bus=0x5641e360) 
at include/hw/audio/pcspk.h:38
  #5  0x5586bf7b in i82378_realize (pci=, 
errp=0x7fffc960) at hw/isa/i82378.c:104
  #6  0x5587e288 in pci_qdev_realize (qdev=0x5641be60, 
errp=) at hw/pci/pci.c:2076
  #7  0x55846fb4 in device_set_realized (obj=, 
value=, errp=0x7fffcaf0) at hw/core/qdev.c:834
  #8  0x559273f7 in property_set_bool (obj=0x5641be60, v=, name=, opaque=0x563df1c0, errp=0x7fffcaf0) at 
qom/object.c:2074
  #9  0x5592ba1f in object_property_set_qobject 
(obj=obj@entry=0x5641be60, value=value@entry=0x5641d2b0, 
name=name@entry=0x55b17175 "realized", errp=errp@entry=0x7fffcaf0) at 
qom/qom-qobject.c:27
  #10 0x55929355 in object_property_set_bool (obj=0x5641be60, 
value=, name=0x55b17175 "realized", errp=0x7fffcaf0) at 
qom/object.c:1332
  #11 0x55845f42 in qdev_init_nofail (dev=dev@entry=0x5641be60) at 
hw/core/qdev.c:321
  #12 0x5587ce06 in pci_create_simple_multifunction 
(name=name@entry=0x55b1f346 "i82378", multifunction=false, 
devfn=devfn@entry=8, bus=bus@entry=0x5628cfe8) at hw/pci/pci.c:2115
  #13 0x5587ce06 in pci_create_simple (bus=bus@entry=0x5628cfe8, 
devfn=devfn@entry=8, name=name@entry=0x55b1f346 "i82378") at 
hw/pci/pci.c:2126
  #14 0x5575e62c in ppc_prep_init (machine=0x5609af00) at 
hw/ppc/prep.c:516
  #15 0x5584d57b in machine_run_board_init (machine=0x5609af00) at 
hw/core/machine.c:1030

Fixes: dd0ff8191ab
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/isa/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/isa/Kconfig b/hw/isa/Kconfig
index 1bb5ccdba7..b40075df89 100644
--- a/hw/isa/Kconfig
+++ b/hw/isa/Kconfig
@@ -11,6 +11,7 @@ config I82378
 select I8254
 select I82374
 select MC146818RTC
+select PCSPK
 
 config PC87312
 bool
-- 
2.20.1




[Qemu-devel] [PATCH v2 1/5] hw/isa/Kconfig: PIIX4 southbridge requires USB UHCI

2019-03-16 Thread Philippe Mathieu-Daudé
This fixes when configuring with --without-default-devices:

  $ qemu-system-mips64 -M malta --nodefaults -bios /dev/null
  qemu-system-mips64: Unknown device 'piix4-usb-uhci' for bus 'PCI'
  Aborted (core dumped)

  (gdb) bt
  #0  0x75a4353f in __GI_raise (sig=sig@entry=6) at 
../sysdeps/unix/sysv/linux/raise.c:50
  #1  0x75a2d895 in __GI_abort () at abort.c:79
  #2  0x558745c3 in qdev_create (bus=bus@entry=0x56336260, 
name=name@entry=0x55b13a4d "piix4-usb-uhci") at hw/core/qdev.c:131
  #3  0x558cb3e1 in pci_create_multifunction 
(bus=bus@entry=0x56336260, devfn=devfn@entry=82, 
multifunction=multifunction@entry=false, name=name@entry=0x55b13a4d 
"piix4-usb-uhci") at hw/pci/pci.c:2104
  #4  0x558cb88b in pci_create_simple_multifunction 
(name=name@entry=0x55b13a4d "piix4-usb-uhci", multifunction=false, 
devfn=devfn@entry=82, bus=bus@entry=0x56336260) at hw/pci/pci.c:2126
  #5  0x558cb88b in pci_create_simple (bus=bus@entry=0x56336260, 
devfn=devfn@entry=82, name=name@entry=0x55b13a4d "piix4-usb-uhci") at 
hw/pci/pci.c:2126
  #6  0x5575ea38 in mips_malta_init (machine=0x55ffe430) at 
hw/mips/mips_malta.c:1392
  #7  0x5587bf2b in machine_run_board_init (machine=0x55ffe430) at 
hw/core/machine.c:1030

Fixes: 7c28b925b7e
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/isa/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/isa/Kconfig b/hw/isa/Kconfig
index 57e09a0cb8..c942b47d03 100644
--- a/hw/isa/Kconfig
+++ b/hw/isa/Kconfig
@@ -29,6 +29,7 @@ config PIIX4
 # For historical reasons, SuperIO devices are created in the board
 # for PIIX4.
 select ISA_BUS
+select USB_UHCI
 
 config VT82C686
 bool
-- 
2.20.1




[Qemu-devel] [PATCH v2 4/5] hw/mips/Kconfig: Fulong 2e board requires ati-vga display device

2019-03-16 Thread Philippe Mathieu-Daudé
This fixes when configuring with --without-default-devices:

  $ qemu-system-mips64el -M fulong2e --nodefaults -bios /dev/null
  qemu-system-mips64el: Unknown device 'ati-vga' for bus 'PCI'
  Aborted (core dumped)

  (gdb) bt
  #1  0x75a11895 in __GI_abort () at abort.c:79
  #2  0x558768d3 in qdev_create (bus=bus@entry=0x562664b0, 
name=name@entry=0x55b24efb "ati-vga") at hw/core/qdev.c:131
  #3  0x558d15e1 in pci_create_multifunction 
(bus=bus@entry=0x562664b0, devfn=devfn@entry=-1, 
multifunction=multifunction@entry=false, name=name@entry=0x55b24efb 
"ati-vga") at hw/pci/pci.c:2104
  #4  0x558d1a7a in pci_create (bus=bus@entry=0x562664b0, 
devfn=devfn@entry=-1, name=name@entry=0x55b24efb "ati-vga") at 
hw/pci/pci.c:2121
  #5  0x55763081 in mips_fulong2e_init (machine=) at 
hw/mips/mips_fulong2e.c:352
  #6  0x5587e23b in machine_run_board_init (machine=0x560b2000) at 
hw/core/machine.c:1030

Fixes: 862b4a291dc
Signed-off-by: Philippe Mathieu-Daudé 
---
 default-configs/mips64el-softmmu.mak | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/default-configs/mips64el-softmmu.mak 
b/default-configs/mips64el-softmmu.mak
index 8b255efc54..a67c9517a2 100644
--- a/default-configs/mips64el-softmmu.mak
+++ b/default-configs/mips64el-softmmu.mak
@@ -6,6 +6,8 @@ CONFIG_RC4030=y
 CONFIG_DP8393X=y
 CONFIG_DS1225Y=y
 CONFIG_FULONG=y
+CONFIG_ATI_VGA=y
+CONFIG_RTL8139_PCI=y
 CONFIG_JAZZ=y
 CONFIG_G364FB=y
 CONFIG_JAZZ_LED=y
-- 
2.20.1




[Qemu-devel] [PATCH v2 0/5] hw/Kconfig: Fixes when running ./configure --without-default-devices

2019-03-16 Thread Philippe Mathieu-Daudé
Hi,

This series contains Kconfig fixes to be able to run binaries
built using: './configure --without-default-devices' when using
the --nodefault option.

v2: Removed machines that run with --nodefault (Paolo)
v1: https://lists.gnu.org/archive/html/qemu-devel/2019-03/msg05366.html

Regards,

Phil.

Philippe Mathieu-Daudé (5):
  hw/isa/Kconfig: PIIX4 southbridge requires USB UHCI
  hw/isa/Kconfig: VT82C686 southbridge requires USB UHCI
  hw/isa/Kconfig: i82378 SuperIO requires PC speaker device
  hw/mips/Kconfig: Fulong 2e board requires ati-vga display device
  hw/sparc/Kconfig: SPARCstation machine requires the TCX display

 default-configs/mips64el-softmmu.mak | 2 ++
 default-configs/sparc-softmmu.mak| 1 -
 hw/isa/Kconfig   | 3 +++
 hw/sparc/Kconfig | 2 +-
 4 files changed, 6 insertions(+), 2 deletions(-)

-- 
2.20.1




[Qemu-devel] [PATCH v2 2/5] hw/isa/Kconfig: VT82C686 southbridge requires USB UHCI

2019-03-16 Thread Philippe Mathieu-Daudé
This fixes when configuring with --without-default-devices:

  $ qemu-system-mips64 -M malta --nodefaults -bios /dev/null
  qemu-system-mips64el: Unknown device 'vt82c686b-usb-uhci' for bus 'PCI'
  Aborted (core dumped)

  (gdb) bt
  #1  0x75a2d895 in __GI_abort () at abort.c:79
  #2  0x558745c3 in qdev_create (bus=bus@entry=0x5623d160, 
name=name@entry=0x55b13ee8 "vt82c686b-usb-uhci") at hw/core/qdev.c:131
  #3  0x558cb3e1 in pci_create_multifunction 
(bus=bus@entry=0x5623d160, devfn=devfn@entry=42, 
multifunction=multifunction@entry=false, name=name@entry=0x55b13ee8 
"vt82c686b-usb-uhci") at hw/pci/pci.c:2104
  #4  0x558cb88b in pci_create_simple_multifunction 
(name=name@entry=0x55b13ee8 "vt82c686b-usb-uhci", multifunction=false, 
devfn=devfn@entry=42, bus=bus@entry=0x5623d160) at hw/pci/pci.c:2126
  #5  0x558cb88b in pci_create_simple (bus=bus@entry=0x5623d160, 
devfn=devfn@entry=42, name=name@entry=0x55b13ee8 "vt82c686b-usb-uhci") at 
hw/pci/pci.c:2126
  #6  0x55760d18 in vt82c686b_southbridge_init (slot=5, 
p_isa_bus=, i2c_bus=, intc=, pci_bus=0x5623d160) at hw/mips/mips_fulong2e.c:243
  #7  0x55760d18 in mips_fulong2e_init (machine=) at 
hw/mips/mips_fulong2e.c:348
  #8  0x5587bf2b in machine_run_board_init (machine=0x55ffe430) at 
hw/core/machine.c:1030

Fixes: 7c28b925b7e
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/isa/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/isa/Kconfig b/hw/isa/Kconfig
index c942b47d03..1bb5ccdba7 100644
--- a/hw/isa/Kconfig
+++ b/hw/isa/Kconfig
@@ -35,6 +35,7 @@ config VT82C686
 bool
 select ISA_BUS
 select ACPI_SMBUS
+select USB_UHCI
 select SERIAL_ISA
 select FDC
 
-- 
2.20.1




[Qemu-devel] [PULL 00/12] EDK2 Firmware roms

2019-03-16 Thread Philippe Mathieu-Daudé
The following changes since commit 8b088d3f8ab5642020d28fa0c2a8d938bc5f3592:

  Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20190315' 
into staging (2019-03-15 11:39:42 +)

are available in the Git repository at:

  https://github.com/philmd/qemu.git tags/edk2_build-pull-request

for you to fetch changes up to e487994c19ddca0e6340f72ddafc5b410877bbed:

  MAINTAINERS: add the "EDK2 Firmware" subsystem (2019-03-16 16:09:29 +0100)



Advance the roms/edk2 submodule to the "edk2-stable201903" release,
build and capture platform firmware binaries from that release.



Laszlo Ersek (12):
  roms: lift "edk2-funcs.sh" from "tests/uefi-test-tools/build.sh"
  roms/edk2-funcs.sh: require gcc-4.8+ for building i386 and x86_64
  tests/uefi-test-tools/build.sh: work around TianoCore#1607
  roms/edk2: advance to tag edk2-stable201903
  roms/edk2-funcs.sh: add the qemu_edk2_get_thread_count() function
  roms/Makefile: replace the $(EFIROM) target with "edk2-basetools"
  roms: build edk2 firmware binaries and variable store templates
  pc-bios: add edk2 firmware binaries and variable store templates
  pc-bios: document the edk2 firmware images; add firmware descriptors
  tests: add missing dependency to build QTEST_QEMU_BINARY, round 2
  Makefile: install the edk2 firmware images and their descriptors
  MAINTAINERS: add the "EDK2 Firmware" subsystem

 .gitignore|   1 +
 MAINTAINERS   |  12 +
 Makefile  |  29 +-
 configure |   1 +
 pc-bios/README|  11 +
 pc-bios/descriptors/50-edk2-i386-secure.json  |  34 +++
 .../descriptors/50-edk2-x86_64-secure.json|  35 +++
 pc-bios/descriptors/60-edk2-aarch64.json  |  31 +++
 pc-bios/descriptors/60-edk2-arm.json  |  31 +++
 pc-bios/descriptors/60-edk2-i386.json |  33 +++
 pc-bios/descriptors/60-edk2-x86_64.json   |  34 +++
 pc-bios/edk2-aarch64-code.fd.xz   | Bin 0 -> 1146804 bytes
 pc-bios/edk2-arm-code.fd.xz   | Bin 0 -> 1147852 bytes
 pc-bios/edk2-arm-vars.fd.xz   | Bin 0 -> 10008 bytes
 pc-bios/edk2-i386-code.fd.xz  | Bin 0 -> 1674764 bytes
 pc-bios/edk2-i386-secure-code.fd.xz   | Bin 0 -> 1870024 bytes
 pc-bios/edk2-i386-vars.fd.xz  | Bin 0 -> 320 bytes
 pc-bios/edk2-licenses.txt | 208 ++
 pc-bios/edk2-x86_64-code.fd.xz| Bin 0 -> 1655276 bytes
 pc-bios/edk2-x86_64-secure-code.fd.xz | Bin 0 -> 1889024 bytes
 roms/Makefile |   9 +-
 roms/Makefile.edk2| 148 ++
 roms/edk2 |   2 +-
 roms/edk2-build.sh|  55 
 roms/edk2-funcs.sh| 253 ++
 tests/Makefile.include|   2 +-
 tests/uefi-test-tools/build.sh| 100 +--
 27 files changed, 933 insertions(+), 96 deletions(-)
 create mode 100644 pc-bios/descriptors/50-edk2-i386-secure.json
 create mode 100644 pc-bios/descriptors/50-edk2-x86_64-secure.json
 create mode 100644 pc-bios/descriptors/60-edk2-aarch64.json
 create mode 100644 pc-bios/descriptors/60-edk2-arm.json
 create mode 100644 pc-bios/descriptors/60-edk2-i386.json
 create mode 100644 pc-bios/descriptors/60-edk2-x86_64.json
 create mode 100644 pc-bios/edk2-aarch64-code.fd.xz
 create mode 100644 pc-bios/edk2-arm-code.fd.xz
 create mode 100644 pc-bios/edk2-arm-vars.fd.xz
 create mode 100644 pc-bios/edk2-i386-code.fd.xz
 create mode 100644 pc-bios/edk2-i386-secure-code.fd.xz
 create mode 100644 pc-bios/edk2-i386-vars.fd.xz
 create mode 100644 pc-bios/edk2-licenses.txt
 create mode 100644 pc-bios/edk2-x86_64-code.fd.xz
 create mode 100644 pc-bios/edk2-x86_64-secure-code.fd.xz
 create mode 100644 roms/Makefile.edk2
 create mode 100755 roms/edk2-build.sh
 create mode 100644 roms/edk2-funcs.sh

-- 
2.20.1




[Qemu-devel] [PULL 02/12] roms/edk2-funcs.sh: require gcc-4.8+ for building i386 and x86_64

2019-03-16 Thread Philippe Mathieu-Daudé
From: Laszlo Ersek 

Adapt the qemu_edk2_get_toolchain() function in "roms/edk2-funcs.sh" in
advance to edk2 commit 8d7cdfae8cb8 ("OvmfPkg: require GCC48 or later",
2019-01-08), which is part of the "edk2-stable201903" tag.

Signed-off-by: Laszlo Ersek 
Reviewed-by: Philippe Mathieu-Daudé 
Tested-by: Philippe Mathieu-Daudé 
Reviewed-by: Michal Privoznik 
Reviewed-by: Michael S. Tsirkin 
Tested-by: Igor Mammedov 
Message-Id: <20190313210057.32584-3-ler...@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé 
---
 roms/edk2-funcs.sh | 14 +-
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/roms/edk2-funcs.sh b/roms/edk2-funcs.sh
index 8930479dcb..d1cb1e4a11 100644
--- a/roms/edk2-funcs.sh
+++ b/roms/edk2-funcs.sh
@@ -149,23 +149,11 @@ qemu_edk2_get_toolchain()
   # Run "git-blame" on "OvmfPkg/build.sh" in edk2 for more information on
   # the mapping below.
   case "$gcc_version" in
-([1-3].*|4.[0-3].*)
+([1-3].*|4.[0-7].*)
   printf '%s: unsupported gcc version "%s"\n' \
 "$program_name" "$gcc_version" >&2
   return 1
   ;;
-(4.4.*)
-  printf 'GCC44\n'
-  ;;
-(4.5.*)
-  printf 'GCC45\n'
-  ;;
-(4.6.*)
-  printf 'GCC46\n'
-  ;;
-(4.7.*)
-  printf 'GCC47\n'
-  ;;
 (4.8.*)
   printf 'GCC48\n'
   ;;
-- 
2.20.1




[Qemu-devel] [PULL 03/12] tests/uefi-test-tools/build.sh: work around TianoCore#1607

2019-03-16 Thread Philippe Mathieu-Daudé
From: Laszlo Ersek 

The edk2-stabe201903 release introduced Python3 support to edk2's
BaseTools; however the Python3 enablement breaks in a corner case (which
is nevertheless supported by the edk2 community), namely the in-module
parallelization that we utilize.

This is tracked under
. For now, work
around the issue (in advance) by forcing Python2. (The workaround is a
no-op before we move to edk2-stabe201903 in the roms/edk2 submodule.)

Signed-off-by: Laszlo Ersek 
Reviewed-by: Philippe Mathieu-Daudé 
Tested-by: Philippe Mathieu-Daudé 
Reviewed-by: Michal Privoznik 
Reviewed-by: Michael S. Tsirkin 
Tested-by: Igor Mammedov 
Message-Id: <20190313210057.32584-4-ler...@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé 
---
 tests/uefi-test-tools/build.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tests/uefi-test-tools/build.sh b/tests/uefi-test-tools/build.sh
index e2b52c855c..8aa7935c43 100755
--- a/tests/uefi-test-tools/build.sh
+++ b/tests/uefi-test-tools/build.sh
@@ -29,6 +29,9 @@ export PACKAGES_PATH=$(realpath -- "$edk2_dir")
 export WORKSPACE=$PWD
 mkdir -p Conf
 
+# Work around .
+export PYTHON_COMMAND=python2
+
 # Source "edksetup.sh" carefully.
 set +e +u +C
 source "$PACKAGES_PATH/edksetup.sh"
-- 
2.20.1




Re: [Qemu-devel] [PATCH] configure: disallow spaces and colons in source path

2019-03-16 Thread Antonio Ospite
Hi, thanks for the comments.

On Fri, 15 Mar 2019 13:48:25 -0500
Eric Blake  wrote:

> On 3/15/19 1:40 PM, Peter Maydell wrote:
> 
> > If you do this after the point where we make the source path absolute, you
> > can skip the realpath (which avoids the problem that 'realpath' doesn't 
> > exist
> > on OSX by default). It will also then be after the handling of the
> > --source-path option argument.
> >
> > Do we also need to check for spaces in the path of the build directory
> > (which is always the current working directory of the script) ?
> 
> I wasn't thinking about VPATH builds, but yes, in general, we should
> ensure that both srcdir and builddir are sane names, while still
> allowing symlinks to work around otherwise problematic canonical names.
> 
[...]

On Fri, 15 Mar 2019 13:46:58 -0500
Eric Blake  wrote:
>
> Why realpath? If my sources live in "/home/me/bad dir" but I have a
> symlink "/home/me/good", this prevents me from building even though I
> won't trip the problem.
> 

The rationale behind the current patch was that the check should be
done as soon as possible to avoid unneeded work, and since $source_path
is a relative path early on in the script I thought about realpath.

TBH I used realpath unconditionally because I saw it in the Makefile
but I overlooked the fact that it is an internal function in make.

I will move the check after the expansion of $source_path.

After Eric's comment I also tried building from a sane symlink, and
while configure is fine with it "make" still does not like it for
in-tree builds: apparently CURDIR (used to set BUILD_PATH in the
Makefile) resolves symlinks and brings back the bad path.

I do get your point tho, do I did some testing to see the current status
and base the changes on that.

Assuming this setup:

├── no_spaces
│   ├── build
│   ├── qemu
│   └── qemulink -> ../with spaces/qemu
└── with spaces
    ├── build
├── qemu
└── qemulink -> ../no_spaces/qemu

This are the results with the current master branch:

in-tree build:

no_spaces/qemu $ ./configure   # OK
no_spaces/qemu $ make  # OK

no_spaces/qemulink $ ./configure   # OK
no_spaces/qemulink $ make  # FAILS because of CURDIR

with spaces/qemu $ ./configure # FAILS because of source_path
with spaces/qemu $ make# FAILS because of SRC_PATH

with spaces/qemulink $ ./configure # FAILS because of source_path
with spaces/qemulink $ make# FAILS because of SRC_PATH

out-of-tree builds:

no_spaces/build $ ../qemu/configure # OK
no_spaces/build $ make  # OK

no_spaces/build $ ../qemulink/configure # OK
no_spaces/build $ make  # OK

no_spaces/build $ ../../with\ spaces/qemu/configure # FAILS
no_spaces/build $ make  # FAILS no Makefile

no_spaces/build $ ../../with\ spaces/qemulink/configure # FAILS
no_spaces/build $ make  # FAILS ^

with spaces/build $ ../qemu/configure   # FAILS
with spaces/build $ make# FAILS no Makefile

with spaces/build $ ../qemulink/configure   # FAILS
with spaces/build $ make# FAILS no Makefile

with spaces/build $ ../../no_spaces/qemu/configure  # OK
with spaces/build $ make# FAILS (CURDIR)

with spaces/build $ ../../no_spaces/qemulink/configure # OK
with spaces/build $ make   # FAILS (CURDIR)

So checking both source_path and PWD is a probably a good thing.

I'd add the check in the Makefile too, to be on the safe side and cover
the case of: no_spaces/qemulink $ make

Yeah, it is a slow Saturday. :)

Ciao,
   Antonio

-- 
Antonio Ospite
https://ao2.it
https://twitter.com/ao2it

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?



[Qemu-devel] [PULL 07/12] roms: build edk2 firmware binaries and variable store templates

2019-03-16 Thread Philippe Mathieu-Daudé
From: Laszlo Ersek 

Add the "efi" target to "Makefile".

Introduce "Makefile.edk2" for building and cleaning the firmware images
and varstore templates.

Collect the common bits from the recipes in the helper script
"edk2-build.sh".

Signed-off-by: Laszlo Ersek 
Reviewed-by: Michal Privoznik 
Tested-by: Philippe Mathieu-Daudé 
Reviewed-by: Philippe Mathieu-Daudé 
Tested-by: Igor Mammedov 
Message-Id: <20190313210057.32584-8-ler...@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé 
---
 roms/Makefile  |   5 ++
 roms/Makefile.edk2 | 148 +
 roms/edk2-build.sh |  55 +
 3 files changed, 208 insertions(+)
 create mode 100644 roms/Makefile.edk2
 create mode 100755 roms/edk2-build.sh

diff --git a/roms/Makefile b/roms/Makefile
index 2e83ececa2..054b432834 100644
--- a/roms/Makefile
+++ b/roms/Makefile
@@ -61,6 +61,7 @@ default:
@echo "  skiboot-- update skiboot.lid"
@echo "  u-boot.e500-- update u-boot.e500"
@echo "  u-boot.sam460  -- update u-boot.sam460"
+   @echo "  efi-- update UEFI (edk2) platform firmware"
 
 bios: build-seabios-config-seabios-128k build-seabios-config-seabios-256k
cp seabios/builds/seabios-128k/bios.bin ../pc-bios/bios.bin
@@ -143,6 +144,9 @@ skiboot:
$(MAKE) -C skiboot CROSS=$(powerpc64_cross_prefix)
cp skiboot/skiboot.lid ../pc-bios/skiboot.lid
 
+efi: edk2-basetools
+   $(MAKE) -f Makefile.edk2
+
 clean:
rm -rf seabios/.config seabios/out seabios/builds
$(MAKE) -C sgabios clean
@@ -153,3 +157,4 @@ clean:
rm -rf u-boot/build.e500
$(MAKE) -C u-boot-sam460ex distclean
$(MAKE) -C skiboot clean
+   $(MAKE) -f Makefile.edk2 clean
diff --git a/roms/Makefile.edk2 b/roms/Makefile.edk2
new file mode 100644
index 00..e5c3036949
--- /dev/null
+++ b/roms/Makefile.edk2
@@ -0,0 +1,148 @@
+# Makefile for building firmware binaries and variable store templates for a
+# number of virtual platforms in edk2.
+#
+# Copyright (C) 2019 Red Hat, Inc.
+#
+# This program and the accompanying materials are licensed and made available
+# under the terms and conditions of the BSD License that accompanies this
+# distribution. The full text of the license may be found at
+# .
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
+# WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+SHELL = /bin/bash
+
+toolchain = $(shell source ./edk2-funcs.sh && qemu_edk2_get_toolchain $(1))
+
+licenses := \
+   edk2/License.txt \
+   edk2/OvmfPkg/License.txt \
+   edk2/CryptoPkg/Library/OpensslLib/openssl/LICENSE
+
+# The "edk2-arm-vars.fd" varstore template is suitable for aarch64 as well.
+# Similarly, the "edk2-i386-vars.fd" varstore template is suitable for x86_64
+# as well, independently of "secure" too.
+flashdevs := \
+   aarch64-code \
+   arm-code \
+   i386-code \
+   i386-secure-code \
+   x86_64-code \
+   x86_64-secure-code \
+   \
+   arm-vars \
+   i386-vars
+
+all: $(foreach flashdev,$(flashdevs),../pc-bios/edk2-$(flashdev).fd.xz) \
+   ../pc-bios/edk2-licenses.txt
+
+../pc-bios/edk2-%.fd.xz: ../pc-bios/edk2-%.fd
+   xz -9 -e -c $< > $@
+
+# When the build completes, we need not keep the uncompressed flash device
+# files.
+.INTERMEDIATE: $(foreach flashdev,$(flashdevs),../pc-bios/edk2-$(flashdev).fd)
+
+submodules:
+   cd edk2 && git submodule update --init --force
+
+# See notes on the ".NOTPARALLEL" target and the "+" indicator in
+# "tests/uefi-test-tools/Makefile".
+.NOTPARALLEL:
+
+../pc-bios/edk2-aarch64-code.fd: submodules
+   +./edk2-build.sh \
+   aarch64 \
+   --arch=AARCH64 \
+   --platform=ArmVirtPkg/ArmVirtQemu.dsc \
+   -D NETWORK_IP6_ENABLE \
+   -D HTTP_BOOT_ENABLE
+   cp edk2/Build/ArmVirtQemu-AARCH64/DEBUG_$(call 
toolchain,aarch64)/FV/QEMU_EFI.fd \
+   $@
+   truncate --size=64M $@
+
+../pc-bios/edk2-arm-code.fd: submodules
+   +./edk2-build.sh \
+   arm \
+   --arch=ARM \
+   --platform=ArmVirtPkg/ArmVirtQemu.dsc \
+   -D NETWORK_IP6_ENABLE \
+   -D HTTP_BOOT_ENABLE
+   cp edk2/Build/ArmVirtQemu-ARM/DEBUG_$(call 
toolchain,arm)/FV/QEMU_EFI.fd \
+   $@
+   truncate --size=64M $@
+
+../pc-bios/edk2-i386-code.fd: submodules
+   +./edk2-build.sh \
+   i386 \
+   --arch=IA32 \
+   --platform=OvmfPkg/OvmfPkgIa32.dsc \
+   -D NETWORK_IP6_ENABLE \
+   -D HTTP_BOOT_ENABLE \
+   -D TLS_ENABLE \
+   -D TPM2_ENABLE \
+   -D TPM2_CONFIG_ENABLE
+   cp edk2/Build/OvmfIa32/DEBUG_$(call toolchain,i386)/FV/OVMF_CODE.fd $@
+
+../pc-bios/edk2-i386-secure-code.fd: submodules
+   

[Qemu-devel] [PULL 10/12] tests: add missing dependency to build QTEST_QEMU_BINARY, round 2

2019-03-16 Thread Philippe Mathieu-Daudé
From: Laszlo Ersek 

In commit b94b330e2333 ("tests: add missing dependency to build
QTEST_QEMU_BINARY", 2017-07-31), Phil fixed the dependency list of make
target "check-qtest-%". Namely, the recipe would set QTEST_QEMU_BINARY to
the softmmu emulator for the emulation target, but the prerequisites
didn't include the emulator.

The same issue affects the "check-report-qtest-%.tap" make target, which
is the other make target whose recipe sets QTEST_QEMU_BINARY:

> $ make -j4 check-report-qtest-aarch64.tap
>   TAP check-report-qtest-aarch64.tap
> sh: /.../aarch64-softmmu/qemu-system-aarch64: No such file or directory

Apply Phil's fix to this make target too.

Signed-off-by: Laszlo Ersek 
Reviewed-by: Michal Privoznik 
Reviewed-by: Michael S. Tsirkin 
Tested-by: Igor Mammedov 
Message-Id: <20190313210057.32584-11-ler...@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé 
---
 tests/Makefile.include | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 852f17b8c7..0a0e1c340f 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -915,7 +915,7 @@ check-speed: $(check-speed-y)
 
 # gtester tests with TAP output
 
-$(patsubst %, check-report-qtest-%.tap, $(QTEST_TARGETS)): 
check-report-qtest-%.tap: $(check-qtest-y)
+$(patsubst %, check-report-qtest-%.tap, $(QTEST_TARGETS)): 
check-report-qtest-%.tap: subdir-%-softmmu $(check-qtest-y)
$(call do_test_tap, $(check-qtest-$*-y) $(check-qtest-generic-y), \
  QTEST_QEMU_BINARY=$*-softmmu/qemu-system-$* \
  QTEST_QEMU_IMG=qemu-img$(EXESUF))
-- 
2.20.1




[Qemu-devel] [PULL 01/12] roms: lift "edk2-funcs.sh" from "tests/uefi-test-tools/build.sh"

2019-03-16 Thread Philippe Mathieu-Daudé
From: Laszlo Ersek 

Extract the dense logic for architecture and toolchain massaging from
"tests/uefi-test-tools/build.sh", to a set of small functions. We'll reuse
these functions for building full platform firmware images.

Signed-off-by: Laszlo Ersek 
Reviewed-by: Philippe Mathieu-Daudé 
Tested-by: Philippe Mathieu-Daudé 
Reviewed-by: Michal Privoznik 
Reviewed-by: Michael S. Tsirkin 
Tested-by: Igor Mammedov 
Message-Id: <20190313210057.32584-2-ler...@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé 
---
 roms/edk2-funcs.sh | 240 +
 tests/uefi-test-tools/build.sh |  97 +
 2 files changed, 246 insertions(+), 91 deletions(-)
 create mode 100644 roms/edk2-funcs.sh

diff --git a/roms/edk2-funcs.sh b/roms/edk2-funcs.sh
new file mode 100644
index 00..8930479dcb
--- /dev/null
+++ b/roms/edk2-funcs.sh
@@ -0,0 +1,240 @@
+# Shell script that defines functions for determining some environmental
+# characteristics for the edk2 "build" utility.
+#
+# This script is meant to be sourced, in a bash environment.
+#
+# Copyright (C) 2019 Red Hat, Inc.
+#
+# This program and the accompanying materials are licensed and made available
+# under the terms and conditions of the BSD License that accompanies this
+# distribution. The full text of the license may be found at
+# .
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
+# WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+# Verify whether the QEMU system emulation target is supported by the UEFI spec
+# and edk2. Print a message to the standard error, and return with nonzero
+# status, if verification fails.
+#
+# Parameters:
+#   $1: QEMU system emulation target
+qemu_edk2_verify_arch()
+{
+  local emulation_target="$1"
+  local program_name=$(basename -- "$0")
+
+  case "$emulation_target" in
+(arm|aarch64|i386|x86_64)
+  ;;
+(*)
+  printf '%s: unknown/unsupported QEMU system emulation target "%s"\n' \
+"$program_name" "$emulation_target" >&2
+  return 1
+  ;;
+  esac
+}
+
+
+# Translate the QEMU system emulation target to the edk2 architecture
+# identifier. Print the result to the standard output.
+#
+# Parameters:
+#   $1: QEMU system emulation target
+qemu_edk2_get_arch()
+{
+  local emulation_target="$1"
+
+  if ! qemu_edk2_verify_arch "$emulation_target"; then
+return 1
+  fi
+
+  case "$emulation_target" in
+(arm)
+  printf 'ARM\n'
+  ;;
+(aarch64)
+  printf 'AARCH64\n'
+  ;;
+(i386)
+  printf 'IA32\n'
+  ;;
+(x86_64)
+  printf 'X64\n'
+  ;;
+  esac
+}
+
+
+# Translate the QEMU system emulation target to the gcc cross-compilation
+# architecture identifier. Print the result to the standard output.
+#
+# Parameters:
+#   $1: QEMU system emulation target
+qemu_edk2_get_gcc_arch()
+{
+  local emulation_target="$1"
+
+  if ! qemu_edk2_verify_arch "$emulation_target"; then
+return 1
+  fi
+
+  case "$emulation_target" in
+(arm|aarch64|x86_64)
+  printf '%s\n' "$emulation_target"
+  ;;
+(i386)
+  printf 'i686\n'
+  ;;
+  esac
+}
+
+
+# Determine the gcc cross-compiler prefix (if any) for use with the edk2
+# toolchain. Print the result to the standard output.
+#
+# Parameters:
+#   $1: QEMU system emulation target
+qemu_edk2_get_cross_prefix()
+{
+  local emulation_target="$1"
+  local gcc_arch
+  local host_arch
+
+  if ! gcc_arch=$(qemu_edk2_get_gcc_arch "$emulation_target"); then
+return 1
+  fi
+
+  host_arch=$(uname -m)
+
+  if [ "$gcc_arch" == "$host_arch" ] ||
+ ( [ "$gcc_arch" == i686 ] && [ "$host_arch" == x86_64 ] ); then
+# no cross-compiler needed
+:
+  else
+printf '%s-linux-gnu-\n' "$gcc_arch"
+  fi
+}
+
+
+# Determine the edk2 toolchain tag for the QEMU system emulation target. Print
+# the result to the standard output. Print a message to the standard error, and
+# return with nonzero status, if the (conditional) gcc version check fails.
+#
+# Parameters:
+#   $1: QEMU system emulation target
+qemu_edk2_get_toolchain()
+{
+  local emulation_target="$1"
+  local program_name=$(basename -- "$0")
+  local cross_prefix
+  local gcc_version
+
+  if ! qemu_edk2_verify_arch "$emulation_target"; then
+return 1
+  fi
+
+  case "$emulation_target" in
+(arm|aarch64)
+  printf 'GCC5\n'
+  ;;
+
+(i386|x86_64)
+  if ! cross_prefix=$(qemu_edk2_get_cross_prefix "$emulation_target"); then
+return 1
+  fi
+
+  gcc_version=$("${cross_prefix}gcc" -v 2>&1 | tail -1 | awk '{print $3}')
+  # Run "git-blame" on "OvmfPkg/build.sh" in edk2 for more information on
+  # the mapping below.
+  case "$gcc_version" in
+([1-3].*|4.[0-3].*)
+  printf '%s: unsupported gcc version "%s"\n' \
+"$program_name" "$gcc_version" >&2
+  return 1
+  ;;
+(4.4.*)
+  printf 'GCC44\n'
+

[Qemu-devel] [PULL 04/12] roms/edk2: advance to tag edk2-stable201903

2019-03-16 Thread Philippe Mathieu-Daudé
From: Laszlo Ersek 

Update the roms/edk2 submodule hash from edk2-stable201811 to
edk2-stable201903. The release notes are available at
.

$ git shortlog edk2-stable201811..edk2-stable201903

Achin Gupta (9):
  ArmPkg: Add PCDs needed for MM communication driver.
  ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.
  ArmPkg/Include: Add MM interface SVC return codes.
  ArmPkg/ArmMmuLib: Add MMU Library suitable for use in S-EL0.
  StandaloneMmPkg: Add missing dependency on PL011UartClockLib
  StandaloneMmPkg: Enforce alignment check for AArch64
  StandaloneMmPkg: Zero data structure explicitly
  StandaloneMmPkg: Replace dependency on ArmMmuLib
  StandaloneMmPkg: Update dependency on PeCoffExtraActionLib

Albecki, Mateusz (1):
  MdeModulePkg/SdMmcPciHcDxe Fix eMMC HS400 switch sequence

Alex James (2):
  StdLib/sys/termios: Define cc_t as unsigned
  StdLib/Environs: Avoid infinite recursion in _Exit

Antoine Coeur (5):
  ArmVirtPkg: Fix various typos
  CryptoPkg: Fix various typos
  CorebootPayloadPkg: Fix various typos
  CorebootModulePkg: Fix various typos
  BaseTools: Various typo

Ard Biesheuvel (116):
  MdePkg/BaseIoLibIntrinsicArmVirt ARM: avoid double word loads and stores
  ArmPkg/ArmGicDxe ARM: fix encoding for GICv3 interrupt acknowledge
  ArmPlatformPkg: clear frame pointer in startup code
  ArmVirtPkg/PrePi: clear frame pointer in startup code
  ArmPkg/ArmSmcPsciResetSystemLib: add missing call to ExitBootServices()
  ArmPkg: remove now unused BsdLib.h
  ArmPlatformPkg/NorFlashDxe: prepare for devicepath format change
  ArmPlatformPkg/NorFlashDxe: use one GUID plus index to identify flash 
banks
  ArmVirtPkg/FdtClientDxe: take DT node 'status' properties into account
  ArmVirtPkg/NorFlashQemuLib: discover NOR flash banks dynamically
  ArmPlatformPkg/NorFlashPlatformLib: remove unused Guid member from struct
  ArmPkg/ArmPkg.dsc: move ArmMmuStandaloneMmLib.inf to AARCH64 section
  EmbeddedPkg/TemplateSec: remove unused module
  EmbeddedPkg/PrePiHobLib: drop CreateHobList() from library
  ArmVirtPkg/FdtPciHostBridgeLib: map ECAM and I/O spaces in GCD memory map
  ArmVirtPkg/QemuVirtMemInfoLib: remove 1:1 mapping of top of PA range
  MdePkg/ProcessorBind.h AARCH64: limit MAX_ADDRESS to 48 bits
  ArmPkg/ArmLib: add support for reading the max physical address space size
  ArmVirtPkg/XenVirtMemInfoLib: refactor reading of the PA space size
  ArmPkg/ArmMmuLib: take the CPU supported maximum PA space into account
  ArmPkg/CpuPei: base GCD memory space size on CPU's PA range
  ArmPlatformPkg/PrePi: base GCD memory space size on CPU's PA range
  ArmVirtPkg/PrePi: base GCD memory space size on CPU's PA range
  BeagleBoardPkg/PrePi: base GCD memory space size on CPU's PA range
  ArmPlatformPkg/PlatformPei: drop unused PCD references
  EmbeddedPkg/PrePiLib: drop unused PCD reference
  ArmVirtPkg: drop PcdPrePiCpuMemorySize assignments from all platforms
  EmbeddedPkg/EmbeddedPkg.dec: drop PcdPrePiCpuMemorySize declarations
  ArmPkg/ArmMmuLib ARM: handle unmapped section in GetMemoryRegion()
  ArmPkg/ArmMmuLib ARM: handle unmapped sections when updating permissions
  ArmVirtPkg/NorFlashQemuLib: disregard our primary FV
  ArmVirtPkg/QemuVirtMemInfoLib: trim the MMIO region mapping
  BaseTools/CommonLib: avoid using 'native' word size in IP address handling
  BaseTools/CommonLib: use explicit 64-bit type in Strtoi()
  BaseTools/DevicePath: use explicit 64-bit number parsing routines
  BaseTools/CommonLib: add definition of MAX_UINT32
  BaseTools/DevicePath: use MAX_UINT32 as default device path max size
  BaseTools/CommonLib: get rid of 'native' type string parsing routines
  BaseTools/CommonLib: drop definition of MAX_UINTN
  BaseTools/CommonLib: drop the use of MAX_ADDRESS
  Revert "MdePkg/ProcessorBind.h AARCH64: limit MAX_ADDRESS to 48 bits"
  MdeModulePkg/FileExplorerLib: avoid packed struct for program data
  BaseTools/tools_def AARCH64 RELEASE: move GCC49/GGC5 to 4 KB alignment
  ArmVirtPkg/ArmVirtQemuKernel ARM: make some PCD settings apply to ARM
  ArmVirtPkg/PrePiUniCoreRelocatable CLANG38: work around build issues
  BaseTools/GenFw ARM: don't permit R_ARM_GOT_PREL relocations
  MdePkg/BaseMemoryLibOptDxe ARM: add missing function annotations
  BaseTools/tools_def ARM CLANG35: work around -mno-movt option name change
  ArmVirtPkg/PrePi ARM CLANG35: drop incompatible command line option
  ArmVirtPkg/ArmVirt.dsc.inc: define TcpIoLib resolution unconditionally
  ArmPkg: remove redundant _ARM_PLATFORM_FLAGS overrides
  EmbeddedPkg: remove GdbDebugAgent library
  BaseTools/tools_def ARM: emit PIC veneers
  ArmPkg/DefaultExceptionHandlerLib ARM: avoid 

Re: [Qemu-devel] [PATCH 13/14] hw/hppa/Kconfig: Dino board requires e1000 network card

2019-03-16 Thread Paolo Bonzini
> This fixes when configuring with --without-default-devices:
> 
>   $ qemu-system-hppa
>   qemu-system-hppa: Unsupported NIC model: e1000

This is intended.  --without-default-devices does not guarantee that you can 
start
the board except with --nodefaults.

Paolo



[Qemu-devel] [PULL 11/12] Makefile: install the edk2 firmware images and their descriptors

2019-03-16 Thread Philippe Mathieu-Daudé
From: Laszlo Ersek 

Decompress and install the edk2 firmware blobs as part of "make install",
unless blob installation was disabled with configure's "--disable-blobs"
option.

Additionally, decompress the blobs as a pre-requisite for building softmmu
binaries -- this is helpful for both "make check" and other ad-hoc tests
one might want to run in the build directory.

Signed-off-by: Laszlo Ersek 
Reviewed-by: Michal Privoznik 
Reviewed-by: Philippe Mathieu-Daudé 
Tested-by: Philippe Mathieu-Daudé 
Reviewed-by: Michael S. Tsirkin 
Tested-by: Igor Mammedov 
Message-Id: <20190313210057.32584-12-ler...@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé 
---
 .gitignore |  1 +
 Makefile   | 29 -
 configure  |  1 +
 3 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index 8f78221804..fd6e6c38c7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -97,6 +97,7 @@
 *.gcno
 *.gcov
 /pc-bios/bios-pq/status
+/pc-bios/edk2-*.fd
 /pc-bios/vgabios-pq/status
 /pc-bios/optionrom/linuxboot.asm
 /pc-bios/optionrom/linuxboot.bin
diff --git a/Makefile b/Makefile
index d8dad39c5d..6c5c1a1cad 100644
--- a/Makefile
+++ b/Makefile
@@ -296,6 +296,10 @@ ui/input-keymap-%.c: $(KEYCODEMAP_GEN) $(KEYCODEMAP_CSV) 
$(SRC_PATH)/ui/Makefile
 $(KEYCODEMAP_GEN): .git-submodule-status
 $(KEYCODEMAP_CSV): .git-submodule-status
 
+edk2-decompressed = $(basename $(wildcard pc-bios/edk2-*.fd.xz))
+pc-bios/edk2-%.fd: pc-bios/edk2-%.fd.xz
+   $(call quiet-command,xz -d -c $< > $@,"UNXZ",$<)
+
 # Don't try to regenerate Makefile or configure
 # We don't generate any of them
 Makefile: ;
@@ -444,6 +448,7 @@ $(SOFTMMU_SUBDIR_RULES): $(block-obj-y)
 $(SOFTMMU_SUBDIR_RULES): $(crypto-obj-y)
 $(SOFTMMU_SUBDIR_RULES): $(io-obj-y)
 $(SOFTMMU_SUBDIR_RULES): config-all-devices.mak
+$(SOFTMMU_SUBDIR_RULES): $(edk2-decompressed)
 
 subdir-%:
$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" 
TARGET_DIR="$*/" all,)
@@ -632,6 +637,7 @@ clean:
! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-arm.a \
! -path ./roms/edk2/BaseTools/Source/Python/UPT/Dll/sqlite3.dll 
\
-exec rm {} +
+   rm -f $(edk2-decompressed)
rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) qemu-ga TAGS cscope.* 
*.pod *~ */*~
rm -f fsdev/*.pod scsi/*.pod
rm -f qemu-img-cmds.h
@@ -722,9 +728,14 @@ spapr-rtas.bin slof.bin skiboot.lid \
 palcode-clipper \
 u-boot.e500 u-boot-sam460-20100605.bin \
 qemu_vga.ndrv \
+edk2-licenses.txt \
 hppa-firmware.img
+
+DESCS=50-edk2-i386-secure.json 50-edk2-x86_64-secure.json \
+60-edk2-aarch64.json 60-edk2-arm.json 60-edk2-i386.json 60-edk2-x86_64.json
 else
 BLOBS=
+DESCS=
 endif
 
 # Note that we manually filter-out the non-Sphinx documentation which
@@ -785,7 +796,8 @@ endif
 
 ICON_SIZES=16x16 24x24 32x32 48x48 64x64 128x128 256x256 512x512
 
-install: all $(if $(BUILD_DOCS),install-doc) install-datadir 
install-localstatedir
+install: all $(if $(BUILD_DOCS),install-doc) install-datadir 
install-localstatedir \
+   $(if $(INSTALL_BLOBS),$(edk2-decompressed))
 ifneq ($(TOOLS),)
$(call install-prog,$(subst 
qemu-ga,qemu-ga$(EXESUF),$(TOOLS)),$(DESTDIR)$(bindir))
 endif
@@ -807,6 +819,21 @@ ifneq ($(BLOBS),)
set -e; for x in $(BLOBS); do \
$(INSTALL_DATA) $(SRC_PATH)/pc-bios/$$x 
"$(DESTDIR)$(qemu_datadir)"; \
done
+endif
+ifdef INSTALL_BLOBS
+   set -e; for x in $(edk2-decompressed); do \
+   $(INSTALL_DATA) $$x "$(DESTDIR)$(qemu_datadir)"; \
+   done
+endif
+ifneq ($(DESCS),)
+   $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/firmware"
+   set -e; tmpf=$$(mktemp); trap 'rm -f -- "$$tmpf"' EXIT; \
+   for x in $(DESCS); do \
+   sed -e 's,@DATADIR@,$(DESTDIR)$(qemu_datadir),' \
+   "$(SRC_PATH)/pc-bios/descriptors/$$x" > "$$tmpf"; \
+   $(INSTALL_DATA) "$$tmpf" \
+   "$(DESTDIR)$(qemu_datadir)/firmware/$$x"; \
+   done
 endif
for s in $(ICON_SIZES); do \
mkdir -p "$(DESTDIR)/$(qemu_icondir)/hicolor/$${s}/apps"; \
diff --git a/configure b/configure
index 7071f52584..dc5876d09a 100755
--- a/configure
+++ b/configure
@@ -7863,6 +7863,7 @@ for bios_file in \
 $source_path/pc-bios/*.img \
 $source_path/pc-bios/openbios-* \
 $source_path/pc-bios/u-boot.* \
+$source_path/pc-bios/edk2-*.fd.xz \
 $source_path/pc-bios/palcode-*
 do
 LINKS="$LINKS pc-bios/$(basename $bios_file)"
-- 
2.20.1




[Qemu-devel] [PULL 06/12] roms/Makefile: replace the $(EFIROM) target with "edk2-basetools"

2019-03-16 Thread Philippe Mathieu-Daudé
From: Laszlo Ersek 

We don't (can't) have a recipe for building just $(EFIROM); therefore,
while we call the target $(EFIROM), we actually build all of the edk2
BaseTools. Rename the target to edk2-basetools, and update the iPXE
prerequisite accordingly. This will let other targets depend on
"edk2-basetools", where an $(EFIROM) pre-requisite would be misleading.

Signed-off-by: Laszlo Ersek 
Reviewed-by: Philippe Mathieu-Daudé 
Tested-by: Philippe Mathieu-Daudé 
Reviewed-by: Michal Privoznik 
Reviewed-by: Michael S. Tsirkin 
Tested-by: Igor Mammedov 
Message-Id: <20190313210057.32584-7-ler...@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé 
---
 roms/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/roms/Makefile b/roms/Makefile
index 78d5dd18c3..2e83ececa2 100644
--- a/roms/Makefile
+++ b/roms/Makefile
@@ -102,7 +102,7 @@ pxe-rom-%: build-pxe-roms
 
 efirom: $(patsubst %,efi-rom-%,$(pxerom_variants))
 
-efi-rom-%: build-pxe-roms build-efi-roms $(EFIROM)
+efi-rom-%: build-pxe-roms build-efi-roms edk2-basetools
$(EFIROM) -f "0x$(VID)" -i "0x$(DID)" -l 0x02 \
-b ipxe/src/bin/$(VID)$(DID).rom \
-ec ipxe/src/bin-i386-efi/$(VID)$(DID).efidrv \
@@ -120,7 +120,7 @@ build-efi-roms: build-pxe-roms
$(patsubst %,bin-i386-efi/%.efidrv,$(pxerom_targets)) \
$(patsubst %,bin-x86_64-efi/%.efidrv,$(pxerom_targets))
 
-$(EFIROM):
+edk2-basetools:
$(MAKE) -C edk2/BaseTools
 
 slof:
-- 
2.20.1




[Qemu-devel] [PULL 08/12] pc-bios: add edk2 firmware binaries and variable store templates

2019-03-16 Thread Philippe Mathieu-Daudé
From: Laszlo Ersek 

Add the files built by the last patch: (compressed) binaries, and the
cumulative license text that covers them.

Signed-off-by: Laszlo Ersek 
Reviewed-by: Michael S. Tsirkin 
Tested-by: Igor Mammedov 
Message-Id: <20190313210057.32584-9-ler...@redhat.com>
[PMD: remove trailing whitespaces in edk2-licenses.txt]
Signed-off-by: Philippe Mathieu-Daudé 
---
 pc-bios/edk2-aarch64-code.fd.xz   | Bin 0 -> 1146804 bytes
 pc-bios/edk2-arm-code.fd.xz   | Bin 0 -> 1147852 bytes
 pc-bios/edk2-arm-vars.fd.xz   | Bin 0 -> 10008 bytes
 pc-bios/edk2-i386-code.fd.xz  | Bin 0 -> 1674764 bytes
 pc-bios/edk2-i386-secure-code.fd.xz   | Bin 0 -> 1870024 bytes
 pc-bios/edk2-i386-vars.fd.xz  | Bin 0 -> 320 bytes
 pc-bios/edk2-licenses.txt | 208 ++
 pc-bios/edk2-x86_64-code.fd.xz| Bin 0 -> 1655276 bytes
 pc-bios/edk2-x86_64-secure-code.fd.xz | Bin 0 -> 1889024 bytes
 9 files changed, 208 insertions(+)
 create mode 100644 pc-bios/edk2-aarch64-code.fd.xz
 create mode 100644 pc-bios/edk2-arm-code.fd.xz
 create mode 100644 pc-bios/edk2-arm-vars.fd.xz
 create mode 100644 pc-bios/edk2-i386-code.fd.xz
 create mode 100644 pc-bios/edk2-i386-secure-code.fd.xz
 create mode 100644 pc-bios/edk2-i386-vars.fd.xz
 create mode 100644 pc-bios/edk2-licenses.txt
 create mode 100644 pc-bios/edk2-x86_64-code.fd.xz
 create mode 100644 pc-bios/edk2-x86_64-secure-code.fd.xz

diff --git a/pc-bios/edk2-aarch64-code.fd.xz b/pc-bios/edk2-aarch64-code.fd.xz
new file mode 100644
index 00..8ca34c56b5
Binary files /dev/null and b/pc-bios/edk2-aarch64-code.fd.xz differ
diff --git a/pc-bios/edk2-arm-code.fd.xz b/pc-bios/edk2-arm-code.fd.xz
new file mode 100644
index 00..db2c20b71e
Binary files /dev/null and b/pc-bios/edk2-arm-code.fd.xz differ
diff --git a/pc-bios/edk2-arm-vars.fd.xz b/pc-bios/edk2-arm-vars.fd.xz
new file mode 100644
index 00..8c3a4b5c8b
Binary files /dev/null and b/pc-bios/edk2-arm-vars.fd.xz differ
diff --git a/pc-bios/edk2-i386-code.fd.xz b/pc-bios/edk2-i386-code.fd.xz
new file mode 100644
index 00..f25dbec37e
Binary files /dev/null and b/pc-bios/edk2-i386-code.fd.xz differ
diff --git a/pc-bios/edk2-i386-secure-code.fd.xz 
b/pc-bios/edk2-i386-secure-code.fd.xz
new file mode 100644
index 00..11d499b90d
Binary files /dev/null and b/pc-bios/edk2-i386-secure-code.fd.xz differ
diff --git a/pc-bios/edk2-i386-vars.fd.xz b/pc-bios/edk2-i386-vars.fd.xz
new file mode 100644
index 00..1656532daa
Binary files /dev/null and b/pc-bios/edk2-i386-vars.fd.xz differ
diff --git a/pc-bios/edk2-licenses.txt b/pc-bios/edk2-licenses.txt
new file mode 100644
index 00..5a1e3f3f14
--- /dev/null
+++ b/pc-bios/edk2-licenses.txt
@@ -0,0 +1,208 @@
+==> edk2/License.txt <==
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.
+Copyright (c) 2011 - 2015, ARM Limited. All rights reserved.
+Copyright (c) 2014 - 2015, Linaro Limited. All rights reserved.
+Copyright (c) 2013 - 2015, Red Hat, Inc.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+* Redistributions of source code must retain the above copyright
+  notice, this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright
+  notice, this list of conditions and the following disclaimer in
+  the documentation and/or other materials provided with the
+  distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+==> edk2/OvmfPkg/License.txt <==
+Copyright (c) 2012, Intel Corporation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+* Redistributions of source code must retain the above copyright
+  notice, this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright
+  notice, this list of conditions and the following disclaimer in
+  the documentation and/or other materials provided with the
+  distribution.
+
+THIS SOFTWARE IS PROVIDED BY 

[Qemu-devel] [PULL 05/12] roms/edk2-funcs.sh: add the qemu_edk2_get_thread_count() function

2019-03-16 Thread Philippe Mathieu-Daudé
From: Laszlo Ersek 

The edk2 "build" utility natively supports building modules (that is, INF
files) in parallel. The feature is not useful when building a single
module (with the "-m" option), but it is useful for platform firmware
builds (which include many modules). Add a function that determines the
"-n" option argument for "build", from the MAKEFLAGS variable (i.e. based
on the presence of a make job server).

Signed-off-by: Laszlo Ersek 
Reviewed-by: Philippe Mathieu-Daudé 
Tested-by: Philippe Mathieu-Daudé 
Reviewed-by: Michal Privoznik 
Reviewed-by: Michael S. Tsirkin 
Tested-by: Igor Mammedov 
Message-Id: <20190313210057.32584-6-ler...@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé 
---
 roms/edk2-funcs.sh | 25 +
 1 file changed, 25 insertions(+)

diff --git a/roms/edk2-funcs.sh b/roms/edk2-funcs.sh
index d1cb1e4a11..a9fae7ee89 100644
--- a/roms/edk2-funcs.sh
+++ b/roms/edk2-funcs.sh
@@ -226,3 +226,28 @@ qemu_edk2_set_cross_env()
 
   eval "export $cross_prefix_var=\$cross_prefix"
 }
+
+
+# Determine the "-n" option argument (that is, the number of modules to build
+# in parallel) for the edk2 "build" utility. Print the result to the standard
+# output.
+#
+# Parameters:
+#   $1: the value of the MAKEFLAGS variable
+qemu_edk2_get_thread_count()
+{
+  local makeflags="$1"
+
+  if [[ "$makeflags" == *--jobserver-auth=* ]] ||
+ [[ "$makeflags" == *--jobserver-fds=* ]]; then
+# If there is a job server, allow the edk2 "build" utility to parallelize
+# as many module builds as there are logical CPUs in the system. The "make"
+# instances forked by "build" are supposed to limit themselves through the
+# job server. The zero value below causes the edk2 "build" utility to fetch
+# the logical CPU count with Python's multiprocessing.cpu_count() method.
+printf '0\n'
+  else
+# Build a single module at a time.
+printf '1\n'
+  fi
+}
-- 
2.20.1




[Qemu-devel] [PULL 09/12] pc-bios: document the edk2 firmware images; add firmware descriptors

2019-03-16 Thread Philippe Mathieu-Daudé
From: Laszlo Ersek 

Update the README file with information on the images added previously,
and provide firmware descriptor documents that conform to
"docs/interop/firmware.json".

Signed-off-by: Laszlo Ersek 
Reviewed-by: Michal Privoznik 
Reviewed-by: Michael S. Tsirkin 
Tested-by: Igor Mammedov 
Message-Id: <20190313210057.32584-10-ler...@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé 
---
 pc-bios/README| 11 ++
 pc-bios/descriptors/50-edk2-i386-secure.json  | 34 ++
 .../descriptors/50-edk2-x86_64-secure.json| 35 +++
 pc-bios/descriptors/60-edk2-aarch64.json  | 31 
 pc-bios/descriptors/60-edk2-arm.json  | 31 
 pc-bios/descriptors/60-edk2-i386.json | 33 +
 pc-bios/descriptors/60-edk2-x86_64.json   | 34 ++
 7 files changed, 209 insertions(+)
 create mode 100644 pc-bios/descriptors/50-edk2-i386-secure.json
 create mode 100644 pc-bios/descriptors/50-edk2-x86_64-secure.json
 create mode 100644 pc-bios/descriptors/60-edk2-aarch64.json
 create mode 100644 pc-bios/descriptors/60-edk2-arm.json
 create mode 100644 pc-bios/descriptors/60-edk2-i386.json
 create mode 100644 pc-bios/descriptors/60-edk2-x86_64.json

diff --git a/pc-bios/README b/pc-bios/README
index d421cb3f1f..f6acd32096 100644
--- a/pc-bios/README
+++ b/pc-bios/README
@@ -50,3 +50,14 @@
 
 - QemuMacDrivers (https://github.com/ozbenh/QemuMacDrivers) is a project to
   provide virtualised drivers for PPC MacOS guests.
+
+- The "edk2-*.fd.xz" images are platform firmware binaries and matching UEFI
+  variable store templates built from the TianoCore community's EFI Development
+  Kit II project
+  . The images
+  were built at git tag "edk2-stable201903". The firmware binaries bundle parts
+  of the OpenSSL project, at git tag "OpenSSL_1_1_0j" (the OpenSSL tag is a
+  function of the edk2 tag). Licensing information is given in
+  "edk2-licenses.txt". The image files are described by the JSON documents in
+  the "pc-bios/descriptors" directory, which conform to the
+  "docs/interop/firmware.json" schema.
diff --git a/pc-bios/descriptors/50-edk2-i386-secure.json 
b/pc-bios/descriptors/50-edk2-i386-secure.json
new file mode 100644
index 00..d7108c1da0
--- /dev/null
+++ b/pc-bios/descriptors/50-edk2-i386-secure.json
@@ -0,0 +1,34 @@
+{
+"description": "UEFI firmware for i386, with Secure Boot and SMM",
+"interface-types": [
+"uefi"
+],
+"mapping": {
+"device": "flash",
+"executable": {
+"filename": "@DATADIR@/edk2-i386-secure-code.fd",
+"format": "raw"
+},
+"nvram-template": {
+"filename": "@DATADIR@/edk2-i386-vars.fd",
+"format": "raw"
+}
+},
+"targets": [
+{
+"architecture": "i386",
+"machines": [
+"pc-q35-*"
+]
+}
+],
+"features": [
+"acpi-s3",
+"requires-smm",
+"secure-boot",
+"verbose-dynamic"
+],
+"tags": [
+
+]
+}
diff --git a/pc-bios/descriptors/50-edk2-x86_64-secure.json 
b/pc-bios/descriptors/50-edk2-x86_64-secure.json
new file mode 100644
index 00..387eb35623
--- /dev/null
+++ b/pc-bios/descriptors/50-edk2-x86_64-secure.json
@@ -0,0 +1,35 @@
+{
+"description": "UEFI firmware for x86_64, with Secure Boot and SMM",
+"interface-types": [
+"uefi"
+],
+"mapping": {
+"device": "flash",
+"executable": {
+"filename": "@DATADIR@/edk2-x86_64-secure-code.fd",
+"format": "raw"
+},
+"nvram-template": {
+"filename": "@DATADIR@/edk2-i386-vars.fd",
+"format": "raw"
+}
+},
+"targets": [
+{
+"architecture": "x86_64",
+"machines": [
+"pc-q35-*"
+]
+}
+],
+"features": [
+"acpi-s3",
+"amd-sev",
+"requires-smm",
+"secure-boot",
+"verbose-dynamic"
+],
+"tags": [
+
+]
+}
diff --git a/pc-bios/descriptors/60-edk2-aarch64.json 
b/pc-bios/descriptors/60-edk2-aarch64.json
new file mode 100644
index 00..800a21bda6
--- /dev/null
+++ b/pc-bios/descriptors/60-edk2-aarch64.json
@@ -0,0 +1,31 @@
+{
+"description": "UEFI firmware for aarch64",
+"interface-types": [
+"uefi"
+],
+"mapping": {
+"device": "flash",
+"executable": {
+"filename": "@DATADIR@/edk2-aarch64-code.fd",
+"format": "raw"
+},
+"nvram-template": {
+"filename": "@DATADIR@/edk2-arm-vars.fd",
+"format": "raw"
+}
+},
+"targets": [
+{
+"architecture": "aarch64",
+"machines": [
+"virt-*"
+]
+}
+],
+

Re: [Qemu-devel] Set up github repo for pmon sources

2019-03-16 Thread BALATON Zoltan

On Sat, 16 Mar 2019, Andrew Randrianasulu wrote:

В сообщении от Saturday 16 March 2019 20:53:01 вы написали:

On 3/15/19 9:06 PM, Andrew Randrianasulu wrote:

https://github.com/Randrianasulu/pmon/commits/2014

hopefully it will stay this way.

Anyone know what license I must pick for this?
3-clause BSD? 4-clause BSD? (from Copyright file it lists 4 terms)


4-clause BSD is incompatible with the GPL, and thus cannot be used for
qemu.  (2-clause and 3-clause are okay, though).




*  $Id: Copyright,v 1.1.1.1 2006/09/14 01:59:06 root Exp $ */

/*
 * Copyright (c) 2000-2002 Opsycon AB  (www.opsycon.se)
 * Copyright (c) 2000 Rtmx, Inc   (www.rtmx.com)
 * Copyright (c) 2001 ipUnplugged AB (www.ipunplugged.com)
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *notice, this list of conditions and the following disclaimer in the
 *documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *must display the following acknowledgement:
 *  This product includes software developed for Rtmx, Inc by
 *  Opsycon Open System Consulting AB, Sweden.
 *  This product includes software developed by Opsycon AB.
 *  This product includes software developed by ipUnplugged AB.


Indeed, this is the advertising clause of the 4-clause BSD, which
renders this license unsuitable for use with GPL projects.


Ow. Ok, then I just leave it as-is, github already showing this text as license,
and while qemu as project can't use this firmware - users still can.

Also, there seems to be another pmon branch on github:
https://github.com/jcowgill/pmon-loongson - but I haven't tested it.


And also two more linked from here:
https://www.opsycon.se/pmon2000

Probably there are even more but none with an easy to build pmon.bin for 
fulong2e board I know of, or one that matches the pmon_2e.bin banary 
available which seems to be the original firmware of the board. Therefore 
providing a tested firmware from QEMU would simplify user's life trying 
this board. So at least we could gather this info somewhere on qemu.org.


Regards,
BALATON Zoltan


Morever, what lives in
http://www.anheng.com.cn/loongson/pmon/updates.lemote.com/files/upload/lm/firmware/pmon/source/

seems to be THIRD branch of pmon, at least radeon-specific file is different,
and apparently solved bug I solved independently. (there was confusion between 
Bytes per pixel and Bits per pixel)




 * 4. The name of the author may not be used to endorse or promote products
 *derived from this software without specific prior written permission.
 *










[Qemu-devel] [PULL 12/12] MAINTAINERS: add the "EDK2 Firmware" subsystem

2019-03-16 Thread Philippe Mathieu-Daudé
From: Laszlo Ersek 

We now have the edk2 submodule, somewhat elaborate build helpers for it,
and even a UEFI application written against edk2 whose genuine home is the
QEMU repository. Add the "EDK2 Firmware" subsystem such that all relevant
pathnames be covered.

Suggested-by: Daniel P. Berrangé 
Suggested-by: Michael S. Tsirkin 
Suggested-by: Philippe Mathieu-Daudé 
Signed-off-by: Laszlo Ersek 
Reviewed-by: Michal Privoznik 
Tested-by: Igor Mammedov 
Reviewed-by: Philippe Mathieu-Daudé 
Tested-by: Philippe Mathieu-Daudé 
Reviewed-by: Michael S. Tsirkin 
Message-Id: <20190313210057.32584-13-ler...@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé 
---
 MAINTAINERS | 12 
 1 file changed, 12 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 0e7baa9aa2..0dc4fa9449 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2210,6 +2210,18 @@ F: include/hw/i2c/smbus_master.h
 F: include/hw/i2c/smbus_slave.h
 F: include/hw/i2c/smbus_eeprom.h
 
+EDK2 Firmware
+M: Laszlo Ersek 
+M: Philippe Mathieu-Daudé 
+S: Supported
+F: pc-bios/descriptors/??-edk2-*.json
+F: pc-bios/edk2-*
+F: roms/Makefile.edk2
+F: roms/edk2
+F: roms/edk2-*
+F: tests/data/uefi-boot-images/
+F: tests/uefi-test-tools/
+
 Usermode Emulation
 --
 Overall
-- 
2.20.1




Re: [Qemu-devel] Set up github repo for pmon sources

2019-03-16 Thread BALATON Zoltan

On Sat, 16 Mar 2019, Eric Blake wrote:

On 3/15/19 9:06 PM, Andrew Randrianasulu wrote:

https://github.com/Randrianasulu/pmon/commits/2014

hopefully it will stay this way.

Anyone know what license I must pick for this?
3-clause BSD? 4-clause BSD? (from Copyright file it lists 4 terms)


4-clause BSD is incompatible with the GPL, and thus cannot be used for
qemu.  (2-clause and 3-clause are okay, though).


To clarify, this is the firmware of the mips_fulong2e board. So it's a 
separate project but would make the board work more like the real 
hardware. We don't use code from this firmware in QEMU itself but 
including the firmware binary would make it simpler to run the board. If 
we include a binary we should probably also provide the source (even if 
BSD license does not require that) for convenience in roms, mirrored from 
the above git repo like for other firmwares. Is it still incompatible for 
that? What should be the preferred way then? Can we put the binary and 
source on qemu.org somewhere and link to it so it's not distributed with 
QEMU but still easy to get?


Regards,
BALATON Zoltan






*  $Id: Copyright,v 1.1.1.1 2006/09/14 01:59:06 root Exp $ */

/*
 * Copyright (c) 2000-2002 Opsycon AB  (www.opsycon.se)
 * Copyright (c) 2000 Rtmx, Inc   (www.rtmx.com)
 * Copyright (c) 2001 ipUnplugged AB (www.ipunplugged.com)
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *notice, this list of conditions and the following disclaimer in the
 *documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *must display the following acknowledgement:
 *  This product includes software developed for Rtmx, Inc by
 *  Opsycon Open System Consulting AB, Sweden.
 *  This product includes software developed by Opsycon AB.
 *  This product includes software developed by ipUnplugged AB.


Indeed, this is the advertising clause of the 4-clause BSD, which
renders this license unsuitable for use with GPL projects.


 * 4. The name of the author may not be used to endorse or promote products
 *derived from this software without specific prior written permission.
 *








[Qemu-devel] [PATCH] hw/ppc/prep: Drop useless inclusion of "hw/input/i8042.h"

2019-03-16 Thread Philippe Mathieu-Daudé
In commit 47973a2dbf we split the last generic chipset out of
the PC board, but missed to remove the i8042 keyboard controller.
This omission was later fixed in commit 7cb00357c1, but here we
forgot to remove the "i8042.h" include. Do it now.

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

diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index 847d320465..b7f459d475 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -40,7 +40,6 @@
 #include "hw/ide.h"
 #include "hw/loader.h"
 #include "hw/timer/mc146818rtc.h"
-#include "hw/input/i8042.h"
 #include "hw/isa/pc87312.h"
 #include "hw/net/ne2000-isa.h"
 #include "sysemu/arch_init.h"
-- 
2.20.1




[Qemu-devel] [PATCH 11/14] hw/sparc/Kconfig: SPARCstation machine requires the TCX display

2019-03-16 Thread Philippe Mathieu-Daudé
This is the default display device used in sun4m_hw_init():

/* If no display specified, default to TCX */

This fixes when configuring with --without-default-devices:

  $ sparc-softmmu/qemu-system-sparc
  qemu-system-sparc: Unknown device 'SUNW,tcx' for default sysbus
  Aborted (core dumped)

  (gdb) bt
  #0  0x7fc78d19353f in __GI_raise (sig=sig@entry=6) at 
../sysdeps/unix/sysv/linux/raise.c:50
  #1  0x7fc78d17d895 in __GI_abort () at abort.c:79
  #2  0x560beaf637f3 in qdev_create (bus=bus@entry=0x0, 
name=name@entry=0x560beb1be36b "SUNW,tcx") at hw/core/qdev.c:131
  #3  0x560beaf1392d in tcx_init (vram_size=1048576, width=1024, 
height=768, depth=8, irq=0x560bed1a0230, addr=1342177280) at 
hw/sparc/sun4m.c:477
  #4  0x560beaf1392d in sun4m_hw_init (hwdef=0x560beb1be780 , 
machine=0x560becf65f00) at hw/sparc/sun4m.c:943
  #5  0x560beaf6b15b in machine_run_board_init (machine=0x560becf65f00) at 
hw/core/machine.c:1030
  #6  0x560beae86692 in main (argc=, argv=, 
envp=) at vl.c:4463

Fixes: 8c75eec06d4
Signed-off-by: Philippe Mathieu-Daudé 
---
 default-configs/sparc-softmmu.mak | 1 -
 hw/sparc/Kconfig  | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/default-configs/sparc-softmmu.mak 
b/default-configs/sparc-softmmu.mak
index ee85218115..56509bf263 100644
--- a/default-configs/sparc-softmmu.mak
+++ b/default-configs/sparc-softmmu.mak
@@ -2,7 +2,6 @@
 
 # Uncomment the following lines to disable these optional devices:
 #
-#CONFIG_TCX=n
 #CONFIG_CG3=n
 
 # Boards:
diff --git a/hw/sparc/Kconfig b/hw/sparc/Kconfig
index 2a83a8010e..5383dbd910 100644
--- a/hw/sparc/Kconfig
+++ b/hw/sparc/Kconfig
@@ -1,6 +1,6 @@
 config SUN4M
 bool
-imply TCX
+select TCX
 imply CG3
 select CS4231
 select ECCMEMCTL
-- 
2.20.1




[Qemu-devel] [PATCH 10/14] hw/s390x/Kconfig: s390x machines require virtio-net-ccw device

2019-03-16 Thread Philippe Mathieu-Daudé
This fixes when configuring with --without-default-devices:

  $ qemu-system-s390x
  qemu-system-s390x: Unknown device 'virtio-net-ccw' for bus 'virtual-css-bus'
  Aborted (core dumped)

  (gdb) bt
  #0  0x75a4353f in __GI_raise (sig=sig@entry=6) at 
../sysdeps/unix/sysv/linux/raise.c:50
  #1  0x75a2d895 in __GI_abort () at abort.c:79
  #2  0x557b13b3 in qdev_create (bus=bus@entry=0x55f84600, 
name=name@entry=0x55a07e44 "virtio-net-ccw") at hw/core/qdev.c:131
  #3  0x5572dfed in s390_create_virtio_net (name=0x55a07e44 
"virtio-net-ccw", bus=0x55f84600) at hw/s390x/s390-virtio-ccw.c:234
  #4  0x5572dfed in ccw_init (machine=) at 
hw/s390x/s390-virtio-ccw.c:293
  #5  0x557b838b in machine_run_board_init (machine=0x55e9ce90) at 
hw/core/machine.c:1030
  #6  0x5568bad2 in main (argc=, argv=, 
envp=) at vl.c:4463

Fixes: b42075bb7 and 9e5c2056d1
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/s390x/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/s390x/Kconfig b/hw/s390x/Kconfig
index a7046ea41f..4158bd8497 100644
--- a/hw/s390x/Kconfig
+++ b/hw/s390x/Kconfig
@@ -9,3 +9,4 @@ config S390_CCW_VIRTIO
 select S390_FLIC
 select SCLPCONSOLE
 select VIRTIO_CCW
+select VIRTIO_NET
-- 
2.20.1




[Qemu-devel] [PATCH 13/14] hw/hppa/Kconfig: Dino board requires e1000 network card

2019-03-16 Thread Philippe Mathieu-Daudé
This fixes when configuring with --without-default-devices:

  $ qemu-system-hppa
  qemu-system-hppa: Unsupported NIC model: e1000

Fixes: 9483cf27dd
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/hppa/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/hppa/Kconfig b/hw/hppa/Kconfig
index 2d9b072c21..03d08382cc 100644
--- a/hw/hppa/Kconfig
+++ b/hw/hppa/Kconfig
@@ -2,6 +2,7 @@ config DINO
 bool
 imply PCI_DEVICES
 select PCI
+select E1000_PCI
 select SERIAL
 select ISA_BUS
 select I8259
-- 
2.20.1




[Qemu-devel] [PATCH 05/14] hw/i386/Kconfig: isapc machine requires e1000 network card

2019-03-16 Thread Philippe Mathieu-Daudé
This fixes when configuring with --without-default-devices:

  $ qemu-system-i386
  qemu-system-i386: Unsupported NIC model: e1000

Fixes: 7c28b925b7e
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/i386/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig
index 55c061a077..3414d1c3d6 100644
--- a/hw/i386/Kconfig
+++ b/hw/i386/Kconfig
@@ -69,6 +69,7 @@ config ISAPC
 # FIXME: it is in the same file as i440fx, and does not compile
 # if separated
 depends on I440FX
+select E1000_PCI
 select VGA_PCI
 
 config Q35
-- 
2.20.1




[Qemu-devel] [PATCH 14/14] hw/alpha/Kconfig: DP264 hardware requires e1000 network card

2019-03-16 Thread Philippe Mathieu-Daudé
This fixes when configuring with --without-default-devices:
  $ qemu-system-alpha
  qemu-system-alpha: Unsupported NIC model: e1000

Fixes: d1a95ef4ac
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/alpha/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/alpha/Kconfig b/hw/alpha/Kconfig
index 22cefd9577..b7b707e558 100644
--- a/hw/alpha/Kconfig
+++ b/hw/alpha/Kconfig
@@ -1,6 +1,7 @@
 config DP264
 bool
 imply PCI_DEVICES
+select E1000_PCI
 imply TEST_DEVICES
 select I82374
 select I8254
-- 
2.20.1




[Qemu-devel] [PATCH 07/14] hw/mips/Kconfig: Fulong 2e board requires ati-vga/rtl8139 PCI devices

2019-03-16 Thread Philippe Mathieu-Daudé
This fixes when configuring with --without-default-devices:

  $ qemu-system-mips64el -bios /dev/null -M fulong2e
  qemu-system-mips64el: Unknown device 'ati-vga' for bus 'PCI'
  Aborted (core dumped)

  (gdb) bt
  #0  0x75a2753f in __GI_raise (sig=sig@entry=6) at 
../sysdeps/unix/sysv/linux/raise.c:50
  #1  0x75a11895 in __GI_abort () at abort.c:79
  #2  0x558768d3 in qdev_create (bus=bus@entry=0x562664b0, 
name=name@entry=0x55b24efb "ati-vga") at hw/core/qdev.c:131
  #3  0x558d15e1 in pci_create_multifunction 
(bus=bus@entry=0x562664b0, devfn=devfn@entry=-1, 
multifunction=multifunction@entry=false, name=name@entry=0x55b24efb 
"ati-vga") at hw/pci/pci.c:2104
  #4  0x558d1a7a in pci_create (bus=bus@entry=0x562664b0, 
devfn=devfn@entry=-1, name=name@entry=0x55b24efb "ati-vga") at 
hw/pci/pci.c:2121
  #5  0x55763081 in mips_fulong2e_init (machine=) at 
hw/mips/mips_fulong2e.c:352
  #6  0x5587e23b in machine_run_board_init (machine=0x560b2000) at 
hw/core/machine.c:1030
  #7  0x556cbea2 in main (argc=, argv=, 
envp=) at vl.c:4463

And then:

  $ qemu-system-mips64el -bios /dev/null -M fulong2e
  qemu-system-mips64el: Unsupported NIC model: rtl8139

Fixes: 862b4a291dc and 7c28b925b7e
Signed-off-by: Philippe Mathieu-Daudé 
---
 default-configs/mips64el-softmmu.mak | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/default-configs/mips64el-softmmu.mak 
b/default-configs/mips64el-softmmu.mak
index 8b255efc54..a67c9517a2 100644
--- a/default-configs/mips64el-softmmu.mak
+++ b/default-configs/mips64el-softmmu.mak
@@ -6,6 +6,8 @@ CONFIG_RC4030=y
 CONFIG_DP8393X=y
 CONFIG_DS1225Y=y
 CONFIG_FULONG=y
+CONFIG_ATI_VGA=y
+CONFIG_RTL8139_PCI=y
 CONFIG_JAZZ=y
 CONFIG_G364FB=y
 CONFIG_JAZZ_LED=y
-- 
2.20.1




[Qemu-devel] [PATCH 09/14] hw/ppc/Kconfig: e500 based machines require virtio-net-pci device

2019-03-16 Thread Philippe Mathieu-Daudé
This fixes when configuring with --without-default-devices:

  $ qemu-system-ppc64 -bios /dev/null -M ppce500
  qemu-system-ppc64: Unsupported NIC model: virtio-net-pci

And:

  $ qemu-system-ppc64 -bios /dev/null -M mpc8544ds
  qemu-system-ppc64: Unsupported NIC model: virtio-net-pci

Fixes: 98bd1db99f
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/ppc/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/ppc/Kconfig b/hw/ppc/Kconfig
index 2f2b21097b..8a2772ee6e 100644
--- a/hw/ppc/Kconfig
+++ b/hw/ppc/Kconfig
@@ -103,6 +103,7 @@ config E500
 select PLATFORM_BUS
 select PPCE500_PCI
 select SERIAL
+select VIRTIO
 
 config VIRTEX
 bool
-- 
2.20.1




[Qemu-devel] [PATCH 03/14] hw/i386/Kconfig: Q35 machine requires e1000e network card

2019-03-16 Thread Philippe Mathieu-Daudé
This fixes when configuring with --without-default-devices:

  $ qemu-system-x86_64 -M q35
  qemu-system-x86_64: Unsupported NIC model: e1000e

Fixes: 7c28b925b7e
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/i386/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig
index 78fd70396a..66b435e020 100644
--- a/hw/i386/Kconfig
+++ b/hw/i386/Kconfig
@@ -77,6 +77,7 @@ config Q35
 select PC_PCI
 select PC_ACPI
 select PCI_EXPRESS_Q35
+select E1000E_PCI_EXPRESS
 select LPC_ICH9
 select AHCI
 select DIMM
-- 
2.20.1




[Qemu-devel] [PATCH 06/14] hw/mips/Kconfig: Malta machine requires the pcnet network card

2019-03-16 Thread Philippe Mathieu-Daudé
This fixes when configuring with --without-default-devices:

  $ qemu-system-mips64 -bios /dev/null -M malta
  qemu-system-mips64: Unsupported NIC model: pcnet

Fixes: 7c28b925b7e
Signed-off-by: Philippe Mathieu-Daudé 
---
 default-configs/mips-softmmu-common.mak | 1 +
 1 file changed, 1 insertion(+)

diff --git a/default-configs/mips-softmmu-common.mak 
b/default-configs/mips-softmmu-common.mak
index 0795d522db..8e54a74b7a 100644
--- a/default-configs/mips-softmmu-common.mak
+++ b/default-configs/mips-softmmu-common.mak
@@ -35,6 +35,7 @@ CONFIG_MIPS_CPS=y
 CONFIG_MIPS_ITU=y
 CONFIG_R4K=y
 CONFIG_MALTA=y
+CONFIG_PCNET_PCI=y
 CONFIG_MIPSSIM=y
 CONFIG_ACPI_SMBUS=y
 CONFIG_SMBUS_EEPROM=y
-- 
2.20.1




[Qemu-devel] [PATCH 12/14] hw/sh4/Kconfig: r2d machine requires the rtl8139 network card

2019-03-16 Thread Philippe Mathieu-Daudé
This fixes when configuring with --without-default-devices:

  $ qemu-system-sh4 -M r2d
  qemu-system-sh4: Unsupported NIC model: rtl8139

Fixes: 7ab58d4c84
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/sh4/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/sh4/Kconfig b/hw/sh4/Kconfig
index 8597613a35..1ee55726e4 100644
--- a/hw/sh4/Kconfig
+++ b/hw/sh4/Kconfig
@@ -7,6 +7,7 @@ config R2D
 select PFLASH_CFI02
 select USB_OHCI
 select PCI
+select RTL8139_PCI
 select SM501
 select SH4
 
-- 
2.20.1




[Qemu-devel] [PATCH 08/14] hw/ppc/Kconfig: Bamboo machine requires e1000 network card

2019-03-16 Thread Philippe Mathieu-Daudé
This fixes when configuring with --without-default-devices:

  $ qemu-system-ppc64 -bios /dev/null -M bamboo
  qemu-system-ppc64: Unsupported NIC model: e1000

Fixes: 7c28b925b7e
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/ppc/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/ppc/Kconfig b/hw/ppc/Kconfig
index 2b83637511..2f2b21097b 100644
--- a/hw/ppc/Kconfig
+++ b/hw/ppc/Kconfig
@@ -37,6 +37,7 @@ config PPC440
 imply PCI_DEVICES
 imply TEST_DEVICES
 select PCI_EXPRESS
+select E1000_PCI
 select PPC4XX
 select SERIAL
 
-- 
2.20.1




[Qemu-devel] [PATCH 04/14] hw/i386/Kconfig: isapc machine requires VGA display

2019-03-16 Thread Philippe Mathieu-Daudé
This fixes when configuring with --without-default-devices:

  $ qemu-system-x86_64
  qemu-system-x86_64: Unknown device 'VGA' for bus 'PCI'
  Aborted (core dumped)

  (gdb) bt
  #0  0x75a2753f in __GI_raise (sig=sig@entry=6) at 
../sysdeps/unix/sysv/linux/raise.c:50
  #1  0x75a11895 in __GI_abort () at abort.c:79
  #2  0x5581dbc3 in qdev_create (bus=0x562f6be0, 
name=0x55ab048e "VGA") at hw/core/qdev.c:131
  #3  0x558510d1 in pci_create_multifunction (bus=, 
devfn=devfn@entry=-1, multifunction=multifunction@entry=false, name=) at hw/pci/pci.c:2104
  #4  0x558514e3 in pci_create_simple_multifunction (name=, multifunction=, devfn=, bus=) at hw/pci/pci.c:2126
  #5  0x558514e3 in pci_create_simple (name=, 
devfn=, bus=) at hw/pci/pci.c:2126
  #6  0x558514e3 in pci_vga_init (bus=bus@entry=0x562f6be0) at 
hw/pci/pci.c:1939
  #7  0x5573bc23 in pc_vga_init (isa_bus=0x55f44360, 
pci_bus=0x562f6be0) at hw/i386/pc.c:1888
  #8  0x5573e291 in pc_init1 (machine=0x55fc3a60, 
pci_type=0x55a9e60f "i440FX", host_type=0x55a9d64c "i440FX-pcihost") at 
hw/i386/pc_piix.c:233
  #9  0x55824b9b in machine_run_board_init (machine=0x55fc3a60) at 
hw/core/machine.c:1030
  #10 0x55695602 in main (argc=, argv=, 
envp=) at vl.c:4463

Fixes: 7c28b925b7e
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/i386/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig
index 66b435e020..55c061a077 100644
--- a/hw/i386/Kconfig
+++ b/hw/i386/Kconfig
@@ -69,6 +69,7 @@ config ISAPC
 # FIXME: it is in the same file as i440fx, and does not compile
 # if separated
 depends on I440FX
+select VGA_PCI
 
 config Q35
 bool
-- 
2.20.1




[Qemu-devel] [PATCH 02/14] hw/isa/Kconfig: i82378 SuperIO requires PC speaker device

2019-03-16 Thread Philippe Mathieu-Daudé
This fixes when configuring with --without-default-devices:

  $ qemu-system-ppc -M prep
  qemu-system-ppc: Machine type 'prep' is deprecated: use 40p machine type 
instead
  qemu-system-ppc: Unknown device 'isa-pcspk' for bus 'ISA'

Fixes: dd0ff8191ab
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/isa/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/isa/Kconfig b/hw/isa/Kconfig
index c942b47d03..6db0d7970c 100644
--- a/hw/isa/Kconfig
+++ b/hw/isa/Kconfig
@@ -11,6 +11,7 @@ config I82378
 select I8254
 select I82374
 select MC146818RTC
+select PCSPK
 
 config PC87312
 bool
-- 
2.20.1




[Qemu-devel] [PATCH 01/14] hw/isa/Kconfig: PIIX4 southbridge requires USB UHCI

2019-03-16 Thread Philippe Mathieu-Daudé
This fixes when configuring with --without-default-devices:

  $ qemu-system-mips64 -bios /dev/null -M malta
  qemu-system-mips64: Unknown device 'piix4-usb-uhci' for bus 'PCI'

Fixes: 7c28b925b7e
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/isa/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/isa/Kconfig b/hw/isa/Kconfig
index 57e09a0cb8..c942b47d03 100644
--- a/hw/isa/Kconfig
+++ b/hw/isa/Kconfig
@@ -29,6 +29,7 @@ config PIIX4
 # For historical reasons, SuperIO devices are created in the board
 # for PIIX4.
 select ISA_BUS
+select USB_UHCI
 
 config VT82C686
 bool
-- 
2.20.1




[Qemu-devel] [PATCH 00/14] hw/Kconfig: Fixes when running ./configure --without-default-devices

2019-03-16 Thread Philippe Mathieu-Daudé
Hi,

This series contains Kconfig fixes to be able to run binaries
built using: './configure --without-default-devices'.

Regards,

Phil.

Philippe Mathieu-Daudé (14):
  hw/isa/Kconfig: PIIX4 southbridge requires USB UHCI
  hw/isa/Kconfig: i82378 SuperIO requires PC speaker device
  hw/i386/Kconfig: Q35 machine requires e1000e network card
  hw/i386/Kconfig: isapc machine requires VGA display
  hw/i386/Kconfig: isapc machine requires e1000 network card
  hw/mips/Kconfig: Malta machine requires the pcnet network card
  hw/mips/Kconfig: Fulong 2e board requires ati-vga/rtl8139 PCI devices
  hw/ppc/Kconfig: Bamboo machine requires e1000 network card
  hw/ppc/Kconfig: e500 based machines require virtio-net-pci device
  hw/s390x/Kconfig: s390x machines require virtio-net-ccw device
  hw/sparc/Kconfig: SPARCstation machine requires the TCX display
  hw/sh4/Kconfig: r2d machine requires the rtl8139 network card
  hw/hppa/Kconfig: Dino board requires e1000 network card
  hw/alpha/Kconfig: DP264 hardware requires e1000 network card

 default-configs/mips-softmmu-common.mak | 1 +
 default-configs/mips64el-softmmu.mak| 2 ++
 default-configs/sparc-softmmu.mak   | 1 -
 hw/alpha/Kconfig| 1 +
 hw/hppa/Kconfig | 1 +
 hw/i386/Kconfig | 3 +++
 hw/isa/Kconfig  | 2 ++
 hw/ppc/Kconfig  | 2 ++
 hw/s390x/Kconfig| 1 +
 hw/sh4/Kconfig  | 1 +
 hw/sparc/Kconfig| 2 +-
 11 files changed, 15 insertions(+), 2 deletions(-)

-- 
2.20.1




Re: [Qemu-devel] Set up github repo for pmon sources

2019-03-16 Thread Andrew Randrianasulu
В сообщении от Saturday 16 March 2019 20:53:01 вы написали:
> On 3/15/19 9:06 PM, Andrew Randrianasulu wrote:
> > https://github.com/Randrianasulu/pmon/commits/2014
> > 
> > hopefully it will stay this way.
> > 
> > Anyone know what license I must pick for this?
> > 3-clause BSD? 4-clause BSD? (from Copyright file it lists 4 terms)
> 
> 4-clause BSD is incompatible with the GPL, and thus cannot be used for
> qemu.  (2-clause and 3-clause are okay, though).
> 
> > 
> > 
> > *  $Id: Copyright,v 1.1.1.1 2006/09/14 01:59:06 root Exp $ */
> > 
> > /*
> >  * Copyright (c) 2000-2002 Opsycon AB  (www.opsycon.se)
> >  * Copyright (c) 2000 Rtmx, Inc   (www.rtmx.com)
> >  * Copyright (c) 2001 ipUnplugged AB (www.ipunplugged.com)
> >  *
> >  * Redistribution and use in source and binary forms, with or without
> >  * modification, are permitted provided that the following conditions
> >  * are met:
> >  * 1. Redistributions of source code must retain the above copyright
> >  *notice, this list of conditions and the following disclaimer.
> >  * 2. Redistributions in binary form must reproduce the above copyright
> >  *notice, this list of conditions and the following disclaimer in the
> >  *documentation and/or other materials provided with the distribution.
> >  * 3. All advertising materials mentioning features or use of this software
> >  *must display the following acknowledgement:
> >  *  This product includes software developed for Rtmx, Inc by
> >  *  Opsycon Open System Consulting AB, Sweden.
> >  *  This product includes software developed by Opsycon AB.
> >  *  This product includes software developed by ipUnplugged AB.
> 
> Indeed, this is the advertising clause of the 4-clause BSD, which
> renders this license unsuitable for use with GPL projects.

Ow. Ok, then I just leave it as-is, github already showing this text as 
license, 
and while qemu as project can't use this firmware - users still can.

Also, there seems to be another pmon branch on github:
https://github.com/jcowgill/pmon-loongson - but I haven't tested it.

Morever, what lives in 
http://www.anheng.com.cn/loongson/pmon/updates.lemote.com/files/upload/lm/firmware/pmon/source/

seems to be THIRD branch of pmon, at least radeon-specific file is different, 
and apparently solved bug I solved independently. (there was confusion between 
Bytes per pixel and Bits per pixel)

> 
> >  * 4. The name of the author may not be used to endorse or promote products
> >  *derived from this software without specific prior written permission.
> >  *
> 
> 





Re: [Qemu-devel] Set up github repo for pmon sources

2019-03-16 Thread Eric Blake
On 3/15/19 9:06 PM, Andrew Randrianasulu wrote:
> https://github.com/Randrianasulu/pmon/commits/2014
> 
> hopefully it will stay this way.
> 
> Anyone know what license I must pick for this?
> 3-clause BSD? 4-clause BSD? (from Copyright file it lists 4 terms)

4-clause BSD is incompatible with the GPL, and thus cannot be used for
qemu.  (2-clause and 3-clause are okay, though).

> 
> 
> *  $Id: Copyright,v 1.1.1.1 2006/09/14 01:59:06 root Exp $ */
> 
> /*
>  * Copyright (c) 2000-2002 Opsycon AB  (www.opsycon.se)
>  * Copyright (c) 2000 Rtmx, Inc   (www.rtmx.com)
>  * Copyright (c) 2001 ipUnplugged AB (www.ipunplugged.com)
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  * 1. Redistributions of source code must retain the above copyright
>  *notice, this list of conditions and the following disclaimer.
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *notice, this list of conditions and the following disclaimer in the
>  *documentation and/or other materials provided with the distribution.
>  * 3. All advertising materials mentioning features or use of this software
>  *must display the following acknowledgement:
>  *  This product includes software developed for Rtmx, Inc by
>  *  Opsycon Open System Consulting AB, Sweden.
>  *  This product includes software developed by Opsycon AB.
>  *  This product includes software developed by ipUnplugged AB.

Indeed, this is the advertising clause of the 4-clause BSD, which
renders this license unsuitable for use with GPL projects.

>  * 4. The name of the author may not be used to endorse or promote products
>  *derived from this software without specific prior written permission.
>  *


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



signature.asc
Description: OpenPGP digital signature


[Qemu-devel] [PULL 1/2] target/hppa: Avoid squishing DISAS_IAQ_N_STALE_EXIT

2019-03-16 Thread Richard Henderson
Within a delay slot, we were squishing both DISAS_IAQ_N_STALE and
DISAS_IAQ_N_STALE_EXIT to DISAS_IAQ_N_UPDATED.  This lost the
required exit to the main loop, and could result in interrupts
never being delivered.

Tested-by: Sven Schnelle 
Reported-by: Sven Schnelle 
Signed-off-by: Richard Henderson 
---
 target/hppa/translate.c | 42 +++--
 1 file changed, 28 insertions(+), 14 deletions(-)

diff --git a/target/hppa/translate.c b/target/hppa/translate.c
index 35c504087f..43b74367ea 100644
--- a/target/hppa/translate.c
+++ b/target/hppa/translate.c
@@ -347,6 +347,7 @@ static int expand_shl11(int val)
 /* Similarly, but we want to return to the main loop immediately
to recognize unmasked interrupts.  */
 #define DISAS_IAQ_N_STALE_EXIT  DISAS_TARGET_2
+#define DISAS_EXIT  DISAS_TARGET_3
 
 /* global register indexes */
 static TCGv_reg cpu_gr[32];
@@ -4218,19 +4219,31 @@ static void hppa_tr_translate_insn(DisasContextBase 
*dcbase, CPUState *cs)
 ctx->iaoq_b = ctx->iaoq_n;
 ctx->base.pc_next += 4;
 
-if (ret == DISAS_NORETURN || ret == DISAS_IAQ_N_UPDATED) {
-return;
-}
-if (ctx->iaoq_f == -1) {
-tcg_gen_mov_reg(cpu_iaoq_f, cpu_iaoq_b);
-copy_iaoq_entry(cpu_iaoq_b, ctx->iaoq_n, ctx->iaoq_n_var);
+switch (ret) {
+case DISAS_NORETURN:
+case DISAS_IAQ_N_UPDATED:
+break;
+
+case DISAS_NEXT:
+case DISAS_IAQ_N_STALE:
+case DISAS_IAQ_N_STALE_EXIT:
+if (ctx->iaoq_f == -1) {
+tcg_gen_mov_reg(cpu_iaoq_f, cpu_iaoq_b);
+copy_iaoq_entry(cpu_iaoq_b, ctx->iaoq_n, ctx->iaoq_n_var);
 #ifndef CONFIG_USER_ONLY
-tcg_gen_mov_i64(cpu_iasq_f, cpu_iasq_b);
+tcg_gen_mov_i64(cpu_iasq_f, cpu_iasq_b);
 #endif
-nullify_save(ctx);
-ctx->base.is_jmp = DISAS_IAQ_N_UPDATED;
-} else if (ctx->iaoq_b == -1) {
-tcg_gen_mov_reg(cpu_iaoq_b, ctx->iaoq_n_var);
+nullify_save(ctx);
+ctx->base.is_jmp = (ret == DISAS_IAQ_N_STALE_EXIT
+? DISAS_EXIT
+: DISAS_IAQ_N_UPDATED);
+} else if (ctx->iaoq_b == -1) {
+tcg_gen_mov_reg(cpu_iaoq_b, ctx->iaoq_n_var);
+}
+break;
+
+default:
+g_assert_not_reached();
 }
 }
 
@@ -4252,11 +4265,12 @@ static void hppa_tr_tb_stop(DisasContextBase *dcbase, 
CPUState *cs)
 case DISAS_IAQ_N_UPDATED:
 if (ctx->base.singlestep_enabled) {
 gen_excp_1(EXCP_DEBUG);
-} else if (is_jmp == DISAS_IAQ_N_STALE_EXIT) {
-tcg_gen_exit_tb(NULL, 0);
-} else {
+} else if (is_jmp != DISAS_IAQ_N_STALE_EXIT) {
 tcg_gen_lookup_and_goto_ptr();
 }
+/* FALLTHRU */
+case DISAS_EXIT:
+tcg_gen_exit_tb(NULL, 0);
 break;
 default:
 g_assert_not_reached();
-- 
2.17.2




[Qemu-devel] [PULL for-4.0 0/2] target/hppa last fixes

2019-03-16 Thread Richard Henderson
The following changes since commit 8b088d3f8ab5642020d28fa0c2a8d938bc5f3592:

  Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20190315' 
into staging (2019-03-15 11:39:42 +)

are available in the Git repository at:

  https://github.com/rth7680/qemu.git tags/pull-hppa-20190316

for you to fetch changes up to 2b42f31eae2c24507c38326b3534cd9292e7dfcf:

  Update seabios-hppa to latest upstream (2019-03-15 10:11:16 -0700)


Fix lost interrupts.
Update seabios-hppa.


Helge Deller (1):
  Update seabios-hppa to latest upstream

Richard Henderson (1):
  target/hppa: Avoid squishing DISAS_IAQ_N_STALE_EXIT

 hw/hppa/hppa_hardware.h   |   4 ++--
 target/hppa/translate.c   |  42 --
 pc-bios/hppa-firmware.img | Bin 760040 -> 783724 bytes
 roms/seabios-hppa |   2 +-
 4 files changed, 31 insertions(+), 17 deletions(-)



Re: [Qemu-devel] [PATCH v2 00/12] bundle edk2 platform firmware with QEMU

2019-03-16 Thread Michael Tokarev

14.03.2019 0:00, Laszlo Ersek wrote:

Repo:   https://github.com/lersek/qemu.git
Branch: edk2_build_v2

Version 1, that is:
   [Qemu-devel] [PATCH 00/10] bundle edk2 platform firmware with QEMU

...

Hmm. Why to do so? Isn't the goal was to REMOVE current
ROM sources from qemu in favor of external projects?

Thanks,

/mjt



Re: [Qemu-devel] [PATCH v3 0/8] slirp: clarify license of slirp as BSD-3

2019-03-16 Thread Samuel Thibault
Eric Blake, le jeu. 14 mars 2019 08:44:06 -0500, a ecrit:
> However, while it does not affect compilation, it DOES have legal
> ramification; I'd feel a lot better about having R-b on every patch,

Sure, I was just asking for the git commit path :) I don't think it's
useful to make it go through my tree.

Samuel



[Qemu-devel] [PATCH PULL 17/18] hw/pvrdma: Fix zero-initialization of resp in {query/modify}_qp

2019-03-16 Thread Marcel Apfelbaum
From: Kamal Heib 

Make sure to zero-initialize only the pvrdma_cmd_query_qp_resp and not
the whole pvrdma_cmd_resp for query_qp, in modify_qp the resp isn't used
so remove it.

Reviewed-by: Yuval Shaia 
Signed-off-by: Kamal Heib 
Message-Id: <20190314153031.7197-5-kamalhe...@gmail.com>
Signed-off-by: Marcel Apfelbaum 
---
 hw/rdma/vmw/pvrdma_cmd.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/hw/rdma/vmw/pvrdma_cmd.c b/hw/rdma/vmw/pvrdma_cmd.c
index b682e919d5..be8c2b61c9 100644
--- a/hw/rdma/vmw/pvrdma_cmd.c
+++ b/hw/rdma/vmw/pvrdma_cmd.c
@@ -488,8 +488,6 @@ static int modify_qp(PVRDMADev *dev, union pvrdma_cmd_req 
*req,
 struct pvrdma_cmd_modify_qp *cmd = >modify_qp;
 int rc;
 
-memset(rsp, 0, sizeof(*rsp));
-
 /* No need to verify sgid_index since it is u8 */
 
 rc = rdma_rm_modify_qp(>rdma_dev_res, >backend_dev,
@@ -512,7 +510,7 @@ static int query_qp(PVRDMADev *dev, union pvrdma_cmd_req 
*req,
 struct ibv_qp_init_attr init_attr;
 int rc;
 
-memset(rsp, 0, sizeof(*rsp));
+memset(resp, 0, sizeof(*resp));
 
 rc = rdma_rm_query_qp(>rdma_dev_res, >backend_dev, 
cmd->qp_handle,
   (struct ibv_qp_attr *)>attrs, cmd->attr_mask,
-- 
2.17.1




[Qemu-devel] [PATCH PULL 02/18] hw/rdma: Switch to generic error reporting way

2019-03-16 Thread Marcel Apfelbaum
From: Yuval Shaia 

Utilize error_report for all pr_err calls and some pr_dbg that are
considered as errors.
For the remaining pr_dbg calls, the important ones were replaced by
trace points while other deleted.
Some of the functions got renamed to include prefix "rdma/pvrdma"
in the function name.

Signed-off-by: Yuval Shaia 
Reviewed-by: Marcel Apfelbaum 
Message-Id: <1552300155-25216-2-git-send-email-yuval.sh...@oracle.com>
Reviewed-by: Kamal Heib 
Signed-off-by: Marcel Apfelbaum 
---
 hw/rdma/rdma_backend.c| 354 ++
 hw/rdma/rdma_backend.h|   4 +-
 hw/rdma/rdma_rm.c | 130 +
 hw/rdma/rdma_rm.h |  10 +-
 hw/rdma/rdma_utils.c  |  15 +-
 hw/rdma/rdma_utils.h  |  45 +
 hw/rdma/trace-events  |  32 ++-
 hw/rdma/vmw/pvrdma.h  |   2 +-
 hw/rdma/vmw/pvrdma_cmd.c  | 113 +++
 hw/rdma/vmw/pvrdma_dev_ring.c |  26 +--
 hw/rdma/vmw/pvrdma_main.c | 144 +-
 hw/rdma/vmw/pvrdma_qp_ops.c   |  49 ++---
 hw/rdma/vmw/trace-events  |  16 +-
 13 files changed, 363 insertions(+), 577 deletions(-)

diff --git a/hw/rdma/rdma_backend.c b/hw/rdma/rdma_backend.c
index fd571f21e5..d138591c86 100644
--- a/hw/rdma/rdma_backend.c
+++ b/hw/rdma/rdma_backend.c
@@ -14,7 +14,6 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu/error-report.h"
 #include "sysemu/sysemu.h"
 #include "qapi/error.h"
 #include "qapi/qmp/qlist.h"
@@ -39,7 +38,6 @@
 
 typedef struct BackendCtx {
 void *up_ctx;
-bool is_tx_req;
 struct ibv_sge sge; /* Used to save MAD recv buffer */
 } BackendCtx;
 
@@ -52,7 +50,7 @@ static void (*comp_handler)(void *ctx, struct ibv_wc *wc);
 
 static void dummy_comp_handler(void *ctx, struct ibv_wc *wc)
 {
-pr_err("No completion handler is registered\n");
+rdma_error_report("No completion handler is registered");
 }
 
 static inline void complete_work(enum ibv_wc_status status, uint32_t 
vendor_err,
@@ -66,29 +64,24 @@ static inline void complete_work(enum ibv_wc_status status, 
uint32_t vendor_err,
 comp_handler(ctx, );
 }
 
-static void poll_cq(RdmaDeviceResources *rdma_dev_res, struct ibv_cq *ibcq)
+static void rdma_poll_cq(RdmaDeviceResources *rdma_dev_res, struct ibv_cq 
*ibcq)
 {
 int i, ne;
 BackendCtx *bctx;
 struct ibv_wc wc[2];
 
-pr_dbg("Entering poll_cq loop on cq %p\n", ibcq);
 do {
 ne = ibv_poll_cq(ibcq, ARRAY_SIZE(wc), wc);
 
-pr_dbg("Got %d completion(s) from cq %p\n", ne, ibcq);
+trace_rdma_poll_cq(ne, ibcq);
 
 for (i = 0; i < ne; i++) {
-pr_dbg("wr_id=0x%" PRIx64 "\n", wc[i].wr_id);
-pr_dbg("status=%d\n", wc[i].status);
-
 bctx = rdma_rm_get_cqe_ctx(rdma_dev_res, wc[i].wr_id);
 if (unlikely(!bctx)) {
-pr_dbg("Error: Failed to find ctx for req %" PRId64 "\n",
-   wc[i].wr_id);
+rdma_error_report("No matching ctx for req %"PRId64,
+  wc[i].wr_id);
 continue;
 }
-pr_dbg("Processing %s CQE\n", bctx->is_tx_req ? "send" : "recv");
 
 comp_handler(bctx->up_ctx, [i]);
 
@@ -98,7 +91,7 @@ static void poll_cq(RdmaDeviceResources *rdma_dev_res, struct 
ibv_cq *ibcq)
 } while (ne > 0);
 
 if (ne < 0) {
-pr_dbg("Got error %d from ibv_poll_cq\n", ne);
+rdma_error_report("ibv_poll_cq fail, rc=%d, errno=%d", ne, errno);
 }
 }
 
@@ -115,12 +108,10 @@ static void *comp_handler_thread(void *arg)
 flags = fcntl(backend_dev->channel->fd, F_GETFL);
 rc = fcntl(backend_dev->channel->fd, F_SETFL, flags | O_NONBLOCK);
 if (rc < 0) {
-pr_dbg("Fail to change to non-blocking mode\n");
+rdma_error_report("Failed to change backend channel FD to 
non-blocking");
 return NULL;
 }
 
-pr_dbg("Starting\n");
-
 pfds[0].fd = backend_dev->channel->fd;
 pfds[0].events = G_IO_IN | G_IO_HUP | G_IO_ERR;
 
@@ -132,27 +123,25 @@ static void *comp_handler_thread(void *arg)
 } while (!rc && backend_dev->comp_thread.run);
 
 if (backend_dev->comp_thread.run) {
-pr_dbg("Waiting for completion on channel %p\n", 
backend_dev->channel);
 rc = ibv_get_cq_event(backend_dev->channel, _cq, _ctx);
-pr_dbg("ibv_get_cq_event=%d\n", rc);
 if (unlikely(rc)) {
-pr_dbg("---> ibv_get_cq_event (%d)\n", rc);
+rdma_error_report("ibv_get_cq_event fail, rc=%d, errno=%d", rc,
+  errno);
 continue;
 }
 
 rc = ibv_req_notify_cq(ev_cq, 0);
 if (unlikely(rc)) {
-pr_dbg("Error %d from ibv_req_notify_cq\n", rc);
+rdma_error_report("ibv_req_notify_cq fail, rc=%d, errno=%d", 
rc,
+  errno);
 }
 
-poll_cq(backend_dev->rdma_dev_res, ev_cq);
+ 

[Qemu-devel] [PATCH PULL 14/18] hw/rdma: Fix broken paths to docs/devel/tracing.txt

2019-03-16 Thread Marcel Apfelbaum
From: Kamal Heib 

The tracing.txt file is under "docs/devel" and not "docs".

Reviewed-by: Yuval Shaia 
Signed-off-by: Kamal Heib 
Message-Id: <20190314153031.7197-2-kamalhe...@gmail.com>
Signed-off-by: Marcel Apfelbaum 
---
 hw/rdma/trace-events | 2 +-
 hw/rdma/vmw/trace-events | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/rdma/trace-events b/hw/rdma/trace-events
index 0fad56c882..12868d8a87 100644
--- a/hw/rdma/trace-events
+++ b/hw/rdma/trace-events
@@ -1,4 +1,4 @@
-# See docs/tracing.txt for syntax documentation.
+# See docs/devel/tracing.txt for syntax documentation.
 
 # hw/rdma/rdma_backend.c
 rdma_check_dev_attr(const char *name, int max_bk, int max_fe) "%s: be=%d, 
fe=%d"
diff --git a/hw/rdma/vmw/trace-events b/hw/rdma/vmw/trace-events
index 0122266ad7..e846d54359 100644
--- a/hw/rdma/vmw/trace-events
+++ b/hw/rdma/vmw/trace-events
@@ -1,4 +1,4 @@
-# See docs/tracing.txt for syntax documentation.
+# See docs/devel/tracing.txt for syntax documentation.
 
 # hw/rdma/vmw/pvrdma_main.c
 pvrdma_regs_read(uint64_t addr, uint64_t val) 
"pvrdma.regs[0x%"PRIx64"]=0x%"PRIx64
-- 
2.17.1




[Qemu-devel] [PATCH PULL 18/18] hw/rdma: Fix the error prints in create_qp_rings()

2019-03-16 Thread Marcel Apfelbaum
From: Kamal Heib 

The prints should indicate that we are talking about QP and not CQ.

Fixes: 98d176f8e592 ("hw/rdma: PVRDMA commands and data-path ops")
Reviewed-by: Yuval Shaia 
Signed-off-by: Kamal Heib 
Message-Id: <20190227085546.23690-1-kamalhe...@gmail.com>
Signed-off-by: Marcel Apfelbaum 
---
 hw/rdma/vmw/pvrdma_cmd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/rdma/vmw/pvrdma_cmd.c b/hw/rdma/vmw/pvrdma_cmd.c
index be8c2b61c9..4afcd2037d 100644
--- a/hw/rdma/vmw/pvrdma_cmd.c
+++ b/hw/rdma/vmw/pvrdma_cmd.c
@@ -374,13 +374,13 @@ static int create_qp_rings(PCIDevice *pci_dev, uint64_t 
pdir_dma,
 
 dir = rdma_pci_dma_map(pci_dev, pdir_dma, TARGET_PAGE_SIZE);
 if (!dir) {
-rdma_error_report("Failed to map to CQ page directory");
+rdma_error_report("Failed to map to QP page directory");
 goto out;
 }
 
 tbl = rdma_pci_dma_map(pci_dev, dir[0], TARGET_PAGE_SIZE);
 if (!tbl) {
-rdma_error_report("Failed to map to CQ page table");
+rdma_error_report("Failed to map to QP page table");
 goto out;
 }
 
@@ -393,7 +393,7 @@ static int create_qp_rings(PCIDevice *pci_dev, uint64_t 
pdir_dma,
 sr->ring_state = (struct pvrdma_ring *)
 rdma_pci_dma_map(pci_dev, tbl[0], TARGET_PAGE_SIZE);
 if (!sr->ring_state) {
-rdma_error_report("Failed to map to CQ ring state");
+rdma_error_report("Failed to map to QP ring state");
 goto out_free_sr_mem;
 }
 
-- 
2.17.1




[Qemu-devel] [PATCH PULL 15/18] hw/rdma: Remove unused parameter from rdma_poll_cq()

2019-03-16 Thread Marcel Apfelbaum
From: Kamal Heib 

The 'rdma_dev_res' parameter is not used in rdma_poll_cq(), so remove it.

Reviewed-by: Yuval Shaia 
Reviewed-by: Marcel Apfelbaum 
Signed-off-by: Kamal Heib 
Message-Id: <20190314153031.7197-3-kamalhe...@gmail.com>
Signed-off-by: Marcel Apfelbaum 
---
 hw/rdma/rdma_backend.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/hw/rdma/rdma_backend.c b/hw/rdma/rdma_backend.c
index 89279e66e7..90983d2846 100644
--- a/hw/rdma/rdma_backend.c
+++ b/hw/rdma/rdma_backend.c
@@ -94,8 +94,7 @@ static void clean_recv_mads(RdmaBackendDev *backend_dev)
 } while (cqe_ctx_id != -ENOENT);
 }
 
-static int rdma_poll_cq(RdmaBackendDev *backend_dev,
-RdmaDeviceResources *rdma_dev_res, struct ibv_cq *ibcq)
+static int rdma_poll_cq(RdmaDeviceResources *rdma_dev_res, struct ibv_cq *ibcq)
 {
 int i, ne, total_ne = 0;
 BackendCtx *bctx;
@@ -181,7 +180,7 @@ static void *comp_handler_thread(void *arg)
 }
 
 backend_dev->rdma_dev_res->stats.poll_cq_from_bk++;
-rdma_poll_cq(backend_dev, backend_dev->rdma_dev_res, ev_cq);
+rdma_poll_cq(backend_dev->rdma_dev_res, ev_cq);
 
 ibv_ack_cq_events(ev_cq, 1);
 }
@@ -315,7 +314,7 @@ void rdma_backend_poll_cq(RdmaDeviceResources 
*rdma_dev_res, RdmaBackendCQ *cq)
 int polled;
 
 rdma_dev_res->stats.poll_cq_from_guest++;
-polled = rdma_poll_cq(cq->backend_dev, rdma_dev_res, cq->ibcq);
+polled = rdma_poll_cq(rdma_dev_res, cq->ibcq);
 if (!polled) {
 rdma_dev_res->stats.poll_cq_from_guest_empty++;
 }
-- 
2.17.1




[Qemu-devel] [PATCH PULL 06/18] {hmp, hw/pvrdma}: Expose device internals via monitor interface

2019-03-16 Thread Marcel Apfelbaum
From: Yuval Shaia 

Allow interrogating device internals through HMP interface.
The exposed indicators can be used for troubleshooting by developers or
sysadmin.
There is no need to expose these attributes to a management system (e.x.
libvirt) because (1) most of them are not "device-management' related
info and (2) there is no guarantee the interface is stable.

Signed-off-by: Yuval Shaia 
Acked-by: Dr. David Alan Gilbert 
Acked-by: Markus Armbruster 
Message-Id: <1552300155-25216-6-git-send-email-yuval.sh...@oracle.com>
Reviewed-by: Marcel Apfelbaum 
Signed-off-by: Marcel Apfelbaum 
---
 hmp-commands-info.hx  | 14 +++
 hmp.c | 27 
 hmp.h |  1 +
 hw/rdma/Makefile.objs |  2 +-
 hw/rdma/rdma.c| 30 ++
 hw/rdma/rdma_rm.c | 53 +++
 hw/rdma/rdma_rm.h |  1 +
 hw/rdma/vmw/pvrdma_main.c | 26 +++
 include/hw/rdma/rdma.h| 40 +
 9 files changed, 193 insertions(+), 1 deletion(-)
 create mode 100644 hw/rdma/rdma.c
 create mode 100644 include/hw/rdma/rdma.h

diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index cbee8b944d..c59444c461 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -202,6 +202,20 @@ STEXI
 @item info pic
 @findex info pic
 Show PIC state.
+ETEXI
+
+{
+.name   = "rdma",
+.args_type  = "",
+.params = "",
+.help   = "show RDMA state",
+.cmd= hmp_info_rdma,
+},
+
+STEXI
+@item info rdma
+@findex info rdma
+Show RDMA state.
 ETEXI
 
 {
diff --git a/hmp.c b/hmp.c
index 4a702d5b97..fa1e59a2fc 100644
--- a/hmp.c
+++ b/hmp.c
@@ -51,6 +51,7 @@
 #include "qemu/error-report.h"
 #include "exec/ramlist.h"
 #include "hw/intc/intc.h"
+#include "hw/rdma/rdma.h"
 #include "migration/snapshot.h"
 #include "migration/misc.h"
 
@@ -1013,6 +1014,32 @@ void hmp_info_pic(Monitor *mon, const QDict *qdict)
hmp_info_pic_foreach, mon);
 }
 
+static int hmp_info_rdma_foreach(Object *obj, void *opaque)
+{
+RdmaProvider *rdma;
+RdmaProviderClass *k;
+Monitor *mon = opaque;
+
+if (object_dynamic_cast(obj, INTERFACE_RDMA_PROVIDER)) {
+rdma = RDMA_PROVIDER(obj);
+k = RDMA_PROVIDER_GET_CLASS(obj);
+if (k->print_statistics) {
+k->print_statistics(mon, rdma);
+} else {
+monitor_printf(mon, "RDMA statistics not available for %s.\n",
+   object_get_typename(obj));
+}
+}
+
+return 0;
+}
+
+void hmp_info_rdma(Monitor *mon, const QDict *qdict)
+{
+object_child_foreach_recursive(object_get_root(),
+   hmp_info_rdma_foreach, mon);
+}
+
 void hmp_info_pci(Monitor *mon, const QDict *qdict)
 {
 PciInfoList *info_list, *info;
diff --git a/hmp.h b/hmp.h
index e0f32f04d3..43617f2646 100644
--- a/hmp.h
+++ b/hmp.h
@@ -36,6 +36,7 @@ void hmp_info_spice(Monitor *mon, const QDict *qdict);
 void hmp_info_balloon(Monitor *mon, const QDict *qdict);
 void hmp_info_irq(Monitor *mon, const QDict *qdict);
 void hmp_info_pic(Monitor *mon, const QDict *qdict);
+void hmp_info_rdma(Monitor *mon, const QDict *qdict);
 void hmp_info_pci(Monitor *mon, const QDict *qdict);
 void hmp_info_block_jobs(Monitor *mon, const QDict *qdict);
 void hmp_info_tpm(Monitor *mon, const QDict *qdict);
diff --git a/hw/rdma/Makefile.objs b/hw/rdma/Makefile.objs
index bd36cbf51c..c354e60e5b 100644
--- a/hw/rdma/Makefile.objs
+++ b/hw/rdma/Makefile.objs
@@ -1,5 +1,5 @@
 ifeq ($(CONFIG_PVRDMA),y)
-obj-$(CONFIG_PCI) += rdma_utils.o rdma_backend.o rdma_rm.o
+obj-$(CONFIG_PCI) += rdma_utils.o rdma_backend.o rdma_rm.o rdma.o
 obj-$(CONFIG_PCI) += vmw/pvrdma_dev_ring.o vmw/pvrdma_cmd.o \
  vmw/pvrdma_qp_ops.o vmw/pvrdma_main.o
 endif
diff --git a/hw/rdma/rdma.c b/hw/rdma/rdma.c
new file mode 100644
index 00..7bec0d0d2c
--- /dev/null
+++ b/hw/rdma/rdma.c
@@ -0,0 +1,30 @@
+/*
+ * RDMA device interface
+ *
+ * Copyright (C) 2018 Oracle
+ * Copyright (C) 2018 Red Hat Inc
+ *
+ * Authors:
+ * Yuval Shaia 
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#include "qemu/osdep.h"
+#include "hw/rdma/rdma.h"
+#include "qemu/module.h"
+
+static const TypeInfo rdma_hmp_info = {
+.name = INTERFACE_RDMA_PROVIDER,
+.parent = TYPE_INTERFACE,
+.class_size = sizeof(RdmaProviderClass),
+};
+
+static void rdma_register_types(void)
+{
+type_register_static(_hmp_info);
+}
+
+type_init(rdma_register_types)
diff --git a/hw/rdma/rdma_rm.c b/hw/rdma/rdma_rm.c
index 35fa1ab44e..b50e192b49 100644
--- a/hw/rdma/rdma_rm.c
+++ b/hw/rdma/rdma_rm.c
@@ -16,6 +16,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "cpu.h"
+#include "monitor/monitor.h"
 
 #include "trace.h"
 #include 

[Qemu-devel] [PATCH PULL 11/18] hw/pvrdma: Unregister from shutdown notifier when device goes down

2019-03-16 Thread Marcel Apfelbaum
From: Yuval Shaia 

This hook was installed to close the device when VM is going down.
After the device is closed there is no need to be informed on VM
shutdown.

Signed-off-by: Yuval Shaia 
Reviewed-by: Marcel Apfelbaum 
Message-Id: <1552300155-25216-11-git-send-email-yuval.sh...@oracle.com>
Reviewed-by: Kamal Heib 
Signed-off-by: Marcel Apfelbaum 
---
 hw/rdma/vmw/pvrdma_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/rdma/vmw/pvrdma_main.c b/hw/rdma/vmw/pvrdma_main.c
index a4afceda14..49bfbd6d41 100644
--- a/hw/rdma/vmw/pvrdma_main.c
+++ b/hw/rdma/vmw/pvrdma_main.c
@@ -311,6 +311,8 @@ static void pvrdma_fini(PCIDevice *pdev)
 {
 PVRDMADev *dev = PVRDMA_DEV(pdev);
 
+notifier_remove(>shutdown_notifier);
+
 pvrdma_qp_ops_fini();
 
 rdma_backend_stop(>backend_dev);
-- 
2.17.1




[Qemu-devel] [PATCH PULL 12/18] hw/pvrdma: Provide correct value to object_get_typename

2019-03-16 Thread Marcel Apfelbaum
From: Yuval Shaia 

Use base object of PCIDevice in call to object_get_typename().

Signed-off-by: Yuval Shaia 
Message-Id: <1552300155-25216-12-git-send-email-yuval.sh...@oracle.com>
Reviewed-by: Kamal Heib 
Reviewed-by: Marcel Apfelbaum 
Signed-off-by: Marcel Apfelbaum 
---
 hw/rdma/vmw/pvrdma_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/rdma/vmw/pvrdma_main.c b/hw/rdma/vmw/pvrdma_main.c
index 49bfbd6d41..0b46561bad 100644
--- a/hw/rdma/vmw/pvrdma_main.c
+++ b/hw/rdma/vmw/pvrdma_main.c
@@ -593,7 +593,7 @@ static void pvrdma_realize(PCIDevice *pdev, Error **errp)
 
 func0 = pci_get_function_0(pdev);
 /* Break if not vmxnet3 device in slot 0 */
-if (strcmp(object_get_typename(>qdev.parent_obj), TYPE_VMXNET3)) {
+if (strcmp(object_get_typename(OBJECT(func0)), TYPE_VMXNET3)) {
 error_setg(errp, "Device on %x.0 must be %s", PCI_SLOT(pdev->devfn),
TYPE_VMXNET3);
 return;
-- 
2.17.1




[Qemu-devel] [PATCH PULL 16/18] hw/rdma: Use {} instead of {0}

2019-03-16 Thread Marcel Apfelbaum
From: Kamal Heib 

Initialize structs with {} instead of {0} to make sure that all code is
using the same convention.

Reviewed-by: Marcel Apfelbaum 
Signed-off-by: Kamal Heib 
Reviewed-by: Yuval Shaia 
Message-Id: <20190314153031.7197-4-kamalhe...@gmail.com>
Signed-off-by: Marcel Apfelbaum 
---
 hw/rdma/rdma_backend.c  | 18 +-
 hw/rdma/vmw/pvrdma_cmd.c|  2 +-
 hw/rdma/vmw/pvrdma_qp_ops.c |  2 +-
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/hw/rdma/rdma_backend.c b/hw/rdma/rdma_backend.c
index 90983d2846..d1660b6474 100644
--- a/hw/rdma/rdma_backend.c
+++ b/hw/rdma/rdma_backend.c
@@ -57,7 +57,7 @@ static void dummy_comp_handler(void *ctx, struct ibv_wc *wc)
 static inline void complete_work(enum ibv_wc_status status, uint32_t 
vendor_err,
  void *ctx)
 {
-struct ibv_wc wc = {0};
+struct ibv_wc wc = {};
 
 wc.status = status;
 wc.vendor_err = vendor_err;
@@ -273,7 +273,7 @@ static void stop_backend_thread(RdmaBackendThread *thread)
 
 static void start_comp_thread(RdmaBackendDev *backend_dev)
 {
-char thread_name[THR_NAME_LEN] = {0};
+char thread_name[THR_NAME_LEN] = {};
 
 stop_backend_thread(_dev->comp_thread);
 
@@ -483,7 +483,7 @@ void rdma_backend_post_send(RdmaBackendDev *backend_dev,
 struct ibv_sge new_sge[MAX_SGE];
 uint32_t bctx_id;
 int rc;
-struct ibv_send_wr wr = {0}, *bad_wr;
+struct ibv_send_wr wr = {}, *bad_wr;
 
 if (!qp->ibqp) { /* This field is not initialized for QP0 and QP1 */
 if (qp_type == IBV_QPT_SMI) {
@@ -600,7 +600,7 @@ void rdma_backend_post_recv(RdmaBackendDev *backend_dev,
 struct ibv_sge new_sge[MAX_SGE];
 uint32_t bctx_id;
 int rc;
-struct ibv_recv_wr wr = {0}, *bad_wr;
+struct ibv_recv_wr wr = {}, *bad_wr;
 
 if (!qp->ibqp) { /* This field does not get initialized for QP0 and QP1 */
 if (qp_type == IBV_QPT_SMI) {
@@ -737,7 +737,7 @@ int rdma_backend_create_qp(RdmaBackendQP *qp, uint8_t 
qp_type,
uint32_t max_recv_wr, uint32_t max_send_sge,
uint32_t max_recv_sge)
 {
-struct ibv_qp_init_attr attr = {0};
+struct ibv_qp_init_attr attr = {};
 
 qp->ibqp = 0;
 
@@ -782,7 +782,7 @@ int rdma_backend_create_qp(RdmaBackendQP *qp, uint8_t 
qp_type,
 int rdma_backend_qp_state_init(RdmaBackendDev *backend_dev, RdmaBackendQP *qp,
uint8_t qp_type, uint32_t qkey)
 {
-struct ibv_qp_attr attr = {0};
+struct ibv_qp_attr attr = {};
 int rc, attr_mask;
 
 attr_mask = IBV_QP_STATE | IBV_QP_PKEY_INDEX | IBV_QP_PORT;
@@ -821,7 +821,7 @@ int rdma_backend_qp_state_rtr(RdmaBackendDev *backend_dev, 
RdmaBackendQP *qp,
   union ibv_gid *dgid, uint32_t dqpn,
   uint32_t rq_psn, uint32_t qkey, bool use_qkey)
 {
-struct ibv_qp_attr attr = {0};
+struct ibv_qp_attr attr = {};
 union ibv_gid ibv_gid = {
 .global.interface_id = dgid->global.interface_id,
 .global.subnet_prefix = dgid->global.subnet_prefix
@@ -880,7 +880,7 @@ int rdma_backend_qp_state_rtr(RdmaBackendDev *backend_dev, 
RdmaBackendQP *qp,
 int rdma_backend_qp_state_rts(RdmaBackendQP *qp, uint8_t qp_type,
   uint32_t sq_psn, uint32_t qkey, bool use_qkey)
 {
-struct ibv_qp_attr attr = {0};
+struct ibv_qp_attr attr = {};
 int rc, attr_mask;
 
 attr.qp_state = IBV_QPS_RTS;
@@ -1012,7 +1012,7 @@ static void process_incoming_mad_req(RdmaBackendDev 
*backend_dev,
 complete_work(IBV_WC_GENERAL_ERR, VENDOR_ERR_INV_MAD_BUFF,
   bctx->up_ctx);
 } else {
-struct ibv_wc wc = {0};
+struct ibv_wc wc = {};
 memset(mad, 0, bctx->sge.length);
 build_mad_hdr((struct ibv_grh *)mad,
   (union ibv_gid *)>umad.hdr.addr.gid, >hdr.sgid,
diff --git a/hw/rdma/vmw/pvrdma_cmd.c b/hw/rdma/vmw/pvrdma_cmd.c
index 6d56746357..b682e919d5 100644
--- a/hw/rdma/vmw/pvrdma_cmd.c
+++ b/hw/rdma/vmw/pvrdma_cmd.c
@@ -123,7 +123,7 @@ static int query_port(PVRDMADev *dev, union pvrdma_cmd_req 
*req,
 {
 struct pvrdma_cmd_query_port *cmd = >query_port;
 struct pvrdma_cmd_query_port_resp *resp = >query_port_resp;
-struct pvrdma_port_attr attrs = {0};
+struct pvrdma_port_attr attrs = {};
 
 if (cmd->port_num > MAX_PORTS) {
 return -EINVAL;
diff --git a/hw/rdma/vmw/pvrdma_qp_ops.c b/hw/rdma/vmw/pvrdma_qp_ops.c
index 508d8fca3c..5b9786efbe 100644
--- a/hw/rdma/vmw/pvrdma_qp_ops.c
+++ b/hw/rdma/vmw/pvrdma_qp_ops.c
@@ -114,7 +114,7 @@ static void pvrdma_qp_ops_comp_handler(void *ctx, struct 
ibv_wc *wc)
 
 static void complete_with_error(uint32_t vendor_err, void *ctx)
 {
-struct ibv_wc wc = {0};
+struct ibv_wc wc = {};
 
 wc.status = IBV_WC_GENERAL_ERR;
 wc.vendor_err = vendor_err;
-- 
2.17.1




[Qemu-devel] [PATCH PULL 10/18] hw/pvrdma: Delete pvrdma_exit function

2019-03-16 Thread Marcel Apfelbaum
From: Yuval Shaia 

This hook is not called and was implemented by mistake.

Signed-off-by: Yuval Shaia 
Reviewed-by: Marcel Apfelbaum 
Message-Id: <1552300155-25216-10-git-send-email-yuval.sh...@oracle.com>
Reviewed-by: Kamal Heib 
Signed-off-by: Marcel Apfelbaum 
---
 hw/rdma/vmw/pvrdma_main.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/hw/rdma/vmw/pvrdma_main.c b/hw/rdma/vmw/pvrdma_main.c
index 04845f46f7..a4afceda14 100644
--- a/hw/rdma/vmw/pvrdma_main.c
+++ b/hw/rdma/vmw/pvrdma_main.c
@@ -654,11 +654,6 @@ out:
 }
 }
 
-static void pvrdma_exit(PCIDevice *pdev)
-{
-pvrdma_fini(pdev);
-}
-
 static void pvrdma_class_init(ObjectClass *klass, void *data)
 {
 DeviceClass *dc = DEVICE_CLASS(klass);
@@ -666,7 +661,6 @@ static void pvrdma_class_init(ObjectClass *klass, void 
*data)
 RdmaProviderClass *ir = INTERFACE_RDMA_PROVIDER_CLASS(klass);
 
 k->realize = pvrdma_realize;
-k->exit = pvrdma_exit;
 k->vendor_id = PCI_VENDOR_ID_VMWARE;
 k->device_id = PCI_DEVICE_ID_VMWARE_PVRDMA;
 k->revision = 0x00;
-- 
2.17.1




[Qemu-devel] [PATCH PULL 13/18] hw/rdma: another clang compilation fix

2019-03-16 Thread Marcel Apfelbaum
Configuring QEMU with:
   configure --target-list="x86_64-softmmu" --cc=clang --enable-pvrdma
Results in:
   qemu/hw/rdma/rdma_rm_defs.h:108:3: error: redefinition of typedef 
'RdmaDeviceResources' is a C11 feature [-Werror,-Wtypedef-redefinition]
   } RdmaDeviceResources;
 ^
   qemu/hw/rdma/rdma_backend_defs.h:24:36: note: previous definition is here
   typedef struct RdmaDeviceResources RdmaDeviceResources;

Fix by removing one of the 'typedef' definitions.

Signed-off-by: Marcel Apfelbaum 
Message-Id: <20190214154053.15050-1-marcel.apfelb...@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé 
Acked-by: Kamal Heib 
Signed-off-by: Marcel Apfelbaum 
---
 hw/rdma/rdma_rm_defs.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/rdma/rdma_rm_defs.h b/hw/rdma/rdma_rm_defs.h
index 4b8d704cfe..c200d311de 100644
--- a/hw/rdma/rdma_rm_defs.h
+++ b/hw/rdma/rdma_rm_defs.h
@@ -120,7 +120,7 @@ typedef struct RdmaRmStats {
 uint32_t missing_cqe;
 } RdmaRmStats;
 
-typedef struct RdmaDeviceResources {
+struct RdmaDeviceResources {
 RdmaRmPort port;
 RdmaRmResTbl pd_tbl;
 RdmaRmResTbl mr_tbl;
@@ -131,6 +131,6 @@ typedef struct RdmaDeviceResources {
 GHashTable *qp_hash; /* Keeps mapping between real and emulated */
 QemuMutex lock;
 RdmaRmStats stats;
-} RdmaDeviceResources;
+};
 
 #endif
-- 
2.17.1




[Qemu-devel] [PATCH PULL 08/18] hw/rdma: Free all receive buffers when QP is destroyed

2019-03-16 Thread Marcel Apfelbaum
From: Yuval Shaia 

When QP is destroyed the backend QP is destroyed as well. This ensures
we clean all received buffer we posted to it.
However, a contexts of these buffers are still remain in the device.
Fix it by maintaining a list of buffer's context and free them when QP
is destroyed.

Signed-off-by: Yuval Shaia 
Reviewed-by: Marcel Apfelbaum 
Message-Id: <1552300155-25216-8-git-send-email-yuval.sh...@oracle.com>
Reviewed-by: Kamal Heib 
Signed-off-by: Marcel Apfelbaum 
---
 hw/rdma/rdma_backend.c  | 26 --
 hw/rdma/rdma_backend.h  |  2 +-
 hw/rdma/rdma_backend_defs.h |  2 +-
 hw/rdma/rdma_rm.c   |  2 +-
 hw/rdma/rdma_utils.c| 29 +
 hw/rdma/rdma_utils.h| 11 +++
 6 files changed, 63 insertions(+), 9 deletions(-)

diff --git a/hw/rdma/rdma_backend.c b/hw/rdma/rdma_backend.c
index d0bbe57bd2..e124d8d16b 100644
--- a/hw/rdma/rdma_backend.c
+++ b/hw/rdma/rdma_backend.c
@@ -39,6 +39,7 @@
 typedef struct BackendCtx {
 void *up_ctx;
 struct ibv_sge sge; /* Used to save MAD recv buffer */
+RdmaBackendQP *backend_qp; /* To maintain recv buffers */
 } BackendCtx;
 
 struct backend_umad {
@@ -73,6 +74,7 @@ static void free_cqe_ctx(gpointer data, gpointer user_data)
 bctx = rdma_rm_get_cqe_ctx(rdma_dev_res, cqe_ctx_id);
 if (bctx) {
 rdma_rm_dealloc_cqe_ctx(rdma_dev_res, cqe_ctx_id);
+atomic_dec(_dev_res->stats.missing_cqe);
 }
 g_free(bctx);
 }
@@ -85,13 +87,15 @@ static void clean_recv_mads(RdmaBackendDev *backend_dev)
 cqe_ctx_id = rdma_protected_qlist_pop_int64(_dev->
 recv_mads_list);
 if (cqe_ctx_id != -ENOENT) {
+atomic_inc(_dev->rdma_dev_res->stats.missing_cqe);
 free_cqe_ctx(GINT_TO_POINTER(cqe_ctx_id),
  backend_dev->rdma_dev_res);
 }
 } while (cqe_ctx_id != -ENOENT);
 }
 
-static int rdma_poll_cq(RdmaDeviceResources *rdma_dev_res, struct ibv_cq *ibcq)
+static int rdma_poll_cq(RdmaBackendDev *backend_dev,
+RdmaDeviceResources *rdma_dev_res, struct ibv_cq *ibcq)
 {
 int i, ne, total_ne = 0;
 BackendCtx *bctx;
@@ -113,6 +117,8 @@ static int rdma_poll_cq(RdmaDeviceResources *rdma_dev_res, 
struct ibv_cq *ibcq)
 
 comp_handler(bctx->up_ctx, [i]);
 
+rdma_protected_gslist_remove_int32(>backend_qp->cqe_ctx_list,
+   wc[i].wr_id);
 rdma_rm_dealloc_cqe_ctx(rdma_dev_res, wc[i].wr_id);
 g_free(bctx);
 }
@@ -175,14 +181,12 @@ static void *comp_handler_thread(void *arg)
 }
 
 backend_dev->rdma_dev_res->stats.poll_cq_from_bk++;
-rdma_poll_cq(backend_dev->rdma_dev_res, ev_cq);
+rdma_poll_cq(backend_dev, backend_dev->rdma_dev_res, ev_cq);
 
 ibv_ack_cq_events(ev_cq, 1);
 }
 }
 
-/* TODO: Post cqe for all remaining buffs that were posted */
-
 backend_dev->comp_thread.is_running = false;
 
 qemu_thread_exit(0);
@@ -311,7 +315,7 @@ void rdma_backend_poll_cq(RdmaDeviceResources 
*rdma_dev_res, RdmaBackendCQ *cq)
 int polled;
 
 rdma_dev_res->stats.poll_cq_from_guest++;
-polled = rdma_poll_cq(rdma_dev_res, cq->ibcq);
+polled = rdma_poll_cq(cq->backend_dev, rdma_dev_res, cq->ibcq);
 if (!polled) {
 rdma_dev_res->stats.poll_cq_from_guest_empty++;
 }
@@ -501,6 +505,7 @@ void rdma_backend_post_send(RdmaBackendDev *backend_dev,
 
 bctx = g_malloc0(sizeof(*bctx));
 bctx->up_ctx = ctx;
+bctx->backend_qp = qp;
 
 rc = rdma_rm_alloc_cqe_ctx(backend_dev->rdma_dev_res, _id, bctx);
 if (unlikely(rc)) {
@@ -508,6 +513,8 @@ void rdma_backend_post_send(RdmaBackendDev *backend_dev,
 goto err_free_bctx;
 }
 
+rdma_protected_gslist_append_int32(>cqe_ctx_list, bctx_id);
+
 rc = build_host_sge_array(backend_dev->rdma_dev_res, new_sge, sge, num_sge,
   _dev->rdma_dev_res->stats.tx_len);
 if (rc) {
@@ -616,6 +623,7 @@ void rdma_backend_post_recv(RdmaBackendDev *backend_dev,
 
 bctx = g_malloc0(sizeof(*bctx));
 bctx->up_ctx = ctx;
+bctx->backend_qp = qp;
 
 rc = rdma_rm_alloc_cqe_ctx(rdma_dev_res, _id, bctx);
 if (unlikely(rc)) {
@@ -623,6 +631,8 @@ void rdma_backend_post_recv(RdmaBackendDev *backend_dev,
 goto err_free_bctx;
 }
 
+rdma_protected_gslist_append_int32(>cqe_ctx_list, bctx_id);
+
 rc = build_host_sge_array(rdma_dev_res, new_sge, sge, num_sge,
   _dev->rdma_dev_res->stats.rx_bufs_len);
 if (rc) {
@@ -762,6 +772,8 @@ int rdma_backend_create_qp(RdmaBackendQP *qp, uint8_t 
qp_type,
 return -EIO;
 }
 
+rdma_protected_gslist_init(>cqe_ctx_list);
+
 qp->ibpd = pd->ibpd;
 
 /* TODO: Query QP to get max_inline_data and save it to be used in send */
@@ -919,11 +931,13 @@ int 

[Qemu-devel] [PATCH PULL 07/18] hw/rdma: Free all MAD receive buffers when device is closed

2019-03-16 Thread Marcel Apfelbaum
From: Yuval Shaia 

When device is going down free all saved MAD buffers.

Signed-off-by: Yuval Shaia 
Reviewed-by: Marcel Apfelbaum 
Message-Id: <1552300155-25216-7-git-send-email-yuval.sh...@oracle.com>
Reviewed-by: Kamal Heib 
Signed-off-by: Marcel Apfelbaum 
---
 hw/rdma/rdma_backend.c| 34 +-
 hw/rdma/vmw/pvrdma_main.c |  2 ++
 2 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/hw/rdma/rdma_backend.c b/hw/rdma/rdma_backend.c
index e8af9741b1..d0bbe57bd2 100644
--- a/hw/rdma/rdma_backend.c
+++ b/hw/rdma/rdma_backend.c
@@ -64,6 +64,33 @@ static inline void complete_work(enum ibv_wc_status status, 
uint32_t vendor_err,
 comp_handler(ctx, );
 }
 
+static void free_cqe_ctx(gpointer data, gpointer user_data)
+{
+BackendCtx *bctx;
+RdmaDeviceResources *rdma_dev_res = user_data;
+unsigned long cqe_ctx_id = GPOINTER_TO_INT(data);
+
+bctx = rdma_rm_get_cqe_ctx(rdma_dev_res, cqe_ctx_id);
+if (bctx) {
+rdma_rm_dealloc_cqe_ctx(rdma_dev_res, cqe_ctx_id);
+}
+g_free(bctx);
+}
+
+static void clean_recv_mads(RdmaBackendDev *backend_dev)
+{
+unsigned long cqe_ctx_id;
+
+do {
+cqe_ctx_id = rdma_protected_qlist_pop_int64(_dev->
+recv_mads_list);
+if (cqe_ctx_id != -ENOENT) {
+free_cqe_ctx(GINT_TO_POINTER(cqe_ctx_id),
+ backend_dev->rdma_dev_res);
+}
+} while (cqe_ctx_id != -ENOENT);
+}
+
 static int rdma_poll_cq(RdmaDeviceResources *rdma_dev_res, struct ibv_cq *ibcq)
 {
 int i, ne, total_ne = 0;
@@ -1037,6 +1064,11 @@ static int mad_init(RdmaBackendDev *backend_dev, 
CharBackend *mad_chr_be)
 return 0;
 }
 
+static void mad_stop(RdmaBackendDev *backend_dev)
+{
+clean_recv_mads(backend_dev);
+}
+
 static void mad_fini(RdmaBackendDev *backend_dev)
 {
 disable_rdmacm_mux_async(backend_dev);
@@ -1224,12 +1256,12 @@ void rdma_backend_start(RdmaBackendDev *backend_dev)
 
 void rdma_backend_stop(RdmaBackendDev *backend_dev)
 {
+mad_stop(backend_dev);
 stop_backend_thread(_dev->comp_thread);
 }
 
 void rdma_backend_fini(RdmaBackendDev *backend_dev)
 {
-rdma_backend_stop(backend_dev);
 mad_fini(backend_dev);
 g_hash_table_destroy(ah_hash);
 ibv_destroy_comp_channel(backend_dev->channel);
diff --git a/hw/rdma/vmw/pvrdma_main.c b/hw/rdma/vmw/pvrdma_main.c
index 729a2df5a0..04845f46f7 100644
--- a/hw/rdma/vmw/pvrdma_main.c
+++ b/hw/rdma/vmw/pvrdma_main.c
@@ -313,6 +313,8 @@ static void pvrdma_fini(PCIDevice *pdev)
 
 pvrdma_qp_ops_fini();
 
+rdma_backend_stop(>backend_dev);
+
 rdma_rm_fini(>rdma_dev_res, >backend_dev,
  dev->backend_eth_device_name);
 
-- 
2.17.1




[Qemu-devel] [PATCH PULL 09/18] hw/pvrdma: Delete unneeded function argument

2019-03-16 Thread Marcel Apfelbaum
From: Yuval Shaia 

The function's argument rdma_dev_res is not needed as it is stored in
the backend_dev object at init.

Signed-off-by: Yuval Shaia 
Reviewed-by: Marcel Apfelbaum 
Message-Id: <1552300155-25216-9-git-send-email-yuval.sh...@oracle.com>
Reviewed-by: Kamal Heib 
Signed-off-by: Marcel Apfelbaum 
---
 hw/rdma/rdma_backend.c  | 13 ++---
 hw/rdma/rdma_backend.h  |  1 -
 hw/rdma/vmw/pvrdma_qp_ops.c |  3 +--
 3 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/hw/rdma/rdma_backend.c b/hw/rdma/rdma_backend.c
index e124d8d16b..89279e66e7 100644
--- a/hw/rdma/rdma_backend.c
+++ b/hw/rdma/rdma_backend.c
@@ -594,7 +594,6 @@ static unsigned int save_mad_recv_buffer(RdmaBackendDev 
*backend_dev,
 }
 
 void rdma_backend_post_recv(RdmaBackendDev *backend_dev,
-RdmaDeviceResources *rdma_dev_res,
 RdmaBackendQP *qp, uint8_t qp_type,
 struct ibv_sge *sge, uint32_t num_sge, void *ctx)
 {
@@ -613,9 +612,9 @@ void rdma_backend_post_recv(RdmaBackendDev *backend_dev,
 rc = save_mad_recv_buffer(backend_dev, sge, num_sge, ctx);
 if (rc) {
 complete_work(IBV_WC_GENERAL_ERR, rc, ctx);
-rdma_dev_res->stats.mad_rx_bufs_err++;
+backend_dev->rdma_dev_res->stats.mad_rx_bufs_err++;
 } else {
-rdma_dev_res->stats.mad_rx_bufs++;
+backend_dev->rdma_dev_res->stats.mad_rx_bufs++;
 }
 }
 return;
@@ -625,7 +624,7 @@ void rdma_backend_post_recv(RdmaBackendDev *backend_dev,
 bctx->up_ctx = ctx;
 bctx->backend_qp = qp;
 
-rc = rdma_rm_alloc_cqe_ctx(rdma_dev_res, _id, bctx);
+rc = rdma_rm_alloc_cqe_ctx(backend_dev->rdma_dev_res, _id, bctx);
 if (unlikely(rc)) {
 complete_work(IBV_WC_GENERAL_ERR, VENDOR_ERR_NOMEM, ctx);
 goto err_free_bctx;
@@ -633,7 +632,7 @@ void rdma_backend_post_recv(RdmaBackendDev *backend_dev,
 
 rdma_protected_gslist_append_int32(>cqe_ctx_list, bctx_id);
 
-rc = build_host_sge_array(rdma_dev_res, new_sge, sge, num_sge,
+rc = build_host_sge_array(backend_dev->rdma_dev_res, new_sge, sge, num_sge,
   _dev->rdma_dev_res->stats.rx_bufs_len);
 if (rc) {
 complete_work(IBV_WC_GENERAL_ERR, rc, ctx);
@@ -652,13 +651,13 @@ void rdma_backend_post_recv(RdmaBackendDev *backend_dev,
 }
 
 atomic_inc(_dev->rdma_dev_res->stats.missing_cqe);
-rdma_dev_res->stats.rx_bufs++;
+backend_dev->rdma_dev_res->stats.rx_bufs++;
 
 return;
 
 err_dealloc_cqe_ctx:
 backend_dev->rdma_dev_res->stats.rx_bufs_err++;
-rdma_rm_dealloc_cqe_ctx(rdma_dev_res, bctx_id);
+rdma_rm_dealloc_cqe_ctx(backend_dev->rdma_dev_res, bctx_id);
 
 err_free_bctx:
 g_free(bctx);
diff --git a/hw/rdma/rdma_backend.h b/hw/rdma/rdma_backend.h
index c54eaf2e4a..38056d97c7 100644
--- a/hw/rdma/rdma_backend.h
+++ b/hw/rdma/rdma_backend.h
@@ -111,7 +111,6 @@ void rdma_backend_post_send(RdmaBackendDev *backend_dev,
 union ibv_gid *dgid, uint32_t dqpn, uint32_t dqkey,
 void *ctx);
 void rdma_backend_post_recv(RdmaBackendDev *backend_dev,
-RdmaDeviceResources *rdma_dev_res,
 RdmaBackendQP *qp, uint8_t qp_type,
 struct ibv_sge *sge, uint32_t num_sge, void *ctx);
 
diff --git a/hw/rdma/vmw/pvrdma_qp_ops.c b/hw/rdma/vmw/pvrdma_qp_ops.c
index 16db726dac..508d8fca3c 100644
--- a/hw/rdma/vmw/pvrdma_qp_ops.c
+++ b/hw/rdma/vmw/pvrdma_qp_ops.c
@@ -231,8 +231,7 @@ void pvrdma_qp_recv(PVRDMADev *dev, uint32_t qp_handle)
 continue;
 }
 
-rdma_backend_post_recv(>backend_dev, >rdma_dev_res,
-   >backend_qp, qp->qp_type,
+rdma_backend_post_recv(>backend_dev, >backend_qp, qp->qp_type,
(struct ibv_sge *)>sge[0], 
wqe->hdr.num_sge,
comp_ctx);
 
-- 
2.17.1




[Qemu-devel] [PATCH PULL 04/18] hw/rdma: Protect against concurrent execution of poll_cq

2019-03-16 Thread Marcel Apfelbaum
From: Yuval Shaia 

The function rdma_poll_cq is called from two contexts - completion
handler thread which sense new completion on backend channel and
explicitly as result of guest issuing poll_cq command.

Add lock to protect against concurrent executions.

Signed-off-by: Yuval Shaia 
Reviewed-by: Marcel Apfelbaum 
Message-Id: <1552300155-25216-4-git-send-email-yuval.sh...@oracle.com>
Reviewed-by: Kamal Heib 
Signed-off-by: Marcel Apfelbaum 
---
 hw/rdma/rdma_backend.c | 2 ++
 hw/rdma/rdma_rm.c  | 4 
 hw/rdma/rdma_rm_defs.h | 1 +
 3 files changed, 7 insertions(+)

diff --git a/hw/rdma/rdma_backend.c b/hw/rdma/rdma_backend.c
index 37edf42215..18975401d9 100644
--- a/hw/rdma/rdma_backend.c
+++ b/hw/rdma/rdma_backend.c
@@ -70,6 +70,7 @@ static void rdma_poll_cq(RdmaDeviceResources *rdma_dev_res, 
struct ibv_cq *ibcq)
 BackendCtx *bctx;
 struct ibv_wc wc[2];
 
+qemu_mutex_lock(_dev_res->lock);
 do {
 ne = ibv_poll_cq(ibcq, ARRAY_SIZE(wc), wc);
 
@@ -89,6 +90,7 @@ static void rdma_poll_cq(RdmaDeviceResources *rdma_dev_res, 
struct ibv_cq *ibcq)
 g_free(bctx);
 }
 } while (ne > 0);
+qemu_mutex_unlock(_dev_res->lock);
 
 if (ne < 0) {
 rdma_error_report("ibv_poll_cq fail, rc=%d, errno=%d", ne, errno);
diff --git a/hw/rdma/rdma_rm.c b/hw/rdma/rdma_rm.c
index 66177b42f5..7ea62a9e60 100644
--- a/hw/rdma/rdma_rm.c
+++ b/hw/rdma/rdma_rm.c
@@ -617,12 +617,16 @@ int rdma_rm_init(RdmaDeviceResources *dev_res, struct 
ibv_device_attr *dev_attr)
 
 init_ports(dev_res);
 
+qemu_mutex_init(_res->lock);
+
 return 0;
 }
 
 void rdma_rm_fini(RdmaDeviceResources *dev_res, RdmaBackendDev *backend_dev,
   const char *ifname)
 {
+qemu_mutex_destroy(_res->lock);
+
 fini_ports(dev_res, backend_dev, ifname);
 
 res_tbl_free(_res->uc_tbl);
diff --git a/hw/rdma/rdma_rm_defs.h b/hw/rdma/rdma_rm_defs.h
index 0ba61d1838..f0ee1f3072 100644
--- a/hw/rdma/rdma_rm_defs.h
+++ b/hw/rdma/rdma_rm_defs.h
@@ -105,6 +105,7 @@ typedef struct RdmaDeviceResources {
 RdmaRmResTbl cq_tbl;
 RdmaRmResTbl cqe_ctx_tbl;
 GHashTable *qp_hash; /* Keeps mapping between real and emulated */
+QemuMutex lock;
 } RdmaDeviceResources;
 
 #endif
-- 
2.17.1




[Qemu-devel] [PATCH PULL 03/18] hw/rdma: Introduce protected qlist

2019-03-16 Thread Marcel Apfelbaum
From: Yuval Shaia 

To make code more readable move handling of protected list to a
rdma_utils

Signed-off-by: Yuval Shaia 
Reviewed-by: Marcel Apfelbaum 
Message-Id: <1552300155-25216-3-git-send-email-yuval.sh...@oracle.com>
Reviewed-by: Kamal Heib 
Signed-off-by: Marcel Apfelbaum 
---
 hw/rdma/rdma_backend.c  | 20 +--
 hw/rdma/rdma_backend_defs.h |  8 ++--
 hw/rdma/rdma_utils.c| 39 +
 hw/rdma/rdma_utils.h|  9 +
 4 files changed, 55 insertions(+), 21 deletions(-)

diff --git a/hw/rdma/rdma_backend.c b/hw/rdma/rdma_backend.c
index d138591c86..37edf42215 100644
--- a/hw/rdma/rdma_backend.c
+++ b/hw/rdma/rdma_backend.c
@@ -527,9 +527,7 @@ static unsigned int save_mad_recv_buffer(RdmaBackendDev 
*backend_dev,
 bctx->up_ctx = ctx;
 bctx->sge = *sge;
 
-qemu_mutex_lock(_dev->recv_mads_list.lock);
-qlist_append_int(backend_dev->recv_mads_list.list, bctx_id);
-qemu_mutex_unlock(_dev->recv_mads_list.lock);
+rdma_protected_qlist_append_int64(_dev->recv_mads_list, bctx_id);
 
 return 0;
 }
@@ -913,23 +911,19 @@ static inline void build_mad_hdr(struct ibv_grh *grh, 
union ibv_gid *sgid,
 static void process_incoming_mad_req(RdmaBackendDev *backend_dev,
  RdmaCmMuxMsg *msg)
 {
-QObject *o_ctx_id;
 unsigned long cqe_ctx_id;
 BackendCtx *bctx;
 char *mad;
 
 trace_mad_message("recv", msg->umad.mad, msg->umad_len);
 
-qemu_mutex_lock(_dev->recv_mads_list.lock);
-o_ctx_id = qlist_pop(backend_dev->recv_mads_list.list);
-qemu_mutex_unlock(_dev->recv_mads_list.lock);
-if (!o_ctx_id) {
+cqe_ctx_id = rdma_protected_qlist_pop_int64(_dev->recv_mads_list);
+if (cqe_ctx_id == -ENOENT) {
 rdma_warn_report("No more free MADs buffers, waiting for a while");
 sleep(THR_POLL_TO);
 return;
 }
 
-cqe_ctx_id = qnum_get_uint(qobject_to(QNum, o_ctx_id));
 bctx = rdma_rm_get_cqe_ctx(backend_dev->rdma_dev_res, cqe_ctx_id);
 if (unlikely(!bctx)) {
 rdma_error_report("No matching ctx for req %ld", cqe_ctx_id);
@@ -994,8 +988,7 @@ static int mad_init(RdmaBackendDev *backend_dev, 
CharBackend *mad_chr_be)
 return -EIO;
 }
 
-qemu_mutex_init(_dev->recv_mads_list.lock);
-backend_dev->recv_mads_list.list = qlist_new();
+rdma_protected_qlist_init(_dev->recv_mads_list);
 
 enable_rdmacm_mux_async(backend_dev);
 
@@ -1010,10 +1003,7 @@ static void mad_fini(RdmaBackendDev *backend_dev)
 {
 disable_rdmacm_mux_async(backend_dev);
 qemu_chr_fe_disconnect(backend_dev->rdmacm_mux.chr_be);
-if (backend_dev->recv_mads_list.list) {
-qlist_destroy_obj(QOBJECT(backend_dev->recv_mads_list.list));
-qemu_mutex_destroy(_dev->recv_mads_list.lock);
-}
+rdma_protected_qlist_destroy(_dev->recv_mads_list);
 }
 
 int rdma_backend_get_gid_index(RdmaBackendDev *backend_dev,
diff --git a/hw/rdma/rdma_backend_defs.h b/hw/rdma/rdma_backend_defs.h
index 15ae8b970e..a8c15b09ab 100644
--- a/hw/rdma/rdma_backend_defs.h
+++ b/hw/rdma/rdma_backend_defs.h
@@ -20,6 +20,7 @@
 #include "chardev/char-fe.h"
 #include 
 #include "contrib/rdmacm-mux/rdmacm-mux.h"
+#include "rdma_utils.h"
 
 typedef struct RdmaDeviceResources RdmaDeviceResources;
 
@@ -30,11 +31,6 @@ typedef struct RdmaBackendThread {
 bool is_running; /* Set by the thread to report its status */
 } RdmaBackendThread;
 
-typedef struct RecvMadList {
-QemuMutex lock;
-QList *list;
-} RecvMadList;
-
 typedef struct RdmaCmMux {
 CharBackend *chr_be;
 int can_receive;
@@ -48,7 +44,7 @@ typedef struct RdmaBackendDev {
 struct ibv_context *context;
 struct ibv_comp_channel *channel;
 uint8_t port_num;
-RecvMadList recv_mads_list;
+RdmaProtectedQList recv_mads_list;
 RdmaCmMux rdmacm_mux;
 } RdmaBackendDev;
 
diff --git a/hw/rdma/rdma_utils.c b/hw/rdma/rdma_utils.c
index b9f07fcda7..0a8abe572d 100644
--- a/hw/rdma/rdma_utils.c
+++ b/hw/rdma/rdma_utils.c
@@ -14,6 +14,8 @@
  */
 
 #include "qemu/osdep.h"
+#include "qapi/qmp/qlist.h"
+#include "qapi/qmp/qnum.h"
 #include "trace.h"
 #include "rdma_utils.h"
 
@@ -51,3 +53,40 @@ void rdma_pci_dma_unmap(PCIDevice *dev, void *buffer, 
dma_addr_t len)
 pci_dma_unmap(dev, buffer, len, DMA_DIRECTION_TO_DEVICE, 0);
 }
 }
+
+void rdma_protected_qlist_init(RdmaProtectedQList *list)
+{
+qemu_mutex_init(>lock);
+list->list = qlist_new();
+}
+
+void rdma_protected_qlist_destroy(RdmaProtectedQList *list)
+{
+if (list->list) {
+qlist_destroy_obj(QOBJECT(list->list));
+qemu_mutex_destroy(>lock);
+list->list = NULL;
+}
+}
+
+void rdma_protected_qlist_append_int64(RdmaProtectedQList *list, int64_t value)
+{
+qemu_mutex_lock(>lock);
+qlist_append_int(list->list, value);
+qemu_mutex_unlock(>lock);
+}
+
+int64_t rdma_protected_qlist_pop_int64(RdmaProtectedQList *list)
+{
+QObject *obj;
+
+

[Qemu-devel] [PATCH PULL 01/18] contrib/rdmacm-mux: Fix out-of-bounds risk

2019-03-16 Thread Marcel Apfelbaum
From: Yuval Shaia 

The function get_fd extract context from the received MAD message and
uses it as a key to fetch the destination fd from the mapping table.
A context can be dgid in case of CM request message or comm_id in case
of CM SIDR response message.

When MAD message with a smaller size as expected for the message type
received we are hitting out-of-bounds where we are looking for the
context out of message boundaries.

Fix it by validating the message size.

Reported-by Sam Smith 
Signed-off-by: Yuval Shaia 
Message-Id: <20190212112347.1605-1-yuval.sh...@oracle.com>
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Marcel Apfelbaum 
---
 contrib/rdmacm-mux/main.c | 35 +--
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/contrib/rdmacm-mux/main.c b/contrib/rdmacm-mux/main.c
index ae88c77a1e..21cc804367 100644
--- a/contrib/rdmacm-mux/main.c
+++ b/contrib/rdmacm-mux/main.c
@@ -300,7 +300,7 @@ static void hash_tbl_remove_fd_ifid_pair(int fd)
 pthread_rwlock_unlock();
 }
 
-static int get_fd(const char *mad, int *fd, __be64 *gid_ifid)
+static int get_fd(const char *mad, int umad_len, int *fd, __be64 *gid_ifid)
 {
 struct umad_hdr *hdr = (struct umad_hdr *)mad;
 char *data = (char *)hdr + sizeof(*hdr);
@@ -308,13 +308,35 @@ static int get_fd(const char *mad, int *fd, __be64 
*gid_ifid)
 uint16_t attr_id = be16toh(hdr->attr_id);
 int rc = 0;
 
+if (umad_len <= sizeof(*hdr)) {
+rc = -EINVAL;
+syslog(LOG_DEBUG, "Ignoring MAD packets with header only\n");
+goto out;
+}
+
 switch (attr_id) {
 case UMAD_CM_ATTR_REQ:
+if (unlikely(umad_len < sizeof(*hdr) + CM_REQ_DGID_POS +
+sizeof(*gid_ifid))) {
+rc = -EINVAL;
+syslog(LOG_WARNING,
+   "Invalid MAD packet size (%d) for attr_id 0x%x\n", umad_len,
+attr_id);
+goto out;
+}
 memcpy(gid_ifid, data + CM_REQ_DGID_POS, sizeof(*gid_ifid));
 rc = hash_tbl_search_fd_by_ifid(fd, gid_ifid);
 break;
 
 case UMAD_CM_ATTR_SIDR_REQ:
+if (unlikely(umad_len < sizeof(*hdr) + CM_SIDR_REQ_DGID_POS +
+sizeof(*gid_ifid))) {
+rc = -EINVAL;
+syslog(LOG_WARNING,
+   "Invalid MAD packet size (%d) for attr_id 0x%x\n", umad_len,
+attr_id);
+goto out;
+}
 memcpy(gid_ifid, data + CM_SIDR_REQ_DGID_POS, sizeof(*gid_ifid));
 rc = hash_tbl_search_fd_by_ifid(fd, gid_ifid);
 break;
@@ -331,6 +353,13 @@ static int get_fd(const char *mad, int *fd, __be64 
*gid_ifid)
 data += sizeof(comm_id);
 /* Fall through */
 case UMAD_CM_ATTR_SIDR_REP:
+if (unlikely(umad_len < sizeof(*hdr) + sizeof(comm_id))) {
+rc = -EINVAL;
+syslog(LOG_WARNING,
+   "Invalid MAD packet size (%d) for attr_id 0x%x\n", umad_len,
+   attr_id);
+goto out;
+}
 memcpy(_id, data, sizeof(comm_id));
 if (comm_id) {
 rc = hash_tbl_search_fd_by_comm_id(comm_id, fd, gid_ifid);
@@ -344,6 +373,7 @@ static int get_fd(const char *mad, int *fd, __be64 
*gid_ifid)
 
 syslog(LOG_DEBUG, "mad_to_vm: %d 0x%x 0x%x\n", *fd, attr_id, comm_id);
 
+out:
 return rc;
 }
 
@@ -372,7 +402,8 @@ static void *umad_recv_thread_func(void *args)
 } while (rc && server.run);
 
 if (server.run) {
-rc = get_fd(msg.umad.mad, , _id);
+rc = get_fd(msg.umad.mad, msg.umad_len, ,
+_id);
 if (rc) {
 continue;
 }
-- 
2.17.1




[Qemu-devel] [PATCH PULL 05/18] hw/pvrdma: Collect debugging statistics

2019-03-16 Thread Marcel Apfelbaum
From: Yuval Shaia 

Add counters to enable enhance debugging

Signed-off-by: Yuval Shaia 
Message-Id: <1552300155-25216-5-git-send-email-yuval.sh...@oracle.com>
Reviewed-by: Kamal Heib 
Signed-off-by: Marcel Apfelbaum 
---
 hw/rdma/rdma_backend.c| 70 +--
 hw/rdma/rdma_rm.c |  7 
 hw/rdma/rdma_rm_defs.h| 27 ++-
 hw/rdma/vmw/pvrdma.h  | 10 ++
 hw/rdma/vmw/pvrdma_cmd.c  |  2 ++
 hw/rdma/vmw/pvrdma_main.c |  8 +
 6 files changed, 106 insertions(+), 18 deletions(-)

diff --git a/hw/rdma/rdma_backend.c b/hw/rdma/rdma_backend.c
index 18975401d9..e8af9741b1 100644
--- a/hw/rdma/rdma_backend.c
+++ b/hw/rdma/rdma_backend.c
@@ -64,9 +64,9 @@ static inline void complete_work(enum ibv_wc_status status, 
uint32_t vendor_err,
 comp_handler(ctx, );
 }
 
-static void rdma_poll_cq(RdmaDeviceResources *rdma_dev_res, struct ibv_cq 
*ibcq)
+static int rdma_poll_cq(RdmaDeviceResources *rdma_dev_res, struct ibv_cq *ibcq)
 {
-int i, ne;
+int i, ne, total_ne = 0;
 BackendCtx *bctx;
 struct ibv_wc wc[2];
 
@@ -89,12 +89,18 @@ static void rdma_poll_cq(RdmaDeviceResources *rdma_dev_res, 
struct ibv_cq *ibcq)
 rdma_rm_dealloc_cqe_ctx(rdma_dev_res, wc[i].wr_id);
 g_free(bctx);
 }
+total_ne += ne;
 } while (ne > 0);
+atomic_sub(_dev_res->stats.missing_cqe, total_ne);
 qemu_mutex_unlock(_dev_res->lock);
 
 if (ne < 0) {
 rdma_error_report("ibv_poll_cq fail, rc=%d, errno=%d", ne, errno);
 }
+
+rdma_dev_res->stats.completions += total_ne;
+
+return total_ne;
 }
 
 static void *comp_handler_thread(void *arg)
@@ -122,6 +128,9 @@ static void *comp_handler_thread(void *arg)
 while (backend_dev->comp_thread.run) {
 do {
 rc = qemu_poll_ns(pfds, 1, THR_POLL_TO * (int64_t)SCALE_MS);
+if (!rc) {
+backend_dev->rdma_dev_res->stats.poll_cq_ppoll_to++;
+}
 } while (!rc && backend_dev->comp_thread.run);
 
 if (backend_dev->comp_thread.run) {
@@ -138,6 +147,7 @@ static void *comp_handler_thread(void *arg)
   errno);
 }
 
+backend_dev->rdma_dev_res->stats.poll_cq_from_bk++;
 rdma_poll_cq(backend_dev->rdma_dev_res, ev_cq);
 
 ibv_ack_cq_events(ev_cq, 1);
@@ -271,7 +281,13 @@ int rdma_backend_query_port(RdmaBackendDev *backend_dev,
 
 void rdma_backend_poll_cq(RdmaDeviceResources *rdma_dev_res, RdmaBackendCQ *cq)
 {
-rdma_poll_cq(rdma_dev_res, cq->ibcq);
+int polled;
+
+rdma_dev_res->stats.poll_cq_from_guest++;
+polled = rdma_poll_cq(rdma_dev_res, cq->ibcq);
+if (!polled) {
+rdma_dev_res->stats.poll_cq_from_guest_empty++;
+}
 }
 
 static GHashTable *ah_hash;
@@ -333,7 +349,7 @@ static void ah_cache_init(void)
 
 static int build_host_sge_array(RdmaDeviceResources *rdma_dev_res,
 struct ibv_sge *dsge, struct ibv_sge *ssge,
-uint8_t num_sge)
+uint8_t num_sge, uint64_t *total_length)
 {
 RdmaRmMR *mr;
 int ssge_idx;
@@ -349,6 +365,8 @@ static int build_host_sge_array(RdmaDeviceResources 
*rdma_dev_res,
 dsge->length = ssge[ssge_idx].length;
 dsge->lkey = rdma_backend_mr_lkey(>backend_mr);
 
+*total_length += dsge->length;
+
 dsge++;
 }
 
@@ -445,8 +463,10 @@ void rdma_backend_post_send(RdmaBackendDev *backend_dev,
 rc = mad_send(backend_dev, sgid_idx, sgid, sge, num_sge);
 if (rc) {
 complete_work(IBV_WC_GENERAL_ERR, VENDOR_ERR_MAD_SEND, ctx);
+backend_dev->rdma_dev_res->stats.mad_tx_err++;
 } else {
 complete_work(IBV_WC_SUCCESS, 0, ctx);
+backend_dev->rdma_dev_res->stats.mad_tx++;
 }
 }
 return;
@@ -458,20 +478,21 @@ void rdma_backend_post_send(RdmaBackendDev *backend_dev,
 rc = rdma_rm_alloc_cqe_ctx(backend_dev->rdma_dev_res, _id, bctx);
 if (unlikely(rc)) {
 complete_work(IBV_WC_GENERAL_ERR, VENDOR_ERR_NOMEM, ctx);
-goto out_free_bctx;
+goto err_free_bctx;
 }
 
-rc = build_host_sge_array(backend_dev->rdma_dev_res, new_sge, sge, 
num_sge);
+rc = build_host_sge_array(backend_dev->rdma_dev_res, new_sge, sge, num_sge,
+  _dev->rdma_dev_res->stats.tx_len);
 if (rc) {
 complete_work(IBV_WC_GENERAL_ERR, rc, ctx);
-goto out_dealloc_cqe_ctx;
+goto err_dealloc_cqe_ctx;
 }
 
 if (qp_type == IBV_QPT_UD) {
 wr.wr.ud.ah = create_ah(backend_dev, qp->ibpd, sgid_idx, dgid);
 if (!wr.wr.ud.ah) {
 complete_work(IBV_WC_GENERAL_ERR, VENDOR_ERR_FAIL_BACKEND, ctx);
-goto out_dealloc_cqe_ctx;
+goto err_dealloc_cqe_ctx;
 }
 wr.wr.ud.remote_qpn = dqpn;
 wr.wr.ud.remote_qkey = 

[Qemu-devel] [PATCH PULL 00/18] RDMA queue

2019-03-16 Thread Marcel Apfelbaum
The following changes since commit 8b088d3f8ab5642020d28fa0c2a8d938bc5f3592:

  Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20190315' 
into staging (2019-03-15 11:39:42 +)

are available in the Git repository at:

  https://github.com/marcel-apf/qemu tags/rdma-pull-request

for you to fetch changes up to cb42a5867e7677a9fa1885a8436d3e7e8cb9:

  hw/rdma: Fix the error prints in create_qp_rings() (2019-03-16 15:52:44 +0200)


RDMA queue

 * Another Clang compilation fix
 * Collect pvrdma debugging statistics
 * Various fixes for the pvrdma device


Kamal Heib (5):
  hw/rdma: Fix broken paths to docs/devel/tracing.txt
  hw/rdma: Remove unused parameter from rdma_poll_cq()
  hw/rdma: Use {} instead of {0}
  hw/pvrdma: Fix zero-initialization of resp in {query/modify}_qp
  hw/rdma: Fix the error prints in create_qp_rings()

Marcel Apfelbaum (1):
  hw/rdma: another clang compilation fix

Yuval Shaia (12):
  contrib/rdmacm-mux: Fix out-of-bounds risk
  hw/rdma: Switch to generic error reporting way
  hw/rdma: Introduce protected qlist
  hw/rdma: Protect against concurrent execution of poll_cq
  hw/pvrdma: Collect debugging statistics
  {hmp, hw/pvrdma}: Expose device internals via monitor interface
  hw/rdma: Free all MAD receive buffers when device is closed
  hw/rdma: Free all receive buffers when QP is destroyed
  hw/pvrdma: Delete unneeded function argument
  hw/pvrdma: Delete pvrdma_exit function
  hw/pvrdma: Unregister from shutdown notifier when device goes down
  hw/pvrdma: Provide correct value to object_get_typename

 contrib/rdmacm-mux/main.c |  35 ++-
 hmp-commands-info.hx  |  14 ++
 hmp.c |  27 +++
 hmp.h |   1 +
 hw/rdma/Makefile.objs |   2 +-
 hw/rdma/rdma.c|  30 +++
 hw/rdma/rdma_backend.c| 518 +-
 hw/rdma/rdma_backend.h|   7 +-
 hw/rdma/rdma_backend_defs.h   |  10 +-
 hw/rdma/rdma_rm.c | 196 +---
 hw/rdma/rdma_rm.h |  11 +-
 hw/rdma/rdma_rm_defs.h|  32 ++-
 hw/rdma/rdma_utils.c  |  83 ++-
 hw/rdma/rdma_utils.h  |  61 ++---
 hw/rdma/trace-events  |  34 ++-
 hw/rdma/vmw/pvrdma.h  |  12 +-
 hw/rdma/vmw/pvrdma_cmd.c  | 121 +++---
 hw/rdma/vmw/pvrdma_dev_ring.c |  26 +--
 hw/rdma/vmw/pvrdma_main.c | 182 +++
 hw/rdma/vmw/pvrdma_qp_ops.c   |  54 ++---
 hw/rdma/vmw/trace-events  |  18 +-
 include/hw/rdma/rdma.h|  40 
 22 files changed, 865 insertions(+), 649 deletions(-)
 create mode 100644 hw/rdma/rdma.c
 create mode 100644 include/hw/rdma/rdma.h

-- 
2.17.1




Re: [Qemu-devel] [PATCH v4 0/2] ati-vga: Implement DDC and EDID info from monitor

2019-03-16 Thread BALATON Zoltan

On Sat, 16 Mar 2019, BALATON Zoltan wrote:

Version 4 try to fix an ASan warning about leaking bitbang_i2c.


I still get ASan warning but it's about gpio_i2c_init in bitbang_i2c.c 
which I haven't changed nor using so I think this is pre-existing problem 
in bitbang_i2c.c which was exposed by touching it now so I'm not trying to 
fix. (Maybe adding an exit function to free the allocated bitbang_i2c in 
object state could help but I think it still leaks the bus so I'm not sure 
how to handle it correctly. Maybe this should be QOMified somehow but 
cannot be a device because it's not connected to a bus but embedded in 
other device models.)


Regards,
BALATON Zoltan


Version 3 keeps bitbang_i2c.h and moves it to include/hw/i2c/
otherwise same as version 2.

BALATON Zoltan (2):
 i2c: Move bitbang_i2c.h to include/hw/i2c/
 ati-vga: Implement DDC and EDID info from monitor

hw/display/Kconfig   |  2 ++
hw/display/ati.c | 44 ++--
hw/display/ati_int.h |  4 
hw/display/ati_regs.h|  1 +
hw/i2c/bitbang_i2c.c |  2 +-
hw/i2c/ppc4xx_i2c.c  |  1 -
hw/i2c/versatile_i2c.c   |  2 +-
{hw => include/hw}/i2c/bitbang_i2c.h |  2 ++
include/hw/i2c/i2c.h |  2 --
include/hw/i2c/ppc4xx_i2c.h  |  2 +-
10 files changed, 54 insertions(+), 8 deletions(-)
rename {hw => include/hw}/i2c/bitbang_i2c.h (80%)






Re: [Qemu-devel] [PATCH] hw/s390x: fix clang compilation on 32bit machines

2019-03-16 Thread Marcel Apfelbaum

Hi Philippe,

On 3/16/19 1:09 PM, Philippe Mathieu-Daudé wrote:

Hi Marcel,

On 3/16/19 10:50 AM, Marcel Apfelbaum wrote:

Configuring QEMU with:
 configure --cc=clang --target-list=s390x-softmmu
And compiling it using a 32 bit machine leads to:

Because there sizeof(ram_addr_t) = sizeof(uintptr_t) = 32.


Right


 hw/s390x/s390-virtio-ccw.c:175:27: error: implicit conversion from
   'unsigned long long' to 'ram_addr_t' (aka 'unsigned int') changes value
   from 8796091973632 to 4293918720 [-Werror,-Wconstant-conversion]
 chunk = MIN(size, KVM_SLOT_MAX_BYTES);
   ~ ~~^~~

The comment 1 line earlier is:

 /* KVM does not allow memslots >= 8 TB */

Clang is correct, this KVM_SLOT_MAX_BYTES is incorrect on a 32bit s390,
you need a 64bit system.

Per Hacking:

   Use hwaddr for guest physical addresses except pcibus_t
   for PCI addresses.  In addition, ram_addr_t is a QEMU internal address
   space that maps guest RAM physical addresses into an intermediate
   address space that can map to host virtual address spaces.  Generally
   speaking, the size of guest memory can always fit into ram_addr_t but
   it would not be correct to store an actual guest physical address in a
   ram_addr_t.

My understanding is we should not use ram_addr_t with KVM but rather
hwaddr, but I'm not sure.

I don't know about s390, if 32bit host is supported or supports KVM.
If it is, maybe this could work:

I don't think the following is clean:

#if TARGET_LONG_BITS == 32
# define KVM_SLOT_MAX_BYTES RAM_ADDR_MAX
#else
# define KVM_SLOT_MAX_BYTES \
  ((KVM_MEM_MAX_NR_PAGES * TARGET_PAGE_SIZE) & SEG_MSK)
#endif

But checking ifdef CONFIG_KVM might be clever:

-- >8 --
@@ -161,7 +161,7 @@ static void virtio_ccw_register_hcalls(void)
  static void s390_memory_init(ram_addr_t mem_size)
  {
  MemoryRegion *sysmem = get_system_memory();
-ram_addr_t chunk, offset = 0;
+hwaddr offset = 0;
  unsigned int number = 0;
  gchar *name;

@@ -169,14 +169,16 @@ static void s390_memory_init(ram_addr_t mem_size)
  name = g_strdup_printf("s390.ram");
  while (mem_size) {
  MemoryRegion *ram = g_new(MemoryRegion, 1);
-uint64_t size = mem_size;
+uint64_t chunk_size = mem_size;

+#ifdef CONFIG_KVM
  /* KVM does not allow memslots >= 8 TB */
-chunk = MIN(size, KVM_SLOT_MAX_BYTES);
-memory_region_allocate_system_memory(ram, NULL, name, chunk);
+chunk_size = MIN(mem_size, KVM_SLOT_MAX_BYTES);
+#endif
+memory_region_allocate_system_memory(ram, NULL, name, chunk_size);
  memory_region_add_subregion(sysmem, offset, ram);
-mem_size -= chunk;
-offset += chunk;
+mem_size -= chunk_size;
+offset += chunk_size;
  g_free(name);
  name = g_strdup_printf("s390.ram.%u", ++number);
  }
---


Looks fairly complicated, the chunk variable will be used by
memory_region_allocate_system_memory as 'ram_size' parameter, not an 
address.

Also it is initialized by a MIN macro with the first operand being uint64_t.

It just seems to me that if some kind of 'check' is needed, maybe is not 
related

to the variable type (in this case).



Anyway s390x experts will figure that out ;)


Definitely!

Thanks for the review,
Marcel


Regards,

Phil.


Fix the missmatch by declaring the 'chunk' variable as uint64_t.

Signed-off-by: Marcel Apfelbaum 
---
  hw/s390x/s390-virtio-ccw.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index d11069b860..2efa47bc3e 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -161,7 +161,7 @@ static void virtio_ccw_register_hcalls(void)
  static void s390_memory_init(ram_addr_t mem_size)
  {
  MemoryRegion *sysmem = get_system_memory();
-ram_addr_t chunk, offset = 0;
+uint64_t chunk, offset = 0;
  unsigned int number = 0;
  gchar *name;
  






Re: [Qemu-devel] [PATCH v4 0/2] ati-vga: Implement DDC and EDID info from monitor

2019-03-16 Thread no-reply
Patchew URL: https://patchew.org/QEMU/cover.1552737957.git.bala...@eik.bme.hu/



Hi,

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

=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-debug@fedora TARGET_LIST=x86_64-softmmu J=14 NETWORK=1
=== TEST SCRIPT END ===

PASS 1 fdc-test /x86_64/fdc/cmos
PASS 2 fdc-test /x86_64/fdc/no_media_on_start
PASS 3 fdc-test /x86_64/fdc/read_without_media
==7573==WARNING: ASan doesn't fully support makecontext/swapcontext functions 
and may produce false positives in some cases!
PASS 4 fdc-test /x86_64/fdc/media_change
PASS 5 fdc-test /x86_64/fdc/sense_interrupt
PASS 6 fdc-test /x86_64/fdc/relative_seek
---
PASS 32 test-opts-visitor /visitor/opts/range/beyond
PASS 33 test-opts-visitor /visitor/opts/dict/unvisited
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  
tests/test-coroutine -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl 
--test-name="test-coroutine" 
==7628==WARNING: ASan doesn't fully support makecontext/swapcontext functions 
and may produce false positives in some cases!
==7628==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 
0x7ffcc0467000; bottom 0x7fa9b61f8000; size: 0x00530a26f000 (356652609536)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
PASS 1 test-coroutine /basic/no-dangling-access
---
PASS 11 test-aio /aio/event/wait
PASS 12 test-aio /aio/event/flush
PASS 13 test-aio /aio/event/wait/no-flush-cb
==7643==WARNING: ASan doesn't fully support makecontext/swapcontext functions 
and may produce false positives in some cases!
PASS 14 test-aio /aio/timer/schedule
PASS 15 test-aio /aio/coroutine/queue-chaining
PASS 16 test-aio /aio-gsource/flush
---
PASS 12 fdc-test /x86_64/fdc/read_no_dma_19
PASS 13 fdc-test /x86_64/fdc/fuzz-registers
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  
tests/test-aio-multithread -m=quick -k --tap < /dev/null | 
./scripts/tap-driver.pl --test-name="test-aio-multithread" 
==7650==WARNING: ASan doesn't fully support makecontext/swapcontext functions 
and may produce false positives in some cases!
PASS 1 test-aio-multithread /aio/multi/lifecycle
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  
QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64 QTEST_QEMU_IMG=qemu-img 
tests/ide-test -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl 
--test-name="ide-test" 
PASS 2 test-aio-multithread /aio/multi/schedule
==7667==WARNING: ASan doesn't fully support makecontext/swapcontext functions 
and may produce false positives in some cases!
PASS 1 ide-test /x86_64/ide/identify
PASS 3 test-aio-multithread /aio/multi/mutex/contended
==7678==WARNING: ASan doesn't fully support makecontext/swapcontext functions 
and may produce false positives in some cases!
PASS 2 ide-test /x86_64/ide/flush
==7689==WARNING: ASan doesn't fully support makecontext/swapcontext functions 
and may produce false positives in some cases!
PASS 3 ide-test /x86_64/ide/bmdma/setup
PASS 4 ide-test /x86_64/ide/bmdma/simple_rw
PASS 5 ide-test /x86_64/ide/bmdma/trim
PASS 6 ide-test /x86_64/ide/bmdma/short_prdt
PASS 7 ide-test /x86_64/ide/bmdma/one_sector_short_prdt
PASS 8 ide-test /x86_64/ide/bmdma/long_prdt
==7689==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 
0x7ffe66446000; bottom 0x7faf800f9000; size: 0x004ee634d000 (338869669888)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
PASS 9 ide-test /x86_64/ide/bmdma/no_busmaster
PASS 10 ide-test /x86_64/ide/bmdma/teardown
PASS 4 test-aio-multithread /aio/multi/mutex/handoff
PASS 11 ide-test /x86_64/ide/flush/nodev
==7705==WARNING: ASan doesn't fully support makecontext/swapcontext functions 
and may produce false positives in some cases!
PASS 5 test-aio-multithread /aio/multi/mutex/mcs
PASS 12 ide-test /x86_64/ide/flush/empty_drive
PASS 6 test-aio-multithread /aio/multi/mutex/pthread
==7715==WARNING: ASan doesn't fully support makecontext/swapcontext functions 
and may produce false positives in some cases!
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  
tests/test-throttle -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl 
--test-name="test-throttle" 
PASS 1 test-throttle /throttle/leak_bucket
PASS 2 test-throttle /throttle/compute_wait
---
PASS 5 test-throttle /throttle/have_timer
PASS 6 test-throttle /throttle/detach_attach
PASS 7 test-throttle /throttle/config_functions
==7722==WARNING: ASan doesn't fully support makecontext/swapcontext functions 
and may produce false positives in some cases!
PASS 8 test-throttle /throttle/accounting
PASS 9 test-throttle /throttle/groups
PASS 10 test-throttle /throttle/config/enabled
---
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  
tests/test-thread-pool -m=quick -k --tap < /dev/null | 

[Qemu-devel] [PATCH v4 0/2] ati-vga: Implement DDC and EDID info from monitor

2019-03-16 Thread BALATON Zoltan
Version 4 try to fix an ASan warning about leaking bitbang_i2c.
Version 3 keeps bitbang_i2c.h and moves it to include/hw/i2c/
otherwise same as version 2.

BALATON Zoltan (2):
  i2c: Move bitbang_i2c.h to include/hw/i2c/
  ati-vga: Implement DDC and EDID info from monitor

 hw/display/Kconfig   |  2 ++
 hw/display/ati.c | 44 ++--
 hw/display/ati_int.h |  4 
 hw/display/ati_regs.h|  1 +
 hw/i2c/bitbang_i2c.c |  2 +-
 hw/i2c/ppc4xx_i2c.c  |  1 -
 hw/i2c/versatile_i2c.c   |  2 +-
 {hw => include/hw}/i2c/bitbang_i2c.h |  2 ++
 include/hw/i2c/i2c.h |  2 --
 include/hw/i2c/ppc4xx_i2c.h  |  2 +-
 10 files changed, 54 insertions(+), 8 deletions(-)
 rename {hw => include/hw}/i2c/bitbang_i2c.h (80%)

-- 
2.13.7




[Qemu-devel] [PATCH v4 2/2] ati-vga: Implement DDC and EDID info from monitor

2019-03-16 Thread BALATON Zoltan
This adds DDC support to ati-vga and connects i2c-ddc to provide EDID
info that is read by guests to find available screen modes. Not sure
if this is 100% correct yet but at least MorphOS is happy with it and
starts in a high resolution mode instead of 640x480 (although its
splash screen is still not correct). Linux needs support from VESA
vgabios, it seems to be missing INT10 0x4F15 function (see
https://gitlab.freedesktop.org/xorg/xserver/blob/master/hw/xfree86/vbe/vbe.c)
without which no DDC is available that also prevents loading the
accelerated X driver.

Signed-off-by: BALATON Zoltan 
---
 hw/display/Kconfig|  2 ++
 hw/display/ati.c  | 44 ++--
 hw/display/ati_int.h  |  4 
 hw/display/ati_regs.h |  1 +
 4 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/hw/display/Kconfig b/hw/display/Kconfig
index 86c1d544c5..f8d65802a9 100644
--- a/hw/display/Kconfig
+++ b/hw/display/Kconfig
@@ -112,3 +112,5 @@ config ATI_VGA
 default y if PCI_DEVICES
 depends on PCI
 select VGA
+select BITBANG_I2C
+select DDC
diff --git a/hw/display/ati.c b/hw/display/ati.c
index 8322f52aff..055cc69e16 100644
--- a/hw/display/ati.c
+++ b/hw/display/ati.c
@@ -24,6 +24,7 @@
 #include "qapi/error.h"
 #include "hw/hw.h"
 #include "ui/console.h"
+#include "hw/i2c/i2c-ddc.h"
 #include "trace.h"
 
 #define ATI_DEBUG_HW_CURSOR 0
@@ -267,7 +268,12 @@ static uint64_t ati_mm_read(void *opaque, hwaddr addr, 
unsigned int size)
 case DAC_CNTL:
 val = s->regs.dac_cntl;
 break;
-/*case GPIO_MONID: FIXME hook up DDC I2C here */
+case GPIO_DVI_DDC:
+val = s->regs.gpio_dvi_ddc;
+break;
+case GPIO_MONID:
+val = s->regs.gpio_monid;
+break;
 case PALETTE_INDEX:
 /* FIXME unaligned access */
 val = vga_ioport_read(>vga, VGA_PEL_IR) << 16;
@@ -501,7 +507,34 @@ static void ati_mm_write(void *opaque, hwaddr addr,
 s->regs.dac_cntl = data & 0xe3ff;
 s->vga.dac_8bit = !!(data & DAC_8BIT_EN);
 break;
-/*case GPIO_MONID: FIXME hook up DDC I2C here */
+case GPIO_DVI_DDC:
+if (s->dev_id == PCI_DEVICE_ID_ATI_RAGE128_PF) {
+break;
+}
+s->regs.gpio_dvi_ddc = data & 0xf000f;
+if (data & BIT(17)) {
+s->regs.gpio_dvi_ddc |= !!(data & BIT(1)) << 9;
+bitbang_i2c_set(s->bbi2c, BITBANG_I2C_SCL, (data & BIT(1)) != 0);
+}
+if (data & BIT(16)) {
+s->regs.gpio_dvi_ddc |= bitbang_i2c_set(s->bbi2c, BITBANG_I2C_SDA,
+data & BIT(0)) << 8;
+}
+break;
+case GPIO_MONID:
+if (s->dev_id != PCI_DEVICE_ID_ATI_RAGE128_PF) {
+break; /* FIXME What does Radeon have here? */
+}
+s->regs.gpio_monid = data & 0x0f0f000f;
+if (data & BIT(2) << 24) {
+s->regs.gpio_monid |= !!(data & BIT(2)) << 10;
+bitbang_i2c_set(s->bbi2c, BITBANG_I2C_SCL, (data & BIT(2)) != 0);
+}
+if (data & BIT(1) << 24) {
+s->regs.gpio_monid |= bitbang_i2c_set(s->bbi2c, BITBANG_I2C_SDA,
+  (data & BIT(1)) != 0) << 9;
+}
+break;
 case PALETTE_INDEX ... PALETTE_INDEX + 3:
 if (size == 4) {
 vga_ioport_write(>vga, VGA_PEL_IR, (data >> 16) & 0xff);
@@ -792,6 +825,12 @@ static void ati_vga_realize(PCIDevice *dev, Error **errp)
 vga->cursor_draw_line = ati_cursor_draw_line;
 }
 
+/* ddc, edid */
+I2CBus *i2cbus = i2c_init_bus(DEVICE(s), "ati-vga.ddc");
+s->bbi2c = bitbang_i2c_init(i2cbus);
+I2CSlave *i2cddc = I2C_SLAVE(qdev_create(BUS(i2cbus), TYPE_I2CDDC));
+i2c_set_slave_address(i2cddc, 0x50);
+
 /* mmio register space */
 memory_region_init_io(>mm, OBJECT(s), _mm_ops, s,
   "ati.mmregs", 0x4000);
@@ -817,6 +856,7 @@ static void ati_vga_exit(PCIDevice *dev)
 ATIVGAState *s = ATI_VGA(dev);
 
 graphic_console_close(s->vga.con);
+g_free(s->bbi2c);
 }
 
 static Property ati_vga_properties[] = {
diff --git a/hw/display/ati_int.h b/hw/display/ati_int.h
index a6f3e20e63..bad1846c76 100644
--- a/hw/display/ati_int.h
+++ b/hw/display/ati_int.h
@@ -11,6 +11,7 @@
 
 #include "qemu/osdep.h"
 #include "hw/pci/pci.h"
+#include "hw/i2c/bitbang_i2c.h"
 #include "vga_int.h"
 
 /*#define DEBUG_ATI*/
@@ -36,6 +37,8 @@ typedef struct ATIVGARegs {
 uint32_t crtc_gen_cntl;
 uint32_t crtc_ext_cntl;
 uint32_t dac_cntl;
+uint32_t gpio_dvi_ddc;
+uint32_t gpio_monid;
 uint32_t crtc_h_total_disp;
 uint32_t crtc_h_sync_strt_wid;
 uint32_t crtc_v_total_disp;
@@ -84,6 +87,7 @@ typedef struct ATIVGAState {
 uint16_t cursor_size;
 uint32_t cursor_offset;
 QEMUCursor *cursor;
+bitbang_i2c_interface *bbi2c;
 MemoryRegion io;
 MemoryRegion mm;
 ATIVGARegs regs;
diff --git 

[Qemu-devel] [PATCH v4 1/2] i2c: Move bitbang_i2c.h to include/hw/i2c/

2019-03-16 Thread BALATON Zoltan
The bitbang i2c implementation is also useful for other device models
such as DDC in display controllers. Move the header to include/hw/i2c/
to allow it to be used from other device models and adjust users of
this include. This also reverts commit 2b4c1125ac which is no longer
needed.

Signed-off-by: BALATON Zoltan 
---
 hw/i2c/bitbang_i2c.c | 2 +-
 hw/i2c/ppc4xx_i2c.c  | 1 -
 hw/i2c/versatile_i2c.c   | 2 +-
 {hw => include/hw}/i2c/bitbang_i2c.h | 2 ++
 include/hw/i2c/i2c.h | 2 --
 include/hw/i2c/ppc4xx_i2c.h  | 2 +-
 6 files changed, 5 insertions(+), 6 deletions(-)
 rename {hw => include/hw}/i2c/bitbang_i2c.h (80%)

diff --git a/hw/i2c/bitbang_i2c.c b/hw/i2c/bitbang_i2c.c
index 8be88ee265..b3534a3bd4 100644
--- a/hw/i2c/bitbang_i2c.c
+++ b/hw/i2c/bitbang_i2c.c
@@ -11,7 +11,7 @@
  */
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "bitbang_i2c.h"
+#include "hw/i2c/bitbang_i2c.h"
 #include "hw/sysbus.h"
 
 //#define DEBUG_BITBANG_I2C
diff --git a/hw/i2c/ppc4xx_i2c.c b/hw/i2c/ppc4xx_i2c.c
index d6dfafab31..a907d0194e 100644
--- a/hw/i2c/ppc4xx_i2c.c
+++ b/hw/i2c/ppc4xx_i2c.c
@@ -30,7 +30,6 @@
 #include "cpu.h"
 #include "hw/hw.h"
 #include "hw/i2c/ppc4xx_i2c.h"
-#include "bitbang_i2c.h"
 
 #define PPC4xx_I2C_MEM_SIZE 18
 
diff --git a/hw/i2c/versatile_i2c.c b/hw/i2c/versatile_i2c.c
index da9f298ee5..39cbcf1948 100644
--- a/hw/i2c/versatile_i2c.c
+++ b/hw/i2c/versatile_i2c.c
@@ -23,7 +23,7 @@
 
 #include "qemu/osdep.h"
 #include "hw/sysbus.h"
-#include "bitbang_i2c.h"
+#include "hw/i2c/bitbang_i2c.h"
 #include "qemu/log.h"
 
 #define TYPE_VERSATILE_I2C "versatile_i2c"
diff --git a/hw/i2c/bitbang_i2c.h b/include/hw/i2c/bitbang_i2c.h
similarity index 80%
rename from hw/i2c/bitbang_i2c.h
rename to include/hw/i2c/bitbang_i2c.h
index 9443021710..3a7126d5de 100644
--- a/hw/i2c/bitbang_i2c.h
+++ b/include/hw/i2c/bitbang_i2c.h
@@ -3,6 +3,8 @@
 
 #include "hw/i2c/i2c.h"
 
+typedef struct bitbang_i2c_interface bitbang_i2c_interface;
+
 #define BITBANG_I2C_SDA 0
 #define BITBANG_I2C_SCL 1
 
diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h
index 8e236f7bb4..75c5bd638b 100644
--- a/include/hw/i2c/i2c.h
+++ b/include/hw/i2c/i2c.h
@@ -81,8 +81,6 @@ uint8_t i2c_recv(I2CBus *bus);
 
 DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t addr);
 
-typedef struct bitbang_i2c_interface bitbang_i2c_interface;
-
 /* lm832x.c */
 void lm832x_key_event(DeviceState *dev, int key, int state);
 
diff --git a/include/hw/i2c/ppc4xx_i2c.h b/include/hw/i2c/ppc4xx_i2c.h
index b3450bacf7..368a5598fe 100644
--- a/include/hw/i2c/ppc4xx_i2c.h
+++ b/include/hw/i2c/ppc4xx_i2c.h
@@ -29,7 +29,7 @@
 
 #include "qemu-common.h"
 #include "hw/sysbus.h"
-#include "hw/i2c/i2c.h"
+#include "hw/i2c/bitbang_i2c.h"
 
 #define TYPE_PPC4xx_I2C "ppc4xx-i2c"
 #define PPC4xx_I2C(obj) OBJECT_CHECK(PPC4xxI2CState, (obj), TYPE_PPC4xx_I2C)
-- 
2.13.7




Re: [Qemu-devel] [PATCH] hw/s390x: fix clang compilation on 32bit machines

2019-03-16 Thread Philippe Mathieu-Daudé
Hi Marcel,

On 3/16/19 10:50 AM, Marcel Apfelbaum wrote:
> Configuring QEMU with:
> configure --cc=clang --target-list=s390x-softmmu
> And compiling it using a 32 bit machine leads to:

Because there sizeof(ram_addr_t) = sizeof(uintptr_t) = 32.

> hw/s390x/s390-virtio-ccw.c:175:27: error: implicit conversion from
>   'unsigned long long' to 'ram_addr_t' (aka 'unsigned int') changes value
>   from 8796091973632 to 4293918720 [-Werror,-Wconstant-conversion]
> chunk = MIN(size, KVM_SLOT_MAX_BYTES);
>   ~ ~~^~~

The comment 1 line earlier is:

/* KVM does not allow memslots >= 8 TB */

Clang is correct, this KVM_SLOT_MAX_BYTES is incorrect on a 32bit s390,
you need a 64bit system.

Per Hacking:

  Use hwaddr for guest physical addresses except pcibus_t
  for PCI addresses.  In addition, ram_addr_t is a QEMU internal address
  space that maps guest RAM physical addresses into an intermediate
  address space that can map to host virtual address spaces.  Generally
  speaking, the size of guest memory can always fit into ram_addr_t but
  it would not be correct to store an actual guest physical address in a
  ram_addr_t.

My understanding is we should not use ram_addr_t with KVM but rather
hwaddr, but I'm not sure.

I don't know about s390, if 32bit host is supported or supports KVM.
If it is, maybe this could work:

I don't think the following is clean:

#if TARGET_LONG_BITS == 32
# define KVM_SLOT_MAX_BYTES RAM_ADDR_MAX
#else
# define KVM_SLOT_MAX_BYTES \
 ((KVM_MEM_MAX_NR_PAGES * TARGET_PAGE_SIZE) & SEG_MSK)
#endif

But checking ifdef CONFIG_KVM might be clever:

-- >8 --
@@ -161,7 +161,7 @@ static void virtio_ccw_register_hcalls(void)
 static void s390_memory_init(ram_addr_t mem_size)
 {
 MemoryRegion *sysmem = get_system_memory();
-ram_addr_t chunk, offset = 0;
+hwaddr offset = 0;
 unsigned int number = 0;
 gchar *name;

@@ -169,14 +169,16 @@ static void s390_memory_init(ram_addr_t mem_size)
 name = g_strdup_printf("s390.ram");
 while (mem_size) {
 MemoryRegion *ram = g_new(MemoryRegion, 1);
-uint64_t size = mem_size;
+uint64_t chunk_size = mem_size;

+#ifdef CONFIG_KVM
 /* KVM does not allow memslots >= 8 TB */
-chunk = MIN(size, KVM_SLOT_MAX_BYTES);
-memory_region_allocate_system_memory(ram, NULL, name, chunk);
+chunk_size = MIN(mem_size, KVM_SLOT_MAX_BYTES);
+#endif
+memory_region_allocate_system_memory(ram, NULL, name, chunk_size);
 memory_region_add_subregion(sysmem, offset, ram);
-mem_size -= chunk;
-offset += chunk;
+mem_size -= chunk_size;
+offset += chunk_size;
 g_free(name);
 name = g_strdup_printf("s390.ram.%u", ++number);
 }
---

Anyway s390x experts will figure that out ;)

Regards,

Phil.

> 
> Fix the missmatch by declaring the 'chunk' variable as uint64_t.
> 
> Signed-off-by: Marcel Apfelbaum 
> ---
>  hw/s390x/s390-virtio-ccw.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
> index d11069b860..2efa47bc3e 100644
> --- a/hw/s390x/s390-virtio-ccw.c
> +++ b/hw/s390x/s390-virtio-ccw.c
> @@ -161,7 +161,7 @@ static void virtio_ccw_register_hcalls(void)
>  static void s390_memory_init(ram_addr_t mem_size)
>  {
>  MemoryRegion *sysmem = get_system_memory();
> -ram_addr_t chunk, offset = 0;
> +uint64_t chunk, offset = 0;
>  unsigned int number = 0;
>  gchar *name;
>  
> 



Re: [Qemu-devel] [RFC PATCH 3/3] hw/acpi: Extract build_mcfg

2019-03-16 Thread Wei Yang
On Thu, Mar 14, 2019 at 10:18:30AM +0100, Igor Mammedov wrote:
>On Wed, 13 Mar 2019 21:31:37 +
>Wei Yang  wrote:
>
>> On Wed, Mar 13, 2019 at 05:09:43PM +0100, Igor Mammedov wrote:
>> >On Wed, 13 Mar 2019 13:33:59 +
>> >Wei Yang  wrote:
>> >  
>> >> On Wed, Mar 13, 2019 at 01:23:00PM +0100, Igor Mammedov wrote:  
>> >> >On Wed, 13 Mar 2019 12:42:53 +0800
>> >> >Wei Yang  wrote:
>> >> >
>> >> >> Now we have two identical build_mcfg function.
>> >> >> 
>> >> >> Extract them to aml-build.c.
>> >> >> 
>> >> >> Signed-off-by: Wei Yang 
>> >> >> ---
>> >> >>  hw/acpi/aml-build.c | 30 ++
>> >> >>  hw/arm/virt-acpi-build.c| 16 
>> >> >>  hw/i386/acpi-build.c| 31 +--
>> >> >>  include/hw/acpi/aml-build.h |  1 +
>> >> >>  4 files changed, 32 insertions(+), 46 deletions(-)
>> >> >> 
>> >> >> diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
>> >> >> index 555c24f21d..58d3b8f31d 100644
>> >> >> --- a/hw/acpi/aml-build.c
>> >> >> +++ b/hw/acpi/aml-build.c
>> >> >

[...]

>> >I mean do not call build_mcfg() at all when you don't have to.
>> >
>> >And when you need to keep table_blob the same size (for old machines)
>> >using acpi_data_push() to reserve space instead of build_mcfg(sig="QEMU")
>> >might just work as well. it's still hack but it can live in x86 specific
>> >acpi_build() keeping build_mcfg() generic.
>> >  
>> 
>> Seems got your idea.
>> 
>> >As for defining what to use as criteria to decide when we need to keep
>> >table_blob size the same, I don't remember history of it, so I'd suggest
>> >to look at commit a1666142, study history of acpi_ram_update() and
>> >legacy_acpi_table_size to figure out since which machine type one doesn't
>> >have to keep table_blob size the same.
>> >  
>> 
>> OK, let me study the history first.
>> 
>> BTW, the legacy here is hardware specification level or qemu software
>> design level?
>it's QEMU only, you need to find a version of QEMU (machine type)
>which didn't have re-sizable MemoryRegion and the next version most likely
>would have a knob somewhere in machine class definition saying that we don't
>care about sizes anymore or care about sizes only for previous machine types.

I have got something, but not sure this is correct. So I'd like to
summarize them here first.

The following commits are ordered in timeline.

1. First we introduced resizable MR.

a1666142db 2015-01-08 acpi-build: make ROMs RAM blocks resizeable
60786ef339 2015-01-08 memory: API to allocate resizeable RAM MR

2. Then acpi_ram_update in introduced

339240b5cd 2015-04-27 acpi-build: remove dependency from ram_addr.h
42d859001d 2015-02-26 acpi-build: fix ACPI RAM management

3. After that we introduce 2.4 machine type

5cb50e0acc 2015-04-27 pc: add 2.4 machine types

But I don't find a comment stating we don't care about sizes anymore.

Below is my understanding of the dummy table history. 

Before resizable MR was introduced, the dummy table is used to be a
place holder so that we could add real table in acpi_build_update().
Othersize the new ACPI table is bigger to be placed into
build_state->table_mr.

If this is correct, after commit a1666142db ACPI table has the
capability to expand itself and not necessary to pre-allocate the dummy
table. Can I say after commit a1666142db, we don't need to put a fake
table in ACPI?

Another confusion is in the comment of build_mcfg(). In which aspect, it
relates to migration? Is this before resizable MR introduced?

-- 
Wei Yang
Help you, Help me



[Qemu-devel] [PATCH] hw/s390x: fix clang compilation on 32bit machines

2019-03-16 Thread Marcel Apfelbaum
Configuring QEMU with:
configure --cc=clang --target-list=s390x-softmmu
And compiling it using a 32 bit machine leads to:
hw/s390x/s390-virtio-ccw.c:175:27: error: implicit conversion from
  'unsigned long long' to 'ram_addr_t' (aka 'unsigned int') changes value
  from 8796091973632 to 4293918720 [-Werror,-Wconstant-conversion]
chunk = MIN(size, KVM_SLOT_MAX_BYTES);
  ~ ~~^~~

Fix the missmatch by declaring the 'chunk' variable as uint64_t.

Signed-off-by: Marcel Apfelbaum 
---
 hw/s390x/s390-virtio-ccw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index d11069b860..2efa47bc3e 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -161,7 +161,7 @@ static void virtio_ccw_register_hcalls(void)
 static void s390_memory_init(ram_addr_t mem_size)
 {
 MemoryRegion *sysmem = get_system_memory();
-ram_addr_t chunk, offset = 0;
+uint64_t chunk, offset = 0;
 unsigned int number = 0;
 gchar *name;
 
-- 
2.17.1