* [edk2-devel] [PATCH v2 30/45] ArmVirtPkg: ArmCcaRsiLib: Fix incorrect RSI version masks
2024-04-12 15:13 [edk2-devel] [PATCH v2 00/45] Support for Arm CCA guest firmware Sami Mujawar
@ 2024-04-12 15:13 ` Sami Mujawar
2024-04-12 15:13 ` [edk2-devel] [PATCH v2 41/45] ArmVirtPkg: RMM 1.0-eac4 - Add RSI Features support Sami Mujawar
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Sami Mujawar @ 2024-04-12 15:13 UTC (permalink / raw)
To: devel
Cc: Sami Mujawar, ardb+tianocore, quic_llindhol, kraxel,
Matteo.Carlini, Akanksha.Jain2, Sibel.Allinson, nd
The RsiInterfaceVersion fieldset contains an RSI interface
version and the width of this fieldset is 64 bits.
The bits 15:0 of this fieldset represent the RSI minor
revision number and the bits 30:16 represent the major
revision number. The remaining bits 63:31 are reserved
and should be zero.
The RSI version masks were incorrectly defined which
resulted in an incorrect RSI version being returned
by RsiGetVersion (). Therefore, fix the RSI version
masks to reflect the bit fields defined by the RMM
specification.
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
---
ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h b/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h
index 70e84a20711f04c32a5850230cc907a6d231f50b..b1c359e2486c20ee19493b10ed3fcef1e20f2689 100644
--- a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h
+++ b/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h
@@ -41,8 +41,8 @@
See Section B4.4.3, RMM Specification, version A-bet0.
The width of the RsiInterfaceVersion fieldset is 64 bits.
*/
-#define RSI_VER_MINOR_MASK 0x00FFULL
-#define RSI_VER_MAJOR_MASK 0x7F00ULL
+#define RSI_VER_MINOR_MASK 0x0000FFFFULL
+#define RSI_VER_MAJOR_MASK 0x7FFF0000ULL
#define RSI_VER_MAJOR_SHIFT 16
#endif // ARM_CCA_RSI_H_
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117712): https://edk2.groups.io/g/devel/message/117712
Mute This Topic: https://groups.io/mt/105484263/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [edk2-devel] [PATCH v2 41/45] ArmVirtPkg: RMM 1.0-eac4 - Add RSI Features support
2024-04-12 15:13 [edk2-devel] [PATCH v2 00/45] Support for Arm CCA guest firmware Sami Mujawar
2024-04-12 15:13 ` [edk2-devel] [PATCH v2 30/45] ArmVirtPkg: ArmCcaRsiLib: Fix incorrect RSI version masks Sami Mujawar
@ 2024-04-12 15:13 ` Sami Mujawar
2024-04-12 15:13 ` [edk2-devel] [PATCH v2 43/45] ArmVirtPkg: RMM 1.0-eac5 - Update RSI Version support Sami Mujawar
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Sami Mujawar @ 2024-04-12 15:13 UTC (permalink / raw)
To: devel
Cc: Sami Mujawar, ardb+tianocore, quic_llindhol, kraxel,
Matteo.Carlini, Akanksha.Jain2, Sibel.Allinson, nd
The RMM 1.0-eac4 introduces a new FID RSI_FEATURES
to query the RSI features supported that have been
implemented.
Therefore, introduce a new function RsiGetFeatures
to query the features supported by the RSI.
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
---
ArmVirtPkg/Include/Library/ArmCcaRsiLib.h | 24 +++++++++++-
ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h | 3 +-
ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c | 39 +++++++++++++++++++-
3 files changed, 63 insertions(+), 3 deletions(-)
diff --git a/ArmVirtPkg/Include/Library/ArmCcaRsiLib.h b/ArmVirtPkg/Include/Library/ArmCcaRsiLib.h
index 88351f53336c42c032fcff6ea97ea7728b917b76..8c1c0d5bc19d14fa640464c8d0d44e3ef522ba79 100644
--- a/ArmVirtPkg/Include/Library/ArmCcaRsiLib.h
+++ b/ArmVirtPkg/Include/Library/ArmCcaRsiLib.h
@@ -11,7 +11,7 @@
- REM - Realm Extensible Measurement
@par Reference(s):
- - Realm Management Monitor (RMM) Specification, version 1.0-eac3
+ - Realm Management Monitor (RMM) Specification, version 1.0-eac4
(https://developer.arm.com/documentation/den0137/)
**/
@@ -334,4 +334,26 @@ RsiGetVersion (
OUT UINT16 *CONST Minor
);
+/**
+ Get the features supported by the RSI implementation.
+
+ RMM implementations across different CCA platforms may support
+ disparate features and may offer disparate configuration options
+ for Realms. The features supported by an RSI implementation are
+ discovered by reading feature pseudo-register values using the
+ RSI_FEATURES command.
+
+ @param [in] FeatureRegIndex The Feature Register Index.
+ @param [out] FeatureRegValue The Feature Register Value.
+
+ @retval RETURN_SUCCESS Success.
+ @retval RETURN_INVALID_PARAMETER A parameter is invalid.
+**/
+RETURN_STATUS
+EFIAPI
+RsiGetFeatures (
+ IN UINT64 FeatureRegIndex,
+ OUT UINT64 *FeatureRegValue
+ );
+
#endif // ARM_CCA_RSI_LIB_
diff --git a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h b/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h
index b1c359e2486c20ee19493b10ed3fcef1e20f2689..cd2c9ac05c02413caeed26fd764320dd751ea05b 100644
--- a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h
+++ b/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h
@@ -10,7 +10,7 @@
- RIPAS - Realm IPA state
@par Reference(s):
- - Realm Management Monitor (RMM) Specification, version A-bet0
+ - Realm Management Monitor (RMM) Specification, version 1.0-eac4
(https://developer.arm.com/documentation/den0137/)
**/
@@ -20,6 +20,7 @@
// FIDs for Realm Service Interface calls.
#define FID_RSI_ATTESTATION_TOKEN_CONTINUE 0xC4000195
#define FID_RSI_ATTESTATION_TOKEN_INIT 0xC4000194
+#define FID_RSI_FEATURES 0xC4000191
#define FID_RSI_HOST_CALL 0xC4000199
#define FID_RSI_IPA_STATE_GET 0xC4000198
#define FID_RSI_IPA_STATE_SET 0xC4000197
diff --git a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c b/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c
index 12636c484824426b2ea81ca007d962f5f7c58f8c..edd2e11f786d11191f13dd9b087cdeec4127b375 100644
--- a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c
+++ b/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c
@@ -11,7 +11,7 @@
- REM - Realm Extensible Measurement
@par Reference(s):
- - Realm Management Monitor (RMM) Specification, version 1.0-eac3
+ - Realm Management Monitor (RMM) Specification, version 1.0-eac4
(https://developer.arm.com/documentation/den0137/)
**/
@@ -574,3 +574,40 @@ RsiGetVersion (
*Major = (SmcCmd.Arg0 & RSI_VER_MAJOR_MASK) >> RSI_VER_MAJOR_SHIFT;
return RETURN_SUCCESS;
}
+
+/**
+ Get the features supported by the RSI implementation.
+
+ RMM implementations across different CCA platforms may support
+ disparate features and may offer disparate configuration options
+ for Realms. The features supported by an RSI implementation are
+ discovered by reading feature pseudo-register values using the
+ RSI_FEATURES command.
+
+ @param [in] FeatureRegIndex The Feature Register Index.
+ @param [out] FeatureRegValue The Feature Register Value.
+
+ @retval RETURN_SUCCESS Success.
+ @retval RETURN_INVALID_PARAMETER A parameter is invalid.
+**/
+RETURN_STATUS
+EFIAPI
+RsiGetFeatures (
+ IN UINT64 FeatureRegIndex,
+ OUT UINT64 *FeatureRegValue
+ )
+{
+ ARM_SMC_ARGS SmcCmd;
+
+ if (FeatureRegValue == NULL) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ ZeroMem (&SmcCmd, sizeof (SmcCmd));
+ SmcCmd.Arg0 = FID_RSI_FEATURES;
+ SmcCmd.Arg1 = FeatureRegIndex;
+
+ ArmCallSmc (&SmcCmd);
+ *FeatureRegValue = SmcCmd.Arg1;
+ return RsiCmdStatusToEfiStatus (SmcCmd.Arg0);
+}
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117715): https://edk2.groups.io/g/devel/message/117715
Mute This Topic: https://groups.io/mt/105484267/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [edk2-devel] [PATCH v2 43/45] ArmVirtPkg: RMM 1.0-eac5 - Update RSI Version support
2024-04-12 15:13 [edk2-devel] [PATCH v2 00/45] Support for Arm CCA guest firmware Sami Mujawar
2024-04-12 15:13 ` [edk2-devel] [PATCH v2 30/45] ArmVirtPkg: ArmCcaRsiLib: Fix incorrect RSI version masks Sami Mujawar
2024-04-12 15:13 ` [edk2-devel] [PATCH v2 41/45] ArmVirtPkg: RMM 1.0-eac4 - Add RSI Features support Sami Mujawar
@ 2024-04-12 15:13 ` Sami Mujawar
2024-04-12 15:13 ` [edk2-devel] [PATCH v2 44/45] ArmVirtPkg: ArmCcaLib: Cache current world value Sami Mujawar
2024-04-12 15:13 ` [edk2-devel] [PATCH v2 45/45] ArmVirtPkg: ArmCcaIoMmu: Provide an implementation for SetAttribute Sami Mujawar
4 siblings, 0 replies; 6+ messages in thread
From: Sami Mujawar @ 2024-04-12 15:13 UTC (permalink / raw)
To: devel
Cc: Sami Mujawar, ardb+tianocore, quic_llindhol, kraxel,
Matteo.Carlini, Akanksha.Jain2, Sibel.Allinson, nd
The RMM 1.0-eac5 specification updates the RSI version command
to return the highest interface revision which is supported by
the RMM and the lower revision value which indicates:
a. The RMM supports an interface revision which is compatible
with the requested revision and the lower revision is equal
to the requested revision and the status code is RSI_SUCCESS
b. The RMM does not support the requested version, but the RMM
supports an interface revision which is lower than the
requested revision and the status code is RSI_ERROR_INPUT
c. The RMM does not support an interface revision which is
compatible with the requested revision and that it supports
an interface revision that is greater than the requested
revision. The status code is RSI_ERROR_INPUT and the lower
revision is equal to the higher revision.
Therefore, update the RsiGetVersion() to return the lower and
higher revision that is supported by the RMM. The RsiGetVersion
function also returns the RSI version that is implemented by
the firmware.
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
---
ArmVirtPkg/Include/Library/ArmCcaRsiLib.h | 20 ++++--
ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.c | 11 +++-
ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h | 12 +++-
ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c | 65 ++++++++++++++++----
4 files changed, 85 insertions(+), 23 deletions(-)
diff --git a/ArmVirtPkg/Include/Library/ArmCcaRsiLib.h b/ArmVirtPkg/Include/Library/ArmCcaRsiLib.h
index b768f3498314a2ea61762af65bf2668d463909a6..fd86191f90f64329aadbb847d31cd46d2549b032 100644
--- a/ArmVirtPkg/Include/Library/ArmCcaRsiLib.h
+++ b/ArmVirtPkg/Include/Library/ArmCcaRsiLib.h
@@ -330,17 +330,25 @@ RsiHostCall (
/**
Get the version of the RSI implementation.
- @param [out] Major The major version of the RSI implementation.
- @param [out] Minor The minor version of the RSI implementation.
+ @param [out] UefiImpl The version of the RSI specification
+ implemented by the UEFI firmware.
+ @param [out] RmmImplLow The low version of the RSI specification
+ implemented by the RMM.
+ @param [out] RmmImplHigh The high version of the RSI specification
+ implemented by the RMM.
- @retval RETURN_SUCCESS Success.
- @retval RETURN_INVALID_PARAMETER A parameter is invalid.
+ @retval RETURN_SUCCESS Success.
+ @retval RETURN_UNSUPPORTED The execution context is not a Realm.
+ @retval RETURN_INCOMPATIBLE_VERSION The Firmware and RMM specification
+ revisions are not compatible.
+ @retval RETURN_INVALID_PARAMETER A parameter is invalid.
**/
RETURN_STATUS
EFIAPI
RsiGetVersion (
- OUT UINT16 *CONST Major,
- OUT UINT16 *CONST Minor
+ OUT UINT32 *CONST UefiImpl,
+ OUT UINT32 *CONST RmmImplLow,
+ OUT UINT32 *CONST RmmImplHigh
);
/**
diff --git a/ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.c b/ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.c
index 57b05f308377cf931c5f43fc7793c260dfdc36fb..3abb4dfaf567c635b28ff3a7cd5adea064e02510 100644
--- a/ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.c
+++ b/ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.c
@@ -36,11 +36,16 @@ IsRealm (
)
{
RETURN_STATUS Status;
- UINT16 Major;
- UINT16 Minor;
+ UINT32 UefiImpl;
+ UINT32 RmmImplLow;
+ UINT32 RmmImplHigh;
if (ArmHasRme ()) {
- Status = RsiGetVersion (&Major, &Minor);
+ Status = RsiGetVersion (
+ &UefiImpl,
+ &RmmImplLow,
+ &RmmImplHigh
+ );
if (!RETURN_ERROR (Status)) {
return TRUE;
}
diff --git a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h b/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h
index cd2c9ac05c02413caeed26fd764320dd751ea05b..ce3cb0c36ffa6ddf3a16f9f47199123dc6150c51 100644
--- a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h
+++ b/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsi.h
@@ -10,7 +10,7 @@
- RIPAS - Realm IPA state
@par Reference(s):
- - Realm Management Monitor (RMM) Specification, version 1.0-eac4
+ - Realm Management Monitor (RMM) Specification, version 1.0-eac5
(https://developer.arm.com/documentation/den0137/)
**/
@@ -45,5 +45,15 @@
#define RSI_VER_MINOR_MASK 0x0000FFFFULL
#define RSI_VER_MAJOR_MASK 0x7FFF0000ULL
#define RSI_VER_MAJOR_SHIFT 16
+#define RSI_VERSION_MASK (RSI_VER_MAJOR_MASK | RSI_VER_MINOR_MASK)
+
+#define RMM_VERSION(Major, Minor) ((Minor & RSI_VER_MINOR_MASK) | \
+ ((Major << RSI_VER_MAJOR_SHIFT) & RSI_VER_MAJOR_MASK))
+
+#define GET_MAJOR_REVISION(Rev) \
+ ((Rev & RSI_VER_MAJOR_MASK) >> RSI_VER_MAJOR_SHIFT)
+
+#define GET_MINOR_REVISION(Rev) \
+ ((Rev & RSI_VER_MINOR_MASK))
#endif // ARM_CCA_RSI_H_
diff --git a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c b/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c
index b861b2e79d5d659a0eb16206d329a0cb039eda0d..dba93013eba0344a717f2e4d082af2be084e469a 100644
--- a/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c
+++ b/ArmVirtPkg/Library/ArmCcaRsiLib/ArmCcaRsiLib.c
@@ -25,6 +25,10 @@
#include <Library/MemoryAllocationLib.h>
#include "ArmCcaRsi.h"
+/** The version of RSI specification implemented by this module.
+*/
+STATIC CONST UINT32 mRsiImplVersion = RMM_VERSION (1, 0);
+
/**
Convert the RSI status code to EFI Status code.
@@ -639,32 +643,67 @@ RsiHostCall (
/**
Get the version of the RSI implementation.
- @param [out] Major The major version of the RSI implementation.
- @param [out] Minor The minor version of the RSI implementation.
+ @param [out] UefiImpl The version of the RSI specification
+ implemented by the UEFI firmware.
+ @param [out] RmmImplLow The low version of the RSI specification
+ implemented by the RMM.
+ @param [out] RmmImplHigh The high version of the RSI specification
+ implemented by the RMM.
- @retval RETURN_SUCCESS Success.
- @retval RETURN_INVALID_PARAMETER A parameter is invalid.
+ @retval RETURN_SUCCESS Success.
+ @retval RETURN_UNSUPPORTED The execution context is not a Realm.
+ @retval RETURN_INCOMPATIBLE_VERSION The Firmware and RMM specification
+ revisions are not compatible.
+ @retval RETURN_INVALID_PARAMETER A parameter is invalid.
**/
RETURN_STATUS
EFIAPI
RsiGetVersion (
- OUT UINT16 *CONST Major,
- OUT UINT16 *CONST Minor
+ OUT UINT32 *CONST UefiImpl,
+ OUT UINT32 *CONST RmmImplLow,
+ OUT UINT32 *CONST RmmImplHigh
)
{
- ARM_SMC_ARGS SmcCmd;
+ RETURN_STATUS Status;
+ ARM_SMC_ARGS SmcCmd;
- if ((Major == NULL) || (Minor == NULL)) {
- return EFI_INVALID_PARAMETER;
+ if ((UefiImpl == NULL) || (RmmImplLow == NULL) || (RmmImplHigh == NULL)) {
+ return RETURN_INVALID_PARAMETER;
}
ZeroMem (&SmcCmd, sizeof (SmcCmd));
SmcCmd.Arg0 = FID_RSI_VERSION;
-
+ SmcCmd.Arg1 = mRsiImplVersion;
ArmCallSmc (&SmcCmd);
- *Minor = SmcCmd.Arg0 & RSI_VER_MINOR_MASK;
- *Major = (SmcCmd.Arg0 & RSI_VER_MAJOR_MASK) >> RSI_VER_MAJOR_SHIFT;
- return RETURN_SUCCESS;
+ if (SmcCmd.Arg0 == MAX_UINT64) {
+ // This FID is not implemented, which means
+ // we are not running in a Realm, therefore
+ // return the error code as unsupported.
+ return RETURN_UNSUPPORTED;
+ }
+
+ *RmmImplLow = (SmcCmd.Arg1 & RSI_VERSION_MASK);
+ *RmmImplHigh = (SmcCmd.Arg2 & RSI_VERSION_MASK);
+ *UefiImpl = mRsiImplVersion;
+
+ // The RSI_VERSION command does not have any failure
+ // conditions see section B5.3.10.2 Failure conditions
+ // Therefore the only defined return values are
+ // RSI_SUCCESS and RSI_ERROR_INPUT.
+ Status = RsiCmdStatusToEfiStatus (SmcCmd.Arg0);
+ if (Status == RETURN_INVALID_PARAMETER) {
+ // RSI_VERSION returns RSI_ERROR_INPUT when
+ // the RMM does not support an interface revision
+ // which is compatible with the requested revision.
+ // Since RSI_ERROR_INPUT is mapped to RETURN_INVALID_PARAMETER
+ // by RsiCmdStatusToEfiStatus(), return the status code as
+ // RETURN_INCOMPATIBLE_VERSION.
+ return RETURN_INCOMPATIBLE_VERSION;
+ }
+
+ // Add an assert in case RMM returns a different error code than expected.
+ ASSERT (Status == RETURN_SUCCESS);
+ return Status;
}
/**
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117711): https://edk2.groups.io/g/devel/message/117711
Mute This Topic: https://groups.io/mt/105484262/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [edk2-devel] [PATCH v2 44/45] ArmVirtPkg: ArmCcaLib: Cache current world value
2024-04-12 15:13 [edk2-devel] [PATCH v2 00/45] Support for Arm CCA guest firmware Sami Mujawar
` (2 preceding siblings ...)
2024-04-12 15:13 ` [edk2-devel] [PATCH v2 43/45] ArmVirtPkg: RMM 1.0-eac5 - Update RSI Version support Sami Mujawar
@ 2024-04-12 15:13 ` Sami Mujawar
2024-04-12 15:13 ` [edk2-devel] [PATCH v2 45/45] ArmVirtPkg: ArmCcaIoMmu: Provide an implementation for SetAttribute Sami Mujawar
4 siblings, 0 replies; 6+ messages in thread
From: Sami Mujawar @ 2024-04-12 15:13 UTC (permalink / raw)
To: devel
Cc: Sami Mujawar, ardb+tianocore, quic_llindhol, kraxel,
Matteo.Carlini, Akanksha.Jain2, Sibel.Allinson, nd
IsRealm() probes to check if the code is executing
in a Realm context by checking if RME is supported
and then issuing a RSI_VERSION command to check it
is supported.
Instead of calling RSI_VERSION command every time the
IsRealm() is called, cache the world value we are
running in, to return the value in subsequent calls.
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
---
ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.c | 31 ++++++++++++--------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.c b/ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.c
index 3abb4dfaf567c635b28ff3a7cd5adea064e02510..67ad2824f1f6a8fe4e1fd3f837300097a68775c7 100644
--- a/ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.c
+++ b/ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.c
@@ -35,23 +35,28 @@ IsRealm (
VOID
)
{
- RETURN_STATUS Status;
- UINT32 UefiImpl;
- UINT32 RmmImplLow;
- UINT32 RmmImplHigh;
+ RETURN_STATUS Status;
+ UINT32 UefiImpl;
+ UINT32 RmmImplLow;
+ UINT32 RmmImplHigh;
+ STATIC BOOLEAN RealmWorld = FALSE;
+ STATIC BOOLEAN FlagsInitialised = FALSE;
- if (ArmHasRme ()) {
- Status = RsiGetVersion (
- &UefiImpl,
- &RmmImplLow,
- &RmmImplHigh
- );
- if (!RETURN_ERROR (Status)) {
- return TRUE;
+ if (!FlagsInitialised) {
+ FlagsInitialised = TRUE;
+ if (ArmHasRme ()) {
+ Status = RsiGetVersion (
+ &UefiImpl,
+ &RmmImplLow,
+ &RmmImplHigh
+ );
+ if (!RETURN_ERROR (Status)) {
+ RealmWorld = TRUE;
+ }
}
}
- return FALSE;
+ return RealmWorld;
}
/**
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117714): https://edk2.groups.io/g/devel/message/117714
Mute This Topic: https://groups.io/mt/105484265/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [edk2-devel] [PATCH v2 45/45] ArmVirtPkg: ArmCcaIoMmu: Provide an implementation for SetAttribute
2024-04-12 15:13 [edk2-devel] [PATCH v2 00/45] Support for Arm CCA guest firmware Sami Mujawar
` (3 preceding siblings ...)
2024-04-12 15:13 ` [edk2-devel] [PATCH v2 44/45] ArmVirtPkg: ArmCcaLib: Cache current world value Sami Mujawar
@ 2024-04-12 15:13 ` Sami Mujawar
4 siblings, 0 replies; 6+ messages in thread
From: Sami Mujawar @ 2024-04-12 15:13 UTC (permalink / raw)
To: devel
Cc: Sami Mujawar, ardb+tianocore, quic_llindhol, kraxel,
Matteo.Carlini, Akanksha.Jain2, Sibel.Allinson, nd
The patch at "049695a0b1e2 MdeModulePkg/PciBusDxe: Add feedback
status for PciIoMap" adds support to propagate the error code
following the invocation of the IoMmu protocol SetAttribute()
operation.
Since the ArmCcaIoMmuDxe implementation of the SetAttribute()
function returned EFI_UNSUPPORTED, it resulted in the virtio
disk not being mounted.
Although there is nothing to be done in SetAttribute(), follow
the approach as done by the patch at "97c3f5b8d272 Provide an
implementation for SetAttribute" to validate the IoMmu access
method being requested against the IoMmu mapping operation and
return a suitable return code.
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
---
ArmVirtPkg/ArmCcaIoMmuDxe/ArmCcaIoMmu.c | 63 +++++++++++++++++++-
1 file changed, 61 insertions(+), 2 deletions(-)
diff --git a/ArmVirtPkg/ArmCcaIoMmuDxe/ArmCcaIoMmu.c b/ArmVirtPkg/ArmCcaIoMmuDxe/ArmCcaIoMmu.c
index cf52b82218bb9ece7bfedcb6e3a2ced00eff5e92..91f9dae91843b6739ddb818e9ec81706ccfa73b3 100644
--- a/ArmVirtPkg/ArmCcaIoMmuDxe/ArmCcaIoMmu.c
+++ b/ArmVirtPkg/ArmCcaIoMmuDxe/ArmCcaIoMmu.c
@@ -629,7 +629,9 @@ IoMmuFreeBuffer (
@param[in] Mapping The mapping value returned from Map().
@param[in] IoMmuAccess The IOMMU access.
- @retval EFI_UNSUPPORTED Operation not supported by IOMMU.
+ @retval EFI_INVALID_PARAMETER A parameter was invalid.
+ @retval EFI_UNSUPPORTED The requested operation is not supported.
+ @retval EFI_SUCCESS Success.
**/
EFI_STATUS
@@ -641,7 +643,64 @@ IoMmuSetAttribute (
IN UINT64 IoMmuAccess
)
{
- return EFI_UNSUPPORTED;
+ EFI_STATUS Status;
+ MAP_INFO *MapInfo;
+
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "%a: Mapping=0x%p Access=%lu\n",
+ __func__,
+ Mapping,
+ IoMmuAccess
+ ));
+
+ if (Mapping == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_SUCCESS;
+
+ // An IoMmuAccess value of 0 is always accepted,
+ // validate any non-zero value.
+ if (IoMmuAccess != 0) {
+ MapInfo = (MAP_INFO *)Mapping;
+
+ // The mapping operation already implied the access mode.
+ // Validate that the supplied access mode matches operation
+ // access mode.
+ switch (MapInfo->Operation) {
+ case EdkiiIoMmuOperationBusMasterRead:
+ case EdkiiIoMmuOperationBusMasterRead64:
+ if (IoMmuAccess != EDKII_IOMMU_ACCESS_READ) {
+ Status = EFI_INVALID_PARAMETER;
+ }
+
+ break;
+
+ case EdkiiIoMmuOperationBusMasterWrite:
+ case EdkiiIoMmuOperationBusMasterWrite64:
+ if (IoMmuAccess != EDKII_IOMMU_ACCESS_WRITE) {
+ Status = EFI_INVALID_PARAMETER;
+ }
+
+ break;
+
+ case EdkiiIoMmuOperationBusMasterCommonBuffer:
+ case EdkiiIoMmuOperationBusMasterCommonBuffer64:
+ if (IoMmuAccess !=
+ (EDKII_IOMMU_ACCESS_READ | EDKII_IOMMU_ACCESS_WRITE))
+ {
+ Status = EFI_INVALID_PARAMETER;
+ }
+
+ break;
+
+ default:
+ Status = EFI_UNSUPPORTED;
+ } // switch
+ }
+
+ return Status;
}
/** Arm CCA IoMMU protocol
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117713): https://edk2.groups.io/g/devel/message/117713
Mute This Topic: https://groups.io/mt/105484264/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 6+ messages in thread