Skip to content

Commit ff987ff

Browse files
author
Marc Zyngier
committed
KVM: arm64: nv: Add support for FEAT_ATS1A
Handling FEAT_ATS1A (which provides the AT S1E{1,2}A instructions) is pretty easy, as it is just the usual AT without the permission check. This basically amounts to plumbing the instructions in the various dispatch tables, and handling FEAT_ATS1A being disabled in the ID registers. Signed-off-by: Marc Zyngier <[email protected]>
1 parent 8df747f commit ff987ff

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

arch/arm64/include/asm/sysreg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,7 @@
673673
#define OP_AT_S12E1W sys_insn(AT_Op0, 4, AT_CRn, 8, 5)
674674
#define OP_AT_S12E0R sys_insn(AT_Op0, 4, AT_CRn, 8, 6)
675675
#define OP_AT_S12E0W sys_insn(AT_Op0, 4, AT_CRn, 8, 7)
676+
#define OP_AT_S1E2A sys_insn(AT_Op0, 4, AT_CRn, 9, 2)
676677

677678
/* TLBI instructions */
678679
#define TLBI_Op0 1

arch/arm64/kvm/at.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ static enum trans_regime compute_translation_regime(struct kvm_vcpu *vcpu, u32 o
7878
switch (op) {
7979
case OP_AT_S1E2R:
8080
case OP_AT_S1E2W:
81+
case OP_AT_S1E2A:
8182
return vcpu_el2_e2h_is_set(vcpu) ? TR_EL20 : TR_EL2;
8283
break;
8384
default:
@@ -852,6 +853,9 @@ static u64 handle_at_slow(struct kvm_vcpu *vcpu, u32 op, u64 vaddr)
852853
case OP_AT_S1E0W:
853854
perm_fail = !uw;
854855
break;
856+
case OP_AT_S1E1A:
857+
case OP_AT_S1E2A:
858+
break;
855859
default:
856860
BUG();
857861
}
@@ -935,6 +939,9 @@ static u64 __kvm_at_s1e01_fast(struct kvm_vcpu *vcpu, u32 op, u64 vaddr)
935939
case OP_AT_S1E0W:
936940
fail = __kvm_at(OP_AT_S1E0W, vaddr);
937941
break;
942+
case OP_AT_S1E1A:
943+
fail = __kvm_at(OP_AT_S1E1A, vaddr);
944+
break;
938945
default:
939946
WARN_ON_ONCE(1);
940947
fail = true;
@@ -1010,6 +1017,9 @@ void __kvm_at_s1e2(struct kvm_vcpu *vcpu, u32 op, u64 vaddr)
10101017
case OP_AT_S1E2W:
10111018
fail = __kvm_at(OP_AT_S1E1W, vaddr);
10121019
break;
1020+
case OP_AT_S1E2A:
1021+
fail = __kvm_at(OP_AT_S1E1A, vaddr);
1022+
break;
10131023
default:
10141024
WARN_ON_ONCE(1);
10151025
fail = true;

arch/arm64/kvm/emulate-nested.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,7 @@ static const struct encoding_to_trap_config encoding_to_cgt[] __initconst = {
786786
SR_TRAP(OP_AT_S12E1W, CGT_HCR_NV),
787787
SR_TRAP(OP_AT_S12E0R, CGT_HCR_NV),
788788
SR_TRAP(OP_AT_S12E0W, CGT_HCR_NV),
789+
SR_TRAP(OP_AT_S1E2A, CGT_HCR_NV),
789790
SR_TRAP(OP_TLBI_IPAS2E1, CGT_HCR_NV),
790791
SR_TRAP(OP_TLBI_RIPAS2E1, CGT_HCR_NV),
791792
SR_TRAP(OP_TLBI_IPAS2LE1, CGT_HCR_NV),
@@ -867,6 +868,7 @@ static const struct encoding_to_trap_config encoding_to_cgt[] __initconst = {
867868
SR_TRAP(OP_AT_S1E0W, CGT_HCR_AT),
868869
SR_TRAP(OP_AT_S1E1RP, CGT_HCR_AT),
869870
SR_TRAP(OP_AT_S1E1WP, CGT_HCR_AT),
871+
SR_TRAP(OP_AT_S1E1A, CGT_HCR_AT),
870872
SR_TRAP(SYS_ERXPFGF_EL1, CGT_HCR_nFIEN),
871873
SR_TRAP(SYS_ERXPFGCTL_EL1, CGT_HCR_nFIEN),
872874
SR_TRAP(SYS_ERXPFGCDN_EL1, CGT_HCR_nFIEN),

arch/arm64/kvm/sys_regs.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2818,6 +2818,13 @@ static bool handle_at_s1e2(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
28182818
{
28192819
u32 op = sys_insn(p->Op0, p->Op1, p->CRn, p->CRm, p->Op2);
28202820

2821+
/* There is no FGT associated with AT S1E2A :-( */
2822+
if (op == OP_AT_S1E2A &&
2823+
!kvm_has_feat(vcpu->kvm, ID_AA64ISAR2_EL1, ATS1A, IMP)) {
2824+
kvm_inject_undefined(vcpu);
2825+
return false;
2826+
}
2827+
28212828
__kvm_at_s1e2(vcpu, op, p->regval);
28222829

28232830
return true;
@@ -3188,6 +3195,7 @@ static struct sys_reg_desc sys_insn_descs[] = {
31883195
SYS_INSN(AT_S12E1W, handle_at_s12),
31893196
SYS_INSN(AT_S12E0R, handle_at_s12),
31903197
SYS_INSN(AT_S12E0W, handle_at_s12),
3198+
SYS_INSN(AT_S1E2A, handle_at_s1e2),
31913199

31923200
SYS_INSN(TLBI_IPAS2E1IS, handle_ipas2e1is),
31933201
SYS_INSN(TLBI_RIPAS2E1IS, handle_ripas2e1is),
@@ -4645,6 +4653,9 @@ void kvm_calculate_traps(struct kvm_vcpu *vcpu)
46454653
HFGITR_EL2_TLBIRVAAE1OS |
46464654
HFGITR_EL2_TLBIRVAE1OS);
46474655

4656+
if (!kvm_has_feat(kvm, ID_AA64ISAR2_EL1, ATS1A, IMP))
4657+
kvm->arch.fgu[HFGITR_GROUP] |= HFGITR_EL2_ATS1E1A;
4658+
46484659
if (!kvm_has_feat(kvm, ID_AA64MMFR1_EL1, PAN, PAN2))
46494660
kvm->arch.fgu[HFGITR_GROUP] |= (HFGITR_EL2_ATS1E1RP |
46504661
HFGITR_EL2_ATS1E1WP);

0 commit comments

Comments
 (0)