From: "Laszlo Ersek" <lersek@redhat.com>
To: edk2-devel-groups-io <devel@edk2.groups.io>
Cc: "Ard Biesheuvel" <ard.biesheuvel@linaro.org>,
"Jordan Justen" <jordan.l.justen@intel.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: [PATCH] OvmfPkg/X86QemuLoadImageLib: fix "unused variable" error in X64 DXE builds
Date: Sat, 7 Mar 2020 00:04:42 +0100 [thread overview]
Message-ID: <20200306230442.24100-1-lersek@redhat.com> (raw)
When the MDE_CPU_IA32 macro is not defined, there is no access to the
"KernelImageHandle" local variable in QemuStartKernelImage(). This breaks
the OvmfPkgIa32X64 and OvmfPkgX64 platform builds, at least with gcc-8.
Move the local variable to the inner scope, where declaration and usage
are inseparable.
(Note that such inner-scope declarations are frowned upon in the wider
edk2 codebase, but we use them liberally in ArmVirtPkg and OvmfPkg anyway,
because they help us reason about variable lifetime and visibility.)
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Fixes: 7c47d89003a6f8f7f6f0ce8ca7d3e87c630d14cc
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2572
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
Notes:
Ard, if you get to it first, feel free to push this in my stead. Thanks!
Repo: https://pagure.io/lersek/edk2.git
Branch: x86qlil_build_fix
OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c b/OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c
index c5bd6862b265..1868c9fcafdf 100644
--- a/OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c
+++ b/OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c
@@ -457,67 +457,68 @@ EFIAPI
QemuStartKernelImage (
IN OUT EFI_HANDLE *ImageHandle
)
{
EFI_STATUS Status;
OVMF_LOADED_X86_LINUX_KERNEL *LoadedImage;
- EFI_HANDLE KernelImageHandle;
Status = gBS->OpenProtocol (
*ImageHandle,
&gOvmfLoadedX86LinuxKernelProtocolGuid,
(VOID **)&LoadedImage,
gImageHandle, // AgentHandle
NULL, // ControllerHandle
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (!EFI_ERROR (Status)) {
return QemuStartLegacyImage (*ImageHandle);
}
Status = gBS->StartImage (
*ImageHandle,
NULL, // ExitDataSize
NULL // ExitData
);
#ifdef MDE_CPU_IA32
if (Status == EFI_UNSUPPORTED) {
+ EFI_HANDLE KernelImageHandle;
+
//
// On IA32, EFI_UNSUPPORTED means that the image's machine type is X64 while
// we are expecting a IA32 one, and the StartImage () boot service is unable
// to handle it, either because the image does not have the special .compat
// PE/COFF section that Linux specifies for mixed mode capable images, or
// because we are running without the support code for that. So load the
// image again, using the legacy loader, and unload the normally loaded
// image before starting the legacy one.
//
Status = QemuLoadLegacyImage (&KernelImageHandle);
if (EFI_ERROR (Status)) {
//
// Note: no change to (*ImageHandle), the caller will release it.
//
return Status;
}
//
// Swap in the legacy-loaded image.
//
QemuUnloadKernelImage (*ImageHandle);
*ImageHandle = KernelImageHandle;
return QemuStartLegacyImage (KernelImageHandle);
}
#endif
return Status;
}
/**
Unloads an image loaded with QemuLoadKernelImage ().
@param ImageHandle Handle that identifies the image to be
unloaded.
@retval EFI_SUCCESS The image has been unloaded.
@retval EFI_UNSUPPORTED The image has been started, and does not
support unload.
@retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle.
@return Exit code from the image's unload function.
**/
--
2.19.1.3.g30247aa5d201
next reply other threads:[~2020-03-06 23:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-06 23:04 Laszlo Ersek [this message]
2020-03-07 0:01 ` [PATCH] OvmfPkg/X86QemuLoadImageLib: fix "unused variable" error in X64 DXE builds Philippe Mathieu-Daudé
2020-03-07 1:00 ` [edk2-devel] " Laszlo Ersek
2020-03-07 6:10 ` Ard Biesheuvel
2020-03-07 7:28 ` Laszlo Ersek
2020-03-07 7:41 ` Laszlo Ersek
2020-03-07 14:34 ` Ard Biesheuvel
2020-03-08 9:40 ` Laszlo Ersek
2020-03-09 23:19 ` Laszlo Ersek
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-list 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=20200306230442.24100-1-lersek@redhat.com \
--to=devel@edk2.groups.io \
/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