]> Git Repo - qemu.git/log
qemu.git
4 years agoppc/translate: Turn the helper macros into functions
Giuseppe Musacchio [Thu, 12 Nov 2020 23:01:28 +0000 (00:01 +0100)]
ppc/translate: Turn the helper macros into functions

Suggested-by: Richard Henderson <[email protected]>
Signed-off-by: Giuseppe Musacchio <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20201112230130[email protected]>
Signed-off-by: David Gibson <[email protected]>
4 years agoppc/translate: Fix unordered f64/f128 comparisons
Giuseppe Musacchio [Thu, 12 Nov 2020 23:01:27 +0000 (00:01 +0100)]
ppc/translate: Fix unordered f64/f128 comparisons

According to the PowerISA v3.1 reference, Table 68 "Actions for xscmpudp
- Part 1: Compare Unordered", whenever one of the two operands is a NaN
the SO bit is set while the other three bits are cleared.

Apply the same change to xscmpuqp.

The respective ordered counterparts are unaffected.

Signed-off-by: Giuseppe Musacchio <[email protected]>
Message-Id: <20201112230130[email protected]>
Signed-off-by: David Gibson <[email protected]>
4 years agoppc: Add a missing break for PPC6xx_INPUT_TBEN
Chen Qun [Mon, 16 Nov 2020 02:48:09 +0000 (10:48 +0800)]
ppc: Add a missing break for PPC6xx_INPUT_TBEN

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
hw/ppc/ppc.c: In function ‘ppc6xx_set_irq’:
hw/ppc/ppc.c:118:16: warning: this statement may fall through [-Wimplicit-fallthrough=]
  118 |             if (level) {
      |                ^
hw/ppc/ppc.c:123:9: note: here
  123 |         case PPC6xx_INPUT_INT:
      |         ^~~~

According to the discussion, a break statement needs to be added here.

Reported-by: Euler Robot <[email protected]>
Signed-off-by: Chen Qun <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Acked-by: David Gibson <[email protected]>
Message-Id: <20201116024810.2415819[email protected]>
Signed-off-by: David Gibson <[email protected]>
4 years agotarget/ppc: replaced the TODO with LOG_UNIMP and add break for silence warnings
Chen Qun [Mon, 16 Nov 2020 02:48:10 +0000 (10:48 +0800)]
target/ppc: replaced the TODO with LOG_UNIMP and add break for silence warnings

When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warning:
target/ppc/mmu_helper.c: In function ‘dump_mmu’:
target/ppc/mmu_helper.c:1351:12: warning: this statement may fall through [-Wimplicit-fallthrough=]
 1351 |         if (ppc64_v3_radix(env_archcpu(env))) {
      |            ^
target/ppc/mmu_helper.c:1358:5: note: here
 1358 |     default:
      |     ^~~~~~~

Use "qemu_log_mask(LOG_UNIMP**)" instead of the TODO comment.
And add the break statement to fix it.

Reported-by: Euler Robot <[email protected]>
Signed-off-by: Chen Qun <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Acked-by: David Gibson <[email protected]>
Message-Id: <20201116024810.2415819[email protected]>
Signed-off-by: David Gibson <[email protected]>
4 years agospapr: Do TPM proxy hotplug sanity checks at pre-plug
Greg Kurz [Fri, 20 Nov 2020 23:42:07 +0000 (00:42 +0100)]
spapr: Do TPM proxy hotplug sanity checks at pre-plug

There can be only one TPM proxy at a time. This is currently
checked at plug time. But this can be detected at pre-plug in
order to error out earlier.

This allows to get rid of error handling in the plug handler.

Signed-off-by: Greg Kurz <[email protected]>
Message-Id: <20201120234208[email protected]>
Signed-off-by: David Gibson <[email protected]>
4 years agospapr: Do PHB hoplug sanity check at pre-plug
Greg Kurz [Fri, 20 Nov 2020 23:42:06 +0000 (00:42 +0100)]
spapr: Do PHB hoplug sanity check at pre-plug

We currently detect that a PHB index is already in use at plug time.
But this can be decteted at pre-plug in order to error out earlier.

This allows to pass &error_abort to spapr_drc_attach() and to end
up with a plug handler that doesn't need to report errors anymore.

Signed-off-by: Greg Kurz <[email protected]>
Message-Id: <20201120234208[email protected]>
Signed-off-by: David Gibson <[email protected]>
4 years agospapr: Make PHB placement functions and spapr_pre_plug_phb() return status
Greg Kurz [Fri, 20 Nov 2020 23:42:05 +0000 (00:42 +0100)]
spapr: Make PHB placement functions and spapr_pre_plug_phb() return status

Read documentation in "qapi/error.h" and changelog of commit
e3fe3988d785 ("error: Document Error API usage rules") for
rationale.

Signed-off-by: Greg Kurz <[email protected]>
Message-Id: <20201120234208[email protected]>
Signed-off-by: David Gibson <[email protected]>
4 years agospapr: Do NVDIMM/PC-DIMM device hotplug sanity checks at pre-plug only
Greg Kurz [Fri, 20 Nov 2020 23:42:01 +0000 (00:42 +0100)]
spapr: Do NVDIMM/PC-DIMM device hotplug sanity checks at pre-plug only

Pre-plug of a memory device, be it an NVDIMM or a PC-DIMM, ensures
that the memory slot is available and that addresses don't overlap
with existing memory regions. The corresponding DRCs in the LMB
and PMEM namespaces are thus necessarily attachable at plug time.

Pass &error_abort to spapr_drc_attach() in spapr_add_lmbs() and
spapr_add_nvdimm(). This allows to greatly simplify error handling
on the plug path.

Signed-off-by: Greg Kurz <[email protected]>
Message-Id: <20201120234208[email protected]>
Signed-off-by: David Gibson <[email protected]>
4 years agospapr: Do PCI device hotplug sanity checks at pre-plug only
Greg Kurz [Fri, 20 Nov 2020 23:42:00 +0000 (00:42 +0100)]
spapr: Do PCI device hotplug sanity checks at pre-plug only

The PHB acts as the hotplug handler for PCI devices. It does some
sanity checks on DR enablement, PCI bridge chassis numbers and
multifunction. These checks are currently performed at plug time,
but they would best sit in a pre-plug handler in order to error
out as early as possible.

Create a spapr_pci_pre_plug() handler and move all the checking
there. Add a check that the associated DRC doesn't already have
an attached device. This is equivalent to the slot availability
check performed by do_pci_register_device() upon realization of
the PCI device.

This allows to pass &error_abort to spapr_drc_attach() and to end
up with a plug handler that doesn't need to report errors anymore.

Signed-off-by: Greg Kurz <[email protected]>
Message-Id: <20201120234208[email protected]>
Signed-off-by: David Gibson <[email protected]>
4 years agospapr/xics: Drop unused argument to xics_kvm_has_broken_disconnect()
Greg Kurz [Fri, 20 Nov 2020 17:46:43 +0000 (18:46 +0100)]
spapr/xics: Drop unused argument to xics_kvm_has_broken_disconnect()

Never used from the start.

Signed-off-by: Greg Kurz <[email protected]>
Message-Id: <20201120174646[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Signed-off-by: David Gibson <[email protected]>
4 years agospapr/xive: Turn some sanity checks into assertions
Greg Kurz [Fri, 20 Nov 2020 17:46:39 +0000 (18:46 +0100)]
spapr/xive: Turn some sanity checks into assertions

The sPAPR XIVE device is created by the machine in spapr_irq_init().
The latter overrides any value provided by the user with -global for
the "nr-irqs" and "nr-ends" properties with strictly positive values.

It seems reasonable to assume these properties should never be 0,
which wouldn't make much sense by the way.

Signed-off-by: Greg Kurz <[email protected]>
Message-Id: <20201120174646[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Signed-off-by: David Gibson <[email protected]>
4 years agoconfigure / meson: Move check for linux/btrfs.h to meson.build
Thomas Huth [Wed, 18 Nov 2020 17:10:52 +0000 (18:10 +0100)]
configure / meson: Move check for linux/btrfs.h to meson.build

This check can be done in a much shorter way in meson.build. And while
we're at it, rename the #define to HAVE_BTRFS_H to match the other
HAVE_someheader_H symbols that we already have.

Signed-off-by: Thomas Huth <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20201118171052[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
4 years agoconfigure / meson: Move check for sys/kcov.h to meson.build
Thomas Huth [Wed, 18 Nov 2020 17:10:51 +0000 (18:10 +0100)]
configure / meson: Move check for sys/kcov.h to meson.build

This check can be done in a much shorter way in meson.build. And while
we're at it, rename the #define to HAVE_SYS_KCOV_H to match the other
HAVE_someheader_H symbols that we already have.

Signed-off-by: Thomas Huth <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20201118171052[email protected]>
[lv: s/signal/kcov/]
Signed-off-by: Laurent Vivier <[email protected]>
4 years agoconfigure / meson: Move check for sys/signal.h to meson.build
Thomas Huth [Wed, 18 Nov 2020 17:10:50 +0000 (18:10 +0100)]
configure / meson: Move check for sys/signal.h to meson.build

This check can be done in a much shorter way in meson.build

Signed-off-by: Thomas Huth <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20201118171052[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
4 years agoconfigure / meson: Move check for drm.h to meson.build
Thomas Huth [Wed, 18 Nov 2020 17:10:49 +0000 (18:10 +0100)]
configure / meson: Move check for drm.h to meson.build

This check can be done in a much shorter way in meson.build

Signed-off-by: Thomas Huth <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20201118171052[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
4 years agoconfigure / meson: Move check for pty.h to meson.build
Thomas Huth [Wed, 18 Nov 2020 17:10:48 +0000 (18:10 +0100)]
configure / meson: Move check for pty.h to meson.build

This check can be done in a much shorter way in meson.build

Signed-off-by: Thomas Huth <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20201118171052[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
4 years agoconfigure: Remove the obsolete check for ifaddrs.h
Thomas Huth [Wed, 18 Nov 2020 17:10:47 +0000 (18:10 +0100)]
configure: Remove the obsolete check for ifaddrs.h

The code that used HAVE_IFADDRS_H has been removed in commit
0a27af918b ("io: use bind() to check for IPv4/6 availability"),
so we don't need this check in the configure script anymore.

Signed-off-by: Thomas Huth <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20201118171052[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
4 years agoblockdev: Fix a memleak in drive_backup_prepare()
Pan Nengyuan [Fri, 23 Oct 2020 06:12:17 +0000 (14:12 +0800)]
blockdev: Fix a memleak in drive_backup_prepare()

'local_err' seems forgot to propagate in error path, it'll cause
a memleak. Fix it.

Reported-by: Euler Robot <[email protected]>
Signed-off-by: Pan Nengyuan <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Reviewed-by: Li Qiang <[email protected]>
Signed-off-by: Chen Qun <[email protected]>
Message-Id: <20201023061218.2080844[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
4 years agoblock/file-posix: fix a possible undefined behavior
Pan Nengyuan [Fri, 23 Oct 2020 06:12:18 +0000 (14:12 +0800)]
block/file-posix: fix a possible undefined behavior

local_err is not initialized to NULL, it will cause a assert error as below:
qemu/util/error.c:59: error_setv: Assertion `*errp == NULL' failed.

Fixes: c6447510690
Reported-by: Euler Robot <[email protected]>
Signed-off-by: Pan Nengyuan <[email protected]>
Reviewed-by: Stefano Garzarella <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Reviewed-by: Li Qiang <[email protected]>
Signed-off-by: Chen Qun <[email protected]>
Message-Id: <20201023061218.2080844[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
4 years agoelf2dmp/pdb: Plug memleak in pdb_init_from_file
Pan Nengyuan [Fri, 23 Oct 2020 06:12:15 +0000 (14:12 +0800)]
elf2dmp/pdb: Plug memleak in pdb_init_from_file

Missing g_error_free in pdb_init_from_file() error path. Fix that.

Reported-by: Euler Robot <[email protected]>
Signed-off-by: Pan Nengyuan <[email protected]>
Reviewed-by: Viktor Prutyanov <[email protected]>
Reviewed-by: Li Qiang <[email protected]>
Signed-off-by: Chen Qun <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <20201023061218.2080844[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
4 years agoelf2dmp/qemu_elf: Plug memleak in QEMU_Elf_init
Pan Nengyuan [Fri, 23 Oct 2020 06:12:14 +0000 (14:12 +0800)]
elf2dmp/qemu_elf: Plug memleak in QEMU_Elf_init

Missing g_error_free in QEMU_Elf_init() error path. Fix that.

Reported-by: Euler Robot <[email protected]>
Signed-off-by: Pan Nengyuan <[email protected]>
Reviewed-by: Viktor Prutyanov <[email protected]>
Reviewed-by: Li Qiang <[email protected]>
Signed-off-by: Chen Qun <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <20201023061218.2080844[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
4 years agoconfigure: Test if $make actually exists
Roman Bolshakov [Tue, 25 Aug 2020 20:27:55 +0000 (23:27 +0300)]
configure: Test if $make actually exists

configure doesn't detect if $make is installed on the build host.
This is also helpful for hosts where an alias for make is used, i.e.
configure would fail if gmake is not present on macOS.

Reviewed-by: Daniel P. Berrangé <[email protected]>
Signed-off-by: Roman Bolshakov <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <20200825202755[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
4 years agotarget/mips: Use FloatRoundMode enum for FCR31 modes conversion
Philippe Mathieu-Daudé [Sun, 22 Nov 2020 17:05:25 +0000 (18:05 +0100)]
target/mips: Use FloatRoundMode enum for FCR31 modes conversion

Use the FloatRoundMode enum type introduced in commit 3dede407cc6
("softfloat: Name rounding mode enum") instead of 'unsigned int'.

Suggested-by: Richard Henderson <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20201123204448.3260804[email protected]>

4 years agotarget/mips: Remove unused headers from fpu_helper.c
Philippe Mathieu-Daudé [Sat, 5 Dec 2020 17:34:51 +0000 (18:34 +0100)]
target/mips: Remove unused headers from fpu_helper.c

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20201206233949.3783184[email protected]>

4 years agotarget/mips: Inline cpu_mips_realize_env() in mips_cpu_realizefn()
Philippe Mathieu-Daudé [Sun, 6 Dec 2020 22:49:07 +0000 (23:49 +0100)]
target/mips: Inline cpu_mips_realize_env() in mips_cpu_realizefn()

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20201206233949.3783184[email protected]>

4 years agotarget/mips: Move cpu definitions, reset() and realize() to cpu.c
Philippe Mathieu-Daudé [Sun, 6 Dec 2020 22:29:33 +0000 (23:29 +0100)]
target/mips: Move cpu definitions, reset() and realize() to cpu.c

Nothing TCG specific there, move to common cpu code.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20201206233949.3783184[email protected]>

4 years agotarget/mips: Move mips_cpu_add_definition() from helper.c to cpu.c
Philippe Mathieu-Daudé [Sun, 6 Dec 2020 21:07:34 +0000 (22:07 +0100)]
target/mips: Move mips_cpu_add_definition() from helper.c to cpu.c

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20201206233949.3783184[email protected]>

4 years agotarget/mips: Extract cpu_supports*/cpu_set* translate.c
Philippe Mathieu-Daudé [Sun, 6 Dec 2020 21:03:35 +0000 (22:03 +0100)]
target/mips: Extract cpu_supports*/cpu_set* translate.c

Move cpu_supports*() and cpu_set_exception_base() from
translate.c to cpu.c.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20201206233949.3783184[email protected]>

4 years agohw/mips/malta: Rewrite CP0_MVPConf0 access using deposit()
Philippe Mathieu-Daudé [Fri, 4 Dec 2020 22:16:45 +0000 (23:16 +0100)]
hw/mips/malta: Rewrite CP0_MVPConf0 access using deposit()

PTC field has 8 bits, PVPE has 4. We plan to use the
"hw/registerfields.h" API with MIPS CPU definitions
(target/mips/cpu.h). Meanwhile we use magic 8 and 4.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20201204222622.2743175[email protected]>

4 years agohw/mips/malta: Do not initialize MT registers if MT ASE absent
Philippe Mathieu-Daudé [Wed, 2 Dec 2020 17:53:09 +0000 (18:53 +0100)]
hw/mips/malta: Do not initialize MT registers if MT ASE absent

Do not initialize MT-related config register if the MT ASE
is not present.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20201204222622.2743175[email protected]>

4 years agotarget/mips: Do not initialize MT registers if MT ASE absent
Philippe Mathieu-Daudé [Wed, 2 Dec 2020 17:53:20 +0000 (18:53 +0100)]
target/mips: Do not initialize MT registers if MT ASE absent

Do not initialize MT-related config registers if the MT ASE
is not present. As some functions access the 'mvp' structure,
we still zero-allocate it.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20201204222622.2743175[email protected]>

4 years agotarget/mips: Introduce ase_mt_available() helper
Philippe Mathieu-Daudé [Wed, 2 Dec 2020 17:49:00 +0000 (18:49 +0100)]
target/mips: Introduce ase_mt_available() helper

Instead of accessing CP0_Config3 directly and checking
the 'Multi-Threading Present' bit, introduce an helper
to simplify code review.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20201204222622.2743175[email protected]>

4 years agotarget/mips: Remove mips_def_t unused argument from mvp_init()
Philippe Mathieu-Daudé [Mon, 30 Nov 2020 09:04:39 +0000 (10:04 +0100)]
target/mips: Remove mips_def_t unused argument from mvp_init()

mvp_init() doesn't require any CPU definition (beside the
information accessible via CPUMIPSState). Remove the unused
argument.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20201204222622.2743175[email protected]>

4 years agotarget/mips: Remove unused headers from op_helper.c
Philippe Mathieu-Daudé [Sat, 5 Dec 2020 17:36:03 +0000 (18:36 +0100)]
target/mips: Remove unused headers from op_helper.c

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20201206233949.3783184[email protected]>

4 years agotarget/mips: Remove unused headers from translate.c
Philippe Mathieu-Daudé [Sun, 6 Dec 2020 23:36:03 +0000 (00:36 +0100)]
target/mips: Remove unused headers from translate.c

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20201206233949.3783184[email protected]>

4 years agohw/mips: Move address translation helpers to target/mips/
Philippe Mathieu-Daudé [Sun, 6 Dec 2020 19:29:00 +0000 (20:29 +0100)]
hw/mips: Move address translation helpers to target/mips/

Address translation is an architectural thing (not hardware
related). Move the helpers from hw/ to target/.

As physical address and KVM are specific to system mode
emulation, restrict this file to softmmu, so it doesn't
get compiled for user-mode emulation.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20201206233949.3783184[email protected]>

4 years agotarget/mips: Introduce cpu_supports_isa() taking CPUMIPSState argument
Philippe Mathieu-Daudé [Mon, 7 Dec 2020 21:33:22 +0000 (22:33 +0100)]
target/mips: Introduce cpu_supports_isa() taking CPUMIPSState argument

Introduce cpu_supports_isa() which takes a CPUMIPSState
argument, more useful at runtime when the CPU is created
(no need to call the extensive object_class_by_name()).

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20201207215257.4004222[email protected]>

4 years agotarget/mips: Rename cpu_supports_FEAT() as cpu_type_supports_FEAT()
Philippe Mathieu-Daudé [Mon, 7 Dec 2020 21:32:49 +0000 (22:32 +0100)]
target/mips: Rename cpu_supports_FEAT() as cpu_type_supports_FEAT()

As cpu_supports_isa() / cpu_supports_cps_smp() take a 'cpu_type'
name argument, rename them cpu_type_supports_FEAT().

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20201207215257.4004222[email protected]>

4 years agotarget/mips: Explicit Release 6 MMU types
Philippe Mathieu-Daudé [Tue, 1 Dec 2020 11:26:09 +0000 (12:26 +0100)]
target/mips: Explicit Release 6 MMU types

As of Release 6, MMU type 4 is assigned to "Dual Variable-Page-Size
and Fixed-Page-Size TLBs" and type 2 to "Block Address Translation.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20201201132817.2863301[email protected]>

4 years agotarget/mips: Allow executing MSA instructions on Loongson-3A4000
Philippe Mathieu-Daudé [Mon, 30 Nov 2020 10:13:01 +0000 (11:13 +0100)]
target/mips: Allow executing MSA instructions on Loongson-3A4000

The Loongson-3A4000 is a GS464V-based processor with MIPS MSA ASE:
https://www.mail-archive.com/[email protected]/msg763059.html

Commit af868995e1b correctly set the 'MSA present' bit of Config3
register, but forgot to allow the MSA instructions decoding in
insn_flags, so executing them triggers a 'Reserved Instruction'.

Fix by adding the ASE_MSA mask to insn_flags.

Fixes: af868995e1b ("target/mips: Add Loongson-3 CPU definition")
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Huacai Chen <[email protected]>
Message-Id: <20201130102228.2395100[email protected]>

4 years agotarget/mips: Also display exception names in user-mode
Philippe Mathieu-Daudé [Wed, 18 Nov 2020 16:47:29 +0000 (17:47 +0100)]
target/mips: Also display exception names in user-mode

Currently MIPS exceptions are displayed as string in system-mode
emulation, but as number in user-mode.
Unify by extracting the current system-mode code as excp_name()
and use that in user-mode.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20201119160536.1980329[email protected]>

4 years agotarget/mips: Remove unused headers from cp0_helper.c
Philippe Mathieu-Daudé [Sat, 5 Dec 2020 17:35:12 +0000 (18:35 +0100)]
target/mips: Remove unused headers from cp0_helper.c

Remove unused headers and add missing "qemu/log.h" since
qemu_log() is called.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20201206233949.3783184[email protected]>

4 years agotarget/mips: Do not include CP0 helpers in user-mode emulation
Philippe Mathieu-Daudé [Mon, 9 Nov 2020 08:41:24 +0000 (09:41 +0100)]
target/mips: Do not include CP0 helpers in user-mode emulation

CP0 helpers are restricted to system-mode emulation.
Do not intent do build cp0_helper.c in user-mode (this
allows to simplify some #ifdef'ry).

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Huacai Chen <[email protected]>
Message-Id: <20201109090422.2445166[email protected]>

4 years agotarget/mips: Replace magic values by CP0PM_MASK or TARGET_PAGE_BITS_MIN
Philippe Mathieu-Daudé [Mon, 9 Nov 2020 08:15:41 +0000 (09:15 +0100)]
target/mips: Replace magic values by CP0PM_MASK or TARGET_PAGE_BITS_MIN

Replace magic values related to page size:

  12 -> TARGET_PAGE_BITS_MIN
  13 -> CP0PM_MASK

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Huacai Chen <[email protected]>
Message-Id: <20201109090422.2445166[email protected]>

4 years agotarget/mips: Include "exec/memattrs.h" in 'internal.h'
Philippe Mathieu-Daudé [Sat, 5 Dec 2020 17:34:15 +0000 (18:34 +0100)]
target/mips: Include "exec/memattrs.h" in 'internal.h'

mips_cpu_do_transaction_failed() requires MemTxAttrs
and MemTxResult declarations.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20201206233949.3783184[email protected]>

4 years agotarget/mips/kvm: Remove unused headers
Philippe Mathieu-Daudé [Sat, 5 Dec 2020 17:35:03 +0000 (18:35 +0100)]
target/mips/kvm: Remove unused headers

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20201206233949.3783184[email protected]>

4 years agoads7846: moves from the hw/display folder to the hw/input folder.
Gan Qixin [Sun, 15 Nov 2020 12:35:03 +0000 (20:35 +0800)]
ads7846: moves from the hw/display folder to the hw/input folder.

ads7846 is a touch-screen controller that is an input device rather
than a display device, so move it to the hw/input folder.

Signed-off-by: Gan Qixin <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Message-Id: <20201115123503.1110665[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
4 years agoCODING_STYLE.rst: Be less strict about 80 character limit
Peter Maydell [Fri, 6 Nov 2020 11:29:40 +0000 (11:29 +0000)]
CODING_STYLE.rst: Be less strict about 80 character limit

Relax the wording about line lengths a little bit; this goes with the
checkpatch changes to warn at 100 characters rather than 80.

(Compare the Linux kernel commit bdc48fa11e46f8; our coding style is
not theirs, but the rationale is good and applies to us too.)

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Message-Id: <20201106112940[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
4 years agofsdev: open brace '{' following struct go on the same line
zhouyang [Wed, 9 Dec 2020 06:07:35 +0000 (14:07 +0800)]
fsdev: open brace '{' following struct go on the same line

I found some style problems while check the code using checkpatch.pl.
This commit fixs the issue below:
ERROR: open brace '{' following struct go on the same line

Signed-off-by: zhouyang <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <20201209060735.2760943[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
4 years agohw/pci-host/pam: Replace magic number by PAM_REGIONS_COUNT definition
Philippe Mathieu-Daudé [Wed, 2 Dec 2020 13:20:38 +0000 (14:20 +0100)]
hw/pci-host/pam: Replace magic number by PAM_REGIONS_COUNT definition

While this change helps triskaidekaphobic developers, it
is a good practice to avoid magic values and using constant
definitions instead.

Introduce the PAM_REGIONS_COUNT and use it. No logical change.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Julia Suvorova <[email protected]>
Message-Id: <20201202132038.1276404[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
4 years agohw/xen: Don't use '#' flag of printf format
Xinhao Zhang [Wed, 4 Nov 2020 13:37:09 +0000 (21:37 +0800)]
hw/xen: Don't use '#' flag of printf format

Fix code style. Don't use '#' flag of printf format ('%#') in
format strings, use '0x' prefix instead

Signed-off-by: Xinhao Zhang <[email protected]>
Signed-off-by: Kai Deng <[email protected]>
Message-Id: <20201104133709.3326630[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
4 years agoMAINTAINERS: update my email address
Michael Roth [Tue, 27 Oct 2020 06:02:53 +0000 (01:02 -0500)]
MAINTAINERS: update my email address

I've recently switched employers and the current email address is out
of date.

Signed-off-by: Michael Roth <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <20201027060253[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
4 years agoqemu-options.hx: Fix minor issues in icount documentation
Peter Maydell [Sat, 21 Nov 2020 21:35:06 +0000 (21:35 +0000)]
qemu-options.hx: Fix minor issues in icount documentation

The documentation for the icount documentation has some minor issues:
 * in a couple of places it says "sleep=on|off" when in the context of the
   sentence it means specifically "sleep=on"
 * the synopsis line for the documentation has drifted out of sync
   with the synopsis line in the DEF() macro (used for "-help" output)
 * the synopsis line in the DEF() macro is missing a "][" between
   the sleep= part and the rr= part
 * the synopsis line doesn't indicate that rrsnapshot is an optional
   part of the rr=mode,rrfile=filename subgrouping
 * we don't document that sleep=on can't be used with shift=auto
   or align=on
 * the rr option description had some minor grammar and formatting
   errors and was a bit terse
 * in commit f1f4b57e88ff in 2015 the documentation of the sleep=
   suboption got added between the two paragraphs defining general
   behaviour of the icount option. This meant that the second
   paragraph talking about the behaviour of "this option" reads as
   if it's talking about sleep=on, when it's really describing -icount
   as a whole. The paragraph is better moved back up to above the
   sleep= section.
 * the summary text displayed in "-help" output didn't mention
   the record-and-replay part

Fix these errors.

Fixes: https://bugs.launchpad.net/qemu/+bug/1774412
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <20201121213506[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
4 years agotarget/i386: tracing: format length values as hex
Dov Murik [Tue, 3 Nov 2020 10:07:45 +0000 (10:07 +0000)]
target/i386: tracing: format length values as hex

Three trace events had a literal "0x" prefix but the 'len' values were
formatted in decimal base.  Keep the prefix and format the numbers as
hex, as is usually the case for length of memory regions.

Signed-off-by: Dov Murik <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <20201103100745[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
4 years agotarget/mips/kvm: Assert unreachable code is not used
Philippe Mathieu-Daudé [Wed, 29 Apr 2020 08:23:55 +0000 (10:23 +0200)]
target/mips/kvm: Assert unreachable code is not used

This code must not be used outside of KVM. Abort if it is.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Huacai Chen <[email protected]>
Acked-by: Paolo Bonzini <[email protected]>
Message-Id: <20200429082916[email protected]>

4 years agoMAINTAINERS: [email protected] -> [email protected]
Huacai Chen [Sat, 5 Dec 2020 09:22:01 +0000 (17:22 +0800)]
MAINTAINERS: [email protected] -> [email protected]

Use @kernel.org address as the main communications end point. Update the
corresponding M-entries and .mailmap (for git shortlog translation).

Signed-off-by: Huacai Chen <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <1607160121[email protected]>

4 years agoMerge remote-tracking branch 'remotes/vivier/tags/m68k-for-6.0-pull-request' into...
Peter Maydell [Sat, 12 Dec 2020 18:33:46 +0000 (18:33 +0000)]
Merge remote-tracking branch 'remotes/vivier/tags/m68k-for-6.0-pull-request' into staging

m68k pull request 20201212

Fix for Coverity CID 1421883
Fix some comment spelling errors
Add m68k vmstate

# gpg: Signature made Sat 12 Dec 2020 17:54:28 GMT
# gpg:                using RSA key CD2F75DDC8E3A4DC2E4F5173F30C38BD3F2FBE3C
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Laurent Vivier <[email protected]>" [full]
# gpg:                 aka "Laurent Vivier <[email protected]>" [full]
# gpg:                 aka "Laurent Vivier (Red Hat) <[email protected]>" [full]
# Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F  5173 F30C 38BD 3F2F BE3C

* remotes/vivier/tags/m68k-for-6.0-pull-request:
  m68k: fix some comment spelling errors
  target/m68k: Add vmstate definition for M68kCPU
  target/m68k: remove useless qregs array
  hw/m68k/q800.c: Make the GLUE chip an actual QOM device
  hw/m68k/q800: Don't connect two qemu_irqs directly to the same input

Signed-off-by: Peter Maydell <[email protected]>
4 years agom68k: fix some comment spelling errors
zhaolichang [Fri, 9 Oct 2020 06:44:43 +0000 (14:44 +0800)]
m68k: fix some comment spelling errors

I found that there are many spelling errors in the comments of qemu/target/m68k.
I used spellcheck to check the spelling errors and found some errors in the folder.

Signed-off-by: zhaolichang <[email protected]>
Reviewed-by: David Edmondson <[email protected]>
Reviewed-by: Philippe Mathieu-Daude<[email protected]>
Reviewed-by: Laurent Vivier<[email protected]>
Message-Id: <20201009064449[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
4 years agotarget/m68k: Add vmstate definition for M68kCPU
Laurent Vivier [Thu, 22 Oct 2020 20:30:00 +0000 (22:30 +0200)]
target/m68k: Add vmstate definition for M68kCPU

Signed-off-by: Laurent Vivier <[email protected]>
Message-Id: <20201022203000.1922749[email protected]>

4 years agotarget/m68k: remove useless qregs array
Laurent Vivier [Thu, 22 Oct 2020 20:29:59 +0000 (22:29 +0200)]
target/m68k: remove useless qregs array

They are unused since the target has been converted to TCG.

Fixes: e1f3808e03f7 ("Convert m68k target to TCG.")
Signed-off-by: Laurent Vivier <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <20201022203000.1922749[email protected]>

4 years agohw/m68k/q800.c: Make the GLUE chip an actual QOM device
Peter Maydell [Fri, 6 Nov 2020 23:51:09 +0000 (23:51 +0000)]
hw/m68k/q800.c: Make the GLUE chip an actual QOM device

The handling of the GLUE (General Logic Unit) device is
currently open-coded. Make this into a proper QOM device.

This minor piece of modernisation gets rid of the free
floating qemu_irq array 'pic', which Coverity points out
is technically leaked when we exit the machine init function.
(The replacement glue device is not leaked because it gets
added to the sysbus, so it's accessible via that.)

Fixes: Coverity CID 1421883
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Laurent vivier <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <20201106235109[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
4 years agohw/m68k/q800: Don't connect two qemu_irqs directly to the same input
Peter Maydell [Fri, 6 Nov 2020 23:51:08 +0000 (23:51 +0000)]
hw/m68k/q800: Don't connect two qemu_irqs directly to the same input

The q800 board code connects both of the IRQ outputs of the ESCC
to the same pic[3] qemu_irq. Connecting two qemu_irqs outputs directly
to the same input is not valid as it produces subtly wrong behaviour
(for instance if both the IRQ lines are high, and then one goes
low, the PIC input will see this as a high-to-low transition
even though the second IRQ line should still be holding it high).

This kind of wiring needs an explicitly created OR gate; add one.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Laurent Vivier <[email protected]>
Message-Id: <20201106235109[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
4 years agoMerge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Peter Maydell [Sat, 12 Dec 2020 00:20:45 +0000 (00:20 +0000)]
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging

Block layer patches:

- Support for FUSE exports
- Fix deadlock in bdrv_co_yield_to_drain()
- Use lock guard macros
- Some preparational patches for 64 bit block layer
- file-posix: Fix request extension to INT64_MAX in raw_do_pwrite_zeroes()

# gpg: Signature made Fri 11 Dec 2020 17:06:19 GMT
# gpg:                using RSA key DC3DEB159A9AF95D3D7456FE7F09B272C88F2FD6
# gpg:                issuer "[email protected]"
# 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: (34 commits)
  block: Fix deadlock in bdrv_co_yield_to_drain()
  block: Fix locking in qmp_block_resize()
  block: Simplify qmp_block_resize() error paths
  block: introduce BDRV_MAX_LENGTH
  block/io: bdrv_check_byte_request(): drop bdrv_is_inserted()
  block/io: bdrv_refresh_limits(): use ERRP_GUARD
  block/file-posix: fix workaround in raw_do_pwrite_zeroes()
  can-host: Fix crash when 'canbus' property is not set
  iotests/221: Discard image before qemu-img map
  file-posix: check the use_lock before setting the file lock
  iotests/308: Add test for FUSE exports
  iotests: Enable fuse for many tests
  iotests: Allow testing FUSE exports
  iotests: Give access to the qemu-storage-daemon
  storage-daemon: Call bdrv_close_all() on exit
  iotests/287: Clean up subshell test image
  iotests: Let _make_test_img guess $TEST_IMG_FILE
  iotests: Restrict some Python tests to file
  iotests/091: Use _cleanup_qemu instad of "wait"
  iotests: Derive image names from $TEST_IMG
  ...

Signed-off-by: Peter Maydell <[email protected]>
4 years agoMerge remote-tracking branch 'remotes/cohuck/tags/s390x-20201211' into staging
Peter Maydell [Fri, 11 Dec 2020 22:22:50 +0000 (22:22 +0000)]
Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20201211' into staging

First set of 6.0 patches for s390x:
- acceptance test for device detection
- bugfixes

# gpg: Signature made Fri 11 Dec 2020 12:21:45 GMT
# gpg:                using RSA key C3D0D66DC3624FF6A8C018CEDECF6B93C6F02FAF
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Cornelia Huck <[email protected]>" [unknown]
# gpg:                 aka "Cornelia Huck <[email protected]>" [full]
# gpg:                 aka "Cornelia Huck <[email protected]>" [full]
# gpg:                 aka "Cornelia Huck <[email protected]>" [unknown]
# gpg:                 aka "Cornelia Huck <[email protected]>" [unknown]
# Primary key fingerprint: C3D0 D66D C362 4FF6 A8C0  18CE DECF 6B93 C6F0 2FAF

* remotes/cohuck/tags/s390x-20201211:
  s390x/cpu: Use timer_free() in the finalize function to avoid memleaks
  tests/acceptance: test s390x zpci fid propagation
  tests/acceptance: verify s390x device detection
  tests/acceptance: test virtio-ccw revision handling
  tests/acceptance: add a test for devices on s390x
  hw/watchdog/wdt_diag288: Remove unnecessary includes

Signed-off-by: Peter Maydell <[email protected]>
4 years agoMerge remote-tracking branch 'remotes/kraxel/tags/ui-20201211-pull-request' into...
Peter Maydell [Fri, 11 Dec 2020 16:55:52 +0000 (16:55 +0000)]
Merge remote-tracking branch 'remotes/kraxel/tags/ui-20201211-pull-request' into staging

ui/console ui_info tweaks.
ui/vnc: alpha cursor support.
ui/vnc: locking fixes.
ui/sdl: add extra mouse buttons.

# gpg: Signature made Fri 11 Dec 2020 09:12:39 GMT
# gpg:                using RSA key 4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <[email protected]>" [full]
# gpg:                 aka "Gerd Hoffmann <[email protected]>" [full]
# gpg:                 aka "Gerd Hoffmann (private) <[email protected]>" [full]
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* remotes/kraxel/tags/ui-20201211-pull-request:
  sdl2: Add extra mouse buttons
  ui/vnc: Add missing lock for send_color_map
  vnc: add alpha cursor support
  vnc: add pseudo encodings
  vnc: drop unused copyrect feature
  vnc: use enum for features
  console: allow con==NULL in dpy_{get, set}_ui_info and dpy_ui_info_supported
  console: drop qemu_console_get_ui_info

Signed-off-by: Peter Maydell <[email protected]>
4 years agoblock: Fix deadlock in bdrv_co_yield_to_drain()
Kevin Wolf [Thu, 3 Dec 2020 17:23:11 +0000 (18:23 +0100)]
block: Fix deadlock in bdrv_co_yield_to_drain()

If bdrv_co_yield_to_drain() is called for draining a block node that
runs in a different AioContext, it keeps that AioContext locked while it
yields and schedules a BH in the AioContext to do the actual drain.

As long as executing the BH is the very next thing that the event loop
of the node's AioContext does, this actually happens to work, but when
it tries to execute something else that wants to take the AioContext
lock, it will deadlock. (In the bug report, this other thing is a
virtio-scsi device running virtio_scsi_data_plane_handle_cmd().)

Instead, always drop the AioContext lock across the yield and reacquire
it only when the coroutine is reentered. The BH needs to unconditionally
take the lock for itself now.

This fixes the 'block_resize' QMP command on a block node that runs in
an iothread.

Cc: [email protected]
Fixes: eb94b81a94bce112e6b206df846c1551aaf6cab6
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1903511
Signed-off-by: Kevin Wolf <[email protected]>
Message-Id: <20201203172311[email protected]>
Reviewed-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agoblock: Fix locking in qmp_block_resize()
Kevin Wolf [Thu, 3 Dec 2020 17:23:10 +0000 (18:23 +0100)]
block: Fix locking in qmp_block_resize()

The drain functions assume that we hold the AioContext lock of the
drained block node. Make sure to actually take the lock.

Cc: [email protected]
Fixes: eb94b81a94bce112e6b206df846c1551aaf6cab6
Signed-off-by: Kevin Wolf <[email protected]>
Message-Id: <20201203172311[email protected]>
Reviewed-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agoblock: Simplify qmp_block_resize() error paths
Kevin Wolf [Thu, 3 Dec 2020 17:23:09 +0000 (18:23 +0100)]
block: Simplify qmp_block_resize() error paths

The only thing that happens after the 'out:' label is blk_unref(blk).
However, blk = NULL in all of the error cases, so instead of jumping to
'out:', we can just return directly.

Cc: [email protected]
Signed-off-by: Kevin Wolf <[email protected]>
Message-Id: <20201203172311[email protected]>
Reviewed-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agoblock: introduce BDRV_MAX_LENGTH
Vladimir Sementsov-Ogievskiy [Thu, 3 Dec 2020 22:27:13 +0000 (01:27 +0300)]
block: introduce BDRV_MAX_LENGTH

We are going to modify block layer to work with 64bit requests. And
first step is moving to int64_t type for both offset and bytes
arguments in all block request related functions.

It's mostly safe (when widening signed or unsigned int to int64_t), but
switching from uint64_t is questionable.

So, let's first establish the set of requests we want to work with.
First signed int64_t should be enough, as off_t is signed anyway. Then,
obviously offset + bytes should not overflow.

And most interesting: (offset + bytes) being aligned up should not
overflow as well. Aligned to what alignment? First thing that comes in
mind is bs->bl.request_alignment, as we align up request to this
alignment. But there is another thing: look at
bdrv_mark_request_serialising(). It aligns request up to some given
alignment. And this parameter may be bdrv_get_cluster_size(), which is
often a lot greater than bs->bl.request_alignment.
Note also, that bdrv_mark_request_serialising() uses signed int64_t for
calculations. So, actually, we already depend on some restrictions.

Happily, bdrv_get_cluster_size() returns int and
bs->bl.request_alignment has 32bit unsigned type, but defined to be a
power of 2 less than INT_MAX. So, we may establish, that INT_MAX is
absolute maximum for any kind of alignment that may occur with the
request.

Note, that bdrv_get_cluster_size() is not documented to return power
of 2, still bdrv_mark_request_serialising() behaves like it is.
Also, backup uses bdi.cluster_size and is not prepared to it not being
power of 2.
So, let's establish that Qemu supports only power-of-2 clusters and
alignments.

So, alignment can't be greater than 2^30.

Finally to be safe with calculations, to not calculate different
maximums for different nodes (depending on cluster size and
request_alignment), let's simply set QEMU_ALIGN_DOWN(INT64_MAX, 2^30)
as absolute maximum bytes length for Qemu. Actually, it's not much less
than INT64_MAX.

OK, then, let's apply it to block/io.

Let's consider all block/io entry points of offset/bytes:

4 bytes/offset interface functions: bdrv_co_preadv_part(),
bdrv_co_pwritev_part(), bdrv_co_copy_range_internal() and
bdrv_co_pdiscard() and we check them all with bdrv_check_request().

We also have one entry point with only offset: bdrv_co_truncate().
Check the offset.

And one public structure: BdrvTrackedRequest. Happily, it has only
three external users:

 file-posix.c: adopted by this patch
 write-threshold.c: only read fields
 test-write-threshold.c: sets obviously small constant values

Better is to make the structure private and add corresponding
interfaces.. Still it's not obvious what kind of interface is needed
for file-posix.c. Let's keep it public but add corresponding
assertions.

After this patch we'll convert functions in block/io.c to int64_t bytes
and offset parameters. We can assume that offset/bytes pair always
satisfy new restrictions, and make
corresponding assertions where needed. If we reach some offset/bytes
point in block/io.c missing bdrv_check_request() it is considered a
bug. As well, if block/io.c modifies a offset/bytes request, expanding
it more then aligning up to request_alignment, it's a bug too.

For all io requests except for discard we keep for now old restriction
of 32bit request length.

iotest 206 output error message changed, as now test disk size is
larger than new limit. Add one more test case with new maximum disk
size to cover too-big-L1 case.

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Message-Id: <20201203222713[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agoblock/io: bdrv_check_byte_request(): drop bdrv_is_inserted()
Vladimir Sementsov-Ogievskiy [Thu, 3 Dec 2020 22:27:12 +0000 (01:27 +0300)]
block/io: bdrv_check_byte_request(): drop bdrv_is_inserted()

Move bdrv_is_inserted() calls into callers.

We are going to make bdrv_check_byte_request() a clean thing.
bdrv_is_inserted() is not about checking the request, it's about
checking the bs. So, it should be separate.

With this patch we probably change error path for some failure
scenarios. But depending on the fact that querying too big request on
empty cdrom (or corrupted qcow2 node with no drv) will result in EIO
and not ENOMEDIUM would be very strange. More over, we are going to
move to 64bit requests, so larger requests will be allowed anyway.

More over, keeping in mind that cdrom is the only driver that has
.bdrv_is_inserted() handler it's strange that we should care so much
about it in generic block layer, intuitively we should just do read and
write, and cdrom driver should return correct errors if it is not
inserted. But it's a work for another series.

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Message-Id: <20201203222713[email protected]>
Reviewed-by: Alberto Garcia <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agoblock/io: bdrv_refresh_limits(): use ERRP_GUARD
Vladimir Sementsov-Ogievskiy [Thu, 3 Dec 2020 22:27:11 +0000 (01:27 +0300)]
block/io: bdrv_refresh_limits(): use ERRP_GUARD

This simplifies following commit.

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Message-Id: <20201203222713[email protected]>
Reviewed-by: Alberto Garcia <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agoblock/file-posix: fix workaround in raw_do_pwrite_zeroes()
Vladimir Sementsov-Ogievskiy [Thu, 3 Dec 2020 22:27:10 +0000 (01:27 +0300)]
block/file-posix: fix workaround in raw_do_pwrite_zeroes()

We should not set overlap_bytes:

1. Don't worry: it is calculated by bdrv_mark_request_serialising() and
   will be equal to or greater than bytes anyway.

2. If the request was already aligned up to some greater alignment,
   than we may break things: we reduce overlap_bytes, and further
   bdrv_mark_request_serialising() may not help, as it will not restore
   old bigger alignment.

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Message-Id: <20201203222713[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agocan-host: Fix crash when 'canbus' property is not set
Kevin Wolf [Mon, 30 Nov 2020 10:56:15 +0000 (11:56 +0100)]
can-host: Fix crash when 'canbus' property is not set

Providing the 'if' property, but not 'canbus' segfaults like this:

 #0  0x0000555555b0f14d in can_bus_insert_client (bus=0x0, client=0x555556aa9af0) at ../net/can/can_core.c:88
 #1  0x00005555559c3803 in can_host_connect (ch=0x555556aa9ac0, errp=0x7fffffffd568) at ../net/can/can_host.c:62
 #2  0x00005555559c386a in can_host_complete (uc=0x555556aa9ac0, errp=0x7fffffffd568) at ../net/can/can_host.c:72
 #3  0x0000555555d52de9 in user_creatable_complete (uc=0x555556aa9ac0, errp=0x7fffffffd5c8) at ../qom/object_interfaces.c:23

Add the missing NULL check.

Signed-off-by: Kevin Wolf <[email protected]>
Message-Id: <20201130105615[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agoiotests/221: Discard image before qemu-img map
Max Reitz [Mon, 7 Dec 2020 15:22:45 +0000 (16:22 +0100)]
iotests/221: Discard image before qemu-img map

See the new comment for why this should be done.

I do not have a reproducer on master, but when using FUSE block exports,
this test breaks depending on the underlying filesystem (for me, it
works on tmpfs, but fails on xfs, because the block allocated by
file-posix has 16 kB there instead of 4 kB).

Suggested-by: Kevin Wolf <[email protected]>
Signed-off-by: Max Reitz <[email protected]>
Message-Id: <20201207152245[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agofile-posix: check the use_lock before setting the file lock
Li Feng [Mon, 7 Dec 2020 11:44:06 +0000 (19:44 +0800)]
file-posix: check the use_lock before setting the file lock

The scenario is that when accessing a volume on an NFS filesystem
without supporting the file lock,  Qemu will complain "Failed to lock
byte 100", even when setting the file.locking = off.

We should do file lock related operations only when the file.locking is
enabled, otherwise, the syscall of 'fcntl' will return non-zero.

Signed-off-by: Li Feng <[email protected]>
Message-Id: <1607341446[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agoiotests/308: Add test for FUSE exports
Max Reitz [Tue, 27 Oct 2020 19:06:00 +0000 (20:06 +0100)]
iotests/308: Add test for FUSE exports

We have good coverage of the normal I/O paths now, but what remains is a
test that tests some more special cases: Exporting an image on itself
(thus turning a formatted image into a raw one), some error cases, and
non-writable and non-growable exports.

Signed-off-by: Max Reitz <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Message-Id: <20201027190600[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agoiotests: Enable fuse for many tests
Max Reitz [Tue, 27 Oct 2020 19:05:59 +0000 (20:05 +0100)]
iotests: Enable fuse for many tests

Many tests (that do not support generic protocols) can run just fine
with FUSE-exported images, so allow them to.  Note that this is no
attempt at being definitely complete.  There are some tests that might
be modified to run on FUSE, but this patch still skips them.  This patch
only tries to pick the rather low-hanging fruits.

Note that 221 and 250 only pass when .lseek is correctly implemented,
which is only possible with a libfuse that is 3.8 or newer.

Signed-off-by: Max Reitz <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Message-Id: <20201027190600[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agoiotests: Allow testing FUSE exports
Max Reitz [Tue, 27 Oct 2020 19:05:58 +0000 (20:05 +0100)]
iotests: Allow testing FUSE exports

This pretends FUSE exports are a kind of protocol.  As such, they are
always tested under the format node.  This is probably the best way to
test them, actually, because this will generate more I/O load and more
varied patterns.

Signed-off-by: Max Reitz <[email protected]>
Message-Id: <20201027190600[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agoiotests: Give access to the qemu-storage-daemon
Max Reitz [Tue, 27 Oct 2020 19:05:57 +0000 (20:05 +0100)]
iotests: Give access to the qemu-storage-daemon

Signed-off-by: Max Reitz <[email protected]>
Message-Id: <20201027190600[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agostorage-daemon: Call bdrv_close_all() on exit
Max Reitz [Tue, 27 Oct 2020 19:05:56 +0000 (20:05 +0100)]
storage-daemon: Call bdrv_close_all() on exit

Otherwise, exports and block devices are not properly shut down and
closed, unless the users explicitly issues blockdev-del and
block-export-del commands for each of them.

Signed-off-by: Max Reitz <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Message-Id: <20201027190600[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agoiotests/287: Clean up subshell test image
Max Reitz [Tue, 27 Oct 2020 19:05:55 +0000 (20:05 +0100)]
iotests/287: Clean up subshell test image

287 creates an image in a subshell (thanks to the pipe) to see whether
that is possible with compression_type=zstd.  If _make_test_img were to
modify any global state, this global state would then be lost before we
could cleanup the image.

When using FUSE as the test protocol, this global state is important, so
clean up the image before the state is lost.

Signed-off-by: Max Reitz <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Message-Id: <20201027190600[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agoiotests: Let _make_test_img guess $TEST_IMG_FILE
Max Reitz [Tue, 27 Oct 2020 19:05:54 +0000 (20:05 +0100)]
iotests: Let _make_test_img guess $TEST_IMG_FILE

When most iotests want to create a test image that is named differently
from the default $TEST_IMG, they do something like this:

    TEST_IMG="$TEST_IMG.base" _make_test_img $options

This works fine with the "file" protocol, but not so much for anything
else: _make_test_img tries to create an image under $TEST_IMG_FILE
first, and only under $TEST_IMG if the former is not set; and on
everything but "file", $TEST_IMG_FILE is set.

There are two ways we can fix this: First, we could make all tests
adjust not only TEST_IMG, but also TEST_IMG_FILE if that is present
(e.g. with something like _set_test_img_suffix $suffix that would affect
not only TEST_IMG but also TEST_IMG_FILE, if necessary).  This is a
pretty clean solution, and this is maybe what we should have done from
the start.

But it would also require changes to most existing bash tests.  So the
alternative is this: Let _make_test_img see whether $TEST_IMG_FILE still
points to the original value.  If so, it is possible that the caller has
adjusted $TEST_IMG but not $TEST_IMG_FILE.  In such a case, we can (for
most protocols) derive the corresponding $TEST_IMG_FILE value from
$TEST_IMG value and thus work around what technically is the caller
misbehaving.

This second solution is less clean, but it is robust against people
keeping their old habit of adjusting TEST_IMG only, and requires much
less changes.  So this patch implements it.

Signed-off-by: Max Reitz <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Message-Id: <20201027190600[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agoiotests: Restrict some Python tests to file
Max Reitz [Tue, 27 Oct 2020 19:05:53 +0000 (20:05 +0100)]
iotests: Restrict some Python tests to file

Most Python tests are restricted to the file protocol (without
explicitly saying so), but these are the ones that would break
./check -fuse -qcow2.

Signed-off-by: Max Reitz <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Message-Id: <20201027190600[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agoiotests/091: Use _cleanup_qemu instad of "wait"
Max Reitz [Tue, 27 Oct 2020 19:05:52 +0000 (20:05 +0100)]
iotests/091: Use _cleanup_qemu instad of "wait"

If the test environment has some other child processes running (like a
storage daemon that provides a FUSE export), then "wait" will never
finish.  Use wait=yes _cleanup_qemu instead.

(We need to discard the output so there is no change to the reference
output.)

Signed-off-by: Max Reitz <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Message-Id: <20201027190600[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agoiotests: Derive image names from $TEST_IMG
Max Reitz [Tue, 27 Oct 2020 19:05:51 +0000 (20:05 +0100)]
iotests: Derive image names from $TEST_IMG

Avoid creating images with custom filenames in $TEST_DIR, because
non-file protocols may want to keep $TEST_IMG (and all other test
images) in some other directory.

Signed-off-by: Max Reitz <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Message-Id: <20201027190600[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agoiotests/046: Avoid renaming images
Max Reitz [Tue, 27 Oct 2020 19:05:50 +0000 (20:05 +0100)]
iotests/046: Avoid renaming images

This generally does not work on non-file protocols.  It is better to
create the image with the final name from the start, and most tests do
this already.  Let 046 follow suit.

Signed-off-by: Max Reitz <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Message-Id: <20201027190600[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agoiotests: Use convert -n in some cases
Max Reitz [Tue, 27 Oct 2020 19:05:49 +0000 (20:05 +0100)]
iotests: Use convert -n in some cases

qemu-img convert (without -n) can often be replaced by a combination of
_make_test_img + qemu-img convert -n.  Doing so allows converting to
protocols that do not allow direct file creation, such as FUSE exports.
The only problem is that for formats other than qcow2 and qed (qcow1 at
least), this may lead to high disk usage for some reason, so we cannot
do it everywhere.

But we can do it in 028 and 089, so let us do that so they can run on
FUSE exports.  Also, in 028 this allows us to remove a 9-line comment
that used to explain why we cannot safely filter drive-backup's image
creation output.

Signed-off-by: Max Reitz <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Message-Id: <20201027190600[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agoiotests: Do not pipe _make_test_img
Max Reitz [Tue, 27 Oct 2020 19:05:48 +0000 (20:05 +0100)]
iotests: Do not pipe _make_test_img

Executing _make_test_img as part of a pipe will undo all variable
changes it has done.  As such, this could not work with FUSE (because
we want to remember all of our exports and their qemu instances).

Replace the pipe by a temporary file in 071 and 174 (the two tests that
can run on FUSE).

Signed-off-by: Max Reitz <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Message-Id: <20201027190600[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agoiotests: Do not needlessly filter _make_test_img
Max Reitz [Tue, 27 Oct 2020 19:05:47 +0000 (20:05 +0100)]
iotests: Do not needlessly filter _make_test_img

In most cases, _make_test_img does not need a _filter_imgfmt on top.  It
does that by itself.

(The exception is when IMGFMT has been overwritten but TEST_IMG has not.
In such cases, we do need a _filter_imgfmt on top to filter the test's
original IMGFMT from TEST_IMG.)

Signed-off-by: Max Reitz <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Message-Id: <20201027190600[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agofuse: Implement hole detection through lseek
Max Reitz [Tue, 27 Oct 2020 19:05:46 +0000 (20:05 +0100)]
fuse: Implement hole detection through lseek

This is a relatively new feature in libfuse (available since 3.8.0,
which was released in November 2019), so we have to add a dedicated
check whether it is available before making use of it.

Signed-off-by: Max Reitz <[email protected]>
Message-Id: <20201027190600[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agofuse: (Partially) implement fallocate()
Max Reitz [Tue, 27 Oct 2020 19:05:45 +0000 (20:05 +0100)]
fuse: (Partially) implement fallocate()

This allows allocating areas after the (old) EOF as part of a growing
resize, writing zeroes, and discarding.

Signed-off-by: Max Reitz <[email protected]>
Message-Id: <20201027190600[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agofuse: Allow growable exports
Max Reitz [Tue, 27 Oct 2020 19:05:44 +0000 (20:05 +0100)]
fuse: Allow growable exports

These will behave more like normal files in that writes beyond the EOF
will automatically grow the export size.

As an optimization, keep the RESIZE permission for growable exports so
we do not have to take it for every post-EOF write.  (This permission is
not released when the export is destroyed, because at that point the
BlockBackend is destroyed altogether anyway.)

Signed-off-by: Max Reitz <[email protected]>
Message-Id: <20201027190600[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agofuse: Implement standard FUSE operations
Max Reitz [Tue, 27 Oct 2020 19:05:43 +0000 (20:05 +0100)]
fuse: Implement standard FUSE operations

This makes the export actually useful instead of only producing errors
whenever it is accessed.

Signed-off-by: Max Reitz <[email protected]>
Message-Id: <20201027190600[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agofuse: Allow exporting BDSs via FUSE
Max Reitz [Tue, 27 Oct 2020 19:05:42 +0000 (20:05 +0100)]
fuse: Allow exporting BDSs via FUSE

block-export-add type=fuse allows mounting block graph nodes via FUSE on
some existing regular file.  That file should then appears like a raw
disk image, and accesses to it result in accesses to the exported BDS.

Right now, we only implement the necessary block export functions to set
it up and shut it down.  We do not implement any access functions, so
accessing the mount point only results in errors.  This will be
addressed by a followup patch.

We keep a hash table of exported mount points, because we want to be
able to detect when users try to use a mount point twice.  This is
because we invoke stat() to check whether the given mount point is a
regular file, but if that file is served by ourselves (because it is
already used as a mount point), then this stat() would have to be served
by ourselves, too, which is impossible to do while we (as the caller)
are waiting for it to settle.  Therefore, keep track of mount point
paths to at least catch the most obvious instances of that problem.

Signed-off-by: Max Reitz <[email protected]>
Message-Id: <20201027190600[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agomeson: Detect libfuse
Max Reitz [Tue, 27 Oct 2020 19:05:41 +0000 (20:05 +0100)]
meson: Detect libfuse

Signed-off-by: Max Reitz <[email protected]>
Message-Id: <20201027190600[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agoblock/iscsi: Use lock guard macros
Gan Qixin [Thu, 3 Dec 2020 07:50:55 +0000 (15:50 +0800)]
block/iscsi: Use lock guard macros

Replace manual lock()/unlock() calls with lock guard macros
(QEMU_LOCK_GUARD/WITH_QEMU_LOCK_GUARD) in block/iscsi.

Signed-off-by: Gan Qixin <[email protected]>
Message-Id: <20201203075055[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agoblock/throttle-groups: Use lock guard macros
Gan Qixin [Thu, 3 Dec 2020 07:50:54 +0000 (15:50 +0800)]
block/throttle-groups: Use lock guard macros

Replace manual lock()/unlock() calls with lock guard macros
(QEMU_LOCK_GUARD/WITH_QEMU_LOCK_GUARD) in block/throttle-groups.

Signed-off-by: Gan Qixin <[email protected]>
Message-Id: <20201203075055[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agoblock/curl: Use lock guard macros
Gan Qixin [Thu, 3 Dec 2020 07:50:53 +0000 (15:50 +0800)]
block/curl: Use lock guard macros

Replace manual lock()/unlock() calls with lock guard macros
(QEMU_LOCK_GUARD/WITH_QEMU_LOCK_GUARD) in block/curl.

Signed-off-by: Gan Qixin <[email protected]>
Reviewed-by: Paolo Bonzini <[email protected]>
Message-Id: <20201203075055[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agoblock/accounting: Use lock guard macros
Gan Qixin [Thu, 3 Dec 2020 07:50:52 +0000 (15:50 +0800)]
block/accounting: Use lock guard macros

Replace manual lock()/unlock() calls with lock guard macros
(QEMU_LOCK_GUARD/WITH_QEMU_LOCK_GUARD) in block/accounting.

Signed-off-by: Gan Qixin <[email protected]>
Reviewed-by: Paolo Bonzini <[email protected]>
Message-Id: <20201203075055[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
4 years agoMerge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20201210' into staging
Peter Maydell [Fri, 11 Dec 2020 15:01:05 +0000 (15:01 +0000)]
Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20201210' into staging

Split CpusAccel for tcg variants

# gpg: Signature made Fri 11 Dec 2020 01:07:33 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-gitlab/tags/pull-tcg-20201210:
  accel/tcg: rename tcg-cpus functions to match module name
  accel/tcg: split tcg_start_vcpu_thread
  accel/tcg: split CpusAccel into three TCG variants

Signed-off-by: Peter Maydell <[email protected]>
This page took 0.098685 seconds and 4 git commands to generate.