[PATCH v1 1/1] StandaloneMmPkg: StandaloneMmMemLib: Change max address computation


Girish Mahadevan
 

Currently the standalonemmlibinternal assumes the max physical bits
to be 36 which is causing issues on v8 architectures.
Instead use the MAX_ADDRESS macro to determine the maximum allowed address
rather than recomputing it locally.

Signed-off-by: Girish Mahadevan <gmahadevan@...>
---
.../ArmStandaloneMmMemLibInternal.c | 15 +--------------
1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/StandaloneMmPkg/Library/StandaloneMmMemLib/ArmStandaloneMmMemLibInternal.c b/StandaloneMmPkg/Library/StandaloneMmMemLib/ArmStandaloneMmMemLibInternal.c
index 297cfae916..4dc392b4e3 100644
--- a/StandaloneMmPkg/Library/StandaloneMmMemLib/ArmStandaloneMmMemLibInternal.c
+++ b/StandaloneMmPkg/Library/StandaloneMmMemLib/ArmStandaloneMmMemLibInternal.c
@@ -20,13 +20,6 @@
//
extern EFI_PHYSICAL_ADDRESS mMmMemLibInternalMaximumSupportAddress;

-#ifdef MDE_CPU_AARCH64
-#define ARM_PHYSICAL_ADDRESS_BITS 36
-#endif
-#ifdef MDE_CPU_ARM
-#define ARM_PHYSICAL_ADDRESS_BITS 32
-#endif
-
/**
Calculate and save the maximum support address.

@@ -36,14 +29,8 @@ MmMemLibInternalCalculateMaximumSupportAddress (
VOID
)
{
- UINT8 PhysicalAddressBits;
-
- PhysicalAddressBits = ARM_PHYSICAL_ADDRESS_BITS;
+ mMmMemLibInternalMaximumSupportAddress = MAX_ADDRESS;

- //
- // Save the maximum support address in one global variable
- //
- mMmMemLibInternalMaximumSupportAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)(LShiftU64 (1, PhysicalAddressBits) - 1);
DEBUG ((DEBUG_INFO, "mMmMemLibInternalMaximumSupportAddress = 0x%lx\n", mMmMemLibInternalMaximumSupportAddress));
}

--
2.17.1


Ard Biesheuvel
 

(cc Damian)

On Sat, 28 Jan 2023 at 01:27, Girish Mahadevan <gmahadevan@...> wrote:

Currently the standalonemmlibinternal assumes the max physical bits
to be 36 which is causing issues on v8 architectures.
Instead use the MAX_ADDRESS macro to determine the maximum allowed address
rather than recomputing it locally.

Signed-off-by: Girish Mahadevan <gmahadevan@...>
---
.../ArmStandaloneMmMemLibInternal.c | 15 +--------------
1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/StandaloneMmPkg/Library/StandaloneMmMemLib/ArmStandaloneMmMemLibInternal.c b/StandaloneMmPkg/Library/StandaloneMmMemLib/ArmStandaloneMmMemLibInternal.c
index 297cfae916..4dc392b4e3 100644
--- a/StandaloneMmPkg/Library/StandaloneMmMemLib/ArmStandaloneMmMemLibInternal.c
+++ b/StandaloneMmPkg/Library/StandaloneMmMemLib/ArmStandaloneMmMemLibInternal.c
@@ -20,13 +20,6 @@
//
extern EFI_PHYSICAL_ADDRESS mMmMemLibInternalMaximumSupportAddress;

-#ifdef MDE_CPU_AARCH64
-#define ARM_PHYSICAL_ADDRESS_BITS 36
-#endif
-#ifdef MDE_CPU_ARM
-#define ARM_PHYSICAL_ADDRESS_BITS 32
-#endif
-
/**
Calculate and save the maximum support address.

@@ -36,14 +29,8 @@ MmMemLibInternalCalculateMaximumSupportAddress (
VOID
)
{
- UINT8 PhysicalAddressBits;
-
- PhysicalAddressBits = ARM_PHYSICAL_ADDRESS_BITS;
+ mMmMemLibInternalMaximumSupportAddress = MAX_ADDRESS;
This should be MAX_ALLOC_ADDRESS not MAX_ADDRESS


- //
- // Save the maximum support address in one global variable
- //
- mMmMemLibInternalMaximumSupportAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)(LShiftU64 (1, PhysicalAddressBits) - 1);
DEBUG ((DEBUG_INFO, "mMmMemLibInternalMaximumSupportAddress = 0x%lx\n", mMmMemLibInternalMaximumSupportAddress));
}

--
2.17.1


Girish Mahadevan
 

Hi

On 1/30/2023 4:27 AM, Ard Biesheuvel wrote:
External email: Use caution opening links or attachments
(cc Damian)
On Sat, 28 Jan 2023 at 01:27, Girish Mahadevan <gmahadevan@...> wrote:

Currently the standalonemmlibinternal assumes the max physical bits
to be 36 which is causing issues on v8 architectures.
Instead use the MAX_ADDRESS macro to determine the maximum allowed address
rather than recomputing it locally.

Signed-off-by: Girish Mahadevan <gmahadevan@...>
---
.../ArmStandaloneMmMemLibInternal.c | 15 +--------------
1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/StandaloneMmPkg/Library/StandaloneMmMemLib/ArmStandaloneMmMemLibInternal.c b/StandaloneMmPkg/Library/StandaloneMmMemLib/ArmStandaloneMmMemLibInternal.c
index 297cfae916..4dc392b4e3 100644
--- a/StandaloneMmPkg/Library/StandaloneMmMemLib/ArmStandaloneMmMemLibInternal.c
+++ b/StandaloneMmPkg/Library/StandaloneMmMemLib/ArmStandaloneMmMemLibInternal.c
@@ -20,13 +20,6 @@
//
extern EFI_PHYSICAL_ADDRESS mMmMemLibInternalMaximumSupportAddress;

-#ifdef MDE_CPU_AARCH64
-#define ARM_PHYSICAL_ADDRESS_BITS 36
-#endif
-#ifdef MDE_CPU_ARM
-#define ARM_PHYSICAL_ADDRESS_BITS 32
-#endif
-
/**
Calculate and save the maximum support address.

@@ -36,14 +29,8 @@ MmMemLibInternalCalculateMaximumSupportAddress (
VOID
)
{
- UINT8 PhysicalAddressBits;
-
- PhysicalAddressBits = ARM_PHYSICAL_ADDRESS_BITS;
+ mMmMemLibInternalMaximumSupportAddress = MAX_ADDRESS;
This should be MAX_ALLOC_ADDRESS not MAX_ADDRESS
ACK.

Best Regards
Girish



- //
- // Save the maximum support address in one global variable
- //
- mMmMemLibInternalMaximumSupportAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)(LShiftU64 (1, PhysicalAddressBits) - 1);
DEBUG ((DEBUG_INFO, "mMmMemLibInternalMaximumSupportAddress = 0x%lx\n", mMmMemLibInternalMaximumSupportAddress));
}

--
2.17.1