]> Git Repo - qemu.git/log
qemu.git
5 years agohw/core/qdev: add trace events to help with resettable transition
Damien Hedde [Thu, 30 Jan 2020 16:02:03 +0000 (16:02 +0000)]
hw/core/qdev: add trace events to help with resettable transition

Adds trace events to reset procedure and when updating the parent
bus of a device.

Signed-off-by: Damien Hedde <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Cornelia Huck <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: 20200123132823.1117486[email protected]
Signed-off-by: Peter Maydell <[email protected]>
5 years agoadd device_legacy_reset function to prepare for reset api change
Damien Hedde [Thu, 30 Jan 2020 16:02:03 +0000 (16:02 +0000)]
add device_legacy_reset function to prepare for reset api change

Provide a temporary device_legacy_reset function doing what
device_reset does to prepare for the transition with Resettable
API.

All occurrence of device_reset in the code tree are also replaced
by device_legacy_reset.

The new resettable API has different prototype and semantics
(resetting child buses as well as the specified device). Subsequent
commits will make the changeover for each call site individually; once
that is complete device_legacy_reset() will be removed.

Signed-off-by: Damien Hedde <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Acked-by: David Gibson <[email protected]>
Acked-by: Cornelia Huck <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: 20200123132823.1117486[email protected]
Signed-off-by: Peter Maydell <[email protected]>
5 years agohw/arm/raspi: Remove obsolete use of -smp to set the soc 'enabled-cpus'
Philippe Mathieu-Daudé [Thu, 30 Jan 2020 16:02:03 +0000 (16:02 +0000)]
hw/arm/raspi: Remove obsolete use of -smp to set the soc 'enabled-cpus'

