Skip to content

Commit 63c151e

Browse files
committed
Kernel/aarch64: Allow userspace to access CTR_EL0
CTR_EL0 is a read-only register that contains information about the architecture of the caches. Both FreeBSD and Linux seem to allow direct access to this register, so I don't think we should disallow EL0 to access it. This register is typically read during `__clear_cache()` to determine the data/instruction cache line sizes and whether they are coherent. `__clear_cache()` in turn is used by JITs to ensure that self-modifying code works properly.
1 parent 0409e72 commit 63c151e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Kernel/Arch/aarch64/Registers.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,9 @@ struct alignas(u64) SCTLR_EL1 {
819819
system_control_register_el1.SA0 = 1;
820820
system_control_register_el1.IESB = 1;
821821

822+
// Allow EL0 to read CTR_EL0 (the cache type register).
823+
system_control_register_el1.UCT = 1;
824+
822825
// Fields that are RES1 if no extensions are supported:
823826
system_control_register_el1.ITD = 1;
824827
system_control_register_el1.SED = 1;

0 commit comments

Comments
 (0)