aboutsummaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2018-06-10 21:51:02 +0200
committerAlexander Graf <agraf@suse.de>2018-06-14 10:52:14 +0200
commite4679489c3fc12f87ce64347d2cebd5090ca9619 (patch)
tree4343f2619c67155718eb924865e123af4e3334ad /arch
parentde452c04c391948dbff68029e900fbb10dd5efb2 (diff)
downloadu-boot-e4679489c3fc12f87ce64347d2cebd5090ca9619.tar.gz
efi_loader: Convert runtime reset from switch to if statements
We currently handle the UEFI runtime reset / power off case handling via a switch statement. Compilers (gcc in my case) may opt to handle these via jump tables which they may conveniently put into .rodata which is not part of the runtime section, so it will be unreachable when executed. Fix this by just converting the switch statement into an if/else statement. It produces smaller code that is faster and also correct because we no longer refer .rodata from efi runtime code. Reported-by: Andreas Färber <aferber@suse.de> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/cpu/armv8/fwcall.c11
-rw-r--r--arch/arm/mach-bcm283x/reset.c11
2 files changed, 8 insertions, 14 deletions
diff --git a/arch/arm/cpu/armv8/fwcall.c b/arch/arm/cpu/armv8/fwcall.c
index c5aa41a0e6..0ba3dad8cc 100644
--- a/arch/arm/cpu/armv8/fwcall.c
+++ b/arch/arm/cpu/armv8/fwcall.c
@@ -143,15 +143,12 @@ void __efi_runtime EFIAPI efi_reset_system(
efi_status_t reset_status,
unsigned long data_size, void *reset_data)
{
- switch (reset_type) {
- case EFI_RESET_COLD:
- case EFI_RESET_WARM:
- case EFI_RESET_PLATFORM_SPECIFIC:
+ if (reset_type == EFI_RESET_COLD ||
+ reset_type == EFI_RESET_WARM ||
+ reset_type == EFI_RESET_PLATFORM_SPECIFIC) {
psci_system_reset();
- break;
- case EFI_RESET_SHUTDOWN:
+ } else if (reset_type == EFI_RESET_SHUTDOWN) {
psci_system_off();
- break;
}
while (1) { }
diff --git a/arch/arm/mach-bcm283x/reset.c b/arch/arm/mach-bcm283x/reset.c
index f8a17755e3..7712d4664c 100644
--- a/arch/arm/mach-bcm283x/reset.c
+++ b/arch/arm/mach-bcm283x/reset.c
@@ -59,13 +59,11 @@ void __efi_runtime EFIAPI efi_reset_system(
{
u32 val;
- switch (reset_type) {
- case EFI_RESET_COLD:
- case EFI_RESET_WARM:
- case EFI_RESET_PLATFORM_SPECIFIC:
+ if (reset_type == EFI_RESET_COLD ||
+ reset_type == EFI_RESET_WARM ||
+ reset_type == EFI_RESET_PLATFORM_SPECIFIC) {
reset_cpu(0);
- break;
- case EFI_RESET_SHUTDOWN:
+ } else if (reset_type == EFI_RESET_SHUTDOWN) {
/*
* We set the watchdog hard reset bit here to distinguish this reset
* from the normal (full) reset. bootcode.bin will not reboot after a
@@ -76,7 +74,6 @@ void __efi_runtime EFIAPI efi_reset_system(
val |= BCM2835_WDOG_RSTS_RASPBERRYPI_HALT;
writel(val, &wdog_regs->rsts);
reset_cpu(0);
- break;
}
while (1) { }