1820 Commits

Author SHA1 Message Date
Alex Bennée
78420b59f0 accel/tcg: move jit thread manipulation into do_tb_phys_invalidate
To invalidate a TB on MacOS we need to enable write access to the JIT
buffer. We were doing this for tb_phys_invalidate__locked but that is
not the only path into do_tb_phys_invalidate. Move the manipulation
into the shared function that does the work.

As a result we can drop the tb_phys_invalidate__locked function and
update the calls directly.

This enables watchpoints to work in MacOS TCG guests.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3444
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20260526110243.470002-5-alex.bennee@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
2026-05-28 21:28:37 +01:00
Magnus Kulke
dbfb680772 accel/mshv: implement cpu_thread_is_idle() hook
In MSHV the hypervisor APIC is always used, so we to implement this hook
to make sure the AP's vcpu thread is not blocked waiting for an INIT SIPI
by the BSP. Without this change soft reboots with -smp cpus>=2 will
hang.

Signed-off-by: Magnus Kulke <magnuskulke@linux.microsoft.com>
Reviewed-by: Mohamed Mediouni <mohamed@unpredictable.fr>
Link: https://lore.kernel.org/r/20260421-mshv_accel_arm64_supp-v3-9-469f544778ba@linux.microsoft.com
[Make comment not x86 specific. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-05-25 16:51:23 +02:00
Marc-André Lureau
e936cfe830 accel/kvm: free device path on finalization
kvm_set_device allocates device via g_strdup, but no
instance_finalize existed for the KVM accelerator type.

Fixes: aef158b093 ("Add class property to configure KVM device node to use")
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-05-11 23:59:33 +04:00
Richard Henderson
1649553313 host-utils: Introduce signed saturation primitives
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2026-05-09 10:50:01 -05:00
Philippe Mathieu-Daudé
61522df799 cpus: Remove CPUClass::init_accel_cpu() left-over hook
Commits f50d0f335a and a522b04bb9 ("target/riscv,i386: Remove
AccelCPUClass::cpu_class_init need") removed the last uses of
the CPUClass::init_accel_cpu hook. Remove it as unused.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20260412212547.29645-1-philmd@linaro.org>
2026-05-06 12:58:08 +02:00
Mohamed Mediouni
37863fff59 hvf: arm: enable vGIC by default for virt-11.1 and later
Save states are incompatible between kernel-irqchip=on and off on HVF due to opaque vGIC state.

Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Message-id: 20260429190532.26538-16-mohamed@unpredictable.fr
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2026-05-05 09:30:12 +01:00
Mohamed Mediouni
d7a75ea483 hw/arm, target/arm: nested virtualisation on HVF
Add hvf_arm_el2_supported for querying EL2 availability.
An hvf_nested_virt_enable workaround is added as nested virt has
to be enabled early on HVF.

And adds hvf_nested_virt_enabled.

Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Message-id: 20260429190532.26538-6-mohamed@unpredictable.fr
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2026-05-05 09:25:21 +01:00
Mohamed Mediouni
2a3c965516 accel, hw/arm, include/system/hvf: infrastructure changes for HVF vGIC
Misc changes needed for HVF vGIC enablement.

Note: x86_64 macOS exposes interrupt controller virtualisation since macOS 12.
Keeping an #ifdef here in case we end up supporting that...

However, given that x86_64 macOS is on its way out, it'll probably (?)
not be supported in QEMU.

Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
Message-id: 20260429190532.26538-4-mohamed@unpredictable.fr
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2026-05-05 09:25:21 +01:00
Mohamed Mediouni
a1a3692d15 whpx: i386: add SeparateSecurityDomain flag and make default
For workloads where isolation is less important, -accel whpx,ssd=off
will provide significantly higher MMIO performance.

Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
Link: https://lore.kernel.org/r/20260422214225.2242-37-mohamed@unpredictable.fr
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-04-30 17:55:04 +02:00
Mohamed Mediouni
bb605df21e whpx: i386: add feature to intercept #GP MSR accesses
It turns out they're not that uncommon, so have
a feature around to log those.

Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
Link: https://lore.kernel.org/r/20260422214225.2242-35-mohamed@unpredictable.fr
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-04-30 17:55:04 +02:00
Mohamed Mediouni
d9225244af whpx: i386: unknown MSR configurability
Add an option to inject back a GPF for unknown MSRs.

Keep it on by default for now as Linux expects accesses to some
AMD-specific MSRs to always succeed when on an AMD host.

Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
Link: https://lore.kernel.org/r/20260422214225.2242-18-mohamed@unpredictable.fr
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-04-30 17:55:03 +02:00
Mohamed Mediouni
f741457c1a whpx: i386: reintroduce enlightenments for Windows 10
Was removed in 2c08624 but it's still useful for
Windows 10 so reintroduce it there.

And this time, actually make it work by reporting
the hypervisor bit in CPUID.

Pretend to be vmware to be able to use vmport's functionality.

If the vmware frequency leaf is disabled, pretend to be
KVM, with the only capability reported being X2APIC support.

Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
Link: https://lore.kernel.org/r/20260422214225.2242-7-mohamed@unpredictable.fr
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-04-30 17:55:03 +02:00
Philippe Mathieu-Daudé
50362dd65a qom: Declare compat properties API in 'qom/compat-properties.h'
While most of QEMU files use the QOM concept, few of them
use the compatibility properties API (mostly use in system
emulation). Move its prototype to a new "qom/compat-properties.h"
header, keeping "qom/object.h" for generic QOM.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Message-Id: <20260325151728.45378-5-philmd@linaro.org>
2026-04-24 21:27:21 +02:00
Stefan Hajnoczi
e7af5f3655 Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
* accel/mshv: ioeventfd fixes
* memory: avoid memmove in flatview_simplify()
* first batch of clang-cl support patches for qemu-ga
* target/i386: fix emulator issue
* target/i386: fix strList leak
* target/i386: emulate: include name of unhandled instruction
* target/i386/tcg: fix decoding of MOVBE and CRC32 in 16-bit mode
* thread-win32: replace CRITICAL_SECTION with SRWLOCK
* target/i386: fix missing PF_INSTR in SIGSEGV context
* util: actually use in pthread_condattr_setclock
* vapic: restore IRQ polling for non-kernel irqchip backends

# -----BEGIN PGP SIGNATURE-----
#
# iQFIBAABCgAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmnp9BYUHHBib256aW5p
# QHJlZGhhdC5jb20ACgkQv/vSX3jHroN0Vwf/SCepaTVfA+XXU9ZQLKBch2uPusxM
# iphUdCFyKytydITrIuTQlAQ4EyfnlTouj1qn7SE/cKuRpl9J1Z/eFUGjg0wsDIYM
# J++3wZfGP0foUDYep2bdRQnTiKqgTC93DQUk2mxahdKLqWTo6lSijM0o9NvBvRT1
# ntItGt0KPH1D0eK/cr7+yA4LoMpVzyx+OUHIP+2egJ2el3eRbcI2z6yRPBIAKcSa
# 7xFHcUmHB8gkLdgKX0Lsn80zL69w/au5cwDnjS1k24iZbl3pFsnVVKkgPMSs0Ekm
# Z81nW7s74Woo7VAhrn8A3sYZmJY6wVWNhM1uI3S3Tkg03yGumRrLVAm7tw==
# =hjOY
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 23 Apr 2026 06:27:34 EDT
# gpg:                using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
# gpg:                issuer "pbonzini@redhat.com"
# gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full]
# gpg:                 aka "Paolo Bonzini <pbonzini@redhat.com>" [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

* tag 'for-upstream' of https://gitlab.com/bonzini/qemu: (25 commits)
  target/i386: emulate: include name of unhandled instruction
  memory: Optimize flatview_simplify() to eliminate redundant memmove calls
  meson: add missing semicolon in pthread_condattr_setclock test
  thread-win32: replace CRITICAL_SECTION with SRWLOCK
  target/i386/tcg: fix decoding of MOVBE and CRC32 in 16-bit mode
  accel/mshv: return correct errno value from ioeventfd failure
  accel/mshv: fix ioeventfd deassignment to forward correct datamatch value
  target/i386/mshv: Fix segment regression in MMIO emu
  meson: Don't require nm for non-modular builds
  storage-daemon: use same link arguments as other tools
  util: Remove unused sys/param.h
  util: Remove unused dirent.h
  osdep: Remove unused strings.h
  hw/ppc: Use glib2 instead of strcasecmp/strncasecmp
  target/xtensa: Use glib2 instead of strcasecmp/strncasecmp
  target/ppc: Use glib2 instead of strcasecmp/strncasecmp
  target/riscv: Use glib2 instead of strcasecmp/strncasecmp
  target/sparc: Use glib2 instead of strcasecmp/strncasecmp
  io: Use glib2 instead of strcasecmp/strncasecmp
  block: Use glib2 instead of strcasecmp/strncasecmp
  ...

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2026-04-23 20:51:46 -04:00
Aastha Rawat
007cec79b2 accel/mshv: return correct errno value from ioeventfd failure
Returning the raw ioctl return value results in misleading error
message. Ensure that actual failure reason is propagated by returning
-errno for ioeventfd failure.

Signed-off-by: Aastha Rawat <aastharawat@linux.microsoft.com>
Reviewed-by: Magnus Kulke <magnuskulke@linux.microsoft.com>
Link: https://lore.kernel.org/r/20260409-fix_ioevent-v1-2-053b810ae6fb@linux.microsoft.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-04-23 12:27:27 +02:00
Aastha Rawat
a395d6a2fa accel/mshv: fix ioeventfd deassignment to forward correct datamatch value
unregister_ioevent() is not forwarding the datamatch (queue index) to
the mshv driver, causing only the first VirtIO-MMIO queue to be
deassigned correctly. Subsequent queues fail with `-ENOENT`, triggering
a fatal abort().

This failure was discovered while booting arm64 EDK2 firmware with mshv
accel.

Signed-off-by: Aastha Rawat <aastharawat@linux.microsoft.com>
Reviewed-by: Magnus Kulke <magnuskulke@linux.microsoft.com>
Link: https://lore.kernel.org/r/20260409-fix_ioevent-v1-1-053b810ae6fb@linux.microsoft.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-04-23 12:27:27 +02:00
Pierrick Bouvier
2578f3b68b tcg/translator: add parameter to translator_loop for current addr type
With TCG_ADDRESS_BITS mechanism, it's now possible to specify which
variant every source file is written for. Compared to before, it means
that addr_type will now vary per tb translation, where it was constant
for a given target previously.

Thus, we add new a parameter to translator_loop().
This will allow us to convert targets one by one.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20260407222208.271838-15-pierrick.bouvier@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2026-04-23 10:24:10 +01:00
Ani Sinha
afa63fc0e3 accel/kvm: return early from kvm_irqchip_create if kvm does not support irqchip
During refactoring of kvm_irqchip_create(), the refactored code was returning
early from do_kvm_irqchip_create() function if the required essential
capabilities were not present in KVM. This was not translating to an early
return from kvm_irqchip_create() as was the case before refactoring.
This is because, do_kvm_irqchip_create() did not have a means to notify the
caller of the lack of required kvm capabilities. Fix this by making
do_notify_irqchip_create() return EOPNOTSUPP error when  capabilities
are absent and then the caller can check the return code and return early.

Due to this regression during refactoring, all KVM guests on ppc64le hang
immediately during startup and this completely breaks all functionality on
that platform.

Fixes: 98884e0cc1 ("accel/kvm: add changes required to support KVM VM file descriptor change")
Message-ID: <20260413090010.60339-1-anisinha@redhat.com>
Reported-by: Misbah Anjum N <misanjum@linux.ibm.com>
Reported-by: Gautam Menghani <gautam@linux.ibm.com>
Tested-by: Misbah Anjum N <misanjum@linux.ibm.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Ani Sinha <anisinha@redhat.com>
Message-id: 20260414045911.63662-1-anisinha@redhat.com
Suggested-by: Fabiano Rosas <farosas@suse.de>
Suggested-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Tested-by: Misbah Anjum N <misanjum@linux.ibm.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Ani Sinha <anisinha@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2026-04-14 15:51:57 +01:00
Peter Maydell
8330da591e include/user/guest-host.h: Provide g2h etc for both abi_ptr and vaddr
In commit 7804c84a ("include/user: Use vaddr in guest-host.h") we
changed all the functions in guest-host.h that took or returned their
guest address argument in type abi_ptr to instead use vaddr.

This introduced regressions for the case of a 32-bit guest and an
address above 2GB for the common situation where the address is a
syscall argument stored in a variable of type 'abi_long'.  With
abi_ptr (which will be an unsigned 32-bit type for 32-bit guests),
the address is cast to unsigned 32-bit, and then zero-extended to
64-bits in g2h_untagged_vaddr().  With the switch to vaddr (which is
always a 64-bit unsigned type), the guest address will instead be
sign-extended to 64 bits, which gives the wrong answer.

Fix this by providing two versions of the affected functions: the
standard names (g2h(), g2h_untagged(), guest_addr_valid_untagged(),
guest_range_valid_untagged(), cpu_untagged_addr()) return to using
the logically-correct abi_ptr type; new versions with a _vaddr()
prefix use the vaddr type.

accel/tcg/user-exec.c must change to use the _vaddr() versions; this
is the only file that uses guest-host.h that we want to compile once.
All the other uses are in linux-user and bsd-user code that
inherently has to know the sizes of target-ABI types.

Cc: qemu-stable@nongnu.org
Fixes: 7804c84a ("include/user: Use vaddr in guest-host.h")
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3333
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20260330143123.1685142-3-peter.maydell@linaro.org
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2026-03-31 19:13:03 +01:00
Alyssa Ross
1347b79b7a accel/kvm: fix typo in variable name
Fixes: 94a8d39afd ("kvm: Consolidate must-have capability checks")
Signed-off-by: Alyssa Ross <hi@alyssa.is>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Link: https://lore.kernel.org/r/20260311095315.25013-1-hi@alyssa.is
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-03-12 12:02:55 +01:00
Peter Maydell
89851dbcce Merge tag 'accel-tcg-20260310' of https://github.com/philmd/qemu into staging
Accelerators and TCG patches queue

- Improve TCG extract and deposit
- Build accelerator stub files once

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmmv9goACgkQ4+MsLN6t
# wN4NVQ//UsLGikzMHhQ52JqSePy3hJ00uBzeZ+6exKcgWfCHCEKLimTewCSuhdjM
# qic6DGSShUrl36EVT1qRdz261jntgvfn12TQfs0LdSvgZKBjdWFcZ+AiIp54jYTS
# Wi0Qsdqi0+oXg4ictiefmGlgqo65qJU8U8mnclzOa5GmLMZC4QbGhV3qvEcE0BNc
# 1tzLSSschLWOqAG+vaHUCyyhr28UgJGO7pqVSuVnw2fA1jXVyRH671ZIyhBf85o9
# eWlChqtuvwrauKojD2eIK4qMw3esDqlwRXckvLu6/Nq1McXYbdc5Mm61c6JW5Wza
# LXMms6bix2iS0CoR5qmkEFgttVe5aZtJwXkYW2FE/+p6wscZHOyhrs0YdxkYqjgp
# 9WYkyqK9oeLLDBHQ2XAa4f+zE/4nPaWzKElu/kqA+XrrxvnkQisD2uijxioXCi6X
# CUa+pJrXxiKZOrWRXRGwuPpdJT4CrX082ydhQnsnH0Pi7gedpXZj9eYIRjxSvndZ
# 06ONtE/4Ja++gKNF6sbu8HLY7eCrfIVCQGOex4h6BrQsyZKU/EYbw0LhcVfUooMw
# QsF3rMD2AyWpzPzcJ3Y0E7t7e5iKNJoKLlN3ziR9qz34HCjdoNmbIwvbR5oUkJpd
# dhvtPikIIgcRnQvVmuLdkiTg6he9z70lsCtSBCkkLQN8nb8j9cE=
# =ak2F
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Mar 10 10:44:26 2026 GMT
# gpg:                using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <f4bug@amsat.org>" [full]
# Primary key fingerprint: FAAB E75E 1291 7221 DCFD  6BB2 E3E3 2C2C DEAD C0DE

* tag 'accel-tcg-20260310' of https://github.com/philmd/qemu:
  accel/qtest: Build once as common object
  accel/xen: Build without target-specific knowledge
  accel/hvf: Build without target-specific knowledge
  accel/mshv: Build without target-specific knowledge
  accel/mshv: Forward-declare mshv_root_hvcall structure
  accel/stubs: Build stubs once
  accel/kvm: Make kvm_irqchip*notifier() declaration non target-specific
  accel/kvm: Include missing 'exec/cpu-common.h' header
  target/hppa: Expand tcg_global_mem_new() -> tcg_global_mem_new_i64()
  tcg/optimize: possibly expand deposit into zero with shifts
  tcg: target-dependent lowering of extract to shr/and
  tcg: Add tcg_op_imm_match
  tcg: Expand missing rotri with extract2
  tcg/optimize: Lower unsupported extract2 during optimize
  tcg/optimize: Lower unsupported deposit during optimize
  tcg: Drop extract+shl expansions in tcg_gen_deposit_z_*

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2026-03-10 13:32:04 +00:00
Peter Maydell
56fe2ca5b6 Merge tag 'staging-pull-request' of https://gitlab.com/peterx/qemu into staging
Memory pull for 11.0 softfreeze

- BALATON's memory cleanups on _nomigrate MRs and else
- Phil's small constify series and else
- Marc-André's initial cleanup patches around ram discard manager

# -----BEGIN PGP SIGNATURE-----
#
# iIgEABYKADAWIQS5GE3CDMRX2s990ak7X8zN86vXBgUCaa8v2xIccGV0ZXJ4QHJl
# ZGhhdC5jb20ACgkQO1/MzfOr1wbiNgD/ZLS5BtRGva5eUQNXKkE3oOiXfDBkLyQ1
# BowQ12zjPZMBAOxrVvyGbpgsI5SOcSjsvFSsWLs1GFfHjVUAyCNusl4D
# =+4wZ
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar  9 20:38:51 2026 GMT
# gpg:                using EDDSA key B9184DC20CC457DACF7DD1A93B5FCCCDF3ABD706
# gpg:                issuer "peterx@redhat.com"
# gpg: Good signature from "Peter Xu <xzpeter@gmail.com>" [marginal]
# gpg:                 aka "Peter Xu <peterx@redhat.com>" [marginal]
# gpg: WARNING: The key's User ID is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: B918 4DC2 0CC4 57DA CF7D  D1A9 3B5F CCCD F3AB D706

* tag 'staging-pull-request' of https://gitlab.com/peterx/qemu:
  system/memory: Have memory_region_type() correctly describe containers
  system/xen: Constify various MemoryRegion arguments
  system/memory: Constify various MemoryRegion arguments
  system/ramblock: Constify various RAMBlock arguments
  kvm: replace RamDicardManager by the RamBlockAttribute
  system/memory: minor doc fix
  virtio-mem: use warn_report_err_once()
  memory: drop RamDiscardListener::double_discard_supported
  system/rba: use DIV_ROUND_UP
  memory: Factor out common ram ptr initialization
  memory: Factor out common ram region initialization
  memory: Add internal memory_region_register_ram function
  memory: Shorten memory_region_init_ram_device_ptr and memory_region_init_rom_device
  memory: Remove memory_region_init_ram_nomigrate()
  hw/xtensa/xtfpga: Do not use memory_region_init_ram_nomigrate()
  sun4m,sun4u,tcx: Do not use memory_region_init_ram_nomigrate()
  memory: Remove memory_region_init_rom_nomigrate()
  hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate()

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2026-03-10 11:38:58 +00:00
Philippe Mathieu-Daudé
c574ff9245 accel/qtest: Build once as common object
No code within qtest.c uses target-specific knowledge:
build it once as target-agnostic common unit.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20260225053408.18426-1-philmd@linaro.org>
2026-03-10 11:36:21 +01:00
Philippe Mathieu-Daudé
beaf63280a accel/xen: Build without target-specific knowledge
Code in accel/ aims to be target-agnostic. Enforce that
by moving the Xen file units to system_ss[], which is
target-agnostic.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Acked-by: Anthony PERARD <anthony.perard@vates.tech>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20260225051303.91614-6-philmd@linaro.org>
2026-03-10 11:36:21 +01:00
Philippe Mathieu-Daudé
593063e4cb accel/hvf: Build without target-specific knowledge
Code in accel/ aims to be target-agnostic. Enforce that
by moving the HVF file units to system_ss[], which is
target-agnostic.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20260225051303.91614-5-philmd@linaro.org>
2026-03-10 11:36:21 +01:00
Philippe Mathieu-Daudé
35f797739b accel/mshv: Build without target-specific knowledge
Code in accel/ aims to be target-agnostic. Enforce that
by moving the MSHV file units to system_ss[], which is
target-agnostic.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20260225051303.91614-4-philmd@linaro.org>
2026-03-10 11:36:21 +01:00
Philippe Mathieu-Daudé
591357b68f accel/mshv: Forward-declare mshv_root_hvcall structure
Forward-declare the target-specific mshv_root_hvcall structure
in order to keep 'system/mshv_int.h' target-agnostic.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20260225051303.91614-3-philmd@linaro.org>
2026-03-10 11:36:21 +01:00
Philippe Mathieu-Daudé
e78cc345db accel/stubs: Build stubs once
Move stubs to the global stub_ss[] source set. These files
are now built once for all binaries, instead of one time
per system binary.

Inspired-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20260225044225.64059-1-philmd@linaro.org>
2026-03-10 11:36:21 +01:00
Philippe Mathieu-Daudé
43f507555d accel/kvm: Include missing 'exec/cpu-common.h' header
kvm-accel-ops.c uses EXCP_DEBUG, itself defined in
"exec/cpu-common.h". Include it explicitly, otherwise
we get when modifying unrelated headers:

  ../accel/kvm/kvm-accel-ops.c: In function ‘kvm_vcpu_thread_fn’:
  ../accel/kvm/kvm-accel-ops.c:54:22: error: ‘EXCP_DEBUG’ undeclared (first use in this function)
     54 |             if (r == EXCP_DEBUG) {
        |                      ^~~~~~~~~~

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20260225051303.91614-2-philmd@linaro.org>
2026-03-10 11:36:21 +01:00
Marc-André Lureau
554671c1ec kvm: replace RamDicardManager by the RamBlockAttribute
No need to cast through the RamDiscardManager interface, use the
RamBlock already retrieved. Makes it more direct and readable, and allow
further refactoring to make RamDiscardManager an aggregator object in
the following patches.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Chenyi Qiang <chenyi.qiang@intel.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/r/20260226140001.3622334-6-marcandre.lureau@redhat.com
Signed-off-by: Peter Xu <peterx@redhat.com>
2026-03-09 14:06:30 -04:00
Mohamed Mediouni
ae9dcd6f26 whpx: make Hyper-V enlightenments configurable
Have them be a machine option instead of a CPU one, to have something available, even if not ideal...

The existing Hyper-V enlightenments configuration mechanism is part of per-CPU configuration, which happens too late for this.

Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
Link: https://lore.kernel.org/r/20260307181856.2209-8-mohamed@unpredictable.fr
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-03-09 09:11:37 +01:00
Mohamed Mediouni
7b6a3c3349 hvf: hvf-all: stop including hvf_arm.h
We don't need this target-specific header in this
target-agnostic source file.

Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20260306130107.35359-5-mohamed@unpredictable.fr
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2026-03-06 13:27:24 +00:00
myrslint
5dacb3b8fa KVM: i386: Default disable ignore guest PAT quirk
Add a new accelerator option that allows the guest to adjust the PAT.
This is already the case for TDX guests and allows using virtio-gpu
Venus with RADV or NVIDIA drivers.

The quirk is disabled by default.  Since this caused problems with
Linux's Bochs video device driver, add a knob to leave it enabled,
and for now do ont enable it by default.

Signed-off-by: Myrsky Lintu <qemu.haziness801@passinbox.com>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2943
Link: https://lore.kernel.org/r/175527721636.15451.4393515241478547957-1@git.sr.ht
[Add property; for now leave it off by default. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-02-27 14:48:04 +01:00
Ani Sinha
956200b180 kvm/vcpu: add notifiers to inform vcpu file descriptor change
When new vcpu file descriptors are created and bound to the new kvm file
descriptor as a part of the confidential guest reset mechanism, various
subsystems needs to know about it. This change adds notifiers so that various
subsystems can take appropriate actions when vcpu fds change by registering
their handlers to this notifier.
Subsequent changes will register specific handlers to this notifier.

Signed-off-by: Ani Sinha <anisinha@redhat.com>
Link: https://lore.kernel.org/r/20260225035000.385950-31-anisinha@redhat.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-02-27 14:48:04 +01:00
Ani Sinha
083ce77fc4 accel/kvm: rebind current VCPUs to the new KVM VM file descriptor upon reset
Confidential guests needs to generate a new KVM file descriptor upon virtual
machine reset. Existing VCPUs needs to be reattached to this new
KVM VM file descriptor. As a part of this, new VCPU file descriptors against
this new KVM VM file descriptor needs to be created and re-initialized.
Resources allocated against the old VCPU fds needs to be released. This change
makes this happen.

Signed-off-by: Ani Sinha <anisinha@redhat.com>
Link: https://lore.kernel.org/r/20260225035000.385950-16-anisinha@redhat.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-02-27 14:22:08 +01:00
Ani Sinha
0f53f021ad accel/kvm: notify when KVM VM file fd is about to be changed
Various subsystems might need to take some steps before the KVM file descriptor
for a virtual machine is changed. So a new boolean attribute is added to the
vmfd_notifier structure which is passed to the notifier callbacks.
vmfd_notifer.pre is true for pre-notification of vmfd change and false for
post notification. Notifier callback implementations can simply check
the boolean value for (vmfd_notifer*)->pre and can take actions for pre or
post vmfd change based on the value.

Subsequent patches will add callback implementations for specific components
that need this pre-notification.

Signed-off-by: Ani Sinha <anisinha@redhat.com>
Link: https://lore.kernel.org/r/20260225035000.385950-9-anisinha@redhat.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-02-27 14:22:08 +01:00
Ani Sinha
4dd184cb41 accel/kvm: add a notifier to indicate KVM VM file descriptor has changed
A notifier callback can be used by various subsystems to perform actions when
KVM file descriptor for a virtual machine changes as a part of confidential
guest reset process. This change adds this notifier mechanism. Subsequent
patches will add specific implementations for various notifier callbacks
corresponding to various subsystems that need to take action when KVM VM file
descriptor changed.

Signed-off-by: Ani Sinha <anisinha@redhat.com>
Link: https://lore.kernel.org/r/20260225035000.385950-8-anisinha@redhat.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-02-27 14:22:08 +01:00
Ani Sinha
9f0c2b3032 accel/kvm: mark guest state as unprotected after vm file descriptor change
When the KVM VM file descriptor has changed and a new one created, the guest
state is no longer in protected state. Mark it as such.
The guest state becomes protected again when TDX and SEV-ES and SEV-SNP mark
it as such.

Signed-off-by: Ani Sinha <anisinha@redhat.com>
Link: https://lore.kernel.org/r/20260225035000.385950-7-anisinha@redhat.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-02-27 14:22:08 +01:00
Ani Sinha
98884e0cc1 accel/kvm: add changes required to support KVM VM file descriptor change
This change adds common kvm specific support to handle KVM VM file descriptor
change. KVM VM file descriptor can change as a part of confidential guest reset
mechanism. A new function api kvm_arch_on_vmfd_change() per
architecture platform is added in order to implement architecture specific
changes required to support it. A subsequent patch will add x86 specific
implementation for kvm_arch_on_vmfd_change() as currently only x86 supports
confidential guest reset.

Signed-off-by: Ani Sinha <anisinha@redhat.com>
Link: https://lore.kernel.org/r/20260225035000.385950-6-anisinha@redhat.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-02-27 14:22:08 +01:00
Alexander Graf
8155bca60d accel: Add Nitro Enclaves accelerator
Nitro Enclaves are a confidential compute technology which
allows a parent instance to carve out resources from itself
and spawn a confidential sibling VM next to itself. Similar
to other confidential compute solutions, this sibling is
controlled by an underlying vmm, but still has a higher level
vmm (QEMU) to implement some of its I/O functionality and
lifecycle.

Add an accelerator to drive this interface. In combination with
follow-on patches to enhance the Nitro Enclaves machine model, this
will allow users to run a Nitro Enclave using QEMU.

Signed-off-by: Alexander Graf <graf@amazon.com>

Link: https://lore.kernel.org/r/20260225220807.33092-5-graf@amazon.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-02-27 08:18:31 +01:00
Mohamed Mediouni
49f31a9671 whpx: common, i386, arm: rework state levels
Change state levels from a set of ifdefs to an enum.
Make register state loads use state levels too.

Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Link: https://lore.kernel.org/r/20260223233950.96076-16-mohamed@unpredictable.fr
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-02-26 18:58:39 +01:00
Mohamed Mediouni
9bd8a24a17 whpx: i386: remove remaining winhvemulation support code
After moving away to target/i386/emulate, this is no longer necessary.

Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
Link: https://lore.kernel.org/r/20260223233950.96076-13-mohamed@unpredictable.fr
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-02-26 18:58:39 +01:00
Mohamed Mediouni
9fdece1224 whpx: move whpx_get_reg/whpx_set_reg to generic code
These will be used in the next commit on the x86_64 backend too.
Also move flush_cpu_state as it's used by get_reg/set_reg and the arm64 code.

Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
Reviewed-by: Bernhard Beschow <shentey@gmail.com>
Link: https://lore.kernel.org/r/20260223233950.96076-10-mohamed@unpredictable.fr
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-02-26 18:58:39 +01:00
Mohamed Mediouni
02dff8f72d whpx: refactor whpx_destroy_vcpu to arch-specific function
Avoid a TARGET_X86_64 define by moving platform-specific code
away from generic WHPX support.

Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Link: https://lore.kernel.org/r/20260223233950.96076-9-mohamed@unpredictable.fr
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-02-26 18:58:39 +01:00
Mohamed Mediouni
19b48084f7 whpx: i386: re-enable guest debug support
Fix what got broken several years ago by adding ops->supports_guest_debug
support as an architecture-specific function.

arm64 WHP doesn't currently provide support needed for this.

Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Link: https://lore.kernel.org/r/20260223233950.96076-7-mohamed@unpredictable.fr
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-02-26 18:58:39 +01:00
Peter Maydell
ece408818d Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
* hw/i386: Remove deprecated PC 2.6 and 2.7 machines
* i386/cpu: Fix incorrect initializer in Diamond Rapids definition
* qom: Clean up property release
* target/i386/kvm: set KVM_PMU_CAP_DISABLE if "-pmu" is configured
* target/i386/kvm: reset AMD and perfmon-v2 PMU registers during VM reset
* mshv: Cleanup
* target/i386: convert SEV-ES termination requests to guest panic events

# -----BEGIN PGP SIGNATURE-----
#
# iQFIBAABCgAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmmO+kYUHHBib256aW5p
# QHJlZGhhdC5jb20ACgkQv/vSX3jHroPwIQf/XL4HXB7bYQH7LtTgsjmmxPpEqGuM
# 2QWvv1HurGf4pBCkBB7iFdzngSbJSzvtIM4D2KRuXVc99Ml8Do4kKGwDdtVfaM+I
# x+nsJfnSGA7tuNVQUUDEM1XWrnk3+O9oQxlk3elBWy8IBIjHFY1rv3FBdO9WkDpu
# AlaMITrX4R7u5gadCrxvAprbngNGlK220HZ+nxdxvf6mWkYMPqy1xtNzHIioG61V
# A94tdv/OZnUoQMd98c/yUvfST4/Gx6FeoEYfmyXGrnLM+Tc9es/xpN/mCYLdP3wA
# MDS170D2Z0zoZScLcpMfeqSn5cDYBMOSHBzqFpw2/FNVTO3td2qlSMLjzw==
# =AqB6
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri Feb 13 10:17:42 2026 GMT
# gpg:                using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
# gpg:                issuer "pbonzini@redhat.com"
# gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full]
# gpg:                 aka "Paolo Bonzini <pbonzini@redhat.com>" [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

* tag 'for-upstream' of https://gitlab.com/bonzini/qemu: (41 commits)
  target/i386/mshv: remove unused optimization of gva=>gpa translation
  accel/mshv: Remove remap overlapping mappings code
  tests: add /qdev/free-properties test
  qdev: make release_tpm() idempotent
  qdev: make release_drive() idempotent
  qdev: make release_string() idempotent
  qdev: Free property array on release
  target/i386/kvm: support perfmon-v2 for reset
  target/i386/kvm: reset AMD PMU registers during VM reset
  target/i386/kvm: rename architectural PMU variables
  target/i386/kvm: extract unrelated code out of kvm_x86_build_cpuid()
  target/i386/kvm: set KVM_PMU_CAP_DISABLE if "-pmu" is configured
  i386/cpu: Fix incorrect initializer in Diamond Rapids definition
  hw/char/virtio-serial: Do not expose the 'emergency-write' property
  hw/virtio/virtio-pci: Remove VirtIOPCIProxy::ignore_backend_features field
  hw/i386/intel_iommu: Remove IntelIOMMUState::buggy_eim field
  hw/core/machine: Remove hw_compat_2_7[] array
  hw/audio/pcspk: Remove PCSpkState::migrate field
  target/i386/cpu: Remove CPUX86State::full_cpuid_auto_level field
  hw/i386/pc: Remove pc_compat_2_7[] array
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2026-02-13 10:30:08 +00:00
Magnus Kulke
626e5dc999 accel/mshv: Remove remap overlapping mappings code
This change removes userland code that worked around a restriction
in the mshv driver in the 6.18 kernel: regions from userland
couldn't be mapped to multiple regions in the kernel. We maintained a
shadow mapping table in qemu and used a heuristic to swap in a requested
region in case of UNMAPPED_GPA exits.

However, this heuristic wasn't reliable in all cases, since HyperV
behaviour is not 100% reliable across versions. HyperV itself doesn't
prohibit to map regions at multiple places into the guest, so the
restriction has been removed in the mshv driver.

Hence we can remove the remapping code. Effectively this will mandate a
6.19 kernel, if the workload attempt to map e.g. BIOS to multiple
reagions. I still think it's the right call to remove this logic:

- The workaround only seems to work reliably with a certain revision
  of HyperV as a nested hypervisor.
- We expect Direct Virtualization (L1VH) to be the main platform for
  the mshv accelerator, which also requires a 6.19 kernel

This reverts commit efc4093358.

Signed-off-by: Magnus Kulke <magnuskulke@linux.microsoft.com>
Acked-by: Wei Liu (Microsoft) <wei.liu@kernel.org>
Tested-by: Mohamed Mediouni <mohamed@unpredictable.fr>
Link: https://lore.kernel.org/r/20260113153708.448968-1-magnuskulke@linux.microsoft.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-02-13 11:16:52 +01:00
Mohamed Mediouni
293984563e hw/arm, accel/hvf, whpx: unify get_physical_address_range between WHPX and HVF
Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2026-02-10 11:34:49 +00:00
Mohamed Mediouni
bf36e65bda whpx: change memory management logic
This allows edk2 to work on Arm, although u-boot is still not functional.

Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2026-02-10 11:34:49 +00:00
Mohamed Mediouni
59432082ce whpx: add arm64 support
Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2026-02-10 11:34:49 +00:00