From patchwork Wed Jul 21 19:48:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Moyer X-Patchwork-Id: 12391999 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=-17.2 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=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 BC9B5C636C9 for ; Wed, 21 Jul 2021 19:46:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2686F6121F for ; Wed, 21 Jul 2021 19:46:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2686F6121F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 54B4D6B005D; Wed, 21 Jul 2021 15:46:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4FBDD6B006C; Wed, 21 Jul 2021 15:46:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3EA736B0070; Wed, 21 Jul 2021 15:46:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0020.hostedemail.com [216.40.44.20]) by kanga.kvack.org (Postfix) with ESMTP id 25D506B005D for ; Wed, 21 Jul 2021 15:46:52 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id D20471858C1A2 for ; Wed, 21 Jul 2021 19:46:51 +0000 (UTC) X-FDA: 78387627822.05.89FCEFF Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf02.hostedemail.com (Postfix) with ESMTP id 6C7F970048FA for ; Wed, 21 Jul 2021 19:46:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626896810; 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; bh=Iposy8Z1TCnh8M15iCA0F2J72JUyVRWfZaGAsV1qGv4=; b=FA2Y6C7AGvLYRIHn8Q5gREX+YRzutMMHhWk0sTsGjLJRMb+kSPeNvm5k94BuuytGqD+yWd dyFV+0oi81izS/Kr5ewWn/4dA0K+Rlr7P10MzLfV7ns96+rG/JlygMqu3yB1JUfPN/mgPE dOi1+uOO7JRNiLs9eY+Tvl9XynG5uZg= 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-467-wqIeiGnFON6kOJ28ja8opQ-1; Wed, 21 Jul 2021 15:46:47 -0400 X-MC-Unique: wqIeiGnFON6kOJ28ja8opQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 99887802C80; Wed, 21 Jul 2021 19:46:45 +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 7E69A1970E; Wed, 21 Jul 2021 19:46:44 +0000 (UTC) From: Jeff Moyer To: dan.j.williams@intel.com Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Tony Luck , Borislav Petkov , , , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [patch] x86/pat: pass correct address to sanitize_phys X-PGP-KeyID: 1F78E1B4 X-PGP-CertKey: F6FE 280D 8293 F72C 65FD 5A58 1FF8 A7CA 1F78 E1B4 Date: Wed, 21 Jul 2021 15:48:10 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FA2Y6C7A; spf=none (imf02.hostedemail.com: domain of jmoyer@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=jmoyer@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam02 X-Stat-Signature: qciidp3emsubnfk9uyu6wf7jutdynnfc X-Rspamd-Queue-Id: 6C7F970048FA X-HE-Tag: 1626896811-899256 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: memtype_reserve takes an address range of the form [start, end). It 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()! 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 Reviewed-by: David Hildenbrand --- It might be worth adding a comment, here. If there are any suggestions on what a sane wording would be, I'm all ears. 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); + 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));