Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2352899pxb; Mon, 20 Sep 2021 19:50:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXky0qgU76jgKmV52Sn71ALYEGsMk1fz7fxu5Q/NNXXAxRGVUYTckp2VpxbAbpnaLa6TfH X-Received: by 2002:a02:22cf:: with SMTP id o198mr5409162jao.37.1632192630023; Mon, 20 Sep 2021 19:50:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632192630; cv=none; d=google.com; s=arc-20160816; b=XERk4v4nrMsfW7Cr+M1or+rRYivQLWYYAR4RV+p2p/fasgsbvoqA5dzrGZRz9feOc2 hyu5fcKrLTYnrUuiCkc3MhFGn/y/slEU4Fk5HX3eBg8sp5waLJ5+XJvE6/CbE8QjhuEO 70tAsYFBimTtRMI7zIhhSj6ptp5P0ByUauSLuCJfm5kkdUpe+uIIpKSfslqXFSun2umG Z/jpfqUpIfYajX0EfwknZnw2wGi5q1FG7/Xsvw/IfNI/mWAtBZFc28s1T1jlpmb0UsNP aMO/RYzBhWkytlZj7OmKbnXH59Ljtg6EYmuQEuvu8bkHmQRpcKGlLar8t7Ema98ECKFj eqhA== 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=Lw2FJeo8NRl/Z6/CJT22K7ZYopRCCVVZriu/k5DWIPA=; b=nedXC3D3vl2XO2v1vql1X3mThY0VxDRiR6cFmIqc3Z3vbjEXcgGHXvakIC2E5b+8sD qa43CNHWTA8gGbsWGaQju68V/qtMukhcNMqAGG+mV553Yubc1dQTpEArG1CT01gySM3W RP+gzzbcdI0gXMCda+FAaJ7Oo6dC4JkQQwSuLdOEnZDxeNEkkM1EDmEBY45poRr3g4f9 qIXh+Kpy1JtOKYeTd3eCA8q+FH3qZzYQPDqDp/RBEj92lYt+uWp8wfwbcD7atMTW0roN TcKRZnDivbjklm9gYY6lx3cLgb1Ly0Pzm2PnFf3O3bAKOxqRp0XZGhXdh9WkZfXnB+nY F/ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dyjH4lGB; 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 g23si13515324jad.40.2021.09.20.19.50.17; Mon, 20 Sep 2021 19:50:30 -0700 (PDT) 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=dyjH4lGB; 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 S245598AbhITSoy (ORCPT + 99 others); Mon, 20 Sep 2021 14:44:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:56474 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382498AbhITSka (ORCPT ); Mon, 20 Sep 2021 14:40:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B018261504; Mon, 20 Sep 2021 17:31:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632159079; bh=BoLplh6bBEsyA6OP7XqisN8yxIN+vNcJcvH1zW8/lns=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dyjH4lGBSRpzKUaaVHdhWEuD2CVvN2wEZQXRjaeaeytc167SYD/MiYvsQ4Msigga6 bpcV607MW+12J1YzFvqxqc9qAw2/eRF3cj7epKbJyyGm92LdkgajUDAWWGtf/NyHK7 uIJIozdXzmiH9jiTZ5HR6dvJoxpxZb4bxHt7IKnM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jeff Moyer , Thomas Gleixner , David Hildenbrand , Dan Williams Subject: [PATCH 5.14 034/168] x86/pat: Pass valid address to sanitize_phys() Date: Mon, 20 Sep 2021 18:42:52 +0200 Message-Id: <20210920163922.771618656@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163921.633181900@linuxfoundation.org> References: <20210920163921.633181900@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: Jeff Moyer commit aeef8b5089b76852bd84889f2809e69a7cfb414e upstream. The end address passed to memtype_reserve() is handed directly to sanitize_phys(). However, end is exclusive and sanitize_phys() expects an inclusive address. If end falls at the end of the physical address space, sanitize_phys() will return 0. This can result in drivers failing to load, and the following warning: WARNING: CPU: 26 PID: 749 at arch/x86/mm/pat.c:354 reserve_memtype+0x262/0x450 reserve_memtype failed: [mem 0x3ffffff00000-0xffffffffffffffff], req uncached-minus Call Trace: [] reserve_memtype+0x262/0x450 [] ioremap_nocache+0x1a/0x20 [] mpt3sas_base_map_resources+0x151/0xa60 [mpt3sas] [] mpt3sas_base_attach+0xf5/0xa50 [mpt3sas] ---[ end trace 6d6eea4438db89ef ]--- ioremap reserve_memtype failed -22 mpt3sas_cm0: unable to map adapter memory! or resource not found mpt3sas_cm0: failure at drivers/scsi/mpt3sas/mpt3sas_scsih.c:10597/_scsih_probe()! Fix this by passing the inclusive end address to sanitize_phys(). Fixes: 510ee090abc3 ("x86/mm/pat: Prepare {reserve, free}_memtype() for "decoy" addresses") Signed-off-by: Jeff Moyer Signed-off-by: Thomas Gleixner Reviewed-by: David Hildenbrand Reviewed-by: Dan Williams Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/x49o8a3pu5i.fsf@segfault.boston.devel.redhat.com Signed-off-by: Greg Kroah-Hartman --- arch/x86/mm/pat/memtype.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/arch/x86/mm/pat/memtype.c +++ b/arch/x86/mm/pat/memtype.c @@ -583,7 +583,12 @@ int memtype_reserve(u64 start, u64 end, int err = 0; start = sanitize_phys(start); - end = sanitize_phys(end); + + /* + * The end address passed into this function is exclusive, but + * sanitize_phys() expects an inclusive address. + */ + end = sanitize_phys(end - 1) + 1; if (start >= end) { WARN(1, "%s failed: [mem %#010Lx-%#010Lx], req %s\n", __func__, start, end - 1, cattr_name(req_type));