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=-8.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 22CDAC4320A for ; Wed, 1 Sep 2021 17:08:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C49C360F4B for ; Wed, 1 Sep 2021 17:08:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C49C360F4B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 5DCFA8D0002; Wed, 1 Sep 2021 13:08:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 58B438D0001; Wed, 1 Sep 2021 13:08:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 452828D0002; Wed, 1 Sep 2021 13:08:39 -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 335128D0001 for ; Wed, 1 Sep 2021 13:08:39 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id E4B0C181AC9BF for ; Wed, 1 Sep 2021 17:08:38 +0000 (UTC) X-FDA: 78539638716.04.4998BA7 Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by imf12.hostedemail.com (Postfix) with ESMTP id 860CF10000A8 for ; Wed, 1 Sep 2021 17:08:38 +0000 (UTC) Received: by mail-pj1-f46.google.com with SMTP id w19-20020a17090aaf9300b00191e6d10a19so200816pjq.1 for ; Wed, 01 Sep 2021 10:08:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=v2XLK1vGEzZIOUNqlY1IqHLpN0ROAFUqn3UGHO+I7VY=; b=XBA1O65n1gbN6cPrV9+41k+LTAxZPhtbxDBy0Fw52JYq0fkfVH/ULgkMybhenv1Fbe OWmT5fPGUNXNOFCKPxdPryVD2wWXaOgXTniMM6GEVMKWbTZwhCha83BC0q2tidTZeihN bLRdKI98ux6DRbs/QfKl/GhuepsqeURaJd2i8o4V0OUvmrYsHlqRBuhMv6cNansgfYsG uBfoKqGidMO4wM8lRXOXNx6aRteVYMLbg1KAxKcXaTYyiR4GIMvHCFxC+EOY9eH7dbql wMf9kC00jcAZ1mFjd87/VYI+7cJGB6el9GIO7jcXsowkHZoaxtdUByN/9IEilenErD3R RWTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=v2XLK1vGEzZIOUNqlY1IqHLpN0ROAFUqn3UGHO+I7VY=; b=VP/he4TArxzFJ37yVUjzaPen40J99Ncb9Ktyh8j11UJdgpOPme8JGiTlDFy2QO6LTr 2DJBAGvX163QGTJlXb2GwAMYgSJg7j5bXKzGsPouZRKTtV+kRWJDI717FCQ3cWYaiKkQ pN4odiyH8tIwSDSajgqDagi8Cm3220hClWIiRK22bdMxn6UEbuSqwGZWnXyd0ax4kEp4 +ZoluF6kvTECjwPkN9nGDaY53whSZ6cMYriVuH5RHz8kzWvAREX0uTF4arD6X73y/THu 75jlZ2sSj7298zCjNDp5C0QQyB/oXmY0+LZrW/1jb4sTIj0A18T10KFh0HZpxajmY9p8 vAZA== X-Gm-Message-State: AOAM530BFHF227W/DT2EZFE84Sdkmq+8EmNYYN//8boFX03kj8E2MxGX TcO8iaMofz9y97Sc6KSX8b5fqLdE2bLMAm2YCqtc3Q== X-Google-Smtp-Source: ABdhPJzFS2Yz4XqYRzwEigrdW654194TKs8JtrS0A1uDukRefQWLrvwzu4krQD/ftL/oMNqO0O9vxaK3fbV1sRX0sOs= X-Received: by 2002:a17:90a:1991:: with SMTP id 17mr375005pji.149.1630516117376; Wed, 01 Sep 2021 10:08:37 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Dan Williams Date: Wed, 1 Sep 2021 10:08:26 -0700 Message-ID: Subject: Re: [patch, v2] x86/pat: pass valid address to sanitize_phys() To: Jeff Moyer Cc: David Hildenbrand , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Tony Luck , Borislav Petkov , linux-edac@vger.kernel.org, X86 ML , Linux Kernel Mailing List , Linux MM Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=intel-com.20150623.gappssmtp.com header.s=20150623 header.b=XBA1O65n; spf=none (imf12.hostedemail.com: domain of dan.j.williams@intel.com has no SPF policy when checking 209.85.216.46) smtp.mailfrom=dan.j.williams@intel.com; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=intel.com (policy=none) X-Stat-Signature: fi3eyo6od5rqpw9tfbk7epoai3ui178r X-Rspamd-Queue-Id: 860CF10000A8 X-Rspamd-Server: rspam04 X-HE-Tag: 1630516118-344096 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: On Wed, Aug 11, 2021 at 2:06 PM Jeff Moyer wrote: > > 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: > > [ 9.999440] mpt3sas version 29.100.01.00 loaded > [ 9.999817] mpt3sas_cm0: 64 BIT PCI BUS DMA ADDRESSING SUPPORTED, tota= l mem (65413664 kB) > [ 9.999819] ------------[ cut here ]------------ > [ 9.999826] WARNING: CPU: 26 PID: 749 at arch/x86/mm/pat.c:354 reserve= _memtype+0x262/0x450 > [ 9.999828] reserve_memtype failed: [mem 0x3ffffff00000-0xffffffffffff= ffff], req uncached-minus > [ 9.999828] Modules linked in: mpt3sas(+) bnxt_en(+) ahci(+) crct10dif= _pclmul crct10dif_common nvme crc32c_intel libahci nvme_core libata raid_cl= ass scsi_transport_sas devlink drm_panel_orientation_quirks nfit libnvdimm = dm_mirror dm_region_hash dm_log dm_mod > [ 9.999840] CPU: 26 PID: 749 Comm: systemd-udevd Not tainted 3.10.0-10= 77.el7_7.mpt3sas_test008.x86_64 #1 > [ 9.999842] Hardware name: Inspur SA5112M5/SA5112M5, BIOS 4.1.12 02/24= /2021 > [ 9.999843] Call Trace: > [ 9.999851] [] dump_stack+0x19/0x1b > [ 9.999857] [] __warn+0xd8/0x100 > [ 9.999859] [] warn_slowpath_fmt+0x5f/0x80 > [ 9.999861] [] reserve_memtype+0x262/0x450 > [ 9.999867] [] __ioremap_caller+0xf4/0x330 > [ 9.999872] [] ? mpt3sas_base_map_resources+0x151/0= xa60 [mpt3sas] > [ 9.999875] [] ioremap_nocache+0x1a/0x20 > [ 9.999879] [] mpt3sas_base_map_resources+0x151/0xa= 60 [mpt3sas] > [ 9.999884] [] ? __kmalloc+0x1eb/0x230 > [ 9.999889] [] mpt3sas_base_attach+0xf5/0xa50 [mpt3= sas] > [ 9.999894] [] _scsih_probe+0x4ec/0xb00 [mpt3sas] > [ 9.999901] [] local_pci_probe+0x4a/0xb0 > [ 9.999903] [] pci_device_probe+0x109/0x160 > [ 9.999909] [] driver_probe_device+0xc5/0x3e0 > [ 9.999910] [] __driver_attach+0x93/0xa0 > [ 9.999912] [] ? __device_attach+0x50/0x50 > [ 9.999914] [] bus_for_each_dev+0x75/0xc0 > [ 9.999916] [] driver_attach+0x1e/0x20 > [ 9.999918] [] bus_add_driver+0x200/0x2d0 > [ 9.999920] [] driver_register+0x64/0xf0 > [ 9.999922] [] __pci_register_driver+0xa5/0xc0 > [ 9.999924] [] ? 0xffffffffc049afff > [ 9.999928] [] _mpt3sas_init+0x16e/0x1000 [mpt3sas] > [ 9.999933] [] do_one_initcall+0xba/0x240 > [ 9.999940] [] load_module+0x271a/0x2bb0 > [ 9.999946] [] ? ddebug_proc_write+0x100/0x100 > [ 9.999948] [] SyS_init_module+0xef/0x140 > [ 9.999954] [] system_call_fastpath+0x25/0x2a > [ 9.999955] ---[ end trace 6d6eea4438db89ef ]--- > [ 9.999957] ioremap reserve_memtype failed -22 > [ 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()! > > (Note that this warning was from an older distribution kernel, so line > numbers and file names may not line up with the current tree.) > > 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 Reviewed-by: Dan Williams