Skip to content

Commit 5e2cb28

Browse files
committed
Merge tag 'tsm-for-6.7' of git://git.kernel.org/pub/scm/linux/kernel/git/djbw/linux
Pull unified attestation reporting from Dan Williams: "In an ideal world there would be a cross-vendor standard attestation report format for confidential guests along with a common device definition to act as the transport. In the real world the situation ended up with multiple platform vendors inventing their own attestation report formats with the SEV-SNP implementation being a first mover to define a custom sev-guest character device and corresponding ioctl(). Later, this configfs-tsm proposal intercepted an attempt to add a tdx-guest character device and a corresponding new ioctl(). It also anticipated ARM and RISC-V showing up with more chardevs and more ioctls(). The proposal takes for granted that Linux tolerates the vendor report format differentiation until a standard arrives. From talking with folks involved, it sounds like that standardization work is unlikely to resolve anytime soon. It also takes the position that kernfs ABIs are easier to maintain than ioctl(). The result is a shared configfs mechanism to return per-vendor report-blobs with the option to later support a standard when that arrives. Part of the goal here also is to get the community into the "uncomfortable, but beneficial to the long term maintainability of the kernel" state of talking to each other about their differentiation and opportunities to collaborate. Think of this like the device-driver equivalent of the common memory-management infrastructure for confidential-computing being built up in KVM. As for establishing an "upstream path for cross-vendor confidential-computing device driver infrastructure" this is something I want to discuss at Plumbers. At present, the multiple vendor proposals for assigning devices to confidential computing VMs likely needs a new dedicated repository and maintainer team, but that is a discussion for v6.8. For now, Greg and Thomas have acked this approach and this is passing is AMD, Intel, and Google tests. Summary: - Introduce configfs-tsm as a shared ABI for confidential computing attestation reports - Convert sev-guest to additionally support configfs-tsm alongside its vendor specific ioctl() - Added signed attestation report retrieval to the tdx-guest driver forgoing a new vendor specific ioctl() - Misc cleanups and a new __free() annotation for kvfree()" * tag 'tsm-for-6.7' of git://git.kernel.org/pub/scm/linux/kernel/git/djbw/linux: virt: tdx-guest: Add Quote generation support using TSM_REPORTS virt: sevguest: Add TSM_REPORTS support for SNP_GET_EXT_REPORT mm/slab: Add __free() support for kvfree virt: sevguest: Prep for kernel internal get_ext_report() configfs-tsm: Introduce a shared ABI for attestation reports virt: coco: Add a coco/Makefile and coco/Kconfig virt: sevguest: Fix passing a stack buffer as a scatterlist target
2 parents b1dfbda + f4738f5 commit 5e2cb28

File tree

18 files changed

+1055
-37
lines changed

18 files changed

