public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <marc.zyngier@arm.com>
To: "Dave Martin" <Dave.Martin@arm.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>
Cc: kvmarm@lists.cs.columbia.edu,
	linux-arm-kernel@lists.infradead.org,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Ard Biesheuvel" <ard.biesheuvel@linaro.org>,
	"Christoffer Dall" <cdall@kernel.org>,
	"Will Deacon" <will.deacon@arm.com>,
	"Julien Grall" <julien.grall@arm.com>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Okamoto Takayuki" <tokamoto@jp.fujitsu.com>,
	"Zhang Lei" <zhang.lei@jp.fujitsu.com>,
	"Viresh Kumar" <viresh.kumar@linaro.org>,
	kvm <kvm@vger.kernel.org>
Subject: Re: [PATCH] KVM: arm64/sve: Fix vq_present() macro to yield a bool
Date: Thu, 04 Jul 2019 09:20:54 +0100	[thread overview]
Message-ID: <86wogynrbt.wl-marc.zyngier@arm.com> (raw)
In-Reply-To: <1562175770-10952-1-git-send-email-Dave.Martin@arm.com>

+KVM, Paolo and Radim,

Guys, do you mind picking this single patch and sending it to Linus?
That's the only fix left for 5.2. Alternatively, I can send you a pull
request, but it feels overkill.

Either way, please let me know.

Thanks,

	M.

On Wed, 03 Jul 2019 18:42:50 +0100,
Dave Martin <Dave.Martin@arm.com> wrote:
> 
> From: Zhang Lei <zhang.lei@jp.fujitsu.com>
> 
> 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.
> 
> Signed-off-by: Zhang Lei <zhang.lei@jp.fujitsu.com>
> Fixes: 0c529ff789bc ("KVM: arm64: Implement vq_present() as a macro")
> Signed-off-by: Dave Martin <Dave.Martin@arm.com> [commit message rewrite]
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> 
> ---
> 
> Posting this under Zhang Lei's authorship, due to the need to turn this
> fix around quickly.  The fix is as per the original suggestion [1].
> 
> Originally observed with the QEMU KVM SVE support under review:
> https://lists.gnu.org/archive/html/qemu-devel/2019-06/msg04945.html
> 
> Bug reproduced and fix tested on the Arm Fast Model, with
> http://linux-arm.org/git?p=kvmtool-dm.git;a=shortlog;h=refs/heads/sve/v3/head
> (After rerunning util/update_headers.sh.)
> 
> (the --sve-vls command line argument was removed in v4 of the
> kvmtool patches).
> 
> [1] http://lists.infradead.org/pipermail/linux-arm-kernel/2019-July/664633.html
> ---
>  arch/arm64/kvm/guest.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c
> index c2afa79..dfd6264 100644
> --- a/arch/arm64/kvm/guest.c
> +++ b/arch/arm64/kvm/guest.c
> @@ -208,7 +208,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)
> -#define vq_present(vqs, vq) ((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)
>  {
> -- 
> 2.1.4
> 

-- 
Jazz is not dead, it just smells funny.

       reply	other threads:[~2019-07-04  8:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1562175770-10952-1-git-send-email-Dave.Martin@arm.com>
2019-07-04  8:20 ` Marc Zyngier [this message]
2019-07-04 12:24   ` [PATCH] KVM: arm64/sve: Fix vq_present() macro to yield a bool Paolo Bonzini
2019-07-04 12:47     ` Dave Martin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86wogynrbt.wl-marc.zyngier@arm.com \
    --to=marc.zyngier@arm.com \
    --cc=Dave.Martin@arm.com \
    --cc=alex.bennee@linaro.org \
    --cc=ard.biesheuvel@linaro.org \
    --cc=catalin.marinas@arm.com \
    --cc=cdall@kernel.org \
    --cc=julien.grall@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=rkrcmar@redhat.com \
    --cc=tokamoto@jp.fujitsu.com \
    --cc=viresh.kumar@linaro.org \
    --cc=will.deacon@arm.com \
    --cc=zhang.lei@jp.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox