ia64/xen-unstable

view tools/vtpm_manager/manager/vtpmpriv.h @ 8977:f84d5cdd9895

Clean up segment selector fixup and validation.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Feb 23 14:43:45 2006 +0100 (2006-02-23)
parents 201d48272a57
children f3661f9a95dd
line source
1 // ===================================================================
2 //
3 // Copyright (c) 2005, Intel Corp.
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions
8 // are met:
9 //
10 // * Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 // * Redistributions in binary form must reproduce the above
13 // copyright notice, this list of conditions and the following
14 // disclaimer in the documentation and/or other materials provided
15 // with the distribution.
16 // * Neither the name of Intel Corporation nor the names of its
17 // contributors may be used to endorse or promote products derived
18 // from this software without specific prior written permission.
19 //
20 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31 // OF THE POSSIBILITY OF SUCH DAMAGE.
32 // ===================================================================
33 //
34 // vtpmpriv.h
35 //
36 // Structures and functions private to the manager
37 //
38 // ==================================================================
40 #ifndef __VTPMPRIV_H__
41 #define __VTPMPRIV_H__
43 #include "tcg.h"
44 #include "tcs.h"
45 #include "buffer.h"
46 #include "crypto.h"
48 #define STATE_FILE "/var/vtpm/VTPM"
49 #define DMI_NVM_FILE "/var/vtpm/vtpm_dm_%d.data"
50 #define VTPM_BE_DEV "/dev/vtpm"
51 #define VTPM_CTL_DM 0
53 #ifndef VTPM_MUTLI_VM
54 #include <sys/types.h>
55 #define GUEST_TX_FIFO "/var/vtpm/fifos/guest-to-%d.fifo"
56 #define GUEST_RX_FIFO "/var/vtpm/fifos/guest-from-all.fifo"
58 #define VTPM_TX_FIFO "/var/vtpm/fifos/vtpm-to-%d.fifo"
59 #define VTPM_RX_FIFO "/var/vtpm/fifos/vtpm-from-all.fifo"
61 #define BE_LISTENER_THREAD 1
62 #define DMI_LISTENER_THREAD 2
64 // Seconds until DMI timeout. Timeouts result in DMI being out
65 // of sync, which may require a reboot of DMI and guest to recover
66 // from. Don't set this to low. Also note that DMI may issue a TPM
67 // call so we should expect time to process at DMI + TPM processing.
68 #define DMI_TIMEOUT 90
69 #endif
72 // ------------------------ Private Structures -----------------------
73 typedef struct VTPM_DMI_RESOURCE_T {
74 // I/O info for Manager to talk to DMI's over FIFOs
75 #ifndef VTPM_MUTLI_VM
76 int guest_tx_fh; // open GUEST_TX_FIFO
77 int vtpm_tx_fh; // open VTPM_TX_FIFO
78 char *guest_tx_fname; // open GUEST_TX_FIFO
79 char *vtpm_tx_fname; // open VTPM_TX_FIFO
81 pid_t dmi_pid;
82 #endif
83 // Non-persistent Information
84 bool connected;
85 UINT32 dmi_domain_id;
86 TCS_CONTEXT_HANDLE TCSContext; // TCS Handle
87 char *NVMLocation; // NULL term string indicating location
88 // of NVM.
89 // Persistent Information about DMI
90 UINT32 dmi_id;
91 TPM_DIGEST NVM_measurement; // Equal to the SHA1 of the blob
92 TPM_DIGEST DMI_measurement; // Correct measurement of the owning DMI
93 } VTPM_DMI_RESOURCE;
95 typedef struct tdVTPM_GLOBALS {
96 // Non-persistent data
97 int be_fh; // File handle to ipc used to communicate with backend
98 #ifndef VTPM_MULTI_VM
99 int vtpm_rx_fh;
100 int guest_rx_fh;
102 pid_t master_pid;
103 #endif
104 struct hashtable *dmi_map; // Table of all DMI's known indexed by persistent instance #
105 #ifndef VTPM_MULTI_VM
106 pthread_mutex_t dmi_map_mutex; //
107 #endif
108 TCS_CONTEXT_HANDLE manager_tcs_handle; // TCS Handle used by manager
109 TPM_HANDLE storageKeyHandle; // Key used by persistent store
110 CRYPTO_INFO storageKey; // For software encryption
111 CRYPTO_INFO bootKey; // For saving table
112 TCS_AUTH keyAuth; // OIAP session for storageKey
113 BOOL DMI_table_dirty; // Indicates that a command
114 // has updated the DMI table
117 // Persistent Data
118 TPM_AUTHDATA owner_usage_auth; // OwnerAuth of real TPM
119 buffer_t storageKeyWrap; // Wrapped copy of storageKey
120 TPM_AUTHDATA srk_usage_auth;
121 TPM_AUTHDATA storage_key_usage_auth;
123 buffer_t bootKeyWrap; // Wrapped copy of boot key
125 }VTPM_GLOBALS;
127 // --------------------------- Global Values --------------------------
128 extern VTPM_GLOBALS *vtpm_globals; // Key info and DMI states
129 extern const TPM_AUTHDATA SRK_AUTH; // SRK Well Known Auth Value
131 // ********************** Command Handler Prototypes ***********************
132 TPM_RESULT VTPM_Handle_Load_NVM( VTPM_DMI_RESOURCE *myDMI,
133 const buffer_t *inbuf,
134 buffer_t *outbuf);
136 TPM_RESULT VTPM_Handle_Save_NVM( VTPM_DMI_RESOURCE *myDMI,
137 const buffer_t *inbuf,
138 buffer_t *outbuf);
140 TPM_RESULT VTPM_Handle_TPM_Command( VTPM_DMI_RESOURCE *dmi,
141 buffer_t *inbuf,
142 buffer_t *outbuf);
144 TPM_RESULT VTPM_Handle_New_DMI(const buffer_t *param_buf);
146 TPM_RESULT VTPM_Handle_Close_DMI(const buffer_t *param_buf);
148 TPM_RESULT VTPM_Handle_Delete_DMI(const buffer_t *param_buf);
150 TPM_RESULT VTPM_SaveService(void);
151 TPM_RESULT VTPM_LoadService(void);
153 TPM_RESULT close_dmi( VTPM_DMI_RESOURCE *dmi_res);
154 #endif // __VTPMPRIV_H__