]> git.proxmox.com Git - mirror_qemu.git/log
mirror_qemu.git
4 years agobuild: rename CONFIG_LIBCAP to CONFIG_LIBCAP_NG
Paolo Bonzini [Fri, 29 Nov 2019 10:42:53 +0000 (11:42 +0100)]
build: rename CONFIG_LIBCAP to CONFIG_LIBCAP_NG

Since we are actually testing for the newer capng library, rename the
symbol to match.

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agocolo: fix return without releasing RCU
Paolo Bonzini [Fri, 13 Dec 2019 14:07:22 +0000 (15:07 +0100)]
colo: fix return without releasing RCU

Use WITH_RCU_READ_LOCK_GUARD to avoid exiting colo_init_ram_cache
without releasing RCU.

Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agomemory: use RCU_READ_LOCK_GUARD
Paolo Bonzini [Fri, 13 Dec 2019 14:06:45 +0000 (15:06 +0100)]
memory: use RCU_READ_LOCK_GUARD

Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agoqsp: Use WITH_RCU_READ_LOCK_GUARD
Dr. David Alan Gilbert [Fri, 13 Dec 2019 13:19:31 +0000 (13:19 +0000)]
qsp: Use WITH_RCU_READ_LOCK_GUARD

The automatic rcu read lock maintenance works quite
nicely in this case where it previously relied on a comment to
delimit the lifetime and now has a block.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agohyperv: Use auto rcu_read macros
Dr. David Alan Gilbert [Fri, 13 Dec 2019 13:19:30 +0000 (13:19 +0000)]
hyperv: Use auto rcu_read macros

Use RCU_READ_LOCK_GUARD and WITH_RCU_READ_LOCK_GUARD
to replace the manual rcu_read_(un)lock calls.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agohw/i386/pc: Extract the port92 device
Philippe Mathieu-Daudé [Fri, 13 Dec 2019 10:51:00 +0000 (11:51 +0100)]
hw/i386/pc: Extract the port92 device

This device is only used by the PC machines. The pc.c file is
already big enough, with 2255 lines. By removing 113 lines of
it, we reduced it by 5%. It is now a bit easier to navigate
the file.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agohw/i386/pc: Inline port92_init()
Philippe Mathieu-Daudé [Fri, 13 Dec 2019 10:50:59 +0000 (11:50 +0100)]
hw/i386/pc: Inline port92_init()

This one-line function is not very helpful, so remove it
by inlining the call to qdev_connect_gpio_out_named().

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agohw/i386/pc: Use TYPE_PORT92 instead of hardcoded string
Philippe Mathieu-Daudé [Fri, 13 Dec 2019 10:50:58 +0000 (11:50 +0100)]
hw/i386/pc: Use TYPE_PORT92 instead of hardcoded string

By using the TYPE_* definitions for devices, we can:
- quickly find where devices are used with 'git-grep'
- easily rename a device (one-line change).

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agohw/isa/isa-bus: cleanup irq functions
Paolo Bonzini [Fri, 13 Dec 2019 12:00:43 +0000 (13:00 +0100)]
hw/isa/isa-bus: cleanup irq functions

The irq number is unsigned; we reject negative values.  But -1
is used for the isairq array, which is declared unsigned!  And
since we have a definition for the number of ISA IRQs, use it.

Based on a patch by Philippe Mathieu-Daudé.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agohw/i386: Simplify ioapic_init_gsi()
Philippe Mathieu-Daudé [Fri, 13 Dec 2019 11:11:45 +0000 (12:11 +0100)]
hw/i386: Simplify ioapic_init_gsi()

All callers of ioapic_init_gsi() provide a parent. We want new
uses to follow the same good practice and provide the parent
name, so do not make this optional: assert the parent name is
provided, and simplify the code.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agohw/i386: De-duplicate gsi_handler() to remove kvm_pc_gsi_handler()
Philippe Mathieu-Daudé [Fri, 13 Dec 2019 11:07:36 +0000 (12:07 +0100)]
hw/i386: De-duplicate gsi_handler() to remove kvm_pc_gsi_handler()

Both gsi_handler() and kvm_pc_gsi_handler() have the same content,
except one comment. Move the comment, and de-duplicate the code.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agopc: stubify x86 iommu
Paolo Bonzini [Thu, 12 Dec 2019 17:10:35 +0000 (18:10 +0100)]
pc: stubify x86 iommu

Allow building microvm without x86-iommu.c.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agoacpi: move PC stubs out of stubs/
Paolo Bonzini [Thu, 12 Dec 2019 17:03:46 +0000 (18:03 +0100)]
acpi: move PC stubs out of stubs/

This is a small cleanup that lets microvm build entirely without
include/hw/i386/pc.h.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agox86: move more x86-generic functions out of PC files
Paolo Bonzini [Thu, 12 Dec 2019 13:14:40 +0000 (14:14 +0100)]
x86: move more x86-generic functions out of PC files

These are needed by microvm too, so move them outside of PC-specific files.
With this patch, microvm.c need not include pc.h anymore.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agohw/i386/pc: Convert DPRINTF() to trace events
Philippe Mathieu-Daudé [Fri, 13 Dec 2019 10:50:57 +0000 (11:50 +0100)]
hw/i386/pc: Convert DPRINTF() to trace events

Convert the deprecated DPRINTF() macro to trace events.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agox86: move SMM property to X86MachineState
Paolo Bonzini [Thu, 12 Dec 2019 16:28:01 +0000 (17:28 +0100)]
x86: move SMM property to X86MachineState

Add it to microvm as well, it is a generic property of the x86
architecture.

Suggested-by: Sergio Lopez <slp@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agopci-stub: add more MSI functions
Paolo Bonzini [Thu, 12 Dec 2019 13:20:05 +0000 (14:20 +0100)]
pci-stub: add more MSI functions

On x86, KVM needs some function from the PCI subsystem in order to set
up interrupt routes.  Provide some stubs to support x86 machines that
lack PCI.

Reviewed-by: Sergio Lopez <slp@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agohw: replace hw/i386/pc.h with a header just for the i8259
Paolo Bonzini [Thu, 12 Dec 2019 16:15:43 +0000 (17:15 +0100)]
hw: replace hw/i386/pc.h with a header just for the i8259

Remove the need to include i386/pc.h to get to the i8259 functions.
This is enough to remove the inclusion of hw/i386/pc.h from all non-x86
files.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agofw_cfg: allow building without other devices
Paolo Bonzini [Thu, 12 Dec 2019 13:12:27 +0000 (14:12 +0100)]
fw_cfg: allow building without other devices

The microvm machine type uses fw_cfg but lacks SMBIOS and ACPI.  Do not
include the files if the symbol is not present in QEMU and remove
dependencies on machine-specific files.

