From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by mx.groups.io with SMTP id smtpd.web12.13843.1583591699349790449 for ; Sat, 07 Mar 2020 06:34:59 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=vYk6q23t; spf=pass (domain: linaro.org, ip: 209.85.221.68, mailfrom: ard.biesheuvel@linaro.org) Received: by mail-wr1-f68.google.com with SMTP id a25so1904319wrd.0 for ; Sat, 07 Mar 2020 06:34:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=kqXdjVEzzWIGLX8ZtEq6ZmPO2XHyKI2WaJgLmbcBofY=; b=vYk6q23tFK3w7AVB2/mlGnOCDUEv11blP5ctjcxM4m/SM7tXJQWo2pFTA0nJaFB36J D+KisDuEgxb/YaAdCE+gQ+fd1uTYufv2nov7Mvo3NIwt7F+TjyuHEH5HOKHtqJCtdIV+ r55tWreHj38cEDGHpII/7sT8+Eht6SIrmhxCf4Ec43lBqFQiEfktVaMfKgU3vQLv2LVQ 8cTzATKC5B7YiLtgSu7ANYqotiNHdc03OW0IS6DD4Ge6lsxY9mnqG8LMopAtqo1YFqd4 oMQHVy3eBYU1M03SStw0BYzwAib/jus7Kw3QEJLaJpj2m8GCKorg5kCwVAK/1DtopRkN 7UpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=kqXdjVEzzWIGLX8ZtEq6ZmPO2XHyKI2WaJgLmbcBofY=; b=SC4lOGLzipZks6cAjGIMcBRHz3r4NjgnFzIaVOZcY1lqPcTdbFk6BTbtz00LlYou2s wC9cDAK9P0nEued8TSJ/UjyMICc+amHXJ+HSghgdW+UjpZdVSeWnW8exwP0hduR0vjtT rd2bKNbcP57Pn7567U+wBce/wiHru/CwIxt8rPvFwfE00BAvFVV3mvR3U4PhDr4yH6nQ ROMvlOkfjAACNcDfcg/6o4IMMy6wgSzJ8LKhCJ58HWcc8qird8/B1VlkA2f9De1Bg3AD rOeegzPuEomY1WS/oP8WuY2rzcOpylhd2FNthxdNN8J79hUqeYyPJ3FVVd7XepMfkS3g oPRQ== X-Gm-Message-State: ANhLgQ34YfWfOtrK/2GRKqQn2UCeMIBxRvVH+ofMmevdsQgitXU4i86S F7eOBXVWpgqZSLtUKBeJ5sE30owCyaSKEbpoiqmmexJVaV0= X-Google-Smtp-Source: ADFU+vusOQh6HICjGdxR3ordVTNQ1a9XU7Dh2fykJ1HOkeQdSuZZMKsMfXAS/bq8QjyRxpsQAzQv7Nt5hWGQiX8G2RU= X-Received: by 2002:a5d:6051:: with SMTP id j17mr9928540wrt.151.1583591697343; Sat, 07 Mar 2020 06:34:57 -0800 (PST) MIME-Version: 1.0 References: <20200306230442.24100-1-lersek@redhat.com> In-Reply-To: <20200306230442.24100-1-lersek@redhat.com> From: "Ard Biesheuvel" Date: Sat, 7 Mar 2020 15:34:46 +0100 Message-ID: Subject: Re: [edk2-devel] [PATCH] OvmfPkg/X86QemuLoadImageLib: fix "unused variable" error in X64 DXE builds To: edk2-devel-groups-io , Laszlo Ersek Cc: Jordan Justen , =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, 7 Mar 2020 at 00:04, Laszlo Ersek wrote: > > When the MDE_CPU_IA32 macro is not defined, there is no access to the > "KernelImageHandle" local variable in QemuStartKernelImage(). This break= s > 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 anywa= y, > because they help us reason about variable lifetime and visibility.) > > Cc: Ard Biesheuvel > Cc: Jordan Justen > Cc: Philippe Mathieu-Daud=C3=A9 > Fixes: 7c47d89003a6f8f7f6f0ce8ca7d3e87c630d14cc > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2572 > Signed-off-by: Laszlo Ersek Reviewed-by: Ard Biesheuvel (in case you still need it) > --- > > Notes: > Ard, if you get to it first, feel free to push this in my stead. Tha= nks! > > 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 =3D gBS->OpenProtocol ( > *ImageHandle, > &gOvmfLoadedX86LinuxKernelProtocolGuid, > (VOID **)&LoadedImage, > gImageHandle, // AgentHandle > NULL, // ControllerHandle > EFI_OPEN_PROTOCOL_GET_PROTOCOL > ); > if (!EFI_ERROR (Status)) { > return QemuStartLegacyImage (*ImageHandle); > } > > Status =3D gBS->StartImage ( > *ImageHandle, > NULL, // ExitDataSize > NULL // ExitData > ); > #ifdef MDE_CPU_IA32 > if (Status =3D=3D 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 imag= es, or > // because we are running without the support code for that. So loa= d the > // image again, using the legacy loader, and unload the normally lo= aded > // image before starting the legacy one. > // > Status =3D 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 =3D KernelImageHandle; > return QemuStartLegacyImage (KernelImageHandle); > } > #endif > return Status; > } > > /** > Unloads an image loaded with QemuLoadKernelImage (). > > @param ImageHandle Handle that identifies the image to b= e > 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 hand= le. > > @return Exit code from the image's unload fun= ction. > **/ > -- > 2.19.1.3.g30247aa5d201 > > >=20 >