Commit Graph

725 Commits

Author SHA1 Message Date
Mikhail Krichanov bc70cc3d69 DefaultExceptionHandlerLib/AArch64: Added selection of the correct stack
for DEBUG printings.
2025-01-30 14:04:09 +03:00
Mikhail Krichanov 5c919d20d9 Ring3: Fixed memory leaks and passed UserArguments to CallBootService
through User stack for ARM, AARCH64.
2025-01-27 11:50:49 +03:00
Mikhail Krichanov 82c76dee94 Ring3: Saved ReturnSP on SysCallStack. 2025-01-20 19:45:00 +03:00
Mikhail Krichanov aeacf20255 Ring3: Fixed line endings. 2025-01-20 16:30:21 +03:00
Mikhail Krichanov 93625d5489 Ring3: Placed UnicodeCollation driver into User space. 2025-01-20 12:57:14 +03:00
Mikhail Krichanov efcbf1946d Ring3: Fixed line endings. 2025-01-10 18:14:00 +03:00
Mikhail Krichanov 645a92be16 ArmPkg: Fixed compilation. 2024-12-23 11:47:33 +03:00
Mikhail Krichanov 75c5b9e27e Ring3: Added support for ARM User page table. 2024-12-19 20:18:28 +03:00
Mikhail Krichanov d051ccdbe8 ArmPkg: Added CpuSetUserMemoryAttributes() for ARM. 2024-12-19 13:39:14 +03:00
Mikhail Krichanov 2f3c4c9dc6 Ring3: Added MakeUserPageTableTemplate() for ARM. 2024-12-19 13:24:32 +03:00
Mikhail Krichanov 7783942407 ArmPkg: Refactored SVC handling. 2024-12-17 15:33:48 +03:00
Mikhail Krichanov 241c5143b4 Ring3: Added support for AARCH64 User page table. 2024-12-16 18:10:18 +03:00
Mikhail Krichanov 458983559f ArmPkg: Added CpuSetUserMemoryAttributes() for AARCH64. 2024-12-09 17:32:37 +03:00
Mikhail Krichanov 6da370bc11 Ring3: Added MakeUserPageTableTemplate() for AARCH64. 2024-12-09 17:28:43 +03:00
Mikhail Krichanov c11185cb8c ArmPkg: Disabled UserSpace by default to fix CI,
as WinPE and Linux EFI stub can not boot in 
EL2&0 translation regime.
2024-10-22 13:18:11 +03:00
Mikhail Krichanov 6012848e12 Ring3: Added support for AARCH64 EL2&0 translation regime. 2024-10-21 17:51:52 +03:00
Mikhail Krichanov 32768e43f3 Ring3: Fixed PAN page faults. 2024-10-01 19:26:04 +03:00
Mikhail Krichanov 51e767463a ArmLib: Added Instruction Synchronization Barriers for PAN changes. 2024-10-01 13:54:44 +03:00
Mikhail Krichanov 2497ca5c32 Ring3: Fixed buggy timer interrupt handling for AARCH64. 2024-09-27 15:43:46 +03:00
Mikhail Krichanov e4c26e4957 ArmPkg/Library/CpuArchLib: Refactored ARM to UEFI attribute conversion. 2024-09-27 12:02:45 +03:00
Mikhail Krichanov 2700df080d ArmPkg: Forbade user access to supervisor sections. 2024-09-16 17:56:05 +03:00
Mikhail Krichanov 6d389121c8 ArmMmuLib: Worked around lack of EL2&0 translation support. 2024-09-13 14:40:24 +03:00
Mikhail Krichanov ab1bc54366 Ring3: Fixed ArmPkg and ArmVirtPkg compilation. 2024-09-03 13:24:22 +03:00
Mikhail Krichanov fc08f7d273 Ring3: Fixed several bugs for ARM. 2024-09-03 13:21:21 +03:00
Mikhail Krichanov bdea79e171 Ring3: Defined SysCallBootService() for ARM. 2024-09-03 13:21:21 +03:00
Mikhail Krichanov 618149a40d Ring3: Added EL0 support for ARM. 2024-09-03 13:21:21 +03:00
Mikhail Krichanov 54d7a130ec Ring3: Added PAN support for ARM. 2024-09-03 13:21:21 +03:00
Mikhail Krichanov c8ed0dc0c1 Ring3: Removed -mcpu=cortex-a76 option from tools_def.template. 2024-09-03 13:21:20 +03:00
Mikhail Krichanov 9bb63c464b Ring3: Refactored SysCallBootService() out of EFI_BOOT_SERVICES. 2024-09-03 13:21:20 +03:00
Mikhail Krichanov c5d244956e Ring3: Defined SysCallReturnToCore for AARCH64,
forbade ExceptionHanlders to use EL0 stack.
2024-09-03 13:21:20 +03:00
Mikhail Krichanov d03b93be3d Ring3: Defined SysCallBootService() for AARCH64. 2024-09-03 13:21:20 +03:00
Mikhail Krichanov 3fc05b0473 Ring3: Defined CallRing3() for AARCH64. 2024-09-03 13:21:19 +03:00
Mikhail Krichanov 04c34b8135 Ring3: Defined CpuGetMemoryAttributes(), DisableSMAP(), EnableSMAP() for AARCH64. 2024-09-03 13:21:19 +03:00
Mikhail Krichanov 6dc6cd62d4 Ring3: Added EL0 and PAN support for AARCH64. 2024-09-03 13:21:19 +03:00
Mikhail Krichanov 46050fc0fc SecurePE: Defined new PcdImageProtectionPolicy. 2024-07-22 13:49:00 +03:00
Mikhail Krichanov 028bb3e2c7 MdePkg/UefiImageLib: Introduce DebugAddress
Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
2024-07-22 13:49:00 +03:00
Mikhail Krichanov 5a8fe7214e MdePkg/UefiImageLib: Support multi-format and multi-source architecture
Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
2024-07-22 13:49:00 +03:00
Mikhail Krichanov 769c333a61 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>
2024-07-22 13:47:18 +03:00
Mikhail Krichanov 2ae98acd86 Drop support for the TE format 2024-07-22 13:47:18 +03:00
Marvin Häuser 584d13a2eb ArmPkg/ArmMmuLib: ASSERT ArmReplaceLiveTranslationEntry alignment 2024-07-22 13:47:18 +03:00
Mikhail Krichanov a955e8811b SecurePE: Replaced old PE loader with Secure one. 2024-07-22 13:42:14 +03:00
Mikhail Krichanov 80c73c3923 MdePkg: DebugLib: Compilation fix for clang-13
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3704

