From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.132.183.28; helo=mx1.redhat.com; envelope-from=lersek@redhat.com; receiver=edk2-devel@lists.01.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D4CFF21196225 for ; Mon, 3 Dec 2018 05:32:22 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6D69825ED8; Mon, 3 Dec 2018 13:32:22 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-61.rdu2.redhat.com [10.10.120.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 961F0277D7; Mon, 3 Dec 2018 13:32:21 +0000 (UTC) To: Ard Biesheuvel , edk2-devel@lists.01.org Cc: Andrew Jones References: <20181130112829.12173-1-ard.biesheuvel@linaro.org> <20181130112829.12173-4-ard.biesheuvel@linaro.org> From: Laszlo Ersek Message-ID: Date: Mon, 3 Dec 2018 14:32:15 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181130112829.12173-4-ard.biesheuvel@linaro.org> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 03 Dec 2018 13:32:22 +0000 (UTC) Subject: Re: [PATCH v2 3/4] ArmVirtPkg/NorFlashQemuLib: disregard our primary FV X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Dec 2018 13:32:23 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 11/30/18 12:28, Ard Biesheuvel wrote: > The primary FV contains the firmware boot image, which is not > runtime updatable in our case. So exposing it to the NOR flash > driver is undesirable, since it may attempt to modify the NOR > flash contents. It is also rather pointless, since we don't > keep anything there that we care to expose. (the SEC and PEI > phase modules are not executable from DXE context, and the > contents of the embedded DXE phase FV are exposed by the DXE > core directly via the FVB2 protocol) > > So let's disregard the NOR flash block that covers the primary > FV. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel > --- > ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf | 5 +++++ > ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c | 13 +++++++++++-- > 2 files changed, 16 insertions(+), 2 deletions(-) > > diff --git a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf b/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf > index d86ff36dbd58..c5752a243e6b 100644 > --- a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf > +++ b/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf > @@ -28,6 +28,7 @@ [Sources.common] > [Packages] > MdePkg/MdePkg.dec > ArmPlatformPkg/ArmPlatformPkg.dec > + ArmPkg/ArmPkg.dec > ArmVirtPkg/ArmVirtPkg.dec > > [LibraryClasses] > @@ -40,3 +41,7 @@ [Protocols] > > [Depex] > gFdtClientProtocolGuid > + > +[Pcd] > + gArmTokenSpaceGuid.PcdFvBaseAddress > + gArmTokenSpaceGuid.PcdFvSize > diff --git a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c b/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c > index 2678f57eaaad..d238e39a59f1 100644 > --- a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c > +++ b/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c > @@ -75,13 +75,22 @@ NorFlashPlatformGetDevices ( > Size = SwapBytes64 (ReadUnaligned64 ((VOID *)&Reg[2])); > Reg += 4; > > + PropSize -= 4 * sizeof (UINT32); > + > + // > + // Disregard any flash devices that overlap with the primary FV. > + // The firmware is not updatable from inside the guest anyway. > + // > + if ((PcdGet64 (PcdFvBaseAddress) + PcdGet32 (PcdFvSize) > Base) && > + (Base + Size) > PcdGet64 (PcdFvBaseAddress)) { > + continue; > + } > + > mNorFlashDevices[Num].DeviceBaseAddress = (UINTN)Base; > mNorFlashDevices[Num].RegionBaseAddress = (UINTN)Base; > mNorFlashDevices[Num].Size = (UINTN)Size; > mNorFlashDevices[Num].BlockSize = QEMU_NOR_BLOCK_SIZE; > Num++; > - > - PropSize -= 4 * sizeof (UINT32); > } > } > > Reviewed-by: Laszlo Ersek