Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: firmware/lib/include/rollback_index.h

Issue 3084030: Add structs for TPM NV simplification (Closed) Base URL: ssh://gitrw.chromium.org/vboot_reference.git
Patch Set: Use new structs Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | firmware/lib/rollback_index.c » ('j') | firmware/lib/rollback_index.c » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 * 4 *
5 * Functions for querying, manipulating and locking rollback indices 5 * Functions for querying, manipulating and locking rollback indices
6 * stored in the TPM NVRAM. 6 * stored in the TPM NVRAM.
7 */ 7 */
8 8
9 #ifndef VBOOT_REFERENCE_ROLLBACK_INDEX_H_ 9 #ifndef VBOOT_REFERENCE_ROLLBACK_INDEX_H_
10 #define VBOOT_REFERENCE_ROLLBACK_INDEX_H_ 10 #define VBOOT_REFERENCE_ROLLBACK_INDEX_H_
11 11
12 #include "sysincludes.h" 12 #include "sysincludes.h"
13 #include "tss_constants.h" 13 #include "tss_constants.h"
14 14
15 /* Rollback version types. */ 15 /* TPM NVRAM location indices. */
16 #define FIRMWARE_VERSIONS 0 16 #define FIRMWARE_NV_INDEX 0x1007
17 #define KERNEL_VERSIONS 1 17 #define KERNEL_NV_INDEX 0x1008
18 18
19 /* Initialization mode */ 19 /* Structure definitions for TPM spaces */
20 #define RO_RECOVERY_MODE 0
21 #define RO_NORMAL_MODE 1
22 #define RW_NORMAL_MODE 2
23 20
24 /* TPM NVRAM location indices. */ 21 __pragma(pack(push, 1)) /* Support packing for MSVC. */
25 #define FIRST_ROLLBACK_NV_INDEX 0x1001 /* First index used here */
26 #define FIRMWARE_VERSIONS_NV_INDEX 0x1001
27 #define KERNEL_VERSIONS_NV_INDEX 0x1002
28 #define TPM_IS_INITIALIZED_NV_INDEX 0x1003
29 #define KERNEL_VERSIONS_BACKUP_NV_INDEX 0x1004
30 #define KERNEL_MUST_USE_BACKUP_NV_INDEX 0x1005
31 #define DEVELOPER_MODE_NV_INDEX 0x1006
32 #define LAST_ROLLBACK_NV_INDEX 0x1006 /* Last index used here */
33 22
34 /* Unique ID to detect kernel space redefinition */ 23 /* Kernel space - KERNEL_NV_INDEX, locked with physical presence. */
35 #define KERNEL_SPACE_UID "GRWL" /* unique ID with secret meaning */ 24 #define ROLLBACK_SPACE_KERNEL_VERSION 1
36 #define KERNEL_SPACE_UID_SIZE (sizeof(KERNEL_SPACE_UID) - 1) 25 #define ROLLBACK_SPACE_KERNEL_UID 0x4752574C /* 'GRWL' */
37 #define KERNEL_SPACE_INIT_DATA ((uint8_t*) "\0\0\0\0" KERNEL_SPACE_UID) 26 typedef struct RollbackSpaceKernel {
38 #define KERNEL_SPACE_SIZE (sizeof(uint32_t) + KERNEL_SPACE_UID_SIZE) 27 uint8_t struct_version; /* Struct version, for backwards
28 * compatibility */
29 uint32_t uid; /* Unique ID to detect space redefinition */
30 uint32_t kernel_versions; /* Kernel versions */
31 uint32_t reserved; /* Reserved for future expansion */
32 } __attribute__((packed)) RollbackSpaceKernel;
33
34
35 /* Flags for firmware space */
36 /* Last boot was developer mode. TPM ownership is cleared when
37 * transitioning to/from developer mode. */
38 #define FLAG_LAST_BOOT_DEVELOPER 0x01
39 /* There have been one or more boots which left PP unlocked, so the
40 * contents of the kernel space are untrusted and must be restored
41 * from the backup copy. */
42 #define FLAG_KERNEL_SPACE_USE_BACKUP 0x02
43
44 #define ROLLBACK_SPACE_FIRMWARE_VERSION 1
45 /* Firmware space - FIRMWARE_NV_INDEX, locked with global lock. */
46 typedef struct RollbackSpaceFirmware {
47 uint8_t struct_version; /* Struct version, for backwards compatibility */
48 uint8_t flags; /* Flags (see FLAG_* above) */
49 uint32_t fw_versions; /* Firmware versions */
50 uint32_t reserved; /* Reserved for future expansion */
51 RollbackSpaceKernel kernel_backup; /* Backup of kernel space */
52 } __attribute__((packed)) RollbackSpaceFirmware;
53
54 __pragma(pack(pop)) /* Support packing for MSVC. */
55
39 56
40 /* All functions return TPM_SUCCESS (zero) if successful, non-zero if error */ 57 /* All functions return TPM_SUCCESS (zero) if successful, non-zero if error */
41 58
42 /* 59 /*
43 60
44 Call from LoadFirmware() 61 Call from LoadFirmware()
45 Normal or developer mode (not recovery) 62 Normal or developer mode (not recovery)
46 Wants firmware versions 63 Wants firmware versions
47 Must send in developer flag 64 Must send in developer flag
48 65
(...skipping 16 matching lines...) Expand all
65 Must send in developer flag 82 Must send in developer flag
66 If not recovery mode, wants kernel versions 83 If not recovery mode, wants kernel versions
67 Must send in developer and recovery flags 84 Must send in developer and recovery flags
68 */ 85 */
69 86
70 /* These functions are callable from LoadFirmware(). They cannot use 87 /* These functions are callable from LoadFirmware(). They cannot use
71 * global variables. */ 88 * global variables. */
72 89
73 /* Setup must be called. Pass developer_mode=nonzero if in developer 90 /* Setup must be called. Pass developer_mode=nonzero if in developer
74 * mode. */ 91 * mode. */
75 uint32_t RollbackFirmwareSetup(int developer_mode); 92 /* TODO: use a 32-bit version instead of 2 version pieces */
76 /* Read and Write may be called after Setup. */ 93 uint32_t RollbackFirmwareSetup(int developer_mode, uint16_t* key_version,
77 uint32_t RollbackFirmwareRead(uint16_t* key_version, uint16_t* version); 94 uint16_t* version);
95
78 /* Write may be called if the versions change */ 96 /* Write may be called if the versions change */
97 /* TODO: use a 32-bit version instead of 2 version pieces */
Luigi Semenzato 2010/08/12 01:12:30 Maybe have Gaurav review this (future) change.
79 uint32_t RollbackFirmwareWrite(uint16_t key_version, uint16_t version); 98 uint32_t RollbackFirmwareWrite(uint16_t key_version, uint16_t version);
80 99
81 /* Lock must be called */ 100 /* Lock must be called */
82 uint32_t RollbackFirmwareLock(void); 101 uint32_t RollbackFirmwareLock(void);
83 102
84 /* These functions are callable from LoadKernel(). They may use global 103 /* These functions are callable from LoadKernel(). They may use global
85 * variables. */ 104 * variables. */
86 105
87 /* Recovery may be called. If it is, this is the first time a 106 /* Recovery may be called. If it is, this is the first time a
88 * rollback function has been called this boot, so it needs to know if 107 * rollback function has been called this boot, so it needs to know if
89 * we're in developer mode. Pass developer_mode=nonzero if in developer 108 * we're in developer mode. Pass developer_mode=nonzero if in developer
90 * mode. */ 109 * mode. */
91 uint32_t RollbackKernelRecovery(int developer_mode); 110 uint32_t RollbackKernelRecovery(int developer_mode);
92 111
93 /* Read and write may be called if not in developer mode. If called in 112 /* Read and write may be called if not in developer mode. If called in
94 * recovery mode, the effect is undefined. */ 113 * recovery mode, the effect is undefined. */
114 /* TODO: use a 32-bit version instead of 2 version pieces */
95 uint32_t RollbackKernelRead(uint16_t* key_version, uint16_t* version); 115 uint32_t RollbackKernelRead(uint16_t* key_version, uint16_t* version);
96 uint32_t RollbackKernelWrite(uint16_t key_version, uint16_t version); 116 uint32_t RollbackKernelWrite(uint16_t key_version, uint16_t version);
97 117
98 /* Lock must be called. Internally, it's ignored in recovery mode. */ 118 /* Lock must be called. Internally, it's ignored in recovery mode. */
99 uint32_t RollbackKernelLock(void); 119 uint32_t RollbackKernelLock(void);
100 120
101 /* The following functions are here for testing only. */ 121 /* The following functions are here for testing only. */
102 122
103 /* Store 1 in *|initialized| if the TPM NVRAM spaces have been initialized, 0
104 * otherwise. Return TPM errors. */
105 uint32_t GetSpacesInitialized(int* initialized);
106
107 /* Issue a TPM_Clear and reenable/reactivate the TPM. */ 123 /* Issue a TPM_Clear and reenable/reactivate the TPM. */
108 uint32_t TPMClearAndReenable(void); 124 uint32_t TPMClearAndReenable(void);
109 125
110 #endif /* VBOOT_REFERENCE_ROLLBACK_INDEX_H_ */ 126 #endif /* VBOOT_REFERENCE_ROLLBACK_INDEX_H_ */
OLDNEW
« no previous file with comments | « no previous file | firmware/lib/rollback_index.c » ('j') | firmware/lib/rollback_index.c » ('J')

Powered by Google App Engine
This is Rietveld 408576698