Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761952AbcJ1VDm (ORCPT ); Fri, 28 Oct 2016 17:03:42 -0400 Received: from smtp50.i.mail.ru ([94.100.177.110]:37121 "EHLO smtp50.i.mail.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761918AbcJ1VDj (ORCPT ); Fri, 28 Oct 2016 17:03:39 -0400 To: Linux kernel Cc: Andy Lutomirski From: Stas Sergeev Subject: /dev/mem and PCI memory = EFAULT? Message-ID: Date: Sat, 29 Oct 2016 00:03:34 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Authentication-Results: smtp50.i.mail.ru; auth=pass smtp.auth=stsp@list.ru smtp.mailfrom=stsp@list.ru X-E1FCDC63: 118DE69D36B00E08A46B37869CFF027D08D917D6130B1AFB X-E1FCDC64: 6297CE889FA6B62BA86C98AC2EA7A57B35AA1534FA60CA86 X-Mailru-Sender: CD12F6D16A91A659C71BA12F480A5E3E0342C7E34219E81F0E0C5039925743E0FDAFE18166A5FE01C5C7FD16981B76AE X-Mras: OK Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 742 Lines: 17 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? Note: I haven't properly tested that case. I can see the problem only under qemu, because all my machines has enough ram for the things to work. Still the failure under qemu makes me wonder if I should stop using /dev/mem for accessing PCI memory.