From a17add32c2466d2185073b3d4ce7a03a3374a692 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Thu, 5 Mar 2020 13:36:14 +0100 Subject: [PATCH] ArmPkg/ArmMmuLib ARM: simplify assignment of TTBR0 system register The expression passed into ArmSetTTBR0 () in ArmConfigureMmu() is sub-optimal at several levels: - TranslationTable is already aligned, and if it wasn't, doing it here wouldn't help - TTBRAttributes is guaranteed not to have any bits set outside of the 0x7f mask, so the mask operation is pointless as well, - an additional (UINTN) cast for good measure is also not needed. So simplify the expression. Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c index 11a1e704be..a6f44dbd5f 100644 --- a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c +++ b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c @@ -392,7 +392,7 @@ ArmConfigureMmu ( } } - ArmSetTTBR0 ((VOID *)(UINTN)(((UINTN)TranslationTable & ~TRANSLATION_TABLE_SECTION_ALIGNMENT_MASK) | (TTBRAttributes & 0x7F))); + ArmSetTTBR0 ((VOID *)((UINTN)TranslationTable | TTBRAttributes)); // // The TTBCR register value is undefined at reset in the Non-Secure world. -- 2.39.2