build -a X64 -t CLANG38 -b RELEASE -p OvmfPkg/OvmfPkgX64.dsc
results in
UDK/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c:1284:31:
error: variable 'Status' set but not used
[-Werror,-Wunused-but-set-variable]

Signed-off-by: Mikhail Krichanov <krichanov@ispras.ru>

MdePkg/DebugLib(PerformanceLib): Fix "unused-but-set-variable" warning

The current definitions of DEBUG_CODE_BEGIN() and DEBUG_CODE_END() use
the local
variable __DebugCodeLocal as an attempt to track parity. If
DEBUG_CODE_END() is
used without a preceding DEBUG_CODE_BEGIN(), __DebugCodeLocal will not
have been
declared and a compilation error will be issued. The mutations of the
variable
are not used to track nesting or such. As the value of this variable is
never
actually used, recent Clang versions issue a "unused-but-set-variable"
warning
for it.

To solve this, re-define __DebugCodeLocal as a BOOLEAN that is always
FALSE and
use it in a do-while loop condition as done explicitly in many places.
Like the
previous solution, DEBUG_CODE_END() cannot be used without
DEBUG_CODE_BEGIN(),
as __DebugCodeLocal will be not have been defined.

Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
2024-07-22 12:37:00 +03:00
Ard Biesheuvel 32460bb5b1 ArmPkg: Allow SMC/HVC monitor conduit to be specified at runtime
ArmVirtQemu may execute at EL2, in which case monitor calls are
generally made using SMC instructions instead of HVC instructions.

Whether or not this is the case can only be decided at runtime, and so
the associated PCD needs to be settable at runtime, if the platform
definition chooses so. This implies a boolean PCD, given that a feature
PCD is build-time configurable only.

Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>

