Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp721230pxb; Thu, 2 Sep 2021 13:31:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmDC3Y3alzVGP8xHJoLVONh/5VLcptZwKIimBfEma9TU2QfvGFpR2rwVeOJwd3a7w0KWNy X-Received: by 2002:a92:640d:: with SMTP id y13mr30108ilb.184.1630614679572; Thu, 02 Sep 2021 13:31:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630614679; cv=none; d=google.com; s=arc-20160816; b=XlJBCDg8Jh5ShINHgopVDDrAvGgZvUY8ABPXRpNKEE7gyrnFAN994OQv8y4tJuLthh 6J8gIeA88NvQoR0NJuvbtYhGHMvw76oJDsXZpFROZzwvc+glMsIyVF5UwigyJZJHPiml DfnOIZw6XsWYaMFPSAI9edR4uehqZheiSePIlf+ZjxB3v2rSzS1wiD9tIU0gRoCnf/S8 2UIrhHxF3QjtyY6XBoeyMCeeyXt70feBroaYtWyP5hFsyq8tEiXjQJJrEYkKFsEuTWcj 87qbMDGpf8O7NAztmKzqhMHWZFjWT5wetPqpVXr0V/416h2Dvha+wK+g3eiblmBCl5p9 d7mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=oGZysDwQ3+M7Bx6ShM7b+Caqlrc/7mmenZ/odx/GLyE=; b=E63l7ChqT6ypmsnFqPetJ+7+MVN3FPKmElBECREcypt/fuTNJ1OalAXsNGofp1tIwY gmO1CUyip4XJf0K4sOJ7z5BCbzSiOR7+0DNyJONIKchYLujMXeZYaVlgyu94ofXEQMH3 TCFQgjF9uk/w8E45+bTKSCAGZnStnlUKHw3HBi4dTXZK6/IYDMn63ZW5b5RkhEMlqbFi peEJu7JGKILkHMi1D+dAI9dPnF4tXrj+mKVG/HfEfdpz1SSeyHUFSyM4IekruF3SJQkP 5y3NNw4nJWGiNwzMvIJ6dV1he8sfqvO4ZCM6vGLJ7CIl6ilJgPxlRtaEI1AnFWR0qZHs gLDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=G0lu2HQk; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Q4hP0u1A; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p19si3398829iov.90.2021.09.02.13.31.06; Thu, 02 Sep 2021 13:31:19 -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=@linutronix.de header.s=2020 header.b=G0lu2HQk; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Q4hP0u1A; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244893AbhIBUCu (ORCPT + 99 others); Thu, 2 Sep 2021 16:02:50 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:45980 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231203AbhIBUCp (ORCPT ); Thu, 2 Sep 2021 16:02:45 -0400 Date: Thu, 02 Sep 2021 20:01:44 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1630612905; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oGZysDwQ3+M7Bx6ShM7b+Caqlrc/7mmenZ/odx/GLyE=; b=G0lu2HQkLmToM+x58zvSAYqOBiYQdWCfuyX6URsBKwZw2LSrYRTGrP+hYPGJuZXHlz3Pmo yGLfKjlasTyNKNtkIqGt0rD26epWswp094y9gKIoZfzmX+eDRQohmtoRwAMS9EvmDg5qnp 9VQMURqLcumQT76RLozu1vdQqKNx+BSuJhMxjJXhzqF5EFaL2sZL5tQNsKOtiLAQ5j2dW1 hGQoJSmwifvyhJSAEoUANaUOQAPUWUVhGndUykYKpXh2USKOMRmrv3CONoNB+VLQd/A/f2 04TV3uycoR98lVhxEp6sx0e5zw+EIjAitF15rvxiQ4yrrpslH6E8FeRshTYTEA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1630612905; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oGZysDwQ3+M7Bx6ShM7b+Caqlrc/7mmenZ/odx/GLyE=; b=Q4hP0u1A0bqCqw1nwia0VgeMplvI8A7cCX29+fhtr5IOHv8SNvPN5g5HX7a+f8xOSncrgQ /LU75gi2FppXf/Dw== From: "tip-bot2 for Jeff Moyer" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] x86/pat: Pass valid address to sanitize_phys() Cc: Jeff Moyer , Thomas Gleixner , David Hildenbrand , Dan Williams , stable@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: References: MIME-Version: 1.0 Message-ID: <163061290453.25758.3837946651745818105.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/urgent branch of tip: Commit-ID: aeef8b5089b76852bd84889f2809e69a7cfb414e Gitweb: https://git.kernel.org/tip/aeef8b5089b76852bd84889f2809e69a7cfb414e Author: Jeff Moyer AuthorDate: Wed, 11 Aug 2021 17:07:37 -04:00 Committer: Thomas Gleixner CommitterDate: Thu, 02 Sep 2021 21:53:18 +02:00 x86/pat: Pass valid address to sanitize_phys() 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 --- arch/x86/mm/pat/memtype.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c index 3112ca7..4ba2a3e 100644 --- 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, enum page_cache_mode req_type, 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));