Skip to content

Commit bb4fa76

Browse files
Sebastian Ottoupton
authored andcommitted
KVM: arm64: show writable masks for feature registers
Instead of using ~0UL provide the actual writable mask for non-id feature registers in the output of the KVM_ARM_GET_REG_WRITABLE_MASKS ioctl. This changes the mask for the CTR_EL0 and CLIDR_EL1 registers. Signed-off-by: Sebastian Ott <[email protected]> Reviewed-by: Eric Auger <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent 2843cae commit bb4fa76

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

arch/arm64/kvm/sys_regs.c

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2486,7 +2486,7 @@ static const struct sys_reg_desc sys_reg_descs[] = {
24862486

24872487
{ SYS_DESC(SYS_CCSIDR_EL1), access_ccsidr },
24882488
{ SYS_DESC(SYS_CLIDR_EL1), access_clidr, reset_clidr, CLIDR_EL1,
2489-
.set_user = set_clidr },
2489+
.set_user = set_clidr, .val = ~CLIDR_EL1_RES0 },
24902490
{ SYS_DESC(SYS_CCSIDR2_EL1), undef_access },
24912491
{ SYS_DESC(SYS_SMIDR_EL1), undef_access },
24922492
{ SYS_DESC(SYS_CSSELR_EL1), access_csselr, reset_unknown, CSSELR_EL1 },
@@ -4046,20 +4046,11 @@ int kvm_vm_ioctl_get_reg_writable_masks(struct kvm *kvm, struct reg_mask_range *
40464046
if (!is_feature_id_reg(encoding) || !reg->set_user)
40474047
continue;
40484048

4049-
/*
4050-
* For ID registers, we return the writable mask. Other feature
4051-
* registers return a full 64bit mask. That's not necessary
4052-
* compliant with a given revision of the architecture, but the
4053-
* RES0/RES1 definitions allow us to do that.
4054-
*/
4055-
if (is_vm_ftr_id_reg(encoding)) {
4056-
if (!reg->val ||
4057-
(is_aa32_id_reg(encoding) && !kvm_supports_32bit_el0()))
4058-
continue;
4059-
val = reg->val;
4060-
} else {
4061-
val = ~0UL;
4049+
if (!reg->val ||
4050+
(is_aa32_id_reg(encoding) && !kvm_supports_32bit_el0())) {
4051+
continue;
40624052
}
4053+
val = reg->val;
40634054

40644055
if (put_user(val, (masks + KVM_ARM_FEATURE_ID_RANGE_INDEX(encoding))))
40654056
return -EFAULT;

0 commit comments

Comments
 (0)