OSDN Git Service

qmiga/qemu.git
5 years agotarget/arm: Honour M-profile FP enable bits
Peter Maydell [Mon, 29 Apr 2019 16:35:58 +0000 (17:35 +0100)]
target/arm: Honour M-profile FP enable bits

Like AArch64, M-profile floating point has no FPEXC enable
bit to gate floating point; so always set the VFPEN TB flag.

M-profile also has CPACR and NSACR similar to A-profile;
they behave slightly differently:
 * the CPACR is banked between Secure and Non-Secure
 * if the NSACR forces a trap then this is taken to
   the Secure state, not the Non-Secure state

Honour the CPACR and NSACR settings. The NSACR handling
requires us to borrow the exception.target_el field
(usually meaningless for M profile) to distinguish the
NOCP UsageFault taken to Secure state from the more
usual fault taken to the current security state.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20190416125744.27770-6-peter.maydell@linaro.org

5 years agotarget/arm: Disable most VFP sysregs for M-profile
Peter Maydell [Mon, 29 Apr 2019 16:35:58 +0000 (17:35 +0100)]
target/arm: Disable most VFP sysregs for M-profile

The only "system register" that M-profile floating point exposes
via the VMRS/VMRS instructions is FPSCR, and it does not have
the odd special case for rd==15. Add a check to ensure we only
expose FPSCR.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20190416125744.27770-5-peter.maydell@linaro.org

5 years agotarget/arm: Implement dummy versions of M-profile FP-related registers
Peter Maydell [Mon, 29 Apr 2019 16:35:58 +0000 (17:35 +0100)]
target/arm: Implement dummy versions of M-profile FP-related registers

The M-profile floating point support has three associated config
registers: FPCAR, FPCCR and FPDSCR. It also makes the registers
CPACR and NSACR have behaviour other than reads-as-zero.
Add support for all of these as simple reads-as-written registers.
We will hook up actual functionality later.

The main complexity here is handling the FPCCR register, which
has a mix of banked and unbanked bits.

Note that we don't share storage with the A-profile
cpu->cp15.nsacr and cpu->cp15.cpacr_el1, though the behaviour
is quite similar, for two reasons:
 * the M profile CPACR is banked between security states
 * it preserves the invariant that M profile uses no state
   inside the cp15 substruct

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20190416125744.27770-4-peter.maydell@linaro.org

5 years agohw/intc/armv7m_nvic: Allow reading of M-profile MVFR* registers
Peter Maydell [Mon, 29 Apr 2019 16:35:58 +0000 (17:35 +0100)]
hw/intc/armv7m_nvic: Allow reading of M-profile MVFR* registers

