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>
lime2-spi
Alexander Graf 7 years ago
parent de452c04c3
commit e4679489c3
  1. 11
      arch/arm/cpu/armv8/fwcall.c
  2. 11
      arch/arm/mach-bcm283x/reset.c

@ -143,15 +143,12 @@ void __efi_runtime EFIAPI efi_reset_system(
efi_status_t reset_status, efi_status_t reset_status,
unsigned long data_size, void *reset_data) unsigned long data_size, void *reset_data)
{ {
switch (reset_type) { if (reset_type == EFI_RESET_COLD ||
case EFI_RESET_COLD: reset_type == EFI_RESET_WARM ||
case EFI_RESET_WARM: reset_type == EFI_RESET_PLATFORM_SPECIFIC) {
case EFI_RESET_PLATFORM_SPECIFIC:
psci_system_reset(); psci_system_reset();
break; } else if (reset_type == EFI_RESET_SHUTDOWN) {
case EFI_RESET_SHUTDOWN:
psci_system_off(); psci_system_off();
break;
} }
while (1) { } while (1) { }

@ -59,13 +59,11 @@ void __efi_runtime EFIAPI efi_reset_system(
{ {
u32 val; u32 val;
switch (reset_type) { if (reset_type == EFI_RESET_COLD ||
case EFI_RESET_COLD: reset_type == EFI_RESET_WARM ||
case EFI_RESET_WARM: reset_type == EFI_RESET_PLATFORM_SPECIFIC) {
case EFI_RESET_PLATFORM_SPECIFIC:
reset_cpu(0); reset_cpu(0);
break; } else if (reset_type == EFI_RESET_SHUTDOWN) {
case EFI_RESET_SHUTDOWN:
/* /*
* We set the watchdog hard reset bit here to distinguish this reset * We set the watchdog hard reset bit here to distinguish this reset
* from the normal (full) reset. bootcode.bin will not reboot after a * 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; val |= BCM2835_WDOG_RSTS_RASPBERRYPI_HALT;
writel(val, &wdog_regs->rsts); writel(val, &wdog_regs->rsts);
reset_cpu(0); reset_cpu(0);
break;
} }
while (1) { } while (1) { }

Loading…
Cancel
Save