[edk2-devel] [PATCH v1 10/11] ArmVirtPkg: Link NorFlashDxe with BaseMemoryLibMmio

Sami Mujawar posted 11 patches 5 years, 9 months ago
There is a newer version of this series
[edk2-devel] [PATCH v1 10/11] ArmVirtPkg: Link NorFlashDxe with BaseMemoryLibMmio
Posted by Sami Mujawar 5 years, 9 months ago
NorFlashDxe must use aligned MMIO accesses to
read data from flash as this is device memory.

The AlignedCopyMem() in NorFlashDxe was used to
copy the flash data which prevented unaligned
access to device memory. However, the compiler
could optimize the code to generate pre/post
indexed or LDP operations. This is a problem
for guest/virtual firmware as the hypervisor
code cannot get the syndrome information for
the trapped accesses.

To address the such issues, BaseMemoryLibMmio
library has been introduced to perform aligned
MMIO accesses.

The NorFlashDxe has been updated to use
CopyMem() instead of using AlignedCopyMem()
and therefore the NorFlashDxe must be linked
with BaseMemoryLibMmio.

This patch updates the workspace files to link
NorFlashDxe with BaseMemoryLibMmio for the
following platforms:
  - Arm Qemu
  - Arm Qemu Kernel

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
---
 ArmVirtPkg/ArmVirtQemu.dsc       | 8 ++++++--
 ArmVirtPkg/ArmVirtQemuKernel.dsc | 8 ++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index 3f649c91d8d6a2e3f3e62f35aa40906e048a15c4..82b7d54c2031fed60dccff38353d3ec19cfdefd0 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -1,5 +1,5 @@
 #
-#  Copyright (c) 2011-2015, ARM Limited. All rights reserved.
+#  Copyright (c) 2011-2020, ARM Limited. All rights reserved.
 #  Copyright (c) 2014, Linaro Limited. All rights reserved.
 #  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
 #
@@ -384,7 +384,11 @@ [Components.common]
     <LibraryClasses>
       NULL|ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.inf
   }
-  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
+  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf {
+    <LibraryClasses>
+      BaseMemoryLib|MdePkg/Library/BaseMemoryLibMmio/BaseMemoryLibMmio.inf
+  }
+
   MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
 
   #
diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc
index 2a6fd6bc06be1cc20d8c6f2bf00d88d593061edf..6cceb61e493c8c84f6564b120b0864ff817c3f31 100644
--- a/ArmVirtPkg/ArmVirtQemuKernel.dsc
+++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc
@@ -1,5 +1,5 @@
 #
-#  Copyright (c) 2011-2015, ARM Limited. All rights reserved.
+#  Copyright (c) 2011-2020, ARM Limited. All rights reserved.
 #  Copyright (c) 2014, Linaro Limited. All rights reserved.
 #  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
 #
@@ -323,7 +323,11 @@ [Components.common]
     <LibraryClasses>
       NULL|ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.inf
   }
-  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
+  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf {
+    <LibraryClasses>
+      BaseMemoryLib|MdePkg/Library/BaseMemoryLibMmio/BaseMemoryLibMmio.inf
+  }
+
   MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
 
   #
-- 
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#59514): https://edk2.groups.io/g/devel/message/59514
Mute This Topic: https://groups.io/mt/74200921/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH v1 10/11] ArmVirtPkg: Link NorFlashDxe with BaseMemoryLibMmio
Posted by Laszlo Ersek 5 years, 9 months ago
On 05/14/20 10:40, Sami Mujawar wrote:
> NorFlashDxe must use aligned MMIO accesses to
> read data from flash as this is device memory.
> 
> The AlignedCopyMem() in NorFlashDxe was used to
> copy the flash data which prevented unaligned
> access to device memory. However, the compiler
> could optimize the code to generate pre/post
> indexed or LDP operations. This is a problem
> for guest/virtual firmware as the hypervisor
> code cannot get the syndrome information for
> the trapped accesses.
> 
> To address the such issues, BaseMemoryLibMmio
> library has been introduced to perform aligned
> MMIO accesses.
> 
> The NorFlashDxe has been updated to use
> CopyMem() instead of using AlignedCopyMem()
> and therefore the NorFlashDxe must be linked
> with BaseMemoryLibMmio.
> 
> This patch updates the workspace files to link
> NorFlashDxe with BaseMemoryLibMmio for the
> following platforms:
>   - Arm Qemu
>   - Arm Qemu Kernel
> 
> Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
> ---
>  ArmVirtPkg/ArmVirtQemu.dsc       | 8 ++++++--
>  ArmVirtPkg/ArmVirtQemuKernel.dsc | 8 ++++++--
>  2 files changed, 12 insertions(+), 4 deletions(-)

Based on Ard's comment under "MdePkg: Base Memory Lib instance using
MMIO" ("I don't think we need this library"), this patch would be
unnecessary too.

(This applies to the
"BaseMemoryLib|MdePkg/Library/BaseMemoryLibMmio/BaseMemoryLibMmio.inf"
resolutions in the previous patch as well, apparently.)

Thanks
Laszlo

> 
> diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
> index 3f649c91d8d6a2e3f3e62f35aa40906e048a15c4..82b7d54c2031fed60dccff38353d3ec19cfdefd0 100644
> --- a/ArmVirtPkg/ArmVirtQemu.dsc
> +++ b/ArmVirtPkg/ArmVirtQemu.dsc
> @@ -1,5 +1,5 @@
>  #
> -#  Copyright (c) 2011-2015, ARM Limited. All rights reserved.
> +#  Copyright (c) 2011-2020, ARM Limited. All rights reserved.
>  #  Copyright (c) 2014, Linaro Limited. All rights reserved.
>  #  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
>  #
> @@ -384,7 +384,11 @@ [Components.common]
>      <LibraryClasses>
>        NULL|ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.inf
>    }
> -  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
> +  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf {
> +    <LibraryClasses>
> +      BaseMemoryLib|MdePkg/Library/BaseMemoryLibMmio/BaseMemoryLibMmio.inf
> +  }
> +
>    MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
>  
>    #
> diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc
> index 2a6fd6bc06be1cc20d8c6f2bf00d88d593061edf..6cceb61e493c8c84f6564b120b0864ff817c3f31 100644
> --- a/ArmVirtPkg/ArmVirtQemuKernel.dsc
> +++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc
> @@ -1,5 +1,5 @@
>  #
> -#  Copyright (c) 2011-2015, ARM Limited. All rights reserved.
> +#  Copyright (c) 2011-2020, ARM Limited. All rights reserved.
>  #  Copyright (c) 2014, Linaro Limited. All rights reserved.
>  #  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
>  #
> @@ -323,7 +323,11 @@ [Components.common]
>      <LibraryClasses>
>        NULL|ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.inf
>    }
> -  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
> +  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf {
> +    <LibraryClasses>
> +      BaseMemoryLib|MdePkg/Library/BaseMemoryLibMmio/BaseMemoryLibMmio.inf
> +  }
> +
>    MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
>  
>    #
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#59553): https://edk2.groups.io/g/devel/message/59553
Mute This Topic: https://groups.io/mt/74200921/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-