From patchwork Sun Jun 10 19:51:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 138193 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp3277023lji; Sun, 10 Jun 2018 12:51:11 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKHDAOeKNW7fxI29PDcv5bt5VVirBeFb1+2Ag9sJhb0qHTB89szlsDvX0wNMruwtT4/n4uv X-Received: by 2002:a50:9793:: with SMTP id e19-v6mr15626525edb.58.1528660271078; Sun, 10 Jun 2018 12:51:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528660271; cv=none; d=google.com; s=arc-20160816; b=kMwRInew2zVpa3hs0kp+IdKD3zgsz+br2TmVT9/YUs9fCXOxl28oZyBYa6qLd7anwO fPqJsJkyDxG3PWeskMT+HuxHUYT+AHsmnn3PRMQhm7Nw8tS7a20nsX10ctiFdSTDzAtR 1U16Ej4gJy196vTxeVsfRfF+MpIcflV7L5GkdrY94s+NapFLUQeG+GBpKaHymfaX8zu0 Z7AvFTEhsRCBeTCziV7Q2rbIHwlPClzwpS5AIi18n6yBhFmjdQi1KHhMB/wIL/5gXqGW 5sF1O1cJKyf6L1qitOqDLLW6Ra1DAdELap2C3xuvawDP+HA4wmsfGNQ9M9NRtCi0ByF3 YJbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :cc:mime-version:message-id:date:to:from:arc-authentication-results; bh=u/cmmOgAdv14cffOrwcSyBM5QNz7Yd6J65N0BmpSgJI=; b=oTqmB8cGcH7GPCUkSti6EAELFBiODZwEWd9LSTIqY+JXGmbpfh8s/j6Nl3EhvRsXSk zZmFuTwzp3j2KWVDX9oK23+e2AuEWSFNBgo5RXfNE8O5vbkWv1n6PExAVrvdX6g3d7Im l/OdYya+pHmQCaQD5Xs+sAahh2h94YntnsRlpjHyIJrBe6O4CS8H+ICycK9A4FWvCuv2 +LT3ITXfF3x5FD3fdszTI35yzfKCm2oXTgLDL6/zTUsLOWtmA7JycWLMjHlGVOnuPOvH PHANc0Uu6YZRa1fE6pjv2FGYIkmdVnKUQ51hAbywUjKoeCShXPADQEOACYJ2CUG/KFwb /0Ag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id u20-v6si3814789edl.251.2018.06.10.12.51.10; Sun, 10 Jun 2018 12:51:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 41DFAC21D9A; Sun, 10 Jun 2018 19:51:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 97D49C21C27; Sun, 10 Jun 2018 19:51:05 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 49CF1C21C27; Sun, 10 Jun 2018 19:51:04 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id E778DC21BE5 for ; Sun, 10 Jun 2018 19:51:03 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 61375ACFC; Sun, 10 Jun 2018 19:51:03 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Sun, 10 Jun 2018 21:51:02 +0200 Message-Id: <20180610195102.38409-1-agraf@suse.de> X-Mailer: git-send-email 2.12.3 MIME-Version: 1.0 Cc: Heinrich Schuchardt , afaerber@suse.de Subject: [U-Boot] [PATCH] efi_loader: Convert runtime reset from switch to if statements X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 Signed-off-by: Alexander Graf --- arch/arm/cpu/armv8/fwcall.c | 11 ++++------- arch/arm/mach-bcm283x/reset.c | 11 ++++------- 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) { }