Commit Graph
34 Commits
Author SHA1 Message Date
Yeoreum Yunandmergify[bot] d0da872d96 MdeModulePkg/ArmFfaLib: return error when CurrentVersion is NULL
Output parameter CurrentVersion of ArmFfaLibGetVersion() is
not optional parameter. That means it should return error
when CurrentVersion is NULL.

Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
2026-05-29 18:44:57 +00:00
Shenghu Liuandmergify[bot] 7f0fd11273 MdeModulePkg/ArmFfaLib: Fix VM ID handling for RX release and RXTX unmap
According to the FFA specification, when FFA_RX_RELEASE or
FFA_RXTX_UNMAP is invoked from UEFI as a non-secure virtual instance,
the w1 register must be zero (MBZ). Supplying a non-zero value causes the
SPMC to return FFA_INVALID_PARAMETER.

When these interfaces are invoked from UEFI as a non-secure physical
instance, FFA_ID_GET always returns a VM ID of zero. Therefore,
providing a non-zero VM ID in this context is unnecessary and may be
invalid.

Update ArmFfaLib to always set w1 (VM ID / partition ID) to zero when
invoking FFA_RX_RELEASE and FFA_RXTX_UNMAP, ensuring compliance with
the FFA specification.

Signed-off-by: Shenghu Liu <shenghul@qti.qualcomm.com>
2026-05-28 23:51:09 +00:00
Yeoreum YunandArd Biesheuvel ae2d2d76c1 ArmPkg,MdePkg,MdeModulePkg: change ArmFfaLibGetVersion() with whole version
Current ArmFfaLibGetVersion()'s arguments receive two arguments
-- major version and minor version.

However, This gives some impression treating major and minor version
of the ABI as two unrelated 16-bit variables as opposed to
the upper and lower 16-bits of a 32-bit version variable.

Therefore, change the arguments with whole version and
let user to get major/minor version via ARM_FFA_MAJOR/MINOR_VERSION_GET
macros.

Also, add some useful helper to check version compatibility and
mimimum require ABI version.

Continuous-integration-options: PatchCheck.ignore-multi-package
Suggested-by: Leif Lindholm <quic_llindhol@quicinc.com>
Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
2026-04-28 19:19:44 +02:00
Yeoreum Yunandmergify[bot] 87cfc60f20 MdeModulePkg/Library: ArmFfaLib: add mapping ARM_FFA_RET_RETRY
There is no mapping ARM_FFA_RET_RETRY with EFI_STATUS but
it falls to EFI_UNSUPPORTED.

Map ARM_FFA_RET_RETRY with EFI_TIMEOUT so that don't make it fall to
EFI_UNSUPPORTED.

Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
2026-04-23 08:22:22 +00:00
Mike Beatonandmergify[bot] 1f5c9f2a5c MdeModulePkg: Add library class SafeIntLib where ArmFfaCommon.c is used
Required by implementation of ArmFfaLibYield.

Fixes: 6479778e6b

Signed-off-by: Mike Beaton <mjsbeaton@gmail.com>
2026-03-09 03:35:31 +00:00
Raymond-MSandmergify[bot] 6479778e6b MdePkg,MdeModulePkg: Add FFA_YIELD command
Add the FF-A YIELD command to the FF-A library.
Continuous-integration-options: PatchCheck.ignore-multi-package

Signed-off-by: Raymond Diaz <raymonddiaz@microsoft.com>
2026-03-07 09:34:09 +00:00
rdiazandmergify[bot] a39c3835aa MdeModulePkg: Add FFA_NS_RES_INFO_GET to ArmFfaCommon
Add FFA_NS_RES_INFO_GET implementation to ArmFfaCommon

Signed-off-by: Raymond Diaz <raymonddiaz@microsoft.com>
2026-03-04 01:22:07 +00:00
Michael Kubackiandmergify[bot] 7a934d0bef MdeModulePkg: Replace include guards with #pragma once
Replace traditional `#ifndef`/`#define`/`#endif` include guards with
`#pragma` once.

`#pragma once` is a widely supported preprocessor directive that
prevents header files from being included multiple times. It is
supported by all toolchains used to build edk2: GCC, Clang/LLVM, and
MSVC.

Compared to macro-based include guards, `#pragma once`:

- Eliminates the risk of macro name collisions or copy/paste errors
  where two headers inadvertently use the same guard macro.
- Eliminate inconsistency in the way include guard macros are named
  (e.g., some files use `__FILE_H__`, others use `FILE_H_`, etc.).
- Reduces boilerplate (three lines replaced by one).
- Avoids polluting the macro namespace with guard symbols.
- Can improve build times as the preprocessor can skip re-opening the
  file entirely, rather than re-reading it to find the matching
  `#endif` ("multiple-include optimization").
  - Note that some compilers may already optimize traditional include
    guards, by recognzining the idiomatic pattern.

