aboutsummaryrefslogtreecommitdiff
path: root/system
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2026-03-02 09:13:34 +0000
committerPeter Maydell <peter.maydell@linaro.org>2026-03-02 09:13:34 +0000
commit333aaa55f051977cc897fb71e0a9ed52bb00a675 (patch)
treeb5370984bab18df84474e129e1cc9070a06ecfb6 /system
parent0aac79bd790148a6ee597225a9762a036a454b06 (diff)
parent5a0f9481b0cf344c4437515b596e4ecf57ccc30f (diff)
downloadqemu-master.zip
qemu-master.tar.gz
qemu-master.tar.bz2
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into stagingHEADmaster
* target/alpha: Fix for record/replay issue * accel/nitro: New Nitro Enclaves accelerator * generic + kvm: add support for rebuilding VMs on reset * audio requirements cleanup * vmmouse: Fix hypercall clobbers * rust: use checked_div to make clippy happy * kvm: Don't clear pending #SMI in kvm_get_vcpu_events * target/i386/emulate: rework MMU code, many fixes * target/i386/whpx: replace winhvemulation with target/i386/emulate * target/i386/whpx: x2apic support * target/i386/whpx: vapic support * kvm: support for the "ignore guest PAT" quirk * target/i386: add ITS_NO bit for the arch-capabilities MSR * target/i386: add MBEC bit for nested VMX # -----BEGIN PGP SIGNATURE----- # # iQFIBAABCgAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmmkVTUUHHBib256aW5p # QHJlZGhhdC5jb20ACgkQv/vSX3jHroOa8Qf+J16s57unw/DiM4Mw7wvnLGA86OSu # bJwlHBgmgz3uT8LwPpg2F3+yTDzTGErm5Ex7JHYJqdLdhVuU0cC3d3/TndUovWZf # lMwQi2QJNKECtOIIz3rqbqvuSoy577Q7qN7CIN4vR8JKFvToPnwABVfkl+VKedCT # Tu/f3SiazXnNH8FejtXsyjDHMwJfMwhYg5HyAHeqxtrqMCnQ/pc46ZQoM4CJr8P+ # jDZu85RDlLVXkA0RtwkJ6QfvxSU3wUjEeDBz9ThGLk00PFCr1LAXj/oz+0Ayz3qu # LkVpLLBxt0hfMCZPlYF0+17m1CJv7/micHVZEgblawpq/xXXk1iE8avGQQ== # =mEuN # -----END PGP SIGNATURE----- # gpg: Signature made Sun Mar 1 15:03:17 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: (102 commits) target/i386: emulate: fix scas whpx: i386: expose HV_X64_MSR_APIC_FREQUENCY when kernel-irqchip=off whpx: i386: enable PMU target/i386: emulate: more 64-bit register handling whpx: i386: warn on unsupported MSR access instead of failing silently whpx: i386: enable synthetic processor features whpx: i386: enable all supported host features whpx: i386: move whpx_vcpu_kick_out_of_hlt() invocation to interrupt raise time target/i386: introduce ClearwaterForest-v3 to expose ITS_NO target/i386: introduce SierraForest-v5 to expose ITS_NO target/i386: introduce GraniteRapids-v5 to expose ITS_NO target/i386: introduce SapphireRapids-v6 to expose ITS_NO target/i386: Add MSR_IA32_ARCH_CAPABILITIES ITS_NO target/i386: Add VMX_SECONDARY_EXEC_MODE_BASED_EPT_EXEC Reapply "rcu: Unify force quiescent state" target/alpha: Reset CPU hw: i386: vapic: enable on WHPX with user-mode irqchip whpx: x86: kick out of HLT manually when using the kernel-irqchip whpx: x86: remove inaccurate comment KVM: i386: Default disable ignore guest PAT quirk ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'system')
-rw-r--r--system/physmem.c28
-rw-r--r--system/runstate.c44
2 files changed, 68 insertions, 4 deletions
diff --git a/system/physmem.c b/system/physmem.c
index 2fb0c25..e5ff26a 100644
--- a/system/physmem.c
+++ b/system/physmem.c
@@ -2827,6 +2827,34 @@ found:
}
/*
+ * Creates new guest memfd for the ramblocks and closes the
+ * existing memfd.
+ */
+int ram_block_rebind(Error **errp)
+{
+ RAMBlock *block;
+
+ qemu_mutex_lock_ramlist();
+
+ RAMBLOCK_FOREACH(block) {
+ if (block->flags & RAM_GUEST_MEMFD) {
+ if (block->guest_memfd >= 0) {
+ close(block->guest_memfd);
+ }
+ block->guest_memfd = kvm_create_guest_memfd(block->max_length,
+ 0, errp);
+ if (block->guest_memfd < 0) {
+ qemu_mutex_unlock_ramlist();
+ return -1;
+ }
+
+ }
+ }
+ qemu_mutex_unlock_ramlist();
+ return 0;
+}
+
+/*
* Finds the named RAMBlock
*
* name: The name of RAMBlock to find
diff --git a/system/runstate.c b/system/runstate.c
index d091a2b..eca722b 100644
--- a/system/runstate.c
+++ b/system/runstate.c
@@ -42,6 +42,7 @@
#include "qapi/qapi-commands-run-state.h"
#include "qapi/qapi-events-run-state.h"
#include "qemu/accel.h"
+#include "accel/accel-ops.h"
#include "qemu/error-report.h"
#include "qemu/job.h"
#include "qemu/log.h"
@@ -57,6 +58,7 @@
#include "system/reset.h"
#include "system/runstate.h"
#include "system/runstate-action.h"
+#include "system/confidential-guest-support.h"
#include "system/system.h"
#include "system/tpm.h"
#include "trace.h"
@@ -508,6 +510,9 @@ void qemu_system_reset(ShutdownCause reason)
{
MachineClass *mc;
ResetType type;
+ AccelClass *ac = ACCEL_GET_CLASS(current_accel());
+ bool guest_state_rebuilt = false;
+ int ret;
mc = current_machine ? MACHINE_GET_CLASS(current_machine) : NULL;
@@ -520,6 +525,29 @@ void qemu_system_reset(ShutdownCause reason)
default:
type = RESET_TYPE_COLD;
}
+
+ if ((reason == SHUTDOWN_CAUSE_GUEST_RESET ||
+ reason == SHUTDOWN_CAUSE_HOST_QMP_SYSTEM_RESET) &&
+ (current_machine->new_accel_vmfd_on_reset || !cpus_are_resettable())) {
+ if (ac->rebuild_guest) {
+ ret = ac->rebuild_guest(current_machine);
+ if (ret < 0) {
+ error_report("unable to rebuild guest: %s(%d)",
+ strerror(-ret), ret);
+ vm_stop(RUN_STATE_INTERNAL_ERROR);
+ } else {
+ info_report("virtual machine state has been rebuilt with new "
+ "guest file handle.");
+ guest_state_rebuilt = true;
+ }
+ } else if (!cpus_are_resettable()) {
+ error_report("accelerator does not support reset!");
+ } else {
+ error_report("accelerator does not support rebuilding guest state,"
+ " proceeding with normal reset!");
+ }
+ }
+
if (mc && mc->reset) {
mc->reset(current_machine, type);
} else {
@@ -542,9 +570,16 @@ void qemu_system_reset(ShutdownCause reason)
* it does _more_ than cpu_synchronize_all_post_reset().
*/
if (cpus_are_resettable()) {
- cpu_synchronize_all_post_reset();
- } else {
- assert(runstate_check(RUN_STATE_PRELAUNCH));
+ if (guest_state_rebuilt) {
+ /*
+ * If guest state has been rebuilt, then we
+ * need to sync full cpu state for non confidential guests post
+ * reset.
+ */
+ cpu_synchronize_all_post_init();
+ } else {
+ cpu_synchronize_all_post_reset();
+ }
}
vm_set_suspended(false);
@@ -697,7 +732,8 @@ void qemu_system_reset_request(ShutdownCause reason)
if (reboot_action == REBOOT_ACTION_SHUTDOWN &&
reason != SHUTDOWN_CAUSE_SUBSYSTEM_RESET) {
shutdown_requested = reason;
- } else if (!cpus_are_resettable()) {
+ } else if (!cpus_are_resettable() &&
+ !confidential_guest_can_rebuild_state(current_machine->cgs)) {
error_report("cpus are not resettable, terminating");
shutdown_requested = reason;
} else {