Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * tboot.h: shared data structure with tboot and kernel and functions
0004  *          used by kernel for runtime support of Intel(R) Trusted
0005  *          Execution Technology
0006  *
0007  * Copyright (c) 2006-2009, Intel Corporation
0008  */
0009 
0010 #ifndef _LINUX_TBOOT_H
0011 #define _LINUX_TBOOT_H
0012 
0013 /* these must have the values from 0-5 in this order */
0014 enum {
0015     TB_SHUTDOWN_REBOOT = 0,
0016     TB_SHUTDOWN_S5,
0017     TB_SHUTDOWN_S4,
0018     TB_SHUTDOWN_S3,
0019     TB_SHUTDOWN_HALT,
0020     TB_SHUTDOWN_WFS
0021 };
0022 
0023 #ifdef CONFIG_INTEL_TXT
0024 #include <linux/acpi.h>
0025 /* used to communicate between tboot and the launched kernel */
0026 
0027 #define TB_KEY_SIZE             64   /* 512 bits */
0028 
0029 #define MAX_TB_MAC_REGIONS      32
0030 
0031 struct tboot_mac_region {
0032     u64  start;         /* must be 64 byte -aligned */
0033     u32  size;          /* must be 64 byte -granular */
0034 } __packed;
0035 
0036 /* GAS - Generic Address Structure (ACPI 2.0+) */
0037 struct tboot_acpi_generic_address {
0038     u8  space_id;
0039     u8  bit_width;
0040     u8  bit_offset;
0041     u8  access_width;
0042     u64 address;
0043 } __packed;
0044 
0045 /*
0046  * combines Sx info from FADT and FACS tables per ACPI 2.0+ spec
0047  * (https://uefi.org/specifications)
0048  */
0049 struct tboot_acpi_sleep_info {
0050     struct tboot_acpi_generic_address pm1a_cnt_blk;
0051     struct tboot_acpi_generic_address pm1b_cnt_blk;
0052     struct tboot_acpi_generic_address pm1a_evt_blk;
0053     struct tboot_acpi_generic_address pm1b_evt_blk;
0054     u16 pm1a_cnt_val;
0055     u16 pm1b_cnt_val;
0056     u64 wakeup_vector;
0057     u32 vector_width;
0058     u64 kernel_s3_resume_vector;
0059 } __packed;
0060 
0061 /*
0062  * shared memory page used for communication between tboot and kernel
0063  */
0064 struct tboot {
0065     /*
0066      * version 3+ fields:
0067      */
0068 
0069     /* TBOOT_UUID */
0070     u8 uuid[16];
0071 
0072     /* version number: 5 is current */
0073     u32 version;
0074 
0075     /* physical addr of tb_log_t log */
0076     u32 log_addr;
0077 
0078     /*
0079      * physical addr of entry point for tboot shutdown and
0080      * type of shutdown (TB_SHUTDOWN_*) being requested
0081      */
0082     u32 shutdown_entry;
0083     u32 shutdown_type;
0084 
0085     /* kernel-specified ACPI info for Sx shutdown */
0086     struct tboot_acpi_sleep_info acpi_sinfo;
0087 
0088     /* tboot location in memory (physical) */
0089     u32 tboot_base;
0090     u32 tboot_size;
0091 
0092     /* memory regions (phys addrs) for tboot to MAC on S3 */
0093     u8 num_mac_regions;
0094     struct tboot_mac_region mac_regions[MAX_TB_MAC_REGIONS];
0095 
0096 
0097     /*
0098      * version 4+ fields:
0099      */
0100 
0101     /* symmetric key for use by kernel; will be encrypted on S3 */
0102     u8 s3_key[TB_KEY_SIZE];
0103 
0104 
0105     /*
0106      * version 5+ fields:
0107      */
0108 
0109     /* used to 4byte-align num_in_wfs */
0110     u8 reserved_align[3];
0111 
0112     /* number of processors in wait-for-SIPI */
0113     u32 num_in_wfs;
0114 } __packed;
0115 
0116 /*
0117  * UUID for tboot data struct to facilitate matching
0118  * defined as {663C8DFF-E8B3-4b82-AABF-19EA4D057A08} by tboot, which is
0119  * represented as {} in the char array used here
0120  */
0121 #define TBOOT_UUID  {0xff, 0x8d, 0x3c, 0x66, 0xb3, 0xe8, 0x82, 0x4b, 0xbf,\
0122              0xaa, 0x19, 0xea, 0x4d, 0x5, 0x7a, 0x8}
0123 
0124 bool tboot_enabled(void);
0125 extern void tboot_probe(void);
0126 extern void tboot_shutdown(u32 shutdown_type);
0127 extern struct acpi_table_header *tboot_get_dmar_table(
0128                       struct acpi_table_header *dmar_tbl);
0129 
0130 #else
0131 
0132 #define tboot_enabled()         0
0133 #define tboot_probe()           do { } while (0)
0134 #define tboot_shutdown(shutdown_type)   do { } while (0)
0135 #define tboot_sleep(sleep_state, pm1a_control, pm1b_control)    \
0136                     do { } while (0)
0137 #define tboot_get_dmar_table(dmar_tbl)  (dmar_tbl)
0138 
0139 #endif /* !CONFIG_INTEL_TXT */
0140 
0141 #endif /* _LINUX_TBOOT_H */