[En-Nut-Discussion] arm port (RFC: Changing ARM mode)

Adam Dybkowski adybkows at wp.pl
Wed Jan 14 22:54:31 CET 2009


Alain M. pisze:

>>> It will probably work with ARM7, but it looks more like a hack...
>>> But it will not work anymore on Cortex...
>> Why? What is the clue difference between Cortex and ARM cores?
> 
> In ARM7, the priviledged mode is kind of not for protection... I don't 
> know what good is a protection that can be turned off with one instruction.
> 
> In Cortex-M3, protectetion is real and to enforce that, SWI (was renamed 
> to SVC) is the only way to switch out of user mode.

The same applies to ARM7TDMI and other ARM cores. In the user mode, some 
of CPU instructions are prohibited, including messing with CPSR 
(changing modes, disabling interrupts etc). You can switch to privileged 
mode only by chip reset, interrupt, SWI or exception (data abort, 
prefetch abort etc).

Once in privileged mode, you can change CPSR to go to any other mode 
(for example system mode that uses user mode registers). Or jump back to 
previous mode by using movs pc,lr ('s' letter is the key here).

Running user applications in user mode will improve security but also 
slow down system calls and overall performance. I think this should be a 
configurable option in the future (if unselected, falling back to 
current all-code-in-supervisor-mode), not the only choice.

-- 
Adam Dybkowski
		adybkows at wp.pl
		http://dybkowski.net/


More information about the En-Nut-Discussion mailing list