Skip to content

Commit cfd230b

Browse files
committed
Merge tag 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm
Pull ARM fixes from Russell King: - fix for "hex" Kconfig default to use 0x0 rather than 0 to allow these to be removed from defconfigs - fix from Ard Biesheuvel for EFI HYP mode booting * tag 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm: ARM: 8985/1: efi/decompressor: deal with HYP mode boot gracefully ARM: 8984/1: Kconfig: set default ZBOOT_ROM_TEXT/BSS value to 0x0
2 parents 5619270 + db227c1 commit cfd230b

File tree

2 files changed

+64
-2
lines changed

2 files changed

+64
-2
lines changed

arch/arm/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,7 +1749,7 @@ config DEPRECATED_PARAM_STRUCT
17491749
# TEXT and BSS so we preserve their values in the config files.
17501750
config ZBOOT_ROM_TEXT
17511751
hex "Compressed ROM boot loader base address"
1752-
default "0"
1752+
default 0x0
17531753
help
17541754
The physical address at which the ROM-able zImage is to be
17551755
placed in the target. Platforms which normally make use of
@@ -1760,7 +1760,7 @@ config ZBOOT_ROM_TEXT
17601760

17611761
config ZBOOT_ROM_BSS
17621762
hex "Compressed ROM boot loader BSS address"
1763-
default "0"
1763+
default 0x0
17641764
help
17651765
The base address of an area of read/write memory in the target
17661766
for the ROM-able zImage which must be available while the

arch/arm/boot/compressed/head.S

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,7 +1410,11 @@ memdump: mov r12, r0
14101410
__hyp_reentry_vectors:
14111411
W(b) . @ reset
14121412
W(b) . @ undef
1413+
#ifdef CONFIG_EFI_STUB
1414+
W(b) __enter_kernel_from_hyp @ hvc from HYP
1415+
#else
14131416
W(b) . @ svc
1417+
#endif
14141418
W(b) . @ pabort
14151419
W(b) . @ dabort
14161420
W(b) __enter_kernel @ hyp
@@ -1429,14 +1433,72 @@ __enter_kernel:
14291433
reloc_code_end:
14301434

14311435
#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+
14321443
ENTRY(efi_enter_kernel)
14331444
mov r4, r0 @ preserve image base
14341445
mov r8, r1 @ preserve DT pointer
14351446

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 that 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 that 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
14361497
mrc p15, 0, r0, c1, c0, 0 @ read SCTLR
14371498
tst r0, #0x1 @ MMU enabled?
14381499
orreq r4, r4, #1 @ set LSB if not
14391500

1501+
.Lefi_hyp:
14401502
mov r0, r8 @ DT start
14411503
add r1, r8, r2 @ DT end
14421504
bl cache_clean_flush

0 commit comments

Comments
 (0)