From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4457BC3F2D1 for ; Fri, 28 Feb 2020 11:19:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2107120658 for ; Fri, 28 Feb 2020 11:19:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725884AbgB1LTX (ORCPT ); Fri, 28 Feb 2020 06:19:23 -0500 Received: from foss.arm.com ([217.140.110.172]:36668 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725928AbgB1LTX (ORCPT ); Fri, 28 Feb 2020 06:19:23 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 214514B2; Fri, 28 Feb 2020 03:19:23 -0800 (PST) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8BC953F73B; Fri, 28 Feb 2020 03:19:22 -0800 (PST) Date: Fri, 28 Feb 2020 11:19:20 +0000 From: Mark Rutland To: Ard Biesheuvel Cc: linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH efi-next 2/3] efi/arm64: clean EFI stub exit code from cache instead of avoiding it Message-ID: <20200228111920.GB36089@lakrids.cambridge.arm.com> References: <20200228100244.10979-1-ardb@kernel.org> <20200228100244.10979-3-ardb@kernel.org> <20200228111450.GA36089@lakrids.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200228111450.GA36089@lakrids.cambridge.arm.com> User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org On Fri, Feb 28, 2020 at 11:14:50AM +0000, Mark Rutland wrote: > On Fri, Feb 28, 2020 at 11:02:43AM +0100, Ard Biesheuvel wrote: > > Commit 9f9223778 ("efi/libstub/arm: Make efi_entry() an ordinary PE/COFF > > entrypoint") modified the handover code written in assembler, and for > > maintainability, aligned the logic with the logic used in the 32-bit ARM > > version, which is to avoid cache maintenance on the remaining instructions > > in the subroutine that will be executed with the MMU and caches off, and > > instead, branch into the relocated copy of the kernel image. > > > > However, this assumes that this copy is executable, and this means we > > expect EFI_LOADER_DATA regions to be executable as well, which is not > > a reasonable assumption to make, even if this is true for most UEFI > > implementations today. > > > > So change this back, and add a __flush_dcache_area() call to cover the > > remaining code in the subroutine. > > > > Signed-off-by: Ard Biesheuvel > > --- > > arch/arm64/kernel/efi-entry.S | 18 +++++++++--------- > > arch/arm64/kernel/image-vars.h | 2 +- > > 2 files changed, 10 insertions(+), 10 deletions(-) > > > > diff --git a/arch/arm64/kernel/efi-entry.S b/arch/arm64/kernel/efi-entry.S > > index 4cfd03c35c49..d5dee064975f 100644 > > --- a/arch/arm64/kernel/efi-entry.S > > +++ b/arch/arm64/kernel/efi-entry.S > > @@ -19,7 +19,8 @@ ENTRY(efi_enter_kernel) > > * point stored in x0. Save those values in registers which are > > * callee preserved. > > */ > > - mov x19, x0 // relocated Image address > > + ldr w2, =stext_offset > > + add x19, x0, x2 // relocated Image entrypoint > > mov x20, x1 // DTB address > > > > /* > > @@ -29,15 +30,14 @@ ENTRY(efi_enter_kernel) > > ldr w1, =kernel_size > > bl __flush_dcache_area > > ic ialluis > > - dsb sy > > > > /* > > - * Jump across, into the copy of the image that we just cleaned > > - * to the PoC, so that we can safely disable the MMU and caches. > > + * Flush the remainder of this routine to the PoC > > Minor nit, but could we please say 'Clean' rather than 'Flush' here? > > Even better, we now have __clean_dcache_area_poc(), and can use that > too. ... or if that's better as a subsequent cleanup for consistency, that'd also be fine, and needn't block this patch. Thanks, Mark. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FC4CC3F2D1 for ; Fri, 28 Feb 2020 11:19:48 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1280E20658 for ; Fri, 28 Feb 2020 11:19:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="F7mTtwg9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1280E20658 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=90YPxaIkDlkATQbBgD8uz0UKDbZMz4AeIrwf5TI3fTU=; b=F7mTtwg9PCPf6k ec8uG9S2EP5NlO6NtnNPdsYxgVzD1aMdfXn6rru8saqeW+h6/gvy3bug2Vg2b0SLZCXSOkM7io4Oa QU55ljO+6+GpnmIhGCLHfIFBnu6aY5IlPRspiIuMFMPcUmS6M6onA7qFlGKVuOnBICdgOcUaDRT1W h0lk2XfmtQwjSzayz3K3h1dLqf2ikOviktcIXtGCNtK/pJo910M0xsDWnfqUqI5rZ7LsKOMIiDCPr 6m8WzviZttJfixEU2JKrXfUKCJzOL5u671fhqSDg9k+U8olhq3zcdjbAG5GA/lEzlTE3wFD2c+Vik rEsjBu9W5vYS7M3f2o7g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j7dg9-0006ue-OL; Fri, 28 Feb 2020 11:19:37 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j7dfv-0006si-Kx for linux-arm-kernel@lists.infradead.org; Fri, 28 Feb 2020 11:19:25 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 214514B2; Fri, 28 Feb 2020 03:19:23 -0800 (PST) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8BC953F73B; Fri, 28 Feb 2020 03:19:22 -0800 (PST) Date: Fri, 28 Feb 2020 11:19:20 +0000 From: Mark Rutland To: Ard Biesheuvel Subject: Re: [PATCH efi-next 2/3] efi/arm64: clean EFI stub exit code from cache instead of avoiding it Message-ID: <20200228111920.GB36089@lakrids.cambridge.arm.com> References: <20200228100244.10979-1-ardb@kernel.org> <20200228100244.10979-3-ardb@kernel.org> <20200228111450.GA36089@lakrids.cambridge.arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200228111450.GA36089@lakrids.cambridge.arm.com> User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200228_031923_729584_D9C16591 X-CRM114-Status: GOOD ( 21.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Feb 28, 2020 at 11:14:50AM +0000, Mark Rutland wrote: > On Fri, Feb 28, 2020 at 11:02:43AM +0100, Ard Biesheuvel wrote: > > Commit 9f9223778 ("efi/libstub/arm: Make efi_entry() an ordinary PE/COFF > > entrypoint") modified the handover code written in assembler, and for > > maintainability, aligned the logic with the logic used in the 32-bit ARM > > version, which is to avoid cache maintenance on the remaining instructions > > in the subroutine that will be executed with the MMU and caches off, and > > instead, branch into the relocated copy of the kernel image. > > > > However, this assumes that this copy is executable, and this means we > > expect EFI_LOADER_DATA regions to be executable as well, which is not > > a reasonable assumption to make, even if this is true for most UEFI > > implementations today. > > > > So change this back, and add a __flush_dcache_area() call to cover the > > remaining code in the subroutine. > > > > Signed-off-by: Ard Biesheuvel > > --- > > arch/arm64/kernel/efi-entry.S | 18 +++++++++--------- > > arch/arm64/kernel/image-vars.h | 2 +- > > 2 files changed, 10 insertions(+), 10 deletions(-) > > > > diff --git a/arch/arm64/kernel/efi-entry.S b/arch/arm64/kernel/efi-entry.S > > index 4cfd03c35c49..d5dee064975f 100644 > > --- a/arch/arm64/kernel/efi-entry.S > > +++ b/arch/arm64/kernel/efi-entry.S > > @@ -19,7 +19,8 @@ ENTRY(efi_enter_kernel) > > * point stored in x0. Save those values in registers which are > > * callee preserved. > > */ > > - mov x19, x0 // relocated Image address > > + ldr w2, =stext_offset > > + add x19, x0, x2 // relocated Image entrypoint > > mov x20, x1 // DTB address > > > > /* > > @@ -29,15 +30,14 @@ ENTRY(efi_enter_kernel) > > ldr w1, =kernel_size > > bl __flush_dcache_area > > ic ialluis > > - dsb sy > > > > /* > > - * Jump across, into the copy of the image that we just cleaned > > - * to the PoC, so that we can safely disable the MMU and caches. > > + * Flush the remainder of this routine to the PoC > > Minor nit, but could we please say 'Clean' rather than 'Flush' here? > > Even better, we now have __clean_dcache_area_poc(), and can use that > too. ... or if that's better as a subsequent cleanup for consistency, that'd also be fine, and needn't block this patch. Thanks, Mark. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel