public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: TDX: Allow userspace to return errors to guest for MAPGPA
@ 2026-01-14  0:30 Sagi Shahar
  2026-01-14  2:59 ` Xiaoyao Li
  0 siblings, 1 reply; 9+ messages in thread
From: Sagi Shahar @ 2026-01-14  0:30 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini, Dave Hansen, Kiryl Shutsemau,
	Rick Edgecombe
  Cc: Thomas Gleixner, Borislav Petkov, H. Peter Anvin, x86, kvm,
	linux-kernel, linux-coco, Vishal Annapurve, Sagi Shahar

From: Vishal Annapurve <vannapurve@google.com>

MAPGPA request from TDX VMs gets split into chunks by KVM using a loop
of userspace exits until the complete range is handled.

In some cases userspace VMM might decide to break the MAPGPA operation
and continue it later. For example: in the case of intrahost migration
userspace might decide to continue the MAPGPA operation after the
migrration is completed.

Allow userspace to signal to TDX guests that the MAPGPA operation should
be retried the next time the guest is scheduled.

Signed-off-by: Vishal Annapurve <vannapurve@google.com>
Co-developed-by: Sagi Shahar <sagis@google.com>
Signed-off-by: Sagi Shahar <sagis@google.com>
---
 arch/x86/kvm/vmx/tdx.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
index 2d7a4d52ccfb..3244064b1a04 100644
--- a/arch/x86/kvm/vmx/tdx.c
+++ b/arch/x86/kvm/vmx/tdx.c
@@ -1189,7 +1189,13 @@ static int tdx_complete_vmcall_map_gpa(struct kvm_vcpu *vcpu)
 	struct vcpu_tdx *tdx = to_tdx(vcpu);
 
 	if (vcpu->run->hypercall.ret) {
-		tdvmcall_set_return_code(vcpu, TDVMCALL_STATUS_INVALID_OPERAND);
+		if (vcpu->run->hypercall.ret == -EBUSY)
+			tdvmcall_set_return_code(vcpu, TDVMCALL_STATUS_RETRY);
+		else if (vcpu->run->hypercall.ret == -EINVAL)
+			tdvmcall_set_return_code(vcpu, TDVMCALL_STATUS_INVALID_OPERAND);
+		else
+			return -EINVAL;
+
 		tdx->vp_enter_args.r11 = tdx->map_gpa_next;
 		return 1;
 	}
-- 
2.52.0.457.g6b5491de43-goog


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-01-15 16:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-14  0:30 [PATCH] KVM: TDX: Allow userspace to return errors to guest for MAPGPA Sagi Shahar
2026-01-14  2:59 ` Xiaoyao Li
2026-01-14  9:32   ` Binbin Wu
2026-01-14 15:57   ` Sean Christopherson
2026-01-14 21:48     ` Sean Christopherson
2026-01-15  1:22       ` Sagi Shahar
2026-01-15  1:21     ` Sagi Shahar
2026-01-15  7:47       ` Xiaoyao Li
2026-01-15 16:54         ` Sean Christopherson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox