Angel Pons | 118a9c7 | 2020-04-02 23:48:34 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Peter Stuge | 483b7bb | 2009-04-14 07:40:01 +0000 | [diff] [blame] | 2 | |
Aaron Durbin | 899d13d | 2015-05-15 23:39:23 -0500 | [diff] [blame] | 3 | #include <assert.h> |
Aaron Durbin | 899d13d | 2015-05-15 23:39:23 -0500 | [diff] [blame] | 4 | #include <boot_device.h> |
| 5 | #include <cbfs.h> |
Julius Werner | 0d9072b | 2020-03-05 12:51:08 -0800 | [diff] [blame] | 6 | #include <cbfs_private.h> |
Julius Werner | 1e37c9c | 2019-12-11 17:09:39 -0800 | [diff] [blame] | 7 | #include <cbmem.h> |
Julius Werner | 98eeb96 | 2019-12-11 15:47:42 -0800 | [diff] [blame] | 8 | #include <commonlib/bsd/compression.h> |
Aaron Durbin | 0b418bd | 2020-10-08 14:56:03 -0600 | [diff] [blame] | 9 | #include <commonlib/endian.h> |
Bill XIE | c79e96b | 2019-08-22 20:28:36 +0800 | [diff] [blame] | 10 | #include <console/console.h> |
Bill XIE | c79e96b | 2019-08-22 20:28:36 +0800 | [diff] [blame] | 11 | #include <fmap.h> |
Aaron Durbin | 899d13d | 2015-05-15 23:39:23 -0500 | [diff] [blame] | 12 | #include <lib.h> |
Julius Werner | fdabf3f | 2020-05-06 17:06:35 -0700 | [diff] [blame] | 13 | #include <metadata_hash.h> |
Bill XIE | c79e96b | 2019-08-22 20:28:36 +0800 | [diff] [blame] | 14 | #include <security/tpm/tspi/crtm.h> |
| 15 | #include <security/vboot/vboot_common.h> |
| 16 | #include <stdlib.h> |
| 17 | #include <string.h> |
Aaron Durbin | 899d13d | 2015-05-15 23:39:23 -0500 | [diff] [blame] | 18 | #include <symbols.h> |
Julius Werner | 09f2921 | 2015-09-29 13:51:35 -0700 | [diff] [blame] | 19 | #include <timestamp.h> |
Patrick Georgi | 58a150a | 2016-05-02 17:22:29 +0800 | [diff] [blame] | 20 | |
Julius Werner | 9b1f3cc | 2020-12-30 17:30:12 -0800 | [diff] [blame] | 21 | #if CBFS_CACHE_AVAILABLE |
| 22 | struct mem_pool cbfs_cache = MEM_POOL_INIT(_cbfs_cache, REGION_SIZE(cbfs_cache)); |
| 23 | |
| 24 | static void switch_to_postram_cache(int unused) |
| 25 | { |
| 26 | if (_preram_cbfs_cache != _postram_cbfs_cache) |
| 27 | mem_pool_init(&cbfs_cache, _postram_cbfs_cache, |
| 28 | REGION_SIZE(postram_cbfs_cache)); |
| 29 | } |
| 30 | ROMSTAGE_CBMEM_INIT_HOOK(switch_to_postram_cache); |
| 31 | #endif |
| 32 | |
Julius Werner | 0d9072b | 2020-03-05 12:51:08 -0800 | [diff] [blame] | 33 | cb_err_t cbfs_boot_lookup(const char *name, bool force_ro, |
| 34 | union cbfs_mdata *mdata, struct region_device *rdev) |
Julius Werner | 1e37c9c | 2019-12-11 17:09:39 -0800 | [diff] [blame] | 35 | { |
Julius Werner | 0d9072b | 2020-03-05 12:51:08 -0800 | [diff] [blame] | 36 | const struct cbfs_boot_device *cbd = cbfs_get_boot_device(force_ro); |
| 37 | if (!cbd) |
| 38 | return CB_ERR; |
| 39 | |
| 40 | size_t data_offset; |
Julius Werner | 1e37c9c | 2019-12-11 17:09:39 -0800 | [diff] [blame] | 41 | cb_err_t err = CB_CBFS_CACHE_FULL; |
Julius Werner | 34cf073 | 2020-12-08 14:21:43 -0800 | [diff] [blame] | 42 | if (!CONFIG(NO_CBFS_MCACHE) && !ENV_SMM && cbd->mcache_size) |
Julius Werner | 1e37c9c | 2019-12-11 17:09:39 -0800 | [diff] [blame] | 43 | err = cbfs_mcache_lookup(cbd->mcache, cbd->mcache_size, |
Julius Werner | 723e3b1 | 2020-12-29 17:33:30 -0800 | [diff] [blame] | 44 | name, mdata, &data_offset); |
Julius Werner | fdabf3f | 2020-05-06 17:06:35 -0700 | [diff] [blame] | 45 | if (err == CB_CBFS_CACHE_FULL) { |
| 46 | struct vb2_hash *metadata_hash = NULL; |
| 47 | if (CONFIG(TOCTOU_SAFETY)) { |
| 48 | if (ENV_SMM) /* Cannot provide TOCTOU safety for SMM */ |
| 49 | dead_code(); |
Julius Werner | 34cf073 | 2020-12-08 14:21:43 -0800 | [diff] [blame] | 50 | if (!cbd->mcache_size) |
| 51 | die("Cannot access CBFS TOCTOU-safely in " ENV_STRING " before CBMEM init!\n"); |
Julius Werner | 723e3b1 | 2020-12-29 17:33:30 -0800 | [diff] [blame] | 52 | /* We can only reach this for the RW CBFS -- an mcache overflow in the |
| 53 | RO CBFS would have been caught when building the mcache in cbfs_get |
| 54 | boot_device(). (Note that TOCTOU_SAFETY implies !NO_CBFS_MCACHE.) */ |
Julius Werner | fdabf3f | 2020-05-06 17:06:35 -0700 | [diff] [blame] | 55 | assert(cbd == vboot_get_cbfs_boot_device()); |
| 56 | /* TODO: set metadata_hash to RW metadata hash here. */ |
| 57 | } |
Julius Werner | 723e3b1 | 2020-12-29 17:33:30 -0800 | [diff] [blame] | 58 | err = cbfs_lookup(&cbd->rdev, name, mdata, &data_offset, metadata_hash); |
Julius Werner | fdabf3f | 2020-05-06 17:06:35 -0700 | [diff] [blame] | 59 | } |
Julius Werner | 0d9072b | 2020-03-05 12:51:08 -0800 | [diff] [blame] | 60 | |
Julius Werner | 723e3b1 | 2020-12-29 17:33:30 -0800 | [diff] [blame] | 61 | if (CONFIG(VBOOT_ENABLE_CBFS_FALLBACK) && !force_ro && err == CB_CBFS_NOT_FOUND) { |
| 62 | printk(BIOS_INFO, "CBFS: Fall back to RO region for %s\n", name); |
Julius Werner | 0d9072b | 2020-03-05 12:51:08 -0800 | [diff] [blame] | 63 | return cbfs_boot_lookup(name, true, mdata, rdev); |
| 64 | } |
Julius Werner | 0247fcf | 2020-12-03 12:41:00 -0800 | [diff] [blame] | 65 | if (err) { |
| 66 | if (err == CB_CBFS_NOT_FOUND) |
| 67 | printk(BIOS_WARNING, "CBFS: '%s' not found.\n", name); |
| 68 | else if (err == CB_CBFS_HASH_MISMATCH) |
| 69 | printk(BIOS_ERR, "CBFS ERROR: metadata hash mismatch!\n"); |
| 70 | else |
Julius Werner | 723e3b1 | 2020-12-29 17:33:30 -0800 | [diff] [blame] | 71 | printk(BIOS_ERR, "CBFS ERROR: error %d when looking up '%s'\n", |
Julius Werner | 0247fcf | 2020-12-03 12:41:00 -0800 | [diff] [blame] | 72 | err, name); |
Julius Werner | 0d9072b | 2020-03-05 12:51:08 -0800 | [diff] [blame] | 73 | return err; |
Julius Werner | 0247fcf | 2020-12-03 12:41:00 -0800 | [diff] [blame] | 74 | } |
Julius Werner | 0d9072b | 2020-03-05 12:51:08 -0800 | [diff] [blame] | 75 | |
| 76 | if (rdev_chain(rdev, &cbd->rdev, data_offset, be32toh(mdata->h.len))) |
| 77 | return CB_ERR; |
| 78 | |
Arthur Heymans | 27545df | 2021-02-26 14:22:47 +0100 | [diff] [blame] | 79 | if (tspi_measure_cbfs_hook(rdev, name, be32toh(mdata->h.type))) { |
| 80 | printk(BIOS_ERR, "CBFS ERROR: error when measuring '%s'\n", name); |
| 81 | } |
Julius Werner | 0d9072b | 2020-03-05 12:51:08 -0800 | [diff] [blame] | 82 | |
| 83 | return CB_SUCCESS; |
Julius Werner | 1e37c9c | 2019-12-11 17:09:39 -0800 | [diff] [blame] | 84 | } |
| 85 | |
Aaron Durbin | 37a5d15 | 2015-09-17 16:09:30 -0500 | [diff] [blame] | 86 | int cbfs_boot_locate(struct cbfsf *fh, const char *name, uint32_t *type) |
Aaron Durbin | 899d13d | 2015-05-15 23:39:23 -0500 | [diff] [blame] | 87 | { |
Julius Werner | 0d9072b | 2020-03-05 12:51:08 -0800 | [diff] [blame] | 88 | if (cbfs_boot_lookup(name, false, &fh->mdata, &fh->data)) |
Julius Werner | 1cd013b | 2019-12-11 16:50:02 -0800 | [diff] [blame] | 89 | return -1; |
| 90 | |
| 91 | size_t msize = be32toh(fh->mdata.h.offset); |
Julius Werner | 723e3b1 | 2020-12-29 17:33:30 -0800 | [diff] [blame] | 92 | if (rdev_chain(&fh->metadata, &addrspace_32bit.rdev, (uintptr_t)&fh->mdata, msize)) |
Julius Werner | 1cd013b | 2019-12-11 16:50:02 -0800 | [diff] [blame] | 93 | return -1; |
Julius Werner | 0d9072b | 2020-03-05 12:51:08 -0800 | [diff] [blame] | 94 | |
Julius Werner | 1cd013b | 2019-12-11 16:50:02 -0800 | [diff] [blame] | 95 | if (type) { |
| 96 | if (!*type) |
| 97 | *type = be32toh(fh->mdata.h.type); |
| 98 | else if (*type != be32toh(fh->mdata.h.type)) |
| 99 | return -1; |
Wim Vervoorn | 114e2e8 | 2019-11-05 14:09:16 +0100 | [diff] [blame] | 100 | } |
| 101 | |
Julius Werner | 1cd013b | 2019-12-11 16:50:02 -0800 | [diff] [blame] | 102 | return 0; |
Aaron Durbin | 899d13d | 2015-05-15 23:39:23 -0500 | [diff] [blame] | 103 | } |
| 104 | |
Julius Werner | 9b1f3cc | 2020-12-30 17:30:12 -0800 | [diff] [blame] | 105 | void cbfs_unmap(void *mapping) |
Julius Werner | 834b3ec | 2020-03-04 16:52:08 -0800 | [diff] [blame] | 106 | { |
Julius Werner | 9b1f3cc | 2020-12-30 17:30:12 -0800 | [diff] [blame] | 107 | /* |
| 108 | * This is save to call with mappings that weren't allocated in the cache (e.g. x86 |
| 109 | * direct mappings) -- mem_pool_free() just does nothing for addresses it doesn't |
| 110 | * recognize. This hardcodes the assumption that if platforms implement an rdev_mmap() |
| 111 | * that requires a free() for the boot_device, they need to implement it via the |
| 112 | * cbfs_cache mem_pool. |
| 113 | */ |
| 114 | if (CBFS_CACHE_AVAILABLE) |
| 115 | mem_pool_free(&cbfs_cache, mapping); |
Julius Werner | 834b3ec | 2020-03-04 16:52:08 -0800 | [diff] [blame] | 116 | } |
| 117 | |
Pratik Prajapati | 2a7708a | 2016-11-30 17:29:10 -0800 | [diff] [blame] | 118 | int cbfs_locate_file_in_region(struct cbfsf *fh, const char *region_name, |
Philipp Deppenwiese | 66f9a09 | 2018-11-08 10:59:40 +0100 | [diff] [blame] | 119 | const char *name, uint32_t *type) |
Pratik Prajapati | 2a7708a | 2016-11-30 17:29:10 -0800 | [diff] [blame] | 120 | { |
| 121 | struct region_device rdev; |
Bill XIE | bad08c2 | 2020-02-13 11:11:35 +0800 | [diff] [blame] | 122 | int ret = 0; |
Pratik Prajapati | 2a7708a | 2016-11-30 17:29:10 -0800 | [diff] [blame] | 123 | if (fmap_locate_area_as_rdev(region_name, &rdev)) { |
Julius Werner | 723e3b1 | 2020-12-29 17:33:30 -0800 | [diff] [blame] | 124 | LOG("%s region not found while looking for %s\n", region_name, name); |
Pratik Prajapati | 2a7708a | 2016-11-30 17:29:10 -0800 | [diff] [blame] | 125 | return -1; |
| 126 | } |
| 127 | |
Julius Werner | 0d9072b | 2020-03-05 12:51:08 -0800 | [diff] [blame] | 128 | uint32_t dummy_type = 0; |
| 129 | if (!type) |
| 130 | type = &dummy_type; |
| 131 | |
Bill XIE | bad08c2 | 2020-02-13 11:11:35 +0800 | [diff] [blame] | 132 | ret = cbfs_locate(fh, &rdev, name, type); |
| 133 | if (!ret) |
Julius Werner | 0d9072b | 2020-03-05 12:51:08 -0800 | [diff] [blame] | 134 | if (tspi_measure_cbfs_hook(&rdev, name, *type)) |
Arthur Heymans | 27545df | 2021-02-26 14:22:47 +0100 | [diff] [blame] | 135 | LOG("error measuring %s in region %s\n", name, region_name); |
Bill XIE | bad08c2 | 2020-02-13 11:11:35 +0800 | [diff] [blame] | 136 | return ret; |
Pratik Prajapati | 2a7708a | 2016-11-30 17:29:10 -0800 | [diff] [blame] | 137 | } |
| 138 | |
Aaron Durbin | a85febc | 2020-05-15 15:09:10 -0600 | [diff] [blame] | 139 | static inline bool fsps_env(void) |
| 140 | { |
| 141 | /* FSP-S is assumed to be loaded in ramstage. */ |
| 142 | if (ENV_RAMSTAGE) |
| 143 | return true; |
| 144 | return false; |
| 145 | } |
| 146 | |
Aaron Durbin | ecbfa99 | 2020-05-15 17:01:58 -0600 | [diff] [blame] | 147 | static inline bool fspm_env(void) |
| 148 | { |
| 149 | /* FSP-M is assumed to be loaded in romstage. */ |
| 150 | if (ENV_ROMSTAGE) |
| 151 | return true; |
| 152 | return false; |
| 153 | } |
| 154 | |
Aaron Durbin | a121f95 | 2020-05-26 15:48:10 -0600 | [diff] [blame] | 155 | static inline bool cbfs_lz4_enabled(void) |
| 156 | { |
Aaron Durbin | a85febc | 2020-05-15 15:09:10 -0600 | [diff] [blame] | 157 | if (fsps_env() && CONFIG(FSP_COMPRESS_FSP_S_LZ4)) |
| 158 | return true; |
Aaron Durbin | ecbfa99 | 2020-05-15 17:01:58 -0600 | [diff] [blame] | 159 | if (fspm_env() && CONFIG(FSP_COMPRESS_FSP_M_LZ4)) |
| 160 | return true; |
Aaron Durbin | a85febc | 2020-05-15 15:09:10 -0600 | [diff] [blame] | 161 | |
Aaron Durbin | a121f95 | 2020-05-26 15:48:10 -0600 | [diff] [blame] | 162 | if ((ENV_BOOTBLOCK || ENV_SEPARATE_VERSTAGE) && !CONFIG(COMPRESS_PRERAM_STAGES)) |
| 163 | return false; |
| 164 | |
Julius Werner | 9b1f3cc | 2020-12-30 17:30:12 -0800 | [diff] [blame] | 165 | if (ENV_SMM) |
| 166 | return false; |
| 167 | |
Aaron Durbin | a121f95 | 2020-05-26 15:48:10 -0600 | [diff] [blame] | 168 | return true; |
| 169 | } |
| 170 | |
| 171 | static inline bool cbfs_lzma_enabled(void) |
| 172 | { |
Aaron Durbin | a85febc | 2020-05-15 15:09:10 -0600 | [diff] [blame] | 173 | if (fsps_env() && CONFIG(FSP_COMPRESS_FSP_S_LZMA)) |
| 174 | return true; |
Aaron Durbin | ecbfa99 | 2020-05-15 17:01:58 -0600 | [diff] [blame] | 175 | if (fspm_env() && CONFIG(FSP_COMPRESS_FSP_M_LZMA)) |
| 176 | return true; |
Aaron Durbin | a121f95 | 2020-05-26 15:48:10 -0600 | [diff] [blame] | 177 | /* We assume here romstage and postcar are never compressed. */ |
| 178 | if (ENV_BOOTBLOCK || ENV_SEPARATE_VERSTAGE) |
| 179 | return false; |
| 180 | if (ENV_ROMSTAGE && CONFIG(POSTCAR_STAGE)) |
| 181 | return false; |
Julius Werner | 723e3b1 | 2020-12-29 17:33:30 -0800 | [diff] [blame] | 182 | if ((ENV_ROMSTAGE || ENV_POSTCAR) && !CONFIG(COMPRESS_RAMSTAGE)) |
Aaron Durbin | a121f95 | 2020-05-26 15:48:10 -0600 | [diff] [blame] | 183 | return false; |
Julius Werner | 9b1f3cc | 2020-12-30 17:30:12 -0800 | [diff] [blame] | 184 | if (ENV_SMM) |
| 185 | return false; |
Aaron Durbin | a121f95 | 2020-05-26 15:48:10 -0600 | [diff] [blame] | 186 | return true; |
| 187 | } |
| 188 | |
Julius Werner | 723e3b1 | 2020-12-29 17:33:30 -0800 | [diff] [blame] | 189 | size_t cbfs_load_and_decompress(const struct region_device *rdev, size_t offset, size_t in_size, |
| 190 | void *buffer, size_t buffer_size, uint32_t compression) |
Aaron Durbin | 899d13d | 2015-05-15 23:39:23 -0500 | [diff] [blame] | 191 | { |
Julius Werner | 09f2921 | 2015-09-29 13:51:35 -0700 | [diff] [blame] | 192 | size_t out_size; |
Aaron Durbin | 84f394e | 2020-05-26 16:16:42 -0600 | [diff] [blame] | 193 | void *map; |
Julius Werner | 09f2921 | 2015-09-29 13:51:35 -0700 | [diff] [blame] | 194 | |
Julius Werner | 7778cf2 | 2021-01-05 18:54:19 -0800 | [diff] [blame] | 195 | DEBUG("Decompressing %zu bytes to %p with algo %d\n", buffer_size, buffer, compression); |
| 196 | |
Julius Werner | 09f2921 | 2015-09-29 13:51:35 -0700 | [diff] [blame] | 197 | switch (compression) { |
| 198 | case CBFS_COMPRESS_NONE: |
Julius Werner | f975e55 | 2016-08-19 15:43:06 -0700 | [diff] [blame] | 199 | if (buffer_size < in_size) |
| 200 | return 0; |
Julius Werner | 09f2921 | 2015-09-29 13:51:35 -0700 | [diff] [blame] | 201 | if (rdev_readat(rdev, buffer, offset, in_size) != in_size) |
| 202 | return 0; |
| 203 | return in_size; |
| 204 | |
| 205 | case CBFS_COMPRESS_LZ4: |
Aaron Durbin | a121f95 | 2020-05-26 15:48:10 -0600 | [diff] [blame] | 206 | if (!cbfs_lz4_enabled()) |
Julius Werner | 09f2921 | 2015-09-29 13:51:35 -0700 | [diff] [blame] | 207 | return 0; |
| 208 | |
Julius Werner | 723e3b1 | 2020-12-29 17:33:30 -0800 | [diff] [blame] | 209 | /* cbfs_stage_load_and_decompress() takes care of in-place LZ4 decompression by |
| 210 | setting up the rdev to be in memory. */ |
Aaron Durbin | 84f394e | 2020-05-26 16:16:42 -0600 | [diff] [blame] | 211 | map = rdev_mmap(rdev, offset, in_size); |
| 212 | if (map == NULL) |
Julius Werner | 09f2921 | 2015-09-29 13:51:35 -0700 | [diff] [blame] | 213 | return 0; |
| 214 | |
| 215 | timestamp_add_now(TS_START_ULZ4F); |
Aaron Durbin | 84f394e | 2020-05-26 16:16:42 -0600 | [diff] [blame] | 216 | out_size = ulz4fn(map, in_size, buffer, buffer_size); |
Julius Werner | 09f2921 | 2015-09-29 13:51:35 -0700 | [diff] [blame] | 217 | timestamp_add_now(TS_END_ULZ4F); |
Aaron Durbin | 84f394e | 2020-05-26 16:16:42 -0600 | [diff] [blame] | 218 | |
| 219 | rdev_munmap(rdev, map); |
| 220 | |
Julius Werner | 09f2921 | 2015-09-29 13:51:35 -0700 | [diff] [blame] | 221 | return out_size; |
| 222 | |
| 223 | case CBFS_COMPRESS_LZMA: |
Aaron Durbin | a121f95 | 2020-05-26 15:48:10 -0600 | [diff] [blame] | 224 | if (!cbfs_lzma_enabled()) |
Julius Werner | 09f2921 | 2015-09-29 13:51:35 -0700 | [diff] [blame] | 225 | return 0; |
Aaron Durbin | 84f394e | 2020-05-26 16:16:42 -0600 | [diff] [blame] | 226 | map = rdev_mmap(rdev, offset, in_size); |
Julius Werner | 09f2921 | 2015-09-29 13:51:35 -0700 | [diff] [blame] | 227 | if (map == NULL) |
| 228 | return 0; |
| 229 | |
| 230 | /* Note: timestamp not useful for memory-mapped media (x86) */ |
| 231 | timestamp_add_now(TS_START_ULZMA); |
| 232 | out_size = ulzman(map, in_size, buffer, buffer_size); |
| 233 | timestamp_add_now(TS_END_ULZMA); |
| 234 | |
| 235 | rdev_munmap(rdev, map); |
| 236 | |
| 237 | return out_size; |
| 238 | |
| 239 | default: |
Aaron Durbin | 899d13d | 2015-05-15 23:39:23 -0500 | [diff] [blame] | 240 | return 0; |
Julius Werner | 09f2921 | 2015-09-29 13:51:35 -0700 | [diff] [blame] | 241 | } |
Aaron Durbin | 899d13d | 2015-05-15 23:39:23 -0500 | [diff] [blame] | 242 | } |
| 243 | |
Julius Werner | 723e3b1 | 2020-12-29 17:33:30 -0800 | [diff] [blame] | 244 | static size_t cbfs_stage_load_and_decompress(const struct region_device *rdev, size_t offset, |
| 245 | size_t in_size, void *buffer, size_t buffer_size, uint32_t compression) |
Aaron Durbin | 84f394e | 2020-05-26 16:16:42 -0600 | [diff] [blame] | 246 | { |
| 247 | struct region_device rdev_src; |
| 248 | |
| 249 | if (compression == CBFS_COMPRESS_LZ4) { |
| 250 | if (!cbfs_lz4_enabled()) |
| 251 | return 0; |
Julius Werner | 723e3b1 | 2020-12-29 17:33:30 -0800 | [diff] [blame] | 252 | /* Load the compressed image to the end of the available memory area for |
| 253 | in-place decompression. It is the responsibility of the caller to ensure that |
| 254 | buffer_size is large enough (see compression.h, guaranteed by cbfstool for |
| 255 | stages). */ |
Aaron Durbin | 84f394e | 2020-05-26 16:16:42 -0600 | [diff] [blame] | 256 | void *compr_start = buffer + buffer_size - in_size; |
| 257 | if (rdev_readat(rdev, compr_start, offset, in_size) != in_size) |
| 258 | return 0; |
| 259 | /* Create a region device backed by memory. */ |
Julius Werner | 723e3b1 | 2020-12-29 17:33:30 -0800 | [diff] [blame] | 260 | rdev_chain(&rdev_src, &addrspace_32bit.rdev, (uintptr_t)compr_start, in_size); |
Aaron Durbin | 84f394e | 2020-05-26 16:16:42 -0600 | [diff] [blame] | 261 | |
Julius Werner | 723e3b1 | 2020-12-29 17:33:30 -0800 | [diff] [blame] | 262 | return cbfs_load_and_decompress(&rdev_src, 0, in_size, buffer, buffer_size, |
| 263 | compression); |
Aaron Durbin | 84f394e | 2020-05-26 16:16:42 -0600 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | /* All other algorithms can use the generic implementation. */ |
Julius Werner | 723e3b1 | 2020-12-29 17:33:30 -0800 | [diff] [blame] | 267 | return cbfs_load_and_decompress(rdev, offset, in_size, buffer, buffer_size, |
| 268 | compression); |
Aaron Durbin | 84f394e | 2020-05-26 16:16:42 -0600 | [diff] [blame] | 269 | } |
| 270 | |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 271 | static inline int tohex4(unsigned int c) |
Patrick Georgi | b203c2f | 2009-08-20 14:48:03 +0000 | [diff] [blame] | 272 | { |
Hung-Te Lin | 6fe0cab | 2013-01-22 18:57:56 +0800 | [diff] [blame] | 273 | return (c <= 9) ? (c + '0') : (c - 10 + 'a'); |
Patrick Georgi | b203c2f | 2009-08-20 14:48:03 +0000 | [diff] [blame] | 274 | } |
| 275 | |
Martin Roth | a616a4b | 2020-01-21 09:28:40 -0700 | [diff] [blame] | 276 | static void tohex8(unsigned int val, char *dest) |
| 277 | { |
| 278 | dest[0] = tohex4((val >> 4) & 0xf); |
| 279 | dest[1] = tohex4(val & 0xf); |
| 280 | } |
| 281 | |
Lee Leahy | b2d834a | 2017-03-08 16:52:22 -0800 | [diff] [blame] | 282 | static void tohex16(unsigned int val, char *dest) |
Patrick Georgi | b203c2f | 2009-08-20 14:48:03 +0000 | [diff] [blame] | 283 | { |
Philipp Deppenwiese | 66f9a09 | 2018-11-08 10:59:40 +0100 | [diff] [blame] | 284 | dest[0] = tohex4(val >> 12); |
| 285 | dest[1] = tohex4((val >> 8) & 0xf); |
| 286 | dest[2] = tohex4((val >> 4) & 0xf); |
Hung-Te Lin | 6fe0cab | 2013-01-22 18:57:56 +0800 | [diff] [blame] | 287 | dest[3] = tohex4(val & 0xf); |
Patrick Georgi | b203c2f | 2009-08-20 14:48:03 +0000 | [diff] [blame] | 288 | } |
| 289 | |
Aaron Durbin | 899d13d | 2015-05-15 23:39:23 -0500 | [diff] [blame] | 290 | void *cbfs_boot_map_optionrom(uint16_t vendor, uint16_t device) |
Peter Stuge | 483b7bb | 2009-04-14 07:40:01 +0000 | [diff] [blame] | 291 | { |
Hung-Te Lin | 6fe0cab | 2013-01-22 18:57:56 +0800 | [diff] [blame] | 292 | char name[17] = "pciXXXX,XXXX.rom"; |
Peter Stuge | 483b7bb | 2009-04-14 07:40:01 +0000 | [diff] [blame] | 293 | |
Philipp Deppenwiese | 66f9a09 | 2018-11-08 10:59:40 +0100 | [diff] [blame] | 294 | tohex16(vendor, name + 3); |
| 295 | tohex16(device, name + 8); |
Peter Stuge | 483b7bb | 2009-04-14 07:40:01 +0000 | [diff] [blame] | 296 | |
Julius Werner | 834b3ec | 2020-03-04 16:52:08 -0800 | [diff] [blame] | 297 | return cbfs_map(name, NULL); |
Peter Stuge | 483b7bb | 2009-04-14 07:40:01 +0000 | [diff] [blame] | 298 | } |
| 299 | |
Martin Roth | a616a4b | 2020-01-21 09:28:40 -0700 | [diff] [blame] | 300 | void *cbfs_boot_map_optionrom_revision(uint16_t vendor, uint16_t device, uint8_t rev) |
| 301 | { |
| 302 | char name[20] = "pciXXXX,XXXX,XX.rom"; |
| 303 | |
| 304 | tohex16(vendor, name + 3); |
| 305 | tohex16(device, name + 8); |
| 306 | tohex8(rev, name + 13); |
| 307 | |
Julius Werner | 834b3ec | 2020-03-04 16:52:08 -0800 | [diff] [blame] | 308 | return cbfs_map(name, NULL); |
Martin Roth | a616a4b | 2020-01-21 09:28:40 -0700 | [diff] [blame] | 309 | } |
| 310 | |
Julius Werner | 7778cf2 | 2021-01-05 18:54:19 -0800 | [diff] [blame] | 311 | void *_cbfs_alloc(const char *name, cbfs_allocator_t allocator, void *arg, |
| 312 | size_t *size_out, bool force_ro, enum cbfs_type *type) |
Julius Werner | f975e55 | 2016-08-19 15:43:06 -0700 | [diff] [blame] | 313 | { |
Julius Werner | d17ce41 | 2020-10-01 18:25:49 -0700 | [diff] [blame] | 314 | struct region_device rdev; |
| 315 | union cbfs_mdata mdata; |
Julius Werner | 7778cf2 | 2021-01-05 18:54:19 -0800 | [diff] [blame] | 316 | void *loc; |
| 317 | |
| 318 | DEBUG("%s(name='%s', alloc=%p(%p), force_ro=%s, type=%d)\n", __func__, name, allocator, |
| 319 | arg, force_ro ? "true" : "false", type ? *type : -1); |
Julius Werner | f975e55 | 2016-08-19 15:43:06 -0700 | [diff] [blame] | 320 | |
Julius Werner | 9d0cc2a | 2020-01-22 18:00:18 -0800 | [diff] [blame] | 321 | if (cbfs_boot_lookup(name, force_ro, &mdata, &rdev)) |
Julius Werner | 7778cf2 | 2021-01-05 18:54:19 -0800 | [diff] [blame] | 322 | return NULL; |
Julius Werner | f975e55 | 2016-08-19 15:43:06 -0700 | [diff] [blame] | 323 | |
Julius Werner | 7778cf2 | 2021-01-05 18:54:19 -0800 | [diff] [blame] | 324 | if (type) { |
| 325 | const enum cbfs_type real_type = be32toh(mdata.h.type); |
| 326 | if (*type == CBFS_TYPE_QUERY) |
| 327 | *type = real_type; |
| 328 | else if (*type != real_type) { |
| 329 | ERROR("'%s' type mismatch (is %u, expected %u)\n", |
| 330 | mdata.h.filename, real_type, *type); |
| 331 | return NULL; |
| 332 | } |
Julius Werner | d17ce41 | 2020-10-01 18:25:49 -0700 | [diff] [blame] | 333 | } |
Julius Werner | f975e55 | 2016-08-19 15:43:06 -0700 | [diff] [blame] | 334 | |
Julius Werner | 7778cf2 | 2021-01-05 18:54:19 -0800 | [diff] [blame] | 335 | size_t size = region_device_sz(&rdev); |
| 336 | uint32_t compression = CBFS_COMPRESS_NONE; |
| 337 | const struct cbfs_file_attr_compression *cattr = cbfs_find_attr(&mdata, |
| 338 | CBFS_FILE_ATTR_TAG_COMPRESSION, sizeof(*cattr)); |
| 339 | if (cattr) { |
| 340 | compression = be32toh(cattr->compression); |
| 341 | size = be32toh(cattr->decompressed_size); |
| 342 | } |
| 343 | |
| 344 | if (size_out) |
| 345 | *size_out = size; |
| 346 | |
| 347 | /* allocator == NULL means do a cbfs_map() */ |
| 348 | if (allocator) { |
| 349 | loc = allocator(arg, size, &mdata); |
| 350 | } else if (compression == CBFS_COMPRESS_NONE) { |
| 351 | return rdev_mmap_full(&rdev); |
| 352 | } else if (!CBFS_CACHE_AVAILABLE) { |
| 353 | ERROR("Cannot map compressed file %s on x86\n", mdata.h.filename); |
| 354 | return NULL; |
| 355 | } else { |
| 356 | loc = mem_pool_alloc(&cbfs_cache, size); |
| 357 | } |
| 358 | |
| 359 | if (!loc) { |
| 360 | ERROR("'%s' allocation failure\n", mdata.h.filename); |
| 361 | return NULL; |
| 362 | } |
| 363 | |
| 364 | size = cbfs_load_and_decompress(&rdev, 0, region_device_sz(&rdev), |
| 365 | loc, size, compression); |
| 366 | if (!size) |
| 367 | return NULL; |
| 368 | |
| 369 | return loc; |
| 370 | } |
| 371 | |
Julius Werner | 4676ec5 | 2021-03-10 16:52:14 -0800 | [diff] [blame] | 372 | void *_cbfs_default_allocator(void *arg, size_t size, const union cbfs_mdata *unused) |
Julius Werner | 7778cf2 | 2021-01-05 18:54:19 -0800 | [diff] [blame] | 373 | { |
| 374 | struct _cbfs_default_allocator_arg *darg = arg; |
| 375 | if (size > darg->buf_size) |
| 376 | return NULL; |
| 377 | return darg->buf; |
| 378 | } |
| 379 | |
Julius Werner | 4676ec5 | 2021-03-10 16:52:14 -0800 | [diff] [blame] | 380 | void *_cbfs_cbmem_allocator(void *arg, size_t size, const union cbfs_mdata *unused) |
Julius Werner | 7778cf2 | 2021-01-05 18:54:19 -0800 | [diff] [blame] | 381 | { |
| 382 | return cbmem_add((uintptr_t)arg, size); |
Julius Werner | f975e55 | 2016-08-19 15:43:06 -0700 | [diff] [blame] | 383 | } |
| 384 | |
Julius Werner | 1de8708 | 2020-12-23 17:38:11 -0800 | [diff] [blame] | 385 | cb_err_t cbfs_prog_stage_load(struct prog *pstage) |
Aaron Durbin | 899d13d | 2015-05-15 23:39:23 -0500 | [diff] [blame] | 386 | { |
Julius Werner | 1de8708 | 2020-12-23 17:38:11 -0800 | [diff] [blame] | 387 | union cbfs_mdata mdata; |
| 388 | struct region_device rdev; |
Julius Werner | 1de8708 | 2020-12-23 17:38:11 -0800 | [diff] [blame] | 389 | cb_err_t err; |
Hung-Te Lin | 6fe0cab | 2013-01-22 18:57:56 +0800 | [diff] [blame] | 390 | |
Julius Werner | 1de8708 | 2020-12-23 17:38:11 -0800 | [diff] [blame] | 391 | prog_locate_hook(pstage); |
Aaron Durbin | 899d13d | 2015-05-15 23:39:23 -0500 | [diff] [blame] | 392 | |
Julius Werner | 1de8708 | 2020-12-23 17:38:11 -0800 | [diff] [blame] | 393 | if ((err = cbfs_boot_lookup(prog_name(pstage), false, &mdata, &rdev))) |
| 394 | return err; |
| 395 | |
| 396 | assert(be32toh(mdata.h.type) == CBFS_TYPE_STAGE); |
| 397 | pstage->cbfs_type = CBFS_TYPE_STAGE; |
| 398 | |
Julius Werner | 81dc20e | 2020-10-15 17:37:57 -0700 | [diff] [blame] | 399 | enum cbfs_compression compression = CBFS_COMPRESS_NONE; |
| 400 | const struct cbfs_file_attr_compression *cattr = cbfs_find_attr(&mdata, |
| 401 | CBFS_FILE_ATTR_TAG_COMPRESSION, sizeof(*cattr)); |
| 402 | if (cattr) |
| 403 | compression = be32toh(cattr->compression); |
Julius Werner | 1de8708 | 2020-12-23 17:38:11 -0800 | [diff] [blame] | 404 | |
Julius Werner | 81dc20e | 2020-10-15 17:37:57 -0700 | [diff] [blame] | 405 | const struct cbfs_file_attr_stageheader *sattr = cbfs_find_attr(&mdata, |
| 406 | CBFS_FILE_ATTR_TAG_STAGEHEADER, sizeof(*sattr)); |
| 407 | if (!sattr) |
| 408 | return CB_ERR; |
| 409 | prog_set_area(pstage, (void *)(uintptr_t)be64toh(sattr->loadaddr), |
| 410 | be32toh(sattr->memlen)); |
| 411 | prog_set_entry(pstage, prog_start(pstage) + |
| 412 | be32toh(sattr->entry_offset), NULL); |
Aaron Durbin | 899d13d | 2015-05-15 23:39:23 -0500 | [diff] [blame] | 413 | |
Aaron Durbin | ed253c8 | 2015-10-07 17:22:42 -0500 | [diff] [blame] | 414 | /* Hacky way to not load programs over read only media. The stages |
| 415 | * that would hit this path initialize themselves. */ |
Julius Werner | 21a4053 | 2020-04-21 16:03:53 -0700 | [diff] [blame] | 416 | if ((ENV_BOOTBLOCK || ENV_SEPARATE_VERSTAGE) && |
| 417 | !CONFIG(NO_XIP_EARLY_STAGES) && CONFIG(BOOT_DEVICE_MEMORY_MAPPED)) { |
Julius Werner | 81dc20e | 2020-10-15 17:37:57 -0700 | [diff] [blame] | 418 | void *mapping = rdev_mmap_full(&rdev); |
Julius Werner | 1de8708 | 2020-12-23 17:38:11 -0800 | [diff] [blame] | 419 | rdev_munmap(&rdev, mapping); |
Julius Werner | 81dc20e | 2020-10-15 17:37:57 -0700 | [diff] [blame] | 420 | if (mapping == prog_start(pstage)) |
| 421 | return CB_SUCCESS; |
Aaron Durbin | ed253c8 | 2015-10-07 17:22:42 -0500 | [diff] [blame] | 422 | } |
| 423 | |
Julius Werner | 81dc20e | 2020-10-15 17:37:57 -0700 | [diff] [blame] | 424 | size_t fsize = cbfs_stage_load_and_decompress(&rdev, 0, region_device_sz(&rdev), |
| 425 | prog_start(pstage), prog_size(pstage), compression); |
Julius Werner | 09f2921 | 2015-09-29 13:51:35 -0700 | [diff] [blame] | 426 | if (!fsize) |
Julius Werner | 1de8708 | 2020-12-23 17:38:11 -0800 | [diff] [blame] | 427 | return CB_ERR; |
Aaron Durbin | 899d13d | 2015-05-15 23:39:23 -0500 | [diff] [blame] | 428 | |
| 429 | /* Clear area not covered by file. */ |
Julius Werner | 81dc20e | 2020-10-15 17:37:57 -0700 | [diff] [blame] | 430 | memset(prog_start(pstage) + fsize, 0, prog_size(pstage) - fsize); |
Aaron Durbin | 899d13d | 2015-05-15 23:39:23 -0500 | [diff] [blame] | 431 | |
Julius Werner | 81dc20e | 2020-10-15 17:37:57 -0700 | [diff] [blame] | 432 | prog_segment_loaded((uintptr_t)prog_start(pstage), prog_size(pstage), |
| 433 | SEG_FINAL); |
Aaron Durbin | 899d13d | 2015-05-15 23:39:23 -0500 | [diff] [blame] | 434 | |
Julius Werner | 1de8708 | 2020-12-23 17:38:11 -0800 | [diff] [blame] | 435 | return CB_SUCCESS; |
Hung-Te Lin | 6fe0cab | 2013-01-22 18:57:56 +0800 | [diff] [blame] | 436 | } |
Aaron Durbin | 6d720f3 | 2015-12-08 17:00:23 -0600 | [diff] [blame] | 437 | |
Julius Werner | 1e37c9c | 2019-12-11 17:09:39 -0800 | [diff] [blame] | 438 | void cbfs_boot_device_find_mcache(struct cbfs_boot_device *cbd, uint32_t id) |
Aaron Durbin | 6d720f3 | 2015-12-08 17:00:23 -0600 | [diff] [blame] | 439 | { |
Julius Werner | 1e37c9c | 2019-12-11 17:09:39 -0800 | [diff] [blame] | 440 | if (CONFIG(NO_CBFS_MCACHE) || ENV_SMM) |
| 441 | return; |
| 442 | |
Julius Werner | 34cf073 | 2020-12-08 14:21:43 -0800 | [diff] [blame] | 443 | if (cbd->mcache_size) |
| 444 | return; |
| 445 | |
Julius Werner | 1e37c9c | 2019-12-11 17:09:39 -0800 | [diff] [blame] | 446 | const struct cbmem_entry *entry; |
| 447 | if (cbmem_possibly_online() && |
| 448 | (entry = cbmem_entry_find(id))) { |
| 449 | cbd->mcache = cbmem_entry_start(entry); |
| 450 | cbd->mcache_size = cbmem_entry_size(entry); |
| 451 | } else if (ENV_ROMSTAGE_OR_BEFORE) { |
| 452 | u8 *boundary = _ecbfs_mcache - REGION_SIZE(cbfs_mcache) * |
| 453 | CONFIG_CBFS_MCACHE_RW_PERCENTAGE / 100; |
Julius Werner | 723e3b1 | 2020-12-29 17:33:30 -0800 | [diff] [blame] | 454 | boundary = (u8 *)ALIGN_DOWN((uintptr_t)boundary, CBFS_MCACHE_ALIGNMENT); |
Julius Werner | 1e37c9c | 2019-12-11 17:09:39 -0800 | [diff] [blame] | 455 | if (id == CBMEM_ID_CBFS_RO_MCACHE) { |
| 456 | cbd->mcache = _cbfs_mcache; |
| 457 | cbd->mcache_size = boundary - _cbfs_mcache; |
| 458 | } else if (id == CBMEM_ID_CBFS_RW_MCACHE) { |
| 459 | cbd->mcache = boundary; |
| 460 | cbd->mcache_size = _ecbfs_mcache - boundary; |
| 461 | } |
| 462 | } |
Aaron Durbin | 6d720f3 | 2015-12-08 17:00:23 -0600 | [diff] [blame] | 463 | } |
Julius Werner | 1e37c9c | 2019-12-11 17:09:39 -0800 | [diff] [blame] | 464 | |
Julius Werner | fdabf3f | 2020-05-06 17:06:35 -0700 | [diff] [blame] | 465 | cb_err_t cbfs_init_boot_device(const struct cbfs_boot_device *cbd, |
Julius Werner | 723e3b1 | 2020-12-29 17:33:30 -0800 | [diff] [blame] | 466 | struct vb2_hash *mdata_hash) |
Julius Werner | fdabf3f | 2020-05-06 17:06:35 -0700 | [diff] [blame] | 467 | { |
| 468 | /* If we have an mcache, mcache_build() will also check mdata hash. */ |
| 469 | if (!CONFIG(NO_CBFS_MCACHE) && !ENV_SMM && cbd->mcache_size > 0) |
Julius Werner | 723e3b1 | 2020-12-29 17:33:30 -0800 | [diff] [blame] | 470 | return cbfs_mcache_build(&cbd->rdev, cbd->mcache, cbd->mcache_size, mdata_hash); |
Julius Werner | fdabf3f | 2020-05-06 17:06:35 -0700 | [diff] [blame] | 471 | |
| 472 | /* No mcache and no verification means we have nothing special to do. */ |
Julius Werner | 723e3b1 | 2020-12-29 17:33:30 -0800 | [diff] [blame] | 473 | if (!CONFIG(CBFS_VERIFICATION) || !mdata_hash) |
Julius Werner | fdabf3f | 2020-05-06 17:06:35 -0700 | [diff] [blame] | 474 | return CB_SUCCESS; |
| 475 | |
Julius Werner | 723e3b1 | 2020-12-29 17:33:30 -0800 | [diff] [blame] | 476 | /* Verification only: use cbfs_walk() without a walker() function to just run through |
| 477 | the CBFS once, will return NOT_FOUND by default. */ |
| 478 | cb_err_t err = cbfs_walk(&cbd->rdev, NULL, NULL, mdata_hash, 0); |
Julius Werner | fdabf3f | 2020-05-06 17:06:35 -0700 | [diff] [blame] | 479 | if (err == CB_CBFS_NOT_FOUND) |
| 480 | err = CB_SUCCESS; |
| 481 | return err; |
| 482 | } |
| 483 | |
Julius Werner | 1e37c9c | 2019-12-11 17:09:39 -0800 | [diff] [blame] | 484 | const struct cbfs_boot_device *cbfs_get_boot_device(bool force_ro) |
| 485 | { |
| 486 | static struct cbfs_boot_device ro; |
| 487 | |
Julius Werner | 723e3b1 | 2020-12-29 17:33:30 -0800 | [diff] [blame] | 488 | /* Ensure we always init RO mcache, even if the first file is from the RW CBFS. |
Julius Werner | 1e37c9c | 2019-12-11 17:09:39 -0800 | [diff] [blame] | 489 | Otherwise it may not be available when needed in later stages. */ |
| 490 | if (ENV_INITIAL_STAGE && !force_ro && !region_device_sz(&ro.rdev)) |
| 491 | cbfs_get_boot_device(true); |
| 492 | |
| 493 | if (!force_ro) { |
| 494 | const struct cbfs_boot_device *rw = vboot_get_cbfs_boot_device(); |
Julius Werner | 723e3b1 | 2020-12-29 17:33:30 -0800 | [diff] [blame] | 495 | /* This will return NULL if vboot isn't enabled, didn't run yet or decided to |
| 496 | boot into recovery mode. */ |
Julius Werner | 1e37c9c | 2019-12-11 17:09:39 -0800 | [diff] [blame] | 497 | if (rw) |
| 498 | return rw; |
| 499 | } |
| 500 | |
Julius Werner | 723e3b1 | 2020-12-29 17:33:30 -0800 | [diff] [blame] | 501 | /* In rare cases post-RAM stages may run this before cbmem_initialize(), so we can't |
| 502 | lock in the result of find_mcache() on the first try and should keep trying every |
| 503 | time until an mcache is found. */ |
Julius Werner | 34cf073 | 2020-12-08 14:21:43 -0800 | [diff] [blame] | 504 | cbfs_boot_device_find_mcache(&ro, CBMEM_ID_CBFS_RO_MCACHE); |
| 505 | |
Julius Werner | 1e37c9c | 2019-12-11 17:09:39 -0800 | [diff] [blame] | 506 | if (region_device_sz(&ro.rdev)) |
| 507 | return &ro; |
| 508 | |
| 509 | if (fmap_locate_area_as_rdev("COREBOOT", &ro.rdev)) |
Julius Werner | fdabf3f | 2020-05-06 17:06:35 -0700 | [diff] [blame] | 510 | die("Cannot locate primary CBFS"); |
Julius Werner | 1e37c9c | 2019-12-11 17:09:39 -0800 | [diff] [blame] | 511 | |
Julius Werner | fdabf3f | 2020-05-06 17:06:35 -0700 | [diff] [blame] | 512 | if (ENV_INITIAL_STAGE) { |
| 513 | cb_err_t err = cbfs_init_boot_device(&ro, metadata_hash_get()); |
| 514 | if (err == CB_CBFS_HASH_MISMATCH) |
| 515 | die("RO CBFS metadata hash verification failure"); |
| 516 | else if (CONFIG(TOCTOU_SAFETY) && err == CB_CBFS_CACHE_FULL) |
| 517 | die("RO mcache overflow breaks TOCTOU safety!\n"); |
| 518 | else if (err && err != CB_CBFS_CACHE_FULL) |
| 519 | die("RO CBFS initialization error: %d", err); |
Julius Werner | 1e37c9c | 2019-12-11 17:09:39 -0800 | [diff] [blame] | 520 | } |
| 521 | |
| 522 | return &ro; |
| 523 | } |
| 524 | |
| 525 | #if !CONFIG(NO_CBFS_MCACHE) |
| 526 | static void mcache_to_cbmem(const struct cbfs_boot_device *cbd, u32 cbmem_id) |
| 527 | { |
| 528 | if (!cbd) |
| 529 | return; |
| 530 | |
| 531 | size_t real_size = cbfs_mcache_real_size(cbd->mcache, cbd->mcache_size); |
| 532 | void *cbmem_mcache = cbmem_add(cbmem_id, real_size); |
| 533 | if (!cbmem_mcache) { |
| 534 | printk(BIOS_ERR, "ERROR: Cannot allocate CBMEM mcache %#x (%#zx bytes)!\n", |
| 535 | cbmem_id, real_size); |
| 536 | return; |
| 537 | } |
| 538 | memcpy(cbmem_mcache, cbd->mcache, real_size); |
| 539 | } |
| 540 | |
| 541 | static void cbfs_mcache_migrate(int unused) |
| 542 | { |
| 543 | mcache_to_cbmem(vboot_get_cbfs_boot_device(), CBMEM_ID_CBFS_RW_MCACHE); |
| 544 | mcache_to_cbmem(cbfs_get_boot_device(true), CBMEM_ID_CBFS_RO_MCACHE); |
| 545 | } |
| 546 | ROMSTAGE_CBMEM_INIT_HOOK(cbfs_mcache_migrate) |
| 547 | #endif |