Reviewed-by: Sergio Lopez <slp@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agoi386: conditionally compile more files
Paolo Bonzini [Thu, 12 Dec 2019 10:52:37 +0000 (11:52 +0100)]
i386: conditionally compile more files

Reviewed-by: Sergio Lopez <slp@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agoconfigure: simplify vhost condition with Kconfig
Marc-André Lureau [Thu, 15 Aug 2019 13:13:06 +0000 (17:13 +0400)]
configure: simplify vhost condition with Kconfig

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agoconfigure: set $PYTHON to a full path
Paolo Bonzini [Mon, 10 Jun 2019 10:03:44 +0000 (12:03 +0200)]
configure: set $PYTHON to a full path

This will make it possible to replace it in a shebang line.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agostubs: replace stubs with lnot if applicable
Paolo Bonzini [Tue, 6 Aug 2019 13:12:18 +0000 (15:12 +0200)]
stubs: replace stubs with lnot if applicable

The stubs mechanism relies on static libraries and compilation order,
which is a bit brittle and should be avoided unless necessary.
Replace it with Boolean operations on CONFIG_* symbols.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agocrypto: move common bits for all emulators to libqemuutil
Paolo Bonzini [Mon, 29 Jul 2019 13:55:47 +0000 (15:55 +0200)]
crypto: move common bits for all emulators to libqemuutil

qcrypto_random_*, AES and qcrypto_init do not need to be linked as a whole
and are the only parts that are used by user-mode emulation.  Place them
in libqemuutil, so that whatever needs them will pick them up automatically.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agolibvixl: remove per-target compiler flags
Paolo Bonzini [Mon, 29 Jul 2019 10:50:04 +0000 (12:50 +0200)]
libvixl: remove per-target compiler flags

We are already including -D__STDC_LIMIT_MACROS in the global CXXFLAGS,
so it makes sense to do the same for -D__STDC_CONSTANT_MACROS and
-D__STDC_FORMAT_MACROS instead of limiting that to libvixl.

The -Wno-sign-compare option can also be removed since GCC 4.6 is not
supported anymore.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agotests: skip block layer tests if !CONFIG_TOOLS
Marc-André Lureau [Tue, 3 Sep 2019 08:30:48 +0000 (12:30 +0400)]
tests: skip block layer tests if !CONFIG_TOOLS

The block tests, as well as ahci-test needs qemu-img.  Do not run
them if it wasn't built.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agoos-posix: simplify os_find_datadir
Marc-André Lureau [Wed, 18 Sep 2019 08:24:10 +0000 (12:24 +0400)]
os-posix: simplify os_find_datadir

Use g_build_filename instead of sprintf, and g_autofree instead of
manual freeing.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agovhost-user-scsi: fix printf format warning
Marc-André Lureau [Wed, 28 Aug 2019 08:18:06 +0000 (12:18 +0400)]
vhost-user-scsi: fix printf format warning

Fixes:
../contrib/vhost-user-scsi/vhost-user-scsi.c:118:57: error: format specifies
      type 'unsigned char' but the argument has type 'int' [-Werror,-Wformat]
    g_warning("Unable to determine cdb len (0x%02hhX)", cdb[0] >> 5);

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agomonitor: fix maybe-uninitialized
Marc-André Lureau [Fri, 4 Oct 2019 11:18:20 +0000 (15:18 +0400)]
monitor: fix maybe-uninitialized

../monitor/misc.c: In function ‘mon_get_cpu_sync’:
/home/elmarco/src/qq/include/sysemu/hw_accel.h:22:9: error: ‘cpu’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
   22 |         kvm_cpu_synchronize_state(cpu);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../monitor/misc.c:397:15: note: ‘cpu’ was declared here
  397 |     CPUState *cpu;
      |               ^~~

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agomigration: fix maybe-uninitialized warning
Marc-André Lureau [Fri, 4 Oct 2019 11:12:09 +0000 (15:12 +0400)]
migration: fix maybe-uninitialized warning

