Hi,


I'm getting Alignment Fault when running UEFI image on Juno R0 board which is caused by VariableRuntimeDxe driver's Reclaim() function calling

  //
  // Copy variable store header.
  //
  CopyMem (ValidBuffer, VariableStoreHeader, sizeof (VARIABLE_STORE_HEADER));


in edk2\MdeModulePkg\Universal\Variable\RuntimeDxe\Variable.c.

The code above copies 28 bytes of data from NOR flash memory region @0xBFC0048 using __memcpy() from

edk2\MdePkg\Library\BaseMemoryLibOptDxe\AArch64\CopyMem.S using unaligned memory accesses, causing Alignment fault for flash region which is mapped as device memory.


The fix involves switching to generic baseMemoryLib and for ArmJuno.dsc is listed below:


  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
    <LibraryClasses>
      NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
+     BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
  }


and is similar to the following commits for Hisilicon/D02/D03/D05:


Hisilicon/D02: flash related drivers switch to use generic BaseMemoryLib:

https://git.linaro.org/uefi/OpenPlatformPkg.git/commit/Platforms/Hisilicon/D02/Pv660D02.dsc?id=e3c520596d9ebdc525f284a9da95f080af815ec9


Hisilicon/D03: flash related drivers switch to use generic BaseMemoryLib:

https://git.linaro.org/uefi/OpenPlatformPkg.git/commit/Platforms/Hisilicon/D03/D03.dsc?id=337713801cceb684326bfde22975310ca1bd0cc0


Hisilicon/D05: flash related drivers switch to use generic BaseMemoryLib:

https://git.linaro.org/uefi/OpenPlatformPkg.git/commit/Platforms/Hisilicon/D05/D05.dsc?id=0749464022407f11c0c6a46cb8eb293fc74ef236


Alexei.



IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.