772 Commits

Author SHA1 Message Date
Mikhail Krichanov
d8204d9779 UserSpace: Fixed compilation after rebasing upon edk2-stable202502 tag. 2025-04-14 21:58:57 +03:00
Mikhail Krichanov
36b11d3852 DefaultExceptionHandlerLib/AArch64: Added selection of the correct stack
for DEBUG printings.
2025-04-14 13:14:52 +03:00
Mikhail Krichanov
d20d45ae9b Ring3: Fixed memory leaks and passed UserArguments to CallBootService
through User stack for ARM, AARCH64.
2025-04-14 13:12:14 +03:00
Mikhail Krichanov
213713f790 Ring3: Saved ReturnSP on SysCallStack. 2025-04-14 13:12:14 +03:00
Mikhail Krichanov
a37ef161b6 Ring3: Fixed line endings. 2025-04-14 13:12:14 +03:00
Mikhail Krichanov
f532beefbd Ring3: Placed UnicodeCollation driver into User space. 2025-04-14 13:12:14 +03:00
Mikhail Krichanov
7a0bb88360 Ring3: Fixed line endings. 2025-04-14 13:06:18 +03:00
Mikhail Krichanov
56d7030ede ArmPkg: Fixed compilation. 2025-04-14 13:05:05 +03:00
Mikhail Krichanov
f4244d8d44 Ring3: Added support for ARM User page table. 2025-04-14 13:05:05 +03:00
Mikhail Krichanov
1c10e31d45 ArmPkg: Added CpuSetUserMemoryAttributes() for ARM. 2025-04-14 13:05:05 +03:00
Mikhail Krichanov
b739cbd2b5 Ring3: Added MakeUserPageTableTemplate() for ARM. 2025-04-14 13:05:05 +03:00
Mikhail Krichanov
6a09c07791 ArmPkg: Refactored SVC handling. 2025-04-14 13:05:05 +03:00
Mikhail Krichanov
2ca7937d11 Ring3: Added support for AARCH64 User page table. 2025-04-14 13:05:02 +03:00
Mikhail Krichanov
5194b674c2 ArmPkg: Added CpuSetUserMemoryAttributes() for AARCH64. 2025-04-14 13:00:53 +03:00
Mikhail Krichanov
2a0b76c4b9 Ring3: Added MakeUserPageTableTemplate() for AARCH64. 2025-04-14 13:00:53 +03:00
Mikhail Krichanov
5fee574a51 ArmPkg: Disabled UserSpace by default to fix CI,
as WinPE and Linux EFI stub can not boot in
EL2&0 translation regime.
2025-04-14 12:48:31 +03:00
Mikhail Krichanov
a071d15784 Ring3: Added support for AARCH64 EL2&0 translation regime. 2025-04-14 12:38:38 +03:00
Mikhail Krichanov
97371df2b6 Ring3: Fixed PAN page faults. 2025-04-14 12:15:43 +03:00
Mikhail Krichanov
4968eac71c ArmLib: Added Instruction Synchronization Barriers for PAN changes. 2025-04-14 12:12:47 +03:00
Mikhail Krichanov
48f5f4f667 Ring3: Fixed buggy timer interrupt handling for AARCH64. 2025-04-14 12:12:47 +03:00
Mikhail Krichanov
b986642b37 ArmPkg/Library/CpuArchLib: Refactored ARM to UEFI attribute conversion. 2025-04-14 12:12:47 +03:00
Mikhail Krichanov
1e5fbf7b87 ArmPkg: Forbade user access to supervisor sections. 2025-04-14 12:12:47 +03:00
Mikhail Krichanov
116f43d49c ArmMmuLib: Worked around lack of EL2&0 translation support. 2025-04-14 12:12:47 +03:00
Mikhail Krichanov
7f308c22c5 Ring3: Fixed ArmPkg and ArmVirtPkg compilation. 2025-04-14 12:12:47 +03:00
Mikhail Krichanov
6b814aff5c Ring3: Fixed several bugs for ARM. 2025-04-14 12:09:42 +03:00
Mikhail Krichanov
76f2ff7259 Ring3: Defined SysCallBootService() for ARM. 2025-04-14 12:09:40 +03:00
Mikhail Krichanov
83fa7ac1d3 Ring3: Added EL0 support for ARM. 2025-04-14 12:07:09 +03:00
Mikhail Krichanov
51824c3409 Ring3: Added PAN support for ARM. 2025-04-14 12:07:06 +03:00
Mikhail Krichanov
ad5f4944d6 Ring3: Removed -mcpu=cortex-a76 option from tools_def.template. 2025-04-14 11:54:25 +03:00
Mikhail Krichanov
8104e4543c Ring3: Refactored SysCallBootService() out of EFI_BOOT_SERVICES. 2025-04-14 11:52:51 +03:00
Mikhail Krichanov
f8c379de5f Ring3: Defined SysCallReturnToCore for AARCH64,
forbade ExceptionHanlders to use EL0 stack.
2025-04-14 11:52:51 +03:00
Mikhail Krichanov
393298742c Ring3: Defined SysCallBootService() for AARCH64. 2025-04-14 11:52:48 +03:00
Mikhail Krichanov
e40c47a69c Ring3: Defined CallRing3() for AARCH64. 2025-04-14 11:49:21 +03:00
Mikhail Krichanov
9059d7330a Ring3: Defined CpuGetMemoryAttributes(), DisableSMAP(), EnableSMAP() for AARCH64. 2025-04-14 11:49:21 +03:00
Mikhail Krichanov
57eb712768 Ring3: Added EL0 and PAN support for AARCH64. 2025-04-14 11:49:18 +03:00
Mikhail Krichanov
992385e15e SecurePE: Defined new PcdImageProtectionPolicy. 2025-04-07 12:30:28 +03:00
Mikhail Krichanov
1fef202932 MdePkg/UefiImageLib: Introduce DebugAddress
Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
2025-04-07 12:24:27 +03:00
Mikhail Krichanov
e46d356fc9 MdePkg/UefiImageLib: Support multi-format and multi-source architecture
Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
2025-04-07 12:24:27 +03:00
Mikhail Krichanov
20dd836214 MdeModulePkg/Core/Dxe: Integrate CPU Architectural producer
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3223

