Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2351871pxb; Mon, 20 Sep 2021 19:48:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzez2HWpC4wuAXRprARvKBDfISkRAYxXyBOPzCpCdG26D8Y4UJA7qGs+Wv97Zz6Ii/XZYkA X-Received: by 2002:a05:6402:3454:: with SMTP id l20mr33076969edc.83.1632192503769; Mon, 20 Sep 2021 19:48:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632192503; cv=none; d=google.com; s=arc-20160816; b=krUCOzwJL3EenAJv1h8UBu7kokgk4cvtjcaFPBTGlgy93AfhwM7YY1GyTW7deTyp71 UPSv+8yOcZc/IJY0UJ79gIfBl0hj7je2Jwr/NCukGli1FWySLqiCgQd/ogfUZf/RtZm6 Z0/saf0twT2TnKzzkPgBCANQiL4fe4No8rdUI4bbgmiY7G4uxnH4TghAWLvkmLid+X0s 4GZqNWD/fVIM8CygDgNRM+FJJVZVKJVNGq5KIQwXU2zRONmaGomTls6Vd/AGdRQMltqq BGEYSp9Mj0beYSHQwPJ1MeZgd9VozvaS4K9xXXgmVe4dV9IuJvhEJTcHaI90Cdv3pOj8 sIww== 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=dN1L0ri4wleHWtBkzjYxd+sXrFPexk+QkAdcWk8tVJm+eJqf6ciaUrc07qytOpMGdB S12V0R5PqktrWEfE6dXvcFa17/7HfzYUeZvjAIxIbNZivxffOVeozBxCRF6ApM59TRWp mgZ+Bt+KbHxYNcmzvE08exhIpPuV1oN0Gq1/S+nvK6x8eTaTwtNTRiNezcmba9O4eOeK SF7HMEMyInU3/lfAfwxRW0Dja6fecpwxmg66Gj4U9xT0DW5MsobN5lJCy4O7Out+xvTB PMQwONlBf03SFFywHQQR+84LSY3Umt8Hken30fY5bP1om6o2KNgDWeM+spmY3FQ3Q4gy jTVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=snZ+xBe5; 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 f16si2106814edf.375.2021.09.20.19.48.00; Mon, 20 Sep 2021 19:48:23 -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=snZ+xBe5; 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 S1379770AbhITSa1 (ORCPT + 99 others); Mon, 20 Sep 2021 14:30:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:44474 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378349AbhITSY0 (ORCPT ); Mon, 20 Sep 2021 14:24:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D8F8B632C8; Mon, 20 Sep 2021 17:25:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632158706; bh=BoLplh6bBEsyA6OP7XqisN8yxIN+vNcJcvH1zW8/lns=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=snZ+xBe5aNxbQ4XK4Wj9V4LTg0DA4graIrcfANIqQn1+d7KL9UlKt1F9CVCQu7UyC x5wMbZaa8EIbGfS2GCfJ0zC+KfTt8WO6oGdUZ3yfT0JXyR1HRUY+DNSXSt3Xk1nkRD nsTqTfLF8YAjo5LmflmengC0M605zTgwMeSryXhM= 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.10 019/122] x86/pat: Pass valid address to sanitize_phys() Date: Mon, 20 Sep 2021 18:43:11 +0200 Message-Id: <20210920163916.406099512@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163915.757887582@linuxfoundation.org> References: <20210920163915.757887582@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));