tboot.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * tboot.h: shared data structure with tboot and kernel and functions
  4. * used by kernel for runtime support of Intel(R) Trusted
  5. * Execution Technology
  6. *
  7. * Copyright (c) 2006-2009, Intel Corporation
  8. */
  9. #ifndef _LINUX_TBOOT_H
  10. #define _LINUX_TBOOT_H
  11. /* these must have the values from 0-5 in this order */
  12. enum {
  13. TB_SHUTDOWN_REBOOT = 0,
  14. TB_SHUTDOWN_S5,
  15. TB_SHUTDOWN_S4,
  16. TB_SHUTDOWN_S3,
  17. TB_SHUTDOWN_HALT,
  18. TB_SHUTDOWN_WFS
  19. };
  20. #ifdef CONFIG_INTEL_TXT
  21. #include <linux/acpi.h>
  22. /* used to communicate between tboot and the launched kernel */
  23. #define TB_KEY_SIZE 64 /* 512 bits */
  24. #define MAX_TB_MAC_REGIONS 32
  25. struct tboot_mac_region {
  26. u64 start; /* must be 64 byte -aligned */
  27. u32 size; /* must be 64 byte -granular */
  28. } __packed;
  29. /* GAS - Generic Address Structure (ACPI 2.0+) */
  30. struct tboot_acpi_generic_address {
  31. u8 space_id;
  32. u8 bit_width;
  33. u8 bit_offset;
  34. u8 access_width;
  35. u64 address;
  36. } __packed;
  37. /*
  38. * combines Sx info from FADT and FACS tables per ACPI 2.0+ spec
  39. * (https://uefi.org/specifications)
  40. */
  41. struct tboot_acpi_sleep_info {
  42. struct tboot_acpi_generic_address pm1a_cnt_blk;
  43. struct tboot_acpi_generic_address pm1b_cnt_blk;
  44. struct tboot_acpi_generic_address pm1a_evt_blk;
  45. struct tboot_acpi_generic_address pm1b_evt_blk;
  46. u16 pm1a_cnt_val;
  47. u16 pm1b_cnt_val;
  48. u64 wakeup_vector;
  49. u32 vector_width;
  50. u64 kernel_s3_resume_vector;
  51. } __packed;
  52. /*
  53. * shared memory page used for communication between tboot and kernel
  54. */
  55. struct tboot {
  56. /*
  57. * version 3+ fields:
  58. */
  59. /* TBOOT_UUID */
  60. u8 uuid[16];
  61. /* version number: 5 is current */
  62. u32 version;
  63. /* physical addr of tb_log_t log */
  64. u32 log_addr;
  65. /*
  66. * physical addr of entry point for tboot shutdown and
  67. * type of shutdown (TB_SHUTDOWN_*) being requested
  68. */
  69. u32 shutdown_entry;
  70. u32 shutdown_type;
  71. /* kernel-specified ACPI info for Sx shutdown */
  72. struct tboot_acpi_sleep_info acpi_sinfo;
  73. /* tboot location in memory (physical) */
  74. u32 tboot_base;
  75. u32 tboot_size;
  76. /* memory regions (phys addrs) for tboot to MAC on S3 */
  77. u8 num_mac_regions;
  78. struct tboot_mac_region mac_regions[MAX_TB_MAC_REGIONS];
  79. /*
  80. * version 4+ fields:
  81. */
  82. /* symmetric key for use by kernel; will be encrypted on S3 */
  83. u8 s3_key[TB_KEY_SIZE];
  84. /*
  85. * version 5+ fields:
  86. */
  87. /* used to 4byte-align num_in_wfs */
  88. u8 reserved_align[3];
  89. /* number of processors in wait-for-SIPI */
  90. u32 num_in_wfs;
  91. } __packed;
  92. /*
  93. * UUID for tboot data struct to facilitate matching
  94. * defined as {663C8DFF-E8B3-4b82-AABF-19EA4D057A08} by tboot, which is
  95. * represented as {} in the char array used here
  96. */
  97. #define TBOOT_UUID {0xff, 0x8d, 0x3c, 0x66, 0xb3, 0xe8, 0x82, 0x4b, 0xbf,\
  98. 0xaa, 0x19, 0xea, 0x4d, 0x5, 0x7a, 0x8}
  99. bool tboot_enabled(void);
  100. extern void tboot_probe(void);
  101. extern void tboot_shutdown(u32 shutdown_type);
  102. extern struct acpi_table_header *tboot_get_dmar_table(
  103. struct acpi_table_header *dmar_tbl);
  104. extern int tboot_force_iommu(void);
  105. #else
  106. #define tboot_enabled() 0
  107. #define tboot_probe() do { } while (0)
  108. #define tboot_shutdown(shutdown_type) do { } while (0)
  109. #define tboot_sleep(sleep_state, pm1a_control, pm1b_control) \
  110. do { } while (0)
  111. #define tboot_get_dmar_table(dmar_tbl) (dmar_tbl)
  112. #define tboot_force_iommu() 0
  113. #endif /* !CONFIG_INTEL_TXT */
  114. #endif /* _LINUX_TBOOT_H */