Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp239473rdb; Thu, 22 Feb 2024 02:04:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVldOCs57yTuWRU9yapQfTwlzRyrxgaCUtSDHZ+pCLnHqIxikvEyZiDB5fIRg0QvYASZTENoth8kE5DsU2fnabBOuiRG1Pn/4+F37Sggw== X-Google-Smtp-Source: AGHT+IE8m1xUUzMTX6u2/MmMBp+vzRE73jyFEH8ZRgmwJK+Ofp4JDAxCPBmnuEkOHCsR0QlZ7C4c X-Received: by 2002:a17:906:1854:b0:a3e:73c8:cd27 with SMTP id w20-20020a170906185400b00a3e73c8cd27mr7653983eje.73.1708596270199; Thu, 22 Feb 2024 02:04:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708596270; cv=pass; d=google.com; s=arc-20160816; b=En/A0VpcPtsqyHngq3HIam29I0omBECqng6s3RZYph7YQty4HxZQC9QmnvPNbHphht HNpKM7NftZjfQpkrCYJlptGjnCcYaz2AB+KKwDvW3cAlErZ2a4E58JTZq7ASliwbvR5C LUIW2amiQLf9zV5ebfg1soiyEEHPLa+ChMyBs+icrh/u50Gr7bN2LhC5HBBGVULNfZQk LyqhesHM5W+rKh77gctgx3MtTJz+ChhnAD4R9qG8zBybB7GSo/wxV1vBTZjYiD1AFnyo Nnx2hI7o9nlsDSWq/mliOLNMuwgMH+kEr3yC4TVxmOE5nBZdS47SjmxkeKIuPbFm5Dym TSqQ== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76287-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id lx26-20020a170906af1a00b00a3e95b82a31si3466954ejb.98.2024.02.22.02.04.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 02:04:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76287-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76287-linux.lists.archive=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 EDDF71F251C3 for ; Thu, 22 Feb 2024 10:04:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5349839AC2; Thu, 22 Feb 2024 10:04:20 +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 To: David Woodhouse , Paul Durrant , Sean Christopherson , Paolo Bonzini Cc: Arnd Bergmann , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Jens Axboe , Jan Kara , Christian Brauner , 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: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Arnd Bergmann 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 --- arch/x86/kvm/xen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- 2.39.2