Re: [PATCH 3/3] KVM: TDX: Exit to userspace for GetTdVmCallInfo

From: Xiaoyao Li
Date: Fri Jun 20 2025 - 08:35:31 EST


On 6/20/2025 8:03 PM, Paolo Bonzini wrote:
Il ven 20 giu 2025, 03:21 Xiaoyao Li <xiaoyao.li@xxxxxxxxx> ha scritto:

tdx->vp_enter_args.r11 = 0;
+ tdx->vp_enter_args.r12 = 0;
tdx->vp_enter_args.r13 = 0;
tdx->vp_enter_args.r14 = 0;
+ return 1;

Though it looks OK to return all-0 for r12 == 0 and undefined case of
r12 > 1, I prefer returning TDVMCALL_STATUS_INVALID_OPERAND for
undefined case.


From the GHCI I wasn't sure that TDVMCALL_STATUS_INVALID_OPERAND is a
valid result at all.

It's part of the new GHCI change, which currently is still in draft state. (Sorry for not informing you)

The proposed GHCI update defines VMCALL_OPERAND_INVALID for the case of input R12 value is not supported. So for VMM that doesn't implement the enumeration for the optional leafs when r12 = 1 can return this status code. As well, VMM can return this status code for the case of input R12 >= 2, to avoid the VMM introduces its own defined behavior.

Paolo


So please make above "case 0:", and make the "default:" return
TDVMCALL_STATUS_INVALID_OPERAND

}
- return 1;
}

static int tdx_complete_simple(struct kvm_vcpu *vcpu)
diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
index 6708bc88ae69..fb3b4cd8d662 100644
--- a/include/uapi/linux/kvm.h
+++ b/include/uapi/linux/kvm.h
@@ -461,6 +461,11 @@ struct kvm_run {
__u64 gpa;
__u64 size;
} get_quote;
+ struct {
+ __u64 ret;
+ __u64 leaf;
+ __u64 r11, r12, r13, r14;
+ } get_tdvmcall_info;
};
} tdx;
/* Fix the size of the union. */