ArmPkg/ArmLib: ASSERT on set/way cache ops being used with MMU on

On ARMv7 and up, doing cache maintenance by set/way is only
permitted in the context of on/offlining a core, and any other
uses should be avoided. Add ASSERT()s in the right place to
ensure that any uses with the MMU enabled are caught in DEBUG
builds.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
This commit is contained in:
Ard Biesheuvel 2020-02-26 14:07:32 +01:00 committed by mergify[bot]
parent 806d1be6a7
commit a2ab46adbc
3 changed files with 17 additions and 0 deletions

View File

@ -10,6 +10,7 @@
#include <Base.h>
#include <Library/ArmLib.h>
#include <Library/DebugLib.h>
#include <Chipset/AArch64.h>
@ -41,6 +42,8 @@ ArmInvalidateDataCache (
VOID
)
{
ASSERT (!ArmMmuEnabled ());
ArmDataSynchronizationBarrier ();
AArch64DataCacheOperation (ArmInvalidateDataCacheEntryBySetWay);
}
@ -51,6 +54,8 @@ ArmCleanInvalidateDataCache (
VOID
)
{
ASSERT (!ArmMmuEnabled ());
ArmDataSynchronizationBarrier ();
AArch64DataCacheOperation (ArmCleanInvalidateDataCacheEntryBySetWay);
}
@ -61,6 +66,8 @@ ArmCleanDataCache (
VOID
)
{
ASSERT (!ArmMmuEnabled ());
ArmDataSynchronizationBarrier ();
AArch64DataCacheOperation (ArmCleanDataCacheEntryBySetWay);
}

View File

@ -10,6 +10,7 @@
#include <Base.h>
#include <Library/ArmLib.h>
#include <Library/DebugLib.h>
#include <Chipset/ArmV7.h>
@ -41,6 +42,8 @@ ArmInvalidateDataCache (
VOID
)
{
ASSERT (!ArmMmuEnabled ());
ArmDataSynchronizationBarrier ();
ArmV7DataCacheOperation (ArmInvalidateDataCacheEntryBySetWay);
}
@ -51,6 +54,8 @@ ArmCleanInvalidateDataCache (
VOID
)
{
ASSERT (!ArmMmuEnabled ());
ArmDataSynchronizationBarrier ();
ArmV7DataCacheOperation (ArmCleanInvalidateDataCacheEntryBySetWay);
}
@ -61,6 +66,8 @@ ArmCleanDataCache (
VOID
)
{
ASSERT (!ArmMmuEnabled ());
ArmDataSynchronizationBarrier ();
ArmV7DataCacheOperation (ArmCleanDataCacheEntryBySetWay);
}

View File

@ -44,6 +44,9 @@
AArch64/AArch64Support.S
AArch64/AArch64ArchTimerSupport.S
[LibraryClasses]
DebugLib
[Packages]
ArmPkg/ArmPkg.dec
MdePkg/MdePkg.dec