For M-profile the MVFR* ID registers are memory mapped, in the
range we implement via the NVIC. Allow them to be read.
(If the CPU has no FPU, these registers are defined to be RAZ.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20190416125744.27770-3-peter.maydell@linaro.org

5 years agotarget/arm: Make sure M-profile FPSCR RES0 bits are not settable
Peter Maydell [Mon, 29 Apr 2019 16:35:58 +0000 (17:35 +0100)]
target/arm: Make sure M-profile FPSCR RES0 bits are not settable

Enforce that for M-profile various FPSCR bits which are RES0 there
but have defined meanings on A-profile are never settable. This
ensures that M-profile code can't enable the A-profile behaviour
(notably vector length/stride handling) by accident.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20190416125744.27770-2-peter.maydell@linaro.org

5 years agoconfigure: Remove --source-path option
Peter Maydell [Mon, 29 Apr 2019 16:35:57 +0000 (17:35 +0100)]
configure: Remove --source-path option

Normally configure identifies the source path by looking
at the location where the configure script itself exists.
We also provide a --source-path option which lets the user
manually override this.

There isn't really an obvious use case for the --source-path
option, and in commit 927128222b0a91f56c13a in 2017 we
accidentally added some logic that looks at $source_path
before the command line option that overrides it has been
processed.

The fact that nobody complained suggests that there isn't
any use of this option and we aren't testing it either;
remove it. This allows us to move the "make $source_path
absolute" logic up so that there is no window in the script
where $source_path is set but not yet absolute.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-id: 20190318134019.23729-1-peter.maydell@linaro.org

5 years agohw/ssi/xilinx_spips: Avoid variable length array
Peter Maydell [Mon, 29 Apr 2019 16:35:57 +0000 (17:35 +0100)]
hw/ssi/xilinx_spips: Avoid variable length array

In the stripe8() function we use a variable length array; however
we know that the maximum length required is MAX_NUM_BUSSES. Use
a fixed-length array and an assert instead.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Message-id: 20190328152635.2794-1-peter.maydell@linaro.org

5 years agohw/arm/smmuv3: Remove SMMUNotifierNode
Eric Auger [Mon, 29 Apr 2019 16:35:57 +0000 (17:35 +0100)]
hw/arm/smmuv3: Remove SMMUNotifierNode

The SMMUNotifierNode struct is not necessary and brings extra
complexity so let's remove it. We now directly track the SMMUDevices
which have registered IOMMU MR notifiers.

This is inspired from the same transformation on intel-iommu
done in commit b4a4ba0d68f50f218ee3957b6638dbee32a5eeef
("intel-iommu: remove IntelIOMMUNotifierNode")

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Message-id: 20190409160219.19026-1-eric.auger@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5 years agoAdd Nios II semihosting support.
Sandra Loosemore [Wed, 3 Apr 2019 19:53:05 +0000 (13:53 -0600)]
Add Nios II semihosting support.

This patch adds support for libgloss semihosting to Nios II bare-metal
emulation.  The specification for the protocol can be found in the
libgloss sources.

Signed-off-by: Sandra Loosemore <sandra@codesourcery.com>
Signed-off-by: Julian Brown <julian@codesourcery.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1554321185-2825-3-git-send-email-sandra@codesourcery.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5 years agoAdd generic Nios II board.
Sandra Loosemore [Wed, 3 Apr 2019 19:53:04 +0000 (13:53 -0600)]
Add generic Nios II board.

This patch adds support for a generic MMU-less Nios II board that can
be used e.g. for bare-metal compiler testing with the linker script
and startup code provided by libgloss.  Nios II booting is also
tweaked so that bare-metal binaries start executing in RAM starting at
0x00000000, rather than an alias at 0xc0000000, which allows features
such as unwinding to work when binaries are linked to start at the
beginning of the address space.

The generic_nommu.c parts are based on code by Andrew Jenner, which was
in turn based on code by Marek Vasut.

Originally by Marek Vasut and Andrew Jenner.

Signed-off-by: Sandra Loosemore <sandra@codesourcery.com>
Signed-off-by: Julian Brown <julian@codesourcery.com>
Signed-off-by: Andrew Jenner <andrew@codesourcery.com>
Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1554321185-2825-2-git-send-email-sandra@codesourcery.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5 years agoMerge remote-tracking branch 'remotes/rth/tags/pull-tcg-20190426' into staging
Peter Maydell [Sun, 28 Apr 2019 10:43:09 +0000 (11:43 +0100)]
Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20190426' into staging

Add tcg_gen_extract2_*.
Deal with overflow of TranslationBlocks.
Respect access_type in io_readx.

# gpg: Signature made Fri 26 Apr 2019 18:17:01 BST
# gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg:                issuer "richard.henderson@linaro.org"
# gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [full]
# Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A  05C0 64DF 38E8 AF7E 215F

* remotes/rth/tags/pull-tcg-20190426:
  cputlb: Fix io_readx() to respect the access_type
  tcg/arm: Restrict constant pool displacement to 12 bits
  tcg/ppc: Allow the constant pool to overflow at 32k
  tcg: Restart TB generation after out-of-line ldst overflow
  tcg: Restart TB generation after constant pool overflow
  tcg: Restart TB generation after relocation overflow
  tcg: Restart after TB code generation overflow
  tcg: Hoist max_insns computation to tb_gen_code
  tcg/aarch64: Support INDEX_op_extract2_{i32,i64}
  tcg/arm: Support INDEX_op_extract2_i32
  tcg/i386: Support INDEX_op_extract2_{i32,i64}
  tcg: Use extract2 in tcg_gen_deposit_{i32,i64}
  tcg: Use deposit and extract2 in tcg_gen_shifti_i64
  tcg: Add INDEX_op_extract2_{i32,i64}
  tcg: Implement tcg_gen_extract2_{i32,i64}

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5 years agoMerge remote-tracking branch 'remotes/dgibson/tags/ppc-for-4.1-20190426' into staging
Peter Maydell [Sat, 27 Apr 2019 20:34:46 +0000 (21:34 +0100)]
Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-4.1-20190426' into staging

ppc patch queue 2019-04-26

Here's the first ppc target pull request for qemu-4.1.  This has a
number of things that have accumulated while qemu-4.0 was frozen.

 * A number of emulated MMU improvements from Ben Herrenschmidt

 * Assorted cleanups fro Greg Kurz

 * A large set of mostly mechanical cleanups from me to make target/ppc
   much closer to compliant with the modern coding style

 * Support for passthrough of NVIDIA GPUs using NVLink2

As well as some other assorted fixes.

# gpg: Signature made Fri 26 Apr 2019 07:02:19 BST
# gpg:                using RSA key 75F46586AE61A66CC44E87DC6C38CACA20D9B392
# gpg: Good signature from "David Gibson <david@gibson.dropbear.id.au>" [full]
# gpg:                 aka "David Gibson (Red Hat) <dgibson@redhat.com>" [full]
# gpg:                 aka "David Gibson (ozlabs.org) <dgibson@ozlabs.org>" [full]
# gpg:                 aka "David Gibson (kernel.org) <dwg@kernel.org>" [unknown]
# Primary key fingerprint: 75F4 6586 AE61 A66C C44E  87DC 6C38 CACA 20D9 B392

* remotes/dgibson/tags/ppc-for-4.1-20190426: (36 commits)
  target/ppc: improve performance of large BAT invalidations
  ppc/hash32: Rework R and C bit updates
  ppc/hash64: Rework R and C bit updates
  ppc/spapr: Use proper HPTE accessors for H_READ
  target/ppc: Don't check UPRT in radix mode when in HV real mode
  target/ppc/kvm: Convert DPRINTF to traces
  target/ppc/trace-events: Fix trivial typo
  spapr: Drop duplicate PCI swizzle code
  spapr_pci: Get rid of duplicate code for node name creation
  target/ppc: Style fixes for translate/spe-impl.inc.c
  target/ppc: Style fixes for translate/vmx-impl.inc.c
  target/ppc: Style fixes for translate/vsx-impl.inc.c
  target/ppc: Style fixes for translate/fp-impl.inc.c
  target/ppc: Style fixes for translate.c
  target/ppc: Style fixes for translate_init.inc.c
  target/ppc: Style fixes for monitor.c
  target/ppc: Style fixes for mmu_helper.c
  target/ppc: Style fixes for mmu-hash64.[ch]
  target/ppc: Style fixes for mmu-hash32.[ch]
  target/ppc: Style fixes for misc_helper.c
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5 years agoMerge remote-tracking branch 'remotes/ehabkost/tags/x86-next-pull-request' into staging
Peter Maydell [Fri, 26 Apr 2019 15:38:04 +0000 (16:38 +0100)]
Merge remote-tracking branch 'remotes/ehabkost/tags/x86-next-pull-request' into staging

x86 queue, 2019-04-25

* Hygon Dhyana CPU model (Pu Wen)
* Categorize a few devices in hw/i386 (Ernest Esene)
* Support host-cache-info on TOPOEXT CPUID leaf (Stanislav Lanci)

# gpg: Signature made Thu 25 Apr 2019 19:12:25 BST
# gpg:                using RSA key 2807936F984DC5A6
# gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>" [full]
# Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF  D1AA 2807 936F 984D C5A6

* remotes/ehabkost/tags/x86-next-pull-request:
  Pass through cache information for TOPOEXT CPUs
  Categorize devices: iommu
  Categorize devices: IGD passthrough ISA bridge
  i386: Add new Hygon 'Dhyana' CPU model

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5 years agoMerge remote-tracking branch 'remotes/ehabkost/tags/machine-next-pull-request' into...
Peter Maydell [Fri, 26 Apr 2019 13:30:18 +0000 (14:30 +0100)]
Merge remote-tracking branch 'remotes/ehabkost/tags/machine-next-pull-request' into staging

Machine queue, 2019-04-25

* 4.1 machine-types (Cornelia Huck)
* Support MAP_SYNC on pmem memory backends (Zhang Yi)
* -cpu parsing fixes and cleanups (Eduardo Habkost)
* machine initialization cleanups (Wei Yang, Markus Armbruster)

# gpg: Signature made Thu 25 Apr 2019 18:54:57 BST
# gpg:                using RSA key 2807936F984DC5A6
# gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>" [full]
# Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF  D1AA 2807 936F 984D C5A6

* remotes/ehabkost/tags/machine-next-pull-request:
  util/mmap-alloc: support MAP_SYNC in qemu_ram_mmap()
  linux-headers: add linux/mman.h.
  scripts/update-linux-headers: add linux/mman.h
  util/mmap-alloc: Add a 'is_pmem' parameter to qemu_ram_mmap
  cpu: Fix crash with empty -cpu option
  cpu: Rename parse_cpu_model() to parse_cpu_option()
  vl: Simplify machine_parse()
  vl: Clean up after previous commit
  vl.c: allocate TYPE_MACHINE list once during bootup
  vl.c: make find_default_machine() local
  hw: add compat machines for 4.1

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5 years agoMerge remote-tracking branch 'remotes/cohuck/tags/s390x-20190425' into staging
Peter Maydell [Fri, 26 Apr 2019 11:54:47 +0000 (12:54 +0100)]
Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20190425' into staging

- properly detect page size of initial memory
- support for IPL (boot) from ECKD DASD passed through via vfio-ccw

# gpg: Signature made Thu 25 Apr 2019 14:11:18 BST
# gpg:                using RSA key C3D0D66DC3624FF6A8C018CEDECF6B93C6F02FAF
# gpg:                issuer "cohuck@redhat.com"
# gpg: Good signature from "Cornelia Huck <conny@cornelia-huck.de>" [unknown]
# gpg:                 aka "Cornelia Huck <huckc@linux.vnet.ibm.com>" [full]
# gpg:                 aka "Cornelia Huck <cornelia.huck@de.ibm.com>" [full]
# gpg:                 aka "Cornelia Huck <cohuck@kernel.org>" [unknown]
# gpg:                 aka "Cornelia Huck <cohuck@redhat.com>" [unknown]
# Primary key fingerprint: C3D0 D66D C362 4FF6 A8C0  18CE DECF 6B93 C6F0 2FAF

* remotes/cohuck/tags/s390x-20190425:
  exec: Introduce qemu_maxrampagesize() and rename qemu_getrampagesize()
  s390x/kvm: Configure page size after memory has actually been initialized
  pc-bios/s390: Update firmware images
  s390-bios: Use control unit type to find bootable devices
  s390-bios: Support booting from real dasd device
  s390-bios: Add channel command codes/structs needed for dasd-ipl
  s390-bios: Use control unit type to determine boot method
  s390-bios: Refactor virtio to run channel programs via cio
  s390-bios: Factor finding boot device out of virtio code path
  s390-bios: Extend find_dev() for non-virtio devices
  s390-bios: cio error handling
  s390-bios: Support for running format-0/1 channel programs
  s390-bios: ptr2u32 and u32toptr
  s390-bios: Map low core memory
  s390-bios: Decouple channel i/o logic from virtio
  s390-bios: Clean up cio.h
  s390-bios: decouple common boot logic from virtio
  s390-bios: decouple cio setup from virtio
  s390 vfio-ccw: Add bootindex property and IPLB data

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5 years agotarget/ppc: improve performance of large BAT invalidations
Artyom Tarasenko [Fri, 12 Apr 2019 21:06:17 +0000 (23:06 +0200)]
target/ppc: improve performance of large BAT invalidations

Performing a complete flush is ~ 100 times faster than flushing
256MiB of 4KiB pages. Set a limit of 1024 pages and perform a complete
flush afterwards.

This patch significantly speeds up AIX 5.1 and NetBSD-ofppc.

Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com>
Message-Id: <1555103178-21894-4-git-send-email-atar4qemu@gmail.com>
Reviewed-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
5 years agoppc/hash32: Rework R and C bit updates
Benjamin Herrenschmidt [Thu, 11 Apr 2019 08:00:02 +0000 (10:00 +0200)]
ppc/hash32: Rework R and C bit updates

With MT-TCG, we are now running translation in a racy way, thus
we need to mimic hardware when it comes to updating the R and
C bits, by doing byte stores.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20190411080004.8690-5-clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
5 years agoppc/hash64: Rework R and C bit updates
Benjamin Herrenschmidt [Thu, 11 Apr 2019 08:00:01 +0000 (10:00 +0200)]
ppc/hash64: Rework R and C bit updates

With MT-TCG, we are now running translation in a racy way, thus
we need to mimic hardware when it comes to updating the R and
C bits, by doing byte stores.

The current "store_hpte" abstraction is ill suited for this, we
replace it with two separate callbacks for setting R and C.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20190411080004.8690-4-clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
5 years agoppc/spapr: Use proper HPTE accessors for H_READ
Benjamin Herrenschmidt [Thu, 11 Apr 2019 08:00:00 +0000 (10:00 +0200)]
ppc/spapr: Use proper HPTE accessors for H_READ

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20190411080004.8690-3-clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
5 years agotarget/ppc: Don't check UPRT in radix mode when in HV real mode
Benjamin Herrenschmidt [Thu, 11 Apr 2019 07:59:59 +0000 (09:59 +0200)]
target/ppc: Don't check UPRT in radix mode when in HV real mode

It appears that during kexec, we run for a while in hypervisor
real mode with LPCR:HR set and LPCR:UPRT clear, which trips
the assertion in ppc_radix64_handle_mmu_fault().

First this shouldn't be an assertion, it's a guest error.

Then we shouldn't be checking these things in hypervisor real
mode (or in virtual hypervisor guest real mode which is similar)
as the real HW won't use those LPCR bits in those cases anyway,
so technically it's ok to have this discrepancy.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20190411080004.8690-2-clg@kaod.org>
[dwg: Fix for 32-bit builds]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
5 years agotarget/ppc/kvm: Convert DPRINTF to traces
Greg Kurz [Fri, 5 Apr 2019 08:05:24 +0000 (10:05 +0200)]
target/ppc/kvm: Convert DPRINTF to traces

Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <155445152490.302073.17033451726459859333.stgit@bahia.lan>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
5 years agotarget/ppc/trace-events: Fix trivial typo
Greg Kurz [Fri, 5 Apr 2019 08:05:19 +0000 (10:05 +0200)]
target/ppc/trace-events: Fix trivial typo

Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <155445151931.302073.18436485925081597460.stgit@bahia.lan>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
5 years agospapr: Drop duplicate PCI swizzle code
Greg Kurz [Fri, 5 Apr 2019 16:30:48 +0000 (18:30 +0200)]
spapr: Drop duplicate PCI swizzle code

LSI mapping in spapr currently open-codes standard PCI swizzling. It thus
duplicates the code of pci_swizzle_map_irq_fn().

Expose the swizzling formula so that it can be used with a slot number
when building the device tree. Simply drop pci_spapr_map_irq() and call
pci_swizzle_map_irq_fn() instead.

Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <155448184841.8446.13959787238854054119.stgit@bahia.lan>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
5 years agospapr_pci: Get rid of duplicate code for node name creation
Greg Kurz [Fri, 5 Apr 2019 16:30:43 +0000 (18:30 +0200)]
spapr_pci: Get rid of duplicate code for node name creation

According to the changelog of 298a971024534, SpaprPhbState::dtbusname was
introduced to "make it easier to relate the guest and qemu views of memory
to each other", hence its name.

Use it when creating the PHB node to avoid code duplication.

Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <155448184292.8446.8225650773162648595.stgit@bahia.lan>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
5 years agotarget/ppc: Style fixes for translate/spe-impl.inc.c
David Gibson [Thu, 21 Mar 2019 12:46:54 +0000 (23:46 +1100)]
target/ppc: Style fixes for translate/spe-impl.inc.c

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
5 years agotarget/ppc: Style fixes for translate/vmx-impl.inc.c
David Gibson [Thu, 21 Mar 2019 12:47:02 +0000 (23:47 +1100)]
target/ppc: Style fixes for translate/vmx-impl.inc.c

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
5 years agotarget/ppc: Style fixes for translate/vsx-impl.inc.c
David Gibson [Thu, 21 Mar 2019 12:47:10 +0000 (23:47 +1100)]
target/ppc: Style fixes for translate/vsx-impl.inc.c

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
5 years agotarget/ppc: Style fixes for translate/fp-impl.inc.c
David Gibson [Thu, 21 Mar 2019 12:39:46 +0000 (23:39 +1100)]
target/ppc: Style fixes for translate/fp-impl.inc.c

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
5 years agotarget/ppc: Style fixes for translate.c
David Gibson [Thu, 21 Mar 2019 11:57:28 +0000 (22:57 +1100)]
target/ppc: Style fixes for translate.c

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
5 years agotarget/ppc: Style fixes for translate_init.inc.c
David Gibson [Thu, 21 Mar 2019 11:45:46 +0000 (22:45 +1100)]
target/ppc: Style fixes for translate_init.inc.c

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
5 years agotarget/ppc: Style fixes for monitor.c
David Gibson [Thu, 21 Mar 2019 11:43:09 +0000 (22:43 +1100)]
target/ppc: Style fixes for monitor.c

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
5 years agotarget/ppc: Style fixes for mmu_helper.c
David Gibson [Thu, 21 Mar 2019 11:36:09 +0000 (22:36 +1100)]
target/ppc: Style fixes for mmu_helper.c

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
5 years agotarget/ppc: Style fixes for mmu-hash64.[ch]
David Gibson [Thu, 21 Mar 2019 11:32:53 +0000 (22:32 +1100)]
target/ppc: Style fixes for mmu-hash64.[ch]

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
5 years agotarget/ppc: Style fixes for mmu-hash32.[ch]
David Gibson [Thu, 21 Mar 2019 11:29:06 +0000 (22:29 +1100)]
target/ppc: Style fixes for mmu-hash32.[ch]

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
5 years agotarget/ppc: Style fixes for misc_helper.c
David Gibson [Thu, 21 Mar 2019 11:27:42 +0000 (22:27 +1100)]
target/ppc: Style fixes for misc_helper.c

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
5 years agotarget/ppc: Style fixes for mfrom_table.inc.c & mfrom_table_gen.c
David Gibson [Thu, 21 Mar 2019 11:25:50 +0000 (22:25 +1100)]
target/ppc: Style fixes for mfrom_table.inc.c & mfrom_table_gen.c

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
5 years agotarget/ppc: Style fixes for mem_helper.c
David Gibson [Thu, 21 Mar 2019 11:22:13 +0000 (22:22 +1100)]
target/ppc: Style fixes for mem_helper.c

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
5 years agotarget/ppc: Style fixes for machine.c
David Gibson [Thu, 21 Mar 2019 11:10:19 +0000 (22:10 +1100)]
target/ppc: Style fixes for machine.c

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
5 years agotarget/ppc: Style fixes for kvm_ppc.h and kvm.c
David Gibson [Thu, 21 Mar 2019 10:47:25 +0000 (21:47 +1100)]
target/ppc: Style fixes for kvm_ppc.h and kvm.c

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
5 years agotarget/ppc: Style fixes for helper_regs.h
David Gibson [Thu, 21 Mar 2019 10:41:17 +0000 (21:41 +1100)]
target/ppc: Style fixes for helper_regs.h

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
5 years agotarget/ppc: Style fixes for gdbstub.c
David Gibson [Thu, 21 Mar 2019 10:31:45 +0000 (21:31 +1100)]
target/ppc: Style fixes for gdbstub.c

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
5 years agotarget/ppc: Style fixes for excp_helper.c
David Gibson [Thu, 21 Mar 2019 10:20:28 +0000 (21:20 +1100)]
target/ppc: Style fixes for excp_helper.c

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
5 years agotarget/ppc: Style fixes for dfp_helper.c
David Gibson [Thu, 21 Mar 2019 06:08:17 +0000 (17:08 +1100)]
target/ppc: Style fixes for dfp_helper.c

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
5 years agotarget/ppc: Style fixes for fpu_helper.c
David Gibson [Thu, 21 Mar 2019 06:01:06 +0000 (17:01 +1100)]
target/ppc: Style fixes for fpu_helper.c

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
5 years agotarget/ppc: Style fixes for int_helper.c
David Gibson [Thu, 21 Mar 2019 05:50:18 +0000 (16:50 +1100)]
target/ppc: Style fixes for int_helper.c

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
5 years agotarget/ppc: Style fixes for cpu.[ch]
David Gibson [Thu, 21 Mar 2019 05:29:36 +0000 (16:29 +1100)]
target/ppc: Style fixes for cpu.[ch]

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
5 years agotarget/ppc: Style fixes for ppc-models.[ch]
David Gibson [Thu, 21 Mar 2019 05:25:02 +0000 (16:25 +1100)]
target/ppc: Style fixes for ppc-models.[ch]

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
5 years agospapr/irq: remove spapr_ics_create()
Cédric Le Goater [Thu, 21 Mar 2019 14:49:11 +0000 (15:49 +0100)]
spapr/irq: remove spapr_ics_create()

spapr_ics_create() is only called once. Merge it in spapr_irq_init_xics()
and simplify a bit the error handling by using 'error_fatal' .

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20190321144914.19934-13-clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
5 years agospapr/rtas: modify spapr_rtas_register() to remove RTAS handlers
Cédric Le Goater [Thu, 21 Mar 2019 14:49:07 +0000 (15:49 +0100)]
spapr/rtas: modify spapr_rtas_register() to remove RTAS handlers

Removing RTAS handlers will become necessary when the new pseries
machine supporting multiple interrupt mode is introduced.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20190321144914.19934-9-clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
5 years agohw/ppc/prep: Drop useless inclusion of "hw/input/i8042.h"
Philippe Mathieu-Daudé [Sat, 16 Mar 2019 20:15:28 +0000 (21:15 +0100)]
hw/ppc/prep: Drop useless inclusion of "hw/input/i8042.h"

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é <philmd@redhat.com>
Message-Id: <20190316201528.9140-1-philmd@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
5 years agospapr: Support NVIDIA V100 GPU with NVLink2
Alexey Kardashevskiy [Tue, 12 Mar 2019 08:21:03 +0000 (19:21 +1100)]
spapr: Support NVIDIA V100 GPU with NVLink2

NVIDIA V100 GPUs have on-board RAM which is mapped into the host memory
space and accessible as normal RAM via an NVLink bus. The VFIO-PCI driver
implements special regions for such GPUs and emulates an NVLink bridge.
NVLink2-enabled POWER9 CPUs also provide address translation services
which includes an ATS shootdown (ATSD) register exported via the NVLink
bridge device.

This adds a quirk to VFIO to map the GPU memory and create an MR;
the new MR is stored in a PCI device as a QOM link. The sPAPR PCI uses
this to get the MR and map it to the system address space.
Another quirk does the same for ATSD.

This adds additional steps to sPAPR PHB setup:

1. Search for specific GPUs and NPUs, collect findings in
sPAPRPHBState::nvgpus, manage system address space mappings;

2. Add device-specific properties such as "ibm,npu", "ibm,gpu",
"memory-block", "link-speed" to advertise the NVLink2 function to
the guest;

3. Add "mmio-atsd" to vPHB to advertise the ATSD capability;

4. Add new memory blocks (with extra "linux,memory-usable" to prevent
the guest OS from accessing the new memory until it is onlined) and
npuphb# nodes representing an NPU unit for every vPHB as the GPU driver
uses it for link discovery.

This allocates space for GPU RAM and ATSD like we do for MMIOs by
adding 2 new parameters to the phb_placement() hook. Older machine types
set these to zero.

This puts new memory nodes in a separate NUMA node to as the GPU RAM
needs to be configured equally distant from any other node in the system.
Unlike the host setup which assigns numa ids from 255 downwards, this
adds new NUMA nodes after the user configures nodes or from 1 if none
were configured.

This adds requirement similar to EEH - one IOMMU group per vPHB.
The reason for this is that ATSD registers belong to a physical NPU
so they cannot invalidate translations on GPUs attached to another NPU.
It is guaranteed by the host platform as it does not mix NVLink bridges
or GPUs from different NPU in the same IOMMU group. If more than one
IOMMU group is detected on a vPHB, this disables ATSD support for that
vPHB and prints a warning.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
[aw: for vfio portions]
Acked-by: Alex Williamson <alex.williamson@redhat.com>
Message-Id: <20190312082103.130561-1-aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
5 years agoPass through cache information for TOPOEXT CPUs
Stanislav Lanci [Tue, 16 Apr 2019 12:38:33 +0000 (14:38 +0200)]
Pass through cache information for TOPOEXT CPUs

Signed-off-by: Stanislav Lanci <pixo@polepetko.eu>
Message-Id: <20190416123833.60649-1-pixo@polepetko.eu>
[ehabkost: removed redundant comment line]
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
5 years agoCategorize devices: iommu
Ernest Esene [Wed, 27 Mar 2019 17:05:18 +0000 (18:05 +0100)]
Categorize devices: iommu

Set category and description for iommu devices.

Signed-off-by: Ernest Esene <eroken1@gmail.com>
Message-Id: <20190327170518.GA16887@erokenlabserver>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
[ehabkost: edited commit message]
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
5 years agoCategorize devices: IGD passthrough ISA bridge
Ernest Esene [Wed, 27 Mar 2019 16:53:56 +0000 (17:53 +0100)]
Categorize devices: IGD passthrough ISA bridge

Set category for the device.

Signed-off-by: Ernest Esene <eroken1@gmail.com>
Message-Id: <20190327133714.GA9329@erokenlabserver>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
[ehabkost: edited commit message]
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
5 years agoi386: Add new Hygon 'Dhyana' CPU model
Pu Wen [Tue, 16 Apr 2019 12:06:13 +0000 (20:06 +0800)]
i386: Add new Hygon 'Dhyana' CPU model

Add a new base CPU model called 'Dhyana' to model processors from Hygon
Dhyana(family 18h), which derived from AMD EPYC(family 17h).

The following features bits have been removed compare to AMD EPYC:
aes, pclmulqdq, sha_ni

The Hygon Dhyana support to KVM in Linux is already accepted upstream[1].
So add Hygon Dhyana support to Qemu is necessary to create Hygon's own
CPU model.

Reference:
[1] https://git.kernel.org/tip/fec98069fb72fb656304a3e52265e0c2fc9adf87

Signed-off-by: Pu Wen <puwen@hygon.cn>
Message-Id: <1555416373-28690-1-git-send-email-puwen@hygon.cn>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
5 years agocputlb: Fix io_readx() to respect the access_type
Shahab Vahedi [Sat, 20 Apr 2019 07:22:37 +0000 (09:22 +0200)]
cputlb: Fix io_readx() to respect the access_type

This change adapts io_readx() to its input access_type. Currently
io_readx() treats any memory access as a read, although it has an
input argument "MMUAccessType access_type". This results in:

1) Calling the tlb_fill() only with MMU_DATA_LOAD
2) Considering only entry->addr_read as the tlb_addr

