[edk2,edk2-platforms,4/7] Silicon/SynQuacer/Fip006Dxe: use proper accessor for unaligned access

Message ID 20190104144336.8941-5-ard.biesheuvel@linaro.org
State New
Headers show
Series
  • Silicon/SynQuacer: implement SMM based secure boot
Related show

Commit Message

Ard Biesheuvel Jan. 4, 2019, 2:43 p.m.
This code may execute in SMM context, where unaligned accesses are
not permitted. So use ReadUnaligned32() instead of performing a
direct UINT32* cast.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

---
 Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.17.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Patch

diff --git a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlash.c b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlash.c
index 2134739bfba9..d45c8d9b35d2 100644
--- a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlash.c
+++ b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlash.c
@@ -841,7 +841,7 @@  NorFlashWriteSingleBlock (
                    BlockSize);
 
       // The word of data that is to be written.
-      TmpBuf = *((UINT32*)(Buffer + (*NumBytes - BytesToWrite)));
+      TmpBuf = ReadUnaligned32 ((UINT32 *)(Buffer + (*NumBytes - BytesToWrite)));
 
       // First do word aligned chunks.
       if ((CurOffset & 0x3) == 0) {