From fc6614dbd852533a73d92715d645b35fa9c981ea Mon Sep 17 00:00:00 2001 From: bzt Date: Sat, 20 Jan 2018 14:55:42 +0100 Subject: [PATCH] Added EL3 handling code (untested) --- 0F_executionlevel/OLVASSEL.md | 2 ++ 0F_executionlevel/README.md | 2 ++ 0F_executionlevel/kernel8.img | Bin 960 -> 1000 bytes 0F_executionlevel/main.c | 2 +- 0F_executionlevel/start.S | 17 ++++++++++++++++- 10_virtualmemory/kernel8.img | Bin 4152 -> 4152 bytes 10_virtualmemory/start.S | 17 ++++++++++++++++- 11_exceptions/kernel8.img | Bin 8248 -> 8248 bytes 11_exceptions/start.S | 17 ++++++++++++++++- 9 files changed, 53 insertions(+), 4 deletions(-) diff --git a/0F_executionlevel/OLVASSEL.md b/0F_executionlevel/OLVASSEL.md index 7c52162e..d0bbf1cc 100644 --- a/0F_executionlevel/OLVASSEL.md +++ b/0F_executionlevel/OLVASSEL.md @@ -13,6 +13,8 @@ Exception return from AArch64 EL2 to AArch64 EL1 PC 0x8004c Current EL is: 00000001 ``` +FIGYELEM: a teljesség kedvéért hozzáadtam az EL3-at is az Issue #6 miatt, bár semmilyen módon nem tudtam kipróbálni. + Start ----- diff --git a/0F_executionlevel/README.md b/0F_executionlevel/README.md index 076bef23..48a1fbf8 100644 --- a/0F_executionlevel/README.md +++ b/0F_executionlevel/README.md @@ -12,6 +12,8 @@ Exception return from AArch64 EL2 to AArch64 EL1 PC 0x8004c Current EL is: 00000001 ``` +NOTE: For completeness, I've added code for EL3 too because of Issue #6, although I had no means to test it. + Start ----- diff --git a/0F_executionlevel/kernel8.img b/0F_executionlevel/kernel8.img index 95168bc2744d10fe1ed464a8cc8eaf384231ee7a..6f6943893d09d4d930814c2398b6d4c3b4f42920 100755 GIT binary patch delta 159 zcmX@W{(^mih(RI?Lxh8q#Z?BDx=Hc|3?CU88A6n{HC$p6l)I`_38Wq5t|l=s2q*#R z2h8)YO_T``z4!mWxDW#jaDW*fCN|12KG`@=n@N8G-^8>3|4)CwEUd-A<8=8EkPTEa tf#Ct)#N$Br4iI04L1+z-{tGl|@((6W#wU}NnB9S77PA@Shsg_>;~2!|pwLxh8q#np)}0irMd{}&fxfB_CL>2); + uart_hex((el>>2)&3); uart_puts("\n"); // echo everything back diff --git a/0F_executionlevel/start.S b/0F_executionlevel/start.S index 34cf99c8..33b5f4f9 100644 --- a/0F_executionlevel/start.S +++ b/0F_executionlevel/start.S @@ -42,7 +42,22 @@ _start: // set up EL1 mrs x0, CurrentEL - cmp x0, #4 + and x0, x0, #12 // clear reserved bits + + // running at EL3? + cmp x0, #12 + bne 5f + // should never be executed, just for completeness + mov x2, #0x5b1 + msr scr_el3, x2 + mov x2, #0x3c9 + msr spsr_el3, x2 + adr x2, 5f + msr elr_el3, x2 + eret + + // running at EL2? +5: cmp x0, #4 beq 5f msr sp_el1, x1 // enable CNTP for EL1 diff --git a/10_virtualmemory/kernel8.img b/10_virtualmemory/kernel8.img index c5438321ba3d22ee265d3185065a000c9c14238c..ba67353120b5d47249e4f778420e063e67d80c15 100755 GIT binary patch delta 98 zcmdm?utQ;jh=C$2Lxh8q#Z?BDx=Hc|3?CU88A6n{HC$p6l)I`_38Wq5t|l=s2q*#R z2h8)YO_a%DyuPv1f{}5-=0l8&nFJHWC!YKNe>wvL!-PkF=1*c+u(^ySi+eJMfB^tZ C(<21{ delta 62 zcmV-E0KxybAh;lq6bRu109ZgmIMtCvYysi1u{Z$%0JG`=qXH4Y7Lm^X|Cay&0FdJR UpOOFovz`QM3zHBAD3b^fFz&4v8UO$Q diff --git a/10_virtualmemory/start.S b/10_virtualmemory/start.S index 142f2285..6e757440 100644 --- a/10_virtualmemory/start.S +++ b/10_virtualmemory/start.S @@ -42,7 +42,22 @@ _start: // set up EL1 mrs x0, CurrentEL - cmp x0, #4 + and x0, x0, #12 // clear reserved bits + + // running at EL3? + cmp x0, #12 + bne 5f + // should never be executed, just for completeness + mov x2, #0x5b1 + msr scr_el3, x2 + mov x2, #0x3c9 + msr spsr_el3, x2 + adr x2, 5f + msr elr_el3, x2 + eret + + // running at EL2? +5: cmp x0, #4 beq 5f msr sp_el1, x1 // enable CNTP for EL1 diff --git a/11_exceptions/kernel8.img b/11_exceptions/kernel8.img index 4357c4bdeaf56525dd3d53f1e0b1cde33ae34537..fcd9f4a27cde2f17a9d6127ebfcf166ea0e0ba20 100755 GIT binary patch delta 94 zcmdntu)|@3j0OWs-6VMfhL4Pl3?WL}8ZI#j%3W2e1kw(2SCbeR1eAdE1LpbHCdyba xC3#K^lapQO!4PrCok60Bfx*PSh2e)23q#B-8j*meG`X;1OTn;9|iyb delta 59 zcmV-B0L1^eK)67V9Fasg0-{QhejXs