Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp280117pxb; Thu, 25 Feb 2021 02:15:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJwqbiomWS8cBqwmZiFkXiJVlQ09e7dv0B7f/78QlX4AJ26fuZ22I32tbJTfjuaIrdDwI7qe X-Received: by 2002:a17:906:792:: with SMTP id l18mr1917803ejc.198.1614248114499; Thu, 25 Feb 2021 02:15:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614248114; cv=none; d=google.com; s=arc-20160816; b=zjks0syZ3iVkio7bmUCsAZj6mCwVShxar5Ic8xXLTgC+NYyQE2yRXuMi/DbkwIzHp4 3HIHkrp0ffF8YjLj7VNPTV6ZXyxkUZ3IqjZRwXk+xxqYuA4nt/awOrq1jCbdYa18doeg G8ABuKrU9u433CT0yz9/yg7+7BhOxPklErB9WHQZAr8pBrDnevD5CAlFTjtO2sX4bJCx RlngnQwqz+mnbQ2co044UoiV4SV/LBiP3tPHals3Ihl/+yo6FJKOPkfLNCGYKrUZTdcC AH3AMbRIoGcm2/giKMQe/pzrZ7nVGqXzlyT2T+ggkv05RQoeldSH5FeqkhW2JKw/w3II sVsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9ePFjRxXzu0D3W7ZoptBjUo9Rxo9Sundlb9sfDAvb4M=; b=qVJjEZEJ5rzI5qR+saU5d+/AwnJ4YqpNXmd4z5KUfPY8/7AFt/8VqiQLtIGyP7CtNR aTrfSf0xs01y5mD8CeBTCJkMs1GSze1L2KQVMli6q0bfEmc95gRoCksDWY9QM9ojBTB5 +kCaOmHwfSfq5d4qv/X5dN1AuezEFJneJM56NazXA0Wf0oYJZBWKxZFsGN60QLEpYFmS 1hrjVerpvIxmQJvc+AvYQm2EneQQ7pXCuE7PXoVajdwHze6yi/Tp0A2cTzCPZF0v307G +WoyNovbZYgA6bCxMyH7QhFTdOlVwqDptG+gK6269OUh6VrIYOaKKmGmbvxNsPtUVEVq ECkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oPLbp5sm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d17si3144426edp.404.2021.02.25.02.14.51; Thu, 25 Feb 2021 02:15:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oPLbp5sm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234136AbhBYKMl (ORCPT + 99 others); Thu, 25 Feb 2021 05:12:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:34282 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235522AbhBYJ7H (ORCPT ); Thu, 25 Feb 2021 04:59:07 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id C6BEE64E90; Thu, 25 Feb 2021 09:55:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614246923; bh=Sm3SnJimB+QalovorrvuEiMROo1SuO2blGO3LBqtqso=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oPLbp5sm9CQ2Bi0BVasJPEAd3dhNj5Q2xH7ME59dfaSVkq7I8HLQroI6qTPL0VPnZ ethXfCs5RH52JFVwYloUoav087n3pNXuOJuR2Bh2JWUG1HTI63I/t1V1Xupfpu8tv7 SZGcWBVbVAHGH1VcHYbBs9zYvUsowz82PFeKO7Xk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Paolo Bonzini Subject: [PATCH 5.10 17/23] KVM: Use kvm_pfn_t for local PFN variable in hva_to_pfn_remapped() Date: Thu, 25 Feb 2021 10:53:48 +0100 Message-Id: <20210225092517.352823951@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210225092516.531932232@linuxfoundation.org> References: <20210225092516.531932232@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson commit a9545779ee9e9e103648f6f2552e73cfe808d0f4 upstream. Use kvm_pfn_t, a.k.a. u64, for the local 'pfn' variable when retrieving a so called "remapped" hva/pfn pair. In theory, the hva could resolve to a pfn in high memory on a 32-bit kernel. This bug was inadvertantly exposed by commit bd2fae8da794 ("KVM: do not assume PTE is writable after follow_pfn"), which added an error PFN value to the mix, causing gcc to comlain about overflowing the unsigned long. arch/x86/kvm/../../../virt/kvm/kvm_main.c: In function ‘hva_to_pfn_remapped’: include/linux/kvm_host.h:89:30: error: conversion from ‘long long unsigned int’ to ‘long unsigned int’ changes value from ‘9218868437227405314’ to ‘2’ [-Werror=overflow] 89 | #define KVM_PFN_ERR_RO_FAULT (KVM_PFN_ERR_MASK + 2) | ^ virt/kvm/kvm_main.c:1935:9: note: in expansion of macro ‘KVM_PFN_ERR_RO_FAULT’ Cc: stable@vger.kernel.org Fixes: add6a0cd1c5b ("KVM: MMU: try to fix up page faults before giving up") Signed-off-by: Sean Christopherson Message-Id: <20210208201940.1258328-1-seanjc@google.com> Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1888,7 +1888,7 @@ static int hva_to_pfn_remapped(struct vm bool write_fault, bool *writable, kvm_pfn_t *p_pfn) { - unsigned long pfn; + kvm_pfn_t pfn; pte_t *ptep; spinlock_t *ptl; int r;