Since we enabled parallel TCG code generation for softmmu (see
commit 3468b59 "tcg: enable multiple TCG contexts in softmmu")
and its subsequent fix (commit 72649619 "add .min_cpus and
.default_cpus fields to machine_class"), the raspi machines are
restricted to always use their 4 cores:

See in hw/arm/raspi2 (with BCM283X_NCPUS set to 4):

  222 static void raspi2_machine_init(MachineClass *mc)
  223 {
  224     mc->desc = "Raspberry Pi 2";
  230     mc->max_cpus = BCM283X_NCPUS;
  231     mc->min_cpus = BCM283X_NCPUS;
  232     mc->default_cpus = BCM283X_NCPUS;
  235 };
  236 DEFINE_MACHINE("raspi2", raspi2_machine_init)

We can no longer use the -smp option, as we get:

  $ qemu-system-arm -M raspi2 -smp 1
  qemu-system-arm: Invalid SMP CPUs 1. The min CPUs supported by machine 'raspi2' is 4

Since we can not set the TYPE_BCM283x SOC "enabled-cpus" with -smp,
remove the unuseful code.

We can achieve the same by using the '-global bcm2836.enabled-cpus=1'
option.

Reported-by: Laurent Bonnans <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-id: 20200120235159[email protected]
Signed-off-by: Peter Maydell <[email protected]>
5 years agomisc/pca9552: Add qom set and get
Joel Stanley [Thu, 30 Jan 2020 16:02:02 +0000 (16:02 +0000)]
misc/pca9552: Add qom set and get

Following the pattern of the work recently done with the ASPEED GPIO
model, this adds support for inspecting and modifying the PCA9552 LEDs
from the monitor.

 (qemu) qom-set  /machine/unattached/device[17] led0 on
 (qemu) qom-set  /machine/unattached/device[17] led0 off
 (qemu) qom-set  /machine/unattached/device[17] led0 pwm0
 (qemu) qom-set  /machine/unattached/device[17] led0 pwm1

Signed-off-by: Joel Stanley <[email protected]>
Signed-off-by: Cédric Le Goater <[email protected]>
Message-id: 20200114103433[email protected]
[clg: - removed the "qom-get" examples from the commit log
      - merged memory leak fixes from Joel ]
Signed-off-by: Cédric Le Goater <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
5 years agohw/arm/aspeed: add a 'execute-in-place' property to boot directly from CE0
Cédric Le Goater [Thu, 30 Jan 2020 16:02:02 +0000 (16:02 +0000)]
hw/arm/aspeed: add a 'execute-in-place' property to boot directly from CE0

The overhead for the OpenBMC firmware images using the a custom U-Boot
is around 2 seconds, which is fine, but with a U-Boot from mainline,
it takes an extra 50 seconds or so to reach Linux. A quick survey on
the number of reads performed on the flash memory region gives the
following figures :

  OpenBMC U-Boot      922478 (~ 3.5 MBytes)
  Mainline U-Boot   20569977 (~ 80  MBytes)

QEMU must be trashing the TCG TBs and reloading text very often. Some
addresses are read more than 250.000 times. Until we find a solution
to improve boot time, execution from MMIO is not activated by default.

Setting this option also breaks migration compatibility.

Signed-off-by: Cédric Le Goater <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: 20200114103433[email protected]
Signed-off-by: Peter Maydell <[email protected]>
5 years agoftgmac100: check RX and TX buffer alignment
Cédric Le Goater [Thu, 30 Jan 2020 16:02:02 +0000 (16:02 +0000)]
ftgmac100: check RX and TX buffer alignment

These buffers should be aligned on 16 bytes.

Ignore invalid RX and TX buffer addresses and log an error. All
incoming and outgoing traffic will be dropped because no valid RX or
TX descriptors will be available.

Signed-off-by: Cédric Le Goater <[email protected]>
Message-id: 20200114103433[email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
5 years agohw/arm: ast2600: Wire up the eMMC controller
Andrew Jeffery [Thu, 30 Jan 2020 16:02:02 +0000 (16:02 +0000)]
hw/arm: ast2600: Wire up the eMMC controller

Initialise another SDHCI model instance for the AST2600's eMMC
controller and use the SDHCI's num_slots value introduced previously to
determine whether we should create an SD card instance for the new slot.

Signed-off-by: Andrew Jeffery <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Cédric Le Goater <[email protected]>
Message-id: 20200114103433[email protected]
[ clg : - removed ternary operator from sdhci_attach_drive()
        - renamed SDHCI objects with a '-controller' prefix ]
Signed-off-by: Cédric Le Goater <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
5 years agohw/sd: Configure number of slots exposed by the ASPEED SDHCI model
Andrew Jeffery [Thu, 30 Jan 2020 16:02:02 +0000 (16:02 +0000)]
hw/sd: Configure number of slots exposed by the ASPEED SDHCI model

The AST2600 includes a second cut-down version of the SD/MMC controller
found in the AST2500, named the eMMC controller. It's cut down in the
sense that it only supports one slot rather than two, but it brings the
total number of slots supported by the AST2600 to three.

The existing code assumed that the SD controller always provided two
slots. Rework the SDHCI object to expose the number of slots as a
property to be set by the SoC configuration.

Signed-off-by: Andrew Jeffery <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Signed-off-by: Cédric Le Goater <[email protected]>
Message-id: 20200114103433[email protected]
[PMM: fixed up to use device_class_set_props()]
Signed-off-by: Peter Maydell <[email protected]>
5 years agotarget/arm/arm-semi: Don't let the guest close stdin/stdout/stderr
Peter Maydell [Thu, 30 Jan 2020 16:02:01 +0000 (16:02 +0000)]
target/arm/arm-semi: Don't let the guest close stdin/stdout/stderr

The guest can use the semihosting API to open a handle
corresponding to QEMU's own stdin, stdout, or stderr.
When the guest closes this handle, we should not
close the underlying host stdin/stdout/stderr
the way we would do if the handle corresponded to
a host fd we'd opened on behalf of the guest in SYS_OPEN.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: 20200124172954[email protected]

5 years agohw/core/or-irq: Fix incorrect assert forbidding num-lines == MAX_OR_LINES
Peter Maydell [Thu, 30 Jan 2020 16:02:01 +0000 (16:02 +0000)]
hw/core/or-irq: Fix incorrect assert forbidding num-lines == MAX_OR_LINES

The num-lines property of the TYPE_OR_GATE device sets the number
of input lines it has. An assert() in or_irq_realize() restricts
this to the maximum supported by the implementation. However we
got the condition in the assert wrong: it should be using <=,
because num-lines == MAX_OR_LINES is permitted, and means that
all entries from 0 to MAX_OR_LINES-1 in the s->levels[] array
are used.

We didn't notice this previously because no user has so far
needed that many input lines.

Reported-by: Guenter Roeck <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Guenter Roeck <[email protected]>
Message-id: 20200120142235[email protected]

5 years agoMerge remote-tracking branch 'remotes/amarkovic/tags/mips-queue-jan-29-2020' into...
Peter Maydell [Thu, 30 Jan 2020 14:18:45 +0000 (14:18 +0000)]
Merge remote-tracking branch 'remotes/amarkovic/tags/mips-queue-jan-29-2020' into staging

MIPS queue for January 29th, 2020

# gpg: Signature made Wed 29 Jan 2020 18:29:43 GMT
# gpg:                using RSA key D4972A8967F75A65
# gpg: Good signature from "Aleksandar Markovic <[email protected]>" [full]
# Primary key fingerprint: 8526 FBF1 5DA3 811F 4A01  DD75 D497 2A89 67F7 5A65

* remotes/amarkovic/tags/mips-queue-jan-29-2020:
  target/mips: Add implementation of GINVT instruction
  target/mips: Amend CP0 WatchHi register implementation
  hw/core/loader: Let load_elf() populate a field with CPU-specific flags
  target/mips: semihosting: Remove 'uhi_done' label in helper_do_semihosting()
  disas: Add a field for target-dependant data to disassemble_info
  target/mips: Rectify documentation on deprecating MIPS r4k machine

Signed-off-by: Peter Maydell <[email protected]>
5 years agoMerge remote-tracking branch 'remotes/stefanberger/tags/pull-tpm-2020-01-29-1' into...
Peter Maydell [Thu, 30 Jan 2020 13:12:39 +0000 (13:12 +0000)]
Merge remote-tracking branch 'remotes/stefanberger/tags/pull-tpm-2020-01-29-1' into staging

Merge tpm 2020/01/29 v1

# gpg: Signature made Wed 29 Jan 2020 13:01:37 GMT
# gpg:                using RSA key B818B9CADF9089C2D5CEC66B75AD65802A0B4211
# gpg: Good signature from "Stefan Berger <[email protected]>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: B818 B9CA DF90 89C2 D5CE  C66B 75AD 6580 2A0B 4211

* remotes/stefanberger/tags/pull-tpm-2020-01-29-1:
  tpm-ppi: page-align PPI RAM

Signed-off-by: Peter Maydell <[email protected]>
5 years agoMerge remote-tracking branch 'remotes/juanquintela/tags/pull-migration-pull-request...
Peter Maydell [Thu, 30 Jan 2020 11:43:21 +0000 (11:43 +0000)]
Merge remote-tracking branch 'remotes/juanquintela/tags/pull-migration-pull-request' into staging

Migration pull request

# gpg: Signature made Wed 29 Jan 2020 10:57:23 GMT
# gpg:                using RSA key 1899FF8EDEBF58CCEE034B82F487EF185872D723
# gpg: Good signature from "Juan Quintela <[email protected]>" [full]
# gpg:                 aka "Juan Quintela <[email protected]>" [full]
# Primary key fingerprint: 1899 FF8E DEBF 58CC EE03  4B82 F487 EF18 5872 D723

* remotes/juanquintela/tags/pull-migration-pull-request:
  migration/compress: compress QEMUFile is not writable
  migration: Simplify get_qlist
  multifd: Split multifd code into its own file
  multifd: Make multifd_load_setup() get an Error parameter
  multifd: Make multifd_save_setup() get an Error parameter
  migration: Make checkpatch happy with comments
  multifd: Use qemu_target_page_size()
  multifd: multifd_send_sync_main only needs the qemufile
  multifd: multifd_queue_page only needs the qemufile
  multifd: multifd_send_pages only needs the qemufile
  ram_addr: Split RAMBlock definition
  migration/multifd: fix nullptr access in multifd_send_terminate_threads
  migration: Create migration_is_running()
  migration-test: Make sure that multifd and cancel works
  migration: Don't send data if we have stopped
  qemu-file: Don't do IO after shutdown
  multifd: Make sure that we don't do any IO after an error
  migration-test: Use g_free() instead of free()

Signed-off-by: Peter Maydell <[email protected]>
5 years agotarget/mips: Add implementation of GINVT instruction
Yongbok Kim [Fri, 20 Dec 2019 09:29:34 +0000 (10:29 +0100)]
target/mips: Add implementation of GINVT instruction

Implement emulation of GINVT instruction. As QEMU doesn't support
caches and virtualization, this implementation covers only one
instruction (GINVT - Global Invalidate TLB) among all TLB-related
MIPS instructions.

Reviewed-by: Aleksandar Rikalo <[email protected]>
Signed-off-by: Yongbok Kim <[email protected]>
Signed-off-by: Aleksandar Markovic <[email protected]>
Message-Id: <1579883929[email protected]>

5 years agotarget/mips: Amend CP0 WatchHi register implementation
Yongbok Kim [Fri, 20 Dec 2019 09:34:09 +0000 (10:34 +0100)]
target/mips: Amend CP0 WatchHi register implementation

WatchHi is extended by the field MemoryMapID with the GINVT instruction.
The field is accessible by MTHC0/MFHC0 in 32-bit architectures and DMTC0/
DMFC0 in 64-bit architectures.

Reviewed-by: Aleksandar Rikalo <[email protected]>
Signed-off-by: Yongbok Kim <[email protected]>
Signed-off-by: Aleksandar Markovic <[email protected]>
Message-Id: <1579883929[email protected]>

5 years agohw/core/loader: Let load_elf() populate a field with CPU-specific flags
Aleksandar Markovic [Sun, 26 Jan 2020 22:55:04 +0000 (23:55 +0100)]
hw/core/loader: Let load_elf() populate a field with CPU-specific flags

While loading the executable, some platforms (like AVR) need to
detect CPU type that executable is built for - and, with this patch,
this is enabled by reading the field 'e_flags' of the ELF header of
the executable in question. The change expands functionality of
the following functions:

  - load_elf()
  - load_elf_as()
  - load_elf_ram()
  - load_elf_ram_sym()

The argument added to these functions is called 'pflags' and is of
type 'uint32_t*' (that matches 'pointer to 'elf_word'', 'elf_word'
being the type of the field 'e_flags', in both 32-bit and 64-bit
variants of ELF header). Callers are allowed to pass NULL as that
argument, and in such case no lookup to the field 'e_flags' will
happen, and no information will be returned, of course.

CC: Richard Henderson <[email protected]>
CC: Peter Maydell <[email protected]>
CC: Edgar E. Iglesias <[email protected]>
CC: Michael Walle <[email protected]>
CC: Thomas Huth <[email protected]>
CC: Laurent Vivier <[email protected]>
CC: Philippe Mathieu-Daudé <[email protected]>
CC: Aleksandar Rikalo <[email protected]>
CC: Aurelien Jarno <[email protected]>
CC: Jia Liu <[email protected]>
CC: David Gibson <[email protected]>
CC: Mark Cave-Ayland <[email protected]>
CC: BALATON Zoltan <[email protected]>
CC: Christian Borntraeger <[email protected]>
CC: Thomas Huth <[email protected]>
CC: Artyom Tarasenko <[email protected]>
CC: Fabien Chouteau <[email protected]>
CC: KONRAD Frederic <[email protected]>
CC: Max Filippov <[email protected]>
Reviewed-by: Aleksandar Rikalo <[email protected]>
Signed-off-by: Michael Rolnik <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Aleksandar Markovic <[email protected]>
Message-Id: <1580079311[email protected]>

5 years agotarget/mips: semihosting: Remove 'uhi_done' label in helper_do_semihosting()
Daniel Henrique Barboza [Mon, 6 Jan 2020 18:23:32 +0000 (15:23 -0300)]
target/mips: semihosting: Remove 'uhi_done' label in helper_do_semihosting()

The label 'uhi_done' is a simple 'return' call and can
be removed for a bit more clarity in the code.

CC: Aurelien Jarno <[email protected]>
CC: Aleksandar Markovic <[email protected]>
CC: Aleksandar Rikalo <[email protected]>
Reviewed-by: Aleksandar Markovic <[email protected]>
Signed-off-by: Aleksandar Markovic <[email protected]>
Signed-off-by: Daniel Henrique Barboza <[email protected]>
Message-Id: <20200106182425[email protected]>

5 years agodisas: Add a field for target-dependant data to disassemble_info
Aleksandar Markovic [Fri, 24 Jan 2020 16:38:47 +0000 (17:38 +0100)]
disas: Add a field for target-dependant data to disassemble_info

This patch adds a field "target_info" to the structure
disassemble_info. The purpose of this field is to enable targets
to pass to disassembler code any additional data thet deem suitable.

Reviewed-by: Aleksandar Rikalo <[email protected]>
Signed-off-by: Aleksandar Markovic <[email protected]>
Message-Id: <1579883929[email protected]>

5 years agotarget/mips: Rectify documentation on deprecating MIPS r4k machine
Aleksandar Markovic [Fri, 24 Jan 2020 16:38:43 +0000 (17:38 +0100)]
target/mips: Rectify documentation on deprecating MIPS r4k machine

Correct file qemu-deprecated.texi with respect to the release since
MIPS r4k machine is deprecated from 4.2 to 5.0.

Fixes: d32dc61421b
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Aleksandar Markovic <[email protected]>
Message-Id: <1579883929[email protected]>

5 years agotpm-ppi: page-align PPI RAM
Marc-André Lureau [Fri, 3 Jan 2020 07:39:59 +0000 (11:39 +0400)]
tpm-ppi: page-align PPI RAM

post-copy migration fails on destination with error such as:
2019-12-26T10:22:44.714644Z qemu-kvm: ram_block_discard_range:
Unaligned start address: 0x559d2afae9a0

Use qemu_memalign() to constrain the PPI RAM memory alignment.

Cc: [email protected]
Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
Reviewed-by: Stefan Berger <[email protected]>
Signed-off-by: Stefan Berger <[email protected]>
Message-id: 20200103074000.1006389[email protected]

5 years agomigration/compress: compress QEMUFile is not writable
Wei Yang [Sat, 12 Oct 2019 02:39:31 +0000 (10:39 +0800)]
migration/compress: compress QEMUFile is not writable

We open a file with empty_ops for compress QEMUFile, which means this is
not writable.

Signed-off-by: Wei Yang <[email protected]>
Reviewed-by: Juan Quintela <[email protected]>
Signed-off-by: Juan Quintela <[email protected]>
5 years agomigration: Simplify get_qlist
Eric Auger [Sat, 25 Jan 2020 17:24:49 +0000 (18:24 +0100)]
migration: Simplify get_qlist

Instead of inserting read elements at the head and
then reversing the list, it is simpler to add
each element after the previous one. Introduce
QLIST_RAW_INSERT_AFTER helper and use it in
get_qlist().

Signed-off-by: Eric Auger <[email protected]>
Suggested-by: Juan Quintela <[email protected]>
Reviewed-by: Juan Quintela <[email protected]>
Signed-off-by: Juan Quintela <[email protected]>
5 years agomultifd: Split multifd code into its own file
Juan Quintela [Wed, 22 Jan 2020 15:16:07 +0000 (16:16 +0100)]
multifd: Split multifd code into its own file

Signed-off-by: Juan Quintela <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
5 years agomultifd: Make multifd_load_setup() get an Error parameter
Juan Quintela [Wed, 12 Jun 2019 09:44:19 +0000 (11:44 +0200)]
multifd: Make multifd_load_setup() get an Error parameter

We need to change the full chain to pass the Error parameter.

Signed-off-by: Juan Quintela <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
5 years agomultifd: Make multifd_save_setup() get an Error parameter
Juan Quintela [Wed, 12 Jun 2019 09:33:27 +0000 (11:33 +0200)]
multifd: Make multifd_save_setup() get an Error parameter

Signed-off-by: Juan Quintela <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
5 years agomigration: Make checkpatch happy with comments
Juan Quintela [Wed, 22 Jan 2020 18:12:28 +0000 (19:12 +0100)]
migration: Make checkpatch happy with comments

Signed-off-by: Juan Quintela <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
5 years agomultifd: Use qemu_target_page_size()
Juan Quintela [Wed, 22 Jan 2020 16:46:30 +0000 (17:46 +0100)]
multifd: Use qemu_target_page_size()

We will make it cpu independent.

Signed-off-by: Juan Quintela <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
5 years agomultifd: multifd_send_sync_main only needs the qemufile
Juan Quintela [Wed, 22 Jan 2020 15:04:53 +0000 (16:04 +0100)]
multifd: multifd_send_sync_main only needs the qemufile

Signed-off-by: Juan Quintela <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
5 years agomultifd: multifd_queue_page only needs the qemufile
Juan Quintela [Wed, 22 Jan 2020 15:03:01 +0000 (16:03 +0100)]
multifd: multifd_queue_page only needs the qemufile

Signed-off-by: Juan Quintela <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
5 years agomultifd: multifd_send_pages only needs the qemufile
Juan Quintela [Wed, 22 Jan 2020 15:01:09 +0000 (16:01 +0100)]
multifd: multifd_send_pages only needs the qemufile

Signed-off-by: Juan Quintela <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
5 years agoram_addr: Split RAMBlock definition
Juan Quintela [Wed, 22 Jan 2020 14:58:57 +0000 (15:58 +0100)]
ram_addr: Split RAMBlock definition

We need some of the fields without having to poison everything else.

Signed-off-by: Juan Quintela <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
5 years agomigration/multifd: fix nullptr access in multifd_send_terminate_threads
Zhimin Feng [Fri, 10 Jan 2020 08:50:19 +0000 (16:50 +0800)]
migration/multifd: fix nullptr access in multifd_send_terminate_threads

If the multifd_send_threads is not created when migration is failed,
multifd_save_cleanup would be called twice. In this senario, the
multifd_send_state is accessed after it has been released, the result
is that the source VM is crashing down.

Here is the coredump stack:
    Program received signal SIGSEGV, Segmentation fault.
    0x00005629333a78ef in multifd_send_terminate_threads (err=err@entry=0x0) at migration/ram.c:1012
    1012            MultiFDSendParams *p = &multifd_send_state->params[i];
    #0  0x00005629333a78ef in multifd_send_terminate_threads (err=err@entry=0x0) at migration/ram.c:1012
    #1  0x00005629333ab8a9 in multifd_save_cleanup () at migration/ram.c:1028
    #2  0x00005629333abaea in multifd_new_send_channel_async (task=0x562935450e70, opaque=<optimized out>) at migration/ram.c:1202
    #3  0x000056293373a562 in qio_task_complete (task=task@entry=0x562935450e70) at io/task.c:196
    #4  0x000056293373a6e0 in qio_task_thread_result (opaque=0x562935450e70) at io/task.c:111
    #5  0x00007f475d4d75a7 in g_idle_dispatch () from /usr/lib64/libglib-2.0.so.0
    #6  0x00007f475d4da9a9 in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
    #7  0x0000562933785b33 in glib_pollfds_poll () at util/main-loop.c:219
    #8  os_host_main_loop_wait (timeout=<optimized out>) at util/main-loop.c:242
    #9  main_loop_wait (nonblocking=nonblocking@entry=0) at util/main-loop.c:518
    #10 0x00005629334c5acf in main_loop () at vl.c:1810
    #11 0x000056293334d7bb in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:4471

If the multifd_send_threads is not created when migration is failed.
In this senario, we don't call multifd_save_cleanup in multifd_new_send_channel_async.

Signed-off-by: Zhimin Feng <[email protected]>
Reviewed-by: Juan Quintela <[email protected]>
Signed-off-by: Juan Quintela <[email protected]>
5 years agomigration: Create migration_is_running()
Juan Quintela [Tue, 21 Jan 2020 14:39:23 +0000 (15:39 +0100)]
migration: Create migration_is_running()

This function returns true if we are in the middle of a migration.
It is like migration_is_setup_or_active() with CANCELLING and COLO.
Adapt all callers that are needed.

Signed-off-by: Juan Quintela <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
5 years agomigration-test: Make sure that multifd and cancel works
Juan Quintela [Wed, 18 Dec 2019 04:13:40 +0000 (05:13 +0100)]
migration-test: Make sure that multifd and cancel works

Test that this sequence works:

- launch source
- launch target
- start migration
- cancel migration
- relaunch target
- do migration again

Signed-off-by: Juan Quintela <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
5 years agomigration: Don't send data if we have stopped
Juan Quintela [Wed, 22 Jan 2020 10:36:12 +0000 (11:36 +0100)]
migration: Don't send data if we have stopped

If we do a cancel, we got out without one error, but we can't do the
rest of the output as in a normal situation.

Signed-off-by: Juan Quintela <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
5 years agoqemu-file: Don't do IO after shutdown
Juan Quintela [Wed, 18 Dec 2019 04:11:31 +0000 (05:11 +0100)]
qemu-file: Don't do IO after shutdown

Be sure that we are not doing neither read/write after shutdown of the
QEMUFile.

Signed-off-by: Juan Quintela <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
5 years agomultifd: Make sure that we don't do any IO after an error
Juan Quintela [Wed, 18 Dec 2019 04:12:36 +0000 (05:12 +0100)]
multifd: Make sure that we don't do any IO after an error

Signed-off-by: Juan Quintela <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
5 years agomigration-test: Use g_free() instead of free()
Juan Quintela [Mon, 20 Jan 2020 14:52:52 +0000 (15:52 +0100)]
migration-test: Use g_free() instead of free()

Signed-off-by: Juan Quintela <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
5 years agoMerge remote-tracking branch 'remotes/jnsnow/tags/ide-pull-request' into staging
Peter Maydell [Tue, 28 Jan 2020 17:09:36 +0000 (17:09 +0000)]
Merge remote-tracking branch 'remotes/jnsnow/tags/ide-pull-request' into staging

Pull request

# gpg: Signature made Tue 28 Jan 2020 01:05:19 GMT
# gpg:                using RSA key F9B7ABDBBCACDF95BE76CBD07DEF8106AAFC390E
# gpg: Good signature from "John Snow (John Huston) <[email protected]>" [full]
# Primary key fingerprint: FAEB 9711 A12C F475 812F  18F2 88A9 064D 1835 61EB
#      Subkey fingerprint: F9B7 ABDB BCAC DF95 BE76  CBD0 7DEF 8106 AAFC 390E

* remotes/jnsnow/tags/ide-pull-request:
  tests/ide-test: Create a single unit-test covering more PRDT cases
  ide: Fix incorrect handling of some PRDTs in ide_dma_cb()

Signed-off-by: Peter Maydell <[email protected]>
5 years agoMerge remote-tracking branch 'remotes/rth/tags/pull-pa-20200127' into staging
Peter Maydell [Tue, 28 Jan 2020 15:11:04 +0000 (15:11 +0000)]
Merge remote-tracking branch 'remotes/rth/tags/pull-pa-20200127' into staging

Improve LASI emulation
Add Artist graphics
Fix main memory allocation
Improve LDCW emulation wrt real hw

# gpg: Signature made Mon 27 Jan 2020 18:53:35 GMT
# gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Richard Henderson <[email protected]>" [full]
# Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A  05C0 64DF 38E8 AF7E 215F

* remotes/rth/tags/pull-pa-20200127:
  target/hppa: Allow, but diagnose, LDCW aligned only mod 4
  hw/hppa/machine: Map the PDC memory region with higher priority
  hw/hppa/machine: Restrict the total memory size to 3GB
  hw/hppa/machine: Correctly check the firmware is in PDC range
  hppa: Add emulation of Artist graphics
  seabios-hppa: update to latest version
  hppa: Switch to tulip NIC by default
  hppa: add emulation of LASI PS2 controllers
  ps2: accept 'Set Key Make and Break' commands
  hppa: Add support for LASI chip with i82596 NIC
  hw/hppa/dino.c: Improve emulation of Dino PCI chip

Signed-off-by: Peter Maydell <[email protected]>
5 years agotests/ide-test: Create a single unit-test covering more PRDT cases
Alexander Popov [Mon, 23 Dec 2019 17:51:17 +0000 (20:51 +0300)]
tests/ide-test: Create a single unit-test covering more PRDT cases

Fuzzing the Linux kernel with syzkaller allowed to find how to crash qemu
using a special SCSI_IOCTL_SEND_COMMAND. It hits the assertion in
ide_dma_cb() introduced in the commit a718978ed58a in July 2015.
Currently this bug is not reproduced by the unit tests.

Let's improve the ide-test to cover more PRDT cases including one
that causes this particular qemu crash.

The test is developed according to the Programming Interface for
Bus Master IDE Controller (Revision 1.0 5/16/94).

Signed-off-by: Alexander Popov <[email protected]>
Message-id: 20191223175117[email protected]
Signed-off-by: John Snow <[email protected]>
5 years agoide: Fix incorrect handling of some PRDTs in ide_dma_cb()
Alexander Popov [Mon, 23 Dec 2019 17:51:16 +0000 (20:51 +0300)]
ide: Fix incorrect handling of some PRDTs in ide_dma_cb()

The commit a718978ed58a from July 2015 introduced the assertion which
implies that the size of successful DMA transfers handled in ide_dma_cb()
should be multiple of 512 (the size of a sector). But guest systems can
initiate DMA transfers that don't fit this requirement.

For fixing that let's check the number of bytes prepared for the transfer
by the prepare_buf() handler. The code in ide_dma_cb() must behave
according to the Programming Interface for Bus Master IDE Controller
(Revision 1.0 5/16/94):
1. If PRDs specified a smaller size than the IDE transfer
   size, then the Interrupt and Active bits in the Controller
   status register are not set (Error Condition).
2. If the size of the physical memory regions was equal to
   the IDE device transfer size, the Interrupt bit in the
   Controller status register is set to 1, Active bit is set to 0.
3. If PRDs specified a larger size than the IDE transfer size,
   the Interrupt and Active bits in the Controller status register
   are both set to 1.

Signed-off-by: Alexander Popov <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Message-id: 20191223175117[email protected]
Signed-off-by: John Snow <[email protected]>
5 years agotarget/hppa: Allow, but diagnose, LDCW aligned only mod 4
Richard Henderson [Fri, 17 Jan 2020 01:46:38 +0000 (15:46 -1000)]
target/hppa: Allow, but diagnose, LDCW aligned only mod 4

The PA-RISC 1.1 specification says that LDCW must be aligned mod 16
or the operation is undefined.  However, real hardware only generates
an unaligned access trap for unaligned mod 4.

Match real hardware, but diagnose with GUEST_ERROR a violation of
the specification.

At the same time fix a bug in the initialization of mop, where the
size was specified twice, and another to free the zero temporary.

Tested-by: Helge Deller <[email protected]>
Reported-by: Helge Deller <[email protected]>
Suggested-by: John David Anglin <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
5 years agohw/hppa/machine: Map the PDC memory region with higher priority
Philippe Mathieu-Daudé [Thu, 9 Jan 2020 00:05:25 +0000 (01:05 +0100)]
hw/hppa/machine: Map the PDC memory region with higher priority

The region in range [0xf0000000 - 0xf1000000] is the PDC area
(Processor Dependent Code), where the firmware is loaded.
This region has higher priority than the main memory.

When the machine has more than 3840MB of RAM, there is an
overlap. Since the PDC is closer to the CPU in the bus
hierarchy, it gets accessed first, and the CPU does not have
access to the RAM in this range.

To model the same behavior and keep a simple memory layout,
reduce the priority of the RAM region. The PDC region ends
overlapping the RAM.

Acked-by: Helge Deller <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <20200109000525[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
5 years agohw/hppa/machine: Restrict the total memory size to 3GB
Philippe Mathieu-Daudé [Thu, 9 Jan 2020 00:05:24 +0000 (01:05 +0100)]
hw/hppa/machine: Restrict the total memory size to 3GB

The hardware expects DIMM slots of 1 or 2 GB, allowing up to
4 GB of memory. We want to accept the same amount of memory the
hardware can deal with. DIMMs of 768MB are not available.

However we have to deal with a firmware limitation: currently
SeaBIOS only supports 32-bit, and expects the RAM size in a
32-bit register. When using a 4GB configuration, the 32-bit
register get truncated and we report a size of 0MB to SeaBIOS,
which ends halting the machine:

  $ qemu-system-hppa -m 4g -serial stdio

  SeaBIOS: Machine configured with too little memory (0 MB), minimum is 16 MB.

  SeaBIOS wants SYSTEM HALT.

The easiest way is to restrict the machine to 3GB of memory.

Acked-by: Helge Deller <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <20200109000525[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
5 years agohw/hppa/machine: Correctly check the firmware is in PDC range
Philippe Mathieu-Daudé [Thu, 9 Jan 2020 00:05:23 +0000 (01:05 +0100)]
hw/hppa/machine: Correctly check the firmware is in PDC range

The firmware has to reside in the PDC range. If the Elf file
expects to load it below FIRMWARE_START, it is incorrect,
regardless the RAM size.

Acked-by: Helge Deller <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <20200109000525[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
5 years agohppa: Add emulation of Artist graphics
Sven Schnelle [Fri, 20 Dec 2019 21:15:11 +0000 (22:15 +0100)]
hppa: Add emulation of Artist graphics

This adds emulation of Artist graphics good enough to get a text
console on both Linux and HP-UX. The X11 server from HP-UX also works.

Adjust boot-serial-test to disable graphics, so that SeaBIOS outputs
to the serial port, as expected by the test.

Signed-off-by: Sven Schnelle <[email protected]>
Message-Id: <20191220211512[email protected]>
[rth: Merge Helge's test for machine->enable_graphics]
Signed-off-by: Richard Henderson <[email protected]>
5 years agoseabios-hppa: update to latest version
Sven Schnelle [Fri, 20 Dec 2019 21:15:12 +0000 (22:15 +0100)]
seabios-hppa: update to latest version

Helge Deller (13):
      Add PDC_MEM_MAP and ENTRY_INIT_SRCH_FRST for OSF/MkLinux
      Return non-existant BTLB for PDC_BLOCK_TLB
      Add serial, parallel and LAN port support of  LASI chip
      Implement ENTRY_IO_BBLOCK_IN IODC function
      Do not print \r on parisc SeaBIOS
      Fix serial ports and add PDC_MODEL functions for special instructions enablement
      Implement SeaBIOS returning additional addresses. Fixes HP-UX boot.
      Fix mod_pgs (number of pages) for graphic cards
      Merge pull request #3 from svenschnelle/sti
      Merge pull request #4 from svenschnelle/parisc-qemu-4.1.0
      parisc: Implement PDC rendenzvous
      parisc: Improve soft power button emulation
      parisc: Fix line wrapping in STI console code

Sven Schnelle (7):
      parisc: fix PDC info for graphics adapter
      parisc: add missing header guard to hppa.h
      parisc: add LASI PS/2 emulation.
      parisc: Add STI support
      parisc: wire up graphics console
      parisc: Add support for setting STI screen resolution
      parisc: support LASI RTC register

Required for STI and LASI support. Also adds a few Bugfixes.

Signed-off-by: Sven Schnelle <[email protected]>
Message-Id: <20191220211512[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
5 years agohppa: Switch to tulip NIC by default
Helge Deller [Sat, 21 Dec 2019 22:25:30 +0000 (23:25 +0100)]
hppa: Switch to tulip NIC by default

Most HP PA-RISC machines have a Digital DS21142/43 Tulip network card,
only some very latest generation machines have an e1000 NIC.
Since qemu now provides an emulated tulip card, use that one instead.

Signed-off-by: Helge Deller <[email protected]>
Message-Id: <20191221222530[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
5 years agohppa: add emulation of LASI PS2 controllers
Sven Schnelle [Fri, 20 Dec 2019 21:15:10 +0000 (22:15 +0100)]
hppa: add emulation of LASI PS2 controllers

Signed-off-by: Sven Schnelle <[email protected]>
Message-Id: <20191220211512[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
5 years agops2: accept 'Set Key Make and Break' commands
Sven Schnelle [Fri, 20 Dec 2019 21:15:09 +0000 (22:15 +0100)]
ps2: accept 'Set Key Make and Break' commands

HP-UX sends both the 'Set key make and break (0xfc) and
'Set all key typematic make and break' (0xfa). QEMU response
with 'Resend' as it doesn't handle these commands. HP-UX than
reports an PS/2 max retransmission exceeded error. Add these
commands and just reply with ACK.

Signed-off-by: Sven Schnelle <[email protected]>
Message-Id: <20191220211512[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
5 years agohppa: Add support for LASI chip with i82596 NIC
Helge Deller [Fri, 20 Dec 2019 21:15:08 +0000 (22:15 +0100)]
hppa: Add support for LASI chip with i82596 NIC

LASI is a built-in multi-I/O chip which supports serial, parallel,
network (Intel i82596 Apricot), sound and other functionalities.
LASI has been used in many HP PARISC machines.
This patch adds the necessary parts to allow Linux and HP-UX to detect
LASI and the network card.

Signed-off-by: Helge Deller <[email protected]>
Signed-off-by: Sven Schnelle <[email protected]>
Message-Id: <20191220211512[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
5 years agoMerge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Peter Maydell [Mon, 27 Jan 2020 18:07:18 +0000 (18:07 +0000)]
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging

Block layer patches:

- iscsi: Cap block count from GET LBA STATUS (CVE-2020-1711)
- AioContext fixes in QMP commands for backup and bitmaps
- iotests fixes

# gpg: Signature made Mon 27 Jan 2020 17:49:58 GMT
# gpg:                using RSA key 7F09B272C88F2FD6
# gpg: Good signature from "Kevin Wolf <[email protected]>" [full]
# Primary key fingerprint: DC3D EB15 9A9A F95D 3D74  56FE 7F09 B272 C88F 2FD6

* remotes/kevin/tags/for-upstream:
  iscsi: Don't access non-existent scsi_lba_status_descriptor
  iscsi: Cap block count from GET LBA STATUS (CVE-2020-1711)
  block/backup: fix memory leak in bdrv_backup_top_append()
  iotests: Test handling of AioContexts with some blockdev actions
  blockdev: Return bs to the proper context on snapshot abort
  blockdev: Acquire AioContext on dirty bitmap functions
  block/backup-top: Don't acquire context while dropping top
  blockdev: honor bdrv_try_set_aio_context() context requirements
  blockdev: unify qmp_blockdev_backup and blockdev-backup transaction paths
  blockdev: unify qmp_drive_backup and drive-backup transaction paths
  blockdev: fix coding style issues in drive_backup_prepare
  iotests: Add more "skip_if_unsupported" statements to the python tests
  iotests.py: Let wait_migration wait even more

Signed-off-by: Peter Maydell <[email protected]>
5 years agohw/hppa/dino.c: Improve emulation of Dino PCI chip
Helge Deller [Fri, 20 Dec 2019 21:15:07 +0000 (22:15 +0100)]
hw/hppa/dino.c: Improve emulation of Dino PCI chip

The tests of the dino chip with the Online-diagnostics CD
("ODE DINOTEST") now succeeds.
Additionally add some qemu trace events.

Signed-off-by: Helge Deller <[email protected]>
Signed-off-by: Sven Schnelle <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <20191220211512[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
5 years agoiscsi: Don't access non-existent scsi_lba_status_descriptor
Kevin Wolf [Thu, 23 Jan 2020 17:00:54 +0000 (18:00 +0100)]
iscsi: Don't access non-existent scsi_lba_status_descriptor

In iscsi_co_block_status(), we may have received num_descriptors == 0
from the iscsi server. Therefore, we can't unconditionally access
lbas->descriptors[0]. Add the missing check.

Signed-off-by: Kevin Wolf <[email protected]>
Reviewed-by: Felipe Franciosi <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: John Snow <[email protected]>
Reviewed-by: Peter Lieven <[email protected]>
5 years agoiscsi: Cap block count from GET LBA STATUS (CVE-2020-1711)
Felipe Franciosi [Thu, 23 Jan 2020 12:44:59 +0000 (12:44 +0000)]
iscsi: Cap block count from GET LBA STATUS (CVE-2020-1711)

When querying an iSCSI server for the provisioning status of blocks (via
GET LBA STATUS), Qemu only validates that the response descriptor zero's
LBA matches the one requested. Given the SCSI spec allows servers to
respond with the status of blocks beyond the end of the LUN, Qemu may
have its heap corrupted by clearing/setting too many bits at the end of
its allocmap for the LUN.

A malicious guest in control of the iSCSI server could carefully program
Qemu's heap (by selectively setting the bitmap) and then smash it.

This limits the number of bits that iscsi_co_block_status() will try to
update in the allocmap so it can't overflow the bitmap.

Fixes: CVE-2020-1711
Cc: [email protected]
Signed-off-by: Felipe Franciosi <[email protected]>
Signed-off-by: Peter Turschmid <[email protected]>
Signed-off-by: Raphael Norwitz <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
5 years agoblock/backup: fix memory leak in bdrv_backup_top_append()
Eiichi Tsukata [Mon, 23 Dec 2019 09:06:32 +0000 (18:06 +0900)]
block/backup: fix memory leak in bdrv_backup_top_append()

bdrv_open_driver() allocates bs->opaque according to drv->instance_size.
There is no need to allocate it and overwrite opaque in
bdrv_backup_top_append().

Reproducer:

  $ QTEST_QEMU_BINARY=./x86_64-softmmu/qemu-system-x86_64 valgrind -q --leak-check=full tests/test-replication -p /replication/secondary/start
  ==29792== 24 bytes in 1 blocks are definitely lost in loss record 52 of 226
  ==29792==    at 0x483AB1A: calloc (vg_replace_malloc.c:762)
  ==29792==    by 0x4B07CE0: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.6000.7)
  ==29792==    by 0x12BAB9: bdrv_open_driver (block.c:1289)
  ==29792==    by 0x12BEA9: bdrv_new_open_driver (block.c:1359)
  ==29792==    by 0x1D15CB: bdrv_backup_top_append (backup-top.c:190)
  ==29792==    by 0x1CC11A: backup_job_create (backup.c:439)
  ==29792==    by 0x1CD542: replication_start (replication.c:544)
  ==29792==    by 0x1401B9: replication_start_all (replication.c:52)
  ==29792==    by 0x128B50: test_secondary_start (test-replication.c:427)
  ...

Fixes: 7df7868b9640 ("block: introduce backup-top filter driver")
Signed-off-by: Eiichi Tsukata <[email protected]>
Reviewed-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
5 years agoiotests: Test handling of AioContexts with some blockdev actions
Sergio Lopez [Wed, 8 Jan 2020 14:31:38 +0000 (15:31 +0100)]
iotests: Test handling of AioContexts with some blockdev actions

Includes the following tests:

 - Adding a dirty bitmap.
   * RHBZ: 1782175

 - Starting a drive-mirror to an NBD-backed target.
   * RHBZ: 17462171773517

 - Aborting an external snapshot transaction.
   * RHBZ: 1779036

 - Aborting a blockdev backup transaction.
   * RHBZ: 1782111

For each one of them, a VM with a number of disks running in an
IOThread AioContext is used.

Signed-off-by: Sergio Lopez <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
5 years agoblockdev: Return bs to the proper context on snapshot abort
Sergio Lopez [Wed, 8 Jan 2020 14:31:37 +0000 (15:31 +0100)]
blockdev: Return bs to the proper context on snapshot abort

external_snapshot_abort() calls to bdrv_set_backing_hd(), which
returns state->old_bs to the main AioContext, as it's intended to be
used then the BDS is going to be released. As that's not the case when
aborting an external snapshot, return it to the AioContext it was
before the call.

This issue can be triggered by issuing a transaction with two actions,
a proper blockdev-snapshot-sync and a bogus one, so the second will
trigger a transaction abort. This results in a crash with an stack
trace like this one:

 #0  0x00007fa1048b28df in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
 #1  0x00007fa10489ccf5 in __GI_abort () at abort.c:79
 #2  0x00007fa10489cbc9 in __assert_fail_base
     (fmt=0x7fa104a03300 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x5572240b44d8 "bdrv_get_aio_context(old_bs) == bdrv_get_aio_context(new_bs)", file=0x557224014d30 "block.c", line=2240, function=<optimized out>) at assert.c:92
 #3  0x00007fa1048aae96 in __GI___assert_fail
     (assertion=assertion@entry=0x5572240b44d8 "bdrv_get_aio_context(old_bs) == bdrv_get_aio_context(new_bs)", file=file@entry=0x557224014d30 "block.c", line=line@entry=2240, function=function@entry=0x5572240b5d60 <__PRETTY_FUNCTION__.31620> "bdrv_replace_child_noperm") at assert.c:101
 #4  0x0000557223e631f8 in bdrv_replace_child_noperm (child=0x557225b9c980, new_bs=new_bs@entry=0x557225c42e40) at block.c:2240
 #5  0x0000557223e68be7 in bdrv_replace_node (from=0x557226951a60, to=0x557225c42e40, errp=0x5572247d6138 <error_abort>) at block.c:4196
 #6  0x0000557223d069c4 in external_snapshot_abort (common=0x557225d7e170) at blockdev.c:1731
 #7  0x0000557223d069c4 in external_snapshot_abort (common=0x557225d7e170) at blockdev.c:1717
 #8  0x0000557223d09013 in qmp_transaction (dev_list=<optimized out>, has_props=<optimized out>, props=0x557225cc7d70, errp=errp@entry=0x7ffe704c0c98) at blockdev.c:2360
 #9  0x0000557223e32085 in qmp_marshal_transaction (args=<optimized out>, ret=<optimized out>, errp=0x7ffe704c0d08) at qapi/qapi-commands-transaction.c:44
 #10 0x0000557223ee798c in do_qmp_dispatch (errp=0x7ffe704c0d00, allow_oob=<optimized out>, request=<optimized out>, cmds=0x5572247d3cc0 <qmp_commands>) at qapi/qmp-dispatch.c:132
 #11 0x0000557223ee798c in qmp_dispatch (cmds=0x5572247d3cc0 <qmp_commands>, request=<optimized out>, allow_oob=<optimized out>) at qapi/qmp-dispatch.c:175
 #12 0x0000557223e06141 in monitor_qmp_dispatch (mon=0x557225c69ff0, req=<optimized out>) at monitor/qmp.c:120
 #13 0x0000557223e0678a in monitor_qmp_bh_dispatcher (data=<optimized out>) at monitor/qmp.c:209
 #14 0x0000557223f2f366 in aio_bh_call (bh=0x557225b9dc60) at util/async.c:117
 #15 0x0000557223f2f366 in aio_bh_poll (ctx=ctx@entry=0x557225b9c840) at util/async.c:117
 #16 0x0000557223f32754 in aio_dispatch (ctx=0x557225b9c840) at util/aio-posix.c:459
 #17 0x0000557223f2f242 in aio_ctx_dispatch (source=<optimized out>, callback=<optimized out>, user_data=<optimized out>) at util/async.c:260
 #18 0x00007fa10913467d in g_main_dispatch (context=0x557225c28e80) at gmain.c:3176
 #19 0x00007fa10913467d in g_main_context_dispatch (context=context@entry=0x557225c28e80) at gmain.c:3829
 #20 0x0000557223f31808 in glib_pollfds_poll () at util/main-loop.c:219
 #21 0x0000557223f31808 in os_host_main_loop_wait (timeout=<optimized out>) at util/main-loop.c:242
 #22 0x0000557223f31808 in main_loop_wait (nonblocking=<optimized out>) at util/main-loop.c:518
 #23 0x0000557223d13201 in main_loop () at vl.c:1828
 #24 0x0000557223bbfb82 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:4504

RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1779036
Signed-off-by: Sergio Lopez <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
5 years agoblockdev: Acquire AioContext on dirty bitmap functions
Sergio Lopez [Wed, 8 Jan 2020 14:31:36 +0000 (15:31 +0100)]
blockdev: Acquire AioContext on dirty bitmap functions

Dirty map addition and removal functions are not acquiring to BDS
AioContext, while they may call to code that expects it to be
acquired.

This may trigger a crash with a stack trace like this one:

 #0  0x00007f0ef146370f in __GI_raise (sig=sig@entry=6)
     at ../sysdeps/unix/sysv/linux/raise.c:50
 #1  0x00007f0ef144db25 in __GI_abort () at abort.c:79
 #2  0x0000565022294dce in error_exit
     (err=<optimized out>, msg=msg@entry=0x56502243a730 <__func__.16350> "qemu_mutex_unlock_impl") at util/qemu-thread-posix.c:36
 #3  0x00005650222950ba in qemu_mutex_unlock_impl
     (mutex=mutex@entry=0x5650244b0240, file=file@entry=0x565022439adf "util/async.c", line=line@entry=526) at util/qemu-thread-posix.c:108
 #4  0x0000565022290029 in aio_context_release
     (ctx=ctx@entry=0x5650244b01e0) at util/async.c:526
 #5  0x000056502221cd08 in bdrv_can_store_new_dirty_bitmap
     (bs=bs@entry=0x5650244dc820, name=name@entry=0x56502481d360 "bitmap1", granularity=granularity@entry=65536, errp=errp@entry=0x7fff22831718)
     at block/dirty-bitmap.c:542
 #6  0x000056502206ae53 in qmp_block_dirty_bitmap_add
     (errp=0x7fff22831718, disabled=false, has_disabled=<optimized out>, persistent=<optimized out>, has_persistent=true, granularity=65536, has_granularity=<optimized out>, name=0x56502481d360 "bitmap1", node=<optimized out>) at blockdev.c:2894
 #7  0x000056502206ae53 in qmp_block_dirty_bitmap_add
     (node=<optimized out>, name=0x56502481d360 "bitmap1", has_granularity=<optimized out>, granularity=<optimized out>, has_persistent=true, persistent=<optimized out>, has_disabled=false, disabled=false, errp=0x7fff22831718) at blockdev.c:2856
 #8  0x00005650221847a3 in qmp_marshal_block_dirty_bitmap_add
     (args=<optimized out>, ret=<optimized out>, errp=0x7fff22831798)
     at qapi/qapi-commands-block-core.c:651
 #9  0x0000565022247e6c in do_qmp_dispatch
     (errp=0x7fff22831790, allow_oob=<optimized out>, request=<optimized out>, cmds=0x565022b32d60 <qmp_commands>) at qapi/qmp-dispatch.c:132
 #10 0x0000565022247e6c in qmp_dispatch
     (cmds=0x565022b32d60 <qmp_commands>, request=<optimized out>, allow_oob=<optimized out>) at qapi/qmp-dispatch.c:175
 #11 0x0000565022166061 in monitor_qmp_dispatch
     (mon=0x56502450faa0, req=<optimized out>) at monitor/qmp.c:145
 #12 0x00005650221666fa in monitor_qmp_bh_dispatcher
     (data=<optimized out>) at monitor/qmp.c:234
 #13 0x000056502228f866 in aio_bh_call (bh=0x56502440eae0)
     at util/async.c:117
 #14 0x000056502228f866 in aio_bh_poll (ctx=ctx@entry=0x56502440d7a0)
     at util/async.c:117
 #15 0x0000565022292c54 in aio_dispatch (ctx=0x56502440d7a0)
     at util/aio-posix.c:459
 #16 0x000056502228f742 in aio_ctx_dispatch
     (source=<optimized out>, callback=<optimized out>, user_data=<optimized out>) at util/async.c:260
 #17 0x00007f0ef5ce667d in g_main_dispatch (context=0x56502449aa40)
     at gmain.c:3176
 #18 0x00007f0ef5ce667d in g_main_context_dispatch
     (context=context@entry=0x56502449aa40) at gmain.c:3829
 #19 0x0000565022291d08 in glib_pollfds_poll () at util/main-loop.c:219
 #20 0x0000565022291d08 in os_host_main_loop_wait
     (timeout=<optimized out>) at util/main-loop.c:242
 #21 0x0000565022291d08 in main_loop_wait (nonblocking=<optimized out>)
     at util/main-loop.c:518
 #22 0x00005650220743c1 in main_loop () at vl.c:1828
 #23 0x0000565021f20a72 in main
     (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>)
     at vl.c:4504

Fix this by acquiring the AioContext at qmp_block_dirty_bitmap_add()
and qmp_block_dirty_bitmap_add().

RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1782175
Signed-off-by: Sergio Lopez <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
5 years agoblock/backup-top: Don't acquire context while dropping top
Sergio Lopez [Wed, 8 Jan 2020 14:31:35 +0000 (15:31 +0100)]
block/backup-top: Don't acquire context while dropping top

All paths that lead to bdrv_backup_top_drop(), except for the call
from backup_clean(), imply that the BDS AioContext has already been
acquired, so doing it there too can potentially lead to QEMU hanging
on AIO_WAIT_WHILE().

An easy way to trigger this situation is by issuing a two actions
transaction, with a proper and a bogus blockdev-backup, so the second
one will trigger a rollback. This will trigger a hang with an stack
trace like this one:

 #0  0x00007fb680c75016 in __GI_ppoll (fds=0x55e74580f7c0, nfds=1, timeout=<optimized out>,
     timeout@entry=0x0, sigmask=sigmask@entry=0x0) at ../sysdeps/unix/sysv/linux/ppoll.c:39
 #1  0x000055e743386e09 in ppoll (__ss=0x0, __timeout=0x0, __nfds=<optimized out>, __fds=<optimized out>)
     at /usr/include/bits/poll2.h:77
 #2  0x000055e743386e09 in qemu_poll_ns
     (fds=<optimized out>, nfds=<optimized out>, timeout=<optimized out>) at util/qemu-timer.c:336
 #3  0x000055e743388dc4 in aio_poll (ctx=0x55e7458925d0, blocking=blocking@entry=true)
     at util/aio-posix.c:669
 #4  0x000055e743305dea in bdrv_flush (bs=bs@entry=0x55e74593c0d0) at block/io.c:2878
 #5  0x000055e7432be58e in bdrv_close (bs=0x55e74593c0d0) at block.c:4017
 #6  0x000055e7432be58e in bdrv_delete (bs=<optimized out>) at block.c:4262
 #7  0x000055e7432be58e in bdrv_unref (bs=bs@entry=0x55e74593c0d0) at block.c:5644
 #8  0x000055e743316b9b in bdrv_backup_top_drop (bs=bs@entry=0x55e74593c0d0) at block/backup-top.c:273
 #9  0x000055e74331461f in backup_job_create
     (job_id=0x0, bs=bs@entry=0x55e7458d5820, target=target@entry=0x55e74589f640, speed=0, sync_mode=MIRROR_SYNC_MODE_FULL, sync_bitmap=sync_bitmap@entry=0x0, bitmap_mode=BITMAP_SYNC_MODE_ON_SUCCESS, compress=false, filter_node_name=0x0, on_source_error=BLOCKDEV_ON_ERROR_REPORT, on_target_error=BLOCKDEV_ON_ERROR_REPORT, creation_flags=0, cb=0x0, opaque=0x0, txn=0x0, errp=0x7ffddfd1efb0) at block/backup.c:478
 #10 0x000055e74315bc52 in do_backup_common
     (backup=backup@entry=0x55e746c066d0, bs=bs@entry=0x55e7458d5820, target_bs=target_bs@entry=0x55e74589f640, aio_context=aio_context@entry=0x55e7458a91e0, txn=txn@entry=0x0, errp=errp@entry=0x7ffddfd1efb0)
     at blockdev.c:3580
 #11 0x000055e74315c37c in do_blockdev_backup
     (backup=backup@entry=0x55e746c066d0, txn=0x0, errp=errp@entry=0x7ffddfd1efb0)
     at /usr/src/debug/qemu-kvm-4.2.0-2.module+el8.2.0+5135+ed3b2489.x86_64/./qapi/qapi-types-block-core.h:1492
 #12 0x000055e74315c449 in blockdev_backup_prepare (common=0x55e746a8de90, errp=0x7ffddfd1f018)
     at blockdev.c:1885
 #13 0x000055e743160152 in qmp_transaction
     (dev_list=<optimized out>, has_props=<optimized out>, props=0x55e7467fe2c0, errp=errp@entry=0x7ffddfd1f088) at blockdev.c:2340
 #14 0x000055e743287ff5 in qmp_marshal_transaction
     (args=<optimized out>, ret=<optimized out>, errp=0x7ffddfd1f0f8)
     at qapi/qapi-commands-transaction.c:44
 #15 0x000055e74333de6c in do_qmp_dispatch
     (errp=0x7ffddfd1f0f0, allow_oob=<optimized out>, request=<optimized out>, cmds=0x55e743c28d60 <qmp_commands>) at qapi/qmp-dispatch.c:132
 #16 0x000055e74333de6c in qmp_dispatch
     (cmds=0x55e743c28d60 <qmp_commands>, request=<optimized out>, allow_oob=<optimized out>)
     at qapi/qmp-dispatch.c:175
 #17 0x000055e74325c061 in monitor_qmp_dispatch (mon=0x55e745908030, req=<optimized out>)
     at monitor/qmp.c:145
 #18 0x000055e74325c6fa in monitor_qmp_bh_dispatcher (data=<optimized out>) at monitor/qmp.c:234
 #19 0x000055e743385866 in aio_bh_call (bh=0x55e745807ae0) at util/async.c:117
 #20 0x000055e743385866 in aio_bh_poll (ctx=ctx@entry=0x55e7458067a0) at util/async.c:117
 #21 0x000055e743388c54 in aio_dispatch (ctx=0x55e7458067a0) at util/aio-posix.c:459
 #22 0x000055e743385742 in aio_ctx_dispatch
     (source=<optimized out>, callback=<optimized out>, user_data=<optimized out>) at util/async.c:260
 #23 0x00007fb68543e67d in g_main_dispatch (context=0x55e745893a40) at gmain.c:3176
 #24 0x00007fb68543e67d in g_main_context_dispatch (context=context@entry=0x55e745893a40) at gmain.c:3829
 #25 0x000055e743387d08 in glib_pollfds_poll () at util/main-loop.c:219
 #26 0x000055e743387d08 in os_host_main_loop_wait (timeout=<optimized out>) at util/main-loop.c:242
 #27 0x000055e743387d08 in main_loop_wait (nonblocking=<optimized out>) at util/main-loop.c:518
 #28 0x000055e74316a3c1 in main_loop () at vl.c:1828
 #29 0x000055e743016a72 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>)
     at vl.c:4504

Fix this by not acquiring the AioContext there, and ensuring all paths
leading to it have it already acquired (backup_clean()).

RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1782111
Signed-off-by: Sergio Lopez <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
5 years agoblockdev: honor bdrv_try_set_aio_context() context requirements
Sergio Lopez [Wed, 8 Jan 2020 14:31:34 +0000 (15:31 +0100)]
blockdev: honor bdrv_try_set_aio_context() context requirements

bdrv_try_set_aio_context() requires that the old context is held, and
the new context is not held. Fix all the occurrences where it's not
done this way.

Suggested-by: Max Reitz <[email protected]>
Signed-off-by: Sergio Lopez <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
5 years agoblockdev: unify qmp_blockdev_backup and blockdev-backup transaction paths
Sergio Lopez [Wed, 8 Jan 2020 14:31:33 +0000 (15:31 +0100)]
blockdev: unify qmp_blockdev_backup and blockdev-backup transaction paths

Issuing a blockdev-backup from qmp_blockdev_backup takes a slightly
different path than when it's issued from a transaction. In the code,
this is manifested as some redundancy between do_blockdev_backup() and
blockdev_backup_prepare().

This change unifies both paths, merging do_blockdev_backup() and
blockdev_backup_prepare(), and changing qmp_blockdev_backup() to
create a transaction instead of calling do_backup_common() direcly.

As a side-effect, now qmp_blockdev_backup() is executed inside a
drained section, as it happens when creating a blockdev-backup
transaction. This change is visible from the user's perspective, as
the job gets paused and immediately resumed before starting the actual
work.

Signed-off-by: Sergio Lopez <[email protected]>
Reviewed-by: Max Reitz <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
5 years agoblockdev: unify qmp_drive_backup and drive-backup transaction paths
Sergio Lopez [Wed, 8 Jan 2020 14:31:32 +0000 (15:31 +0100)]
blockdev: unify qmp_drive_backup and drive-backup transaction paths

Issuing a drive-backup from qmp_drive_backup takes a slightly
different path than when it's issued from a transaction. In the code,
this is manifested as some redundancy between do_drive_backup() and
drive_backup_prepare().

This change unifies both paths, merging do_drive_backup() and
drive_backup_prepare(), and changing qmp_drive_backup() to create a
transaction instead of calling do_backup_common() direcly.

As a side-effect, now qmp_drive_backup() is executed inside a drained
section, as it happens when creating a drive-backup transaction. This
change is visible from the user's perspective, as the job gets paused
and immediately resumed before starting the actual work.

Also fix tests 141, 185 and 219 to cope with the extra
JOB_STATUS_CHANGE lines.

Signed-off-by: Sergio Lopez <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
5 years agoblockdev: fix coding style issues in drive_backup_prepare
Sergio Lopez [Wed, 8 Jan 2020 14:31:31 +0000 (15:31 +0100)]
blockdev: fix coding style issues in drive_backup_prepare

Fix a couple of minor coding style issues in drive_backup_prepare.

Signed-off-by: Sergio Lopez <[email protected]>
Reviewed-by: Max Reitz <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
5 years agoiotests: Add more "skip_if_unsupported" statements to the python tests
Thomas Huth [Tue, 14 Jan 2020 14:02:03 +0000 (15:02 +0100)]
iotests: Add more "skip_if_unsupported" statements to the python tests

The python code already contains a possibility to skip tests if the
corresponding driver is not available in the qemu binary - use it
in more spots to avoid that the tests are failing if the driver has
been disabled.

While we're at it, we can now also remove some of the old checks that
were using iotests.supports_quorum() - and which were apparently not
working as expected since the tests aborted instead of being skipped
when "quorum" was missing in the QEMU binary.

Signed-off-by: Thomas Huth <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
5 years agoiotests.py: Let wait_migration wait even more
Max Reitz [Thu, 19 Dec 2019 18:36:17 +0000 (19:36 +0100)]
iotests.py: Let wait_migration wait even more

The "migration completed" event may be sent (on the source, to be
specific) before the migration is actually completed, so the VM runstate
will still be "finish-migrate" instead of "postmigrate".  So ask the
users of VM.wait_migration() to specify the final runstate they desire
and then poll the VM until it has reached that state.  (This should be
over very quickly, so busy polling is fine.)

Without this patch, I see intermittent failures in the new iotest 280
under high system load.  I have not yet seen such failures with other
iotests that use VM.wait_migration() and query-status afterwards, but
maybe they just occur even more rarely, or it is because they also wait
on the destination VM to be running.

Signed-off-by: Max Reitz <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
5 years agoMerge remote-tracking branch 'remotes/cohuck/tags/s390x-20200127' into staging
Peter Maydell [Mon, 27 Jan 2020 13:02:36 +0000 (13:02 +0000)]
Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20200127' into staging

s390x changes:
- kvm: re-enable adapter interrupt suppression (AIS)
- fixes and cleanups

# gpg: Signature made Mon 27 Jan 2020 12:14:12 GMT
# gpg:                using RSA key C3D0D66DC3624FF6A8C018CEDECF6B93C6F02FAF
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Cornelia Huck <[email protected]>" [marginal]
# gpg:                 aka "Cornelia Huck <[email protected]>" [full]
# gpg:                 aka "Cornelia Huck <[email protected]>" [full]
# gpg:                 aka "Cornelia Huck <[email protected]>" [marginal]
# gpg:                 aka "Cornelia Huck <[email protected]>" [marginal]
# Primary key fingerprint: C3D0 D66D C362 4FF6 A8C0  18CE DECF 6B93 C6F0 2FAF

* remotes/cohuck/tags/s390x-20200127:
  s390x: sigp: Fix sense running reporting
  hw/s390x: Add a more verbose comment about get_machine_class() and the wrappers
  target/s390x: Remove DisasFields argument from extract_insn
  target/s390x: Move DisasFields into DisasContext
  target/s390x: Pass DisasContext to get_field and have_field
  target/s390x: Remove DisasFields argument from callbacks
  target/s390x: Move struct DisasFields definition earlier
  target/s390x/kvm: Enable adapter interruption suppression again
  docs/devel: fix stable process doc formatting
  target/s390x: Remove duplicated ifdef macro
  s390x/event-facility: fix error propagation
  s390x: adapter routes error handling
  s390x/event-facility.c: remove unneeded labels
  intc/s390_flic_kvm.c: remove unneeded label in kvm_flic_load()
  s390x/sclp.c: remove unneeded label in sclp_service_call()

Signed-off-by: Peter Maydell <[email protected]>
5 years agos390x: sigp: Fix sense running reporting
Janosch Frank [Fri, 24 Jan 2020 13:48:18 +0000 (08:48 -0500)]
s390x: sigp: Fix sense running reporting

The logic was inverted and reported running if the cpu was stopped.
Let's fix that.

Signed-off-by: Janosch Frank <[email protected]>
Fixes: d1b468bc8869 ("s390x/tcg: implement SIGP SENSE RUNNING STATUS")
Reviewed-by: David Hildenbrand <[email protected]>
Message-Id: <20200124134818[email protected]>
Signed-off-by: Cornelia Huck <[email protected]>
5 years agohw/s390x: Add a more verbose comment about get_machine_class() and the wrappers
Thomas Huth [Thu, 23 Jan 2020 17:02:56 +0000 (18:02 +0100)]
hw/s390x: Add a more verbose comment about get_machine_class() and the wrappers

While working on the "Enable adapter interruption suppression again"
recently, I had to discover that the meaning of get_machine_class()
and the related *_allowed() wrappers is not very obvious. Add a more
verbose comment here to clarify how these should be used.

Signed-off-by: Thomas Huth <[email protected]>
Message-Id: <20200123170256[email protected]>
Reviewed-by: David Hildenbrand <[email protected]>
Signed-off-by: Cornelia Huck <[email protected]>
5 years agotarget/s390x: Remove DisasFields argument from extract_insn
Richard Henderson [Thu, 23 Jan 2020 23:22:48 +0000 (13:22 -1000)]
target/s390x: Remove DisasFields argument from extract_insn

The separate pointer is now redundant.

Signed-off-by: Richard Henderson <[email protected]>
Message-Id: <20200123232248[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Signed-off-by: Cornelia Huck <[email protected]>
5 years agotarget/s390x: Move DisasFields into DisasContext
Richard Henderson [Thu, 23 Jan 2020 23:22:47 +0000 (13:22 -1000)]
target/s390x: Move DisasFields into DisasContext

I believe that the separate allocation of DisasFields from DisasContext
was meant to limit the places from which we could access fields.  But
that plan did not go unchanged, and since DisasContext contains a pointer
to fields, the substructure is accessible everywhere.

By allocating the substructure with DisasContext, we improve the locality
of the accesses by avoiding one level of pointer chasing.  In addition,
we avoid a dangling pointer to stack allocated memory, diagnosed by static
checkers.

Launchpad: https://bugs.launchpad.net/bugs/1661815
Signed-off-by: Richard Henderson <[email protected]>
Message-Id: <20200123232248[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Signed-off-by: Cornelia Huck <[email protected]>
5 years agotarget/s390x: Pass DisasContext to get_field and have_field
Richard Henderson [Thu, 23 Jan 2020 23:22:46 +0000 (13:22 -1000)]
target/s390x: Pass DisasContext to get_field and have_field

All callers pass s->fields, so we might as well pass s directly.

Signed-off-by: Richard Henderson <[email protected]>
Message-Id: <20200123232248[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Signed-off-by: Cornelia Huck <[email protected]>
5 years agotarget/s390x: Remove DisasFields argument from callbacks
Richard Henderson [Thu, 23 Jan 2020 23:22:45 +0000 (13:22 -1000)]
target/s390x: Remove DisasFields argument from callbacks

The DisasFields data is available from DisasContext.
We do not need to pass a separate argument.

Signed-off-by: Richard Henderson <[email protected]>
Message-Id: <20200123232248[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Signed-off-by: Cornelia Huck <[email protected]>
5 years agotarget/s390x: Move struct DisasFields definition earlier
Richard Henderson [Thu, 23 Jan 2020 23:22:44 +0000 (13:22 -1000)]
target/s390x: Move struct DisasFields definition earlier

We will want to include the struct in DisasContext.

Signed-off-by: Richard Henderson <[email protected]>
Message-Id: <20200123232248[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Signed-off-by: Cornelia Huck <[email protected]>
5 years agotarget/s390x/kvm: Enable adapter interruption suppression again
Thomas Huth [Wed, 22 Jan 2020 10:14:37 +0000 (11:14 +0100)]
target/s390x/kvm: Enable adapter interruption suppression again

The AIS feature has been disabled late in the v2.10 development cycle since
there were some issues with migration (see commit 3f2d07b3b01ea61126b -
"s390x/ais: for 2.10 stable: disable ais facility"). We originally wanted
to enable it again for newer machine types, but apparently we forgot to do
this so far. Let's do it now for the machines that support proper CPU models.

Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1756946
Signed-off-by: Thomas Huth <[email protected]>
Message-Id: <20200122101437[email protected]>
Reviewed-by: David Hildenbrand <[email protected]>
Tested-by: Matthew Rosato <[email protected]>
Signed-off-by: Cornelia Huck <[email protected]>
5 years agodocs/devel: fix stable process doc formatting
Cornelia Huck [Mon, 13 Jan 2020 10:30:23 +0000 (11:30 +0100)]
docs/devel: fix stable process doc formatting

Enumeration of stable criteria needs proper bullet points.

Message-Id: <20200113103023[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Cornelia Huck <[email protected]>
5 years agotarget/s390x: Remove duplicated ifdef macro
Philippe Mathieu-Daudé [Tue, 21 Jan 2020 11:03:44 +0000 (12:03 +0100)]
target/s390x: Remove duplicated ifdef macro

Commit ae71ed8610 replaced the use of global max_cpus variable
with a machine property, but introduced a unnecessary ifdef, as
this block is already in the 'not CONFIG_USER_ONLY' branch part:

   86 #if defined(CONFIG_USER_ONLY)
   87
  ...
  106 #else /* !CONFIG_USER_ONLY */
  107
  ...
  292 static void do_ext_interrupt(CPUS390XState *env)
  293 {
  ...
  313 #ifndef CONFIG_USER_ONLY
  314         MachineState *ms = MACHINE(qdev_get_machine());
  315         unsigned int max_cpus = ms->smp.max_cpus;
  316 #endif

To ease code review, remove the duplicated preprocessor macro,
and move the declarations at the beginning of the statement.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <20200121110349[email protected]>
Signed-off-by: Cornelia Huck <[email protected]>
5 years agos390x/event-facility: fix error propagation
Cornelia Huck [Tue, 21 Jan 2020 09:41:00 +0000 (10:41 +0100)]
s390x/event-facility: fix error propagation

We currently check (by error) if the passed-in Error pointer errp
is non-null and return after realizing the first child of the
event facility in that case. Symptom is that 'virsh shutdown'
does not work, as the sclpquiesce device is not realized.

Fix this by (correctly) checking the local Error err.

Reported-by: Christian Borntraeger <[email protected]>
Fixes: 3d508334dd2c ("s390x/event-facility: Fix realize() error API violations")
Message-Id: <20200121095506[email protected]>
Reviewed-by: David Hildenbrand <[email protected]>
Tested-by: Christian Borntraeger <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Cornelia Huck <[email protected]>
5 years agos390x: adapter routes error handling
Cornelia Huck [Thu, 16 Jan 2020 12:10:35 +0000 (13:10 +0100)]
s390x: adapter routes error handling

If the kernel irqchip has been disabled, we don't want the
{add,release}_adapter_routes routines to call any kvm_irqchip_*
interfaces, as they may rely on an irqchip actually having been
created. Just take a quick exit in that case instead. If you are
trying to use irqfd without a kernel irqchip, we will fail with
an error.

Also initialize routes->gsi[] with -1 in the virtio-ccw handling,
to make sure we don't trip over other errors, either. (Nobody
else uses the gsi array in that structure.)

Fixes: d426d9fba8ea ("s390x/virtio-ccw: wire up irq routing and irqfds")
Reviewed-by: Thomas Huth <[email protected]>
Acked-by: Christian Borntraeger <[email protected]>
Message-Id: <20200117111147[email protected]>
Signed-off-by: Cornelia Huck <[email protected]>
5 years agos390x/event-facility.c: remove unneeded labels
Daniel Henrique Barboza [Wed, 8 Jan 2020 14:46:07 +0000 (11:46 -0300)]
s390x/event-facility.c: remove unneeded labels

'out' label from write_event_mask() and write_event_data()
can be replaced by 'return'.

The 'out' label from read_event_data() can also be replaced.
However, as suggested by Cornelia Huck, instead of simply
replacing the 'out' label, let's also change the code flow
a bit to make it clearer that sccb events are always handled
regardless of the mask for unconditional reads, while selective
reads are handled if the mask is valid.

CC: Cornelia Huck <[email protected]>
CC: Thomas Huth <[email protected]>
CC: Halil Pasic <[email protected]>
CC: Christian Borntraeger <[email protected]>
Signed-off-by: Daniel Henrique Barboza <[email protected]>
Message-Id: <20200108144607[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Signed-off-by: Cornelia Huck <[email protected]>
5 years agointc/s390_flic_kvm.c: remove unneeded label in kvm_flic_load()
Daniel Henrique Barboza [Mon, 6 Jan 2020 18:24:07 +0000 (15:24 -0300)]
intc/s390_flic_kvm.c: remove unneeded label in kvm_flic_load()

'out' label can be replaced by 'return' with the appropriate
value that is set by 'r' right before the jump.

Cc: Christian Borntraeger <[email protected]>
Signed-off-by: Daniel Henrique Barboza <[email protected]>
Message-Id: <20200106182425[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Signed-off-by: Cornelia Huck <[email protected]>
5 years agos390x/sclp.c: remove unneeded label in sclp_service_call()
Daniel Henrique Barboza [Mon, 6 Jan 2020 18:24:04 +0000 (15:24 -0300)]
s390x/sclp.c: remove unneeded label in sclp_service_call()

'out' label can be replaced by 'return' with the appropriate
value. The 'r' integer, which is used solely to set the
return value for this label, can also be removed.

CC: Cornelia Huck <[email protected]>
CC: Halil Pasic <[email protected]>
CC: Christian Borntraeger <[email protected]>
Signed-off-by: Daniel Henrique Barboza <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <20200106182425[email protected]>
Signed-off-by: Cornelia Huck <[email protected]>
5 years agoMerge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
Peter Maydell [Mon, 27 Jan 2020 09:44:03 +0000 (09:44 +0000)]
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging

* Register qdev properties as class properties (Marc-André)
* Cleanups (Philippe)
* virtio-scsi fix (Pan Nengyuan)
* Tweak Skylake-v3 model id (Kashyap)
* x86 UCODE_REV support and nested live migration fix (myself)
* Advisory mode for pvpanic (Zhenwei)

# gpg: Signature made Fri 24 Jan 2020 20:16:23 GMT
# gpg:                using RSA key BFFBD25F78C7AE83
# gpg: Good signature from "Paolo Bonzini <[email protected]>" [full]
# gpg:                 aka "Paolo Bonzini <[email protected]>" [full]
# Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4  E2F7 7E15 100C CD36 69B1
#      Subkey fingerprint: F133 3857 4B66 2389 866C  7682 BFFB D25F 78C7 AE83

* remotes/bonzini/tags/for-upstream: (58 commits)
  build-sys: clean up flags included in the linker command line
  target/i386: Add the 'model-id' for Skylake -v3 CPU models
  qdev: use object_property_help()
  qapi/qmp: add ObjectPropertyInfo.default-value
  qom: introduce object_property_help()
  qom: simplify qmp_device_list_properties()
  vl: print default value in object help
  qdev: register properties as class properties
  qdev: move instance properties to class properties
  qdev: rename DeviceClass.props
  qdev: set properties with device_class_set_props()
  object: return self in object_ref()
  object: release all props
  object: add object_class_property_add_link()
  object: express const link with link property
  object: add direct link flag
  object: rename link "child" to "target"
  object: check strong flag with &
  object: do not free class properties
  object: add object_property_set_default
  ...

Signed-off-by: Peter Maydell <[email protected]>
5 years agobuild-sys: clean up flags included in the linker command line
Paolo Bonzini [Wed, 11 Dec 2019 14:34:27 +0000 (15:34 +0100)]
build-sys: clean up flags included in the linker command line

Some of the CFLAGS that are discovered during configure, for example
compiler warnings, are being included on the linker command line because
QEMU_CFLAGS is added to it.  Other flags, such as the -m32, appear twice
because they are included in both QEMU_CFLAGS and LDFLAGS.  All this
leads to confusion with respect to what goes in which Makefile variables
(and we have plenty).

So, introduce QEMU_LDFLAGS for flags discovered by configure, following
the lead of QEMU_CFLAGS, and stop adding to it:

1) options that are already in CFLAGS, for example "-g"

2) duplicate options

At the same time, options that _are_ needed by both compiler and linker
must now be added to both QEMU_CFLAGS and QEMU_LDFLAGS, which is clearer.
This is mostly -fsanitize options.  For now, --extra-cflags has this behavior
(but --extra-cxxflags does not).

Meson will not include CFLAGS on the linker command line, do the same in our
build system as well.

Signed-off-by: Marc-André Lureau <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
5 years agotarget/i386: Add the 'model-id' for Skylake -v3 CPU models
Kashyap Chamarthy [Thu, 23 Jan 2020 09:01:15 +0000 (10:01 +0100)]
target/i386: Add the 'model-id' for Skylake -v3 CPU models

This fixes a confusion in the help output.  (Although, if you squint
long enough at the '-cpu help' output, you _do_ notice that
"Skylake-Client-noTSX-IBRS" is an alias of "Skylake-Client-v3";
similarly for Skylake-Server-v3.)

Without this patch:

    $ qemu-system-x86 -cpu help
    ...
    x86 Skylake-Client-v1     Intel Core Processor (Skylake)
    x86 Skylake-Client-v2     Intel Core Processor (Skylake, IBRS)
    x86 Skylake-Client-v3     Intel Core Processor (Skylake, IBRS)
    ...
    x86 Skylake-Server-v1     Intel Xeon Processor (Skylake)
    x86 Skylake-Server-v2     Intel Xeon Processor (Skylake, IBRS)
    x86 Skylake-Server-v3     Intel Xeon Processor (Skylake, IBRS)
    ...

With this patch:

    $ ./qemu-system-x86 -cpu help
    ...
    x86 Skylake-Client-v1     Intel Core Processor (Skylake)
    x86 Skylake-Client-v2     Intel Core Processor (Skylake, IBRS)
    x86 Skylake-Client-v3     Intel Core Processor (Skylake, IBRS, no TSX)
    ...
    x86 Skylake-Server-v1     Intel Xeon Processor (Skylake)
    x86 Skylake-Server-v2     Intel Xeon Processor (Skylake, IBRS)
    x86 Skylake-Server-v3     Intel Xeon Processor (Skylake, IBRS, no TSX)
    ...

Signed-off-by: Kashyap Chamarthy <[email protected]>
Message-Id: <20200123090116[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
5 years agoqdev: use object_property_help()
Marc-André Lureau [Fri, 10 Jan 2020 15:30:39 +0000 (19:30 +0400)]
qdev: use object_property_help()

Use the common function introduced earlier, and report default value.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20200110153039.1379601[email protected]>
[Sort the properties, following what is done for -object ...,help. - Paolo]
Signed-off-by: Paolo Bonzini <[email protected]>
5 years agoqapi/qmp: add ObjectPropertyInfo.default-value
Marc-André Lureau [Fri, 10 Jan 2020 15:30:38 +0000 (19:30 +0400)]
qapi/qmp: add ObjectPropertyInfo.default-value

Report the default value associated with a property.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20200110153039.1379601[email protected]>
[Report it as type "any", not string. - Paolo]
Signed-off-by: Paolo Bonzini <[email protected]>
5 years agoqom: introduce object_property_help()
Marc-André Lureau [Fri, 10 Jan 2020 15:30:37 +0000 (19:30 +0400)]
qom: introduce object_property_help()

Let's factor out the code to format a help string for a property. We
are going to reuse it in qdev next, which will bring some consistency.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20200110153039.1379601[email protected]>
[Adjust for removal of object_property_get_default, move default
 after description. - Paolo]
Signed-off-by: Paolo Bonzini <[email protected]>
5 years agoqom: simplify qmp_device_list_properties()
Paolo Bonzini [Thu, 23 Jan 2020 11:17:13 +0000 (12:17 +0100)]
qom: simplify qmp_device_list_properties()

All qdev properties are object properties, no need for
make_device_property_info() helper.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20200110153039.1379601[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
5 years agovl: print default value in object help
Marc-André Lureau [Fri, 10 Jan 2020 15:30:35 +0000 (19:30 +0400)]
vl: print default value in object help

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20200110153039.1379601[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
5 years agoqdev: register properties as class properties
Marc-André Lureau [Fri, 10 Jan 2020 15:30:34 +0000 (19:30 +0400)]
qdev: register properties as class properties

Use class properties facilities to add properties to the class during
device_class_set_props().

qdev_property_add_static() must be adapted as PropertyInfo now
operates with classes (and not instances), so we must
set_default_value() on the ObjectProperty, before calling its init()
method on the object instance.

Also, PropertyInfo.create() is now exclusively used for class
properties. Fortunately, qdev_property_add_static() is only used in
target/arm/cpu.c so far, which doesn't use "link" properties (that
require create()).

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20200110153039.1379601[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
5 years agoqdev: move instance properties to class properties
Marc-André Lureau [Fri, 10 Jan 2020 15:30:33 +0000 (19:30 +0400)]
qdev: move instance properties to class properties

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20200110153039.1379601[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
5 years agoqdev: rename DeviceClass.props
Paolo Bonzini [Thu, 23 Jan 2020 11:11:38 +0000 (12:11 +0100)]
qdev: rename DeviceClass.props

Ensure that conflicts in the future will cause a syntax error.

Signed-off-by: Paolo Bonzini <[email protected]>
5 years agoqdev: set properties with device_class_set_props()
Marc-André Lureau [Fri, 10 Jan 2020 15:30:32 +0000 (19:30 +0400)]
qdev: set properties with device_class_set_props()

The following patch will need to handle properties registration during
class_init time. Let's use a device_class_set_props() setter.

spatch --macro-file scripts/cocci-macro-file.h  --sp-file
./scripts/coccinelle/qdev-set-props.cocci --keep-comments --in-place
--dir .

@@
typedef DeviceClass;
DeviceClass *d;
expression val;
@@
- d->props = val
+ device_class_set_props(d, val)

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20200110153039.1379601[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
5 years agoobject: return self in object_ref()
Marc-André Lureau [Fri, 10 Jan 2020 15:30:31 +0000 (19:30 +0400)]
object: return self in object_ref()

This allow for simpler assignment with ref: foo = object_ref(bar)

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <20200110153039.1379601[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
5 years agoobject: release all props
Marc-André Lureau [Fri, 10 Jan 2020 15:30:30 +0000 (19:30 +0400)]
object: release all props

Class properties may have to release resources when the object is
destroyed. Let's use the existing release() callback for that, but
class properties must not release ObjectProperty, as it can be shared
by various instances.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20200110153039.1379601[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
5 years agoobject: add object_class_property_add_link()
Marc-André Lureau [Fri, 10 Jan 2020 15:30:29 +0000 (19:30 +0400)]
object: add object_class_property_add_link()

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20200110153039.1379601[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
5 years agoobject: express const link with link property
Marc-André Lureau [Fri, 10 Jan 2020 15:30:28 +0000 (19:30 +0400)]
object: express const link with link property

Let's not mix child property and link property callbacks, as this is
confusing, use LinkProperty with DIRECT flag to hold the target pointer.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20200110153039.1379601[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
5 years agoobject: add direct link flag
Marc-André Lureau [Fri, 10 Jan 2020 15:30:27 +0000 (19:30 +0400)]
object: add direct link flag

Allow the link property to hold the pointer to the target, instead of
indirectly through another variable.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <20200110153039.1379601[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
This page took 0.10024 seconds and 4 git commands to generate.