Skip to content

Commit

Permalink
Ring3: Fixed LibraryConstructors' initialization and
Browse files Browse the repository at this point in the history
allowed user to access ports.
  • Loading branch information
Mikhail Krichanov committed Jan 18, 2024
1 parent d2e5746 commit cff574f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions MdeModulePkg/Core/Dxe/DxeMain.inf
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdImageLargeAddressLoad ## CONSUMES
gEfiMdePkgTokenSpaceGuid.PcdDebugRaisePropertyMask ## CONSUMES
gEfiMdePkgTokenSpaceGuid.PcdImageProtectionPolicy ## CONSUMES
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase ## CONSUMES
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaSize ## CONSUMES

# [Hob]
# RESOURCE_DESCRIPTOR ## CONSUMES
Expand Down
9 changes: 9 additions & 0 deletions MdeModulePkg/Core/Dxe/Image/Image.c
Original file line number Diff line number Diff line change
Expand Up @@ -1714,6 +1714,15 @@ CoreStartImage (
TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
// DEBUG ((DEBUG_ERROR, "RING3_CODE64_SEL = 0x%x RING3_DATA64_SEL = 0x%x\n", (UINT16)RING3_CODE64_SEL, (UINT16)RING3_DATA64_SEL));

//
// Necessary fix for ProcessLibraryConstructorList() -> DxeCcProbeLibConstructor()
//
SetUefiImageMemoryAttributes (
FixedPcdGet32 (PcdOvmfWorkAreaBase),
FixedPcdGet32 (PcdOvmfWorkAreaSize),
EFI_MEMORY_XP | EFI_MEMORY_USER
);

EnterUserImage (
(SWITCH_STACK_ENTRY_POINT)(UINTN)Image->EntryPoint,
ImageHandle,
Expand Down
4 changes: 4 additions & 0 deletions MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,10 @@ CreateIdentityMappingPageTables (

Eflags.UintN = AsmReadEflags ();
Eflags.Bits.AC = 0;
//
// Allow user image to access ports.
//
Eflags.Bits.IOPL = 3;
AsmWriteEflags (Eflags.UintN);
}

Expand Down

0 comments on commit cff574f

Please sign in to comment.