From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.81]) by mx.groups.io with SMTP id smtpd.web12.1197.1583539320809018252 for ; Fri, 06 Mar 2020 16:02:01 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VZbTR7gX; spf=pass (domain: redhat.com, ip: 207.211.31.81, mailfrom: philmd@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583539320; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WSEwSnxiRi7Fa8FWMZNgTEv8VPFeJqsrKe/gpM717ts=; b=VZbTR7gXDbHLO6VbAfSD3Z35Hy4gE2L3bzCvM1qPQ3GJyRM+ecaKpSuMd6M5lYKgGkUU0J mBtm8KYZ9yqn3KuDZQUQj3V4EuE+J8erKMqkaQoHLy/zY7pqH1Tcoyp0kDA4DBrcUCxwYg Y88xEY6a2GvK9zxFNpIsw/wxGZAN+dA= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-271-VgB1Zs_wN0uq1huEe1JtQQ-1; Fri, 06 Mar 2020 19:01:50 -0500 X-MC-Unique: VgB1Zs_wN0uq1huEe1JtQQ-1 Received: by mail-wr1-f71.google.com with SMTP id n12so1689653wrp.19 for ; Fri, 06 Mar 2020 16:01:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=T33iHRGEI5J0t3jw2QyCYcfiC6H2NN7U2W8bTk4hYUQ=; b=LK7OufynbGS+/p5EafkOfeT7ecHVigMCIgjRRslj7zPQA1QlmjzkJ21nMqOjgD7P06 zw11x39KFek7dCN/KTfbixixZPB7b8cJD1rS3POr6LElgKeePjLrFd1umCwXLYvYw6k8 ayXfDehCrgXzvs20lX7VI7c5EclHkpNrPWznSL/gXhh9XEQNkr9TL1Gl/Nmty26nGijD YUSFxs5opdlLE9Xx7B3e8ysMCmI5wg/1B6tg1bVDRC7E/g94GEB9T2gBg5ksxfVvGOA0 u6si239pYlCIgxCfFZd3YO0ZhgVKyLnPTuHVd7a1aTd7MyeFon59S2TnYQ7wi6Hnizre HbKw== X-Gm-Message-State: ANhLgQ1DLk4ffhp6wvQPGpXCjG+IODA/TrOnRo/Szor6XFiB12VhlqV6 WMt0dUT2GRq+R9yiSfz9ROoYFWsqzf9rJF40vWCt4LPO3IrQVujgNz7NLWrTsV6Q+5rHW9IP8go HPG7gLm1GQxNoBQ== X-Received: by 2002:adf:eb0a:: with SMTP id s10mr6206149wrn.405.1583539309686; Fri, 06 Mar 2020 16:01:49 -0800 (PST) X-Google-Smtp-Source: ADFU+vvFXOJnW59MWOoo43fNT6/Tr19UzcBS9jhDTG5gwlQXl7HvwmtmUeFlj12MvC3YnDeEv21vww== X-Received: by 2002:adf:eb0a:: with SMTP id s10mr6206127wrn.405.1583539309477; Fri, 06 Mar 2020 16:01:49 -0800 (PST) Return-Path: Received: from [192.168.1.35] (47.red-88-21-205.staticip.rima-tde.net. [88.21.205.47]) by smtp.gmail.com with ESMTPSA id g7sm50650594wrq.21.2020.03.06.16.01.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Mar 2020 16:01:48 -0800 (PST) Subject: Re: [PATCH] OvmfPkg/X86QemuLoadImageLib: fix "unused variable" error in X64 DXE builds To: Laszlo Ersek , edk2-devel-groups-io Cc: Ard Biesheuvel , Jordan Justen References: <20200306230442.24100-1-lersek@redhat.com> From: =?UTF-8?B?UGhpbGlwcGUgTWF0aGlldS1EYXVkw6k=?= Message-ID: <5e359f2c-b914-1aa7-6b47-b39a1dff9d42@redhat.com> Date: Sat, 7 Mar 2020 01:01:47 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200306230442.24100-1-lersek@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable On 3/7/20 12:04 AM, Laszlo Ersek wrote: > 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. >=20 > Move the local variable to the inner scope, where declaration and usage > are inseparable. >=20 > (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.) >=20 > 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: Philippe Mathieu-Daude Tested-by: Philippe Mathieu-Daude > --- >=20 > Notes: > Ard, if you get to it first, feel free to push this in my stead. Tha= nks! > =20 > Repo: https://pagure.io/lersek/edk2.git > Branch: x86qlil_build_fix >=20 > OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) >=20 > 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; > =20 > Status =3D gBS->OpenProtocol ( > *ImageHandle, > &gOvmfLoadedX86LinuxKernelProtocolGuid, > (VOID **)&LoadedImage, > gImageHandle, // AgentHandle > NULL, // ControllerHandle > EFI_OPEN_PROTOCOL_GET_PROTOCOL > ); > if (!EFI_ERROR (Status)) { > return QemuStartLegacyImage (*ImageHandle); > } > =20 > 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; > } > =20 > /** > Unloads an image loaded with QemuLoadKernelImage (). > =20 > @param ImageHandle Handle that identifies the image to b= e > unloaded. > =20 > @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. > =20 > @return Exit code from the image's unload fun= ction. > **/ >=20