From nobody Mon Apr 29 17:01:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+55622+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+55622+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583535892; cv=none; d=zohomail.com; s=zohoarc; b=BtaFLjssMoxxVG4bOwsCPoCcYWZiFV1jh/C3GNVBbp0Eqp6jpst/SYeJwOCeY14gleScY9MnS3+kkuf382mttIubC93+9K+OJeCekMpMWM+KsKH7RpoWWok5vqXQo1twiFDBEGKufEvR4niM1tcpNlajvwmTPh7Q+JkRMvf5ncc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583535892; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=nf6DAYNh6lbW1cOQCC6QqTPt2P5mT7FWWo/lv1XTUpU=; b=TefHTXBaC9W2xPpS0Pp7xgJ/Qq0+9RC8m2BFoSbrTiAaMIaN406QCuN8lTuNlFjz55PHkoa6XNLRZTiwV5yWfKUOGhDcWiKY4MRN/j4R/HxYGqGop4C8gFjbU43Kwj5wE0NfDkY5hE7KnpsO2CuViPA1bdpitkCLCobc0ozLCHI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+55622+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1583535892944334.42300579140044; Fri, 6 Mar 2020 15:04:52 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id iX1eYY1788612xD0sDblqSSh; Fri, 06 Mar 2020 15:04:52 -0800 X-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.web10.375.1583535891887224990 for ; Fri, 06 Mar 2020 15:04:52 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-463-WX3lSpLbOd29N50EVz27nA-1; Fri, 06 Mar 2020 18:04:46 -0500 X-MC-Unique: WX3lSpLbOd29N50EVz27nA-1 X-Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4932F8017DF; Fri, 6 Mar 2020 23:04:45 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-117-130.ams2.redhat.com [10.36.117.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 180611001B2B; Fri, 6 Mar 2020 23:04:43 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Jordan Justen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [edk2-devel] [PATCH] OvmfPkg/X86QemuLoadImageLib: fix "unused variable" error in X64 DXE builds Date: Sat, 7 Mar 2020 00:04:42 +0100 Message-Id: <20200306230442.24100-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: Y4Nmi4e28ZunPzGdr8MaAmpSx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1583535892; bh=nf6DAYNh6lbW1cOQCC6QqTPt2P5mT7FWWo/lv1XTUpU=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=ibGWoRRuYeBvYr2gkp9LL5Z0fn+Bog/7PnXlR+Xm6F6jaFyYl7YnB3dvDAuoyaPYiPa 38S6HSORL2Huv2oQgakQvjaw4JyFLxWXeyoHHltmQIf/ucO9VHUq390PN0t8nki1J752b qjf4Bmbp/nAy5oQb5CGnc4GhC0pFd0S8FnQ= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" 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 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 Reviewed-by: Philippe Mathieu-Daude Tested-by: Philippe Mathieu-Daude --- Notes: Ard, if you get to it first, feel free to push this in my stead. Thanks! =20 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/Ov= mfPkg/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 .c= ompat // PE/COFF section that Linux specifies for mixed mode capable images,= or // because we are running without the support code for that. So load t= he // image again, using the legacy loader, and unload the normally loaded // 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 be 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 handle. =20 @return Exit code from the image's unload functi= on. **/ --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#55622): https://edk2.groups.io/g/devel/message/55622 Mute This Topic: https://groups.io/mt/71785477/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-