mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paul Durrant <xadimgnik@gmail.com>
To: Arnd Bergmann <arnd@kernel.org>,
	David Woodhouse <dwmw2@infradead.org>,
	Sean Christopherson <seanjc@google.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	Jens Axboe <axboe@kernel.dk>, Jan Kara <jack@suse.cz>,
	Christian Brauner <brauner@kernel.org>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: x86/xen: fix 32-bit pointer cast
Date: Thu, 22 Feb 2024 10:14:38 +0000	[thread overview]
Message-ID: <c8c37018-8681-458f-96b7-82bae88ebcd3@xen.org> (raw)
In-Reply-To: <20240222100412.560961-1-arnd@kernel.org>

On 22/02/2024 10:03, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> shared_info.hva is a 64-bit variable, so casting to a pointer causes
> a warning in 32-bit builds:
> 
> arch/x86/kvm/xen.c: In function 'kvm_xen_hvm_set_attr':
> arch/x86/kvm/xen.c:660:45: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
>    660 |                         void __user * hva = (void *)data->u.shared_info.hva;
> 
> Replace the cast with a u64_to_user_ptr() call that does the right thing.

Thanks Arnd. I'd just got a ping from kernel test robot for lack of 
__user qualifier in the cast 
(https://lore.kernel.org/oe-kbuild-all/202402221721.mhF8MNVh-lkp@intel.com/), 
which this should also fix.

> 
> Fixes: 01a871852b11 ("KVM: x86/xen: allow shared_info to be mapped by fixed HVA")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>   arch/x86/kvm/xen.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 

Reviewed-by: Paul Durrant <paul@xen.org>

> diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c
> index 01c0fd138d2f..8a04e0ae9245 100644
> --- a/arch/x86/kvm/xen.c
> +++ b/arch/x86/kvm/xen.c
> @@ -657,7 +657,7 @@ int kvm_xen_hvm_set_attr(struct kvm *kvm, struct kvm_xen_hvm_attr *data)
>   						     gfn_to_gpa(gfn), PAGE_SIZE);
>   			}
>   		} else {
> -			void __user * hva = (void *)data->u.shared_info.hva;
> +			void __user * hva = u64_to_user_ptr(data->u.shared_info.hva);
>   
>   			if (!PAGE_ALIGNED(hva) || !access_ok(hva, PAGE_SIZE)) {
>   				r = -EINVAL;


  reply	other threads:[~2024-02-22 10:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-22 10:03 Arnd Bergmann
2024-02-22 10:14 ` Paul Durrant [this message]
2024-02-22 15:04   ` Sean Christopherson

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=c8c37018-8681-458f-96b7-82bae88ebcd3@xen.org \
    --to=xadimgnik@gmail.com \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=bp@alien8.de \
    --cc=brauner@kernel.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=dwmw2@infradead.org \
    --cc=hpa@zytor.com \
    --cc=jack@suse.cz \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=paul@xen.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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

all inboxes | Powered by JetHome®