powerpc: Take in account addition CPU node when building kexec FDT
authorLaurent Dufour <ldufour@linux.ibm.com>
Thu, 10 Nov 2022 18:06:19 +0000 (19:06 +0100)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 7 Dec 2022 09:19:04 +0000 (20:19 +1100)
commit340a4a9f8773e102cc5ef531665970a686dfa245
tree06af7e468fe9572d15f3dd09d413a8166b085ee0
parente13d23a404f2e6dfaf8b1ef7d161a0836fce4fa5
powerpc: Take in account addition CPU node when building kexec FDT

On a system with a large number of CPUs, the creation of the FDT for a
kexec kernel may fail because the allocated FDT is not large enough.

When this happens, such a message is displayed on the console:

  Unable to add ibm,processor-vadd-size property: FDT_ERR_NOSPACE

The property's name may change depending when the buffer overwrite is
detected.

Obviously the created FDT is missing information, and it is expected
that system dump or kexec kernel failed to run properly.

When the FDT is allocated, the size of the FDT the kernel received at
boot time is used and an extra size can be applied. Currently, only
memory added after boot time is taken in account, not the CPU nodes.

The extra size should take in account these additional CPU nodes and
compute the required extra space. To achieve that, the size of a CPU
node, including its subnode is computed once and multiplied by the
number of additional CPU nodes.

The assumption is that the size of the CPU node is _same_ for all the
node, the only variable part should be the name "PowerPC,POWERxx@##"
where "##" may vary a little.

Signed-off-by: Laurent Dufour <ldufour@linux.ibm.com>
[mpe: Don't shadow function name w/variable, minor coding style changes]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20221110180619.15796-3-ldufour@linux.ibm.com
arch/powerpc/kexec/file_load_64.c