Documentation/virt/kvm/api.rst | 62 ++++++++++++++++++++++++- arch/x86/include/asm/shared/tdx.h | 1 + arch/x86/kvm/vmx/tdx.c | 77 ++++++++++++++++++++++++++++--- include/uapi/linux/kvm.h | 22 +++++++++ 4 files changed, 154 insertions(+), 8 deletions(-)
This is a refresh of Binbin's patches with a change to the userspace API. I am consolidating everything into a single KVM_EXIT_TDX and adding to the contract that userspace is free to ignore it *except* for having to reenter the guest with KVM_RUN. If in the future this does not work, it should be possible to introduce an opt-in interface. Hopefully that will not be necessary. Paolo Binbin Wu (3): KVM: TDX: Add new TDVMCALL status code for unsupported subfuncs KVM: TDX: Handle TDG.VP.VMCALL<GetQuote> KVM: TDX: Exit to userspace for GetTdVmCallInfo Documentation/virt/kvm/api.rst | 62 ++++++++++++++++++++++++- arch/x86/include/asm/shared/tdx.h | 1 + arch/x86/kvm/vmx/tdx.c | 77 ++++++++++++++++++++++++++++--- include/uapi/linux/kvm.h | 22 +++++++++ 4 files changed, 154 insertions(+), 8 deletions(-) -- 2.43.5
On 6/20/2025 2:01 AM, Paolo Bonzini wrote: > This is a refresh of Binbin's patches with a change to the userspace > API. I am consolidating everything into a single KVM_EXIT_TDX and > adding to the contract that userspace is free to ignore it *except* > for having to reenter the guest with KVM_RUN. > > If in the future this does not work, it should be possible to introduce > an opt-in interface. Hopefully that will not be necessary. > > Paolo > > Binbin Wu (3): > KVM: TDX: Add new TDVMCALL status code for unsupported subfuncs > KVM: TDX: Handle TDG.VP.VMCALL<GetQuote> > KVM: TDX: Exit to userspace for GetTdVmCallInfo > > Documentation/virt/kvm/api.rst | 62 ++++++++++++++++++++++++- > arch/x86/include/asm/shared/tdx.h | 1 + > arch/x86/kvm/vmx/tdx.c | 77 ++++++++++++++++++++++++++++--- > include/uapi/linux/kvm.h | 22 +++++++++ > 4 files changed, 154 insertions(+), 8 deletions(-) > Tested the patch set with the TDX kvm-unit-tests, TDX enhanced KVM selftests, booting a Linux TD, and TDX related test cases defined in the LKVS test suite as described in: https://github.com/intel/lkvs/blob/main/KVM/docs/lkvs_on_avocado.md Xiaoyao has tested the flow for GetQuote and had some comments for small issues on qemu patch: https://mail.gnu.org/archive/html/qemu-devel/2025-06/msg03154.html
On 6/20/2025 2:01 AM, Paolo Bonzini wrote: > This is a refresh of Binbin's patches with a change to the userspace > API. I am consolidating everything into a single KVM_EXIT_TDX and > adding to the contract that userspace is free to ignore it *except* > for having to reenter the guest with KVM_RUN. > > If in the future this does not work, it should be possible to introduce > an opt-in interface. Hopefully that will not be necessary. For <GetTdVmCallInfo> exit, I think KVM still needs to report which TDVMCALL leaf will exit to userspace, to differentiate between different KVMs. But it's not a must for current <GetQuote> since it exits to userspace from day 0. So that we can leave the report interface until KVM needs to support user exit of another TDVMCALL leaf. > Paolo > > Binbin Wu (3): > KVM: TDX: Add new TDVMCALL status code for unsupported subfuncs > KVM: TDX: Handle TDG.VP.VMCALL<GetQuote> > KVM: TDX: Exit to userspace for GetTdVmCallInfo > > Documentation/virt/kvm/api.rst | 62 ++++++++++++++++++++++++- > arch/x86/include/asm/shared/tdx.h | 1 + > arch/x86/kvm/vmx/tdx.c | 77 ++++++++++++++++++++++++++++--- > include/uapi/linux/kvm.h | 22 +++++++++ > 4 files changed, 154 insertions(+), 8 deletions(-) >
Il ven 20 giu 2025, 03:30 Xiaoyao Li <xiaoyao.li@intel.com> ha scritto: > > On 6/20/2025 2:01 AM, Paolo Bonzini wrote: > > This is a refresh of Binbin's patches with a change to the userspace > > API. I am consolidating everything into a single KVM_EXIT_TDX and > > adding to the contract that userspace is free to ignore it *except* > > for having to reenter the guest with KVM_RUN. > > > > If in the future this does not work, it should be possible to introduce > > an opt-in interface. Hopefully that will not be necessary. > > For <GetTdVmCallInfo> exit, I think KVM still needs to report which > TDVMCALL leaf will exit to userspace, to differentiate between different > KVMs. The interface I chose is that KVM always exits, but it initializes the output values such that userspace can leave them untouched for unknown TDVMCALLs or unknown leaves. So there is no need for this. Querying kernel support of other services can be added later, but unless the GHCI adds more input or output fields to TdVmCallInfo there is no need to limit the userspace exit to leaf 1. Paolo > > But it's not a must for current <GetQuote> since it exits to userspace > from day 0. So that we can leave the report interface until KVM needs to > support user exit of another TDVMCALL leaf. > > > Paolo > > > > Binbin Wu (3): > > KVM: TDX: Add new TDVMCALL status code for unsupported subfuncs > > KVM: TDX: Handle TDG.VP.VMCALL<GetQuote> > > KVM: TDX: Exit to userspace for GetTdVmCallInfo > > > > Documentation/virt/kvm/api.rst | 62 ++++++++++++++++++++++++- > > arch/x86/include/asm/shared/tdx.h | 1 + > > arch/x86/kvm/vmx/tdx.c | 77 ++++++++++++++++++++++++++++--- > > include/uapi/linux/kvm.h | 22 +++++++++ > > 4 files changed, 154 insertions(+), 8 deletions(-) > > >
On 6/20/2025 8:03 PM, Paolo Bonzini wrote: > Il ven 20 giu 2025, 03:30 Xiaoyao Li <xiaoyao.li@intel.com> ha scritto: >> >> On 6/20/2025 2:01 AM, Paolo Bonzini wrote: >>> This is a refresh of Binbin's patches with a change to the userspace >>> API. I am consolidating everything into a single KVM_EXIT_TDX and >>> adding to the contract that userspace is free to ignore it *except* >>> for having to reenter the guest with KVM_RUN. >>> >>> If in the future this does not work, it should be possible to introduce >>> an opt-in interface. Hopefully that will not be necessary. >> >> For <GetTdVmCallInfo> exit, I think KVM still needs to report which >> TDVMCALL leaf will exit to userspace, to differentiate between different >> KVMs. > > > The interface I chose is that KVM always exits, but it initializes the > output values such that userspace can leave them untouched for unknown > TDVMCALLs or unknown leaves. So there is no need for this. > > Querying kernel support of other services can be added later, but > unless the GHCI adds more input or output fields to TdVmCallInfo there > is no need to limit the userspace exit to leaf 1. I meant the case where KVM is going to support another optional TDVMCALL leaf in the future, e.g., SetEventNotifyInterrupt. At that time, userspace needs to differentiate between old KVM which only supports <GetQuote> and new KVM which supports both <GetQuote> and <SetEventNotifyInterrupt>. - If it's old KVM, userspace should only set <GetQuote> bit in GetTdVmCallInfo exit. If userspace sets <SetEventNotifyInterrupt> in GetTdVmCallInfo exit and enumerate to TD guest, but it's wrong info since the KVM doesn't support <SetEventNotifyInterrupt> and userspace won't get any chance to handle the guest call of <SetEventNotifyInterrupt> - But if it's new KVM, userspace can <SetEventNotifyInterrupt> bit in GetTdVmCallInfo exit and enumerate to TD guest. Anyway, its the future problem, there should be various options to handle it in the future. This series works for the current need. > > Paolo > >> >> But it's not a must for current <GetQuote> since it exits to userspace >> from day 0. So that we can leave the report interface until KVM needs to >> support user exit of another TDVMCALL leaf. >> >>> Paolo >>> >>> Binbin Wu (3): >>> KVM: TDX: Add new TDVMCALL status code for unsupported subfuncs >>> KVM: TDX: Handle TDG.VP.VMCALL<GetQuote> >>> KVM: TDX: Exit to userspace for GetTdVmCallInfo >>> >>> Documentation/virt/kvm/api.rst | 62 ++++++++++++++++++++++++- >>> arch/x86/include/asm/shared/tdx.h | 1 + >>> arch/x86/kvm/vmx/tdx.c | 77 ++++++++++++++++++++++++++++--- >>> include/uapi/linux/kvm.h | 22 +++++++++ >>> 4 files changed, 154 insertions(+), 8 deletions(-) >>> >> >
On Fri, Jun 20, 2025 at 2:48 PM Xiaoyao Li <xiaoyao.li@intel.com> wrote: > > The interface I chose is that KVM always exits, but it initializes the > > output values such that userspace can leave them untouched for unknown > > TDVMCALLs or unknown leaves. So there is no need for this. > > > > Querying kernel support of other services can be added later, but > > unless the GHCI adds more input or output fields to TdVmCallInfo there > > is no need to limit the userspace exit to leaf 1. > > I meant the case where KVM is going to support another optional TDVMCALL > leaf in the future, e.g., SetEventNotifyInterrupt. At that time, > userspace needs to differentiate between old KVM which only supports > <GetQuote> and new KVM which supports both <GetQuote> and > <SetEventNotifyInterrupt>. Yeah, I see what you mean now. Userspace cannot know which TDVMCALL will exit, other than GET_QUOTE which we know is in the first part. By the way I'm tempted to implement SetupEventNotifyInterrupt as well, it's just a handful of lines of code. Paolo
On Fri, 2025-06-20 at 19:24 +0200, Paolo Bonzini wrote: > On Fri, Jun 20, 2025 at 2:48 PM Xiaoyao Li <xiaoyao.li@intel.com> wrote: > > > The interface I chose is that KVM always exits, but it initializes the > > > output values such that userspace can leave them untouched for unknown > > > TDVMCALLs or unknown leaves. So there is no need for this. > > > > > > Querying kernel support of other services can be added later, but > > > unless the GHCI adds more input or output fields to TdVmCallInfo there > > > is no need to limit the userspace exit to leaf 1. > > > > I meant the case where KVM is going to support another optional TDVMCALL > > leaf in the future, e.g., SetEventNotifyInterrupt. At that time, > > userspace needs to differentiate between old KVM which only supports > > <GetQuote> and new KVM which supports both <GetQuote> and > > <SetEventNotifyInterrupt>. > > Yeah, I see what you mean now. Userspace cannot know which TDVMCALL > will exit, other than GET_QUOTE which we know is in the first part. How about we expose the KVM supported GHCI exits in KVM_TDX_CAPABILITIES? We had been discussing this as an option. It is not needed for the initial fixup series I think. It can include GHCI calls handled within KVM, and ones that are supported via exits. > > By the way I'm tempted to implement SetupEventNotifyInterrupt as well, > it's just a handful of lines of code. Seems ok to me. In general I think we should lean towards implementing the minimum. It seems we are still in the learning period and have already had some TDX arch course corrections. If a GetQuote2, SetEventNotifyInterrupt2, etc shows up, it all starts to add up. Having a KVM_EXIT_TDX will help there, from the KVM side at least.
On 6/20/2025 9:30 AM, Xiaoyao Li wrote: > On 6/20/2025 2:01 AM, Paolo Bonzini wrote: >> This is a refresh of Binbin's patches with a change to the userspace >> API. I am consolidating everything into a single KVM_EXIT_TDX and >> adding to the contract that userspace is free to ignore it *except* >> for having to reenter the guest with KVM_RUN. >> >> If in the future this does not work, it should be possible to introduce >> an opt-in interface. Hopefully that will not be necessary. > > For <GetTdVmCallInfo> exit, I think KVM still needs to report which TDVMCALL leaf will exit to userspace, to differentiate between different KVMs. Yes, I planned a v2 to expose the bitmap of TDVMCALLs that KVM will exit to userspace VMM for handling via KVM_TDX_CAPABILITIES. > > But it's not a must for current <GetQuote> since it exits to userspace from day 0. So that we can leave the report interface until KVM needs to support user exit of another TDVMCALL leaf. Agree. This report interface can be added later when needed. About the compatibility: Since <GetQuote> is the only optional TDVMCALL for now and KVM always exit to userspace for <GetQuote>, a userspace VMM can always set the bit for <GetQuote> if it's supported in userspace. Then - First KVM release + new userspace VMM release with report interface. Userspace will see nothing reported by the interface, and it always sets <GetQuote> , which is expected. - New KVM release with report interface + first userspace VMM release Userspace doesn't know the report interface and it only sets <GetQuote>, which is expected. > >> Paolo >> >> Binbin Wu (3): >> KVM: TDX: Add new TDVMCALL status code for unsupported subfuncs >> KVM: TDX: Handle TDG.VP.VMCALL<GetQuote> >> KVM: TDX: Exit to userspace for GetTdVmCallInfo >> >> Documentation/virt/kvm/api.rst | 62 ++++++++++++++++++++++++- >> arch/x86/include/asm/shared/tdx.h | 1 + >> arch/x86/kvm/vmx/tdx.c | 77 ++++++++++++++++++++++++++++--- >> include/uapi/linux/kvm.h | 22 +++++++++ >> 4 files changed, 154 insertions(+), 8 deletions(-) >> >
© 2016 - 2025 Red Hat, Inc.