Skip to content

Commit 989fce6

Browse files
author
Marc Zyngier
committed
KVM: arm64: Simplify handling of CNTKCTL_EL12
We go trough a great deal of effort to map CNTKCTL_EL12 to CNTKCTL_EL1 while hidding this mapping from userspace via a special visibility helper. However, it would be far simpler to just provide an accessor doing the mapping job, removing the need for a visibility helper. With that done, we can also remove the EL12_REG() macro which serves no purpose. Reviewed-by: Oliver Upton <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Zyngier <[email protected]>
1 parent 7c626ce commit 989fce6

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

arch/arm64/kvm/sys_regs.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,15 +2095,6 @@ static unsigned int hidden_user_visibility(const struct kvm_vcpu *vcpu,
20952095
return REG_HIDDEN_USER;
20962096
}
20972097

2098-
#define EL12_REG(name, acc, rst, v) { \
2099-
SYS_DESC(SYS_##name##_EL12), \
2100-
.access = acc, \
2101-
.reset = rst, \
2102-
.reg = name##_EL1, \
2103-
.val = v, \
2104-
.visibility = hidden_user_visibility, \
2105-
}
2106-
21072098
/*
21082099
* Since reset() callback and field val are not used for idregs, they will be
21092100
* used for specific purposes for idregs.
@@ -2211,6 +2202,18 @@ static bool access_spsr(struct kvm_vcpu *vcpu,
22112202
return true;
22122203
}
22132204

2205+
static bool access_cntkctl_el12(struct kvm_vcpu *vcpu,
2206+
struct sys_reg_params *p,
2207+
const struct sys_reg_desc *r)
2208+
{
2209+
if (p->is_write)
2210+
__vcpu_sys_reg(vcpu, CNTKCTL_EL1) = p->regval;
2211+
else
2212+
p->regval = __vcpu_sys_reg(vcpu, CNTKCTL_EL1);
2213+
2214+
return true;
2215+
}
2216+
22142217
static u64 reset_hcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
22152218
{
22162219
u64 val = r->val;
@@ -2798,7 +2801,7 @@ static const struct sys_reg_desc sys_reg_descs[] = {
27982801
EL2_REG_VNCR(CNTVOFF_EL2, reset_val, 0),
27992802
EL2_REG(CNTHCTL_EL2, access_rw, reset_val, 0),
28002803

2801-
EL12_REG(CNTKCTL, access_rw, reset_val, 0),
2804+
{ SYS_DESC(SYS_CNTKCTL_EL12), access_cntkctl_el12 },
28022805

28032806
EL2_REG(SP_EL2, NULL, reset_unknown, 0),
28042807
};

0 commit comments

Comments
 (0)