MMU Hack
level: advanced
date: 24.10.2006 22:33
author: Squidge

Here is the sourcecode of squidges hack: http://dev.gp2x.de/code/mmuhack.html. And here are some infos what it does and how it works:
Each application runs in it's own memory space with it's own mmu tables, so this code must be included with any program that wants to modify it's mmu tables (for eg. fast access to memory >32mb). Programs running without this hack included will run as normal.
No, it doesn't break the video player unless you happen to overwrite memory that is reserved by the second processor (ie. exactly the same as before), as the changes to the mmu tables only apply to the currently running program. Any program not including this code will run as normal, with slow access to >32mb, even if another program using this hack is running in the background.
The kernel code that is overwritten (sys_newuname) isn't very big in size (it's basically just copies a string into the user provided buffer and returns), so if you want to run a lot of code as supervisor, it would be best if you used kmalloc to allocate kernel memory; copied your code there and branched to that. Only problem is that kmalloc is only available to the kernel, so you need to use a similar technique to what is used here to use that function. You could branch to a function in user land instead, but don't forget that if linux does a task switch on you whilst your in that code, and another task calls sys_newuname, expect a nice big kernel panic. One way of stopping this is disabling interrupts in your new code, but that will screw up timers/etc if you take too long.
The reason I chose sys_newuname for overwriting is that it seems to be the least used system call on Linux - there's little chance of a task switch happening and another function calling that routine, as most programs simply don't care about the os they are running on.
Now there is a kernel module, too. You can find it here: http://dev.gp2x.de/code/mmuhack.o