Skip to content

Commit 69c19e0

Browse files
Marc Zyngieroupton
authored andcommitted
KVM: arm64: Add TCR2_EL2 to the sysreg arrays
Add the TCR2_EL2 register to the per-vcpu sysreg register array, the sysreg descriptor array, and advertise it as mapped to TCR2_EL1 for NV purposes. Access to this register is conditional based on ID_AA64MMFR3_EL1.TCRX being advertised. Reviewed-by: Joey Gouly <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent 9ae424d commit 69c19e0

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

arch/arm64/include/asm/kvm_host.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ enum vcpu_sysreg {
499499

500500
/* Anything from this can be RES0/RES1 sanitised */
501501
MARKER(__SANITISED_REG_START__),
502+
TCR2_EL2, /* Extended Translation Control Register (EL2) */
502503

503504
/* Any VNCR-capable reg goes after this point */
504505
MARKER(__VNCR_START__),

arch/arm64/kvm/sys_regs.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ static bool get_el2_to_el1_mapping(unsigned int reg,
134134
MAPPED_EL2_SYSREG(ESR_EL2, ESR_EL1, NULL );
135135
MAPPED_EL2_SYSREG(FAR_EL2, FAR_EL1, NULL );
136136
MAPPED_EL2_SYSREG(MAIR_EL2, MAIR_EL1, NULL );
137+
MAPPED_EL2_SYSREG(TCR2_EL2, TCR2_EL1, NULL );
137138
MAPPED_EL2_SYSREG(AMAIR_EL2, AMAIR_EL1, NULL );
138139
MAPPED_EL2_SYSREG(ELR_EL2, ELR_EL1, NULL );
139140
MAPPED_EL2_SYSREG(SPSR_EL2, SPSR_EL1, NULL );
@@ -452,6 +453,18 @@ static bool access_vm_reg(struct kvm_vcpu *vcpu,
452453
return true;
453454
}
454455

456+
static bool access_tcr2_el2(struct kvm_vcpu *vcpu,
457+
struct sys_reg_params *p,
458+
const struct sys_reg_desc *r)
459+
{
460+
if (!kvm_has_feat(vcpu->kvm, ID_AA64MMFR3_EL1, TCRX, IMP)) {
461+
kvm_inject_undefined(vcpu);
462+
return false;
463+
}
464+
465+
return access_rw(vcpu, p, r);
466+
}
467+
455468
static bool access_actlr(struct kvm_vcpu *vcpu,
456469
struct sys_reg_params *p,
457470
const struct sys_reg_desc *r)
@@ -2866,6 +2879,7 @@ static const struct sys_reg_desc sys_reg_descs[] = {
28662879
EL2_REG(TTBR0_EL2, access_rw, reset_val, 0),
28672880
EL2_REG(TTBR1_EL2, access_rw, reset_val, 0),
28682881
EL2_REG(TCR_EL2, access_rw, reset_val, TCR_EL2_RES1),
2882+
EL2_REG(TCR2_EL2, access_tcr2_el2, reset_val, TCR2_EL2_RES1),
28692883
EL2_REG_VNCR(VTTBR_EL2, reset_val, 0),
28702884
EL2_REG_VNCR(VTCR_EL2, reset_val, 0),
28712885

0 commit comments

Comments
 (0)