From patchwork Tue Sep 16 00:47:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 37436 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f197.google.com (mail-we0-f197.google.com [74.125.82.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 884AA203E6 for ; Tue, 16 Sep 2014 02:34:01 +0000 (UTC) Received: by mail-we0-f197.google.com with SMTP id w61sf2686962wes.4 for ; Mon, 15 Sep 2014 19:34:00 -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:cc:subject:date:message-id :in-reply-to:references: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; bh=ubiH7yeAAP1p6fR//bGABrKy+egPSeaCgUAf6WO8UN8=; b=OSk/MFM9XELErV2nfm5PfXmDdfFiYVyCsdOAsalxvSMkWWUrTLMw66Y8CRwQEcKEOn V2Mhaok8cZTxRqga8fdycllsWMAlaYgHv/J1+idwxLflJdTXm9miy2vWdl2fFnNcR1QZ wbtsWkOqAAxN4MAXp8F2KILCoyZ7xtjPlMSkA278uO33oXO2s9dm1/0WtprdXRwmfH7l zUcOQdcWVIB1B/n3bbbIjfm7rUhoVpSxFQOpGp5FXTPiMdSj6o5wsnU9yHAeXArBiJp9 4AuixCgoTFwleAVb8mOAL2pMlE8nx/b3Gl7/O+5ymmtogzjARAH4lTKmzPXb/SJPGQNa 9rbA== X-Gm-Message-State: ALoCoQlDlE4W4vg8+dN0961+M7U3rbfCvJ031q2X6L3IExRgbWA5/2Dm5Z7HBspgekYWC8eJEm0c X-Received: by 10.180.8.1 with SMTP id n1mr6184271wia.1.1410834840670; Mon, 15 Sep 2014 19:34:00 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.116.99 with SMTP id jv3ls448113lab.54.gmail; Mon, 15 Sep 2014 19:34:00 -0700 (PDT) X-Received: by 10.112.13.10 with SMTP id d10mr31046286lbc.10.1410834840466; Mon, 15 Sep 2014 19:34:00 -0700 (PDT) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com [209.85.215.51]) by mx.google.com with ESMTPS id oe10si21845918lbb.34.2014.09.15.19.34.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Sep 2014 19:34:00 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by mail-la0-f51.google.com with SMTP id gi9so5950735lab.10 for ; Mon, 15 Sep 2014 19:34:00 -0700 (PDT) X-Received: by 10.112.4.33 with SMTP id h1mr30358813lbh.67.1410834839968; Mon, 15 Sep 2014 19:33:59 -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.112.130.169 with SMTP id of9csp318847lbb; Mon, 15 Sep 2014 19:33:59 -0700 (PDT) X-Received: by 10.69.26.74 with SMTP id iw10mr11188446pbd.137.1410834838146; Mon, 15 Sep 2014 19:33:58 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fr3si26613080pbd.34.2014.09.15.19.33.57 for ; Mon, 15 Sep 2014 19:33:58 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753760AbaIPCdh (ORCPT + 27 others); Mon, 15 Sep 2014 22:33:37 -0400 Received: from mail-bn1on0113.outbound.protection.outlook.com ([157.56.110.113]:5376 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752716AbaIPCdg (ORCPT ); Mon, 15 Sep 2014 22:33:36 -0400 Received: from BLUPR02CA030.namprd02.prod.outlook.com (25.160.23.148) by BL2PR02MB484.namprd02.prod.outlook.com (10.141.95.151) with Microsoft SMTP Server (TLS) id 15.0.1019.16; Tue, 16 Sep 2014 02:33:33 +0000 Received: from BY2FFO11FD025.protection.gbl (2a01:111:f400:7c0c::199) by BLUPR02CA030.outlook.office365.com (2a01:111:e400:8ad::20) with Microsoft SMTP Server (TLS) id 15.0.1029.13 via Frontend Transport; Tue, 16 Sep 2014 02:33:32 +0000 Received: from atltwp02.amd.com (165.204.84.222) by BY2FFO11FD025.mail.protection.outlook.com (10.1.15.214) with Microsoft SMTP Server id 15.0.1019.14 via Frontend Transport; Tue, 16 Sep 2014 02:33:31 +0000 X-WSS-ID: 0NBZ33P-08-TT4-02 X-M-MSG: Received: from satlvexedge01.amd.com (satlvexedge01.amd.com [10.177.96.28]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by atltwp02.amd.com (Axway MailGate 5.3.1) with ESMTPS id 2CD73BD88E2; Mon, 15 Sep 2014 21:33:25 -0500 (CDT) Received: from SATLEXDAG01.amd.com (10.181.40.3) by satlvexedge01.amd.com (10.177.96.28) with Microsoft SMTP Server (TLS) id 14.3.195.1; Mon, 15 Sep 2014 21:33:34 -0500 Received: from ssuthiku-fedora-lt.amd.com (10.180.168.240) by SATLEXDAG01.amd.com (10.181.40.3) with Microsoft SMTP Server id 14.3.195.1; Mon, 15 Sep 2014 22:33:28 -0400 From: To: , , , CC: , , , , , , , , , , , , Ard Biesheuvel Subject: [PATCH 2/4] arm64/efi: efistub: don't abort if base of DRAM is occupied Date: Mon, 15 Sep 2014 19:47:24 -0500 Message-ID: <1410828446-28502-3-git-send-email-suravee.suthikulpanit@amd.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1410828446-28502-1-git-send-email-suravee.suthikulpanit@amd.com> References: <1410828446-28502-1-git-send-email-suravee.suthikulpanit@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.222; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(428002)(189002)(199003)(97736003)(31966008)(83322001)(105586002)(86152002)(4396001)(20776003)(33646002)(106466001)(107046002)(53416004)(83072002)(36756003)(95666004)(89996001)(84676001)(92726001)(90102001)(77096002)(44976005)(87286001)(87936001)(68736004)(85306004)(76482001)(62966002)(19580395003)(86362001)(76176999)(229853001)(93916002)(102836001)(104166001)(77156001)(21056001)(101416001)(48376002)(47776003)(2201001)(99396002)(88136002)(19580405001)(50986999)(92566001)(50226001)(81342003)(74662003)(81542003)(74502003)(80022003)(79102003)(77982003)(46102003)(85852003)(2101003); DIR:OUT; SFP:1102; SCL:1; SRVR:BL2PR02MB484; H:atltwp02.amd.com; FPR:; MLV:sfv; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;UriScan:; X-Forefront-PRVS: 03361FCC43 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-OriginatorOrg: amd4.onmicrosoft.com 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: suravee.suthikulpanit@amd.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 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 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Ard Biesheuvel If we cannot relocate the kernel Image to its preferred offset of base of DRAM plus TEXT_OFFSET, instead relocate it to the lowest available 2 MB boundary plus TEXT_OFFSET. We may lose a bit of memory at the low end, but we can still proceed normally otherwise. Acked-by: Mark Salter Acked-by: Mark Rutland Acked-by: Leif Lindholm Tested-by: Leif Lindholm Signed-off-by: Ard Biesheuvel Signed-off-by: Will Deacon --- arch/arm64/kernel/efi-stub.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/arch/arm64/kernel/efi-stub.c b/arch/arm64/kernel/efi-stub.c index 1317fef..d27dd98 100644 --- a/arch/arm64/kernel/efi-stub.c +++ b/arch/arm64/kernel/efi-stub.c @@ -28,20 +28,16 @@ efi_status_t handle_kernel_image(efi_system_table_t *sys_table, kernel_size = _edata - _text; if (*image_addr != (dram_base + TEXT_OFFSET)) { kernel_memsize = kernel_size + (_end - _edata); - status = efi_relocate_kernel(sys_table, image_addr, - kernel_size, kernel_memsize, - dram_base + TEXT_OFFSET, - PAGE_SIZE); + status = efi_low_alloc(sys_table, kernel_memsize + TEXT_OFFSET, + SZ_2M, reserve_addr); if (status != EFI_SUCCESS) { pr_efi_err(sys_table, "Failed to relocate kernel\n"); return status; } - if (*image_addr != (dram_base + TEXT_OFFSET)) { - pr_efi_err(sys_table, "Failed to alloc kernel memory\n"); - efi_free(sys_table, kernel_memsize, *image_addr); - return EFI_LOAD_ERROR; - } - *image_size = kernel_memsize; + memcpy((void *)*reserve_addr + TEXT_OFFSET, (void *)*image_addr, + kernel_size); + *image_addr = *reserve_addr + TEXT_OFFSET; + *reserve_size = kernel_memsize + TEXT_OFFSET; }