Skip to content

Commit 4762568

Browse files
committed
target: arm: HACK: implement dummy Mistral-specific registers
This includes dummy versions of the KTRR registers and four other registers not documented in XNU source and only found on t8015.
1 parent 21d133e commit 4762568

2 files changed

Lines changed: 39 additions & 1 deletion

File tree

target/arm/cpu.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,13 @@ typedef struct CPUARMState {
474474
uint64_t pmccfiltr_el0; /* Performance Monitor Filter Register */
475475
uint64_t vpidr_el2; /* Virtualization Processor ID Register */
476476
uint64_t vmpidr_el2; /* Virtualization Multiprocessor ID Register */
477+
uint64_t ktrr_mystery0_el1; // ktrr reg 0
478+
uint64_t ktrr_mystery1_el1; // ktrr reg 1
479+
uint64_t ktrr_lock_el1; // ktrr reg 2
480+
uint64_t ktrr_lower_el1; // ktrr reg 3
481+
uint64_t ktrr_upper_el1; // ktrr reg 4
482+
uint64_t ktrr_mystery6_el1; // ktrr reg 6
483+
uint64_t ktrr_mystery7_el1; // ktrr reg 7
477484
} cp15;
478485

479486
struct {

target/arm/helper.c

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3738,6 +3738,36 @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
37383738
.access = PL1_RW, .accessfn = access_trap_aa32s_el1,
37393739
.writefn = sdcr_write,
37403740
.fieldoffset = offsetoflow32(CPUARMState, cp15.mdcr_el3) },
3741+
// zhuowei: hack: KTRR for Apple CPUs
3742+
{ .name = "KTRR_MYSTERY0_EL1", .state = ARM_CP_STATE_AA64,
3743+
.opc0 = 3, .opc1 = 4, .crn = 15, .crm = 2, .opc2 = 0,
3744+
.resetvalue = 0,
3745+
.access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.ktrr_mystery0_el1) },
3746+
{ .name = "KTRR_MYSTERY1_EL1", .state = ARM_CP_STATE_AA64,
3747+
.opc0 = 3, .opc1 = 4, .crn = 15, .crm = 2, .opc2 = 1,
3748+
.resetvalue = 0,
3749+
.access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.ktrr_mystery1_el1) },
3750+
{ .name = "KTRR_LOCK_EL1", .state = ARM_CP_STATE_AA64,
3751+
.opc0 = 3, .opc1 = 4, .crn = 15, .crm = 2, .opc2 = 2,
3752+
.resetvalue = 0,
3753+
.access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.ktrr_lock_el1) },
3754+
{ .name = "KTRR_LOWER_EL1", .state = ARM_CP_STATE_AA64,
3755+
.opc0 = 3, .opc1 = 4, .crn = 15, .crm = 2, .opc2 = 3,
3756+
.resetvalue = 0,
3757+
.access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.ktrr_lower_el1) },
3758+
{ .name = "KTRR_UPPER_EL1", .state = ARM_CP_STATE_AA64,
3759+
.opc0 = 3, .opc1 = 4, .crn = 15, .crm = 2, .opc2 = 4,
3760+
.resetvalue = 0,
3761+
.access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.ktrr_upper_el1) },
3762+
// no ktrr register 5, I think.
3763+
{ .name = "KTRR_MYSTERY6_EL1", .state = ARM_CP_STATE_AA64,
3764+
.opc0 = 3, .opc1 = 4, .crn = 15, .crm = 2, .opc2 = 6,
3765+
.resetvalue = 0,
3766+
.access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.ktrr_mystery6_el1) },
3767+
{ .name = "KTRR_MYSTERY7_EL1", .state = ARM_CP_STATE_AA64,
3768+
.opc0 = 3, .opc1 = 4, .crn = 15, .crm = 2, .opc2 = 7,
3769+
.resetvalue = 0,
3770+
.access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.ktrr_mystery7_el1) },
37413771
REGINFO_SENTINEL
37423772
};
37433773

@@ -5843,7 +5873,8 @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu,
58435873
break;
58445874
}
58455875
/* assert our permissions are not too lax (stricter is fine) */
5846-
assert((r->access & ~mask) == 0);
5876+
// zhuowei: hack. make KTRR registers writable from EL1 even though they have opc1=4
5877+
// assert((r->access & ~mask) == 0);
58475878
}
58485879

58495880
/* Check that the register definition has enough info to handle

0 commit comments

Comments
 (0)