OLD | NEW |
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_ |
(...skipping 25 matching lines...) Expand all Loading... |
36 #define DEVELOPER_MODE_NV_INDEX 0x1006 | 36 #define DEVELOPER_MODE_NV_INDEX 0x1006 |
37 | 37 |
38 /* Unique ID to detect kernel space redefinition */ | 38 /* Unique ID to detect kernel space redefinition */ |
39 #define KERNEL_SPACE_UID "GRWL" /* unique ID with secret meaning */ | 39 #define KERNEL_SPACE_UID "GRWL" /* unique ID with secret meaning */ |
40 #define KERNEL_SPACE_UID_SIZE (sizeof(KERNEL_SPACE_UID) - 1) | 40 #define KERNEL_SPACE_UID_SIZE (sizeof(KERNEL_SPACE_UID) - 1) |
41 #define KERNEL_SPACE_INIT_DATA ((uint8_t*) "\0\0\0\0" KERNEL_SPACE_UID) | 41 #define KERNEL_SPACE_INIT_DATA ((uint8_t*) "\0\0\0\0" KERNEL_SPACE_UID) |
42 #define KERNEL_SPACE_SIZE (sizeof(uint32_t) + KERNEL_SPACE_UID_SIZE) | 42 #define KERNEL_SPACE_SIZE (sizeof(uint32_t) + KERNEL_SPACE_UID_SIZE) |
43 | 43 |
44 /* All functions return TPM_SUCCESS (zero) if successful, non-zero if error */ | 44 /* All functions return TPM_SUCCESS (zero) if successful, non-zero if error */ |
45 | 45 |
| 46 |
| 47 /* |
| 48 |
| 49 Call from LoadFirmware() |
| 50 Normal or developer mode (not recovery) |
| 51 Wants firmware versions |
| 52 Must send in developer flag |
| 53 |
| 54 RollbackFirmwareSetup(IN devmode, OUT firmware versions) |
| 55 (maybe) RollbackFirmwareWrite() |
| 56 RollbackFirmwareLock() |
| 57 |
| 58 Call from LoadKernel() |
| 59 |
| 60 RollbackKernelRecovery(IN devmode) |
| 61 (implies LockFirmwareVersions() inside the setup) |
| 62 |
| 63 RollbackKernelRead(OUT kernel versions) |
| 64 (maybe) RollbackKernelWrite() |
| 65 RollbackKernelLock() |
| 66 |
| 67 Any mode |
| 68 If recovery mode, this is the first time we've been called |
| 69 Must send in developer flag |
| 70 If not recovery mode, wants kernel versions |
| 71 Must send in developer and recovery flags |
| 72 */ |
| 73 |
| 74 /* These functions are callable from LoadFirmware(). They cannot use |
| 75 * global variables. */ |
| 76 /* Setup must be called. */ |
| 77 uint32_t RollbackFirmwareSetup(int developer_mode, |
| 78 uint16_t* key_version, uint16_t* version); |
| 79 /* Write may be called if the versions change */ |
| 80 uint32_t RollbackFirmwareWrite(uint16_t key_version, uint16_t version); |
| 81 /* Lock must be called */ |
| 82 uint32_t RollbackFirmwareLock(void); |
| 83 |
| 84 /* These functions are callable from LoadKernel(). They may use global |
| 85 * variables. */ |
| 86 /* Recovery may be called. If it is, this is the first time a |
| 87 * rollback function has been called this boot, so it needs to know if |
| 88 * we're in developer mode. */ |
| 89 uint32_t RollbackKernelRecovery(int developer_mode); |
| 90 /* Read and write may be called if not in developer mode. If called in |
| 91 * recovery mode, these are ignored and/or return 0 versions. */ |
| 92 uint32_t RollbackKernelRead(uint16_t* key_version, uint16_t* version); |
| 93 uint32_t RollbackKernelWrite(uint16_t key_version, uint16_t version); |
| 94 /* Lock must be called. Internally, it's ignored in recovery mode. */ |
| 95 uint32_t RollbackKernelLock(void); |
| 96 |
| 97 |
46 /* SetupTPM is called on boot and on starting the RW firmware, passing the | 98 /* SetupTPM is called on boot and on starting the RW firmware, passing the |
47 * appripriate MODE and DEVELOPER_FLAG parameters. MODE can be one of | 99 * appripriate MODE and DEVELOPER_FLAG parameters. MODE can be one of |
48 * RO_RECOVERY_MODE, RO_NORMAL_MODE, RW_NORMAL_MODE. DEVELOPER_FLAG is 1 when | 100 * RO_RECOVERY_MODE, RO_NORMAL_MODE, RW_NORMAL_MODE. DEVELOPER_FLAG is 1 when |
49 * the developer switch is ON, 0 otherwise. | 101 * the developer switch is ON, 0 otherwise. |
50 * | 102 * |
51 * If SetupTPM returns TPM_SUCCESS, the caller may proceed. If it returns | 103 * If SetupTPM returns TPM_SUCCESS, the caller may proceed. If it returns |
52 * TPM_E_MUST_REBOOT, the caller must reboot in the current mode. For all | 104 * TPM_E_MUST_REBOOT, the caller must reboot in the current mode. For all |
53 * other return values, the caller must reboot in recovery mode. | 105 * other return values, the caller must reboot in recovery mode. |
54 * | 106 * |
55 * This function has many side effects on the TPM state. In particular, when | 107 * This function has many side effects on the TPM state. In particular, when |
56 * called with mode = RECOVERY_MODE, it locks the firmware versions before | 108 * called with mode = RECOVERY_MODE, it locks the firmware versions before |
57 * returning. In all other cases, the caller is responsible for locking the | 109 * returning. In all other cases, the caller is responsible for locking the |
58 * firmware versions once it decides it doesn't need to update them. | 110 * firmware versions once it decides it doesn't need to update them. |
59 */ | 111 */ |
60 uint32_t SetupTPM(int mode, int developer_flag); | 112 uint32_t SetupTPM(int mode, int developer_flag); |
61 uint32_t GetStoredVersions(int type, uint16_t* key_version, uint16_t* version); | 113 uint32_t GetStoredVersions(int type, uint16_t* key_version, uint16_t* version); |
62 uint32_t WriteStoredVersions(int type, uint16_t key_version, uint16_t version); | 114 uint32_t WriteStoredVersions(int type, uint16_t key_version, uint16_t version); |
63 uint32_t LockFirmwareVersions(void); | 115 uint32_t LockFirmwareVersions(void); |
64 uint32_t LockKernelVersionsByLockingPP(void); | 116 uint32_t LockKernelVersionsByLockingPP(void); |
65 | 117 |
66 #endif /* VBOOT_REFERENCE_ROLLBACK_INDEX_H_ */ | 118 #endif /* VBOOT_REFERENCE_ROLLBACK_INDEX_H_ */ |
OLD | NEW |