Skip to content

Commit 700698a

Browse files
Dave MartinMarc Zyngier
authored andcommitted
KVM: arm64/sve: sys_regs: Demote redundant vcpu_has_sve() checks to WARNs
Because of the logic in kvm_arm_sys_reg_{get,set}_reg() and sve_id_visibility(), we should never call {get,set}_id_aa64zfr0_el1() for a vcpu where !vcpu_has_sve(vcpu). To avoid the code giving the impression that it is valid for these functions to be called in this situation, and to help the compiler make the right optimisation decisions, this patch adds WARN_ON() for these cases. Given the way the logic is spread out, this seems preferable to dropping the checks altogether. Suggested-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Dave Martin <Dave.Martin@arm.com> Reviewed-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
1 parent 0323e02 commit 700698a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎arch/arm64/kvm/sys_regs.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@ static int get_id_aa64zfr0_el1(struct kvm_vcpu *vcpu,
11441144
{
11451145
u64 val;
11461146

1147-
if (!vcpu_has_sve(vcpu))
1147+
if (WARN_ON(!vcpu_has_sve(vcpu)))
11481148
return -ENOENT;
11491149

11501150
val = guest_id_aa64zfr0_el1(vcpu);
@@ -1159,7 +1159,7 @@ static int set_id_aa64zfr0_el1(struct kvm_vcpu *vcpu,
11591159
int err;
11601160
u64 val;
11611161

1162-
if (!vcpu_has_sve(vcpu))
1162+
if (WARN_ON(!vcpu_has_sve(vcpu)))
11631163
return -ENOENT;
11641164

11651165
err = reg_from_user(&val, uaddr, id);

0 commit comments

Comments
 (0)