]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmVirtPkg/NorFlashQemuLib: disregard our primary FV
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Fri, 30 Nov 2018 11:28:28 +0000 (12:28 +0100)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Mon, 3 Dec 2018 14:56:10 +0000 (15:56 +0100)
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 <ard.biesheuvel@linaro.org>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c
ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf

index 2678f57eaaad0915cee88268a10e19b430d2d429..d238e39a59f101315e0b1e3a4f01c7b4adaba9ad 100644 (file)
@@ -75,13 +75,22 @@ NorFlashPlatformGetDevices (
       Size = SwapBytes64 (ReadUnaligned64 ((VOID *)&Reg[2]));\r
       Reg += 4;\r
 \r
       Size = SwapBytes64 (ReadUnaligned64 ((VOID *)&Reg[2]));\r
       Reg += 4;\r
 \r
+      PropSize -= 4 * sizeof (UINT32);\r
+\r
+      //\r
+      // Disregard any flash devices that overlap with the primary FV.\r
+      // The firmware is not updatable from inside the guest anyway.\r
+      //\r
+      if ((PcdGet64 (PcdFvBaseAddress) + PcdGet32 (PcdFvSize) > Base) &&\r
+          (Base + Size) > PcdGet64 (PcdFvBaseAddress)) {\r
+        continue;\r
+      }\r
+\r
       mNorFlashDevices[Num].DeviceBaseAddress = (UINTN)Base;\r
       mNorFlashDevices[Num].RegionBaseAddress = (UINTN)Base;\r
       mNorFlashDevices[Num].Size              = (UINTN)Size;\r
       mNorFlashDevices[Num].BlockSize         = QEMU_NOR_BLOCK_SIZE;\r
       Num++;\r
       mNorFlashDevices[Num].DeviceBaseAddress = (UINTN)Base;\r
       mNorFlashDevices[Num].RegionBaseAddress = (UINTN)Base;\r
       mNorFlashDevices[Num].Size              = (UINTN)Size;\r
       mNorFlashDevices[Num].BlockSize         = QEMU_NOR_BLOCK_SIZE;\r
       Num++;\r
-\r
-      PropSize -= 4 * sizeof (UINT32);\r
     }\r
   }\r
 \r
     }\r
   }\r
 \r
index d86ff36dbd58a40c89a9d7a82694cb057b0bd570..c5752a243e6b46482ccb572add8535d15ecb83a9 100644 (file)
@@ -28,6 +28,7 @@
 [Packages]\r
   MdePkg/MdePkg.dec\r
   ArmPlatformPkg/ArmPlatformPkg.dec\r
 [Packages]\r
   MdePkg/MdePkg.dec\r
   ArmPlatformPkg/ArmPlatformPkg.dec\r
+  ArmPkg/ArmPkg.dec\r
   ArmVirtPkg/ArmVirtPkg.dec\r
 \r
 [LibraryClasses]\r
   ArmVirtPkg/ArmVirtPkg.dec\r
 \r
 [LibraryClasses]\r
@@ -40,3 +41,7 @@
 \r
 [Depex]\r
   gFdtClientProtocolGuid\r
 \r
 [Depex]\r
   gFdtClientProtocolGuid\r
+\r
+[Pcd]\r
+  gArmTokenSpaceGuid.PcdFvBaseAddress\r
+  gArmTokenSpaceGuid.PcdFvSize\r