+1055
-37
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
What: /sys/kernel/config/tsm/report/$name/inblob
2+
Date: September, 2023
3+
KernelVersion: v6.7
4+
5+
Description:
6+
(WO) Up to 64 bytes of user specified binary data. For replay
7+
protection this should include a nonce, but the kernel does not
8+
place any restrictions on the content.
9+
10+
What: /sys/kernel/config/tsm/report/$name/outblob
11+
Date: September, 2023
12+
KernelVersion: v6.7
13+
14+
Description:
15+
(RO) Binary attestation report generated from @inblob and other
16+
options The format of the report is implementation specific
17+
where the implementation is conveyed via the @provider
18+
attribute.
19+
20+
What: /sys/kernel/config/tsm/report/$name/auxblob
21+
Date: October, 2023
22+
KernelVersion: v6.7
23+
24+
Description:
25+
(RO) Optional supplemental data that a TSM may emit, visibility
26+
of this attribute depends on TSM, and may be empty if no
27+
auxiliary data is available.
28+
29+
When @provider is "sev_guest" this file contains the
30+
"cert_table" from SEV-ES Guest-Hypervisor Communication Block
31+
Standardization v2.03 Section 4.1.8.1 MSG_REPORT_REQ.
32+
https://www.amd.com/content/dam/amd/en/documents/epyc-technical-docs/specifications/56421.pdf
33+
34+
What: /sys/kernel/config/tsm/report/$name/provider
35+
Date: September, 2023
36+
KernelVersion: v6.7
37+
38+
Description:
39+
(RO) A name for the format-specification of @outblob like
40+
"sev_guest" [1] or "tdx_guest" [2] in the near term, or a
41+
common standard format in the future.
42+
43+
[1]: SEV Secure Nested Paging Firmware ABI Specification
44+
Revision 1.55 Table 22
45+
https://www.amd.com/content/dam/amd/en/documents/epyc-technical-docs/specifications/56860.pdf
46+
47+
[2]: Intel® Trust Domain Extensions Data Center Attestation
48+
Primitives : Quote Generation Library and Quote Verification
49+
Library Revision 0.8 Appendix 4,5
50+
https://download.01.org/intel-sgx/latest/dcap-latest/linux/docs/Intel_TDX_DCAP_Quoting_Library_API.pdf
51+
52+
What: /sys/kernel/config/tsm/report/$name/generation
53+
Date: September, 2023
54+
KernelVersion: v6.7
55+
56+
Description:
57+
(RO) The value in this attribute increments each time @inblob or
58+
any option is written. Userspace can detect conflicts by
59+
checking generation before writing to any attribute and making
60+
sure the number of writes matches expectations after reading
61+
@outblob, or it can prevent conflicts by creating a report
62+
instance per requesting context.
63+
64+
What: /sys/kernel/config/tsm/report/$name/privlevel
65+
Date: September, 2023
66+
KernelVersion: v6.7
67+
68+
Description:
69+
(WO) Attribute is visible if a TSM implementation provider
70+
supports the concept of attestation reports for TVMs running at
71+
different privilege levels, like SEV-SNP "VMPL", specify the
72+
privilege level via this attribute. The minimum acceptable
73+
value is conveyed via @privlevel_floor and the maximum
74+
acceptable value is TSM_PRIVLEVEL_MAX (3).
75+
76+
What: /sys/kernel/config/tsm/report/$name/privlevel_floor
77+
Date: September, 2023
78+
KernelVersion: v6.7
79+
80+
Description:
81+
(RO) Indicates the minimum permissible value that can be written
82+
to @privlevel.

MAINTAINERS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22058,6 +22058,14 @@ W: https://github.com/srcres258/linux-doc
2205822058
T: git git://github.com/srcres258/linux-doc.git doc-zh-tw
2205922059
F: Documentation/translations/zh_TW/
2206022060

22061+
TRUSTED SECURITY MODULE (TSM) ATTESTATION REPORTS
22062+
M: Dan Williams <[email protected]>
22063+
22064+
S: Maintained
22065+
F: Documentation/ABI/testing/configfs-tsm
22066+
F: drivers/virt/coco/tsm.c
22067+
F: include/linux/tsm.h
22068+
2206122069
TTY LAYER AND SERIAL DRIVERS
2206222070
M: Greg Kroah-Hartman <[email protected]>
2206322071
M: Jiri Slaby <[email protected]>

arch/x86/coco/tdx/tdx.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,27 @@ int tdx_mcall_get_report0(u8 *reportdata, u8 *tdreport)
106106
}
107107
EXPORT_SYMBOL_GPL(tdx_mcall_get_report0);
108108

