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=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 E3239C432BE for ; Wed, 1 Sep 2021 17:08:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C4B646108B for ; Wed, 1 Sep 2021 17:08:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236271AbhIARJg (ORCPT ); Wed, 1 Sep 2021 13:09:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344682AbhIARJf (ORCPT ); Wed, 1 Sep 2021 13:09:35 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB4BEC061575 for ; Wed, 1 Sep 2021 10:08:37 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id m4so86685pll.0 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=hUakcHRCBcG5mNMsu3ZnrO42uWcl0HVLzLbtT/G+ZhetZxm0H75lMSiBN0qMpnALwR VurKYkLKHy0j9ncSbCEFCenF9Ftb6lqvB1klgrTJooBKsVqMBgAGIA9eQAUgpQWowoYq m0ZSSQ8WC4Y9SIkiWJXiLNH70NL48kJXe6xZ66BzS4GoWL/+i/k4hZ2CRgfEMlArqV0p +bO3wtCRYQu1QO/Rudtt9pzdxQVUwKy2zcQ5ZCj+hB74MAHBxd576D4kYoiDzUbY8Sfw 2xTViqKvk340vSu2gqtRE5s6kIRwyYReYI2fC+XB0ArD/fmh2+h0QYVvFn44H+gKO2MX 1h9w== X-Gm-Message-State: AOAM532jBwc/6DnBt/UbywbFlXq/W7RY/U+vnqIaXCscUd/yDcgsJD+5 70GdCNL1jSLCf51GfR7wXUVm2M724ljl9mvKBHFg+MomEPPrHw== 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 Precedence: bulk List-ID: X-Mailing-List: linux-edac@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