Skip to content

Commit e19d533

Browse files
Marc Zyngieroupton
authored andcommitted
KVM: arm64: nv: Add trap description for CPTR_EL2
Add trap description for CPTR_EL2.{TCPAC,TAM,E0POE,TTA}. TTA is a bit annoying as it changes location depending on E2H. This forces us to add yet another "complex" trap condition. Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent 0edc60f commit e19d533

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

arch/arm64/kvm/emulate-nested.c

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ enum cgt_group_id {
7979
CGT_MDCR_E2TB,
8080
CGT_MDCR_TDCC,
8181

82+
CGT_CPACR_E0POE,
83+
CGT_CPTR_TAM,
84+
CGT_CPTR_TCPAC,
85+
8286
/*
8387
* Anything after this point is a combination of coarse trap
8488
* controls, which must all be evaluated to decide what to do.
@@ -106,6 +110,8 @@ enum cgt_group_id {
106110
CGT_CNTHCTL_EL1PCTEN = __COMPLEX_CONDITIONS__,
107111
CGT_CNTHCTL_EL1PTEN,
108112

113+
CGT_CPTR_TTA,
114+
109115
/* Must be last */
110116
__NR_CGT_GROUP_IDS__
111117
};
@@ -345,6 +351,24 @@ static const struct trap_bits coarse_trap_bits[] = {
345351
.mask = MDCR_EL2_TDCC,
346352
.behaviour = BEHAVE_FORWARD_ANY,
347353
},
354+
[CGT_CPACR_E0POE] = {
355+
.index = CPTR_EL2,
356+
.value = CPACR_ELx_E0POE,
357+
.mask = CPACR_ELx_E0POE,
358+
.behaviour = BEHAVE_FORWARD_ANY,
359+
},
360+
[CGT_CPTR_TAM] = {
361+
.index = CPTR_EL2,
362+
.value = CPTR_EL2_TAM,
363+
.mask = CPTR_EL2_TAM,
364+
.behaviour = BEHAVE_FORWARD_ANY,
365+
},
366+
[CGT_CPTR_TCPAC] = {
367+
.index = CPTR_EL2,
368+
.value = CPTR_EL2_TCPAC,
369+
.mask = CPTR_EL2_TCPAC,
370+
.behaviour = BEHAVE_FORWARD_ANY,
371+
},
348372
};
349373

350374
#define MCB(id, ...) \
@@ -410,12 +434,26 @@ static enum trap_behaviour check_cnthctl_el1pten(struct kvm_vcpu *vcpu)
410434
return BEHAVE_FORWARD_ANY;
411435
}
412436

437+
static enum trap_behaviour check_cptr_tta(struct kvm_vcpu *vcpu)
438+
{
439+
u64 val = __vcpu_sys_reg(vcpu, CPTR_EL2);
440+
441+
if (!vcpu_el2_e2h_is_set(vcpu))
442+
val = translate_cptr_el2_to_cpacr_el1(val);
443+
444+
if (val & CPACR_ELx_TTA)
445+
return BEHAVE_FORWARD_ANY;
446+
447+
return BEHAVE_HANDLE_LOCALLY;
448+
}
449+
413450
#define CCC(id, fn) \
414451
[id - __COMPLEX_CONDITIONS__] = fn
415452

416453
static const complex_condition_check ccc[] = {
417454
CCC(CGT_CNTHCTL_EL1PCTEN, check_cnthctl_el1pcten),
418455
CCC(CGT_CNTHCTL_EL1PTEN, check_cnthctl_el1pten),
456+
CCC(CGT_CPTR_TTA, check_cptr_tta),
419457
};
420458