Buglink: https://bugs.launchpad.net/qemu/+bug/1825359
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Shahab Vahedi <shahab.vahedi@gmail.com>
Message-Id: <20190420072236.12347-1-shahab.vahedi@gmail.com>
[rth: Remove assert; fix expression formatting.]
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg/arm: Restrict constant pool displacement to 12 bits
Richard Henderson [Thu, 25 Apr 2019 17:39:39 +0000 (10:39 -0700)]
tcg/arm: Restrict constant pool displacement to 12 bits

This will not necessarily restrict the size of the TB, since for v7
the majority of constant pool usage is for calls from the out-of-line
ldst code, which is already at the end of the TB.  But this does
allow us to save one insn per reference on the off-chance.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agoutil/mmap-alloc: support MAP_SYNC in qemu_ram_mmap()
Zhang Yi [Mon, 22 Apr 2019 00:48:48 +0000 (08:48 +0800)]
util/mmap-alloc: support MAP_SYNC in qemu_ram_mmap()

When a file supporting DAX is used as vNVDIMM backend, mmap it with
MAP_SYNC flag in addition which can ensure file system metadata
synced in each guest writes to the backend file, without other QEMU
actions (e.g., periodic fsync() by QEMU).

Current, We have below different possible use cases:

1. pmem=on is set, shared=on is set, MAP_SYNC supported:
   a: backend is a dax supporting file.
    - MAP_SYNC will active.
   b: backend is not a dax supporting file.
    - mmap will trigger a warning. then MAP_SYNC flag will be ignored

