From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752042AbcEYUGU (ORCPT ); Wed, 25 May 2016 16:06:20 -0400 Received: from mail-bn1bon0140.outbound.protection.outlook.com ([157.56.111.140]:46317 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751017AbcEYUGS (ORCPT ); Wed, 25 May 2016 16:06:18 -0400 From: "Kani, Toshimitsu" To: "mcgrof@kernel.org" CC: "mingo@kernel.org" , "linux-kernel@vger.kernel.org" , "hch@infradead.org" , "bp@suse.de" , "tglx@linutronix.de" , "x86@kernel.org" , "dan.j.williams@intel.com" , "hpa@zytor.com" , "paulmck@linux.vnet.ibm.com" , "will.deacon@arm.com" , "luto@kernel.org" , "julia.lawall@lip6.fr" , "linux-arch@vger.kernel.org" , "benh@kernel.crashing.org" Subject: Re: [PATCH] x86/mm: Add warning to ioremap() for conflicting cache type Thread-Topic: [PATCH] x86/mm: Add warning to ioremap() for conflicting cache type Thread-Index: AQHRoJpXZ/CwSEU39U2SG9FOsedo5Z/I6BgAgAFM3wA= Date: Wed, 25 May 2016 19:34:27 +0000 Message-ID: <1464204282.3504.70.camel@hpe.com> References: <1461770757-26817-1-git-send-email-toshi.kani@hpe.com> <20160524233318.GC11948@wotan.suse.de> In-Reply-To: <20160524233318.GC11948@wotan.suse.de> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=hpe.com; x-originating-ip: [15.219.163.9] x-ms-office365-filtering-correlation-id: 0e28e536-f5c3-47f4-7f03-08d384d395dd x-microsoft-exchange-diagnostics: 1;CS1PR84MB0007;5:CfoDyZXZQ0kxYWHHQmy9l8AYh8Cpk/inqx+bnjhhDoAzvoQiroMttYx8CA6IdS8aedrNLKMiqBMdqauSvlkDcKiIKARPC5l1YXyDPKV1BJyCEUt0sNMQ7U5aaoKBLKV1C4fUmR1hIgzCI8yP+xDpXg==;24:HYKemXKW+KLKeSvt3B3Jh5HCsxdwVcTLbnuRGL8p7vJQf16d2yXVSZlnzqsmiZnP3lt7R+FDOxlBU5Snwc0YTz9foQYSrlCovWojrWr0df0=;7:Y/bW0qeSP3WsAxJffDf0hw+HVyb6Vh+gZ9rV+ktuNRk+1WEI/X2ckD5LSST1HgGb3j7rh4+05hXMwAvMmI4mR+LZWaipMjtGIEtLm2i9qAsWCqmqaase57777IiqXpdK2Q0Y1PRjE2G5G6hZ/ene4PBKnhys/Aqfq/ukIkmHe95blQpGBFVlm5ac3OZZMUmq x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CS1PR84MB0007; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046);SRVR:CS1PR84MB0007;BCL:0;PCL:0;RULEID:;SRVR:CS1PR84MB0007; x-forefront-prvs: 09538D3531 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(24454002)(377424004)(2906002)(2501003)(586003)(4326007)(2950100001)(2900100001)(50986999)(122556002)(3846002)(1730700003)(5008740100001)(77096005)(10400500002)(1220700001)(99286002)(6116002)(102836003)(5640700001)(15975445007)(3660700001)(3280700002)(81166006)(8676002)(110136002)(19580405001)(19580395003)(189998001)(92566002)(106116001)(2351001)(33646002)(76176999)(36756003)(87936001)(54356999)(103116003)(5002640100001)(8936002)(66066001)(5004730100002)(11100500001);DIR:OUT;SFP:1102;SCL:1;SRVR:CS1PR84MB0007;H:CS1PR84MB0005.NAMPRD84.PROD.OUTLOOK.COM;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" Content-ID: <7A0BA46F7D346840869B9ABEB05AE871@NAMPRD84.PROD.OUTLOOK.COM> MIME-Version: 1.0 X-OriginatorOrg: hpe.com X-MS-Exchange-CrossTenant-originalarrivaltime: 25 May 2016 19:34:27.5408 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-Transport-CrossTenantHeadersStamped: CS1PR84MB0007 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id u4PK6QBt007355 On Wed, 2016-05-25 at 01:33 +0200, Luis R. Rodriguez wrote: > On Wed, Apr 27, 2016 at 09:25:57AM -0600, Toshi Kani wrote: > > > > On x86, ioremap() and remap_pfn_range() fail on conflicting cache > > type of an alias mapping request only if the case is not allowed > > by the rule set in is_new_memtype_allowed(). While this exemption > > is necessary for remap_pfn_range() called for /dev/mem mappings, > > it is not necessary for ioremap(). > > The wording here is a bit unclear. How about: I will update the change log according to your suggestions. > > Link: https://lkml.org/lkml/2016/4/16/54 > > lkml.org references should be avoided, we have no control over > that domain. Please instead use: > > http://lkml.kernel.org/r/20160416092018.GA8453@gmail.com Will do. > > > > Signed-off-by: Toshi Kani > > Cc: Ingo Molnar > > Cc: Thomas Gleixner > > Cc: "H. Peter Anvin" > > Cc: Borislav Petkov > > Cc: Luis R. Rodriguez > > Cc: Andy Lutomirski > > Cc: Dan Williams > > --- > >  arch/x86/mm/ioremap.c |   10 ++++++---- > >  1 file changed, 6 insertions(+), 4 deletions(-) > > > > diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c > > index 0d8d53d..16c5887 100644 > > --- a/arch/x86/mm/ioremap.c > > +++ b/arch/x86/mm/ioremap.c > > @@ -138,14 +138,16 @@ static void __iomem > > *__ioremap_caller(resource_size_t phys_addr, > >   } > >   > >   if (pcm != new_pcm) { > > - if (!is_new_memtype_allowed(phys_addr, size, pcm, > > new_pcm)) { > > - printk(KERN_ERR > > - "ioremap error for 0x%llx-0x%llx, requested 0x%x, got > > 0x%x\n", > > + retval = is_new_memtype_allowed(phys_addr, size, pcm, > > new_pcm); > > + pr_err( > > +     "ioremap %s for 0x%llx-0x%llx, requested 0x%x, got > > 0x%x\n", > > + retval ? "warning" : "error", > >   (unsigned long long)phys_addr, > >   (unsigned long long)(phys_addr + > > size), > >   pcm, new_pcm); > > This doesn't really make it humanly consumable, a pcm_to_str may help, > such use already exists but not generalized see pat_get_cache_mode(). OK, I will add a pcm_to_str. > > > > + if (!retval) > >   goto err_free_memtype; > > - } > > + > >   pcm = new_pcm; > >   } > > In the future we may be able to proactively hunt for these invalid uses > semantically but to do so we need first a demo driver with all known > possible bugs we can think of. Right. Thanks, -Toshi