Skip to content

Implement Firmware Assisted Dump for PSeries

Aditya Gupta qemu-devel 5 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest8 patches 15 repliesIn review
  2. v48 patches 27 repliesSuperseded
  3. v38 patches 4 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v28 patches1 replySuperseded
v16 patches22 repliesSuperseded

Changes in v5 from the cover letter

+ rebased to upstream, implemented reviews by sourabh and harsh
+ [patch #1]: patch #1 and #2 of v4 merged into one
+ [patch #3]: copy memory region in chunks of 32MB instead of all at once
+ [patch #4]: fix endianness of vcpu id in CPUSTRT/CPUEND entries
+ [patch #5]: replaced type __be32 with uint32_t
+ [patch #7]: increased timeout for few messages to 20 seconds
+ [patch #8]: update maintainers file for fadump

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8hw/ppc: Implement fadump register commandhw/ppc/meson.build hw/ppc/spapr_fadump.c hw/ppc/spapr_rtas.c +2 more+274 -12 replies
2/8hw/ppc: Trigger Fadump boot if fadump is registeredhw/ppc/spapr_fadump.c hw/ppc/spapr_rtas.c include/hw/ppc/spapr_fadump.h+88 -01 reply
3/8hw/ppc: Preserve memory regions registered for fadumphw/ppc/spapr_fadump.c include/hw/ppc/spapr_fadump.h+196 -51 reply
4/8hw/ppc: Implement saving CPU state in Fadumphw/ppc/spapr_fadump.c include/hw/ppc/spapr_fadump.h+390 -25 replies
5/8hw/ppc: Pass dump-sizes property for fadump in device treehw/ppc/spapr.c hw/ppc/spapr_fadump.c+60 -31 reply
6/8hw/ppc: Enable fadump for PSerieshw/ppc/spapr.c+12 -02 replies
7/8tests/functional: Add test for fadump in PSeriestests/functional/ppc64/meson.build tests/functional/ppc64/test_fadump.py tests/functional/qemu_test/linuxkernel.py+243 -00 replies
8/8MAINTAINERS: Add entry for FADump (pSeries)MAINTAINERS+8 -01 reply

Reviews trailers per patch

7 of 8 patches have a Reviewed-by or Acked-by.

PatchSourabh JainShivang Upadhyay
SeriesT-b
1/8R-b
2/8R-b
3/8R-b
4/8R-b
5/8R-b
6/8R-b
7/8
8/8A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v5 thread

Cover letter [PATCH v5 0/8] Implement Firmware Assisted Dump for PSeries

Overview
=========

Implemented Firmware Assisted Dump (fadump) on PSeries machine in QEMU.

Fadump is an alternative dump mechanism to kdump, in which we the firmware does a memory preserving boot, and the second/crashkernel is booted fresh like a normal system reset, instead of the crashed kernel loading the second/crashkernel in case of kdump.

This requires implementing the "ibm,configure-kernel-dump" RTAS call in QEMU.

While booting with fadump=on, Linux will register fadump memory regions.

Some memory regions like Real Mode Memory regions, and custom memory regions declared by OS basically require copying the requested memory range to a destination

While other memory regions are populated by the firmware/platform (QEMU in this case), such as CPU State Data and HPTE.
We pass the sizes for these data segment to the kernel as it needs to know how much memory to reserve (ibm,configure-kernel-dump-sizes).

Then after a crash, once Linux does a OS terminate call, we trigger fadump if fadump was registered.

Implementing the fadump boot as:
* pause all vcpus (will save registers later)
* preserve memory regions specified by fadump
* do a memory preserving reboot (using GUEST_RESET as it doesn't clear the memory)

And then we pass a metadata (firmware memory structure) as "ibm,kernel-dump" in the device tree, containing all details of the preserved memory regions to the kernel.

Refer the Patch #7: "hw/ppc: Enable fadump for PSeries" for logs of a succesfful fadump crash

Note: HPTE region has not been implemented. It's not planned as of now.

Testing
=======

Has been tested with following QEMU options:

* make check-functional-ppc64
* smt1/smt4
* with/without e1000e device
* gitlab ci: https://gitlab.com/adi-g15-ibm/qemu/-/pipelines/2111480523

Following vmcore has been generated with v5 of this series, booted with -smp 4: https://ibm.box.com/s/dv92hdi67hh0588xn8cbvkjmlcy04d7h

Git Tree for Testing
====================

https://github.com/adi-g15-ibm/qemu/tree/fadump-pseries-v5

Note: You will need a way to get the /proc/vmcore out of the VM for testing with crash-utility

I use the following command line which sets up networking:

    "-net user,hostfwd=tcp::10022-:22 -net nic"

And a rootfs with ssh support, then copy the /proc/vmcore with networking (can do compression using gzip before ssh, but compression might take lot of time if done inside the VM)

Changelog
=========
v5:
+ rebased to upstream, implemented reviews by sourabh and harsh
+ [patch #1]: patch #1 and #2 of v4 merged into one
+ [patch #3]: copy memory region in chunks of 32MB instead of all at once
+ [patch #4]: fix endianness of vcpu id in CPUSTRT/CPUEND entries
+ [patch #5]: replaced type __be32 with uint32_t
+ [patch #7]: increased timeout for few messages to 20 seconds
+ [patch #8]: update maintainers file for fadump

v4
+ [patch #8/8]: fixed kvm testcase, add license

v3:
+ [patch #3,7]: fix compile errors (#define declared in a later patch but used in this patch, unused var)
+ [patch #4/8]: use 'g_autofree' for cpu buffer, and replace g_malloc with g_try_malloc
+ [patch #5/8]: use 'g_new' instead of 'malloc', add null check for cpu region
- nothing in other patches has been changed compared to v2

v2:
+ rearrange code so that no unused functions get introduced in any patch
+ add functional test for pseries as suggested by nick
+ fix multiple issues pointed by harsh and nick
+ fix bug in cpu register saving where it was being stored in little-endian
- removed 'is_next_boot_fadump' and used fadump header's status flag to store it
+ fixed multiple style issues (naming, unneeded diffs etc)

Aditya Gupta (8):
hw/ppc: Implement fadump register command hw/ppc: Trigger Fadump boot if fadump is registered hw/ppc: Preserve memory regions registered for fadump hw/ppc: Implement saving CPU state in Fadump hw/ppc: Pass dump-sizes property for fadump in device tree hw/ppc: Enable fadump for PSeries tests/functional: Add test for fadump in PSeries
MAINTAINERS: Add entry for FADump (pSeries)

 MAINTAINERS                               |   8 +
 hw/ppc/meson.build                        |   1 +
 hw/ppc/spapr.c                            |  69 ++
 hw/ppc/spapr_fadump.c                     | 730 ++++++++++++++++++++++
 hw/ppc/spapr_rtas.c                       |  76 +++
 include/hw/ppc/spapr.h                    |  11 +-
 include/hw/ppc/spapr_fadump.h             | 124 ++++
 tests/functional/ppc64/meson.build        |   2 +
 tests/functional/ppc64/test_fadump.py     | 182 ++++++
 tests/functional/qemu_test/linuxkernel.py |  59 ++
 10 files changed, 1261 insertions(+), 1 deletion(-)
 create mode 100644 hw/ppc/spapr_fadump.c
 create mode 100644 include/hw/ppc/spapr_fadump.h
 create mode 100755 tests/functional/ppc64/test_fadump.py
Signature · 1 line
2.51.0