Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S942528AbcJ1VTE (ORCPT ); Fri, 28 Oct 2016 17:19:04 -0400 Received: from smtp47.i.mail.ru ([94.100.177.107]:57912 "EHLO smtp47.i.mail.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933956AbcJ1VS5 (ORCPT ); Fri, 28 Oct 2016 17:18:57 -0400 Subject: Re: /dev/mem and PCI memory = EFAULT? To: Andy Lutomirski References: Cc: Linux kernel From: Stas Sergeev Message-ID: <52478c6c-39cb-35b1-0517-33d9f6e99a5a@list.ru> Date: Sat, 29 Oct 2016 00:18:52 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Authentication-Results: smtp47.i.mail.ru; auth=pass smtp.auth=stsp@list.ru smtp.mailfrom=stsp@list.ru X-E1FCDC63: 118DE69D36B00E08AD0DBDDA8C5B741BF8D9167951635F18 X-E1FCDC64: CF31CF4FBB5EE2D30F3FB0A8C80809EBFB8DAACEF07967E78896C5CA584DE5E5852F988894FAF51A X-Mailru-Sender: CD12F6D16A91A659C71BA12F480A5E3EEC9B1A14FD4EFCEA027A791971745748B1B10FB8AC87530DFEDCCBD3DDE7F493 X-Mras: OK Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1460 Lines: 31 29.10.2016 00:05, Andy Lutomirski пишет: > On Fri, Oct 28, 2016 at 2:03 PM, Stas Sergeev 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? >> > What is DOSEMU trying to do here? Access the framebuffer? > > ISTM it would be better to use the DRM or FB layer directly (just map > the framebuffer itself) or, if necessary, use VFIO. Yes, framebuffer. Mapping fb directly is not really an option because dosemu does its own modesetting when you do vga pass-through. So it is usually started that way with "nomodeset=1" and w/o fb. Yes, some crazy people try the pass-through even out of fb console, but that's weird (the problem is most SDL2 builds do not have directfb backend compiled in, otherwise we could just use SDL rendering on top of fb). The thing is, I needed (for testing purposes, unrelated to dosemu) some quick way to access the PCI memory space, and to my surprise I couldn't do that with /dev/mem. Was this really disallowed intentionally?