Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1350874

Re: Overlapping ioremap() calls, set_memory_*() semantics

From Ingo Molnar <mingo@kernel.org>
Newsgroups linux.kernel
Subject Re: Overlapping ioremap() calls, set_memory_*() semantics
Date 2016-03-05 12:50 +0100
Message-ID <r9iSC-5Al-13@gated-at.bofh.it> (permalink)
References <r8IYO-4Fu-21@gated-at.bofh.it> <r8UwY-4Id-59@gated-at.bofh.it> <r91I6-1ID-23@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


* Toshi Kani <toshi.kani@hpe.com> wrote:

> > So I'd say that since ioremap() in itself is fragile enough, we should work 
> > towards eliminating overlapping ranges.
> > 
> > The thing is, the whole vmap_area logic is based around non-overlapping 
> > ranges, sorted into the vmap_area_root rbtree.
> > 
> > Just check the logic in mm/vmalloc.c::alloc_vmap_area(): it's based on finding 
> > holes in the kernel-virtual allocations. 'Overlapping ranges' is very much not 
> > part of that logic, at least to my understanding.
> > 
> > How are overlapping ioremap()s even possible with that logic? The allocator 
> > searches for holes, not allowing for overlaps. What am I missing?
> > 
> > Could you outline a specific case where it's done intentionally - and the 
> > purpose behind that intention?
> 
> The term "overlapping" is a bit misleading. [...]

A bit? It was totally misleading ...

You meant virtual aliases for the same physical address, and those of course are 
allowed, as long the cache attributes are compatible, that is what the whole 
memtype infrastructure is about, as you yourself note:

> [...]  This is "alias" mapping -- a physical address range is mapped to multiple 
> virtual address ranges.  There is no overlapping in VMA.
> 
> Such alias mappings are used by multiple modules.  For instance, a PMEM range is 
> mapped to the kernel and user spaces.  /dev/mem is another example that creates 
> a user space mapping to a physical address where other mappings may already 
> exist.
> 
> Hence, alias mapping itself is a supported use-case.  However, alias mapping 
> with different cache types is not as it causes undefined behavior.  Therefore, 
> PAT module protects from this case by tracking cache types used for mapping 
> physical ranges.  When a different cache type is requested, 
> is_new_memtype_allowed() checks if the request needs to be failed or can be 
> changed to the existing type.

So where is the problem? The memtype implementation and hence most ioremap() users 
are supposed to be safe. set_memory_*() APIs are supposed to be safe as well, as 
they too go via the memtype API.

> I agree that the current implementation is fragile, and some interfaces skip 
> such check at all, ex. vm_insert_pfn().

Most of those are really just low level interfaces for special cases that skip the 
memtype infrastructure.

Thanks,

	Ingo

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Overlapping ioremap() calls, set_memory_*() semantics Ingo Molnar <mingo@kernel.org> - 2016-03-04 10:50 +0100
  Re: Overlapping ioremap() calls, set_memory_*() semantics Toshi Kani <toshi.kani@hpe.com> - 2016-03-04 18:30 +0100
    Re: Overlapping ioremap() calls, set_memory_*() semantics "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-03-04 20:00 +0100
      Re: Overlapping ioremap() calls, set_memory_*() semantics Toshi Kani <toshi.kani@hpe.com> - 2016-03-04 21:50 +0100
      Re: Overlapping ioremap() calls, set_memory_*() semantics Ingo Molnar <mingo@kernel.org> - 2016-03-05 12:50 +0100
    Re: Overlapping ioremap() calls, set_memory_*() semantics Ingo Molnar <mingo@kernel.org> - 2016-03-05 12:50 +0100
      Re: Overlapping ioremap() calls, set_memory_*() semantics Toshi Kani <toshi.kani@hpe.com> - 2016-03-07 17:20 +0100
        Re: Overlapping ioremap() calls, set_memory_*() semantics Ingo Molnar <mingo@kernel.org> - 2016-03-08 13:20 +0100
          Re: Overlapping ioremap() calls, set_memory_*() semantics Toshi Kani <toshi.kani@hpe.com> - 2016-03-09 00:40 +0100
            Re: Overlapping ioremap() calls, set_memory_*() semantics Ingo Molnar <mingo@kernel.org> - 2016-03-09 10:20 +0100
              Re: Overlapping ioremap() calls, set_memory_*() semantics Toshi Kani <toshi.kani@hpe.com> - 2016-03-11 22:30 +0100
                Re: Overlapping ioremap() calls, set_memory_*() semantics "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-03-16 02:50 +0100
        Re: Overlapping ioremap() calls, set_memory_*() semantics Andy Lutomirski <luto@amacapital.net> - 2016-03-11 07:50 +0100
          Re: Overlapping ioremap() calls, set_memory_*() semantics Toshi Kani <toshi.kani@hpe.com> - 2016-03-11 22:50 +0100
            Re: Overlapping ioremap() calls, set_memory_*() semantics Andy Lutomirski <luto@amacapital.net> - 2016-03-13 02:10 +0100

csiph-web