From: Peter Fang KVM needs to know if the Quoting extension is available to determine whether userspace must be involved in Quote generation. Since the Quote buffer is always created during Quoting extension bringup, checking whether the buffer exists is sufficient. Signed-off-by: Peter Fang Signed-off-by: Xu Yilun --- arch/x86/include/asm/tdx.h | 2 ++ arch/x86/virt/vmx/tdx/tdx.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/arch/x86/include/asm/tdx.h b/arch/x86/include/asm/tdx.h index 15eac89b0afb..7b257088aa1e 100644 --- a/arch/x86/include/asm/tdx.h +++ b/arch/x86/include/asm/tdx.h @@ -176,6 +176,8 @@ struct tdx_vp { struct page **tdcx_pages; }; +bool tdx_quote_enabled(void); + static inline u64 mk_keyed_paddr(u16 hkid, struct page *page) { u64 ret; diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c index 9d04293394d7..b305fa5aab5c 100644 --- a/arch/x86/virt/vmx/tdx/tdx.c +++ b/arch/x86/virt/vmx/tdx/tdx.c @@ -1213,6 +1213,21 @@ static inline u64 tdx_tdr_pa(struct tdx_td *td) return page_to_phys(td->tdr_page); } +/** + * tdx_quote_enabled() - Check whether TDX Quoting extension is available + * + * Return: %true if the Quoting extension is available, otherwise %false. + */ +bool tdx_quote_enabled(void) +{ + /* + * No need for locking here. The quote buffer is initialized as part of + * core TDX bringup, which comes before KVM is ready for userspace. + */ + return !!quote_data.buf; +} +EXPORT_SYMBOL_FOR_KVM(tdx_quote_enabled); + #define HPAS_PER_PAGE (PAGE_SIZE / sizeof(u64)) static int tdx_quote_create_buf(unsigned int nr_pages, struct quote_data *qdata) -- 2.25.1