hw/ppc/fadump: Fix CPU_STATE_DATA region reported size
v3 cover hw/ppc/fadump: Fix CPU_STATE_DATA region reported size
Fadump is unable to collect dump, when qemu is started with maxcpus option. This bug was also disucssed on linux side here [1]. But We could not find a way to mitigate all the ambiguity around the fadump region error reporting. It is assumed that if allocated size and dumped size dont match, then data copy must have failed. So Replicating the Phyp's behaviour here.
The following behaviour is observed with Phyp.
1. Registers entries are only filled for online CPUs.
2. regNum is set as number of currently online CPUs.
3. CPU_STATE_DATA's bytes_dumped always equals source_len.
Qemu already have, same behaviour for 1 and 2. Fixing the 3rd behaviour in this patch.
[1] https://lore.kernel.org/all/[email protected]/
--
Changelog:
v3: Removing the fake entries population. Kernel handles this case by default.
v2: https://lore.kernel.org/qemu-devel/[email protected]/
--
Shivang Upadhyay (1):
hw/ppc/fadump: report CPU_STATE_DATA dumped_bytes as source_len
hw/ppc/spapr_fadump.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
Signature · 1 line
2.54.0
PATCH v3 1/1 hw/ppc/fadump: report CPU_STATE_DATA dumped_bytes as source_len
When system is restarted with fadump, cpu registers data is copied to CPU_STATE_DATA region. The size of data depends on the number of cpus that are currently present in the system. But when maxcpus config option is provided in qemu command line, this causes the linux kernel to allocate extra space for CPU_STATE_DATA region. If there are no hotplug operations, this will lead to part of region being empty.
As per current Linux kernel, It expects the size of collected Fadump region to be exactly equal to allocated size. Otherwise kernel assumes that dump is incomplete [1].
If maxcpus option is used, This causes qemu to send partially filled region, and Kernel then rejects to collect to any dump. As a result of this /proc/vmcore is not generated.
To fix this, Changing fadump to always report CPU_STATE_DATA's dumped_bytes as source_len. This behaviour is also noticed in Phyp.
--- hw/ppc/spapr_fadump.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
hw/ppc/spapr_fadump.c +5 -2
@@ -575,8 +575,9 @@ static bool do_populate_cpu_state(FadumpSection *region)if (region->source_len != region->bytes_dumped) {/* -* Log the error, but don't fail the dump collection here, let -* kernel handle the mismatch +* Log the error, but don't fail the dump collection here. +* This is probably because of maxcpus config. Linux kernel would +* not collect any dump if dumped_bytes does not match source_len. */ qemu_log_mask (LOG_GUEST_ERROR , "FADump: Mismatch in CPU State region's length exported:"
@@ -584,6 +585,8 @@ static bool do_populate_cpu_state(FadumpSection *region)" QEMU exported: 0x%" PRIx64" bytes\n" ,be64_to_cpu (region->source_len), be64_to_cpu(region->bytes_dumped)); + + region->bytes_dumped = region->source_len; }return true;
Signature · 1 line
2.54.0
Re: [PATCH v3 1/1] hw/ppc/fadump: report CPU_STATE_DATA dumped_bytes as source_len
Quoted 32 lines · Shivang Upadhyay
When system is restarted with fadump, cpu registers data is copied to
CPU_STATE_DATAregion. The size of data depends on the number of cpus that are currently present in the system. But when maxcpus config option is provided in qemu command line, this causes the linux kernel to allocate extra space forCPU_STATE_DATAregion. If there are no hotplug operations, this will lead to part of region being empty.As per current Linux kernel, It expects the size of collected Fadump region to be exactly equal to allocated size. Otherwise kernel assumes that dump is incomplete [1].
If maxcpus option is used, This causes qemu to send partially filled region, and Kernel then rejects to collect to any dump. As a result of this
/proc/vmcoreis not generated.To fix this, Changing fadump to always report CPU_STATE_DATA's
dumped_bytesassource_len. This behaviour is also noticed in Phyp.Cc Sourabh Jain <[email protected]>Cc Aditya Gupta <[email protected]>Reported-by Anushree Mathur <[email protected]>Signed-off-by Shivang Upadhyay <[email protected]>--- hw/ppc/spapr_fadump.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)hw/ppc/spapr_fadump.c +0
-0
hw/ppc/spapr_fadump.c static bool do_populate_cpu_state(FadumpSection *region) · line 581
Quoted 9 lines
hw/ppc/spapr_fadump.c +3
-2@@ -575,8 +575,9 @@ static bool do_populate_cpu_state(FadumpSection *region)if (region->source_len != region->bytes_dumped) {/* -* Log the error, but don't fail the dump collection here, let -* kernel handle the mismatch +* Log the error, but don't fail the dump collection here. +* This is probably because of maxcpus config. Linux kernel would +* not collect any dump if dumped_bytes does not match source_len. */
Understood the problem, can we mention something like "this is not specifically suggested by spapr, matching phyp's behaviour here" or something like that ?
hw/ppc/spapr_fadump.c static bool do_populate_cpu_state(FadumpSection *region) · line 589
Quoted 8 lines
hw/ppc/spapr_fadump.c +2
-0qemu_log_mask (LOG_GUEST_ERROR , "FADump: Mismatch in CPU State region's length exported:"@@ -584,6 +585,8 @@ static bool do_populate_cpu_state(FadumpSection *region)" QEMU exported: 0x%" PRIx64" bytes\n" ,be64_to_cpu (region->source_len), be64_to_cpu(region->bytes_dumped)); + + region->bytes_dumped = region->source_len;
source_len = bytes_dumped makes more sense here, than increasing bytes_dumped to source_len. what do you say ?
otherwise okay with me, but good to have a clear comment about deviating from spapr to match phyp here, so we can fix it if phyp or spapr were to change to follow one thing.
thanks,
- Aditya G