mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stas Sergeev <stsp@list.ru>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>,
	Linux kernel <linux-kernel@vger.kernel.org>,
	dosemu-devel <dosemu-devel@lists.sourceforge.net>,
	Bart Oldeman <bartoldeman@users.sourceforge.net>,
	"Eric W. Biederman" <ebiederm@xmission.com>
Subject: Re: /dev/mem and PCI memory = EFAULT (regression?)
Date: Sat, 29 Oct 2016 02:47:42 +0300	[thread overview]
Message-ID: <39321cd2-c2c7-8595-cba1-218dd685f29e@list.ru> (raw)
In-Reply-To: <CA+55aFz_n8DJUtXjoJn9vD=rEo-Rn1_mcx9OX50OS5wEb5On_w@mail.gmail.com>

29.10.2016 02:26, Linus Torvalds пишет:
> On Fri, Oct 28, 2016 at 2:36 PM, Stas Sergeev <stsp@list.ru> wrote:
>>>>> On Fri, Oct 28, 2016 at 2:03 PM, Stas Sergeev <stsp@list.ru> wrote:
>> Hello.
>>
>> For the long time dosemu used /dev/mem for vga pass-through.
>> Now it appears /dev/mem has this check:
>> http://lxr.free-electrons.com/source/drivers/char/mem.c#L51
>> which prevents an accesses to PCI memory regions if the
>> "high_memory" points low enough. It seems "high_memory"
>> just points to the end of the physical ram, so depending on
>> the ram size you either can access PCI devices or you get
>> EFAULT.
>> Was it wrong to use /dev/mem for accessing the PCI devices?
>> How should I do that now?
> Has it ever worked for you?
Well, yes, even today: if the ram size is large enough to last
beyond the PCI space, then I am not getting EFAULT (i've yet
to check if the results are as expected, but at least no error
returned).
It is exactly that ram size envolvement made me think this
is a bug (and regression).

>   That code is ancient, going back in some
> form or another at least ten years.
Yes, indeed, I can see that on lxr now...

> So /dev/mem does not allow "read()/write()" on IO memory, and really
> hasn't in a long long time (maybe ever, quite frankly). It does allow
> it on regular RAM, but STRICT_DEV_MEM then disallows that too for
> security reasons (and realistically, everybody uses STRICT_DEV_MEM
> these days).
>
> What people do use /dev/mem for is to mmap() PCI memory, and then you
> can access it from user space. That's the traditional model that X.org
> used to do etc.
Yes, thanks, I was confused. mmap() is indeed unaffected,
only read and write are. So the only problem I have, is the test-case
I was trying, that does read/write and works depending on the
ram size (under qemu). But there is no any problem for dosemu.
Perhaps for consistency it would be good to make things independent
of the ram size, but then there is no real problem here.
So sorry for the noise!

      reply	other threads:[~2016-10-28 23:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-28 21:03 /dev/mem and PCI memory = EFAULT? Stas Sergeev
2016-10-28 21:05 ` Andy Lutomirski
2016-10-28 21:18   ` Stas Sergeev
2016-10-28 21:26     ` Andy Lutomirski
2016-10-28 21:36       ` /dev/mem and PCI memory = EFAULT (regression?) Stas Sergeev
2016-10-28 23:26         ` Linus Torvalds
2016-10-28 23:47           ` Stas Sergeev [this message]

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=39321cd2-c2c7-8595-cba1-218dd685f29e@list.ru \
    --to=stsp@list.ru \
    --cc=bartoldeman@users.sourceforge.net \
    --cc=dosemu-devel@lists.sourceforge.net \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=torvalds@linux-foundation.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

all inboxes | Powered by JetHome®