From patchwork Wed Aug 7 03:45:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 2839754 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 A3EC19F479 for ; Wed, 7 Aug 2013 03:48:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C6030201CB for ; Wed, 7 Aug 2013 03:48:41 +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 BB145201C7 for ; Wed, 7 Aug 2013 03:48:40 +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 1V6uib-0003YK-91; Wed, 07 Aug 2013 03:47:26 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V6ui6-0001PA-3Z; Wed, 07 Aug 2013 03:46:54 +0000 Received: from mail-gh0-f178.google.com ([209.85.160.178]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V6uh2-0001Dp-Jb for linux-arm-kernel@lists.infradead.org; Wed, 07 Aug 2013 03:45:59 +0000 Received: by mail-gh0-f178.google.com with SMTP id g15so392713ghb.37 for ; Tue, 06 Aug 2013 20:45:27 -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=jxNd4+Q4zE9bhLKJCz2TJX3HmwicmbaQ0z+UoC25NZo=; b=FAu7E+CWBZNltrFshWwvjYitxuM7jLkDRvsoNQFLY7Qb43x19bERmNJvkld74ugw5Z 2YioqYxyPYEj6nBlgShmV5JSX7qbI6h3KeYPUqRku0ohYiPYRqPuh5rxFE+8QTmsea09 DqPrR0SuMLooWOsu6RJfhlkPfekZ/4gC5BSmXzMlin1hBoHwSBrNGqRqRXUE8hmBG0LJ kLfsGwrdXFKxpe1fhFI9pN1V6/wpeHKCXmCftfQQ05Wq/XcfMGZlT2aLhRdw1rxGwm0e LsTkNxGrpoEIX5ComlJoglKiuSEfJikt0G0kLR3hniWuEdlNDCwNzSDe4n4qXUMHMx3f jhpQ== X-Gm-Message-State: ALoCoQkifApyamSAY49K6oLzOKAeUFgmmsKcVYxZE1Na1gsUFTmDVfMmJFuq0svSMKcjX3Rkeb64 X-Received: by 10.236.88.170 with SMTP id a30mr732385yhf.85.1375847127551; Tue, 06 Aug 2013 20:45:27 -0700 (PDT) Received: from rfranz-v430.caveonetworks.com (64.2.3.195.ptr.us.xo.net. [64.2.3.195]) by mx.google.com with ESMTPSA id s65sm6814380yhs.14.2013.08.06.20.45.26 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 06 Aug 2013 20:45:27 -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 05/17] Add minimum address parameter to efi_low_alloc() Date: Tue, 6 Aug 2013 20:45:01 -0700 Message-Id: <1375847113-24884-6-git-send-email-roy.franz@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1375847113-24884-1-git-send-email-roy.franz@linaro.org> References: <1375847113-24884-1-git-send-email-roy.franz@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130806_234548_907202_310A49F5 X-CRM114-Status: GOOD ( 10.19 ) X-Spam-Score: -2.6 (--) Cc: Roy Franz , dave.martin@arm.com, leif.lindholm@linaro.org 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 --- arch/x86/boot/compressed/eboot.c | 11 ++++++----- drivers/firmware/efi/efi-stub-helper.c | 5 ++++- 2 files changed, 10 insertions(+), 6 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 8e6a7f9..63e3556 100644 --- a/drivers/firmware/efi/efi-stub-helper.c +++ b/drivers/firmware/efi/efi-stub-helper.c @@ -167,7 +167,7 @@ fail: */ 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;