lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-id: <4760823B.30901@shaw.ca>
Date:	Wed, 12 Dec 2007 18:52:11 -0600
From:	Robert Hancock <hancockr@...w.ca>
To:	Aras Vaichas <arasv@...tech.com.au>
Cc:	linux-kernel@...r.kernel.org
Subject: Re: mmaping an IO port device

Aras Vaichas wrote:
> Hi,
> 
> Can I implement mmap with an io port connected device on an x86 based CPU?
> 
> 
> Background:
> 
> I've got a device driver which can be compiled for either x86 or ARM. 
> The driver provides an interface to an FPGA via either an IO port 
> (0x180) on the x86 or as a memory mapped SRAM-like device (0x30000000) 
> on the ARM.
> 
> To get myself an "address" for ioread calls I use:
> 
> FPGA_base = (u32) ioremap_nocache(FPGA_REG_IO_BASE, SZ_4K) for both CPU 
> types.
> 
> FPGA_REG_IO_BASE is set to either 0x180 or 0x30000000 for x86 and ARM 
> respectively.
> 
> I then call ioread16(FPGA_base + FPGA_register) for both x86 and ARM and 
> it all works perfectly. No problems there.
> 
> My problem is that I am now moving from ioctl calls to a mmap interface. 
> This isn't a problem with ARM as I can pass (0x30000000 >> PAGE_SHIFT) 
> to remap_pfn_range() in the .mmap fops function but I can't pass 0x180 
> because ... well, it's obvious.
> 
> Is there a trick?
> 
> Aras

It's impossible to mmap an IO port area on x86 since IO ports are not 
accessible as part of the normal memory space. The only way to get 
access to IO ports in userspace is to use iopl (which requires root 
privileges) and then executing inl/outl, etc. instructions directly.

-- 
Robert Hancock      Saskatoon, SK, Canada
To email, remove "nospam" from hancockr@...pamshaw.ca
Home Page: http://www.roberthancock.com/

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