From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB9BAC4320E for ; Tue, 10 Aug 2021 06:38:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6EE7061052 for ; Tue, 10 Aug 2021 06:38:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6EE7061052 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linutronix.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id D03F88D0001; Tue, 10 Aug 2021 02:38:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CB43D6B0072; Tue, 10 Aug 2021 02:38:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BA3398D0001; Tue, 10 Aug 2021 02:38:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0103.hostedemail.com [216.40.44.103]) by kanga.kvack.org (Postfix) with ESMTP id 99B1F6B0071 for ; Tue, 10 Aug 2021 02:38:50 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 440D72197F for ; Tue, 10 Aug 2021 06:38:50 +0000 (UTC) X-FDA: 78458218020.20.423A537 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf20.hostedemail.com (Postfix) with ESMTP id AA2C0D0013B6 for ; Tue, 10 Aug 2021 06:38:49 +0000 (UTC) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1628577527; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=bSnzBs68VhjDQ3u78tqjUyQJhwzdf88dCvELM4pNA2Q=; b=uqmqUId9lCIImeFKZg4WDPF8nF0evgk1x6FInFYKkm18Zycnzmpj5pEr4DhNNz2INmH7KW GbX/7uWwYT5PGkW8CsjGn5Cuc1NvrxDQxCv4jwErQGUUnPp2xKyTqXvTSb/C10JT3vsQap l3UV4GxFOEZS0VL3kUFb1KQa3+LCN2xzSNuqQx9ucjv2Rd4SrLG81EXowR9KNFzW33G6a3 83Bt27m1TMuQnumpcsn6rQYMj7SMV01ksbKSmhTXq0AM5JgiJIsN6MvNGVCsicP9WjhYld W0pFNBzpYWRxugJF/xM6qGlgANJ172GVu3mKtMgk1XunpvCibOix8o0HhCN+8Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1628577527; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=bSnzBs68VhjDQ3u78tqjUyQJhwzdf88dCvELM4pNA2Q=; b=b9av0Nd34hog4yyxX9E+8vqOvNpEjZl3IiKG8E4g+Bm+ck63sLPzGl/uuA7Qf7eH5j3U5l /t9DfkNG9il8IfDA== To: Jeff Moyer , dan.j.williams@intel.com Cc: Ingo Molnar , "H. Peter Anvin" , Tony Luck , Borislav Petkov , linux-edac@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [patch] x86/pat: pass correct address to sanitize_phys In-Reply-To: References: Date: Tue, 10 Aug 2021 08:38:46 +0200 Message-ID: <87wnotst1l.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: AA2C0D0013B6 Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=uqmqUId9; dkim=pass header.d=linutronix.de header.s=2020e header.b=b9av0Nd3; dmarc=pass (policy=none) header.from=linutronix.de; spf=pass (imf20.hostedemail.com: domain of tglx@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=tglx@linutronix.de X-Stat-Signature: pnc45uhj1q3r1b7rn6wjhwycwk3pnes6 X-HE-Tag: 1628577529-279308 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Jeff, On Wed, Jul 21 2021 at 15:48, Jeff Moyer wrote: Please write function names with brackets, i.e. sanitize_phys(). > memtype_reserve takes an address range of the form [start, end). It [start, end] > then passes the start and end addresses to sanitize_phys, which is meant > to operate on the inclusive addresses. If end falls at the end of the > physical address space, sanitize_phys will return 0. This can result in > drivers failing to load: > > [ 10.000087] mpt3sas_cm0: unable to map adapter memory! or resource not found > [ 10.000334] mpt3sas_cm0: failure at drivers/scsi/mpt3sas/mpt3sas_scsih.c:10597/_scsih_probe()! Doesn't this trigger the WARN() right below that offending line? > 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 > -- > It might be worth adding a comment, here. If there are any suggestions > on what a sane wording would be, I'm all ears. See below. > diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c > index 3112ca7786ed..482557905294 100644 > --- a/arch/x86/mm/pat/memtype.c > +++ b/arch/x86/mm/pat/memtype.c > @@ -583,7 +583,7 @@ int memtype_reserve(u64 start, u64 end, enum page_cache_mode req_type, > int err = 0; > > start = sanitize_phys(start); > - end = sanitize_phys(end); /* * [start, end] is an exclusive address range, but * sanitize_phys() expects an inclusive end 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)); Thanks, tglx