2. The rest of cases:
   - we will never pass the MAP_SYNC to mmap2

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Signed-off-by: Zhang Yi <yi.z.zhang@linux.intel.com>
[ehabkost: Rebased patch to latest code on master]
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
Tested-by: Wei Yang <richardw.yang@linux.intel.com>
Message-Id: <20190422004849.26463-2-richardw.yang@linux.intel.com>
[ehabkost: squashed documentation patch]
Message-Id: <20190422004849.26463-3-richardw.yang@linux.intel.com>
[ehabkost: documentation fixup]
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Pankaj Gupta <pagupta@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
5 years agolinux-headers: add linux/mman.h.
Zhang Yi [Fri, 8 Feb 2019 10:11:00 +0000 (18:11 +0800)]
linux-headers: add linux/mman.h.

Update it to 4.20-rc1

Signed-off-by: Zhang Yi <yi.z.zhang@linux.intel.com>
Message-Id: <f9346f1816b940a4231524a84d57a2cac8466ccc.1549555521.git.yi.z.zhang@linux.intel.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
5 years agoscripts/update-linux-headers: add linux/mman.h
Zhang Yi [Fri, 8 Feb 2019 10:10:49 +0000 (18:10 +0800)]
scripts/update-linux-headers: add linux/mman.h

Add linux/mman.h,asm/mman.h,asm/mman-common.h to linux-headers,
So we can use more mmap2 flags.