In the current design, memory protection is not available till CpuDxe
is loaded. To resolve this, introduce CpuArchLib to move the
CPU Architectural initialization to DxeCore.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Vitaly Cheptsov <vit9696@protonmail.com>
Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
2025-04-07 12:23:28 +03:00
Mikhail Krichanov
bc87d7b430 Drop support for the TE format 2025-04-07 12:18:22 +03:00
Marvin Häuser
9e2b1a158f ArmPkg/ArmMmuLib: ASSERT ArmReplaceLiveTranslationEntry alignment 2025-04-07 12:18:22 +03:00
Mikhail Krichanov
09a0c067d0 SecurePE: Replaced old PE loader with Secure one. 2025-04-07 12:12:35 +03:00
Kun Qin
523dbb6d59 ArmPkg: ArmFfaStandaloneMmLib: Fix non-FFA path
ArmFfaLibCommonInit will return EFI_UNSUPPORTED when there is no FFA
supported on the platform. This is expected behavior. However, the return
of error code will incur program asserts.

This change fixed the non-FFA path for the Standalone MM instance.

Signed-off-by: Kun Qin <kun.qin@microsoft.com>
2025-02-11 21:21:40 +00:00
Oliver Smith-Denny
efbf5ed08c MdePkg: Move StackCheckLibStaticInit to StackCheckLib
This commit oves StackCheckLib from a NULL lib to an instance of
StackCheckLib. This requires every entry point to add a library
dependency on StackCheckLib. It also requires every SEC module
to have a dependency on StackCheckLib because there is no
standard SEC entry point.

It allows for greater flexibility for a platform to apply stack
cookies and simplifies DSC logic.

Continuous-integration-options: PatchCheck.ignore-multi-package

Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2025-02-07 02:23:11 +00:00
Ard Biesheuvel
62cd7d338b ArmPkg: Retire ArmDisassemblerLib
No longer used anywhere so can be retired.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2025-01-31 13:50:45 +00:00
Ard Biesheuvel
ef80dd8fad ArmPkg: Stop using ArmDisassemblerLib
ArmDisassemblerLib is used to pretty print the instruction that
triggered an unhandled exception, but it was never implemented for
AARCH64, and according to the existing file comment, Thumb2 support
(which is used predominantly when building EDK2 for 32-bit ARM due to
its smaller size) is incomplete.

