This new function is necessary for the VM introspection object. By sending all e820 entries, not just the RAM ones, the introspection tool can differentiate between an invalid address and a reserved one.
CC: Paolo Bonzini <pbonz...@redhat.com> CC: Richard Henderson <r...@twiddle.net> CC: Eduardo Habkost <ehabk...@redhat.com> CC: "Michael S. Tsirkin" <m...@redhat.com> CC: Marcel Apfelbaum <marcel.apfelb...@gmail.com> Signed-off-by: Adalbert Lazăr <ala...@bitdefender.com> --- hw/i386/e820_memory_layout.c | 12 ++++++++++++ hw/i386/e820_memory_layout.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/hw/i386/e820_memory_layout.c b/hw/i386/e820_memory_layout.c index bcf9eaf837..a875e9e326 100644 --- a/hw/i386/e820_memory_layout.c +++ b/hw/i386/e820_memory_layout.c @@ -57,3 +57,15 @@ bool e820_get_entry(int idx, uint32_t type, uint64_t *address, uint64_t *length) } return false; } + +bool e820_get_entry2(int idx, uint32_t *type, uint64_t *address, + uint64_t *length) +{ + if (idx < e820_entries) { + *type = le32_to_cpu(e820_table[idx].type); + *address = le64_to_cpu(e820_table[idx].address); + *length = le64_to_cpu(e820_table[idx].length); + return true; + } + return false; +} diff --git a/hw/i386/e820_memory_layout.h b/hw/i386/e820_memory_layout.h index 2a0ceb8b9c..a4555c21fb 100644 --- a/hw/i386/e820_memory_layout.h +++ b/hw/i386/e820_memory_layout.h @@ -36,6 +36,8 @@ int e820_add_entry(uint64_t address, uint64_t length, uint32_t type); int e820_get_num_entries(void); bool e820_get_entry(int index, uint32_t type, uint64_t *address, uint64_t *length); +bool e820_get_entry2(int index, uint32_t *type, + uint64_t *address, uint64_t *length);