Re: [PATCH] x86/mm: Add warning to ioremap() for conflicting cache type
From: Kani, Toshimitsu
Date: Wed May 25 2016 - 16:06:23 EST
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@xxxxxxxxx
Will do.
> >
> > Signed-off-by: Toshi Kani <toshi.kani@xxxxxxx>
> > Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> > Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> > Cc: "H. Peter Anvin" <hpa@xxxxxxxxx>
> > Cc: Borislav Petkov <bp@xxxxxxx>
> > Cc: Luis R. Rodriguez <mcgrof@xxxxxxxx>
> > Cc: Andy Lutomirski <luto@xxxxxxxxxx>
> > Cc: Dan Williams <dan.j.williams@xxxxxxxxx>
> > ---
> > Â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