@@ -1410,7 +1410,11 @@ memdump: mov r12, r0
1410
1410
__hyp_reentry_vectors:
1411
1411
W(b) . @ reset
1412
1412
W(b) . @ undef
1413
+ #ifdef CONFIG_EFI_STUB
1414
+ W(b) __enter_kernel_from_hyp @ hvc from HYP
1415
+ #else
1413
1416
W(b) . @ svc
1417
+ #endif
1414
1418
W(b) . @ pabort
1415
1419
W(b) . @ dabort
1416
1420
W(b) __enter_kernel @ hyp
@@ -1429,14 +1433,72 @@ __enter_kernel:
1429
1433
reloc_code_end:
1430
1434
1431
1435
#ifdef CONFIG_EFI_STUB
1436
+ __enter_kernel_from_hyp:
1437
+ mrc p15 , 4 , r0 , c1 , c0 , 0 @ read HSCTLR
1438
+ bic r0 , r0 , # 0x5 @ disable MMU and caches
1439
+ mcr p15 , 4 , r0 , c1 , c0 , 0 @ write HSCTLR
1440
+ isb
1441
+ b __enter_kernel
1442
+
1432
1443
ENTRY(efi_enter_kernel)
1433
1444
mov r4 , r0 @ preserve image base
1434
1445
mov r8 , r1 @ preserve DT pointer
1435
1446
1447
+ ARM( adrl r0 , call_cache_fn )
1448
+ THUMB( adr r0 , call_cache_fn )
1449
+ adr r1 , 0f @ clean the region of code we
1450
+ bl cache_clean_flush @ may run with the MMU off
1451
+
1452
+ #ifdef CONFIG_ARM_VIRT_EXT
1453
+ @
1454
+ @ The EFI spec does not support booting on ARM in HYP mode ,
1455
+ @ since it mandates th at the MMU and caches are on , with all
1456
+ @ 32 - bit addressable DRAM mapped 1 : 1 using short descriptors.
1457
+ @
1458
+ @ While the EDK2 reference implementation adheres to this ,
1459
+ @ U - Boot might decide to enter the EFI stub in HYP mode
1460
+ @ anyway , with the MMU and caches either on or off.
1461
+ @
1462
+ mrs r0 , cpsr @ get the current mode
1463
+ msr spsr_cxsf , r0 @ record boot mode
1464
+ and r0 , r0 , #MODE_MASK @ are we running in HYP mode?
1465
+ cmp r0 , #HYP_MODE
1466
+ bne .Lefi_svc
1467
+
1468
+ mrc p15 , 4 , r1 , c1 , c0 , 0 @ read HSCTLR
1469
+ tst r1 , # 0x1 @ MMU enabled at HYP?
1470
+ beq 1f
1471
+
1472
+ @
1473
+ @ When running in HYP mode with the caches on , we're better
1474
+ @ off just carrying on using the cached 1 : 1 mapping th at the
1475
+ @ firmware provided. Set up the HYP vectors so HVC instructions
1476
+ @ issued from HYP mode take us to the correct handler code. We
1477
+ @ will disable the MMU before jumping to the kernel proper.
1478
+ @
1479
+ adr r0 , __hyp_reentry_vectors
1480
+ mcr p15 , 4 , r0 , c12 , c0 , 0 @ set HYP vector base (HVBAR)
1481
+ isb
1482
+ b .Lefi_hyp
1483
+
1484
+ @
1485
+ @ When running in HYP mode with the caches off , we need to drop
1486
+ @ into SVC mode now , and let the decompressor set up its cached
1487
+ @ 1 : 1 mapping as usual.
1488
+ @
1489
+ 1 : mov r9 , r4 @ preserve image base
1490
+ bl __hyp_stub_install @ install HYP stub vectors
1491
+ safe_svcmode_maskall r1 @ drop to SVC mode
1492
+ msr spsr_cxsf , r0 @ record boot mode
1493
+ orr r4 , r9 , # 1 @ restore image base and set LSB
1494
+ b .Lefi_hyp
1495
+ .Lefi_svc:
1496
+ #endif
1436
1497
mrc p15 , 0 , r0 , c1 , c0 , 0 @ read SCTLR
1437
1498
tst r0 , # 0x1 @ MMU enabled?
1438
1499
orreq r4 , r4 , # 1 @ set LSB if not
1439
1500
1501
+ .Lefi_hyp:
1440
1502
mov r0 , r8 @ DT start
1441
1503
add r1 , r8 , r2 @ DT end
1442
1504
bl cache_clean_flush
0 commit comments