Skip to content
This repository was archived by the owner on Mar 28, 2025. It is now read-only.

Commit 13b62c5

Browse files
chuongtranlenhivp
authored andcommitted
AmpereAltraPkg: Fix OS kernel crash if not call SetVirtualAddressMap()
OS kernel avoided SetVirtualAddressMap() on arm64 due to commit d3549a93 ("efi/arm64: libstub: avoid SetVirtualAddressMap() when possible"). Currently, RuntimeFlashLib in AmpereAltraPkg relies on function call SetVirtualAddressMap() to determine whether it is in boot time or run-time. At boot time, the code optimizes to avoid the use of temporary buffer because the virtual address and physical address are identical. If SetVirtualAddressMap() isn't called, it does not know when to switch. As such, don't do that optimization and the physical address is always known. Signed-off-by: Chuong Tran <chuong@os.amperecomputing.com>
1 parent 87e2414 commit 13b62c5

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

Silicon/Ampere/AmpereAltraPkg/Library/FlashLib/FlashLibCommon.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
#define UEFI_MISC_SIZE 0x1000
1919

20-
BOOLEAN gFlashLibRuntime = FALSE;
2120
UINT8 *gFlashLibPhysicalBuffer;
2221
UINT8 *gFlashLibVirtualBuffer;
2322

@@ -36,13 +35,9 @@ ConvertToPhysicalBuffer (
3635
IN UINT32 Size
3736
)
3837
{
39-
if (gFlashLibRuntime) {
40-
ASSERT (VirtualPtr != NULL);
41-
CopyMem (gFlashLibVirtualBuffer, VirtualPtr, Size);
42-
return gFlashLibPhysicalBuffer;
43-
}
44-
45-
return VirtualPtr;
38+
ASSERT (VirtualPtr != NULL);
39+
CopyMem (gFlashLibVirtualBuffer, VirtualPtr, Size);
40+
return gFlashLibPhysicalBuffer;
4641
}
4742

4843
/**

Silicon/Ampere/AmpereAltraPkg/Library/FlashLib/RuntimeFlashLib.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ FlashLibAddressChangeEvent (
3535
{
3636
gRT->ConvertPointer (0x0, (VOID **)&gFlashLibVirtualBuffer);
3737
gRT->ConvertPointer (0x0, (VOID **)&mMmCommunicationProtocol);
38-
39-
gFlashLibRuntime = TRUE;
4038
}
4139

4240
/**

0 commit comments

Comments
 (0)