Signed-off-by: Zhang Yi <yi.z.zhang@linux.intel.com>
Message-Id: <f65c78d74859f815aa9c4f97407eb33361a6672c.1549555521.git.yi.z.zhang@linux.intel.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
5 years agoutil/mmap-alloc: Add a 'is_pmem' parameter to qemu_ram_mmap
Zhang Yi [Fri, 8 Feb 2019 10:10:37 +0000 (18:10 +0800)]
util/mmap-alloc: Add a 'is_pmem' parameter to qemu_ram_mmap

besides the existing 'shared' flags, we are going to add
'is_pmem' to qemu_ram_mmap(), which indicated the memory backend
file is a persist memory.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Signed-off-by: Zhang Yi <yi.z.zhang@linux.intel.com>
Reviewed-by: Pankaj Gupta <pagupta@redhat.com>
Message-Id: <786c46862cfeb253ee0ea2f44d62ffe76edb7fa4.1549555521.git.yi.z.zhang@linux.intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Pankaj Gupta <pagupta@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
5 years agocpu: Fix crash with empty -cpu option
Eduardo Habkost [Thu, 18 Apr 2019 03:45:01 +0000 (00:45 -0300)]
cpu: Fix crash with empty -cpu option

Fix the following crash:

  $ qemu-system-x86_64 -cpu ''
  qemu-system-x86_64: qom/cpu.c:291: cpu_class_by_name: \
      Assertion `cpu_model && cc->class_by_name' failed.

Regression test script included.

Fixes: 99193d8f2ef5 ("cpu: drop unnecessary NULL check and cpu_common_class_by_name()")
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <20190418034501.5038-1-ehabkost@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Tested-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
5 years agocpu: Rename parse_cpu_model() to parse_cpu_option()
Eduardo Habkost [Wed, 17 Apr 2019 02:59:40 +0000 (23:59 -0300)]
cpu: Rename parse_cpu_model() to parse_cpu_option()

The "model[,option...]" string parsed by the function is not just
a CPU model.  Rename the function and its argument to indicate it
expects the full "-cpu" option to be provided.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <20190417025944.16154-2-ehabkost@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
5 years agovl: Simplify machine_parse()
Markus Armbruster [Fri, 5 Apr 2019 06:41:21 +0000 (14:41 +0800)]
vl: Simplify machine_parse()

Exploit that argument @name is nerver null.  Check is_help_option()
first, because that's what we do elsewhere.  If we (foolishly!)
defined a machine named "help", -machine help would now print help
instead of selecting the machine named "help".

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
Message-Id: <20190405064121.23662-5-richardw.yang@linux.intel.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
5 years agovl: Clean up after previous commit
Markus Armbruster [Fri, 5 Apr 2019 06:41:20 +0000 (14:41 +0800)]
vl: Clean up after previous commit

Since the previous commit, find_machine() and find_default_machine()
don't have to deallocate on return.  This permits further
simplifications.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
Message-Id: <20190405064121.23662-4-richardw.yang@linux.intel.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
5 years agovl.c: allocate TYPE_MACHINE list once during bootup
Wei Yang [Fri, 5 Apr 2019 06:41:19 +0000 (14:41 +0800)]
vl.c: allocate TYPE_MACHINE list once during bootup

Now all the functions used to select machine is local and the call flow
looks like below:

    select_machine()
        find_default_machine()
        machine_parse()
            find_machine()

All these related function will need a GSList for TYPE_MACHINE.
Currently we allocate this list each time we use it, while this is not
necessary to do so because we don't need to modify this.

This patch make the TYPE_MACHINE list allocation in select_machine and
pass this to its child for use.

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190405064121.23662-3-richardw.yang@linux.intel.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
5 years agovl.c: make find_default_machine() local
Wei Yang [Fri, 5 Apr 2019 06:41:18 +0000 (14:41 +0800)]
vl.c: make find_default_machine() local

Function find_default_machine() is introduced by commit 2c8cffa599b7
"vl: make find_default_machine externally visible", and it was used
outside of vl.c until commit a904410af5f1 "pc_sysfw: remove the rom_only
property".

Commit a904410af5f1 "pc_sysfw: remove the rom_only property" removed the
only user of find_default_machine() outside vl.c, but neglected to make
it static. Do that now.

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
Message-Id: <20190405064121.23662-2-richardw.yang@linux.intel.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
5 years agohw: add compat machines for 4.1
Cornelia Huck [Thu, 11 Apr 2019 10:20:25 +0000 (12:20 +0200)]
hw: add compat machines for 4.1

Add 4.1 machine types for arm/i440fx/q35/s390x/spapr.

Signed-off-by: Cornelia Huck <cohuck@redhat.com>
Message-Id: <20190411102025.22559-1-cohuck@redhat.com>
Acked-by: Greg Kurz <groug@kaod.org>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
5 years agoMerge tag 's390-ccw-bios-2019-04-12' into s390-next-staging
Cornelia Huck [Thu, 25 Apr 2019 12:08:17 +0000 (14:08 +0200)]
Merge tag 's390-ccw-bios-2019-04-12' into s390-next-staging

Support for booting from a vfio-ccw passthrough dasd device

# gpg: Signature made Fri 12 Apr 2019 01:17:03 PM CEST
# gpg:                using RSA key 2ED9D774FE702DB5
# gpg: Good signature from "Thomas Huth <th.huth@gmx.de>" [full]
# gpg:                 aka "Thomas Huth <thuth@redhat.com>" [undefined]
# gpg:                 aka "Thomas Huth <huth@tuxfamily.org>" [undefined]
# gpg:                 aka "Thomas Huth <th.huth@posteo.de>" [unknown]

* tag 's390-ccw-bios-2019-04-12':
  pc-bios/s390: Update firmware images
  s390-bios: Use control unit type to find bootable devices
  s390-bios: Support booting from real dasd device
  s390-bios: Add channel command codes/structs needed for dasd-ipl
  s390-bios: Use control unit type to determine boot method
  s390-bios: Refactor virtio to run channel programs via cio
  s390-bios: Factor finding boot device out of virtio code path
  s390-bios: Extend find_dev() for non-virtio devices
  s390-bios: cio error handling
  s390-bios: Support for running format-0/1 channel programs
  s390-bios: ptr2u32 and u32toptr
  s390-bios: Map low core memory
  s390-bios: Decouple channel i/o logic from virtio
  s390-bios: Clean up cio.h
  s390-bios: decouple common boot logic from virtio
  s390-bios: decouple cio setup from virtio
  s390 vfio-ccw: Add bootindex property and IPLB data

Signed-off-by: Cornelia Huck <cohuck@redhat.com>
5 years agoexec: Introduce qemu_maxrampagesize() and rename qemu_getrampagesize()
David Hildenbrand [Wed, 17 Apr 2019 11:31:43 +0000 (13:31 +0200)]
exec: Introduce qemu_maxrampagesize() and rename qemu_getrampagesize()

Rename qemu_getrampagesize() to qemu_minrampagesize(). While at it,
properly rename find_max_supported_pagesize() to
find_min_backend_pagesize().

s390x is actually interested into the maximum ram pagesize, so
introduce and use qemu_maxrampagesize().

Add a TODO, indicating that looking at any mapped memory backends is not
100% correct in some cases.

Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20190417113143.5551-3-david@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
5 years agos390x/kvm: Configure page size after memory has actually been initialized
David Hildenbrand [Wed, 17 Apr 2019 11:31:42 +0000 (13:31 +0200)]
s390x/kvm: Configure page size after memory has actually been initialized

Right now we configure the pagesize quite early, when initializing KVM.
This is long before system memory is actually allocated via
memory_region_allocate_system_memory(), and therefore memory backends
marked as mapped.

Instead, let's configure the maximum page size after initializing
memory in s390_memory_init(). cap_hpage_1m is still properly
configured before creating any CPUs, and therefore before configuring
the CPU model and eventually enabling CMMA.

This is not a fix but rather a preparation for the future, when initial
memory might reside on memory backends (not the case for s390x right now)
We will replace qemu_getrampagesize() soon by a function that will always
return the maximum page size (not the minimum page size, which only
works by pure luck so far, as there are no memory backends).

Acked-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20190417113143.5551-2-david@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
5 years agotcg/ppc: Allow the constant pool to overflow at 32k
Richard Henderson [Mon, 22 Apr 2019 17:12:33 +0000 (17:12 +0000)]
tcg/ppc: Allow the constant pool to overflow at 32k

There is no point in coding for a 2GB offset when the max TB size
is already limited to 64k.  If we further restrict to 32k then we
can eliminate the extra ADDIS instruction.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg: Restart TB generation after out-of-line ldst overflow
Richard Henderson [Sun, 21 Apr 2019 21:51:00 +0000 (14:51 -0700)]
tcg: Restart TB generation after out-of-line ldst overflow

This is part c of relocation overflow handling.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg: Restart TB generation after constant pool overflow
Richard Henderson [Sun, 21 Apr 2019 20:51:56 +0000 (13:51 -0700)]
tcg: Restart TB generation after constant pool overflow

This is part b of relocation overflow handling.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg: Restart TB generation after relocation overflow
Richard Henderson [Sun, 21 Apr 2019 20:34:35 +0000 (13:34 -0700)]
tcg: Restart TB generation after relocation overflow

If the TB generates too much code, such that backend relocations
overflow, try again with a smaller TB.  In support of this, move
relocation processing from a random place within tcg_out_op, in
the handling of branch opcodes, to a new function at the end of
tcg_gen_code.

This is not a complete solution, as there are additional relocs
generated for out-of-line ldst handling and constant pools.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg: Restart after TB code generation overflow
Richard Henderson [Tue, 16 Apr 2019 08:06:39 +0000 (22:06 -1000)]
tcg: Restart after TB code generation overflow

If a TB generates too much code, try again with fewer insns.

Fixes: https://bugs.launchpad.net/bugs/1824853
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg: Hoist max_insns computation to tb_gen_code
Richard Henderson [Tue, 16 Apr 2019 06:54:54 +0000 (20:54 -1000)]
tcg: Hoist max_insns computation to tb_gen_code

In order to handle TB's that translate to too much code, we
need to place the control of the length of the translation
in the hands of the code gen master loop.

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg/aarch64: Support INDEX_op_extract2_{i32,i64}
Richard Henderson [Mon, 25 Feb 2019 21:25:46 +0000 (13:25 -0800)]
tcg/aarch64: Support INDEX_op_extract2_{i32,i64}

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg/arm: Support INDEX_op_extract2_i32
Richard Henderson [Mon, 25 Feb 2019 21:20:01 +0000 (13:20 -0800)]
tcg/arm: Support INDEX_op_extract2_i32

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg/i386: Support INDEX_op_extract2_{i32,i64}
Richard Henderson [Mon, 25 Feb 2019 19:42:35 +0000 (11:42 -0800)]
tcg/i386: Support INDEX_op_extract2_{i32,i64}

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg: Use extract2 in tcg_gen_deposit_{i32,i64}
Richard Henderson [Mon, 25 Feb 2019 19:10:53 +0000 (11:10 -0800)]
tcg: Use extract2 in tcg_gen_deposit_{i32,i64}

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg: Use deposit and extract2 in tcg_gen_shifti_i64
Richard Henderson [Mon, 25 Feb 2019 18:58:15 +0000 (10:58 -0800)]
tcg: Use deposit and extract2 in tcg_gen_shifti_i64

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg: Add INDEX_op_extract2_{i32,i64}
Richard Henderson [Mon, 25 Feb 2019 18:29:25 +0000 (10:29 -0800)]
tcg: Add INDEX_op_extract2_{i32,i64}

This will let backends implement the double-word shift operation.

Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg: Implement tcg_gen_extract2_{i32,i64}
David Hildenbrand [Mon, 25 Feb 2019 15:42:04 +0000 (16:42 +0100)]
tcg: Implement tcg_gen_extract2_{i32,i64}

Will be helpful for s390x. Input 128 bit and output 64 bit only,
which is sufficient for now.

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20190225154204.26751-1-david@redhat.com>
[rth: Add matching tcg_gen_extract2_i32.]
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agoMerge remote-tracking branch 'remotes/lersek/tags/edk2-pull-2019-04-22' into staging
Peter Maydell [Wed, 24 Apr 2019 12:19:41 +0000 (13:19 +0100)]
Merge remote-tracking branch 'remotes/lersek/tags/edk2-pull-2019-04-22' into staging

Advance the roms/edk2 submodule to the "edk2-stable201903" release, and
build and capture platform firmware binaries from that release. The
binaries are meant to be used by both end-users and by the "BIOS tables"
unit tests in qtest ("make check").

# gpg: Signature made Mon 22 Apr 2019 19:20:08 BST
# gpg:                using RSA key D39DA71E0D496CFA
# gpg: Good signature from "Laszlo Ersek <lersek@redhat.com>" [marginal]
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: F5D9 660F 1BA5 F310 A95A  C5E0 466A EAE0 6125 3988
#      Subkey fingerprint: B3A5 5D3F 88A8 90ED 2E63  3E8D D39D A71E 0D49 6CFA

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

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5 years agoMerge remote-tracking branch 'remotes/armbru/tags/pull-error-monitor-2019-04-18'...
Peter Maydell [Wed, 24 Apr 2019 10:55:48 +0000 (11:55 +0100)]
Merge remote-tracking branch 'remotes/armbru/tags/pull-error-monitor-2019-04-18' into staging

Error reporting & monitor patches for 2019-04-18

# gpg: Signature made Thu 18 Apr 2019 21:40:41 BST
# gpg:                using RSA key 3870B400EB918653
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full]
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>" [full]
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* remotes/armbru/tags/pull-error-monitor-2019-04-18: (36 commits)
  include: Move fprintf_function to disas/
  disas: Rename include/disas/bfd.h back to include/disas/dis-asm.h
  monitor: Clean up how monitor_disas() funnels output to monitor
  qom/cpu: Simplify how CPUClass:cpu_dump_state() prints
  qemu-print: New qemu_fprintf(), qemu_vfprintf()
  qom/cpu: Simplify how CPUClass::dump_statistics() prints
  target/i386: Simplify how x86_cpu_dump_local_apic_state() prints
  target: Clean up how the dump_mmu() print
  target: Simplify how the TARGET_cpu_list() print
  memory: Clean up how mtree_info() prints
  block/qapi: Clean up how we print to monitor or stdout
  qsp: Simplify how qsp_report() prints
  tcg: Simplify how dump_drift_info() prints
  tcg: Simplify how dump_exec_info() prints
  tcg: Simplify how dump_opcount_info() prints
  trace: Simplify how st_print_trace_file_status() prints
  include: Include fprintf-fn.h only where needed
  monitor: Simplify how -device/device_add print help
  char-pty: Print "char device redirected" message to stdout
  char: Make -chardev help print to stdout
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5 years agoOpen 4.1 development tree
Peter Maydell [Wed, 24 Apr 2019 09:12:22 +0000 (10:12 +0100)]
Open 4.1 development tree

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5 years agoUpdate version for v4.0.0 release
Peter Maydell [Tue, 23 Apr 2019 16:32:17 +0000 (17:32 +0100)]
Update version for v4.0.0 release

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5 years agoinclude: Move fprintf_function to disas/
Markus Armbruster [Wed, 17 Apr 2019 19:18:05 +0000 (21:18 +0200)]
include: Move fprintf_function to disas/

The previous commits have eliminated fprintf_function outside
disassemblers, simplifying code and cleaning up the ugly type-punning
fprintf_function seems to attract.  Move fprintf_function to
include/disas/dis-asm.h to reduce the temptation to abuse it.

I considered renaming it to fprintf_ftype (reverting that part of
commit 6e2d864edf5, v0.14.0) to get us closer to binutils, but I
figure the fork is too distant to make this worthwhile.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20190417191805.28198-18-armbru@redhat.com>

5 years agodisas: Rename include/disas/bfd.h back to include/disas/dis-asm.h
Markus Armbruster [Wed, 17 Apr 2019 19:18:04 +0000 (21:18 +0200)]
disas: Rename include/disas/bfd.h back to include/disas/dis-asm.h

Commit dc99065b5f9 (v0.1.0) added dis-asm.h from binutils.

Commit 43d4145a986 (v0.1.5) inlined bfd.h into dis-asm.h to remove the
dependency on binutils.

Commit 76cad71136b (v1.4.0) moved dis-asm.h to include/disas/bfd.h.
The new name is confusing when you try to match against (pre GPLv3+)
binutils.  Rename it back.  Keep it in the same directory, of course.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190417191805.28198-17-armbru@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
5 years agomonitor: Clean up how monitor_disas() funnels output to monitor
Markus Armbruster [Wed, 17 Apr 2019 19:18:03 +0000 (21:18 +0200)]
monitor: Clean up how monitor_disas() funnels output to monitor

INIT_DISASSEMBLE_INFO() takes an fprintf()-like callback and a FILE *
to pass to it.  monitor_disas() passes monitor_fprintf() and the
current monitor cast to FILE *.  monitor_fprintf() casts it right
back, and is otherwise identical to monitor_printf().  The
type-punning is ugly.

Pass qemu_fprintf() and NULL instead.

monitor_fprintf() is now unused; delete it.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20190417191805.28198-16-armbru@redhat.com>
[Commit message typo corrected]

5 years agoqom/cpu: Simplify how CPUClass:cpu_dump_state() prints
Markus Armbruster [Wed, 17 Apr 2019 19:18:02 +0000 (21:18 +0200)]
qom/cpu: Simplify how CPUClass:cpu_dump_state() prints

CPUClass method dump_statistics() takes an fprintf()-like callback and
a FILE * to pass to it.  Most callers pass fprintf() and stderr.
log_cpu_state() passes fprintf() and qemu_log_file.
hmp_info_registers() passes monitor_fprintf() and the current monitor
cast to FILE *.  monitor_fprintf() casts it right back, and is
otherwise identical to monitor_printf().

The callback gets passed around a lot, which is tiresome.  The
type-punning around monitor_fprintf() is ugly.

Drop the callback, and call qemu_fprintf() instead.  Also gets rid of
the type-punning, since qemu_fprintf() takes NULL instead of the
current monitor cast to FILE *.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20190417191805.28198-15-armbru@redhat.com>

5 years agoqemu-print: New qemu_fprintf(), qemu_vfprintf()
Markus Armbruster [Wed, 17 Apr 2019 19:18:01 +0000 (21:18 +0200)]
qemu-print: New qemu_fprintf(), qemu_vfprintf()

Code that doesn't want to know about current monitor vs. stdout
vs. stderr takes an fprintf_function callback and a FILE * argument to
pass to it.  Actual arguments are either fprintf() and stdout or
stderr, or monitor_fprintf() and the current monitor cast to FILE *.
monitor_fprintf() casts it right back, and is otherwise identical to
monitor_printf().  The type-punning is ugly.

New qemu_fprintf() and qemu_vprintf() address this need without type
punning: they are like fprintf() and vfprintf(), except they print to
the current monitor when passed a null FILE *.  The next commits will
put them to use.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20190417191805.28198-14-armbru@redhat.com>

5 years agoqom/cpu: Simplify how CPUClass::dump_statistics() prints
Markus Armbruster [Wed, 17 Apr 2019 19:18:00 +0000 (21:18 +0200)]
qom/cpu: Simplify how CPUClass::dump_statistics() prints

CPUClass method dump_statistics() takes an fprintf()-like callback and
a FILE * to pass to it.

Its only caller hmp_info_cpustats() (via cpu_dump_statistics()) passes
monitor_fprintf() and the current monitor cast to FILE *.
monitor_fprintf() casts it right back, and is otherwise identical to
monitor_printf().  The type-punning is ugly.

Drop the callback, and call qemu_printf() instead.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20190417191805.28198-13-armbru@redhat.com>

5 years agotarget/i386: Simplify how x86_cpu_dump_local_apic_state() prints
Markus Armbruster [Wed, 17 Apr 2019 19:17:59 +0000 (21:17 +0200)]
target/i386: Simplify how x86_cpu_dump_local_apic_state() prints

x86_cpu_dump_local_apic_state() takes an fprintf()-like callback and a
FILE * to pass to it, and so do its helper functions.

Its only caller hmp_info_local_apic() passes monitor_fprintf() and the
current monitor cast to FILE *.  monitor_fprintf() casts it right
back, and is otherwise identical to monitor_printf().  The
type-punning is ugly.

Drop the callback, and call qemu_printf() instead.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20190417191805.28198-12-armbru@redhat.com>

5 years agotarget: Clean up how the dump_mmu() print
Markus Armbruster [Wed, 17 Apr 2019 19:17:58 +0000 (21:17 +0200)]
target: Clean up how the dump_mmu() print

The various dump_mmu() take an fprintf()-like callback and a FILE * to
pass to it, and so do their helper functions.  Passing around callback
and argument is rather tiresome.

Most dump_mmu() are called only by the target's hmp_info_tlb().  These
all pass monitor_printf() cast to fprintf_function and the current
monitor cast to FILE *.

SPARC's dump_mmu() gets also called from target/sparc/ldst_helper.c a
few times #ifdef DEBUG_MMU.  These calls pass fprintf() and stdout.

The type-punning is technically undefined behaviour, but works in
practice.  Clean up: drop the callback, and call qemu_printf()
instead.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20190417191805.28198-11-armbru@redhat.com>

5 years agotarget: Simplify how the TARGET_cpu_list() print
Markus Armbruster [Wed, 17 Apr 2019 19:17:57 +0000 (21:17 +0200)]
target: Simplify how the TARGET_cpu_list() print

The various TARGET_cpu_list() take an fprintf()-like callback and a
FILE * to pass to it.  Their callers (vl.c's main() via list_cpus(),
bsd-user/main.c's main(), linux-user/main.c's main()) all pass
fprintf() and stdout.  Thus, the flexibility provided by the (rather
tiresome) indirection isn't actually used.

Drop the callback, and call qemu_printf() instead.

Calling printf() would also work, but would make the code unsuitable
for monitor context without making it simpler.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190417191805.28198-10-armbru@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
5 years agomemory: Clean up how mtree_info() prints
Markus Armbruster [Wed, 17 Apr 2019 19:17:56 +0000 (21:17 +0200)]
memory: Clean up how mtree_info() prints

mtree_info() takes an fprintf()-like callback and a FILE * to pass to
it, and so do its helper functions.  Passing around callback and
argument is rather tiresome.

Its only caller hmp_info_mtree() passes monitor_printf() cast to
fprintf_function and the current monitor cast to FILE *.

The type-punning is technically undefined behaviour, but works in
practice.  Clean up: drop the callback, and call qemu_printf()
instead.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20190417191805.28198-9-armbru@redhat.com>

5 years agoblock/qapi: Clean up how we print to monitor or stdout
Markus Armbruster [Wed, 17 Apr 2019 19:17:55 +0000 (21:17 +0200)]
block/qapi: Clean up how we print to monitor or stdout

bdrv_snapshot_dump(), bdrv_image_info_specific_dump(),
bdrv_image_info_dump() and their helpers take an fprintf()-like
callback and a FILE * to pass to it.

hmp.c passes monitor_printf() cast to fprintf_function and the current
monitor cast to FILE *.

qemu-img.c and qemu-io-cmds.c pass fprintf and stdout.

The type-punning is technically undefined behaviour, but works in
practice.  Clean up: drop the callback, and call qemu_printf()
instead.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20190417191805.28198-8-armbru@redhat.com>

5 years agoqsp: Simplify how qsp_report() prints
Markus Armbruster [Wed, 17 Apr 2019 19:17:54 +0000 (21:17 +0200)]
qsp: Simplify how qsp_report() prints

qsp_report() takes an fprintf()-like callback and a FILE * to pass to
it.

Its only caller hmp_sync_profile() passes monitor_fprintf() and the
current monitor cast to FILE *.  monitor_fprintf() casts it right
back, and is otherwise identical to monitor_printf().  The
type-punning is ugly.

Drop the callback, and call qemu_printf() instead.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20190417191805.28198-7-armbru@redhat.com>