From patchwork Mon Mar 23 10:52:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 46179 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9B45B214B0 for ; Mon, 23 Mar 2015 10:55:08 +0000 (UTC) Received: by lbvp9 with SMTP id p9sf26582913lbv.0 for ; Mon, 23 Mar 2015 03:55:07 -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:subject:date:message-id:cc :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=6yy3ZqXTpaoR3rMUyVquqmqNDhXxxg69h0Gh5sH9iuM=; b=ZDctk7F1MzYHkhZnRtRfA+1qabebwCjFp1QXxi4gNeuxpz5MGu/FgxA5VQny37RHmi 1CCCyAbcRRYdqRBsO07vWCXiQ1fLcoh+tAXe9RzY8ftH2wQxbz8Ei+7C9ZT/tOHnZNvn X8YoHH3MgZyh39Jr5eF/PzNQ4RBcVsgHD6oJKx7OrbAmi4kIl3hHTxVVN/GEBbOZRf1E ohfLqyNCtvUtXsKhCbwzRcL6rXqjddQO/KNDJOY+tphIzlO3Q9hhmue6dYcuxyE9+kFu whQrTl6LZ/9XiECXzoASPGCU+Mgz9cJnNV9A7JR8mAXp2xJoRAB81sZFVk+Wp78+SIJd 498Q== X-Gm-Message-State: ALoCoQl25I5+YF1rzeyijiYKEhv8QY8pDx/9Vh4tQVbUI7/XiqXAHkIvVCKLRJcRs7F9Etpm12LF X-Received: by 10.152.8.73 with SMTP id p9mr11035821laa.6.1427108107516; Mon, 23 Mar 2015 03:55:07 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.42.178 with SMTP id p18ls549597lal.68.gmail; Mon, 23 Mar 2015 03:55:07 -0700 (PDT) X-Received: by 10.152.243.4 with SMTP id wu4mr83979353lac.33.1427108107370; Mon, 23 Mar 2015 03:55:07 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id f1si291202lah.139.2015.03.23.03.55.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Mar 2015 03:55:07 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by labto5 with SMTP id to5so23064039lab.0 for ; Mon, 23 Mar 2015 03:55:07 -0700 (PDT) X-Received: by 10.112.25.38 with SMTP id z6mr32943835lbf.106.1427108107229; Mon, 23 Mar 2015 03:55:07 -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.57.201 with SMTP id k9csp745927lbq; Mon, 23 Mar 2015 03:55:06 -0700 (PDT) X-Received: by 10.70.134.74 with SMTP id pi10mr108631222pdb.119.1427108105471; Mon, 23 Mar 2015 03:55:05 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id we7si652492pac.68.2015.03.23.03.55.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Mar 2015 03:55:05 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YZzzB-0004Xg-Sm; Mon, 23 Mar 2015 10:53:33 +0000 Received: from mail-we0-f170.google.com ([74.125.82.170]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YZzz8-0004SY-0n for linux-arm-kernel@lists.infradead.org; Mon, 23 Mar 2015 10:53:30 +0000 Received: by wetk59 with SMTP id k59so134378833wet.3 for ; Mon, 23 Mar 2015 03:53:07 -0700 (PDT) X-Received: by 10.180.90.113 with SMTP id bv17mr18558596wib.3.1427107987272; Mon, 23 Mar 2015 03:53:07 -0700 (PDT) Received: from ards-macbook-pro.local (62.82.106.185.static.user.ono.com. [62.82.106.185]) by mx.google.com with ESMTPSA id dj4sm826312wjc.13.2015.03.23.03.53.05 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 23 Mar 2015 03:53:06 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, will.deacon@arm.com, mark.rutland@arm.com, catalin.marinas@arm.com, marc.zyngier@arm.com Subject: [PATCH] ARM: kvm: implement replacement for ld's LOG2CEIL() Date: Mon, 23 Mar 2015 11:52:57 +0100 Message-Id: <1427107977-18591-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150323_035330_235912_15CD6A2B X-CRM114-Status: GOOD ( 11.04 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.170 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [74.125.82.170 listed in wl.mailspike.net] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: Ard Biesheuvel X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 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+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org 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.44 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 Commit 06f75a1f6200 ("ARM, arm64: kvm: get rid of the bounce page") uses ld's builtin function LOG2CEIL() to align the KVM init code to a log2 upper bound of its size. However, this function turns out to be a fairly recent addition to binutils, which breaks the build for older toolchains. So instead, implement a replacement LOG2_ROUNDUP() using the C preprocessor. Signed-off-by: Ard Biesheuvel --- Linker map output after applying this patch: 0xc09a2590 __idmap_text_end = . [...] *fill* 0xc09a2590 0x70 0xc09a2600 __hyp_idmap_text_start = . *(.hyp.idmap.text) .hyp.idmap.text 0xc09a2600 0x100 arch/arm/kvm/built-in.o 0xc09a2600 __kvm_hyp_init 0xc09a26ec __kvm_hyp_init_end 0xc09a2700 __hyp_idmap_text_end = . which confirms that the alignemnt is correct. The size of the region is 0xec bytes, and 0x70 bytes of padding are emitted to align it at a 0x100 byte boundary arch/arm/kernel/vmlinux.lds.S | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S index ba65f1217310..2d760df0d57d 100644 --- a/arch/arm/kernel/vmlinux.lds.S +++ b/arch/arm/kernel/vmlinux.lds.S @@ -11,7 +11,27 @@ #ifdef CONFIG_ARM_KERNMEM_PERMS #include #endif - + +/* + * Poor man's version of LOG2CEIL(), which is + * not available in binutils before v2.24. + */ +#define LOG2_ROUNDUP(size) ( \ + __LOG2_ROUNDUP(size, 2) \ + __LOG2_ROUNDUP(size, 3) \ + __LOG2_ROUNDUP(size, 4) \ + __LOG2_ROUNDUP(size, 5) \ + __LOG2_ROUNDUP(size, 6) \ + __LOG2_ROUNDUP(size, 7) \ + __LOG2_ROUNDUP(size, 8) \ + __LOG2_ROUNDUP(size, 9) \ + __LOG2_ROUNDUP(size, 10) \ + __LOG2_ROUNDUP(size, 11) \ + 12) + +#define __LOG2_ROUNDUP(size, order) \ + (size) <= (1 << order) ? order : + #define PROC_INFO \ . = ALIGN(4); \ VMLINUX_SYMBOL(__proc_info_begin) = .; \ @@ -23,7 +43,7 @@ VMLINUX_SYMBOL(__idmap_text_start) = .; \ *(.idmap.text) \ VMLINUX_SYMBOL(__idmap_text_end) = .; \ - . = ALIGN(1 << LOG2CEIL(__hyp_idmap_size)); \ + . = ALIGN(1 << LOG2_ROUNDUP(__hyp_idmap_size)); \ VMLINUX_SYMBOL(__hyp_idmap_text_start) = .; \ *(.hyp.idmap.text) \ VMLINUX_SYMBOL(__hyp_idmap_text_end) = .;