Secure Monitor
Description
Because implementing full-featured hardware MTM is too hard task, most vendors usually enable only software emulation of MTM. All OMAP chips have only software emulation of MTM, and not full.
This emulation usually provides by time-split system: few ticks - Non-Secure World, few ticks - Secure World.
In OMAP we can call Secure Monitor by SMC instruction, which call specific in-cpu interrupt, and CPU enter in Secure mode Also L2 cache in Secure mode dont used, really. So you need to be shure flush cache before enter Secure World
Provide a few Secure Services
Internal structure
ARM v7ar provide System Monitor CPU mode, and Secure Extensions for Control Coprocessor cp15 with c12 register.
See chapter B3.12.39 of ARM Architecture Reference Guide.
How To Use
Security Monitor can be called by these functions:
__int32 __cdecl security_monitor_call(__int32 secure_service_id, __int32 proc_id, __int32 flags, void *params)
Invalid language.
You need to specify a language like this: <source lang="html4strict">...</source>
Supported languages for syntax highlighting:
4cs, 6502acme, 6502kickass, 6502tasm, 68000devpac, abap, actionscript, actionscript3, ada, algol68, apache, applescript, apt_sources, arm, asm, asp, asymptote, autoconf, autohotkey, autoit, avisynth, awk, bascomavr, bash, basic4gl, bf, bibtex, blitzbasic, bnf, boo, c, c_loadrunner, c_mac, caddcl, cadlisp, cfdg, cfm, chaiscript, cil, clojure, cmake, cobol, coffeescript, cpp, cpp-qt, csharp, css, cuesheet, d, dcl, dcpu16, dcs, delphi, diff, div, dos, dot, e, ecmascript, eiffel, email, epc, erlang, euphoria, f1, falcon, fo, fortran, freebasic, freeswitch, fsharp, gambas, gdb, genero, genie, gettext, glsl, gml, gnuplot, go, groovy, gwbasic, haskell, haxe, hicest, hq9plus, html4strict, html5, icon, idl, ini, inno, intercal, io, j, java, java5, javascript, jquery, kixtart, klonec, klonecpp, latex, lb, ldif, lisp, llvm, locobasic, logtalk, lolcode, lotusformulas, lotusscript, lscript, lsl2, lua, m68k, magiksf, make, mapbasic, matlab, mirc, mmix, modula2, modula3, mpasm, mxml, mysql, nagios, netrexx, newlisp, nsis, oberon2, objc, objeck, ocaml, ocaml-brief, octave, oobas, oorexx, oracle11, oracle8, oxygene, oz, parasail, parigp, pascal, pcre, per, perl, perl6, pf, php, php-brief, pic16, pike, pixelbender, pli, plsql, postgresql, povray, powerbuilder, powershell, proftpd, progress, prolog, properties, providex, purebasic, pycon, pys60, python, q, qbasic, rails, rebol, reg, rexx, robots, rpmspec, rsplus, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, spark, sparql, sql, stonescript, systemverilog, tcl, teraterm, text, thinbasic, tsql, typoscript, unicon, upc, urbi, uscript, vala, vb, vbnet, vedit, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, whois, winbatch, xbasic, xml, xorg_conf, xpp, yaml, z80, zxbasic
; =============== S U B R O U T I N E ======================================= security_monitor_call ; CODE XREF: security_monitor_parse_flags_and_call+8 STMFD SP!, {R4-R12,LR} ; Store Block to Memory MOV R6, #0xFF ; Rd = Op2 MOV R12, #0 ; Rd = Op2 MCR p15, 0, R0,c7,c5, 4 ; prefetch flush MCR p15, 0, R0,c7,c10, 4 ; data synchronisation barrier SMC 1 ; Secure Monitor Call B service_end ; Branch ; --------------------------------------------------------------------------- NOP ; No Operation MOV R12, #SMC_IRQ_END ; Rd = Op2 SMC 1 ; Secure Monitor Call service_end ; CODE XREF: security_monitor_call+18 LDMFD SP!, {R4-R12,LR} ; Load Block from Memory BX LR ; Branch to/from Thumb mode ; End of function security_monitor_call
And here example of params parser function, which parse flags and params before calling secure service:
__int32 __fastcall security_monitor_parse_flags_and_call(__int32 ssid, __int32 proc_id, __int32 flag, __int32 params_count, void *params)
Invalid language.
You need to specify a language like this: <source lang="html4strict">...</source>
Supported languages for syntax highlighting:
4cs, 6502acme, 6502kickass, 6502tasm, 68000devpac, abap, actionscript, actionscript3, ada, algol68, apache, applescript, apt_sources, arm, asm, asp, asymptote, autoconf, autohotkey, autoit, avisynth, awk, bascomavr, bash, basic4gl, bf, bibtex, blitzbasic, bnf, boo, c, c_loadrunner, c_mac, caddcl, cadlisp, cfdg, cfm, chaiscript, cil, clojure, cmake, cobol, coffeescript, cpp, cpp-qt, csharp, css, cuesheet, d, dcl, dcpu16, dcs, delphi, diff, div, dos, dot, e, ecmascript, eiffel, email, epc, erlang, euphoria, f1, falcon, fo, fortran, freebasic, freeswitch, fsharp, gambas, gdb, genero, genie, gettext, glsl, gml, gnuplot, go, groovy, gwbasic, haskell, haxe, hicest, hq9plus, html4strict, html5, icon, idl, ini, inno, intercal, io, j, java, java5, javascript, jquery, kixtart, klonec, klonecpp, latex, lb, ldif, lisp, llvm, locobasic, logtalk, lolcode, lotusformulas, lotusscript, lscript, lsl2, lua, m68k, magiksf, make, mapbasic, matlab, mirc, mmix, modula2, modula3, mpasm, mxml, mysql, nagios, netrexx, newlisp, nsis, oberon2, objc, objeck, ocaml, ocaml-brief, octave, oobas, oorexx, oracle11, oracle8, oxygene, oz, parasail, parigp, pascal, pcre, per, perl, perl6, pf, php, php-brief, pic16, pike, pixelbender, pli, plsql, postgresql, povray, powerbuilder, powershell, proftpd, progress, prolog, properties, providex, purebasic, pycon, pys60, python, q, qbasic, rails, rebol, reg, rexx, robots, rpmspec, rsplus, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, spark, sparql, sql, stonescript, systemverilog, tcl, teraterm, text, thinbasic, tsql, typoscript, unicon, upc, urbi, uscript, vala, vb, vbnet, vedit, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, whois, winbatch, xbasic, xml, xorg_conf, xpp, yaml, z80, zxbasic
; =============== S U B R O U T I N E ======================================= security_monitor_parse_flags_and_call ; CODE XREF: security_call_SSID_0x04+E ; security_call_SSID_0x03+C ... caller_address = -0x14 ssid = -0x10 proc_id = -0xC flag = -8 params_count = -4 params = 0 PUSH {R0-R3} ; stack = [R0,R1,R2,R3,R4,LR] stack_head PUSH {R4,LR} ; Push registers ADD R3, SP, #0x18+params_count ; params_addr LDR R2, [SP,#0x18+flag] ; flag BLX security_monitor_call ; Branch with Link and Exchange (immediate address) POP {R4} ; Pop registers LDR.W PC, [SP+0x14+caller_address],#0x14 ; returning back to the caller function ; End of function security_monitor_parse_flags_and_call