github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/cpvmm/vmm/bootstrap/tboot.h (about)

     1  /*
     2   * tboot.h: shared data structure with MLE and kernel and functions
     3   *          used by kernel for runtime support
     4   *
     5   * Copyright (c) 2006-2010, Intel Corporation
     6   * All rights reserved.
     7   *
     8   * Redistribution and use in source and binary forms, with or without
     9   * modification, are permitted provided that the following conditions
    10   * are met:
    11   *
    12   *   * Redistributions of source code must retain the above copyright
    13   *     notice, this list of conditions and the following disclaimer.
    14   *   * Redistributions in binary form must reproduce the above
    15   *     copyright notice, this list of conditions and the following
    16   *     disclaimer in the documentation and/or other materials provided
    17   *     with the distribution.
    18   *   * Neither the name of the Intel Corporation nor the names of its
    19   *     contributors may be used to endorse or promote products derived
    20   *     from this software without specific prior written permission.
    21   *
    22   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    23   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    24   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
    25   * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
    26   * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
    27   * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    28   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    29   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    30   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
    31   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    32   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
    33   * OF THE POSSIBILITY OF SUCH DAMAGE.
    34   *
    35   */
    36  
    37  #ifndef __TBOOT_H__
    38  #define __TBOOT_H__
    39  
    40  #ifndef __packed
    41  #define __packed   __attribute__ ((packed))
    42  #endif
    43  
    44  /* define uuid_t here in case uuid.h wasn't pre-included */
    45  /* (i.e. so tboot.h can be self-sufficient) */
    46  #ifndef __UUID_H__
    47  typedef struct __packed {
    48    uint32_t    data1;
    49    uint16_t    data2;
    50    uint16_t    data3;
    51    uint16_t    data4;
    52    uint8_t     data5[6];
    53  } uuid_t;
    54  #endif
    55  
    56  /*
    57   * used to communicate between tboot and the launched kernel (i.e. Xen)
    58   */
    59  
    60  #define TB_KEY_SIZE             64   /* 512 bits */
    61  
    62  #define MAX_TB_MAC_REGIONS      32
    63  typedef struct __packed {
    64      uint64_t  start;         /* must be 4k byte -aligned */
    65      uint32_t  size;          /* must be 4k byte -granular */
    66  } tboot_mac_region_t;
    67  
    68  /* GAS - Generic Address Structure (ACPI 2.0+) */
    69  typedef struct __packed {
    70      uint8_t  space_id;         /* only 0,1 (memory, I/O) are supported */
    71      uint8_t  bit_width;
    72      uint8_t  bit_offset;
    73      uint8_t  access_width;     /* only 1-3 (byte, word, dword) are supported */
    74      uint64_t address;
    75  } tboot_acpi_generic_address_t;
    76  
    77  typedef struct __packed {
    78      tboot_acpi_generic_address_t pm1a_cnt_blk;
    79      tboot_acpi_generic_address_t pm1b_cnt_blk;
    80      tboot_acpi_generic_address_t pm1a_evt_blk;
    81      tboot_acpi_generic_address_t pm1b_evt_blk;
    82      uint16_t pm1a_cnt_val;
    83      uint16_t pm1b_cnt_val;
    84      uint64_t wakeup_vector;
    85      uint32_t vector_width;
    86      uint64_t kernel_s3_resume_vector;
    87  } tboot_acpi_sleep_info_t;
    88  
    89  typedef struct __packed {
    90      /* version 3+ fields: */
    91      uuid_t    uuid;              /* {663C8DFF-E8B3-4b82-AABF-19EA4D057A08} */
    92      uint32_t  version;           /* currently 0.6 */
    93      uint32_t  log_addr;          /* physical addr of log or NULL if none */
    94      uint32_t  shutdown_entry;    /* entry point for tboot shutdown */
    95      uint32_t  shutdown_type;     /* type of shutdown (TB_SHUTDOWN_*) */
    96      tboot_acpi_sleep_info_t
    97                acpi_sinfo;        /* where kernel put acpi sleep info in Sx */
    98      uint32_t  tboot_base;        /* starting addr for tboot */
    99      uint32_t  tboot_size;        /* size of tboot */
   100      uint8_t   num_mac_regions;   /* number mem regions to MAC on S3 */
   101                                   /* contig regions memory to MAC on S3 */
   102      tboot_mac_region_t mac_regions[MAX_TB_MAC_REGIONS];
   103      /* version 4+ fields: */
   104                                   /* populated by tboot; will be encrypted */
   105      uint8_t   s3_key[TB_KEY_SIZE];
   106      /* version 5+ fields: */
   107      uint8_t   reserved_align[3]; /* used to 4byte-align num_in_wfs */
   108      uint32_t  num_in_wfs;        /* number of processors in wait-for-SIPI */
   109      /* version 6+ fields: */
   110      uint32_t  flags;
   111      uint64_t  ap_wake_addr;      /* phys addr of kernel/VMM SIPI vector */
   112      uint32_t  ap_wake_trigger;   /* kernel/VMM writes APIC ID to wake AP */
   113  } tboot_shared_t;
   114  
   115  #define TB_SHUTDOWN_REBOOT      0
   116  #define TB_SHUTDOWN_S5          1
   117  #define TB_SHUTDOWN_S4          2
   118  #define TB_SHUTDOWN_S3          3
   119  #define TB_SHUTDOWN_HALT        4
   120  #define TB_SHUTDOWN_WFS         5
   121  
   122  #define TB_FLAG_AP_WAKE_SUPPORT   0x00000001  /* kernel/VMM use INIT-SIPI-SIPI
   123                                                   if clear, ap_wake_* if set */
   124  
   125  /* {663C8DFF-E8B3-4b82-AABF-19EA4D057A08} */
   126  #define TBOOT_SHARED_UUID    {0x663c8dff, 0xe8b3, 0x4b82, 0xaabf, \
   127                                   {0x19, 0xea, 0x4d, 0x5, 0x7a, 0x8 }}
   128  
   129  /*
   130   * used to log tboot printk output
   131   */
   132  
   133  typedef struct {
   134      uuid_t     uuid;
   135      uint32_t   max_size;
   136      uint32_t   curr_pos;
   137      char       buf[];
   138  } tboot_log_t;
   139  
   140  /* {C0192526-6B30-4db4-844C-A3E953B88174} */
   141  #define TBOOT_LOG_UUID   {0xc0192526, 0x6b30, 0x4db4, 0x844c, \
   142                               {0xa3, 0xe9, 0x53, 0xb8, 0x81, 0x74 }}
   143  
   144  extern tboot_shared_t *g_tboot_shared;
   145  
   146  static inline bool tboot_in_measured_env(void)
   147  {
   148      return (g_tboot_shared != NULL);
   149  }
   150  
   151  #endif    /* __TBOOT_H__ */