Message ID | 20240222100412.560961-1-arnd@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-76287-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp149298dyb; Thu, 22 Feb 2024 02:04:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXolwWp37/GyAchlH/h/JAbVtPsshrq9GMw04zo03Hl0o1CG9LzmEm0tg6OyYBcbONwiTUqqFBokQoUIgRzayCoV3giFQ== X-Google-Smtp-Source: AGHT+IEFBPds98T3nnSzZOcdpDSeys4q5qNVfT/4Psw9hfgQ4Ggx1CGo3JrPwTPcuI79PDSrZczm X-Received: by 2002:aa7:c147:0:b0:564:246a:42a with SMTP id r7-20020aa7c147000000b00564246a042amr8019143edp.33.1708596286546; Thu, 22 Feb 2024 02:04:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708596286; cv=pass; d=google.com; s=arc-20160816; b=yWZDMdgm5QbjIMEGAXsFS58qj6bsplwpgsL+Rg43V7FpmJ+mrMRg0/jnMDGg5AY+DK vgjoRY6w4iJzCrbh+fbhvQ9ziucyrRQQOZ3mN609Yy/Kwhwumi7Q1e3+XTRe17MAdlTb k0Xj1KtCShCKb9gaXs7IdEGYhe4yyKNOKpLwVvbRZsMfGZuQous6CDuLIZC8F7QsbUNr XJ33TLovrhdNPeL7TEySb7QWVwqx/d0fzNV79KGcAgKW5U24neqY3LA6oMSRnCDrtPDf 6oAoo31RbolIeAN2qcE2o6nRR2Pxkebv2KtgmTgyU6aGF73fgveZQt/ebCBGxJ8oNn97 zHUw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=siDtcaBXyVnyniRmfclSjdXh3KFyc1J5oQMeDcambEY=; fh=5odU2jBgezux29KzuLwBnhy/DP6twHFqwNrBWBZ1M+4=; b=PtZ0hXSuew5CJobl1eEyfNL7CGTG7IUqIj9cMxsw1lHoJpLYlS32aH0LjJ3qPOE0cB swxWYpOzXYGf4Kb6O6Ys8O8yXsANoXbHYw/5mJBBIInXkzxD4KL8MNcQ3vAkx19ecouW tHXahOUHP619/cQvVdKhEbsyhWsBzJq4IhW8hClOHArCEUK1BjavCtBxCOoa0VGUd607 wTds5TAeYCBoMhM85RsZfJ7OK8vOyEQk0FhYiqUYAwnHwDPXOXGSTqN69Tdr2hNik8B/ C84jpJzwc9LiYEkQ80U4LBIiE9UxxQ2X21xYMHgJCVDq1ONLHCK96jOmRZU4lY762XFw 9kZw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BLFBAFuS; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-76287-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76287-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id v26-20020a50955a000000b0056480179295si3417956eda.409.2024.02.22.02.04.46 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 02:04:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76287-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BLFBAFuS; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-76287-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76287-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 2E36E1F22C15 for <ouuuleilei@gmail.com>; Thu, 22 Feb 2024 10:04:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 090393B182; Thu, 22 Feb 2024 10:04:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BLFBAFuS" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7962638DD9; Thu, 22 Feb 2024 10:04:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708596259; cv=none; b=NzLnU9bC6t+ZWS2R1HXLT+2ZcYDDcBUntiirKGteE8hD9Vl/JMV5jEYUYdv+RwGHXcr0bIy66fVre85ZoQJF9u6gmi7u3X/DDFa+pHtwbiynoL/dveICUk8DP5/BAzdUCDrqr5hs1J6ztlmUQ4TRmulZakmY7PqHxUe0IPsJp8w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708596259; c=relaxed/simple; bh=DY+laaDGWADlgjZ4aCk/y2nEJQIg6zplT0mKVagO2gE=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=lS97D8ngWiBiXsGfHeO6IpXaPe+VmfzfMEeRtPlpgE87wFV0nVeKwCaH/GObn768VtBqBZVRpEtxEDCtkImY5RXatwv27940GDJD+bhzXfqUMueADzR/I88wtYUzShfX488tLwaFG/AdjAy1QldRtDQ0CSwXTEuP2A/tAXyU1po= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BLFBAFuS; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9CB37C433F1; Thu, 22 Feb 2024 10:04:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708596259; bh=DY+laaDGWADlgjZ4aCk/y2nEJQIg6zplT0mKVagO2gE=; h=From:To:Cc:Subject:Date:From; b=BLFBAFuS1IqZtsu4OkQIujYD8nRbeCwV9jGbdUmQMen0qak0DD7GCeTMy/o92a6jR QeG2H/KO+xVYKuqf9XuyYY1IjgvMDAhzJgMIngXNJ8H9CwJHcN+nuee/C55+kXemL2 VFxAPStbgXsHPBhbovrhsre+27Ku68taiwDZQ70gNT4NEfHnqYSd93mlIvsHeaHlBW HreItCp7zMUEGA5rJK6Lj6QSpohfJk77GuHoDmC2XtmdB1t2AeZNdonBBnx9NbcmHt V2ywIcxpAVu3ABiTXPPA9lDMZPnTmZHcXz3EhZpGx+nwz16SuhEUjhaEkGu6I4CtiK kC/MGvB3U6UQQ== From: Arnd Bergmann <arnd@kernel.org> To: David Woodhouse <dwmw2@infradead.org>, Paul Durrant <paul@xen.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: [PATCH] KVM: x86/xen: fix 32-bit pointer cast Date: Thu, 22 Feb 2024 11:03:58 +0100 Message-Id: <20240222100412.560961-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791593059914436364 X-GMAIL-MSGID: 1791593059914436364 |
Series |
KVM: x86/xen: fix 32-bit pointer cast
|
|
Commit Message
Arnd Bergmann
Feb. 22, 2024, 10:03 a.m. UTC
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. 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(-)
Comments
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;
On Thu, Feb 22, 2024, Paul Durrant wrote: > 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. Ya, 'tis a good bot. I squashed this in. Paul/David, new hashes for the affected commits are below. Thanks Arnd! KVM: x86/xen: allow shared_info to be mapped by fixed HVA https://github.com/kvm-x86/linux/commit/b9220d32799a KVM: x86/xen: allow vcpu_info to be mapped by fixed HVA https://github.com/kvm-x86/linux/commit/3991f35805d0 KVM: selftests: map Xen's shared_info page using HVA rather than GFN https://github.com/kvm-x86/linux/commit/9397b5334af1 KVM: selftests: re-map Xen's vcpu_info using HVA rather than GPA https://github.com/kvm-x86/linux/commit/b4dfbfdc9538 KVM: x86/xen: advertize the KVM_XEN_HVM_CONFIG_SHARED_INFO_HVA capability https://github.com/kvm-x86/linux/commit/615451d8cb3f KVM: pfncache: check the need for invalidation under read lock first https://github.com/kvm-x86/linux/commit/9fa336e343b2 KVM: x86/xen: allow vcpu_info content to be 'safely' copied https://github.com/kvm-x86/linux/commit/003d914220c9
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;