thermosphere: use barriers and caches *properly*. Cache code refactoring

- set/way cache ops create losses of coherency, do not broadcast and are only meant to be used on boot, period.

Cache ops by VA are **the only way** to do data cache maintenance.

Fix a bug where the L2 cache was evicted by each core. It shouldn't have.

- Cleaning dcache to PoU and invalidating icache to PoU, by VA is sufficient for self-modifying code

- Since we operate within a single cluster and don't do DMA, we almost always operate within the inner shareability domain

(commit untested on real hw)
This commit is contained in:
TuxSH
2020-01-15 02:42:07 +00:00
parent 1369697058
commit 72d1992eec
13 changed files with 234 additions and 300 deletions

View File

@@ -17,7 +17,6 @@
#include <string.h>
#include "software_breakpoints.h"
#include "utils.h"
#include "arm.h"
SoftwareBreakpointManager g_softwareBreakpointManager = {0};
@@ -74,14 +73,14 @@ static inline bool doApplySoftwareBreakpoint(size_t id)
static void applySoftwareBreakpointHandler(void *p)
{
u64 flags = maskIrq();
__dmb_sy();
__dmb();
doApplySoftwareBreakpoint(*(size_t *)p);
restoreInterruptFlags(flags);
}
static void applySoftwareBreakpoint(size_t id)
{
__dmb_sy();
__dmb();
executeFunctionOnAllCores(applySoftwareBreakpointHandler, &id, true);
}
@@ -103,14 +102,14 @@ static inline bool doRevertSoftwareBreakpoint(size_t id)
static void revertSoftwareBreakpointHandler(void *p)
{
u64 flags = maskIrq();
__dmb_sy();
__dmb();
doRevertSoftwareBreakpoint(*(size_t *)p);
restoreInterruptFlags(flags);
}
static void revertSoftwareBreakpoint(size_t id)
{
__dmb_sy();
__dmb();
executeFunctionOnAllCores(revertSoftwareBreakpointHandler, &id, true);
}