mirror of
https://git.proxmox.com/git/mirror_ubuntu-kernels.git
synced 2025-12-07 13:27:22 +00:00
In TDX guest, the attestation process is used to verify the TDX guest trustworthiness to other entities before provisioning secrets to the guest. The first step in the attestation process is TDREPORT generation, which involves getting the guest measurement data in the format of TDREPORT, which is further used to validate the authenticity of the TDX guest. TDREPORT by design is integrity-protected and can only be verified on the local machine. To support remote verification of the TDREPORT in a SGX-based attestation, the TDREPORT needs to be sent to the SGX Quoting Enclave (QE) to convert it to a remotely verifiable Quote. SGX QE by design can only run outside of the TDX guest (i.e. in a host process or in a normal VM) and guest can use communication channels like vsock or TCP/IP to send the TDREPORT to the QE. But for security concerns, the TDX guest may not support these communication channels. To handle such cases, TDX defines a GetQuote hypercall which can be used by the guest to request the host VMM to communicate with the SGX QE. More details about GetQuote hypercall can be found in TDX Guest-Host Communication Interface (GHCI) for Intel TDX 1.0, section titled "TDG.VP.VMCALL<GetQuote>". Trusted Security Module (TSM) [1] exposes a common ABI for Confidential Computing Guest platforms to get the measurement data via ConfigFS. Extend the TSM framework and add support to allow an attestation agent to get the TDX Quote data (included usage example below). report=/sys/kernel/config/tsm/report/report0 mkdir $report dd if=/dev/urandom bs=64 count=1 > $report/inblob hexdump -C $report/outblob rmdir $report GetQuote TDVMCALL requires TD guest pass a 4K aligned shared buffer with TDREPORT data as input, which is further used by the VMM to copy the TD Quote result after successful Quote generation. To create the shared buffer, allocate a large enough memory and mark it shared using set_memory_decrypted() in tdx_guest_init(). This buffer will be re-used for GetQuote requests in the TDX TSM handler. Although this method reserves a fixed chunk of memory for GetQuote requests, such one time allocation can help avoid memory fragmentation related allocation failures later in the uptime of the guest. Since the Quote generation process is not time-critical or frequently used, the current version uses a polling model for Quote requests and it also does not support parallel GetQuote requests. Link: https://lore.kernel.org/lkml/169342399185.3934343.3035845348326944519.stgit@dwillia2-xfh.jf.intel.com/ [1] Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> Reviewed-by: Erdem Aktas <erdemaktas@google.com> Tested-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> Tested-by: Peter Gonda <pgonda@google.com> Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
110 lines
2.6 KiB
C
110 lines
2.6 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _ASM_X86_SHARED_TDX_H
|
|
#define _ASM_X86_SHARED_TDX_H
|
|
|
|
#include <linux/bits.h>
|
|
#include <linux/types.h>
|
|
|
|
#define TDX_HYPERCALL_STANDARD 0
|
|
|
|
#define TDX_CPUID_LEAF_ID 0x21
|
|
#define TDX_IDENT "IntelTDX "
|
|
|
|
/* TDX module Call Leaf IDs */
|
|
#define TDX_GET_INFO 1
|
|
#define TDX_GET_VEINFO 3
|
|
#define TDX_GET_REPORT 4
|
|
#define TDX_ACCEPT_PAGE 6
|
|
#define TDX_WR 8
|
|
|
|
/* TDCS fields. To be used by TDG.VM.WR and TDG.VM.RD module calls */
|
|
#define TDCS_NOTIFY_ENABLES 0x9100000000000010
|
|
|
|
/* TDX hypercall Leaf IDs */
|
|
#define TDVMCALL_MAP_GPA 0x10001
|
|
#define TDVMCALL_GET_QUOTE 0x10002
|
|
#define TDVMCALL_REPORT_FATAL_ERROR 0x10003
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
/*
|
|
* Used in __tdx_hypercall() to pass down and get back registers' values of
|
|
* the TDCALL instruction when requesting services from the VMM.
|
|
*
|
|
* This is a software only structure and not part of the TDX module/VMM ABI.
|
|
*/
|
|
struct tdx_hypercall_args {
|
|
u64 r8;
|
|
u64 r9;
|
|
u64 r10;
|
|
u64 r11;
|
|
u64 r12;
|
|
u64 r13;
|
|
u64 r14;
|
|
u64 r15;
|
|
u64 rdi;
|
|
u64 rsi;
|
|
u64 rbx;
|
|
u64 rdx;
|
|
};
|
|
|
|
/* Used to request services from the VMM */
|
|
u64 __tdx_hypercall(struct tdx_hypercall_args *args);
|
|
u64 __tdx_hypercall_ret(struct tdx_hypercall_args *args);
|
|
|
|
/*
|
|
* Wrapper for standard use of __tdx_hypercall with no output aside from
|
|
* return code.
|
|
*/
|
|
static inline u64 _tdx_hypercall(u64 fn, u64 r12, u64 r13, u64 r14, u64 r15)
|
|
{
|
|
struct tdx_hypercall_args args = {
|
|
.r10 = TDX_HYPERCALL_STANDARD,
|
|
.r11 = fn,
|
|
.r12 = r12,
|
|
.r13 = r13,
|
|
.r14 = r14,
|
|
.r15 = r15,
|
|
};
|
|
|
|
return __tdx_hypercall(&args);
|
|
}
|
|
|
|
|
|
/* Called from __tdx_hypercall() for unrecoverable failure */
|
|
void __tdx_hypercall_failed(void);
|
|
|
|
/*
|
|
* Used in __tdx_module_call() to gather the output registers' values of the
|
|
* TDCALL instruction when requesting services from the TDX module. This is a
|
|
* software only structure and not part of the TDX module/VMM ABI
|
|
*/
|
|
struct tdx_module_output {
|
|
u64 rcx;
|
|
u64 rdx;
|
|
u64 r8;
|
|
u64 r9;
|
|
u64 r10;
|
|
u64 r11;
|
|
};
|
|
|
|
/* Used to communicate with the TDX module */
|
|
u64 __tdx_module_call(u64 fn, u64 rcx, u64 rdx, u64 r8, u64 r9,
|
|
struct tdx_module_output *out);
|
|
|
|
bool tdx_accept_memory(phys_addr_t start, phys_addr_t end);
|
|
|
|
/*
|
|
* The TDG.VP.VMCALL-Instruction-execution sub-functions are defined
|
|
* independently from but are currently matched 1:1 with VMX EXIT_REASONs.
|
|
* Reusing the KVM EXIT_REASON macros makes it easier to connect the host and
|
|
* guest sides of these calls.
|
|
*/
|
|
static __always_inline u64 hcall_func(u64 exit_reason)
|
|
{
|
|
return exit_reason;
|
|
}
|
|
|
|
#endif /* !__ASSEMBLY__ */
|
|
#endif /* _ASM_X86_SHARED_TDX_H */
|