static int relocate_patch_table(void *fsp, size_t size, size_t offset, ssize_t adjustment) { struct fsp_patch_table *table; uint32_t num; table = relative_offset(fsp, offset); if ((offset + sizeof(*table) > size) || (table->header_length + offset) > size) { printk(BIOS_ERR, "FSPP not entirely contained in region.\n"); return -1; } printk(FSP_DBG_LVL, "FSPP relocs: %x\n", table->patch_entry_num); for (num = 0; num < table->patch_entry_num; num++) { uint32_t *reloc; reloc = fspp_reloc(fsp, size, table->patch_entries[num]); if (reloc == NULL) { printk(BIOS_ERR, "Ignoring FSPP entry: %x\n", table->patch_entries[num]); continue; } printk(FSP_DBG_LVL, "Adjusting %p %x -> %x\n", reloc, *reloc, (unsigned int)(*reloc + adjustment)); *reloc += adjustment; } return 0; }
static int relocate_patch_table(void *fsp, size_t size, size_t offset, ssize_t adjustment) { struct fsp_patch_table *table; size_t num; size_t num_entries; table = relative_offset(fsp, offset); if ((offset + sizeof(*table) > size) || (read_le16(&table->header_length) + offset) > size) { printk(BIOS_ERR, "FSPP not entirely contained in region.\n"); return -1; } num_entries = read_le32(&table->patch_entry_num); printk(FSP_DBG_LVL, "FSPP relocs: %zx\n", num_entries); for (num = 0; num < num_entries; num++) { uint32_t *reloc; uint32_t reloc_val; reloc = fspp_reloc(fsp, size, read_le32(&table->patch_entries[num])); if (reloc == NULL) { printk(BIOS_ERR, "Ignoring FSPP entry: %x\n", read_le32(&table->patch_entries[num])); continue; } reloc_val = read_le32(reloc); printk(FSP_DBG_LVL, "Adjusting %p %x -> %x\n", reloc, reloc_val, (unsigned int)(reloc_val + adjustment)); write_le32(reloc, reloc_val + adjustment); } return 0; }