Skip to content

Commit

Permalink
KVM: arm64: Implement vq_present() as a macro
Browse files Browse the repository at this point in the history
This routine is a one-liner and doesn't really need to be function and
can be implemented as a macro.

Suggested-by: Dave Martin <[email protected]>
Reviewed-by: Dave Martin <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
Signed-off-by: Marc Zyngier <[email protected]>
  • Loading branch information
vireshk authored and Marc Zyngier committed Jun 12, 2019
1 parent 623e152 commit 0c529ff
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions arch/arm64/kvm/guest.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,7 @@ static int set_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)

#define vq_word(vq) (((vq) - SVE_VQ_MIN) / 64)
#define vq_mask(vq) ((u64)1 << ((vq) - SVE_VQ_MIN) % 64)

static bool vq_present(
const u64 (*const vqs)[KVM_ARM64_SVE_VLS_WORDS],
unsigned int vq)
{
return (*vqs)[vq_word(vq)] & vq_mask(vq);
}
#define vq_present(vqs, vq) ((vqs)[vq_word(vq)] & vq_mask(vq))

static int get_sve_vls(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
{
Expand Down Expand Up @@ -258,7 +252,7 @@ static int set_sve_vls(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)

max_vq = 0;
for (vq = SVE_VQ_MIN; vq <= SVE_VQ_MAX; ++vq)
if (vq_present(&vqs, vq))
if (vq_present(vqs, vq))
max_vq = vq;

if (max_vq > sve_vq_from_vl(kvm_sve_max_vl))
Expand All @@ -272,7 +266,7 @@ static int set_sve_vls(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
* maximum:
*/
for (vq = SVE_VQ_MIN; vq <= max_vq; ++vq)
if (vq_present(&vqs, vq) != sve_vq_available(vq))
if (vq_present(vqs, vq) != sve_vq_available(vq))
return -EINVAL;

/* Can't run with no vector lengths at all: */
Expand Down

0 comments on commit 0c529ff

Please sign in to comment.