Skip to content

Commit c9a3c58

Browse files
soccertackMarc Zyngier
authored andcommitted
KVM: arm64: Add the EL1 physical timer access handler
KVM traps on the EL1 phys timer accesses from VMs, but it doesn't handle those traps. This results in terminating VMs. Instead, set a handler for the EL1 phys timer access, and inject an undefined exception as an intermediate step. Signed-off-by: Jintack Lim <jintack@cs.columbia.edu> Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
1 parent f242ada commit c9a3c58

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

arch/arm64/kvm/sys_regs.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,30 @@ static bool access_pmuserenr(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
820820
CRm((0b1100 | (((n) >> 3) & 0x3))), Op2(((n) & 0x7)), \
821821
access_pmu_evtyper, reset_unknown, (PMEVTYPER0_EL0 + n), }
822822

823+
static bool access_cntp_tval(struct kvm_vcpu *vcpu,
824+
struct sys_reg_params *p,
825+
const struct sys_reg_desc *r)
826+
{
827+
kvm_inject_undefined(vcpu);
828+
return true;
829+
}
830+
831+
static bool access_cntp_ctl(struct kvm_vcpu *vcpu,
832+
struct sys_reg_params *p,
833+
const struct sys_reg_desc *r)
834+
{
835+
kvm_inject_undefined(vcpu);
836+
return true;
837+
}
838+
839+
static bool access_cntp_cval(struct kvm_vcpu *vcpu,
840+
struct sys_reg_params *p,
841+
const struct sys_reg_desc *r)
842+
{
843+
kvm_inject_undefined(vcpu);
844+
return true;
845+
}
846+
823847
/*
824848
* Architected system registers.
825849
* Important: Must be sorted ascending by Op0, Op1, CRn, CRm, Op2
@@ -1029,6 +1053,16 @@ static const struct sys_reg_desc sys_reg_descs[] = {
10291053
{ Op0(0b11), Op1(0b011), CRn(0b1101), CRm(0b0000), Op2(0b011),
10301054
NULL, reset_unknown, TPIDRRO_EL0 },
10311055

1056+
/* CNTP_TVAL_EL0 */
1057+
{ Op0(0b11), Op1(0b011), CRn(0b1110), CRm(0b0010), Op2(0b000),
1058+
access_cntp_tval },
1059+
/* CNTP_CTL_EL0 */
1060+
{ Op0(0b11), Op1(0b011), CRn(0b1110), CRm(0b0010), Op2(0b001),
1061+
access_cntp_ctl },
1062+
/* CNTP_CVAL_EL0 */
1063+
{ Op0(0b11), Op1(0b011), CRn(0b1110), CRm(0b0010), Op2(0b010),
1064+
access_cntp_cval },
1065+
10321066
/* PMEVCNTRn_EL0 */
10331067
PMU_PMEVCNTR_EL0(0),
10341068
PMU_PMEVCNTR_EL0(1),

0 commit comments

Comments
 (0)