170e6f7e2SDan Williams /* SPDX-License-Identifier: GPL-2.0 */ 270e6f7e2SDan Williams #ifndef __TSM_H 370e6f7e2SDan Williams #define __TSM_H 470e6f7e2SDan Williams 570e6f7e2SDan Williams #include <linux/sizes.h> 670e6f7e2SDan Williams #include <linux/types.h> 7*627dc671STom Lendacky #include <linux/uuid.h> 870e6f7e2SDan Williams 970e6f7e2SDan Williams #define TSM_INBLOB_MAX 64 1070e6f7e2SDan Williams #define TSM_OUTBLOB_MAX SZ_32K 1170e6f7e2SDan Williams 1270e6f7e2SDan Williams /* 1370e6f7e2SDan Williams * Privilege level is a nested permission concept to allow confidential 1470e6f7e2SDan Williams * guests to partition address space, 4-levels are supported. 1570e6f7e2SDan Williams */ 1670e6f7e2SDan Williams #define TSM_PRIVLEVEL_MAX 3 1770e6f7e2SDan Williams 1870e6f7e2SDan Williams /** 1970e6f7e2SDan Williams * struct tsm_desc - option descriptor for generating tsm report blobs 2070e6f7e2SDan Williams * @privlevel: optional privilege level to associate with @outblob 2170e6f7e2SDan Williams * @inblob_len: sizeof @inblob 2270e6f7e2SDan Williams * @inblob: arbitrary input data 23*627dc671STom Lendacky * @service_provider: optional name of where to obtain the tsm report blob 24*627dc671STom Lendacky * @service_guid: optional service-provider service guid to attest 25*627dc671STom Lendacky * @service_manifest_version: optional service-provider service manifest version requested 2670e6f7e2SDan Williams */ 2770e6f7e2SDan Williams struct tsm_desc { 2870e6f7e2SDan Williams unsigned int privlevel; 2970e6f7e2SDan Williams size_t inblob_len; 3070e6f7e2SDan Williams u8 inblob[TSM_INBLOB_MAX]; 31*627dc671STom Lendacky char *service_provider; 32*627dc671STom Lendacky guid_t service_guid; 33*627dc671STom Lendacky unsigned int service_manifest_version; 3470e6f7e2SDan Williams }; 3570e6f7e2SDan Williams 3670e6f7e2SDan Williams /** 3770e6f7e2SDan Williams * struct tsm_report - track state of report generation relative to options 3870e6f7e2SDan Williams * @desc: input parameters to @report_new() 3970e6f7e2SDan Williams * @outblob_len: sizeof(@outblob) 4070e6f7e2SDan Williams * @outblob: generated evidence to provider to the attestation agent 4170e6f7e2SDan Williams * @auxblob_len: sizeof(@auxblob) 4270e6f7e2SDan Williams * @auxblob: (optional) auxiliary data to the report (e.g. certificate data) 43*627dc671STom Lendacky * @manifestblob_len: sizeof(@manifestblob) 44*627dc671STom Lendacky * @manifestblob: (optional) manifest data associated with the report 4570e6f7e2SDan Williams */ 4670e6f7e2SDan Williams struct tsm_report { 4770e6f7e2SDan Williams struct tsm_desc desc; 4870e6f7e2SDan Williams size_t outblob_len; 4970e6f7e2SDan Williams u8 *outblob; 5070e6f7e2SDan Williams size_t auxblob_len; 5170e6f7e2SDan Williams u8 *auxblob; 52*627dc671STom Lendacky size_t manifestblob_len; 53*627dc671STom Lendacky u8 *manifestblob; 5470e6f7e2SDan Williams }; 5570e6f7e2SDan Williams 5670e6f7e2SDan Williams /** 5720dfee95STom Lendacky * enum tsm_attr_index - index used to reference report attributes 5820dfee95STom Lendacky * @TSM_REPORT_GENERATION: index of the report generation number attribute 5920dfee95STom Lendacky * @TSM_REPORT_PROVIDER: index of the provider name attribute 6020dfee95STom Lendacky * @TSM_REPORT_PRIVLEVEL: index of the desired privilege level attribute 6120dfee95STom Lendacky * @TSM_REPORT_PRIVLEVEL_FLOOR: index of the minimum allowed privileg level attribute 62*627dc671STom Lendacky * @TSM_REPORT_SERVICE_PROVIDER: index of the service provider identifier attribute 63*627dc671STom Lendacky * @TSM_REPORT_SERVICE_GUID: index of the service GUID attribute 64*627dc671STom Lendacky * @TSM_REPORT_SERVICE_MANIFEST_VER: index of the service manifest version attribute 6520dfee95STom Lendacky */ 6620dfee95STom Lendacky enum tsm_attr_index { 6720dfee95STom Lendacky TSM_REPORT_GENERATION, 6820dfee95STom Lendacky TSM_REPORT_PROVIDER, 6920dfee95STom Lendacky TSM_REPORT_PRIVLEVEL, 7020dfee95STom Lendacky TSM_REPORT_PRIVLEVEL_FLOOR, 71*627dc671STom Lendacky TSM_REPORT_SERVICE_PROVIDER, 72*627dc671STom Lendacky TSM_REPORT_SERVICE_GUID, 73*627dc671STom Lendacky TSM_REPORT_SERVICE_MANIFEST_VER, 7420dfee95STom Lendacky }; 7520dfee95STom Lendacky 7620dfee95STom Lendacky /** 7720dfee95STom Lendacky * enum tsm_bin_attr_index - index used to reference binary report attributes 7820dfee95STom Lendacky * @TSM_REPORT_INBLOB: index of the binary report input attribute 7920dfee95STom Lendacky * @TSM_REPORT_OUTBLOB: index of the binary report output attribute 8020dfee95STom Lendacky * @TSM_REPORT_AUXBLOB: index of the binary auxiliary data attribute 81*627dc671STom Lendacky * @TSM_REPORT_MANIFESTBLOB: index of the binary manifest data attribute 8220dfee95STom Lendacky */ 8320dfee95STom Lendacky enum tsm_bin_attr_index { 8420dfee95STom Lendacky TSM_REPORT_INBLOB, 8520dfee95STom Lendacky TSM_REPORT_OUTBLOB, 8620dfee95STom Lendacky TSM_REPORT_AUXBLOB, 87*627dc671STom Lendacky TSM_REPORT_MANIFESTBLOB, 8820dfee95STom Lendacky }; 8920dfee95STom Lendacky 9020dfee95STom Lendacky /** 9170e6f7e2SDan Williams * struct tsm_ops - attributes and operations for tsm instances 9270e6f7e2SDan Williams * @name: tsm id reflected in /sys/kernel/config/tsm/report/$report/provider 9370e6f7e2SDan Williams * @privlevel_floor: convey base privlevel for nested scenarios 9470e6f7e2SDan Williams * @report_new: Populate @report with the report blob and auxblob 9570e6f7e2SDan Williams * (optional), return 0 on successful population, or -errno otherwise 9620dfee95STom Lendacky * @report_attr_visible: show or hide a report attribute entry 9720dfee95STom Lendacky * @report_bin_attr_visible: show or hide a report binary attribute entry 9870e6f7e2SDan Williams * 9970e6f7e2SDan Williams * Implementation specific ops, only one is expected to be registered at 10070e6f7e2SDan Williams * a time i.e. only one of "sev-guest", "tdx-guest", etc. 10170e6f7e2SDan Williams */ 10270e6f7e2SDan Williams struct tsm_ops { 10370e6f7e2SDan Williams const char *name; 104614dc0fbSTom Lendacky unsigned int privlevel_floor; 10570e6f7e2SDan Williams int (*report_new)(struct tsm_report *report, void *data); 10620dfee95STom Lendacky bool (*report_attr_visible)(int n); 10720dfee95STom Lendacky bool (*report_bin_attr_visible)(int n); 10870e6f7e2SDan Williams }; 10970e6f7e2SDan Williams 11020dfee95STom Lendacky int tsm_register(const struct tsm_ops *ops, void *priv); 11170e6f7e2SDan Williams int tsm_unregister(const struct tsm_ops *ops); 11270e6f7e2SDan Williams #endif /* __TSM_H */ 113