Skip to content

Commit f81cb2c

Browse files
Andrew JonesMarc Zyngier
authored andcommitted
KVM: arm64: Don't hide ID registers from userspace
ID registers are RAZ until they've been allocated a purpose, but that doesn't mean they should be removed from the KVM_GET_REG_LIST list. So far we only have one register, SYS_ID_AA64ZFR0_EL1, that is hidden from userspace when its function, SVE, is not present. Expose SYS_ID_AA64ZFR0_EL1 to userspace as RAZ when SVE is not implemented. Removing the userspace visibility checks is enough to reexpose it, as it will already return zero to userspace when SVE is not present. The register already behaves as RAZ for the guest when SVE is not present. Fixes: 7343376 ("KVM: arm64/sve: System register context switch and access support") Reported-by: 张东旭 <xu910121@sina.com> Signed-off-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Cc: stable@vger.kernel.org#v5.2+ Link: https://lore.kernel.org/r/20201105091022.15373-2-drjones@redhat.com
1 parent faf0003 commit f81cb2c

1 file changed

Lines changed: 1 addition & 17 deletions

File tree

arch/arm64/kvm/sys_regs.c

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,16 +1193,6 @@ static unsigned int sve_visibility(const struct kvm_vcpu *vcpu,
11931193
return REG_HIDDEN_USER | REG_HIDDEN_GUEST;
11941194
}
11951195

1196-
/* Visibility overrides for SVE-specific ID registers */
1197-
static unsigned int sve_id_visibility(const struct kvm_vcpu *vcpu,
1198-
const struct sys_reg_desc *rd)
1199-
{
1200-
if (vcpu_has_sve(vcpu))
1201-
return 0;
1202-
1203-
return REG_HIDDEN_USER;
1204-
}
1205-
12061196
/* Generate the emulated ID_AA64ZFR0_EL1 value exposed to the guest */
12071197
static u64 guest_id_aa64zfr0_el1(const struct kvm_vcpu *vcpu)
12081198
{
@@ -1229,9 +1219,6 @@ static int get_id_aa64zfr0_el1(struct kvm_vcpu *vcpu,
12291219
{
12301220
u64 val;
12311221

1232-
if (WARN_ON(!vcpu_has_sve(vcpu)))
1233-
return -ENOENT;
1234-
12351222
val = guest_id_aa64zfr0_el1(vcpu);
12361223
return reg_to_user(uaddr, &val, reg->id);
12371224
}
@@ -1244,9 +1231,6 @@ static int set_id_aa64zfr0_el1(struct kvm_vcpu *vcpu,
12441231
int err;
12451232
u64 val;
12461233

1247-
if (WARN_ON(!vcpu_has_sve(vcpu)))
1248-
return -ENOENT;
1249-
12501234
err = reg_from_user(&val, uaddr, id);
12511235
if (err)
12521236
return err;
@@ -1509,7 +1493,7 @@ static const struct sys_reg_desc sys_reg_descs[] = {
15091493
ID_SANITISED(ID_AA64PFR1_EL1),
15101494
ID_UNALLOCATED(4,2),
15111495
ID_UNALLOCATED(4,3),
1512-
{ SYS_DESC(SYS_ID_AA64ZFR0_EL1), access_id_aa64zfr0_el1, .get_user = get_id_aa64zfr0_el1, .set_user = set_id_aa64zfr0_el1, .visibility = sve_id_visibility },
1496+
{ SYS_DESC(SYS_ID_AA64ZFR0_EL1), access_id_aa64zfr0_el1, .get_user = get_id_aa64zfr0_el1, .set_user = set_id_aa64zfr0_el1, },
15131497
ID_UNALLOCATED(4,5),
15141498
ID_UNALLOCATED(4,6),
15151499
ID_UNALLOCATED(4,7),

0 commit comments

Comments
 (0)