From patchwork Wed Mar 19 15:13:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Salter X-Patchwork-Id: 26588 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f72.google.com (mail-oa0-f72.google.com [209.85.219.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BF248203C3 for ; Wed, 19 Mar 2014 15:14:06 +0000 (UTC) Received: by mail-oa0-f72.google.com with SMTP id eb12sf11753671oac.3 for ; Wed, 19 Mar 2014 08:14:06 -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:message-id:subject:from:to:cc:date :in-reply-to:references:organization:mime-version:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe :content-type:content-transfer-encoding; bh=+jteX1FeM+QuAJdOa04GhxJfp30DtJRlwLT561FwHBY=; b=exIDAqC1hSEQbkFpT0mZ5Zb/BMrpgbObBnDlyqoVp/u81t6pGHBEVg6hldsfwR2sqn dtYiPrrvudyG35YqGPRruTY6SRghjLt1BmgjsZ5z63kwH0gyqpa9OWUwwGXkNJsI85Pe Chrakp4eWiP9tGX7LarCaRdX4OHFbWF/OKv0V6fYKum/WjhoEJrIEu0q/FYBaxK8YdQP clut1B3ySPCt01cel/JLjd5YTTP66xUP2eAyL9kVnUyPJbfGKQApH4FCFX086SaNs2xZ Q2yM+uQ8p4SgRfGwPc8+OPxNuc402CB7TwiKj39+CRcRmqnUmqGqdl0KhLa4jRTkOSDW aAgw== X-Gm-Message-State: ALoCoQkqKC5Ifkj3DUfOh+JRVmhcLL+yG6mORurcTOvPU8rlI1n/QBlfcqTPsJ5kn/LliyB0O5fQ X-Received: by 10.43.92.73 with SMTP id bp9mr13935055icc.26.1395242046272; Wed, 19 Mar 2014 08:14:06 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.37.102 with SMTP id q93ls2541262qgq.67.gmail; Wed, 19 Mar 2014 08:14:06 -0700 (PDT) X-Received: by 10.52.163.236 with SMTP id yl12mr690011vdb.39.1395242046086; Wed, 19 Mar 2014 08:14:06 -0700 (PDT) Received: from mail-ve0-f181.google.com (mail-ve0-f181.google.com [209.85.128.181]) by mx.google.com with ESMTPS id sh5si3588138vdc.50.2014.03.19.08.14.06 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 19 Mar 2014 08:14:06 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.181; Received: by mail-ve0-f181.google.com with SMTP id oy12so8838772veb.26 for ; Wed, 19 Mar 2014 08:14:06 -0700 (PDT) X-Received: by 10.220.44.20 with SMTP id y20mr12862vce.60.1395242045975; Wed, 19 Mar 2014 08:14:05 -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.220.78.9 with SMTP id i9csp307899vck; Wed, 19 Mar 2014 08:14:05 -0700 (PDT) X-Received: by 10.66.122.101 with SMTP id lr5mr17553314pab.130.1395242044712; Wed, 19 Mar 2014 08:14:04 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id vo7si14289959pab.303.2014.03.19.08.14.04; Wed, 19 Mar 2014 08:14:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965468AbaCSPN4 (ORCPT + 26 others); Wed, 19 Mar 2014 11:13:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37144 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965095AbaCSPNx (ORCPT ); Wed, 19 Mar 2014 11:13:53 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s2JFDLO4014592 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 19 Mar 2014 11:13:21 -0400 Received: from [10.3.113.16] ([10.3.113.16]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s2JFDKAx000376; Wed, 19 Mar 2014 11:13:20 -0400 Message-ID: <1395241998.2967.52.camel@deneb.redhat.com> Subject: Re: [PATCH v2 11/15] arm64: add EFI stub From: Mark Salter To: Catalin Marinas Cc: Leif Lindholm , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-efi@vger.kernel.org" , "matt.fleming@intel.com" , "roy.franz@linaro.org" , Ard Biesheuvel Date: Wed, 19 Mar 2014 11:13:18 -0400 In-Reply-To: <20140319105706.GE2214@arm.com> References: <1394750828-16351-1-git-send-email-leif.lindholm@linaro.org> <1394750828-16351-12-git-send-email-leif.lindholm@linaro.org> <20140318120919.GG13200@arm.com> <1395153629.2967.10.camel@deneb.redhat.com> <20140318182826.GC20497@arm.com> <1395178831.2967.29.camel@deneb.redhat.com> <20140319105706.GE2214@arm.com> Organization: Red Hat, Inc Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: msalter@redhat.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , On Wed, 2014-03-19 at 10:57 +0000, Catalin Marinas wrote: > On Tue, Mar 18, 2014 at 09:40:31PM +0000, Mark Salter wrote: > > On Tue, 2014-03-18 at 18:28 +0000, Catalin Marinas wrote: > > > If UEFI doesn't handle the caches, the only thing left to EFI_STUB is to > > > flush by MVA. We don't need to flush the whole DRAM (and I would even > > > recommend it) but at least the relevant kernel code/data touched with > > > the MMU disabled. > > > > So, it goes like this: > > > > 1) UEFI calls stub with MMU/Caches on. Stub/kernel can be anywhere. > > 2) Stub runs and relocates kernel to the desired runtime location > > but continues to execute from wherever UEFI loaded it until just > > after ExitBootServices(). > > 3) After ExitBootServices, efi_entry() returns relocated entry point > > for kernel to efi_stub_entry() in efi-entry.S where the Dcache and > > MMU are turned off, the __flush_dcache_all is called, then the > > code jumps to the kernel proper entry point. > > > > It isn't clear to me if UEFI does cache flushing at ExitBootServices > > time, but even so, at least stack use will get cached between then and > > the kernel entry point. The stub could conceivably get its hands on the > > EFI memmap and invalidate dcache using address ranges from UEFI memory > > descriptors so maybe that is the way we should do it. > > I think the stub just needs to flush the relocated kernel image, ensure > it is sync with the memory. Additional flushing can be done by the > kernel for bits it writes (like page tables, code patching etc). We can > enter the kernel with the SCTLR.I bit set, so it can allocate in an > unified cache already and D-cache maintenance would be needed anyway. How about this? --- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/arch/arm64/kernel/efi-entry.S b/arch/arm64/kernel/efi-entry.S index 83bfb72..ed480b2 100644 --- a/arch/arm64/kernel/efi-entry.S +++ b/arch/arm64/kernel/efi-entry.S @@ -52,11 +52,19 @@ ENTRY(efi_stub_entry) * efi_entry() will have relocated the kernel image if necessary * and we return here with device tree address in x0 and the kernel * entry point stored at *image_addr. Save those values in registers - * which are preserved by __flush_dcache_all. + * which are callee preserved. */ - ldr x1, [sp, #16] mov x20, x0 - mov x21, x1 + ldr x0, [sp, #16] + mov x21, x0 + + adrp x1, _text + add x1, x1, #:lo12:_text + adrp x2, _edata + add x2, x2, #:lo12:_edata + sub x1, x2, x1 + + bl __flush_dcache_area /* Turn off Dcache and MMU */ mrs x0, CurrentEL @@ -76,8 +84,6 @@ ENTRY(efi_stub_entry) msr sctlr_el1, x0 isb 2: - bl __flush_dcache_all - /* Jump to real entry point */ mov x0, x20 mov x1, xzr