The DEBUG diagnostics that are produced on an unhandled exception are
generally sufficient to dump the entire executable that triggered it,
and so this disassembly is of limited value, especially because it
doesn't work on AARCH64.

So let's start getting rid of it, by dropping references to it in code
and in the various .INF and .DSC files. Once out-of-tree platforms have
been allowed to catch up, we can remove the library implementation and
its class definition entirely.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2025-01-30 16:01:56 +00:00
Leif Lindholm
74376f0b72 ArmPkg,ArmPkg/ArmExceptionLib: drop vector relocation variant/support
There were several bugs in the vector table relocation code which means
it can't really have been used by anyone on AArch64 in the last decade or
so. So delete the support code from the library, as well as the
ArmRelocateExceptionLib.inf file.

This gets rid of PcdDebuggerExceptionSupport (including a duff reference
in CpuDxe), PcdCpuVectorBaseAddress and PcdRelocateVectorTable.

Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
2025-01-30 15:09:09 +00:00
Ard Biesheuvel
eaa60a6b10 ArmPkg/ArmGic: Retire ArmGicArchLib
ArmGicArchLib is no longer use so remove all remaining references and
implementations.

Continuous-integration-options: PatchCheck.ignore-multi-package

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2025-01-17 18:37:27 +00:00
Levi Yun
f0c87b9ef4 StandaloneMmPkg: move core entry point lib and cpu driver to ArmPkg
StandaloneMmCpu driver is only used for Arm architecture and
StandaloneMmCoreEntryPointLib for Arm has specific implementation with
StandaloneMmCpu driver.

Move StandaloneMmCpu Driver and StandaloneMmCoreEntryPointLib for Arm
to ArmPkg.

Continuous-integration-options: PatchCheck.ignore-multi-package
Signed-off-by: Levi Yun <yeoreum.yun@arm.com>
2025-01-17 14:55:42 +00:00
Levi Yun
4ca452cf91 ArmPkg/Library: Update StandaloneMmuLib with FF-A v1.2 with page granulirty
The StandaloneMm implementation for Arm sets up the stack in
the early startup code using the data section reserved in the
assembly code.

When TF-A loads the StandaloneMM binary in the DRAM it maps
the entire StandaloneMM memory region as Read Only.

Therefore, the initial startup assembly code updates the mem
permissions of the stack region to Read Write.

However, when the StandaloneMmCore is loaded the function
UpdateMmFoundationPeCoffPermissions() starts applying the
memory permissions based on the PE COFF sections as below:

A. If the section is not executable, it first removes the
executable permission of the section by calling TextUpdate().
TextUpdate() is the StandaloneMM MMU library function
ArmSetMemoryRegionNoExec().

B. It then checks if the section is writable, and if it is
it calls ReadWriteUpdater(), which invokes the StandaloneMM
MMU library function ArmClearMemoryRegionReadOnly() to make
the section writable.

However, this results in the stack being made read-only
between A and B. To understand this please see the following
flow.

1. TF-A sets the entire StandaloneMM region as Read Only.
2. The stack is reserved in the data section by the early
   assembly entry point code.
    +--------------------+   <--- Start of Data Section
    |                    |
    |  Data Section      |
    |                    |
    | +----------------+ |   <--- Stack region
    | |   Stack        | |
    | +----------------+ |
    |                    |
    +--------------------+

3. The StanaloneMM early entry point code updates the
   attributes of the stack to Read Write.
4. When UpdateMmFoundationPeCoffPermissions() sets the
   permission of the data section to remove the Execute
   attribute, it calls ArmSetMemoryRegionNoExec().
5. The ArmSetMemoryRegionNoExec() implementation gets the
   attributes of the first granule which is at the start
   of the data section, then clears the execute permission
   and applies the attribute for the entire data section.
6. Since TF-A has mapped the entire section as read only
   the first granule of the data section is read only and
   therefore the stack region attributes are changed to
   Read Only no execute.
7. Since the stack is read only after point A any updates
   to the stack result in an exception.

To resolve this issue with update the library with FF-A v1.2,
get/set memory permission per page unit.

Links: https://developer.arm.com/documentation/den0140/latest/ [0]
Signed-off-by: Levi Yun <yeoreum.yun@arm.com>
2025-01-17 14:55:42 +00:00