Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753474AbcD0Pet (ORCPT ); Wed, 27 Apr 2016 11:34:49 -0400 Received: from g4t3428.houston.hp.com ([15.201.208.56]:23665 "EHLO g4t3428.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753087AbcD0Pes (ORCPT ); Wed, 27 Apr 2016 11:34:48 -0400 From: Toshi Kani To: mingo@kernel.org, bp@suse.de, hpa@zytor.com, tglx@linutronix.de Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Toshi Kani , "Luis R. Rodriguez" , Andy Lutomirski , Dan Williams Subject: [PATCH] x86/mm: Add warning to ioremap() for conflicting cache type Date: Wed, 27 Apr 2016 09:25:57 -0600 Message-Id: <1461770757-26817-1-git-send-email-toshi.kani@hpe.com> X-Mailer: git-send-email 2.5.5 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1833 Lines: 52 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(). Drivers should never call ioremap() with a conflicting cache type. This exemption handling may hide possible bugs in drivers. Add a warning message to ioremap() when a conflicting cache type is allowed by is_new_memtype_allowed(). This helps us identify such usages in drivers. There is no change in the behavior. Link: https://lkml.org/lkml/2016/4/16/54 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); + if (!retval) goto err_free_memtype; - } + pcm = new_pcm; }