From patchwork Wed Nov 2 09:37:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 80457 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp40769qge; Wed, 2 Nov 2016 02:38:39 -0700 (PDT) X-Received: by 10.98.82.65 with SMTP id g62mr5120738pfb.119.1478079519316; Wed, 02 Nov 2016 02:38:39 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id ui10si1652261pac.74.2016.11.02.02.38.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Nov 2016 02:38:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c1rzM-00055E-Od; Wed, 02 Nov 2016 09:37:44 +0000 Received: from mail-it0-x233.google.com ([2607:f8b0:4001:c0b::233]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c1rzG-0004mN-Re for linux-arm-kernel@lists.infradead.org; Wed, 02 Nov 2016 09:37:40 +0000 Received: by mail-it0-x233.google.com with SMTP id m138so73879970itm.1 for ; Wed, 02 Nov 2016 02:37:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=PBUI21PFgkbR0k9504Tnk3ni2ZQ4ZEDhTxBWq+Lk75c=; b=BERXjBnSsKOKExYD5LhLJxzE+5wOe9vXbaNWXUcG1GmA6L8YdLmeazc7chNt7jUNmx 5VvxmCOpuoWsAMjYVVCB/hehJf9hE9vSd5QpeAroCs3UK39QmzQt44Rf8bh8KrNfDI1n 0Qh99l3xOOQkXrz4wnrzX88xS/L2Od68xvl4U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=PBUI21PFgkbR0k9504Tnk3ni2ZQ4ZEDhTxBWq+Lk75c=; b=Tz+3tsG3aIe1EDZFmuVSA7cAHKictQePUEn4t+orxhOJWvKZZ15foL6JNuEpjGMFir FVgBjeyMBENnS6svmGgm+2/qdEBy2ChdJ+IqmeinmxwTy01zhzCmdfS6catr/Kf/S6W7 m862mN26Qnr9EKpRh7ZNQ3+IdzVW2OUTSsYlkd42zM3gmXkF/0Z9FdyfcxyLQS4J0Dk/ 5n3kurbkNWZj9t7QiNIGNwa9NSaANhBaTFY6qINCNRavUOzfEapssfGTeK0pCuJi/UzN 4LLMqMAMtJWGbbJlq8Dp/H9v2+gv9jJSnWrX/wv5NBHorsYgmo1C/MTNF0gMjocHCm3m tO0g== X-Gm-Message-State: ABUngvejyTfg7Bv7SmWI3whXgHD4ypJ96th4T2XRVKRiLGGn3j69WUIB+tiKlZ6XQM2/m4M87ihn/GhuzTrL93Te X-Received: by 10.107.2.65 with SMTP id 62mr3026279ioc.83.1478079434069; Wed, 02 Nov 2016 02:37:14 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.59.147 with HTTP; Wed, 2 Nov 2016 02:37:13 -0700 (PDT) In-Reply-To: <1476962486-18368-3-git-send-email-ard.biesheuvel@linaro.org> References: <1476962486-18368-1-git-send-email-ard.biesheuvel@linaro.org> <1476962486-18368-3-git-send-email-ard.biesheuvel@linaro.org> From: Ard Biesheuvel Date: Wed, 2 Nov 2016 09:37:13 +0000 Message-ID: Subject: Re: [PATCH v2 2/3] efi/libstub: add random.c to ARM build To: "linux-arm-kernel@lists.infradead.org" , "linux-efi@vger.kernel.org" , Mark Rutland , Matt Fleming , Kees Cook X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161102_023739_011437_C434A90E X-CRM114-Status: GOOD ( 19.04 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:4001:c0b:0:0:0:233 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Theodore Ts'o , Ard Biesheuvel Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org On 20 October 2016 at 12:21, Ard Biesheuvel wrote: > Make random.c build for ARM by moving the fallback definition of > EFI_ALLOC_ALIGN to efistub.h > > Signed-off-by: Ard Biesheuvel > --- > drivers/firmware/efi/libstub/Makefile | 4 ++-- > drivers/firmware/efi/libstub/efi-stub-helper.c | 9 --------- > drivers/firmware/efi/libstub/efistub.h | 9 +++++++++ > 3 files changed, 11 insertions(+), 11 deletions(-) > I need the following hunks on top to make this build on ARM: "" """ This is because ARM does not have a division routine in the decompressor, and the fact that the division by 'align' should always involve a power of 2 is not visible to the compiler. If nobody objects, I will fold this in when applying Thanks, Ard. > diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile > index c06945160a41..40ddf8f763a8 100644 > --- a/drivers/firmware/efi/libstub/Makefile > +++ b/drivers/firmware/efi/libstub/Makefile > @@ -36,11 +36,11 @@ arm-deps := fdt_rw.c fdt_ro.c fdt_wip.c fdt.c fdt_empty_tree.c fdt_sw.c sort.c > $(obj)/lib-%.o: $(srctree)/lib/%.c FORCE > $(call if_changed_rule,cc_o_c) > > -lib-$(CONFIG_EFI_ARMSTUB) += arm-stub.o fdt.o string.o \ > +lib-$(CONFIG_EFI_ARMSTUB) += arm-stub.o fdt.o string.o random.o \ > $(patsubst %.c,lib-%.o,$(arm-deps)) > > lib-$(CONFIG_ARM) += arm32-stub.o > -lib-$(CONFIG_ARM64) += arm64-stub.o random.o > +lib-$(CONFIG_ARM64) += arm64-stub.o > CFLAGS_arm64-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET) > > # > diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c > index aded10662020..3c2fe209bbfe 100644 > --- a/drivers/firmware/efi/libstub/efi-stub-helper.c > +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c > @@ -32,15 +32,6 @@ > > static unsigned long __chunk_size = EFI_READ_CHUNK_SIZE; > > -/* > - * Allow the platform to override the allocation granularity: this allows > - * systems that have the capability to run with a larger page size to deal > - * with the allocations for initrd and fdt more efficiently. > - */ > -#ifndef EFI_ALLOC_ALIGN > -#define EFI_ALLOC_ALIGN EFI_PAGE_SIZE > -#endif > - > #define EFI_MMAP_NR_SLACK_SLOTS 8 > > struct file_info { > diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h > index ee49cd23ee63..fe1f22584c69 100644 > --- a/drivers/firmware/efi/libstub/efistub.h > +++ b/drivers/firmware/efi/libstub/efistub.h > @@ -15,6 +15,15 @@ > */ > #undef __init > > +/* > + * Allow the platform to override the allocation granularity: this allows > + * systems that have the capability to run with a larger page size to deal > + * with the allocations for initrd and fdt more efficiently. > + */ > +#ifndef EFI_ALLOC_ALIGN > +#define EFI_ALLOC_ALIGN EFI_PAGE_SIZE > +#endif > + > void efi_char16_printk(efi_system_table_t *, efi_char16_t *); > > efi_status_t efi_open_volume(efi_system_table_t *sys_table_arg, void *__image, > -- > 2.7.4 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --- a/drivers/firmware/efi/libstub/random.c +++ b/drivers/firmware/efi/libstub/random.c @@ -8,6 +8,7 @@ */ #include +#include #include #include "efistub.h" @@ -41,8 +42,9 @@ */ static unsigned long get_entry_num_slots(efi_memory_desc_t *md, unsigned long size, - unsigned long align) + unsigned long align_shift) { + unsigned long align = 1UL << align_shift; u64 start, end; if (md->type != EFI_CONVENTIONAL_MEMORY) @@ -55,7 +57,7 @@ if (start > end) return 0; - return (end - start + 1) / align; + return (end - start + 1) >> align_shift; } /* @@ -98,7 +100,7 @@ efi_memory_desc_t *md = (void *)memory_map + map_offset; unsigned long slots; - slots = get_entry_num_slots(md, size, align); + slots = get_entry_num_slots(md, size, ilog2(align)); MD_NUM_SLOTS(md) = slots; total_slots += slots; }