Skip to content

Commit 9db52c7

Browse files
Shannon ZhaoMarc Zyngier
authored andcommitted
arm64: KVM: Add access handler for PMINTENSET and PMINTENCLR register
Since the reset value of PMINTENSET and PMINTENCLR is UNKNOWN, use reset_unknown for its reset handler. Add a handler to emulate writing PMINTENSET or PMINTENCLR register. Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org> Reviewed-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
1 parent 9feb21a commit 9db52c7

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

arch/arm64/include/asm/kvm_host.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ enum vcpu_sysreg {
127127
PMEVTYPER30_EL0 = PMEVTYPER0_EL0 + 30,
128128
PMCCFILTR_EL0, /* Cycle Count Filter Register */
129129
PMCNTENSET_EL0, /* Count Enable Set Register */
130+
PMINTENSET_EL1, /* Interrupt Enable Set Register */
130131

131132
/* 32bit specific registers. Keep them at the end of the range */
132133
DACR32_EL2, /* Domain Access Control Register */

arch/arm64/kvm/sys_regs.c

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,30 @@ static bool access_pmcnten(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
626626
return true;
627627
}
628628

629+
static bool access_pminten(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
630+
const struct sys_reg_desc *r)
631+
{
632+
u64 mask = kvm_pmu_valid_counter_mask(vcpu);
633+
634+
if (!kvm_arm_pmu_v3_ready(vcpu))
635+
return trap_raz_wi(vcpu, p, r);
636+
637+
if (p->is_write) {
638+
u64 val = p->regval & mask;
639+
640+
if (r->Op2 & 0x1)
641+
/* accessing PMINTENSET_EL1 */
642+
vcpu_sys_reg(vcpu, PMINTENSET_EL1) |= val;
643+
else
644+
/* accessing PMINTENCLR_EL1 */
645+
vcpu_sys_reg(vcpu, PMINTENSET_EL1) &= ~val;
646+
} else {
647+
p->regval = vcpu_sys_reg(vcpu, PMINTENSET_EL1) & mask;
648+
}
649+
650+
return true;
651+
}
652+
629653
/* Silly macro to expand the DBG{BCR,BVR,WVR,WCR}n_EL1 registers in one go */
630654
#define DBG_BCR_BVR_WCR_WVR_EL1(n) \
631655
/* DBGBVRn_EL1 */ \
@@ -784,10 +808,10 @@ static const struct sys_reg_desc sys_reg_descs[] = {
784808

785809
/* PMINTENSET_EL1 */
786810
{ Op0(0b11), Op1(0b000), CRn(0b1001), CRm(0b1110), Op2(0b001),
787-
trap_raz_wi },
811+
access_pminten, reset_unknown, PMINTENSET_EL1 },
788812
/* PMINTENCLR_EL1 */
789813
{ Op0(0b11), Op1(0b000), CRn(0b1001), CRm(0b1110), Op2(0b010),
790-
trap_raz_wi },
814+
access_pminten, NULL, PMINTENSET_EL1 },
791815

792816
/* MAIR_EL1 */
793817
{ Op0(0b11), Op1(0b000), CRn(0b1010), CRm(0b0010), Op2(0b000),
@@ -1182,8 +1206,8 @@ static const struct sys_reg_desc cp15_regs[] = {
11821206
{ Op1( 0), CRn( 9), CRm(13), Op2( 1), access_pmu_evtyper },
11831207
{ Op1( 0), CRn( 9), CRm(13), Op2( 2), access_pmu_evcntr },
11841208
{ Op1( 0), CRn( 9), CRm(14), Op2( 0), trap_raz_wi },
1185-
{ Op1( 0), CRn( 9), CRm(14), Op2( 1), trap_raz_wi },
1186-
{ Op1( 0), CRn( 9), CRm(14), Op2( 2), trap_raz_wi },
1209+
{ Op1( 0), CRn( 9), CRm(14), Op2( 1), access_pminten },
1210+
{ Op1( 0), CRn( 9), CRm(14), Op2( 2), access_pminten },
11871211

11881212
{ Op1( 0), CRn(10), CRm( 2), Op2( 0), access_vm_reg, NULL, c10_PRRR },
11891213
{ Op1( 0), CRn(10), CRm( 2), Op2( 1), access_vm_reg, NULL, c10_NMRR },

0 commit comments

Comments
 (0)