Committed-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Doug Flick [MSFT] <doug.edk2@gmail.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
2024-05-24 15:48:52 +00:00
Ard Biesheuvel 7f5e75895b ArmPkg/DebugPeCoffExtraActionLib: Drop RVCT and Cygwin support
The DebugPeCoffExtraActionLib implemention in ArmPkg contains some cruft
that dates back to the original RVCT based ARM port, and support for
RVCT was dropped a while ago.

Also drop the handling of Cygwin specific paths, which is highly
unlikely to be still depended upon by anyone.

Tweak the logic so that only two versions of the DEBUG() invocations
remain: one for __GNUC__ when PdbPointer is set, and the fallback that
just prints the image address and the address of the entrypoint.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2023-12-14 16:29:17 +00:00
Michael Kubacki d451bba399 ArmPkg/ArmMmuLib: Use function pointer type
mReplaceLiveEntryFunc is a function pointer but assigned as a VOID*
pointer:

  mReplaceLiveEntryFunc = *(VOID **)GET_GUID_HOB_DATA (Hob);

This leads to the Visual Studio warning:

  nonstandard extension, function/data pointer conversion in
  expression

This change updates the assignment to avoid using a data pointer and
defines a type for the function pointer to succinctly and accurately
refer to the type when it is used in the library code.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
2023-11-28 10:12:29 +00:00
Sami Mujawar a671a14e63 ArmPkg/ArmLib: Add ArmHasEte () helper function
Create a helper function to query whether ID_AA64MFR1_EL1 indicates
presence of the Embedded Trace Extension (ETE). This feature is only
visible in AARCH64 state.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Pierre Gondois <pierre.gondois@arm.com>
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
2023-10-30 12:16:56 +00:00
Sami Mujawar 08431081a3 ArmPkg/ArmLib: Add ArmHasTrbe () helper function
Create a helper function to query whether ID_AA64MFR1_EL1 indicates
presence of the Trace Buffer Extension (TRBE). This feature is only
visible in AARCH64 state.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Pierre Gondois <pierre.gondois@arm.com>
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
2023-10-30 12:16:56 +00:00
Leif Lindholm 89dad77cfb ArmPkg/ArmLib: Add ArmHasVhe () helper function
Create a helper function to query whether ID_AA64MFR1_EL1 indicates
presence of the Virtualization Host Extensions. This feature is only
visible in AARCH64 state.

Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Tested-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
2023-09-20 14:52:07 +00:00
Ard Biesheuvel 4f4a2c3b07 ArmPkg/ArmMmuLib: Drop buggy secure memory type check
Jake reports that the IS_ARM_MEMORY_REGION_ATTRIBUTES_SECURE() macro is
no longer accurate since commit 852227a9d5 ("ArmPkg/Mmu: Remove
handling of NONSECURE memory regions").

Fortunately, it only affects the NS bit in level 1 short descriptors,
which is ignored when executing in non-secure mode. And given that
running UEFI in the secure world is not a use case we aim to support,
let's just drop this logic altogether.

Reported-by: Jake Garver <jake@nvidia.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
2023-09-12 10:20:27 +00:00
Oliver Smith-Denny ef05145136 ArmPkg: DefaultExceptionHandlerLib: Do Not Allocate Memory
If gST->ConOut is available when Arm's DefaultExceptionHandler is
running, AsciiPrint will get called to attempt to print to ConOut, in
addition to the serial output.

AsciiPrint calls AsciiInternalPrint in UefiLibPrint.c which in turn
calls AllocatePool to allocate a buffer to convert the Ascii input
string to a Unicode string to pass to ConOut->OutputString.

Per the comment on DefaultExceptionHandler, we should not be allocating
memory in the exception handler, as this can cause the exception handler
to fail if we had a memory exception or the system state is such that we
cannot allocate memory.

It has been observed on ArmVirtQemu that exceptions generated in the
memory handling code will fail to output the stack dump and CPU state
that is critical to debugging because the AllocatePool will fail.

This patch fixes the Arm and AARCH64 DefaultExceptionHandlers to not
allocate memory when ConOut is available and instead use stack memory to
convert the Ascii string needed for SerialPortWrite to the Unicode
string needed for ConOut->OutputString. Correspondingly, ArmVirtQemu can
now output the stack dump and CPU state when hitting an exception in
memory code.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
2023-08-03 14:43:08 +00:00