Skip to content

Commit 5a43097

Browse files
Alexandru EliseiMarc Zyngier
authored andcommitted
KVM: arm64: Use get_raz_reg() for userspace reads of PMSWINC_EL0
PMSWINC_EL0 is a write-only register and was initially part of the VCPU register state, but was later removed in commit 7a3ba30 ("KVM: arm64: Remove PMSWINC_EL0 shadow register"). To prevent regressions, the register was kept accessible from userspace as Read-As-Zero (RAZ). The read function that is used to handle userspace reads of this register is get_raz_id_reg(), which, while technically correct, as it returns 0, it is not semantically correct, as PMSWINC_EL0 is not an ID register as the function name suggests. Add a new function, get_raz_reg(), to use it as the accessor for PMSWINC_EL0, as to not conflate get_raz_id_reg() to handle other types of registers. No functional change intended. Signed-off-by: Alexandru Elisei <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 00d5101 commit 5a43097

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

arch/arm64/kvm/sys_regs.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,15 @@ static int set_raz_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
12851285
return __set_id_reg(vcpu, rd, uaddr, true);
12861286
}
12871287

1288+
static int get_raz_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
1289+
const struct kvm_one_reg *reg, void __user *uaddr)
1290+
{
1291+
const u64 id = sys_reg_to_index(rd);
1292+
const u64 val = 0;
1293+
1294+
return reg_to_user(uaddr, &val, id);
1295+
}
1296+
12881297
static int set_wi_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
12891298
const struct kvm_one_reg *reg, void __user *uaddr)
12901299
{
@@ -1647,7 +1656,7 @@ static const struct sys_reg_desc sys_reg_descs[] = {
16471656
* previously (and pointlessly) advertised in the past...
16481657
*/
16491658
{ PMU_SYS_REG(SYS_PMSWINC_EL0),
1650-
.get_user = get_raz_id_reg, .set_user = set_wi_reg,
1659+
.get_user = get_raz_reg, .set_user = set_wi_reg,
16511660
.access = access_pmswinc, .reset = NULL },
16521661
{ PMU_SYS_REG(SYS_PMSELR_EL0),
16531662
.access = access_pmselr, .reset = reset_pmselr, .reg = PMSELR_EL0 },

0 commit comments

Comments
 (0)