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=-16.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, 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=unavailable 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 D52D9C4338F for ; Tue, 10 Aug 2021 19:21:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7042160F94 for ; Tue, 10 Aug 2021 19:21:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7042160F94 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id E07DE6B0071; Tue, 10 Aug 2021 15:21:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D91D18D0001; Tue, 10 Aug 2021 15:21:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C32116B0073; Tue, 10 Aug 2021 15:21:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0163.hostedemail.com [216.40.44.163]) by kanga.kvack.org (Postfix) with ESMTP id A7C9D6B0071 for ; Tue, 10 Aug 2021 15:21:04 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 4EEF022C06 for ; Tue, 10 Aug 2021 19:21:04 +0000 (UTC) X-FDA: 78460138848.25.52F3889 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf12.hostedemail.com (Postfix) with ESMTP id AB2381005595 for ; Tue, 10 Aug 2021 19:21:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628623262; 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=UKz5RODz5prskKuvBZqrHvPYmgz3FaALdg2u0GEXeAk=; b=ZnFfTXm+qi3jkH2GjvkecPaF1OXCDece+9jAqGLbDLFpv5sB3Z1qoGW1Nycu9LtIGjgHDt z2TjdEoC7EYSu8HSQU+oF/fMmFc6KGaY9N5jtb6cyP/fyzOGzyhAOOkGFWb091KGYD5UPd CmN0Fm1WYLrN8RdmWtjN6fVkyT08AYk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-604-zMfGCzHEMwWOtYJbUDazOA-1; Tue, 10 Aug 2021 15:20:58 -0400 X-MC-Unique: zMfGCzHEMwWOtYJbUDazOA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 34E05190B2A0; Tue, 10 Aug 2021 19:20:56 +0000 (UTC) Received: from segfault.boston.devel.redhat.com (segfault.boston.devel.redhat.com [10.19.60.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0B4905C1A1; Tue, 10 Aug 2021 19:20:54 +0000 (UTC) From: Jeff Moyer To: Thomas Gleixner Cc: dan.j.williams@intel.com, 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 References: <87wnotst1l.ffs@tglx> X-PGP-KeyID: 1F78E1B4 X-PGP-CertKey: F6FE 280D 8293 F72C 65FD 5A58 1FF8 A7CA 1F78 E1B4 Date: Tue, 10 Aug 2021 15:22:19 -0400 In-Reply-To: <87wnotst1l.ffs@tglx> (Thomas Gleixner's message of "Tue, 10 Aug 2021 08:38:46 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: AB2381005595 Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZnFfTXm+; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf12.hostedemail.com: domain of jmoyer@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=jmoyer@redhat.com X-Stat-Signature: 31nfw3jkrmyh46spynktzbigjh6r93jb X-HE-Tag: 1628623262-144979 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: Thomas Gleixner writes: > Jeff, > > On Wed, Jul 21 2021 at 15:48, Jeff Moyer wrote: > > Please write function names with brackets, i.e. sanitize_phys(). OK, will do. >> memtype_reserve takes an address range of the form [start, end). It > > [start, end] Start is inclusive, end is exclusive, so start <= x < end. I used the notation found here: https://en.wikipedia.org/wiki/Interval_(mathematics) If that's too confusing, I can stick to inclusive vs exclusive verbiage. >> 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? It does. I'll include the warning message in the v2 posting. >> 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 > */ That works for me (modulo the interval notation), thanks for the suggestion. Thanks! Jeff