From patchwork Fri Aug 9 23:26:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 2842251 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 617DE9F294 for ; Fri, 9 Aug 2013 23:29:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 77A7220345 for ; Fri, 9 Aug 2013 23:29:06 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5DBAB20316 for ; Fri, 9 Aug 2013 23:29:05 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V7w6J-0000wi-6z; Fri, 09 Aug 2013 23:28:08 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V7w5t-0003i3-Gk; Fri, 09 Aug 2013 23:27:41 +0000 Received: from mail-pa0-f52.google.com ([209.85.220.52]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V7w59-0003Yo-4p for linux-arm-kernel@lists.infradead.org; Fri, 09 Aug 2013 23:26:58 +0000 Received: by mail-pa0-f52.google.com with SMTP id kq13so5405976pab.39 for ; Fri, 09 Aug 2013 16:26:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=odXzCzy3FHvlf587UY0xD+K6a+4fqGWrgHQrpB15Tpw=; b=HoOkb7mWAMi+xzWGxCzFkWW/O50R/cfVrEtCVqVbxJ635UTJfXWIGUC6h0RoPXtZMW SwkkU1Ke17IHlXQn0q6DWjWL9cGfMmxdL9UXRB1JTom8w+zl+ethY3yBSv78LuB1y24S xAMUQnUIafhDU/Vb4nD1HpqhMnw6dudVXKQUgjd9B6Jnwp9E0XwDEEjsogsmZ+ADflxx pEELMA+731b0cPTyiwzWR6cvJjBWHtOi7Vq9G91raHztS7PWbNw5FjHkI9p0pF+dGctJ bkKwAmUrQvpncexzI4C9qtn/S2xPxxqcFVIWIQxWLReSMGGKAP2uT17InPk8I/wlFeZR vMIw== X-Gm-Message-State: ALoCoQnHLm1vBjhBykfcK/w0O/JqB196blj823JQYuJzcK1eDMmH8gKDyka+rALzFPoTkTXxXOeb X-Received: by 10.68.253.138 with SMTP id aa10mr13785252pbd.24.1376090793816; Fri, 09 Aug 2013 16:26:33 -0700 (PDT) Received: from rfranz-i7.local (c-24-10-48-230.hsd1.ca.comcast.net. [24.10.48.230]) by mx.google.com with ESMTPSA id ue9sm24823913pab.7.2013.08.09.16.26.32 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 09 Aug 2013 16:26:33 -0700 (PDT) From: Roy Franz To: linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, matt.fleming@intel.com, linux@arm.linux.org.uk Subject: [PATCH 04/16] Add minimum address parameter to efi_low_alloc() Date: Fri, 9 Aug 2013 16:26:05 -0700 Message-Id: <1376090777-20090-5-git-send-email-roy.franz@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1376090777-20090-1-git-send-email-roy.franz@linaro.org> References: <1376090777-20090-1-git-send-email-roy.franz@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130809_192655_336798_4150BF2C X-CRM114-Status: GOOD ( 10.96 ) X-Spam-Score: -2.6 (--) Cc: Roy Franz , dave.martin@arm.com, leif.lindholm@linaro.org, msalter@redhat.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This allows allocations to be made low in memory while avoiding allocations at the base of memory. Signed-off-by: Roy Franz Acked-by: Mark Salter Reviewed-by: Grant Likely --- arch/x86/boot/compressed/eboot.c | 11 ++++++----- drivers/firmware/efi/efi-stub-helper.c | 7 +++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index 2a4430a..f44ef2f 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c @@ -458,7 +458,7 @@ struct boot_params *make_boot_params(void *handle, efi_system_table_t *_table) } status = efi_low_alloc(sys_table, 0x4000, 1, - (unsigned long *)&boot_params); + (unsigned long *)&boot_params, 0); if (status != EFI_SUCCESS) { efi_printk(sys_table, "Failed to alloc lowmem for boot params\n"); return NULL; @@ -505,7 +505,7 @@ struct boot_params *make_boot_params(void *handle, efi_system_table_t *_table) options_size++; /* NUL termination */ status = efi_low_alloc(sys_table, options_size, 1, - &cmdline); + &cmdline, 0); if (status != EFI_SUCCESS) { efi_printk(sys_table, "Failed to alloc mem for cmdline\n"); goto fail; @@ -563,7 +563,8 @@ static efi_status_t exit_boot(struct boot_params *boot_params, again: size += sizeof(*mem_map) * 2; _size = size; - status = efi_low_alloc(sys_table, size, 1, (unsigned long *)&mem_map); + status = efi_low_alloc(sys_table, size, 1, + (unsigned long *)&mem_map, 0); if (status != EFI_SUCCESS) return status; @@ -697,7 +698,7 @@ static efi_status_t relocate_kernel(struct setup_header *hdr) nr_pages, &start); if (status != EFI_SUCCESS) { status = efi_low_alloc(sys_table, hdr->init_size, - hdr->kernel_alignment, &start); + hdr->kernel_alignment, &start, 0); if (status != EFI_SUCCESS) efi_printk(sys_table, "Failed to alloc mem for kernel\n"); } @@ -745,7 +746,7 @@ struct boot_params *efi_main(void *handle, efi_system_table_t *_table, gdt->size = 0x800; status = efi_low_alloc(sys_table, gdt->size, 8, - (unsigned long *)&gdt->address); + (unsigned long *)&gdt->address, 0); if (status != EFI_SUCCESS) { efi_printk(sys_table, "Failed to alloc mem for gdt\n"); goto fail; diff --git a/drivers/firmware/efi/efi-stub-helper.c b/drivers/firmware/efi/efi-stub-helper.c index 0218d535..40cd16e 100644 --- a/drivers/firmware/efi/efi-stub-helper.c +++ b/drivers/firmware/efi/efi-stub-helper.c @@ -163,11 +163,11 @@ fail: } /* - * Allocate at the lowest possible address. + * Allocate at the lowest possible address, that is not below min. */ static efi_status_t efi_low_alloc(efi_system_table_t *sys_table_arg, unsigned long size, unsigned long align, - unsigned long *addr) + unsigned long *addr, unsigned long min) { unsigned long map_size, desc_size; efi_memory_desc_t *map; @@ -204,6 +204,9 @@ static efi_status_t efi_low_alloc(efi_system_table_t *sys_table_arg, if (start == 0x0) start += 8; + if (start < min) + start = min; + start = round_up(start, align); if ((start + size) > end) continue;