2load_kernel: Change bootloader_address out-parameter to offset

One of the output parameters of vb2api_load_kernel() is the bootloader
address that was embedded in the kernel preamble and points to the
"bootloader" section at the end of the kernel image (which also marks
the end of the main kernel body and is therefore important to find the
command line).

...except that it doesn't. It points to where vbutil_kernel thought the
bootloader should be loaded to, which is in relation to the body load
address that it thought the main kernel should be loaded to.  But since
kernel_buffer is an in-out parameter in vb2_kernel_params we actually
usually load the kernel to wherever we want and ignore the body load
address in the preamble, which means that the bootloader address
returned to the calling firmware can be completely bogus, and since we
don't return the preamble's body load address in vb2_kernel_params, the
calling firmware doesn't even have a chance to correct it. Depthcharge
works around that by just hardcoding the number 0x100000, which is the
default vbutil_kernel uses as body load address if none is provided
(which we in practice never do).

Still, we shouldn't need to hardcode magic numbers all over the place
and just pray that nobody overrode --kloadaddr to vbutil_kernel at build
time. This patch changes bootloader_address in vb2_kernel_params to
bootloader_offset, which is usually what the caller needs anyway.

BUG=none
TEST=booted CoachZ

Signed-off-by: Julius Werner <jwerner@chromium.org>
Cq-Depend: chromium:4576494
Change-Id: Ieee619d774d24716efec5bb6efe945eda3b2ca18
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4577395
Reviewed-by: Nicholas Bishop <nicholasbishop@google.com>
Commit-Queue: Nicholas Bishop <nicholasbishop@google.com>
6 files changed