| 416 | } |
| 417 | |
| 418 | static int relocate_patch_table(void *fsp, size_t size, size_t offset, |
| 419 | ssize_t adjustment) |
| 420 | { |
| 421 | struct fsp_patch_table *table; |
| 422 | size_t num; |
| 423 | size_t num_entries; |
| 424 | |
| 425 | table = relative_offset(fsp, offset); |
| 426 | |
| 427 | if ((offset + sizeof(*table) > size) || |
| 428 | (read_le16(&table->header_length) + offset) > size) { |
| 429 | printk(BIOS_ERR, "FSPP not entirely contained in region.\n"); |
| 430 | return -1; |
| 431 | } |
| 432 | |
| 433 | num_entries = read_le32(&table->patch_entry_num); |
| 434 | printk(FSP_DBG_LVL, "FSPP relocs: %zx\n", num_entries); |
| 435 | |
| 436 | for (num = 0; num < num_entries; num++) { |
| 437 | uint32_t *reloc; |
| 438 | uint32_t reloc_val; |
| 439 | |
| 440 | reloc = fspp_reloc(fsp, size, |
| 441 | read_le32(&table->patch_entries[num])); |
| 442 | |
| 443 | if (reloc == NULL) { |
| 444 | printk(BIOS_ERR, "Ignoring FSPP entry: %x\n", |
| 445 | read_le32(&table->patch_entries[num])); |
| 446 | continue; |
| 447 | } |
| 448 | |
| 449 | reloc_val = read_le32(reloc); |
| 450 | printk(FSP_DBG_LVL, "Adjusting %p %x -> %x\n", |
| 451 | reloc, reloc_val, |
| 452 | (unsigned int)(reloc_val + adjustment)); |
| 453 | |
| 454 | write_le32(reloc, reloc_val + adjustment); |
| 455 | } |
| 456 | |
| 457 | return 0; |
| 458 | } |
| 459 | |
| 460 | static ssize_t relocate_remaining_items(void *fsp, size_t size, |
| 461 | uintptr_t new_addr, size_t fih_offset) |
no test coverage detected