linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Roland Dreier <rdreier@cisco.com>
To: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@ozlabs.org, Joachim Fenkes <fenkes@de.ibm.com>
Subject: Re: [PATCH] Allow drivers to map individual 4k pages to userspace
Date: Tue, 03 Apr 2007 19:34:13 -0700	[thread overview]
Message-ID: <adar6r0dg0q.fsf@cisco.com> (raw)
In-Reply-To: <17938.14674.621036.256587@cargo.ozlabs.ibm.com> (Paul Mackerras's message of "Tue, 3 Apr 2007 21:24:02 +1000")

Warning: I am somewhat of a PowerPC ignoramus, so this reply may not
make sense.

 > Some drivers have resources that they want to be able to map into
 > userspace that are 4k in size.  On a kernel configured with 64k pages
 > we currently end up mapping the 4k we want plus another 60k of
 > physical address space, which could contain anything.  This can
 > introduce security problems, for example in the case of an infiniband
 > adaptor where the other 60k could contain registers that some other
 > program is using for its communications.

I assume this is an eHCA-specific problem.  Mellanox adapters (which
I'm much more familiar with) allow the driver to pass in the system
page size at initialization time, and make the register pages of size
equal to the system size.

Another approach is simply not to enable the other 4K pages that are
exposed when mapping a 64K page into userspace - ie only use 1/16th of
the available contexts.  Although perhaps eHCA has such a limited # of
contexts that this is not practical.

 > This patch adds a new function, remap_4k_pfn, which drivers can use to
 > map a single 4k page to userspace regardless of whether the kernel is
 > using a 4k or a 64k page size.  Like remap_pfn_range, it would
 > typically be called in a driver's mmap function.  It only maps a
 > single 4k page, which on a 64k page kernel appears replicated 16 times
 > throughout a 64k page.  On a 4k page kernel it reduces to a call to
 > remap_pfn_range.

The problem with this approach is that remap_4k_pfn is
powerpc-specific, right?  For example, I don't believe that an ia64
kernel running with 16K pages could implement this.  Which means that
any driver that calls remap_4k_pfn is now powerpc-specific (or has an
#ifdef to work around this).

In fact my impression was that the powerpc MMU is not part of the
architecture, in the sense that a new implementation could come along
that supported 64K pages without the ability to do this 4K aliasing
trick.  Which would make multiplatform kernels very painful, since
remap_4k_pfn might work for some platforms the kernel could boot on.
Or is this not a problem?

 - R.

  reply	other threads:[~2007-04-04  2:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-03 11:24 [PATCH] Allow drivers to map individual 4k pages to userspace Paul Mackerras
2007-04-04  2:34 ` Roland Dreier [this message]
2007-04-04  3:23   ` Benjamin Herrenschmidt
2007-04-04  4:07     ` Roland Dreier
2007-04-04  4:43       ` Benjamin Herrenschmidt
2007-04-04  5:14       ` Paul Mackerras
2007-04-04  4:41   ` Paul Mackerras

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=adar6r0dg0q.fsf@cisco.com \
    --to=rdreier@cisco.com \
    --cc=fenkes@de.ibm.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=paulus@samba.org \
    /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;
as well as URLs for NNTP newsgroup(s).