From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Linus Torvalds <torvalds@linux-foundation.org>,
Jiri Kosina <jikos@kernel.org>
Cc: "Jürgen Groß" <jgross@suse.com>,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
"Michal Hocko" <mhocko@suse.com>,
"Naoya Horiguchi" <n-horiguchi@ah.jp.nec.com>,
"Michael Ellerman" <mpe@ellerman.id.au>,
"Will Deacon" <will.deacon@arm.com>
Subject: Re: Access to non-RAM pages
Date: Mon, 03 Sep 2018 10:48:05 +1000 [thread overview]
Message-ID: <a1980256cf3d2ea8e91707fcda7cf141b27a212d.camel@kernel.crashing.org> (raw)
In-Reply-To: <CA+55aFyOSLEbiNvPoHkHe8WXae_aJiS+jsnubG8Xk0CYw8U4uw@mail.gmail.com>
On Sat, 2018-09-01 at 11:06 -0700, Linus Torvalds wrote:
> [ Adding a few new people the the cc.
>
> The issue is the worry about software-speculative accesses (ie
> things like CONFIG_DCACHE_WORD_ACCESS - not talking about the hw
> speculation now) accessing past RAM into possibly contiguous IO ]
>
> On Sat, Sep 1, 2018 at 10:27 AM Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
> >
> > If you have a machine with RAM that touches IO, you need to disable
> > the last page, exactly the same way we disable and marked reserved the
> > first page at zero.
So I missed the departure of that train ... stupid question, with
CONFIG_DCACHE_WORD_ACCESS, if that can be unaligned (I assume it can),
what prevents it from crossing into a non-mapped page (not even IO) and
causing an oops ? Looking at a random user in fs/dcache.c its not a
uaccess-style read with recovery.... Or am I missing somethign obvious
here ?
IE, should we "reserve" the last page of any memory region (maybe mark
it read-only) to avoid this along with avoiding leakage into IO space ?
> > I thought we already did that.
>
> We don't seem to do that.
>
> And it's not just the last page, it's _any_ last page in a region that
> bumps up to IO. That's actually much more common in the low 4G area on
> PC's, I suspect, although the reserved BIOS ranges always tend to be
> there.
What makes IO more "wrong" than oopsing due to the page not being
mapped ?
> I suspect it should be trivial to do - maybe in
> e820__memblock_setup()? That's where we already trim partial pages
> etc.
>
> In fact, I think this might be done as an extension of commit
> 124049decbb1 ("x86/e820: put !E820_TYPE_RAM regions into
> memblock.reserved"), except making sure that non-RAM regions mark one
> page _previous_ as reserved too.
>
> I assume memory hotplug might have the same issue, and checking
> whether ARM64 and powerpc perhaps might have already done something
> like this (or might need to add it).
>
> We discussed long ago the case of user space mapping IO in user space,
> and decided we didn't care. But the kernel should probably explicitly
> make sure we don't either, even if I can't recall having ever seen a
> machine that actually maps IO contiguously to RAM. The layout always
> tends to end up having holes anyway.
Can't we put the safety in generic memblock ? IE, don't hand out an
allocation that contain the last page of a "block" and handle that last
page in the memblock->buddy transition rather than in arch specific
code ?
Cheers,
Ben.
next prev parent reply other threads:[~2018-09-03 2:06 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-29 12:10 Juergen Gross
2018-08-31 21:18 ` Jiri Kosina
2018-09-01 10:47 ` Juergen Gross
2018-09-01 17:13 ` Al Viro
2018-09-01 21:48 ` Jiri Kosina
2018-09-01 17:27 ` Linus Torvalds
2018-09-01 18:06 ` Linus Torvalds
2018-09-03 0:48 ` Benjamin Herrenschmidt [this message]
2018-09-03 0:55 ` Benjamin Herrenschmidt
2018-09-03 1:38 ` Linus Torvalds
2018-09-03 1:42 ` Linus Torvalds
2018-09-03 2:00 ` Benjamin Herrenschmidt
2018-09-03 2:10 ` Linus Torvalds
2018-09-03 2:25 ` Benjamin Herrenschmidt
2018-09-03 2:47 ` Linus Torvalds
2018-09-03 2:52 ` Linus Torvalds
2018-09-03 3:44 ` Benjamin Herrenschmidt
2018-09-03 5:08 ` Juergen Gross
2018-09-03 6:05 ` Jiri Kosina
2018-09-03 10:36 ` Will Deacon
2018-09-03 1:44 ` Benjamin Herrenschmidt
2018-09-03 1:46 ` Benjamin Herrenschmidt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a1980256cf3d2ea8e91707fcda7cf141b27a212d.camel@kernel.crashing.org \
--to=benh@kernel.crashing.org \
--cc=jgross@suse.com \
--cc=jikos@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhocko@suse.com \
--cc=mpe@ellerman.id.au \
--cc=n-horiguchi@ah.jp.nec.com \
--cc=torvalds@linux-foundation.org \
--cc=will.deacon@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome