[Rpcemu] Dynamic recompilation on x86(-PAE) and x86-64 Linux

Kai Thomsen kai.thomsen at gmx.de
Thu Oct 11 00:25:29 BST 2007


Hi,

when running a DynaRec version of RPCemu on an x86-64 Linux system or
an x86 one with the Physical Address Extension (PAE) enabled by the
kernel, it's possible that RPCemu instantly fails with a segmentation
fault when it attempts to execute DynaRec-generated code that resides
in memory pages marked as non-executable by default.

Distributions on which I've observed this include Fedora 7 and the
development version of Fedora 8, both using SELinux in enforcing mode.

Patch summary:

  * On x86 and x86-64 Linux, mark the memory pages containing DynaRec
    code blocks as executable. This prevents a segmentation fault on
    kernels that enable the CPU's NX/XD feature (No eXecute / eXecute
    Disable).

  (Authors: Christof Efkemann, Kai Thomsen)

On SELinux-using distributions like Fedora, it's also necessary to
actually allow RPCemu to mark any of its own memory pages as
executable, otherwise the mprotect() call fails with EPERM (permission
denied). On Fedora, you can toggle a particular SELinux boolean to
permit this operation for all processes:

  $ su -c "/usr/sbin/setsebool -P allow_execmem=1"

I realize that this compromises the system's security, but it's at
least better than disabling SELinux as a whole.

By the way, in Fedora's graphical configuration tool
`system-config-selinux', this SELinux boolean can be found under
"Memory Protection" -> "Allow unconfined executables to map a memory
region as both executable and writable. [...]".

Assuming the patch is OK to be committed, perhaps the preceding
paragraphs should be adapted for inclusion in readme.txt?

A clean solution that handles the RPCemu executable specifically would
be preferrable, of course.


--Kai
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rpcemu-execmem-linux-svn96.patch
Type: text/x-patch
Size: 2394 bytes
Desc: not available
Url : http://www.riscos.info/pipermail/rpcemu/attachments/20071011/d52cc3db/attachment.bin 


More information about the Rpcemu mailing list