Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp804541pxb; Wed, 1 Sep 2021 10:12:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkluZHdeZxKZZBVhWWqsFyVsGOjlyQltqyOXYpqJfDaKdVT/O5uaeddtf39+Drlx19LZct X-Received: by 2002:a17:906:9747:: with SMTP id o7mr511810ejy.486.1630516368594; Wed, 01 Sep 2021 10:12:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630516368; cv=none; d=google.com; s=arc-20160816; b=djqp1Ioe79Vj+SnT3Hvvb/UEC4IWJtcvVzqsjwQZk0iKk+WFNvAiAONYcsGUXDk6JZ Jc2jDHJ93o21phj2NDayDFhM7EvBxhXM77hN0OalBzfgosbP7VMkUiBo1oaME4mTvaLF DUAUHThLQKltL/YQTXCGbM7VRgWXBoYn+xTSxtWjUs3Os1X5QReaZjj1jxywoxi64MuR pFCmgljDLt28f/1tGjUBt7vLJHCbkg+4UhYxrZYgequIDfCUSvcXPQQPzYqxVRDPWCY2 26P8UiYUXssmQ98FrkL6t2jXy6H7FhKtOidqPCW4bEPzOhLGLiFgR/8LotHRWlSkrXk8 PDwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=v2XLK1vGEzZIOUNqlY1IqHLpN0ROAFUqn3UGHO+I7VY=; b=YHuvBvvKtkSOJr+ZKKN1r8WzoNIIl52ytubRj7J2aaJTiWhYZ2FQvVD7um/MBZUCzq CmJn8jD2xfhh828JWC5dpYZ5/hADMcS2lyQbHrPoT1pMRfNltrq+uX74dVuDIhYP8S6m Xw/w9STQUOJg9BcH9dfSWJrXnYSvMylA7m34+6ean2/89sMGkmakkxzgge01uhrpzgWD YNg6XulM+vooDTKvzH25eQoY2LqvKfXpJ2pAEqj4B3hmFvZm1ID7Bj3A+ebQG/eqkF21 bb0TUSfLJ8Ic4NzNo5wlkQcMApdgDq7+uAiqNozk8u9FoKpES0U9R/VKSbddpeqEInKU kPaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=XBA1O65n; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f21si64742edt.530.2021.09.01.10.11.56; Wed, 01 Sep 2021 10:12:48 -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=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=XBA1O65n; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345543AbhIARJg (ORCPT + 99 others); Wed, 1 Sep 2021 13:09:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345538AbhIARJf (ORCPT ); Wed, 1 Sep 2021 13:09:35 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE5D8C061764 for ; Wed, 1 Sep 2021 10:08:37 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id gp20-20020a17090adf1400b00196b761920aso178577pjb.3 for ; Wed, 01 Sep 2021 10:08:37 -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=gf/2M4C2k2TDlW4EZCAx44Ma/ZMKl0Wb4i7kY0gOrQtCgbK7m0jGbVOjlIZauoemKl eDc7xuLDpxC0n4IHso+nAf+cjQ9SKal9im39rE+uweAWZzfHOfOymIoXxRpgpiTcZfkQ 4CqhGYV3ch17O9xE6JzkzDibUmGpV4WfrsndzTUyG/3B2cm3ylztxjQcpDgk3n1gOltq H7EgmYshFvalsh2K2prKI9uMFs60XHIgatgsxmr6RPc49gYH2kBlxY2AFruGOI7aYUEf T0+WXmO9xD/M6gDANH7x5IkTOszDS1d/27C59MxN/zdL6tAh/Mk+UvMxo66/udiP/w14 wQ9w== X-Gm-Message-State: AOAM532Udk/dD5MFWK3AZLmZZfnjLOa1xVA4wssiAJ31VP0LDTgrMvYP C6/JjZgcTJ8Jm8sMHlHNnKI1iqDNFYdqD9+e1kGDAA== 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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