On Wed, Feb 10, 2016 at 10:51:47AM +0200, Michael S. Tsirkin wrote: > So maybe we should > leave this alone, wait until we see an actual user - this way we can > figure out the implementation constraints better.
What I'm definitely interested in seeing is improving the bios_linker_loader API within QEMU. Is the below going in the right direction, in your opinion? diff --git a/include/hw/acpi/bios-linker-loader.h b/include/hw/acpi/bios-linker-loader.h index 498c0af..78d9a16 100644 --- a/include/hw/acpi/bios-linker-loader.h +++ b/include/hw/acpi/bios-linker-loader.h @@ -17,6 +17,17 @@ void bios_linker_loader_add_checksum(GArray *linker, const char *file, void *start, unsigned size, uint8_t *checksum); +/* + * bios_linker_loader_add_pointer: ask guest to append address of source file + * into destination file at the specified pointer. + * + * @linker: linker file array + * @dest_file: destination file that must be changed + * @src_file: source file whos address must be taken + * @table: destination file array + * @pointer: location of the pointer to be patched within destination file + * @pointer_size: size of pointer to be patched, in bytes + */ void bios_linker_loader_add_pointer(GArray *linker, const char *dest_file, const char *src_file, diff --git a/hw/acpi/bios-linker-loader.c b/hw/acpi/bios-linker-loader.c index e04d60a..84be25a 100644 --- a/hw/acpi/bios-linker-loader.c +++ b/hw/acpi/bios-linker-loader.c @@ -142,7 +142,13 @@ void bios_linker_loader_add_pointer(GArray *linker, uint8_t pointer_size) { BiosLinkerLoaderEntry entry; - size_t offset = (gchar *)pointer - table->data; + size_t offset; + + assert((gchar *)pointer >= table->data); + + offset = (gchar *)pointer - table->data; + + assert(offset + pointer_size < table->len); memset(&entry, 0, sizeof entry); strncpy(entry.pointer.dest_file, dest_file, -- MST