From patchwork Fri Jul 4 17:41:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 33111 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f72.google.com (mail-yh0-f72.google.com [209.85.213.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D0A2020C88 for ; Fri, 4 Jul 2014 17:43:43 +0000 (UTC) Received: by mail-yh0-f72.google.com with SMTP id f10sf6787837yha.3 for ; Fri, 04 Jul 2014 10:43:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=AHNrE9q/JsUs9usNoyCZKIBM7SJg5nycZARPd0q+97s=; b=mIdHUAsEbfrPQjwRrMswj1ikfmcJRWyX88NlAjXFWeZLpd+TB1MUU/VCs2otQPJj3w llDBOIczypnHv2lfdiMlXO10B/Zk+coALL5uEidudzMwX4gVgUz7PGeuYnUMb8OyGqUg 6SCOcBic/5bETAD2OYVI7Dyl7HsxvR1p7r2hyESkQthkH3uY+Fyr65CiR6CClUxI1+h/ /3nAroiFiMv8W2rkFMYN5q6opC9V/TWybuLYz1Ny78KrRHuAKPwPwb8ezxT7YVhFBdOz 5HqTfsbwc0bBnQ9x5Gka166XXszb8VV/bjHTcDPh6XI+x4dhLuyu9LyMEWxL4Lldfvli YKzw== X-Gm-Message-State: ALoCoQlAV3+jepKbqJaW1qNnutWFxvZiMU5EX9VfnPHx5G/kLeeCXhUObhWNrP3D5giV/BAXmNqQ X-Received: by 10.58.114.41 with SMTP id jd9mr6334581veb.9.1404495823639; Fri, 04 Jul 2014 10:43:43 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.108.34 with SMTP id i31ls921461qgf.51.gmail; Fri, 04 Jul 2014 10:43:43 -0700 (PDT) X-Received: by 10.52.252.4 with SMTP id zo4mr9035953vdc.20.1404495823571; Fri, 04 Jul 2014 10:43:43 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id xk1si15773600vdc.56.2014.07.04.10.43.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 04 Jul 2014 10:43:43 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 as permitted sender) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id il7so1809149vcb.26 for ; Fri, 04 Jul 2014 10:43:43 -0700 (PDT) X-Received: by 10.58.12.73 with SMTP id w9mr10800619veb.13.1404495823485; Fri, 04 Jul 2014 10:43:43 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp480957vcb; Fri, 4 Jul 2014 10:43:42 -0700 (PDT) X-Received: by 10.70.134.165 with SMTP id pl5mr3274176pdb.140.1404495822557; Fri, 04 Jul 2014 10:43:42 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id iw8si35713814pbc.137.2014.07.04.10.43.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Jul 2014 10:43:42 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1X37VQ-0006Xs-LI; Fri, 04 Jul 2014 17:42:40 +0000 Received: from mail-we0-f182.google.com ([74.125.82.182]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X37VF-0006Nb-4r for linux-arm-kernel@lists.infradead.org; Fri, 04 Jul 2014 17:42:29 +0000 Received: by mail-we0-f182.google.com with SMTP id q59so1958090wes.13 for ; Fri, 04 Jul 2014 10:42:06 -0700 (PDT) X-Received: by 10.180.188.144 with SMTP id ga16mr19710146wic.72.1404495726721; Fri, 04 Jul 2014 10:42:06 -0700 (PDT) Received: from ards-macbook-pro.local (89-164-111-59.dsl.iskon.hr. [89.164.111.59]) by mx.google.com with ESMTPSA id ec8sm62606790wic.10.2014.07.04.10.42.04 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 04 Jul 2014 10:42:06 -0700 (PDT) From: Ard Biesheuvel To: matt.fleming@intel.com, catalin.marinas@arm.com, msalter@redhat.com Subject: [PATCH v3 2/2] efi/arm64: preserve FP/SIMD registers on UEFI runtime services calls Date: Fri, 4 Jul 2014 19:41:53 +0200 Message-Id: <1404495713-10338-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1404495713-10338-1-git-send-email-ard.biesheuvel@linaro.org> References: <1404495713-10338-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140704_104229_340059_1499E23E X-CRM114-Status: GOOD ( 13.69 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.182 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [74.125.82.182 listed in wl.mailspike.net] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: linux-efi@vger.kernel.org, leif.lindholm@linaro.org, linux-arm-kernel@lists.infradead.org, Ard Biesheuvel X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 According to the UEFI spec section 2.3.6.4, the use of FP/SIMD instructions is allowed, and should adhere to the AAPCS64 calling convention, which states that 'only the bottom 64 bits of each value stored in registers v8-v15 need to be preserved' (section 5.1.2). This applies equally to UEFI Runtime Services called by the kernel, so make sure the FP/SIMD register file is preserved in this case. We do this by enabling the wrappers for UEFI Runtime Services (CONFIG_EFI_RUNTIME_WRAPPERS) and inserting calls to kernel_neon_begin() and kernel_neon_end() into these wrappers. Signed-off-by: Ard Biesheuvel Acked-by: Catalin Marinas --- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/efi.h | 21 +++++++++++++++++++++ arch/arm64/kernel/efi.c | 14 +------------- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index a474de346be6..93e11f4d9513 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -299,6 +299,7 @@ config EFI select LIBFDT select UCS2_STRING select EFI_PARAMS_FROM_FDT + select EFI_RUNTIME_WRAPPERS default y help This option provides support for runtime services provided diff --git a/arch/arm64/include/asm/efi.h b/arch/arm64/include/asm/efi.h index 5a46c4e7f539..375ba342dca6 100644 --- a/arch/arm64/include/asm/efi.h +++ b/arch/arm64/include/asm/efi.h @@ -2,6 +2,7 @@ #define _ASM_EFI_H #include +#include #ifdef CONFIG_EFI extern void efi_init(void); @@ -11,4 +12,24 @@ extern void efi_idmap_init(void); #define efi_idmap_init() #endif +#define efi_call_virt(f, ...) \ +({ \ + efi_##f##_t *__f = efi.systab->runtime->f; \ + efi_status_t __s; \ + \ + kernel_neon_begin(); \ + __s = __f(__VA_ARGS__); \ + kernel_neon_end(); \ + __s; \ +}) + +#define __efi_call_virt(f, ...) \ +({ \ + efi_##f##_t *__f = efi.systab->runtime->f; \ + \ + kernel_neon_begin(); \ + __f(__VA_ARGS__); \ + kernel_neon_end(); \ +}) + #endif /* _ASM_EFI_H */ diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c index 14db1f6e8d7f..56c3327bbf79 100644 --- a/arch/arm64/kernel/efi.c +++ b/arch/arm64/kernel/efi.c @@ -449,19 +449,7 @@ static int __init arm64_enter_virtual_mode(void) /* Set up runtime services function pointers */ runtime = efi.systab->runtime; - efi.get_time = runtime->get_time; - efi.set_time = runtime->set_time; - efi.get_wakeup_time = runtime->get_wakeup_time; - efi.set_wakeup_time = runtime->set_wakeup_time; - efi.get_variable = runtime->get_variable; - efi.get_next_variable = runtime->get_next_variable; - efi.set_variable = runtime->set_variable; - efi.query_variable_info = runtime->query_variable_info; - efi.update_capsule = runtime->update_capsule; - efi.query_capsule_caps = runtime->query_capsule_caps; - efi.get_next_high_mono_count = runtime->get_next_high_mono_count; - efi.reset_system = runtime->reset_system; - + efi_native_runtime_setup(); set_bit(EFI_RUNTIME_SERVICES, &efi.flags); return 0;