qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel@nongnu.org, imammedo@redhat.com, berrange@redhat.com,
	ehabkost@redhat.com, anderson@redhat.com, lersek@redhat.com
Subject: Re: [Qemu-devel] [PATCH v5 0/8] KASLR kernel dump support
Date: Wed, 16 Aug 2017 23:15:54 +0300	[thread overview]
Message-ID: <20170816231527-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20170807181618.22562-1-marcandre.lureau@redhat.com>

On Mon, Aug 07, 2017 at 08:16:10PM +0200, Marc-André Lureau wrote:
> Recent linux kernels enable KASLR to randomize phys/virt memory
> addresses. This series aims to provide enough information in qemu
> dumps so that crash utility can work with randomized kernel too (it
> hasn't been tested on other archs than x86 though, help welcome).
> 
> The previous design to provide qemu with debug details (using qemu-ga
> and a dedicated vmcoreinfo ACPI device) failed to satisfy the
> requirements during previous iterations.
> 
> In particular, the previous proposed vmcoreinfo ACPI device had the
> following issues:
> - hazardous memory handling with no explicit synchronization
> - occupy 2 fw-cfg entries (for memory and pointer)
> - occupy 4k of guest memory (this could have been tweaked)
> - did not provide ACPI methods (this could have been added)
> - may be difficult to maintain compatibility (according to Michael)
> 
> This is a new proposal, that leverage fw-cfg device instead of adding
> a new device. A "etc/vmcoreinfo" entry is added, where the guest,
> during boot or later, can write the addr/size location of an ELF note
> to be appended in the qemu dump.

Looks ok to me. Pls remember to ping after release.

> Note: only guest kernel is expected to write to a fw-cfg entry.  This
> method is not meant for general qemu/user-space communication. There
> are more appropriate devices for this purpose, and the guest kernel
> should not expose this facility.
> 
> This is quite easier to implement, and uses less of the limited fw-cfg
> slots, and guest memory. It also solves the synchronization issue, and
> may be easier to discover or to maintain compatibility.
> 
> The Linux ELF note is expected to be the VMCOREINFO note, which will
> have a special handling in qemu in this case helping kaslr-kernel
> debugging. But it could be any valid ELF note.
> 
> Crash 7.1.9 will parse the "phys_base" value from the VMCOREINFO note,
> and thus will work with KASLR-dump produced by this series.
> 
> The series implements the note addition in qemu ELF/kdump,
> as well as the python scripts/dump-guest-memory.py.
> 
> To test:
> 
> Using kernel from https://github.com/elmarco/linux fw-cfg branch,
> Compile and run guest kernel with CONFIG_RANDOMIZE_BASE=y & CONFIG_FW_CFG_SYSFS=y.
> 
> Run qemu with -global fw_cfg.vmcoreinfo=on
> 
> Produce an ELF dump:
> { "execute": "dump-guest-memory", "arguments": { "protocol": "file:dump", "paging": false } }
> 
> Produce a kdump:
> { "execute": "dump-guest-memory", "arguments": { "protocol": "file:dump", "paging": false, "format": "kdump-zlib" } }
> 
> Or with (gdb) dump-guest-memory, with scripts/dump-guest-memory.py script.
> 
> Analyze with crash >= 7.1.9 (or the git version for 4.13 fixes..):
> 
> $ crash vmlinux dump
> 
> v5:
> - removed x-write-pointer-available patch from this series
> - drop vmcoreinfo device
> - add write callback to fw_cfg entries
> - add a writable fw_cfg "vmcoreinfo" entry
> - split phys_base update from VMCOREINFO note in a seperate patch
> - most patches had non-trivial changes, dropping reviewed-by tags
> 
> v4: from Laszlo review
> - switch to warn_report*()
> - update test to follow vmgenid and use boot-sector infrastructure
> - fix range checks in the python script
> - add vmcoreinfo_get() stub
> 
> v3: from Laszlo review
> - change vmcoreinfo offset to 36
> - reset err to null after report
> - use PRIu32
> - change name_size and desc_size against MAX_VMCOREINFO_SIZE
> - python code simplification
> - check boundaries of blocks in phys_memory_read()
> - fix some vmgi vs vmci names
> - add more comments in code
> - fix comment indentation
> - add r-b tags
> 
> v2: from Laszlo review
> - vmci: fix guest endianess handling
> - vmci: fix wrong sizeof()
> - vmci: add back reset logic from vmgenid
> - dump: have 1MB size limit for vmcoreinfo
> - dump: fix potential off-by-1 buffer manipulation
> - dump: use temporary variable for qemu_strtou64
> - dump: fixed VMCOREINFO duplication in kdump
> - update gdb script to not call into qemu process
> - update MAINTAINERS with some new files
> 
> Marc-André Lureau (8):
>   fw_cfg: rename read callback
>   fw_cfg: add write callback
>   fw_cfg: add vmcoreinfo file
>   dump: add guest ELF note
>   dump: update phys_base header field based on VMCOREINFO content
>   kdump: set vmcoreinfo location
>   scripts/dump-guest-memory.py: add vmcoreinfo
>   MAINTAINERS: add Dump maintainers
> 
>  scripts/dump-guest-memory.py |  51 ++++++++++++
>  include/hw/compat.h          |   8 ++
>  include/hw/loader.h          |   2 +-
>  include/hw/nvram/fw_cfg.h    |  18 ++++-
>  include/sysemu/dump.h        |   2 +
>  dump.c                       | 179 +++++++++++++++++++++++++++++++++++++++++++
>  hw/acpi/vmgenid.c            |   2 +-
>  hw/core/loader.c             |   4 +-
>  hw/i386/acpi-build.c         |   2 +-
>  hw/isa/lpc_ich9.c            |   4 +-
>  hw/nvram/fw_cfg.c            |  64 ++++++++++++----
>  MAINTAINERS                  |   9 +++
>  docs/specs/fw_cfg.txt        |  24 ++++++
>  13 files changed, 343 insertions(+), 26 deletions(-)
> 
> -- 
> 2.14.0.1.geff633fa0

  parent reply	other threads:[~2017-08-16 20:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-07 18:16 [Qemu-devel] [PATCH v5 0/8] KASLR kernel dump support Marc-André Lureau
2017-08-07 18:16 ` [Qemu-devel] [PATCH v5 1/8] fw_cfg: rename read callback Marc-André Lureau
2017-08-07 18:16 ` [Qemu-devel] [PATCH v5 2/8] fw_cfg: add write callback Marc-André Lureau
2017-09-08 12:40   ` Michael S. Tsirkin
2017-08-07 18:16 ` [Qemu-devel] [PATCH v5 3/8] fw_cfg: add vmcoreinfo file Marc-André Lureau
2017-09-08 12:32   ` Michael S. Tsirkin
2017-09-08 12:36   ` Michael S. Tsirkin
2017-09-08 12:42   ` Michael S. Tsirkin
2017-09-08 15:39   ` Michael S. Tsirkin
2017-09-08 15:39     ` Michael S. Tsirkin
2017-09-08 15:49       ` Marc-André Lureau
2017-09-10  1:52         ` Michael S. Tsirkin
2017-08-07 18:16 ` [Qemu-devel] [PATCH v5 4/8] dump: add guest ELF note Marc-André Lureau
2017-08-07 18:16 ` [Qemu-devel] [PATCH v5 5/8] dump: update phys_base header field based on VMCOREINFO content Marc-André Lureau
2017-08-07 18:16 ` [Qemu-devel] [PATCH v5 6/8] kdump: set vmcoreinfo location Marc-André Lureau
2017-08-07 18:16 ` [Qemu-devel] [PATCH v5 7/8] scripts/dump-guest-memory.py: add vmcoreinfo Marc-André Lureau
2017-08-07 18:16 ` [Qemu-devel] [PATCH v5 8/8] MAINTAINERS: add Dump maintainers Marc-André Lureau
2017-08-16 20:15 ` Michael S. Tsirkin [this message]
2017-09-08 12:46 ` [Qemu-devel] [PATCH v5 0/8] KASLR kernel dump support Michael S. Tsirkin

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=20170816231527-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=anderson@redhat.com \
    --cc=berrange@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=lersek@redhat.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).