mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-11 09:15:38 +00:00
target/arm: Honor the HCR_EL2.TTLB bit
This bit traps EL1 access to tlb maintenance insns. Backports commit 30881b7353b5bb41210c32cd8e00421da757808c from qemu
This commit is contained in:
parent
74d6aa6012
commit
cc32a96183
|
@ -403,6 +403,16 @@ static CPAccessResult access_tacr(CPUARMState *env, const ARMCPRegInfo *ri,
|
|||
return CP_ACCESS_OK;
|
||||
}
|
||||
|
||||
/* Check for traps from EL1 due to HCR_EL2.TTLB. */
|
||||
static CPAccessResult access_ttlb(CPUARMState *env, const ARMCPRegInfo *ri,
|
||||
bool isread)
|
||||
{
|
||||
if (arm_current_el(env) == 1 && (arm_hcr_el2_eff(env) & HCR_TTLB)) {
|
||||
return CP_ACCESS_TRAP_EL2;
|
||||
}
|
||||
return CP_ACCESS_OK;
|
||||
}
|
||||
|
||||
static void dacr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
|
||||
{
|
||||
ARMCPU *cpu = env_archcpu(env);
|
||||
|
@ -2083,41 +2093,53 @@ static const ARMCPRegInfo v7_cp_reginfo[] = {
|
|||
.type = ARM_CP_NO_RAW, .access = PL1_R, .readfn = isr_read },
|
||||
/* 32 bit ITLB invalidates */
|
||||
{ .name = "ITLBIALL", .cp = 15, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 0,
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbiall_write },
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb,
|
||||
.writefn = tlbiall_write },
|
||||
{ .name = "ITLBIMVA", .cp = 15, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 1,
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbimva_write },
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb,
|
||||
.writefn = tlbimva_write },
|
||||
{ .name = "ITLBIASID", .cp = 15, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 2,
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbiasid_write },
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb,
|
||||
.writefn = tlbiasid_write },
|
||||
/* 32 bit DTLB invalidates */
|
||||
{ .name = "DTLBIALL", .cp = 15, .opc1 = 0, .crn = 8, .crm = 6, .opc2 = 0,
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbiall_write },
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb,
|
||||
.writefn = tlbiall_write },
|
||||
{ .name = "DTLBIMVA", .cp = 15, .opc1 = 0, .crn = 8, .crm = 6, .opc2 = 1,
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbimva_write },
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb,
|
||||
.writefn = tlbimva_write },
|
||||
{ .name = "DTLBIASID", .cp = 15, .opc1 = 0, .crn = 8, .crm = 6, .opc2 = 2,
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbiasid_write },
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb,
|
||||
.writefn = tlbiasid_write },
|
||||
/* 32 bit TLB invalidates */
|
||||
{ .name = "TLBIALL", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 0,
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbiall_write },
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb,
|
||||
.writefn = tlbiall_write },
|
||||
{ .name = "TLBIMVA", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 1,
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbimva_write },
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb,
|
||||
.writefn = tlbimva_write },
|
||||
{ .name = "TLBIASID", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 2,
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbiasid_write },
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb,
|
||||
.writefn = tlbiasid_write },
|
||||
{ .name = "TLBIMVAA", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 3,
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbimvaa_write },
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb,
|
||||
.writefn = tlbimvaa_write },
|
||||
REGINFO_SENTINEL
|
||||
};
|
||||
|
||||
static const ARMCPRegInfo v7mp_cp_reginfo[] = {
|
||||
/* 32 bit TLB invalidates, Inner Shareable */
|
||||
{ .name = "TLBIALLIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 0,
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbiall_is_write },
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb,
|
||||
.writefn = tlbiall_is_write },
|
||||
{ .name = "TLBIMVAIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 1,
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbimva_is_write },
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb,
|
||||
.writefn = tlbimva_is_write },
|
||||
{ .name = "TLBIASIDIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 2,
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W,
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb,
|
||||
.writefn = tlbiasid_is_write },
|
||||
{ .name = "TLBIMVAAIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 3,
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W,
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb,
|
||||
.writefn = tlbimvaa_is_write },
|
||||
REGINFO_SENTINEL
|
||||
};
|
||||
|
@ -4588,19 +4610,19 @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
|
|||
/* TLBI operations */
|
||||
{ .name = "TLBI_VMALLE1IS", .state = ARM_CP_STATE_AA64,
|
||||
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 0,
|
||||
.access = PL1_W, .type = ARM_CP_NO_RAW,
|
||||
.access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW,
|
||||
.writefn = tlbi_aa64_vmalle1is_write },
|
||||
{ .name = "TLBI_VAE1IS", .state = ARM_CP_STATE_AA64,
|
||||
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 1,
|
||||
.access = PL1_W, .type = ARM_CP_NO_RAW,
|
||||
.access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW,
|
||||
.writefn = tlbi_aa64_vae1is_write },
|
||||
{ .name = "TLBI_ASIDE1IS", .state = ARM_CP_STATE_AA64,
|
||||
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 2,
|
||||
.access = PL1_W, .type = ARM_CP_NO_RAW,
|
||||
.access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW,
|
||||
.writefn = tlbi_aa64_vmalle1is_write },
|
||||
{ .name = "TLBI_VAAE1IS", .state = ARM_CP_STATE_AA64,
|
||||
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 3,
|
||||
.access = PL1_W, .type = ARM_CP_NO_RAW,
|
||||
.access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW,
|
||||
.writefn = tlbi_aa64_vae1is_write },
|
||||
{ .name = "TLBI_VALE1IS", .state = ARM_CP_STATE_AA64,
|
||||
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 5,
|
||||
|
@ -4608,31 +4630,31 @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
|
|||
.writefn = tlbi_aa64_vae1is_write },
|
||||
{ .name = "TLBI_VAALE1IS", .state = ARM_CP_STATE_AA64,
|
||||
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 7,
|
||||
.access = PL1_W, .type = ARM_CP_NO_RAW,
|
||||
.access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW,
|
||||
.writefn = tlbi_aa64_vae1is_write },
|
||||
{ .name = "TLBI_VMALLE1", .state = ARM_CP_STATE_AA64,
|
||||
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 0,
|
||||
.access = PL1_W, .type = ARM_CP_NO_RAW,
|
||||
.access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW,
|
||||
.writefn = tlbi_aa64_vmalle1_write },
|
||||
{ .name = "TLBI_VAE1", .state = ARM_CP_STATE_AA64,
|
||||
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 1,
|
||||
.access = PL1_W, .type = ARM_CP_NO_RAW,
|
||||
.access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW,
|
||||
.writefn = tlbi_aa64_vae1_write },
|
||||
{ .name = "TLBI_ASIDE1", .state = ARM_CP_STATE_AA64,
|
||||
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 2,
|
||||
.access = PL1_W, .type = ARM_CP_NO_RAW,
|
||||
.access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW,
|
||||
.writefn = tlbi_aa64_vmalle1_write },
|
||||
{ .name = "TLBI_VAAE1", .state = ARM_CP_STATE_AA64,
|
||||
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 3,
|
||||
.access = PL1_W, .type = ARM_CP_NO_RAW,
|
||||
.access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW,
|
||||
.writefn = tlbi_aa64_vae1_write },
|
||||
{ .name = "TLBI_VALE1", .state = ARM_CP_STATE_AA64,
|
||||
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 5,
|
||||
.access = PL1_W, .type = ARM_CP_NO_RAW,
|
||||
.access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW,
|
||||
.writefn = tlbi_aa64_vae1_write },
|
||||
{ .name = "TLBI_VAALE1", .state = ARM_CP_STATE_AA64,
|
||||
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 7,
|
||||
.access = PL1_W, .type = ARM_CP_NO_RAW,
|
||||
.access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW,
|
||||
.writefn = tlbi_aa64_vae1_write },
|
||||
{ .name = "TLBI_IPAS2E1IS", .state = ARM_CP_STATE_AA64,
|
||||
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 0, .opc2 = 1,
|
||||
|
@ -4718,14 +4740,17 @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
|
|||
#endif
|
||||
/* TLB invalidate last level of translation table walk */
|
||||
{ .name = "TLBIMVALIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 5,
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbimva_is_write },
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb,
|
||||
.writefn = tlbimva_is_write },
|
||||
{ .name = "TLBIMVAALIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 7,
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W,
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb,
|
||||
.writefn = tlbimvaa_is_write },
|
||||
{ .name = "TLBIMVAL", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 5,
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbimva_write },
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb,
|
||||
.writefn = tlbimva_write },
|
||||
{ .name = "TLBIMVAAL", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 7,
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbimvaa_write },
|
||||
.type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb,
|
||||
.writefn = tlbimvaa_write },
|
||||
{ .name = "TLBIMVALH", .cp = 15, .opc1 = 4, .crn = 8, .crm = 7, .opc2 = 5,
|
||||
.type = ARM_CP_NO_RAW, .access = PL2_W,
|
||||
.writefn = tlbimva_hyp_write },
|
||||
|
|
Loading…
Reference in a new issue