On Wed, 17 Dec 2025, Gerd Hoffmann wrote:
> On Fri, Dec 12, 2025 at 08:33:41PM +0530, Ani Sinha wrote:
> > When the confidential virtual machine KVM file descriptor changes due to the
> > guest reset, some TDX specific setup steps needs to be done again. This
> > includes finalizing the inital guest launch state again. This change
> > re-executes some parts of the TDX setup during the device reset phaze using
> > a
> > resettable interface. This finalizes the guest launch state again and locks
> > it in. Also care has been taken so that notifiers are installed only once.
>
> > + if (!notifier_added) {
> > + qemu_add_machine_init_done_notifier(&tdx_machine_done_notify);
> > + notifier_added = true;
> > + }
>
> Is this notifier needed still if you finalize the initial guest state in
> the reset handler?
>
Yes good point. Following small change will be needed.
>From 59e1df5f3c64a75a14139c498106a225bf3b42b2 Mon Sep 17 00:00:00 2001
From: Ani Sinha <[email protected]>
Date: Thu, 18 Dec 2025 14:11:40 +0530
Subject: [PATCH] i386/tdx: remove notifier that is not needed
Take Gerd's suggestion.
Signed-off-by: Ani Sinha <[email protected]>
---
target/i386/kvm/tdx.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c
index 20f9d63eff..144020e378 100644
--- a/target/i386/kvm/tdx.c
+++ b/target/i386/kvm/tdx.c
@@ -392,7 +392,7 @@ static void tdx_finalize_vm(Notifier *notifier, void
*unused)
static void tdx_handle_reset(Object *obj, ResetType type)
{
- if (!runstate_is_running()) {
+ if (!runstate_is_running() && !phase_check(PHASE_MACHINE_READY)) {
return;
}
@@ -429,9 +429,6 @@ static NotifierWithReturn tdx_vmfd_pre_change_notifier = {
.notify = set_tdx_vm_uninitialized,
};
-static Notifier tdx_machine_done_notify = {
- .notify = tdx_finalize_vm,
-};
/*
* Some CPUID bits change from fixed1 to configurable bits when TDX module
@@ -778,7 +775,6 @@ static int tdx_kvm_init(ConfidentialGuestSupport *cgs,
Error **errp)
kvm_readonly_mem_allowed = false;
if (!notifier_added) {
- qemu_add_machine_init_done_notifier(&tdx_machine_done_notify);
kvm_vmfd_add_pre_change_notifier(&tdx_vmfd_pre_change_notifier);
notifier_added = true;
}
--
2.42.0