109+
/**
110+
* tdx_hcall_get_quote() - Wrapper to request TD Quote using GetQuote
111+
* hypercall.
112+
* @buf: Address of the directly mapped shared kernel buffer which
113+
* contains TDREPORT. The same buffer will be used by VMM to
114+
* store the generated TD Quote output.
115+
* @size: size of the tdquote buffer (4KB-aligned).
116+
*
117+
* Refer to section titled "TDG.VP.VMCALL<GetQuote>" in the TDX GHCI
118+
* v1.0 specification for more information on GetQuote hypercall.
119+
* It is used in the TDX guest driver module to get the TD Quote.
120+
*
121+
* Return 0 on success or error code on failure.
122+
*/
123+
u64 tdx_hcall_get_quote(u8 *buf, size_t size)
124+
{
125+
/* Since buf is a shared memory, set the shared (decrypted) bits */
126+
return _tdx_hypercall(TDVMCALL_GET_QUOTE, cc_mkdec(virt_to_phys(buf)), size, 0, 0);
127+
}
128+
EXPORT_SYMBOL_GPL(tdx_hcall_get_quote);
129+
109130
static void __noreturn tdx_panic(const char *msg)
110131
{
111132
struct tdx_module_args args = {

arch/x86/include/asm/shared/tdx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
/* TDX hypercall Leaf IDs */
2525
#define TDVMCALL_MAP_GPA 0x10001
26+
#define TDVMCALL_GET_QUOTE 0x10002
2627
#define TDVMCALL_REPORT_FATAL_ERROR 0x10003
2728

2829
#define TDVMCALL_STATUS_RETRY 1

arch/x86/include/asm/tdx.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ bool tdx_early_handle_ve(struct pt_regs *regs);
5656

5757
int tdx_mcall_get_report0(u8 *reportdata, u8 *tdreport);
5858

59+
u64 tdx_hcall_get_quote(u8 *buf, size_t size);
60+
5961
#else
6062

6163
static inline void tdx_early_init(void) { };

drivers/virt/Kconfig

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ source "drivers/virt/nitro_enclaves/Kconfig"
4848

4949
source "drivers/virt/acrn/Kconfig"
5050

51-
source "drivers/virt/coco/efi_secret/Kconfig"
52-
53-
source "drivers/virt/coco/sev-guest/Kconfig"
54-
55-
source "drivers/virt/coco/tdx-guest/Kconfig"
51+
source "drivers/virt/coco/Kconfig"
5652

5753
endif

drivers/virt/Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,4 @@ obj-y += vboxguest/
99

1010
obj-$(CONFIG_NITRO_ENCLAVES) += nitro_enclaves/
1111
obj-$(CONFIG_ACRN_HSM) += acrn/
12-
obj-$(CONFIG_EFI_SECRET) += coco/efi_secret/
13-
obj-$(CONFIG_SEV_GUEST) += coco/sev-guest/
14-
obj-$(CONFIG_INTEL_TDX_GUEST) += coco/tdx-guest/
12+
obj-y += coco/

drivers/virt/coco/Kconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
#
3+
# Confidential computing related collateral
4+
#
5+
6+
config TSM_REPORTS
7+
select CONFIGFS_FS
8+
tristate
9+
10+
source "drivers/virt/coco/efi_secret/Kconfig"
11+
12+
source "drivers/virt/coco/sev-guest/Kconfig"
13+
14+
source "drivers/virt/coco/tdx-guest/Kconfig"

drivers/virt/coco/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
#
3+
# Confidential computing related collateral
4+
#
5+
obj-$(CONFIG_TSM_REPORTS) += tsm.o
6+
obj-$(CONFIG_EFI_SECRET) += efi_secret/
7+
obj-$(CONFIG_SEV_GUEST) += sev-guest/
8+
obj-$(CONFIG_INTEL_TDX_GUEST) += tdx-guest/

drivers/virt/coco/sev-guest/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ config SEV_GUEST
55
select CRYPTO
66
select CRYPTO_AEAD2
77
select CRYPTO_GCM
8+
select TSM_REPORTS
89
help
910
SEV-SNP firmware provides the guest a mechanism to communicate with
1011
the PSP without risk from a malicious hypervisor who wishes to read,

0 commit comments

Comments
 (0)