../migration/ram.c: In function ‘multifd_recv_thread’:
/home/elmarco/src/qq/include/qapi/error.h:165:5: error: ‘block’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  165 |     error_setg_internal((errp), __FILE__, __LINE__, __func__,   \
      |     ^~~~~~~~~~~~~~~~~~~
../migration/ram.c:818:15: note: ‘block’ was declared here
  818 |     RAMBlock *block;
      |               ^~~~~

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agobuild-sys: do not include Windows SLIRP dependencies in $LIBS
Paolo Bonzini [Wed, 11 Dec 2019 13:41:51 +0000 (14:41 +0100)]
build-sys: do not include Windows SLIRP dependencies in $LIBS

When including the internal SLIRP library, we should add all the libraries that
it needs for the build.  Right now they are all included by QEMU, but -liphlpapi
is not needed without slirp.  Move it from LIBS to slirp_libs.

Based on a patch by Marc-André Lureau.

Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agobuild-sys: build vhost-user-gpu only if CONFIG_TOOLS
Marc-André Lureau [Tue, 27 Aug 2019 08:08:24 +0000 (12:08 +0400)]
build-sys: build vhost-user-gpu only if CONFIG_TOOLS

vhost-user-gpu is always built and installed, but it is not part of the emulator
proper.  Cut it if --disable-tools is specified.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agoobject: Improve documentation of interfaces
Greg Kurz [Wed, 11 Dec 2019 13:32:41 +0000 (14:32 +0100)]
object: Improve documentation of interfaces

QOM interfaces allow a limited form of multiple inheritance, at the
condition of being stateless. That is, they cannot be instantiated
and a pointer to an interface shouldn't be dereferenceable in any way.
This is achieved by making the QOM instance type an incomplete type,
which is, as mentioned by Markus Armbruster, the closest you can get
to abstract class in C.

Incomplete types are widely used to hide implementation details, but
people usually expect to find at least one place where the type is
fully defined. The fact that it doesn't happen with QOM interfaces is
quite disturbing, especially since it isn't documented anywhere as
recently discussed in this thread:

https://lists.gnu.org/archive/html/qemu-devel/2019-12/msg01579.html

Amend the documentation in the object.h header file to provide more
details about why and how to implement QOM interfaces using incomplete
types.

Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agoMakefile: remove unused variables
Paolo Bonzini [Mon, 5 Aug 2019 15:11:23 +0000 (17:11 +0200)]
Makefile: remove unused variables

Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agokvm: convert "-machine kernel_irqchip" to an accelerator property
Paolo Bonzini [Wed, 13 Nov 2019 09:56:53 +0000 (10:56 +0100)]
kvm: convert "-machine kernel_irqchip" to an accelerator property

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agokvm: introduce kvm_kernel_irqchip_* functions
Paolo Bonzini [Wed, 13 Nov 2019 10:17:12 +0000 (11:17 +0100)]
kvm: introduce kvm_kernel_irqchip_* functions

The KVMState struct is opaque, so provide accessors for the fields
that will be moved from current_machine to the accelerator.  For now
they just forward to the machine object, but this will change.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agokvm: convert "-machine kvm_shadow_mem" to an accelerator property
Paolo Bonzini [Wed, 13 Nov 2019 09:56:53 +0000 (10:56 +0100)]
kvm: convert "-machine kvm_shadow_mem" to an accelerator property

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agoxen: convert "-machine igd-passthru" to an accelerator property
Paolo Bonzini [Wed, 13 Nov 2019 09:56:53 +0000 (10:56 +0100)]
xen: convert "-machine igd-passthru" to an accelerator property

The first machine property to fall is Xen's Intel integrated graphics
passthrough.  The "-machine igd-passthru" option does not set anymore
a property on the machine object, but desugars to a GlobalProperty on
accelerator objects.

The setter is very simple, since the value ends up in a
global variable, so this patch also provides an example before the more
complicated cases that follow it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agotcg: add "-accel tcg,tb-size" and deprecate "-tb-size"
Paolo Bonzini [Wed, 13 Nov 2019 14:16:44 +0000 (15:16 +0100)]
tcg: add "-accel tcg,tb-size" and deprecate "-tb-size"

-tb-size fits nicely in the new framework for accelerator-specific options.  It
is a very niche option, so insta-deprecate it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agotcg: convert "-accel threads" to a QOM property
Paolo Bonzini [Wed, 13 Nov 2019 09:36:01 +0000 (10:36 +0100)]
tcg: convert "-accel threads" to a QOM property

Replace the ad-hoc qemu_tcg_configure with generic code invoking QOM
property getters and setters.  More properties (and thus more valid
-accel suboptions) will be added in the next patches, which will move
accelerator-related "-machine" options to accelerators.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agoaccel: pass object to accel_init_machine
Paolo Bonzini [Wed, 13 Nov 2019 13:03:46 +0000 (14:03 +0100)]
accel: pass object to accel_init_machine

We will have to set QOM properties before accel_init_machine, based on the
options provided to -accel.  Construct the object outside it so that it
will be possible to iterate on properties between object_new_with_class
and accel_init_machine.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agoqom: add object_new_with_class
Paolo Bonzini [Wed, 13 Nov 2019 12:57:55 +0000 (13:57 +0100)]
qom: add object_new_with_class

Similar to CPU and machine classes, "-accel" class names are mangled,
so we have to first get a class via accel_find and then instantiate it.
Provide a new function to instantiate a class without going through
object_class_get_name, and use it for CPUs and machines already.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agoqom: introduce object_register_sugar_prop
Paolo Bonzini [Wed, 13 Nov 2019 12:33:44 +0000 (13:33 +0100)]
qom: introduce object_register_sugar_prop

Similar to the existing "-rtc driftfix" option, we will convert some
legacy "-machine" command line options to global properties on accelerators.
Because accelerators are not devices, we cannot use qdev_prop_register_global.
Instead, provide a slot in the generic object_compat_props arrays for
command line syntactic sugar.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agovl: warn for unavailable accelerators, clarify messages
Paolo Bonzini [Wed, 13 Nov 2019 11:08:38 +0000 (12:08 +0100)]
vl: warn for unavailable accelerators, clarify messages

So far, specifying an accelerator that was not compiled in did not result
in an error; fix that.

While at it, clarify the mysterious "Back to TCG" message.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agovl: configure accelerators from -accel options
Paolo Bonzini [Wed, 13 Nov 2019 09:10:47 +0000 (10:10 +0100)]
vl: configure accelerators from -accel options

Drop the "accel" property from MachineState, and instead desugar
"-machine accel=" to a list of "-accel" options.

This has a semantic change due to removing merge_lists from -accel.
For example:

- "-accel kvm -accel tcg" all but ignored "-accel kvm".  This is a bugfix.

- "-accel kvm -accel thread=single" ignored "thread=single", since it
  applied the option to KVM.  Now it fails due to not specifying the
  accelerator on "-accel thread=single".

- "-accel tcg -accel thread=single" chose single-threaded TCG, while now
  it will fail due to not specifying the accelerator on "-accel
  thread=single".

Also, "-machine accel" and "-accel" become incompatible.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agovl: introduce object_parse_property_opt
Paolo Bonzini [Wed, 13 Nov 2019 10:44:48 +0000 (11:44 +0100)]
vl: introduce object_parse_property_opt

We will reuse the parsing loop of machine_set_property soon for "-accel",
but we do not want the "_" -> "-" conversion since "-accel" can just
standardize on dashes.  We will also add a bunch of legacy option handling
to keep the QOM machine object clean.  Extract the loop into a separate
function, and keep the legacy handling in machine_set_property.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agoaccel: compile accel/accel.c just once
Paolo Bonzini [Thu, 14 Nov 2019 11:06:52 +0000 (12:06 +0100)]
accel: compile accel/accel.c just once

Now that accel/accel.c does not use CONFIG_TCG or CONFIG_KVM anymore,
it need not be compiled once for every softmmu target.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agovl: merge -accel processing into configure_accelerators
Paolo Bonzini [Wed, 13 Nov 2019 08:59:04 +0000 (09:59 +0100)]
vl: merge -accel processing into configure_accelerators

The next step is to move the parsing of "-machine accel=..." into vl.c,
unifying it with the configure_accelerators() function that has just
been introduced.  This way, we will be able to desugar it into multiple
"-accel" options, without polluting accel/accel.c.

The CONFIG_TCG and CONFIG_KVM symbols are not available in vl.c, but
we can use accel_find instead to find their value at runtime.  Once we
know that the binary has one of TCG or KVM, the default accelerator
can be expressed simply as "tcg:kvm", because TCG never fails to initialize.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agovl: extract accelerator option processing to a separate function
Paolo Bonzini [Thu, 14 Nov 2019 10:10:43 +0000 (11:10 +0100)]
vl: extract accelerator option processing to a separate function

As a first step towards supporting multiple "-accel" options, push the
late processing of -icount and -accel into a new function, and use
qemu_opts_foreach to retrieve -accel options instead of stashing
them into globals.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agotcg: move qemu_tcg_configure to accel/tcg/tcg-all.c
Paolo Bonzini [Thu, 14 Nov 2019 09:40:27 +0000 (10:40 +0100)]
tcg: move qemu_tcg_configure to accel/tcg/tcg-all.c

Move everything related to mttcg_enabled in accel/tcg/tcg-all.c,
which will make even more sense when "thread" becomes a QOM property.

For now, initializing mttcg_enabled in the instance_init function
prepares for the next patch, which will only invoke qemu_tcg_configure
when the command line includes a -accel option.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agovl: move icount configuration earlier
Paolo Bonzini [Wed, 13 Nov 2019 11:37:00 +0000 (12:37 +0100)]
vl: move icount configuration earlier

Once qemu_tcg_configure is turned into a QOM property setter, it will not
be able to set a default value for mttcg_enabled.  Setting the default will
move to the TCG instance_init function, which currently runs before "-icount"
is processed.

However, it is harmless to do configure_icount for all accelerators; we will
just fail later if a non-TCG accelerator is selected.  So do that.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agomemory: do not look at current_machine->accel
Paolo Bonzini [Wed, 13 Nov 2019 10:50:03 +0000 (11:50 +0100)]
memory: do not look at current_machine->accel

"info mtree -f" prints the wrong accelerator name if used with for example
"-machine accel=kvm:tcg".  The right thing to do is to fetch the name
from the AccelClass, which will also work nicely once
current_machine->accel stops existing.

Tested-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 years agomigration-test: Use a struct for test_migrate_start parameters
Juan Quintela [Thu, 12 Dec 2019 22:20:33 +0000 (23:20 +0100)]
migration-test: Use a struct for test_migrate_start parameters

It has two bools and two strings, it is very difficult to remember
which does what.  And it makes very difficult to add new parameters as
we need to modify all the callers.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Tested-by: Cornelia Huck <cohuck@redhat.com> #s390x
Tested-by: Laurent Vivier <lvivier@redhat.com>
4 years agomigration-test: Rename cmd_src/dst to arch_source/arch_target
Juan Quintela [Thu, 12 Dec 2019 22:20:32 +0000 (23:20 +0100)]
migration-test: Rename cmd_src/dst to arch_source/arch_target

This explains better what they do and avoid confussino with
command_src/target.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Tested-by: Cornelia Huck <cohuck@redhat.com> #s390x
Tested-by: Laurent Vivier <lvivier@redhat.com>
4 years agomigration-test: Move -incomming handling to common commandline
Juan Quintela [Thu, 12 Dec 2019 22:20:31 +0000 (23:20 +0100)]
migration-test: Move -incomming handling to common commandline

Signed-off-by: Juan Quintela <quintela@redhat.com>
Tested-by: Cornelia Huck <cohuck@redhat.com> #s390x
Tested-by: Laurent Vivier <lvivier@redhat.com>
4 years agomigration-test: Move -serial handling to common commandline
Juan Quintela [Thu, 12 Dec 2019 22:20:30 +0000 (23:20 +0100)]
migration-test: Move -serial handling to common commandline

Signed-off-by: Juan Quintela <quintela@redhat.com>
Tested-by: Cornelia Huck <cohuck@redhat.com> #s390x
Tested-by: Laurent Vivier <lvivier@redhat.com>
4 years agomigration-test: Move -name handling to common commandline
Juan Quintela [Thu, 12 Dec 2019 22:20:29 +0000 (23:20 +0100)]
migration-test: Move -name handling to common commandline

Signed-off-by: Juan Quintela <quintela@redhat.com>
Tested-by: Cornelia Huck <cohuck@redhat.com> #s390x
Tested-by: Laurent Vivier <lvivier@redhat.com>
4 years agomigration-test: Move shmem handling to common commandline
Juan Quintela [Thu, 12 Dec 2019 22:20:28 +0000 (23:20 +0100)]
migration-test: Move shmem handling to common commandline

Signed-off-by: Juan Quintela <quintela@redhat.com>
Tested-by: Cornelia Huck <cohuck@redhat.com> #s390x
Tested-by: Laurent Vivier <lvivier@redhat.com>
4 years agomigration-test: Move memory size to common commandline
Juan Quintela [Thu, 12 Dec 2019 22:20:27 +0000 (23:20 +0100)]
migration-test: Move memory size to common commandline

Signed-off-by: Juan Quintela <quintela@redhat.com>
Tested-by: Cornelia Huck <cohuck@redhat.com> #s390x
Tested-by: Laurent Vivier <lvivier@redhat.com>
4 years agomigration-test: Move -machine to common commandline
Juan Quintela [Thu, 12 Dec 2019 22:20:26 +0000 (23:20 +0100)]
migration-test: Move -machine to common commandline

Signed-off-by: Juan Quintela <quintela@redhat.com>
Tested-by: Cornelia Huck <cohuck@redhat.com> #s390x
Tested-by: Laurent Vivier <lvivier@redhat.com>
4 years agomigration-test: Move hide_stderr to common commandline
Juan Quintela [Thu, 12 Dec 2019 22:20:25 +0000 (23:20 +0100)]
migration-test: Move hide_stderr to common commandline

Signed-off-by: Juan Quintela <quintela@redhat.com>
Tested-by: Cornelia Huck <cohuck@redhat.com> #s390x
Tested-by: Laurent Vivier <lvivier@redhat.com>
4 years agomigration-test: Create cmd_soure and cmd_target
Juan Quintela [Thu, 12 Dec 2019 22:20:24 +0000 (23:20 +0100)]
migration-test: Create cmd_soure and cmd_target

We are repeating almost everything for each machine while creating the
command line for migration.  And once for source and another for
destination.  We start putting there opts_src and opts_dst.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Tested-by: Cornelia Huck <cohuck@redhat.com> #s390x
Tested-by: Laurent Vivier <lvivier@redhat.com>
4 years agokvm: Reallocate dirty_bmap when we change a slot
Dr. David Alan Gilbert [Thu, 21 Nov 2019 16:56:45 +0000 (16:56 +0000)]
kvm: Reallocate dirty_bmap when we change a slot

kvm_set_phys_mem can be called to reallocate a slot by something the
guest does (e.g. writing to PAM and other chipset registers).
This can happen in the middle of a migration, and if we're unlucky
it can now happen between the split 'sync' and 'clear'; the clear
asserts if there's no bmap to clear.   Recreate the bmap whenever
we change the slot, keeping the clear path happy.

Typically this is triggered by the guest rebooting during a migrate.

Corresponds to:
https://bugzilla.redhat.com/show_bug.cgi?id=1772774
https://bugzilla.redhat.com/show_bug.cgi?id=1771032

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
4 years agoMerge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2019-12-17' into...
Peter Maydell [Tue, 17 Dec 2019 15:55:20 +0000 (15:55 +0000)]
Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2019-12-17' into staging

* Removal of the deprecated bluetooth code
* Some qtest and misc patches

# gpg: Signature made Tue 17 Dec 2019 08:09:08 GMT
# gpg:                using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5
# gpg:                issuer "thuth@redhat.com"
# gpg: Good signature from "Thomas Huth <th.huth@gmx.de>" [full]
# gpg:                 aka "Thomas Huth <thuth@redhat.com>" [full]
# gpg:                 aka "Thomas Huth <huth@tuxfamily.org>" [full]
# gpg:                 aka "Thomas Huth <th.huth@posteo.de>" [unknown]
# Primary key fingerprint: 27B8 8847 EEE0 2501 18F3  EAB9 2ED9 D774 FE70 2DB5

* remotes/huth-gitlab/tags/pull-request-2019-12-17:
  tests: use g_test_rand_int
  tests/Makefile: Fix check-report.* targets shown in check-help
  glib: use portable g_setenv()
  hw/misc/ivshmem: Bury dead legacy INTx code
  pseries: disable migration-test if /dev/kvm cannot be used
  tests: fix modules-test 'duplicate test case' error
  Remove libbluetooth / bluez from the CI tests
  Remove the core bluetooth code
  hw/usb: Remove the USB bluetooth dongle device
  hw/arm/nseries: Replace the bluetooth chardev with a "null" chardev

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4 years agoMerge remote-tracking branch 'remotes/cleber/tags/python-next-pull-request' into...
Peter Maydell [Tue, 17 Dec 2019 14:34:31 +0000 (14:34 +0000)]
Merge remote-tracking branch 'remotes/cleber/tags/python-next-pull-request' into staging

Python queue 2019-12-17

# gpg: Signature made Tue 17 Dec 2019 05:12:43 GMT
# gpg:                using RSA key 7ABB96EB8B46B94D5E0FE9BB657E8D33A5F209F3
# gpg: Good signature from "Cleber Rosa <crosa@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: 7ABB 96EB 8B46 B94D 5E0F  E9BB 657E 8D33 A5F2 09F3

* remotes/cleber/tags/python-next-pull-request:
  python/qemu: Remove unneeded imports in __init__
  python/qemu: accel: Add tcg_available() method
  python/qemu: accel: Strengthen kvm_available() checks
  python/qemu: accel: Add list_accel() method
  python/qemu: Move kvm_available() to its own module
  Acceptance tests: use relative location for tests
  Acceptance tests: use avocado tags for machine type
  Acceptance tests: introduce utility method for tags unique vals
  Acceptance test x86_cpu_model_versions: use default vm
  tests/acceptance: Makes linux_initrd and empty_cpu_model use QEMUMachine
  python/qemu: Add set_qmp_monitor() to QEMUMachine
  analyze-migration.py: replace numpy with python 3.2
  analyze-migration.py: fix find() type error
  Revert "Acceptance test: cancel test if m68k kernel packages goes missing"
  tests/boot_linux_console: Fetch assets from Debian snapshot archives

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4 years agoMerge remote-tracking branch 'remotes/dgibson/tags/ppc-for-5.0-20191217' into staging
Peter Maydell [Tue, 17 Dec 2019 11:52:04 +0000 (11:52 +0000)]
Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-5.0-20191217' into staging

ppc patch queue 2019-12-17

This is the first pull request for the qemu-5.0 branch.  It has a lot
of accumulated changes, including:

    * SLOF update to support boot using the IOMMU (will become
      necessary for secure guests)

    * Clean ups to pnv handling of chip models

    * A number of extensions to the powernv machine model

    * TCG extensions to allow powernv emulated systems to run KVM guests

    * Outline support for POWER10 chips in powernv

    * Cleanups to the ibm,client-architecture-support feature negotiation path

    * XIVE reworks to better handle the powernv machine

    * Improvements to not waste interrupt queues and other semi-scarce
      resources when using XIVE under KVM

# gpg: Signature made Tue 17 Dec 2019 04:42:20 GMT
# 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-5.0-20191217: (88 commits)
  pseries: Update SLOF firmware image
  ppc/pnv: Drop PnvChipClass::type
  ppc/pnv: Introduce PnvChipClass::xscom_pcba() method
  ppc/pnv: Drop pnv_chip_is_power9() and pnv_chip_is_power10() helpers
  ppc/pnv: Pass content of the "compatible" property to pnv_dt_xscom()
  ppc/pnv: Pass XSCOM base address and address size to pnv_dt_xscom()
  ppc/pnv: Introduce PnvChipClass::xscom_core_base() method
  ppc/pnv: Introduce PnvChipClass::intc_print_info() method
  ppc/pnv: Drop pnv_is_power9() and pnv_is_power10() helpers
  ppc/pnv: Introduce PnvMachineClass::dt_power_mgt()
  ppc/pnv: Introduce PnvMachineClass and PnvMachineClass::compat
  ppc/pnv: Drop PnvPsiClass::chip_type
  ppc/pnv: Introduce PnvPsiClass::compat
  ppc: Drop useless extern annotation for functions
  ppc/pnv: Fix OCC common area region mapping
  ppc/pnv: Introduce PBA registers
  ppc/pnv: Make PnvXScomInterface an incomplete type
  ppc/pnv: populate the DT with realized XSCOM devices
  ppc/pnv: Loop on the whole hierarchy to populate the DT with the XSCOM nodes
  target/ppc: Add SPR TBU40
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4 years agoMerge remote-tracking branch 'remotes/ehabkost/tags/x86-next-pull-request' into staging
Peter Maydell [Tue, 17 Dec 2019 10:57:07 +0000 (10:57 +0000)]
Merge remote-tracking branch 'remotes/ehabkost/tags/x86-next-pull-request' into staging

x86 queue, 2019-12-16

Feature:
* Cooperlake CPU model

Cleanups:
* Use g_autofree in a few places

# gpg: Signature made Mon 16 Dec 2019 19:36:51 GMT
# gpg:                using RSA key 5A322FD5ABC4D3DBACCFD1AA2807936F984DC5A6
# gpg:                issuer "ehabkost@redhat.com"
# 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:
  i386: Use g_autofree in a few places
  i386: Add new CPU model Cooperlake
  i386: Add macro for stibp
  i386: Add MSR feature bit for MDS-NO

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4 years agotests: use g_test_rand_int
Paolo Bonzini [Thu, 12 Dec 2019 01:17:58 +0000 (02:17 +0100)]
tests: use g_test_rand_int

g_test_rand_int provides a reproducible random integer number, using a
different number seed every time but allowing reproduction using the
--seed command line option.  It is thus better suited to tests than
g_random_int or random.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <1576113478-42926-1-git-send-email-pbonzini@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
4 years agotests/Makefile: Fix check-report.* targets shown in check-help
Wainer dos Santos Moschetta [Wed, 11 Dec 2019 20:44:27 +0000 (15:44 -0500)]
tests/Makefile: Fix check-report.* targets shown in check-help

The check-report.html and check-report.xml targets were replaced
with check-report.tap in commit 9df43317b82 but the check-help
text was not updated so it still lists check-report.html.

Fixes: 9df43317b82
Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
Message-Id: <20191211204427.4681-2-wainersm@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
4 years agoglib: use portable g_setenv()
Marc-André Lureau [Wed, 11 Dec 2019 14:23:28 +0000 (15:23 +0100)]
glib: use portable g_setenv()

We have a setenv() wrapper in os-win32.c that no one is actually using.
Drop it and change to g_setenv() uniformly.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <1576074210-52834-7-git-send-email-pbonzini@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
4 years agohw/misc/ivshmem: Bury dead legacy INTx code
Markus Armbruster [Thu, 5 Dec 2019 20:35:57 +0000 (21:35 +0100)]
hw/misc/ivshmem: Bury dead legacy INTx code

Devices "ivshmem-plain" and "ivshmem-doorbell" support only MSI-X.
Config space register Interrupt Pin is zero.  Device "ivshmem"
additionally supported legacy INTx, but it was removed in commit
5a0e75f0a9 "hw/misc/ivshmem: Remove deprecated "ivshmem" legacy
device".  The commit left ivshmem_update_irq() behind.  Since the
Interrupt Pin register is zero, the function does nothing.  Remove it.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20191205203557.11254-1-armbru@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
4 years agopseries: disable migration-test if /dev/kvm cannot be used
Laurent Vivier [Wed, 20 Nov 2019 17:09:55 +0000 (18:09 +0100)]
pseries: disable migration-test if /dev/kvm cannot be used

On ppc64, migration-test only works with kvm_hv, and we already
have a check to verify the module is loaded.

kvm_hv module can be loaded in memory and /sys/module/kvm_hv exists,
but on some systems (like build systems) /dev/kvm can be missing
(by administrators choice).

And as kvm_hv exists test-migration is started but QEMU falls back to
TCG because it cannot be used:

    Could not access KVM kernel module: No such file or directory
    failed to initialize KVM: No such file or directory
    Back to tcg accelerator

And as the test is done with TCG, it fails.

As for s390x, we must check for the existence and the access rights
of /dev/kvm.

Reported-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Message-Id: <20191120170955.242900-1-lvivier@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
4 years agotests: fix modules-test 'duplicate test case' error
Cole Robinson [Wed, 13 Nov 2019 21:09:35 +0000 (16:09 -0500)]
tests: fix modules-test 'duplicate test case' error

./configure --enable-sdl --audio-drv-list=sdl --enable-modules

Will generate two identical test names: /$arch/module/load/sdl
Which generates an error like:

(tests/modules-test:23814): GLib-ERROR **: 18:23:06.359: duplicate test case path: /aarch64//module/load/sdl

Add the subsystem prefix in the name as well, so instead we get:

/$arch/module/load/audio-sdl
/$arch/module/load/ui-sdl

Signed-off-by: Cole Robinson <crobinso@redhat.com>
Message-Id: <d64c9aa098cc6e5c0b638438c4959eddfa7e24e2.1573679311.git.crobinso@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
4 years agoRemove libbluetooth / bluez from the CI tests
Thomas Huth [Wed, 20 Nov 2019 09:10:14 +0000 (10:10 +0100)]
Remove libbluetooth / bluez from the CI tests

Since the bluetooth code has been removed, we don't need to test
with this library anymore.

Message-Id: <20191120091014.16883-5-thuth@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
4 years agoRemove the core bluetooth code
Thomas Huth [Wed, 20 Nov 2019 09:10:13 +0000 (10:10 +0100)]
Remove the core bluetooth code

It's been deprecated since QEMU v3.1. We've explicitly asked in the
deprecation message that people should speak up on qemu-devel in case
they are still actively using the bluetooth part of QEMU, but nobody
ever replied that they are really still using it.

I've tried it on my own to use this bluetooth subsystem for one of my
guests, but I was also not able to get it running anymore: When I was
trying to pass-through a real bluetooth device, either the guest did
not see the device at all, or the guest crashed.

Even worse for the emulated device: When running

 qemu-system-x86_64 -bt device:keyboard

QEMU crashes once you hit a key.

So it seems like the bluetooth stack is not only neglected, it is
completely bitrotten, as far as I can tell. The only attention that
this code got during the past years were some CVEs that have been
spotted there. So this code is a burden for the developers, without
any real benefit anymore. Time to remove it.

Note: hw/bt/Kconfig only gets cleared but not removed here yet.
Otherwise there is a problem with the *-softmmu/config-devices.mak.d
dependency files - they still contain a reference to this file which
gets evaluated first on some build hosts, before the file gets
properly recreated. To avoid breaking these builders, we still need
the file around for some time. It will get removed in a couple of
weeks instead.

Message-Id: <20191120091014.16883-4-thuth@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
4 years agopseries: Update SLOF firmware image
Alexey Kardashevskiy [Tue, 17 Dec 2019 00:31:54 +0000 (11:31 +1100)]
pseries: Update SLOF firmware image

This fixes PCI bridges support regression.

This enables IOMMU support in virtio drivers.

The full list of changes is:

Alexey Kardashevskiy (12):
      allocator: Fix format strings for DEBUG
      virtio: Make virtio_set_qaddr static
      client: Load initramdisk location
      sloffs: Fix -Wunused-result gcc warnings in read/write
      pci-phb: Reimplement dma-map-in/out
      virtio: Store queue descriptors in virtio_device
      virtio-net: Init queues after features negotiation
      virtio: Enable IOMMU
      ibm,client-architecture-support: Fix stack handling
      fdt: Fix updating the tree at H_CAS
      version: update to 20191206
      version: update to 20191217

Michael Roth (1):
      dma: Define default dma methods for using by client/package instances

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4 years agoppc/pnv: Drop PnvChipClass::type
Greg Kurz [Fri, 13 Dec 2019 12:00:41 +0000 (13:00 +0100)]
ppc/pnv: Drop PnvChipClass::type

It isn't used anymore.

Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <157623844102.360005.12070225703151669294.stgit@bahia.lan>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4 years agoppc/pnv: Introduce PnvChipClass::xscom_pcba() method
Greg Kurz [Fri, 13 Dec 2019 12:00:35 +0000 (13:00 +0100)]
ppc/pnv: Introduce PnvChipClass::xscom_pcba() method

The XSCOM bus is implemented with a QOM interface, which is mostly
generic from a CPU type standpoint, except for the computation of
addresses on the Pervasive Connect Bus (PCB) network. This is handled
by the pnv_xscom_pcba() function with a switch statement based on
the chip_type class level attribute of the CPU chip.

This can be achieved using QOM. Also the address argument is masked with
PNV_XSCOM_SIZE - 1, which is for POWER8 only. Addresses may have different
sizes with other CPU types. Have each CPU chip type handle the appropriate
computation with a QOM xscom_pcba() method.

Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <157623843543.360005.13996472463887521794.stgit@bahia.lan>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4 years agoppc/pnv: Drop pnv_chip_is_power9() and pnv_chip_is_power10() helpers
Greg Kurz [Fri, 13 Dec 2019 12:00:29 +0000 (13:00 +0100)]
ppc/pnv: Drop pnv_chip_is_power9() and pnv_chip_is_power10() helpers

They aren't used anymore.

Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <157623842986.360005.1787401623906380181.stgit@bahia.lan>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4 years agoppc/pnv: Pass content of the "compatible" property to pnv_dt_xscom()
Greg Kurz [Fri, 13 Dec 2019 12:00:24 +0000 (13:00 +0100)]
ppc/pnv: Pass content of the "compatible" property to pnv_dt_xscom()

Since pnv_dt_xscom() is called from chip specific dt_populate() hooks,
it shouldn't have to guess the chip type in order to populate the
"compatible" property. Just pass the compat string and its size as
arguments.

Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <157623842430.360005.9513965612524265862.stgit@bahia.lan>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4 years agoppc/pnv: Pass XSCOM base address and address size to pnv_dt_xscom()
Greg Kurz [Fri, 13 Dec 2019 12:00:18 +0000 (13:00 +0100)]
ppc/pnv: Pass XSCOM base address and address size to pnv_dt_xscom()

Since pnv_dt_xscom() is called from chip specific dt_populate() hooks,
it shouldn't have to guess the chip type in order to populate the "reg"
property. Just pass the base address and address size as arguments.

Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <157623841868.360005.17577624823547136435.stgit@bahia.lan>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4 years agoppc/pnv: Introduce PnvChipClass::xscom_core_base() method
Greg Kurz [Fri, 13 Dec 2019 12:00:13 +0000 (13:00 +0100)]
ppc/pnv: Introduce PnvChipClass::xscom_core_base() method

The pnv_chip_core_realize() function configures the XSCOM MMIO subregion
for each core of a single chip. The base address of the subregion depends
on the CPU type. Its computation is currently open-code using the
pnv_chip_is_powerXX() helpers. This can be achieved with QOM. Introduce
a method for this in the base chip class and implement it in child classes.

Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <157623841311.360005.4705705734873339545.stgit@bahia.lan>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4 years agoppc/pnv: Introduce PnvChipClass::intc_print_info() method
Greg Kurz [Fri, 13 Dec 2019 12:00:07 +0000 (13:00 +0100)]
ppc/pnv: Introduce PnvChipClass::intc_print_info() method

The pnv_pic_print_info() callback checks the type of the chip in order
to forward to the request appropriate interrupt controller. This can
be achieved with QOM. Introduce a method for this in the base chip class
and implement it in child classes.

This also prepares ground for the upcoming interrupt controller of POWER10
chips.

Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <157623840755.360005.5002022339473369934.stgit@bahia.lan>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4 years agoppc/pnv: Drop pnv_is_power9() and pnv_is_power10() helpers
Greg Kurz [Fri, 13 Dec 2019 12:00:02 +0000 (13:00 +0100)]
ppc/pnv: Drop pnv_is_power9() and pnv_is_power10() helpers

They aren't used anymore.

Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <157623840200.360005.1300941274565357363.stgit@bahia.lan>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4 years agoppc/pnv: Introduce PnvMachineClass::dt_power_mgt()
Greg Kurz [Fri, 13 Dec 2019 11:59:56 +0000 (12:59 +0100)]
ppc/pnv: Introduce PnvMachineClass::dt_power_mgt()

We add an extra node to advertise power management on some machines,
namely powernv9 and powernv10. This is achieved by using the
pnv_is_power9() and pnv_is_power10() helpers.

This can be achieved with QOM. Add a method to the base class for
powernv machines and have it implemented by machine types that
support power management instead.

Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <157623839642.360005.9243510140436689941.stgit@bahia.lan>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4 years agoppc/pnv: Introduce PnvMachineClass and PnvMachineClass::compat
Greg Kurz [Fri, 13 Dec 2019 11:59:50 +0000 (12:59 +0100)]
ppc/pnv: Introduce PnvMachineClass and PnvMachineClass::compat

The pnv_dt_create() function generates different contents for the
"compatible" property of the root node in the DT, depending on the
CPU type. This is open coded with multiple ifs using pnv_is_powerXX()
helpers.

It seems cleaner to achieve with QOM. Introduce a base class for the
powernv machine and a compat attribute that each child class can use
to provide the value for the "compatible" property.

Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <157623839085.360005.4046508784077843216.stgit@bahia.lan>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
[dwg: Folded in small fix Greg spotted after posting]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4 years agopython/qemu: Remove unneeded imports in __init__
Wainer dos Santos Moschetta [Mon, 16 Dec 2019 19:14:38 +0000 (16:14 -0300)]
python/qemu: Remove unneeded imports in __init__

__init_.py import some sub-modules unnecessarily. So let's
clean it up.

Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
Suggested-by: Cleber Rosa <crosa@redhat.com>
Reviewed-by: Cleber Rosa <crosa@redhat.com>
Tested-by: Cleber Rosa <crosa@redhat.com>
Message-Id: <20191216191438.93418-6-wainersm@redhat.com>
Signed-off-by: Cleber Rosa <crosa@redhat.com>
4 years agoppc/pnv: Drop PnvPsiClass::chip_type
Greg Kurz [Fri, 13 Dec 2019 11:59:45 +0000 (12:59 +0100)]
ppc/pnv: Drop PnvPsiClass::chip_type

It isn't used anymore.

Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <157623838530.360005.15470128760871845396.stgit@bahia.lan>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4 years agoppc/pnv: Introduce PnvPsiClass::compat
Greg Kurz [Fri, 13 Dec 2019 11:59:39 +0000 (12:59 +0100)]
ppc/pnv: Introduce PnvPsiClass::compat

The Processor Service Interface (PSI) model has a chip_type class level
attribute, which is used to generate the content of the "compatible" DT
property according to the CPU type.

Since the PSI model already has specialized classes for each supported
CPU type, it seems cleaner to achieve this with QOM. Provide the content
of the "compatible" property with a new class level attribute.

Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <157623837974.360005.14706607446188964477.stgit@bahia.lan>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4 years agoppc: Drop useless extern annotation for functions
Greg Kurz [Fri, 13 Dec 2019 11:59:34 +0000 (12:59 +0100)]
ppc: Drop useless extern annotation for functions

Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <157623837421.360005.412120366652768311.stgit@bahia.lan>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4 years agoppc/pnv: Fix OCC common area region mapping
Cédric Le Goater [Wed, 11 Dec 2019 08:29:12 +0000 (09:29 +0100)]
ppc/pnv: Fix OCC common area region mapping

The OCC common area is mapped at a unique address on the system and
each OCC is assigned a segment to expose its sensor data :

  -------------------------------------------------------------------------
  | Start (Offset from | End           | Size     |Description            |
  | BAR2 base address) |               |          |                       |
  -------------------------------------------------------------------------
  |    0x00580000      |  0x005A57FF   |150kB     |OCC 0 Sensor Data Block|
  |    0x005A5800      |  0x005CAFFF   |150kB     |OCC 1 Sensor Data Block|
  |        :           |       :       |  :       |            :          |
  |    0x00686800      |  0x006ABFFF   |150kB     |OCC 7 Sensor Data Block|
  |    0x006AC000      |  0x006FFFFF   |336kB     |Reserved               |
  -------------------------------------------------------------------------

Maximum size is 1.5MB.

We could define a "OCC common area" memory region at the machine level
and sub regions for each OCC. But it adds some extra complexity to the
models. Fix the current layout with a simpler model.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20191211082912.2625-3-clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4 years agoppc/pnv: Introduce PBA registers
Cédric Le Goater [Wed, 11 Dec 2019 08:29:11 +0000 (09:29 +0100)]
ppc/pnv: Introduce PBA registers

The PBA bridge unit (Power Bus Access) connects the OCC (On Chip
Controller) to the Power bus and System Memory. The PBA is used to
gather sensor data, for power management, for sleep states, for
initial boot, among other things.

The PBA logic provides a set of four registers PowerBus Access Base
Address Registers (PBABAR0..3) which map the OCC address space to the
PowerBus space. These registers are setup by the initial FW and define
the PowerBus Range of system memory that can be accessed by PBA.

The current modeling of the PBABAR registers is done under the common
XSCOM handlers. We introduce a specific XSCOM regions for these
registers and fix :

 - BAR sizes and BAR masks
 - The mapping of the OCC common area. It is common to all chips and
   should be mapped once.  We will address per-OCC area in the next
   change.
 - OCC common area is in BAR 3 on P8

Inspired by previous work of Balamuruhan S <bala24@linux.ibm.com>

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20191211082912.2625-2-clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4 years agoppc/pnv: Make PnvXScomInterface an incomplete type
Greg Kurz [Wed, 11 Dec 2019 16:04:15 +0000 (17:04 +0100)]
ppc/pnv: Make PnvXScomInterface an incomplete type

PnvXScomInterface is an interface instance. It should never be
dereferenced. Drop the dummy type definition for extra safety,
which is the common practice with QOM interfaces.

While here also convert the bogus OBJECT_CHECK() to INTERFACE_CHECK().

Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <157608025541.186670.1577861507610404326.stgit@bahia.lan>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4 years agoppc/pnv: populate the DT with realized XSCOM devices
Cédric Le Goater [Tue, 10 Dec 2019 13:58:45 +0000 (14:58 +0100)]
ppc/pnv: populate the DT with realized XSCOM devices

Some devices could be initialized in the instance_init handler but not
realized for configuration reasons. Nodes should not be added in the DT
for such devices.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20191210135845.19773-3-clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4 years agoppc/pnv: Loop on the whole hierarchy to populate the DT with the XSCOM nodes
Cédric Le Goater [Tue, 10 Dec 2019 13:58:44 +0000 (14:58 +0100)]
ppc/pnv: Loop on the whole hierarchy to populate the DT with the XSCOM nodes

Some PnvXScomInterface objects lie a bit deeper (PnvPBCQState) than
the first layer, so we need to loop on the whole object hierarchy to
catch them.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20191210135845.19773-2-clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
[dwg: Corrected error in comment]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4 years agotarget/ppc: Add SPR TBU40
Suraj Jitindar Singh [Thu, 28 Nov 2019 13:46:57 +0000 (14:46 +0100)]
target/ppc: Add SPR TBU40

The spr TBU40 is used to set the upper 40 bits of the timebase
register, present on POWER5+ and later processors.

This register can only be written by the hypervisor, and cannot be read.

Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20191128134700.16091-5-clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4 years agotarget/ppc: Add SPR ASDR
Suraj Jitindar Singh [Thu, 28 Nov 2019 13:46:56 +0000 (14:46 +0100)]
target/ppc: Add SPR ASDR

The Access Segment Descriptor Register (ASDR) provides information about
the storage element when taking a hypervisor storage interrupt. When
performing nested radix address translation, this is normally the guest
real address. This register is present on POWER9 processors and later.

Implement the ADSR, note read and write access is limited to the
hypervisor.

Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20191128134700.16091-4-clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4 years agotarget/ppc: Work [S]PURR implementation and add HV support
Suraj Jitindar Singh [Thu, 28 Nov 2019 13:46:55 +0000 (14:46 +0100)]
target/ppc: Work [S]PURR implementation and add HV support

The Processor Utilisation of Resources Register (PURR) and Scaled
Processor Utilisation of Resources Register (SPURR) provide an estimate
of the resources used by the thread, present on POWER7 and later
processors.

Currently the [S]PURR registers simply count at the rate of the
timebase.

Preserve this behaviour but rework the implementation to store an offset
like the timebase rather than doing the calculation manually. Also allow
hypervisor write access to the register along with the currently
available read access.

Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
[ clg: rebased on current ppc tree ]
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20191128134700.16091-3-clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4 years agotarget/ppc: Implement the VTB for HV access
Suraj Jitindar Singh [Thu, 28 Nov 2019 13:46:54 +0000 (14:46 +0100)]
target/ppc: Implement the VTB for HV access

The virtual timebase register (VTB) is a 64-bit register which
increments at the same rate as the timebase register, present on POWER8
and later processors.

The register is able to be read/written by the hypervisor and read by
the supervisor. All other accesses are illegal.

Currently the VTB is just an alias for the timebase (TB) register.

Implement the VTB so that is can be read/written independent of the TB.
Make use of the existing method for accessing timebase facilities where
by the compensation is stored and used to compute the value on reads/is
updated on writes.

Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
[ clg: rebased on current ppc tree ]
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20191128134700.16091-2-clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4 years agoppc/pnv: add a LPC Controller model for POWER10
Cédric Le Goater [Thu, 5 Dec 2019 18:44:54 +0000 (19:44 +0100)]
ppc/pnv: add a LPC Controller model for POWER10

Same a POWER9, only the MMIO window changes.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20191205184454.10722-6-clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>