ia64/xen-unstable

view tools/vtpm_manager/manager/tpmpassthrough.c @ 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 3399f4b9396a
children
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 // tpmpassthrough.c
35 //
36 // Functions regarding passing DMI requests to HWTPM
37 //
38 // ==================================================================
40 #include "tcg.h"
41 #include "vtpm_manager.h"
42 #include "vtpmpriv.h"
43 #include "vtsp.h"
44 #include "log.h"
46 TPM_RESULT VTPM_Handle_TPM_Command( VTPM_DMI_RESOURCE *dmi,
47 buffer_t *inbuf,
48 buffer_t *outbuf) {
50 TPM_RESULT status = TPM_SUCCESS;
51 TPM_COMMAND_CODE *ord;
53 ord = (TPM_COMMAND_CODE *) (inbuf->bytes + sizeof(TPM_TAG) + sizeof(UINT32));
55 switch (*ord) {
57 // Forbidden for DMI use
58 case TPM_ORD_TakeOwnership:
59 case TPM_ORD_ChangeAuthOwner:
60 case TPM_ORD_DirWriteAuth:
61 case TPM_ORD_DirRead:
62 case TPM_ORD_AuthorizeMigrationKey:
63 case TPM_ORD_CreateMaintenanceArchive:
64 case TPM_ORD_LoadMaintenanceArchive:
65 case TPM_ORD_KillMaintenanceFeature:
66 case TPM_ORD_LoadManuMaintPub:
67 case TPM_ORD_ReadManuMaintPub:
68 case TPM_ORD_SelfTestFull:
69 case TPM_ORD_SelfTestStartup:
70 case TPM_ORD_CertifySelfTest:
71 case TPM_ORD_ContinueSelfTest:
72 case TPM_ORD_GetTestResult:
73 case TPM_ORD_Reset:
74 case TPM_ORD_OwnerClear:
75 case TPM_ORD_DisableOwnerClear:
76 case TPM_ORD_ForceClear:
77 case TPM_ORD_DisableForceClear:
78 case TPM_ORD_GetCapabilityOwner:
79 case TPM_ORD_OwnerSetDisable:
80 case TPM_ORD_PhysicalEnable:
81 case TPM_ORD_PhysicalDisable:
82 case TPM_ORD_SetOwnerInstall:
83 case TPM_ORD_PhysicalSetDeactivated:
84 case TPM_ORD_SetTempDeactivated:
85 case TPM_ORD_CreateEndorsementKeyPair:
86 case TPM_ORD_GetAuditEvent:
87 case TPM_ORD_GetAuditEventSigned:
88 case TPM_ORD_GetOrdinalAuditStatus:
89 case TPM_ORD_SetOrdinalAuditStatus:
90 case TPM_ORD_SetRedirection:
91 case TPM_ORD_FieldUpgrade:
92 case TSC_ORD_PhysicalPresence:
93 status = TPM_DISABLED_CMD;
94 goto abort_egress;
95 break;
97 } // End ORD Switch
99 // Call TCS with command
101 TPMTRY(TPM_IOERROR, VTSP_RawTransmit( dmi->TCSContext,inbuf, outbuf) );
103 goto egress;
105 abort_egress:
106 vtpmloginfo(VTPM_LOG_VTPM, "TPM Command Failed in tpmpassthrough.\n");
107 egress:
109 return status;
110 }