Message ID | 20240514072252.5657-5-sebott@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | KVM: arm64: emulation for CTR_EL0 | expand |
Hi Sebastian, On 5/14/24 09:22, Sebastian Ott wrote: > 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 <sebott@redhat.com> > --- > arch/arm64/kvm/sys_regs.c | 19 +++++-------------- > 1 file changed, 5 insertions(+), 14 deletions(-) > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > index 8e8acf3dd9bd..1b6ab483e21e 100644 > --- a/arch/arm64/kvm/sys_regs.c > +++ b/arch/arm64/kvm/sys_regs.c > @@ -2562,7 +2562,7 @@ static const struct sys_reg_desc sys_reg_descs[] = { > > { SYS_DESC(SYS_CCSIDR_EL1), access_ccsidr }, > { SYS_DESC(SYS_CLIDR_EL1), access_clidr, reset_clidr, CLIDR_EL1, > - .set_user = set_clidr }, > + .set_user = set_clidr, .val = ~CLIDR_EL1_RES0 }, > { SYS_DESC(SYS_CCSIDR2_EL1), undef_access }, > { SYS_DESC(SYS_SMIDR_EL1), undef_access }, > { SYS_DESC(SYS_CSSELR_EL1), access_csselr, reset_unknown, CSSELR_EL1 }, > @@ -4121,20 +4121,11 @@ int kvm_vm_ioctl_get_reg_writable_masks(struct kvm *kvm, struct reg_mask_range * > if (!is_feature_id_reg(encoding) || !reg->set_user) > continue; > > - /* > - * For ID registers, we return the writable mask. Other feature > - * registers return a full 64bit mask. That's not necessary > - * compliant with a given revision of the architecture, but the > - * RES0/RES1 definitions allow us to do that. > - */ > - if (is_vm_ftr_id_reg(encoding)) { > - if (!reg->val || > - (is_aa32_id_reg(encoding) && !kvm_supports_32bit_el0())) > - continue; > - val = reg->val; > - } else { > - val = ~0UL; > + if (!reg->val || > + (is_aa32_id_reg(encoding) && !kvm_supports_32bit_el0())) { > + continue; > } > + val = reg->val; > > if (put_user(val, (masks + KVM_ARM_FEATURE_ID_RANGE_INDEX(encoding)))) > return -EFAULT; Reviewed-by: Eric Auger <eric.auger@redhat.com> Eric
diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 8e8acf3dd9bd..1b6ab483e21e 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -2562,7 +2562,7 @@ static const struct sys_reg_desc sys_reg_descs[] = { { SYS_DESC(SYS_CCSIDR_EL1), access_ccsidr }, { SYS_DESC(SYS_CLIDR_EL1), access_clidr, reset_clidr, CLIDR_EL1, - .set_user = set_clidr }, + .set_user = set_clidr, .val = ~CLIDR_EL1_RES0 }, { SYS_DESC(SYS_CCSIDR2_EL1), undef_access }, { SYS_DESC(SYS_SMIDR_EL1), undef_access }, { SYS_DESC(SYS_CSSELR_EL1), access_csselr, reset_unknown, CSSELR_EL1 }, @@ -4121,20 +4121,11 @@ int kvm_vm_ioctl_get_reg_writable_masks(struct kvm *kvm, struct reg_mask_range * if (!is_feature_id_reg(encoding) || !reg->set_user) continue; - /* - * For ID registers, we return the writable mask. Other feature - * registers return a full 64bit mask. That's not necessary - * compliant with a given revision of the architecture, but the - * RES0/RES1 definitions allow us to do that. - */ - if (is_vm_ftr_id_reg(encoding)) { - if (!reg->val || - (is_aa32_id_reg(encoding) && !kvm_supports_32bit_el0())) - continue; - val = reg->val; - } else { - val = ~0UL; + if (!reg->val || + (is_aa32_id_reg(encoding) && !kvm_supports_32bit_el0())) { + continue; } + val = reg->val; if (put_user(val, (masks + KVM_ARM_FEATURE_ID_RANGE_INDEX(encoding)))) return -EFAULT;
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 <sebott@redhat.com> --- arch/arm64/kvm/sys_regs.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-)