History

KVM: arm64/sve: Fix vq_present() macro to yield a bool

The original implementation of vq_present() relied on aggressive inlining in order for the compiler to know that the code is correct, due to some const-casting issues. This was causing sparse and clang to complain, while GCC compiled cleanly. Commit 0c529ff789bc addressed this problem, but since vq_present() is no longer a function, there is now no implicit casting of the returned value to the return type (bool). In set_sve_vls(), this uncast bit value is compared against a bool, and so may spuriously compare as unequal when both are nonzero. As a result, KVM may reject valid SVE vector length configurations as invalid, and vice versa. Fix it by forcing the returned value to a bool.

Zhang Lei committed 7 years ago

Commit e644fa11 parent bb34e691 file · +1 −1Browse files

Unified · Split

arch/arm64/kvm/guest.c+1−1
@@ -208,7 +208,7 @@ out: · 207 unmodified lines
208208
209209 #define vq_word(vq) (((vq) - SVE_VQ_MIN) / 64)
210210 #define vq_mask(vq) ((u64)1 << ((vq) - SVE_VQ_MIN) % 64)
211−#define vq_present(vqs, vq) ((vqs)[vq_word(vq)] & vq_mask(vq))
211+#define vq_present(vqs, vq) (!!((vqs)[vq_word(vq)] & vq_mask(vq)))
212212
213213 static int get_sve_vls(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
214214 {