This change is made acknowledging that overall portability of the
code will technically be reduced, as `#pragma once` is not part of the
C/C++ standards.

However, this is considered acceptable given:

1. edk2 already defines a subset of supported compilers in
   BaseTools/Conf/tools_def.template, all of which have supported
   `#pragma once` for over two decades.
2. There have been concerns raised to the project about inconsistent
   include guard naming and potential macro collisions.

Approximate compiler support dates:

- MSVC: Supported since Visual C++ 4.2 (1996)
- GCC: Supported since 3.4 (2004)
  (http://gnu.ist.utl.pt/software/gcc/gcc-3.4/changes.html)
- Clang (LLVM based): Since initial release in 2007

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2026-02-23 21:01:28 +00:00
rdiazandmergify[bot] b7a715f7c0 MdeModulePkg: Add Unmap Callback
Add Unmap callback for when PEI and SEC need to invalidate the
Rx/Tx buffer HOB on a call to Unmap.

Signed-off-by: Raymond Diaz <raymonddiaz@microsoft.com>
2026-02-13 11:55:46 +00:00
rdiazandmergify[bot] 0e8dc1693d MdeModulePkg: Code/Comment cleanup
Cleaned various comments and debug messages as well as
headers to either fix typos or for readability.

Signed-off-by: Raymond Diaz <raymonddiaz@microsoft.com>
2026-02-13 11:55:46 +00:00
rdiazandmergify[bot] 3457388b7c MdeModulePkg: Use EFI_PAGES_TO_SIZE macro in ArmFfaSecRxTxMap
Replaced all instances of PcdGet64 (PcdFfaTxRxPageCount) *
EFI_PAGE_SIZE, with EFI_PAGES_TO_SIZE macro.

Signed-off-by: Raymond Diaz <raymonddiaz@microsoft.com>
2026-02-13 11:55:46 +00:00
rdiazandmergify[bot] ea8447eec7 MdeModulePkg: Remove global usage from ArmFfaSecRxTxMap
Removed the global variables in ArmFfaSecRxTxMap. Rx/Tx
buffer HOB is now created within the Map function rather
than in the constructor of ArmFfaSecLib. This allows for
the use of the HOB to find the Rx/Tx buffer information.

Signed-off-by: Raymond Diaz <raymonddiaz@microsoft.com>
2026-02-13 11:55:46 +00:00
rdiazandmergify[bot] 7416ebda09 MdeModulePkg: Remove global usage in ArmFfaCommon
Removed global variables in ArmFfaCommon. Moved the globals to
locals in each phase's ArmFfaLib implementation. SEC and PEI
will query when necessary to avoid setting globals when memory
is unavailable.

Signed-off-by: Raymond Diaz <raymonddiaz@microsoft.com>
2026-02-13 11:55:46 +00:00
rdiazandmergify[bot] 16d9ba7275 MdeModulePkg: Add helper to check if FF-A is supported
Added ArmFfaLibIsFfaSupported to ArmFfaCommon to allow for
queries of FF-A support outside of ArmFfaCommonInit.

Signed-off-by: Raymond Diaz <raymonddiaz@microsoft.com>
2026-02-13 11:55:46 +00:00
Levi Yunandmergify[bot] c16f1cc684 MdePkg,MdeModulePkg/ArmFfaLib: introduce ArmFfaGetPartitionInfo()
Introduce ArmFfaGetPartitionInfo(), which retrieves the first partition
associated with the service GUID. This allows us to remove duplicated
code previously used to obtain the partition ID.

Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
Continuous-integration-options: PatchCheck.ignore-multi-package
2026-01-08 12:07:46 +00:00
Levi Yunandmergify[bot] 898ae481d9 MdeModulePkg/ArmFfaLib: support ArmFfaLib wihtout Rx/Tx buffer
In the normal world, it is possible to communicate with
a secure partition using the ARM_FFA_PARTITION_INFO_GET_REGS ABI,
even when the Rx/Tx buffer ABI is not supported.

Therefore, treat the EFI_UNSUPPORTED error returned
during Rx/Tx buffer mapping as a valid result
when the ARM_FFA_PARTITION_INFO_GET_REGS ABI is supported.

Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
2026-01-08 12:07:46 +00:00
Levi Yunandmergify[bot] eea64c7fcd MdePkg, MdeModulePkg/ArmFfaLib: add funcs to get partition info via regs
Starting from FF-A v1.2 [0], the FFA_PARTITION_INFO_GET_REGS
interface was added to retrieve partition information
through registers.

This ABI is useful in environments where the Rx/Tx buffer
does not need to be mapped, or where buffer mapping
is not supported for retrieving partition information.

To support this, two new APIs are introduced:
ArmFfaLibPartitionInfoGetRegs() and ArmFfaLibPartitionCountGetRegs().

Link: https://developer.arm.com/documentation/den0077/latest [0]
Continuous-integration-options: PatchCheck.ignore-multi-package
Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
2026-01-08 12:07:46 +00:00
kuqin12andmergify[bot] 94065db3dc MdeModulePkg: ArmFfaLib: Add FFA_YIELD handling
If a secure partition on AArch64 platforms would consume extended time
to operate with peripherals, it might elect to yield the control back to
normal world and expect the normal world to callback after hinted period
of time.

This change adds the FFA_YIELD handling from ArmFfaLib to support long
operations from secure partitions. Timeout arguments are ignored because
systems in this context cannot benefit from the timeout period. Treating
FFA_YIELD like FFA_INTERRUPT and expecting the caller to invoke FFA_RUN
is the least disruptive approach while achieving the intended behavior.

This was tested on proprietary hardware platforms and booted to Windows.

Signed-off-by: Kun Qin <kun.qin@microsoft.com>
2025-10-31 07:26:12 +00:00
Michael Kubackiandmergify[bot] 282a324bf4 MdeModulePkg/ArmFfaLib: Add MemoryAllocationLib
ArmFfaRxTxMap.c is built by both ArmFfaPeiLib and ArmFfaDxeLib.

ArmFfaSecRxTxMap.c is built by ArmFfaSecLib.

ArmFfaStandaloneMmRxTxMap.c is built by ArmFfaStandaloneMm*Lib.

The files depend on `MemoryAllocationLib` APIs such as
`AllocateAlignedPages()`. This change adds `MemoryAllocationLib` to
those library INF files.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2025-09-12 07:31:53 +00:00
Michael Kubackiandmergify[bot] 2558af552d MdeModulePkg/ArmFfaLib: Add HobLib to StMm instances
ArmFfaCommon.c is built by both ArmFfaStandaloneMmCoreLib and
ArmFfaStandaloneMmLib. It links against HobLiib APIs such as
`GetFirstHob()`. Right now, the symbols fail to link:

```
lld-link: error: undefined symbol: GetFirstHob
          ArmFfaStandaloneMmCoreLib.lib(ArmFfaCommon.obj)
```

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2025-09-12 07:31:53 +00:00
Levi YunandArd Biesheuvel d7832b4800 MdeModulePkg: consider UNSUPPORTED return as valid in ArmFfaStandaloneMmLib
commit b534cabbda ("ArmFfaLib: Add Rx/Tx support for Stmm secure partition")
makes ArmFfaStandlaoneMm(Core)Lib map Rx/Tx buffer in its constructor.

This makes a failure of loading StandaloneMm in legacy platform
which doesn't implements Rx/Tx buffer related API since it doesn't need to.

StandaloneMm could be only service provider not cosumer in some platform
where doesn't need to map RxTx buffer.
Therefore, Considier EFI_UNSUPPORTED return in ArmFfaStandaloneMmLib's
constructor.

Fixes: b534cabbda ("ArmFfaLib: Add Rx/Tx support for Stmm secure partition")
Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
2025-09-09 01:09:48 +10:00
Levi Yunandmergify[bot] d8e875e625 Global: fix ArmFfaLibRun() caller couldn't get ret-args
When ArmFfaLibDirectMsgReq(2) is preempted, caller of these functions
should resume it works via ArmFfaLibRun() and the secure partition
will be return with FFA_DIRECT_MSG_RESP(2) with return arguments.

However, since ArmFfaLibRun() gets its return in its stack variable,
So caller of ArmFfaLibRun() doesn't get the return arguments from
secure partition.

To resolve this, add output parameter to ArmFfaLibRun() to
receive return arguments.

Continuous-integration-options: PatchCheck.ignore-multi-package
Fixes: 5d1b38dd07 ("ArmPkg: Add ArmFfaLib used in Dxe driver")
Reported-by: Mariam Elshakfy <Mariam.Elshakfy@arm.com>
Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
2025-09-08 13:14:00 +00:00
Levi Yunandmergify[bot] f85c718167 MdeModulePkg/Include: change type of buffer address in ArmFfaRxTxBufferInfo
Change type of buffer address type in ArmFfaRxTxBufferInfo
so that reduce the type casting.

Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
2025-07-14 11:59:38 +00:00
Levi Yunandmergify[bot] 5a2713ec2b MdeModulePkg/Library: commonize some duplicate code in ArmFfaLib
Some of code for handling Rx/Tx buffer is duplicate.
This patch commonize some of duplication routine used in
Rx/Tx buffer related functions.

Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
2025-07-14 11:59:38 +00:00
Levi Yunandmergify[bot] a7e27682cf MdeModulePkg/Library: add ArmFfaSecLib
To use Arm-FFA intereface in PeilessSec, implments
ArmFfaSecLib used by PeilessSec.
For example, communicate with TPM service using CRB over ARM-FFA
(via Tpm2DeviceLibFfa), PeilessSec need to use Arm-FFA interface.

Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
2025-07-14 11:59:38 +00:00