qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Jon Doron" <arilou@gmail.com>
Cc: qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v2] dump: Set correct vaddr for ELF dump
Date: Tue, 8 Jan 2019 17:55:05 +0100	[thread overview]
Message-ID: <b5f64cfc-7a2e-ff6c-6396-c6a724af4b5f@redhat.com> (raw)
In-Reply-To: <CAMxuvayU-0nLmcMs3zWF61Y5GT9u8AtaZtZApdbYaDDDoCti=A@mail.gmail.com>

On 01/08/19 14:05, Marc-André Lureau wrote:
> On Tue, Jan 8, 2019 at 5:02 PM Jon Doron <arilou@gmail.com> wrote:
>>
>> vaddr needs to be equal to the paddr since the dump file represents the
>> physical memory image.
>>
>> Without setting vaddr correctly, GDB would load all the different memory
>> regions on top of each other to vaddr 0, thus making GDB showing the wrong
>> memory data for a given address.
>>
>> Signed-off-by: Jon Doron <arilou@gmail.com>
> 
> Not sure we are doing everything correctly, but solves the non-paging
> GDB case, so:
> 
> Tested-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Same thoughts here.

Acked-by: Laszlo Ersek <lersek@redhat.com>

Thanks
Laszlo

>> ---
>>  dump.c                       | 5 +++--
>>  scripts/dump-guest-memory.py | 1 +
>>  2 files changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/dump.c b/dump.c
>> index 4ec94c5e25..7a56e254d4 100644
>> --- a/dump.c
>> +++ b/dump.c
>> @@ -192,7 +192,7 @@ static void write_elf64_load(DumpState *s, MemoryMapping *memory_mapping,
>>      phdr.p_paddr = cpu_to_dump64(s, memory_mapping->phys_addr);
>>      phdr.p_filesz = cpu_to_dump64(s, filesz);
>>      phdr.p_memsz = cpu_to_dump64(s, memory_mapping->length);
>> -    phdr.p_vaddr = cpu_to_dump64(s, memory_mapping->virt_addr);
>> +    phdr.p_vaddr = cpu_to_dump64(s, memory_mapping->virt_addr) ? : phdr.p_paddr;
>>
>>      assert(memory_mapping->length >= filesz);
>>
>> @@ -216,7 +216,8 @@ static void write_elf32_load(DumpState *s, MemoryMapping *memory_mapping,
>>      phdr.p_paddr = cpu_to_dump32(s, memory_mapping->phys_addr);
>>      phdr.p_filesz = cpu_to_dump32(s, filesz);
>>      phdr.p_memsz = cpu_to_dump32(s, memory_mapping->length);
>> -    phdr.p_vaddr = cpu_to_dump32(s, memory_mapping->virt_addr);
>> +    phdr.p_vaddr =
>> +               cpu_to_dump32(s, memory_mapping->virt_addr) ? : phdr.p_paddr;
>>
>>      assert(memory_mapping->length >= filesz);
>>
>> diff --git a/scripts/dump-guest-memory.py b/scripts/dump-guest-memory.py
>> index 198cd0fe40..2c587cbefc 100644
>> --- a/scripts/dump-guest-memory.py
>> +++ b/scripts/dump-guest-memory.py
>> @@ -163,6 +163,7 @@ class ELF(object):
>>          phdr = get_arch_phdr(self.endianness, self.elfclass)
>>          phdr.p_type = p_type
>>          phdr.p_paddr = p_paddr
>> +        phdr.p_vaddr = p_paddr
>>          phdr.p_filesz = p_size
>>          phdr.p_memsz = p_size
>>          self.segments.append(phdr)
>> --
>> 2.19.2
>>

  reply	other threads:[~2019-01-08 16:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-08 13:02 [Qemu-devel] [PATCH v2] dump: Set correct vaddr for ELF dump Jon Doron
2019-01-08 13:05 ` Marc-André Lureau
2019-01-08 16:55   ` Laszlo Ersek [this message]
2019-01-08 14:29 ` no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b5f64cfc-7a2e-ff6c-6396-c6a724af4b5f@redhat.com \
    --to=lersek@redhat.com \
    --cc=arilou@gmail.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).