Mathieu Poirier [Tue, 12 Oct 2021 20:59:02 +0000 (14:59 -0600)]
vhost-user-rng: Add vhost-user-rng implementation
Introduce a random number generator (RNG) backend that communicates
with a vhost-user server to retrieve entropy. That way other VMM
that comply with the vhost user protocl can use the same vhost-user
daemon without having to write yet another RNG driver.
We end up not copying the mmap_addr of all existing regions, resulting
in a SEGFAULT once we actually try to map/access anything within our
memory regions.
Eugenio Pérez [Thu, 14 Oct 2021 14:12:34 +0000 (16:12 +0200)]
vdpa: Skip protected ram IOMMU mappings
Following the logic of commit 56918a126ae ("memory: Add RAM_PROTECTED
flag to skip IOMMU mappings") with VFIO, skip memory sections
inaccessible via normal mechanisms, including DMA.
Igor Mammedov [Thu, 2 Sep 2021 11:35:41 +0000 (07:35 -0400)]
tests: acpi: update expected tables blobs
Update adds CPU entries to MADT/SRAT/FACP and DSDT to cover 288 CPUs.
Notable changes are that CPUs with APIC ID 255 and higher
use 'Processor Local x2APIC Affinity' structure in SRAT and
"Device" element in DSDT.
FACP:
- Use APIC Cluster Model (V4) : 0
+ Use APIC Cluster Model (V4) : 1
Igor Mammedov [Thu, 2 Sep 2021 11:35:38 +0000 (07:35 -0400)]
tests: qtest: add qtest_has_accel() to check if tested binary supports accelerator
Currently it is not possible to create tests that have KVM as a hard
requirement on a host that doesn't support KVM for tested target
binary (modulo going through the trouble of compiling out
the offending test case).
Following scenario makes test fail when it's run on non x86 host:
qemu-system-x86_64 -enable-kvm -M q35,kernel-irqchip=on -smp 1,maxcpus=288
This patch introduces qtest_has_accel() to let users check if accel is
available in advance and avoid executing non run-able test-cases.
It implements detection of TCG and KVM only, the rest could be
added later on, when we actually start testing them in qtest.
* remotes/juanquintela/tags/migration.next-pull-request:
migration/rdma: advise prefetch write for ODP region
migration/rdma: Try to register On-Demand Paging memory region
migration: allow enabling mutilfd for specific protocol only
migration: allow multifd for socket protocol only
migration/ram: Don't passs RAMState to migration_clear_memory_region_dirty_bitmap_*()
multifd: Unconditionally unregister yank function
multifd: Implement yank for multifd send side
Li Zhijian [Fri, 10 Sep 2021 07:02:55 +0000 (15:02 +0800)]
migration/rdma: advise prefetch write for ODP region
The responder mr registering with ODP will sent RNR NAK back to
the requester in the face of the page fault.
---------
ibv_poll_cq wc.status=13 RNR retry counter exceeded!
ibv_poll_cq wrid=WRITE RDMA!
---------
ibv_advise_mr(3) helps to make pages present before the actual IO is
conducted so that the responder does page fault as little as possible.
Li Zhijian [Fri, 10 Sep 2021 07:02:54 +0000 (15:02 +0800)]
migration/rdma: Try to register On-Demand Paging memory region
Previously, for the fsdax mem-backend-file, it will register failed with
Operation not supported. In this case, we can try to register it with
On-Demand Paging[1] like what rpma_mr_reg() does on rpma[2].
multifd with unsupported protocol will cause a segment fault.
(gdb) bt
#0 0x0000563b4a93faf8 in socket_connect (addr=0x0, errp=0x7f7f02675410) at ../util/qemu-sockets.c:1190
#1 0x0000563b4a797a03 in qio_channel_socket_connect_sync
(ioc=0x563b4d16e8c0, addr=0x0, errp=0x7f7f02675410) at
../io/channel-socket.c:145
#2 0x0000563b4a797abf in qio_channel_socket_connect_worker (task=0x563b4cd86c30, opaque=0x0) at ../io/channel-socket.c:168
#3 0x0000563b4a792631 in qio_task_thread_worker (opaque=0x563b4cd86c30) at ../io/task.c:124
#4 0x0000563b4a91da69 in qemu_thread_start (args=0x563b4c44bb80) at ../util/qemu-thread-posix.c:541
#5 0x00007f7fe9b5b3f9 in ?? ()
#6 0x0000000000000000 in ?? ()
It's enough to check migrate_multifd_is_allowed() in multifd cleanup() and
multifd setup() though there are so many other places using migrate_use_multifd().
[[PGP Signed Part:No public key for 35AB0B289C5DB258 created at 2021-08-04T21:26:32+0200 using RSA]]
Unconditionally unregister yank function in multifd_load_cleanup().
If it is not unregistered here, it will leak and cause a crash
in yank_unregister_instance(). Now if the ioc is still in use
afterwards, it will only lead to qemu not being able to recover
from a hang related to that ioc.
After checking the code, i am pretty sure that ref is always 1
when arriving here. So all this currently does is remove the
unneeded check.
[[PGP Signed Part:No public key for 35AB0B289C5DB258 created at 2021-09-01T17:58:57+0200 using RSA]]
When introducing yank functionality in the migration code I forgot
to cover the multifd send side.
Merge remote-tracking branch 'remotes/bsdimp/tags/pull-bsd-user-20211018-pull-request' into staging
bsd-user pull request: merge dependencies for next architectures
Merge the dependencies for arm, aarch64, and riscv64 architectures. This joins
together two patch series:
[PATCH v2 00/15] bsd-user: misc cleanup for aarch64 import
Prepare for aarch64 support (the next architecture to be upstreamed). As the
aarch64 emulation is more complete, it relies on a number of different items.
In some cases, I've pulled in the full support from bsd-user fork. In other
cases I've created a simple stub (as is the case for signals, which have
independent changes pending, so I wanted to be as minimal as possible. Since
all pre-12.2 support was purged from the bsd-user fork, go ahead and remove it
here. FreeBSD 11.x goes ouft of support at the end of the month. Remove what
little multi-version support that's in upstream.
and
[PATCH v3 0/9] bsd-user mmap fixes
This series synchronizes mmap.c with the bsd-user fork. This is a mix of old bug
fixes pulled in from linux-user, as well as some newer fixes to adress bugs
found in check-tcg and recent FreeBSD developments. There are also a couple of
style commits. Updated to migrate debugging to qemu_log.
as well as a couple of minor rebase tweaks. In addition, the next two
architectures I plan on upstreaming (arm and riscv64) also have their prereqs
satisfied with this request.
v2: Remove accidental module regression in patch 7 and try again.
# gpg: Signature made Mon 18 Oct 2021 12:00:28 PM PDT
# gpg: using RSA key 2035F894B00AA3CF7CCDE1B76C1CD1287DB01100
# gpg: Good signature from "Warner Losh <[email protected]>" [unknown]
# gpg: aka "Warner Losh <[email protected]>" [unknown]
# gpg: aka "Warner Losh <[email protected]>" [unknown]
# gpg: aka "Warner Losh <[email protected]>" [unknown]
# gpg: aka "Warner Losh <[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: 2035 F894 B00A A3CF 7CCD E1B7 6C1C D128 7DB0 1100
* remotes/bsdimp/tags/pull-bsd-user-20211018-pull-request: (23 commits)
bsd-user/signal: Create a dummy signal queueing function
bsd-user: Rename sigqueue to qemu_sigqueue
bsd-user/sysarch: Move to using do_freebsd_arch_sysarch interface
bsd-user: Add stop_all_tasks
bsd-user: Remove used from TaskState
bsd-user/target_os_elf: If ELF_HWCAP2 is defined, publish it
bsd-user/target_os_elf.h: Remove fallback ELF_HWCAP and reorder
bsd-user: move TARGET_MC_GET_CLEAR_RET to target_os_signal.h
bsd-user/errno_defs.h: Add internal error numbers
bsd-user: export get_errno and is_error from syscall.c
bsd-user: TARGET_RESET define is unused, remove it
bsd-user/strace.list: Remove support for FreeBSD versions older than 12.0
bsd-user/target_os-user.h: Remove support for FreeBSD older than 12.0
meson: *-user: only descend into *-user when configured
bsd-user/mmap.c: assert that target_mprotect cannot fail
bsd-user/mmap.c: Implement MAP_EXCL, required by jemalloc in head
bsd-user/mmap.c: Don't mmap fd == -1 independently from MAP_ANON flag
bsd-user/mmap.c: Convert to qemu_log logging for mmap debugging
bsd-user/mmap.c: mmap prefer MAP_ANON for BSD
bsd-user/mmap.c: mmap return ENOMEM on overflow
...
Warner Losh [Tue, 21 Sep 2021 22:20:52 +0000 (16:20 -0600)]
bsd-user/signal: Create a dummy signal queueing function
Create dummy signal queueing function so we can start to integrate other
architectures (at the cost of signals remaining broken) to tame the
dependency graph a bit and to bring in signals in a more controlled
fashion. Log unimplemented events to it in the mean time.
Warner Losh [Mon, 20 Sep 2021 19:56:06 +0000 (13:56 -0600)]
bsd-user: Rename sigqueue to qemu_sigqueue
To avoid a name clash with FreeBSD's sigqueue data structure in
signalvar.h, rename sigqueue to qemu_sigqueue. This structure
is currently defined, but unused.
Warner Losh [Mon, 20 Sep 2021 19:41:38 +0000 (13:41 -0600)]
bsd-user/sysarch: Move to using do_freebsd_arch_sysarch interface
do_freebsd_arch_sysarch() exists in $ARCH/target_arch_sysarch.h for x86.
Call it from do_freebsd_sysarch() and remove the mostly duplicate
version in syscall.c. Future changes will move it to os-sys.c and
support other architectures.
Warner Losh [Sat, 18 Sep 2021 15:38:11 +0000 (09:38 -0600)]
bsd-user/target_os_elf: If ELF_HWCAP2 is defined, publish it
Some architectures publish AT_HWCAP2 as well as AT_HWCAP. Those
architectures will define ELF_HWCAP2 in their target_arch_elf.h files
for the value for this process. If it is defined, then publish it.
Warner Losh [Fri, 8 Oct 2021 22:47:37 +0000 (16:47 -0600)]
meson: *-user: only descend into *-user when configured
To increase flexibility, only descend into *-user when that is
configured. This allows *-user to selectively include directories based
on the host OS which may not exist on all hosts. Adopt Paolo's
suggestion of checking the configuration in the directories that know
about the configuration.
Warner Losh [Fri, 17 Sep 2021 15:16:54 +0000 (09:16 -0600)]
bsd-user/mmap.c: assert that target_mprotect cannot fail
Similar to the equivalent linux-user change 86abac06c14. All error
conditions that target_mprotect checks are also checked by target_mmap.
EACCESS cannot happen because we are just removing PROT_WRITE. ENOMEM
should not happen because we are modifying a whole VMA (and we have
bigger problems anyway if it happens).
Fixes a Coverity false positive, where Coverity complains about
target_mprotect's return value being passed to tb_invalidate_phys_range.
Kyle Evans [Thu, 8 Nov 2018 20:39:47 +0000 (14:39 -0600)]
bsd-user/mmap.c: Implement MAP_EXCL, required by jemalloc in head
jemalloc requires a working MAP_EXCL. Ensure that no page is double
mapped when specified. In addition, use guest_range_valid_untagged to
test for valid ranges of pages rather than an incomplete inlined version
of the test that might be wrong.
Warner Losh [Mon, 18 Oct 2021 18:51:17 +0000 (12:51 -0600)]
bsd-user/mmap.c: Don't mmap fd == -1 independently from MAP_ANON flag
Switch checks for !(flags & MAP_ANONYMOUS) with checks for fd != -1.
MAP_STACK and MAP_GUARD both require fd == -1 and don't require mapping
the fd either. Add analysis from Guy Yur detailing the different cases
for MAP_GUARD and MAP_STACK.
* remotes/philmd/tags/mips-20211018:
via-ide: Avoid using isa_get_irq()
vt82c686: Add a method to VIA_ISA to raise ISA interrupts
vt82c686: Move common code to via_isa_realize
via-ide: Set user_creatable to false
target/mips: Remove unused TCG temporary in gen_mipsdsp_accinsn()
target/mips: Fix DEXTRV_S.H DSP opcode
target/mips: Use tcg_constant_tl() in gen_compute_compact_branch()
target/mips: Use explicit extract32() calls in gen_msa_i5()
target/mips: Use tcg_constant_i32() in gen_msa_3rf()
target/mips: Use tcg_constant_i32() in gen_msa_2r()
target/mips: Use tcg_constant_i32() in gen_msa_2rf()
target/mips: Use tcg_constant_i32() in gen_msa_elm_df()
target/mips: Remove unused register from MSA 2R/2RF instruction format
hw/mips/boston: Add FDT generator
hw/mips/boston: Allow loading elf kernel and dtb
hw/mips/boston: Massage memory map information
target/mips: Check nanoMIPS DSP MULT[U] accumulator with Release 6
Warner Losh [Fri, 17 Sep 2021 00:43:01 +0000 (18:43 -0600)]
bsd-user/mmap.c: mmap return ENOMEM on overflow
mmap should return ENOMEM on len overflow rather than EINVAL. Return
EINVAL when len == 0 and ENOMEM when the rounded to a page length is 0.
Found by make check-tcg.
bsd-user/mmap.c: check pread's return value to fix warnings with _FORTIFY_SOURCE
Simmilar to the equivalent linux-user: commit fb7e378cf9c, which added
checking to pread's return value. Update to current qemu standards with
{} around the if statement.
BALATON Zoltan [Fri, 15 Oct 2021 01:06:20 +0000 (03:06 +0200)]
via-ide: Avoid using isa_get_irq()
Use via_isa_set_irq() which better encapsulates irq handling in the
vt82xx model and avoids using isa_get_irq() that has a comment saying
it should not be used.
BALATON Zoltan [Fri, 15 Oct 2021 01:06:20 +0000 (03:06 +0200)]
vt82c686: Add a method to VIA_ISA to raise ISA interrupts
Other functions in the VT82xx chips need to raise ISA interrupts. Keep
a reference to them in the device state and add via_isa_set_irq() to
allow setting their state.
BALATON Zoltan [Fri, 15 Oct 2021 01:06:20 +0000 (03:06 +0200)]
vt82c686: Move common code to via_isa_realize
The vt82c686b_realize and vt8231_realize methods are almost identical,
factor out the common parts to a via_isa_realize function to avoid
code duplication.
target/mips: Remove unused TCG temporary in gen_mipsdsp_accinsn()
Since gen_mipsdsp_accinsn() got added in commit b53371ed5d4
("target-mips: Add ASE DSP accumulator instructions"), the
'v2_t' TCG temporary has never been used. Remove it.
"The shift argument is provided in the instruction."
For the DEXTRV_S.H opcode we have:
"The five least-significant bits of register rs provide the
shift argument, interpreted as a five-bit unsigned integer;
the remaining bits in rs are ignored."
While 't1' contains the 'rs' register content (the shift value
for DEXTR_S.H), we need to load the value of 'rs' for DEXTRV_S.H.
We can directly use the v1_t TCG register which already contains
this shift value.
target/mips: Remove unused register from MSA 2R/2RF instruction format
Commits cbe50b9a8e7 ("target-mips: add MSA VEC/2R format instructions")
and 3bdeb68866e ("target-mips: add MSA 2RF format instructions") added
the MSA 2R/2RF instructions. However these instructions don't use any
target vector register, so remove the unused TCG temporaries.
target/mips: Check nanoMIPS DSP MULT[U] accumulator with Release 6
Per the "MIPS Architecture Extension: nanoMIPS32 DSP TRM" rev 0.04,
MULT and MULTU opcodes:
The value of ac selects an accumulator numbered from 0 to 3.
When ac=0, this refers to the original HI/LO register pair of the
MIPS32 architecture.
In Release 6 of the MIPS Architecture, accumulators are eliminated
from MIPS32.
Ensure pre-Release 6 is restricted to HI/LO registers pair.
Fixes: 8b3698b2947 ("target/mips: Add emulation of DSP ASE for nanoMIPS - part 4") Reviewed-by: Richard Henderson <[email protected]> Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
* remotes/rth/tags/pull-tcg-20211016: (24 commits)
Revert "cpu: Move cpu_common_props to hw/core/cpu.c"
target/xtensa: Drop check for singlestep_enabled
target/tricore: Drop check for singlestep_enabled
target/sh4: Drop check for singlestep_enabled
target/s390x: Drop check for singlestep_enabled
target/rx: Drop checks for singlestep_enabled
target/riscv: Remove exit_tb and lookup_and_goto_ptr
target/riscv: Remove dead code after exception
target/ppc: Drop exit checks for singlestep_enabled
target/openrisc: Drop checks for singlestep_enabled
target/mips: Drop exit checks for singlestep_enabled
target/mips: Fix single stepping
target/microblaze: Drop checks for singlestep_enabled
target/microblaze: Check CF_NO_GOTO_TB for DISAS_JUMP
target/m68k: Drop checks for singlestep_enabled
target/i386: Drop check for singlestep_enabled
target/i386: Check CF_NO_GOTO_TB for dc->jmp_opt
target/hppa: Drop checks for singlestep_enabled
target/arm: Drop checks for singlestep_enabled
target/hexagon: Drop checks for singlestep_enabled
...
Despite a comment saying why cpu_common_props cannot be placed in
a file that is compiled once, it was moved anyway. Revert that.
Since then, Property is not defined in hw/core/cpu.h, so it is now
easier to declare a function to install the properties rather than
the Property array itself.
As per an ancient comment in mips_tr_translate_insn about the
expectations of gdb, when restarting the insn in a delay slot
we also re-execute the branch. Which means that we are
expected to execute two insns in this case.
This has been broken since 8b86d6d2580, where we forced max_insns
to 1 while single-stepping. This resulted in an exit from the
translator loop after the branch but before the delay slot is
translated.
Increase the max_insns to 2 for this case. In addition, bypass
the end-of-page check, for when the branch itself ends the page.