421459
/*
@@ -1000,6 +1038,59 @@ static const struct encoding_to_trap_config encoding_to_cgt[] __initconst = {
10001038
SR_TRAP(SYS_TRBPTR_EL1, CGT_MDCR_E2TB),
10011039
SR_TRAP(SYS_TRBSR_EL1, CGT_MDCR_E2TB),
10021040
SR_TRAP(SYS_TRBTRG_EL1, CGT_MDCR_E2TB),
1041+
SR_TRAP(SYS_CPACR_EL1, CGT_CPTR_TCPAC),
1042+
SR_TRAP(SYS_AMUSERENR_EL0, CGT_CPTR_TAM),
1043+
SR_TRAP(SYS_AMCFGR_EL0, CGT_CPTR_TAM),
1044+
SR_TRAP(SYS_AMCGCR_EL0, CGT_CPTR_TAM),
1045+
SR_TRAP(SYS_AMCNTENCLR0_EL0, CGT_CPTR_TAM),
1046+
SR_TRAP(SYS_AMCNTENCLR1_EL0, CGT_CPTR_TAM),
1047+
SR_TRAP(SYS_AMCNTENSET0_EL0, CGT_CPTR_TAM),
1048+
SR_TRAP(SYS_AMCNTENSET1_EL0, CGT_CPTR_TAM),
1049+
SR_TRAP(SYS_AMCR_EL0, CGT_CPTR_TAM),
1050+
SR_TRAP(SYS_AMEVCNTR0_EL0(0), CGT_CPTR_TAM),
1051+
SR_TRAP(SYS_AMEVCNTR0_EL0(1), CGT_CPTR_TAM),
1052+
SR_TRAP(SYS_AMEVCNTR0_EL0(2), CGT_CPTR_TAM),
1053+
SR_TRAP(SYS_AMEVCNTR0_EL0(3), CGT_CPTR_TAM),
1054+
SR_TRAP(SYS_AMEVCNTR1_EL0(0), CGT_CPTR_TAM),
1055+
SR_TRAP(SYS_AMEVCNTR1_EL0(1), CGT_CPTR_TAM),
1056+
SR_TRAP(SYS_AMEVCNTR1_EL0(2), CGT_CPTR_TAM),
1057+
SR_TRAP(SYS_AMEVCNTR1_EL0(3), CGT_CPTR_TAM),
1058+
SR_TRAP(SYS_AMEVCNTR1_EL0(4), CGT_CPTR_TAM),
1059+
SR_TRAP(SYS_AMEVCNTR1_EL0(5), CGT_CPTR_TAM),
1060+
SR_TRAP(SYS_AMEVCNTR1_EL0(6), CGT_CPTR_TAM),
1061+
SR_TRAP(SYS_AMEVCNTR1_EL0(7), CGT_CPTR_TAM),
1062+
SR_TRAP(SYS_AMEVCNTR1_EL0(8), CGT_CPTR_TAM),
1063+
SR_TRAP(SYS_AMEVCNTR1_EL0(9), CGT_CPTR_TAM),
1064+
SR_TRAP(SYS_AMEVCNTR1_EL0(10), CGT_CPTR_TAM),
1065+
SR_TRAP(SYS_AMEVCNTR1_EL0(11), CGT_CPTR_TAM),
1066+
SR_TRAP(SYS_AMEVCNTR1_EL0(12), CGT_CPTR_TAM),
1067+
SR_TRAP(SYS_AMEVCNTR1_EL0(13), CGT_CPTR_TAM),
1068+
SR_TRAP(SYS_AMEVCNTR1_EL0(14), CGT_CPTR_TAM),
1069+
SR_TRAP(SYS_AMEVCNTR1_EL0(15), CGT_CPTR_TAM),
1070+
SR_TRAP(SYS_AMEVTYPER0_EL0(0), CGT_CPTR_TAM),
1071+
SR_TRAP(SYS_AMEVTYPER0_EL0(1), CGT_CPTR_TAM),
1072+
SR_TRAP(SYS_AMEVTYPER0_EL0(2), CGT_CPTR_TAM),
1073+
SR_TRAP(SYS_AMEVTYPER0_EL0(3), CGT_CPTR_TAM),
1074+
SR_TRAP(SYS_AMEVTYPER1_EL0(0), CGT_CPTR_TAM),
1075+
SR_TRAP(SYS_AMEVTYPER1_EL0(1), CGT_CPTR_TAM),
1076+
SR_TRAP(SYS_AMEVTYPER1_EL0(2), CGT_CPTR_TAM),
1077+
SR_TRAP(SYS_AMEVTYPER1_EL0(3), CGT_CPTR_TAM),
1078+
SR_TRAP(SYS_AMEVTYPER1_EL0(4), CGT_CPTR_TAM),
1079+
SR_TRAP(SYS_AMEVTYPER1_EL0(5), CGT_CPTR_TAM),
1080+
SR_TRAP(SYS_AMEVTYPER1_EL0(6), CGT_CPTR_TAM),
1081+
SR_TRAP(SYS_AMEVTYPER1_EL0(7), CGT_CPTR_TAM),
1082+
SR_TRAP(SYS_AMEVTYPER1_EL0(8), CGT_CPTR_TAM),
1083+
SR_TRAP(SYS_AMEVTYPER1_EL0(9), CGT_CPTR_TAM),
1084+
SR_TRAP(SYS_AMEVTYPER1_EL0(10), CGT_CPTR_TAM),
1085+
SR_TRAP(SYS_AMEVTYPER1_EL0(11), CGT_CPTR_TAM),
1086+
SR_TRAP(SYS_AMEVTYPER1_EL0(12), CGT_CPTR_TAM),
1087+
SR_TRAP(SYS_AMEVTYPER1_EL0(13), CGT_CPTR_TAM),
1088+
SR_TRAP(SYS_AMEVTYPER1_EL0(14), CGT_CPTR_TAM),
1089+
SR_TRAP(SYS_AMEVTYPER1_EL0(15), CGT_CPTR_TAM),
1090+
SR_TRAP(SYS_POR_EL0, CGT_CPACR_E0POE),
1091+
/* op0=2, op1=1, and CRn<0b1000 */
1092+
SR_RANGE_TRAP(sys_reg(2, 1, 0, 0, 0),
1093+
sys_reg(2, 1, 7, 15, 7), CGT_CPTR_TTA),
10031094
SR_TRAP(SYS_CNTP_TVAL_EL0, CGT_CNTHCTL_EL1PTEN),
10041095
SR_TRAP(SYS_CNTP_CVAL_EL0, CGT_CNTHCTL_EL1PTEN),
10051096
SR_TRAP(SYS_CNTP_CTL_EL0, CGT_CNTHCTL_EL1PTEN),

0 commit comments

Comments
 (0)