tboot.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  2. * tboot.h: shared data structure with tboot and kernel and functions
  3. * used by kernel for runtime support of Intel(R) Trusted
  4. * Execution Technology
  5. *
  6. * Copyright (c) 2006-2009, Intel Corporation
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms and conditions of the GNU General Public License,
  10. * version 2, as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope it will be useful, but WITHOUT
  13. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  15. * more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along with
  18. * this program; if not, write to the Free Software Foundation, Inc.,
  19. * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  20. *
  21. */
  22. #ifndef _LINUX_TBOOT_H
  23. #define _LINUX_TBOOT_H
  24. /* these must have the values from 0-5 in this order */
  25. enum {
  26. TB_SHUTDOWN_REBOOT = 0,
  27. TB_SHUTDOWN_S5,
  28. TB_SHUTDOWN_S4,
  29. TB_SHUTDOWN_S3,
  30. TB_SHUTDOWN_HALT,
  31. TB_SHUTDOWN_WFS
  32. };
  33. #ifdef CONFIG_INTEL_TXT
  34. #include <linux/acpi.h>
  35. /* used to communicate between tboot and the launched kernel */
  36. #define TB_KEY_SIZE 64 /* 512 bits */
  37. #define MAX_TB_MAC_REGIONS 32
  38. struct tboot_mac_region {
  39. u64 start; /* must be 64 byte -aligned */
  40. u32 size; /* must be 64 byte -granular */
  41. } __packed;
  42. /* GAS - Generic Address Structure (ACPI 2.0+) */
  43. struct tboot_acpi_generic_address {
  44. u8 space_id;
  45. u8 bit_width;
  46. u8 bit_offset;
  47. u8 access_width;
  48. u64 address;
  49. } __packed;
  50. /*
  51. * combines Sx info from FADT and FACS tables per ACPI 2.0+ spec
  52. * (http://www.acpi.info/)
  53. */
  54. struct tboot_acpi_sleep_info {
  55. struct tboot_acpi_generic_address pm1a_cnt_blk;
  56. struct tboot_acpi_generic_address pm1b_cnt_blk;
  57. struct tboot_acpi_generic_address pm1a_evt_blk;
  58. struct tboot_acpi_generic_address pm1b_evt_blk;
  59. u16 pm1a_cnt_val;
  60. u16 pm1b_cnt_val;
  61. u64 wakeup_vector;
  62. u32 vector_width;
  63. u64 kernel_s3_resume_vector;
  64. } __packed;
  65. /*
  66. * shared memory page used for communication between tboot and kernel
  67. */
  68. struct tboot {
  69. /*
  70. * version 3+ fields:
  71. */
  72. /* TBOOT_UUID */
  73. u8 uuid[16];
  74. /* version number: 5 is current */
  75. u32 version;
  76. /* physical addr of tb_log_t log */
  77. u32 log_addr;
  78. /*
  79. * physical addr of entry point for tboot shutdown and
  80. * type of shutdown (TB_SHUTDOWN_*) being requested
  81. */
  82. u32 shutdown_entry;
  83. u32 shutdown_type;
  84. /* kernel-specified ACPI info for Sx shutdown */
  85. struct tboot_acpi_sleep_info acpi_sinfo;
  86. /* tboot location in memory (physical) */
  87. u32 tboot_base;
  88. u32 tboot_size;
  89. /* memory regions (phys addrs) for tboot to MAC on S3 */
  90. u8 num_mac_regions;
  91. struct tboot_mac_region mac_regions[MAX_TB_MAC_REGIONS];
  92. /*
  93. * version 4+ fields:
  94. */
  95. /* symmetric key for use by kernel; will be encrypted on S3 */
  96. u8 s3_key[TB_KEY_SIZE];
  97. /*
  98. * version 5+ fields:
  99. */
  100. /* used to 4byte-align num_in_wfs */
  101. u8 reserved_align[3];
  102. /* number of processors in wait-for-SIPI */
  103. u32 num_in_wfs;
  104. } __packed;
  105. /*
  106. * UUID for tboot data struct to facilitate matching
  107. * defined as {663C8DFF-E8B3-4b82-AABF-19EA4D057A08} by tboot, which is
  108. * represented as {} in the char array used here
  109. */
  110. #define TBOOT_UUID {0xff, 0x8d, 0x3c, 0x66, 0xb3, 0xe8, 0x82, 0x4b, 0xbf,\
  111. 0xaa, 0x19, 0xea, 0x4d, 0x5, 0x7a, 0x8}
  112. extern struct tboot *tboot;
  113. static inline int tboot_enabled(void)
  114. {
  115. return tboot != NULL;
  116. }
  117. extern void tboot_probe(void);
  118. extern void tboot_shutdown(u32 shutdown_type);
  119. extern struct acpi_table_header *tboot_get_dmar_table(
  120. struct acpi_table_header *dmar_tbl);
  121. extern int tboot_force_iommu(void);
  122. #else
  123. #define tboot_enabled() 0
  124. #define tboot_probe() do { } while (0)
  125. #define tboot_shutdown(shutdown_type) do { } while (0)
  126. #define tboot_sleep(sleep_state, pm1a_control, pm1b_control) \
  127. do { } while (0)
  128. #define tboot_get_dmar_table(dmar_tbl) (dmar_tbl)
  129. #define tboot_force_iommu() 0
  130. #endif /* !CONFIG_INTEL_TXT */
  131. #endif /* _LINUX_TBOOT_H */