lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 01 Jun 2015 16:29:55 +0200
From:	Arnd Bergmann <arnd@...db.de>
To:	Dan Williams <dan.j.williams@...el.com>
Cc:	Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
	"H. Peter Anvin" <hpa@...or.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Ross Zwisler <ross.zwisler@...ux.intel.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Juergen Gross <jgross@...e.com>, X86 ML <x86@...nel.org>,
	"Kani, Toshimitsu" <toshi.kani@...com>,
	"linux-nvdimm@...ts.01.org" <linux-nvdimm@...ts.01.org>,
	Luis Rodriguez <mcgrof@...e.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	Stefan Bader <stefan.bader@...onical.com>,
	Andy Lutomirski <luto@...capital.net>, linux-mm@...ck.org,
	geert@...ux-m68k.org, Henrique de Moraes Holschuh <hmh@....eng.br>,
	Tejun Heo <tj@...nel.org>, Christoph Hellwig <hch@....de>
Subject: Re: [PATCH v2 3/4] arch: introduce memremap()

On Saturday 30 May 2015 14:39:48 Dan Williams wrote:
> On Sat, May 30, 2015 at 2:00 PM, Arnd Bergmann <arnd@...db.de> wrote:
> > On Saturday 30 May 2015, Dan Williams wrote:
> >>
> >> +/*
> >> + * memremap() is "ioremap" for cases where it is known that the resource
> >> + * being mapped does not have i/o side effects and the __iomem
> >> + * annotation is not applicable.
> >> + */
> >> +
> >> +static inline void *memremap(resource_size_t offset, size_t size)
> >> +{
> >> +       return (void __force *) ioremap(offset, size);
> >> +}
> >> +
> >> +static inline void *memremap_nocache(resource_size_t offset, size_t size)
> >> +{
> >> +       return (void __force *) ioremap_nocache(offset, size);
> >> +}
> >> +
> >> +static inline void *memremap_cache(resource_size_t offset, size_t size)
> >> +{
> >> +       return (void __force *) ioremap_cache(offset, size);
> >> +}
> >> +
> >
> > There are architectures on which the result of ioremap is not necessarily
> > a pointer, but instead indicates that the access is to be done through
> > some other indirect access, or require special instructions. I think implementing
> > the memremap() interfaces is generally helpful, but don't rely on the
> > ioremap implementation.
> 
> Is it enough to detect the archs where ioremap() does return an
> otherwise usable pointer and set ARCH_HAS_MEMREMAP, in the first take
> of this introduction?  Regardless, it seems that drivers should have
> Kconfig dependency checks for archs where ioremap can not be used in
> this manner.

Yes, that should work.

> > Adding both cached an uncached versions is also dangerous, because you
> > typically get either undefined behavior or a system checkstop when a
> > single page is mapped both cached and uncached at the same time. This
> > means that doing memremap() or memremap_nocache() on something that
> > may be part of the linear kernel mapping is a bug, and we should probably
> > check for that here.
> 
> Part of the reason for relying on ioremap() was to borrow its internal
> checks to fail attempts that try to remap ranges that are already in
> the kernel linear map.  Hmm, that's a guarantee x86 ioremap gives, but
> maybe that's not universal?

I haven't seen that check elsewhere. IIRC what ioremap() guarantees on ARM
is that if there is an existing boot-time mapping (similar to x86 fixmap,
but more commonly used), we use the same flags in the new ioremap and
override the ones that are provided by the caller.

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