Skip to content

Commit

Permalink
Aarch64: enable CPU cache operation from user program
Browse files Browse the repository at this point in the history
Frameworks such as Node.js expect to be able to retrieve CPU cache
characteristics such as cache line sizes, and execute cache
maintenance operations (e.g. flushing the instruction cache).
This change modifies the settings of the SCTLR_EL1 register so that
cache access instructions from the user program do not generate
exceptions.
  • Loading branch information
francescolavra committed May 9, 2023
1 parent 9fea844 commit 016b5f3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/aarch64/kernel_machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
#define SCTLR_EL1_WXN U64_FROM_BIT(19) /* write implies execute never */
#define SCTLR_EL1_nTWE U64_FROM_BIT(18) /* no trap on WFE */
#define SCTLR_EL1_nTWI U64_FROM_BIT(16) /* no trap on WFI */
#define SCTLR_EL1_UCT U64_FROM_BIT(15) /* no trap on CTR_EL0 access */
#define SCTLR_EL1_I U64_FROM_BIT(12) /* instruction cacheability (no effect) */
#define SCTLR_EL1_CP15BEN U64_FROM_BIT(5) /* memory barrier enable from EL0 */
#define SCTLR_EL1_SA0 U64_FROM_BIT(4) /* SP alignment fault enable for EL0 */
Expand Down
2 changes: 2 additions & 0 deletions src/aarch64/page.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ void enable_mmu(u64 vtarget)
u64 sctlr = (SCTLR_EL1_SPAN |
SCTLR_EL1_nTWE |
SCTLR_EL1_nTWI |
SCTLR_EL1_UCI |
SCTLR_EL1_UCT |
SCTLR_EL1_I |
SCTLR_EL1_C |
SCTLR_EL1_M);
Expand Down

0 comments on commit 016b5f3

Please sign in to comment.