Skip to content

Commit

Permalink
SysCall: Fixed page fault for ARM.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Krichanov committed Sep 25, 2024
1 parent 0dd56c8 commit 760614b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
17 changes: 13 additions & 4 deletions MdeModulePkg/Core/Dxe/SysCall/ARM/InitializeMsr.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "DxeMain.h"

STATIC UINTN mCoreSp;
extern UINTN gUartBaseAddress;

EFI_STATUS
EFIAPI
Expand Down Expand Up @@ -64,6 +65,12 @@ SysCallBootService (
// All remaining arguments are on User Stack.
//
CopyMem ((VOID *)((UINTN)Physical + 5 * sizeof (UINTN)), (VOID *)UserRsp, 4 * sizeof (UINTN));

SetUefiImageMemoryAttributes (
gUartBaseAddress,
EFI_PAGE_SIZE,
EFI_MEMORY_XP
);
ForbidSupervisorAccessToUserMemory ();

Status = CallBootService (
Expand All @@ -72,6 +79,12 @@ SysCallBootService (
(RING3_STACK *)(UINTN)Physical
);

SetUefiImageMemoryAttributes (
gUartBaseAddress,
EFI_PAGE_SIZE,
EFI_MEMORY_XP | EFI_MEMORY_USER
);

CoreFreePages (Physical, EFI_SIZE_TO_PAGES (9 * sizeof (UINTN)));

return Status;
Expand All @@ -84,10 +97,6 @@ InitializeMsr (
IN UINTN NumberOfEntries
)
{
//
// TODO: EFI_CONFIGURATION_TABLE, HOB_DATA, Uart are accessible to User.
// Fix PageTable initialization.
//
if (ArmHasPan ()) {
//
// Enable Privileged Access Never feature.
Expand Down
6 changes: 3 additions & 3 deletions MdeModulePkg/Core/Dxe/SysCall/SupportedProtocols.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ EFI_FILE_PROTOCOL mRing3FileProtocol;

EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *mRing3SimpleFileSystemPointer;

#if defined (MDE_CPU_AARCH64)
#if defined (MDE_CPU_AARCH64) || defined (MDE_CPU_ARM)
extern UINTN gUartBaseAddress;
#endif

Expand Down Expand Up @@ -73,7 +73,7 @@ GoToRing3 (
EFI_MEMORY_XP | EFI_MEMORY_USER
);
}
#elif defined (MDE_CPU_AARCH64)
#elif defined (MDE_CPU_AARCH64) || defined (MDE_CPU_ARM)
//
// Necessary fix for DEBUG printings.
//
Expand All @@ -93,7 +93,7 @@ GoToRing3 (
EFI_MEMORY_XP
);
}
#elif defined (MDE_CPU_AARCH64)
#elif defined (MDE_CPU_AARCH64) || defined (MDE_CPU_ARM)
//
// Problem 2: Uart memory maped page is not allocated at the very beginnig
// and can be used for translation table later.
Expand Down

0 comments on commit 760614b

Please sign in to comment.