From patchwork Mon Apr 7 13:59:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 27897 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f197.google.com (mail-ob0-f197.google.com [209.85.214.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DEC5E208CF for ; Mon, 7 Apr 2014 14:00:35 +0000 (UTC) Received: by mail-ob0-f197.google.com with SMTP id wp18sf27436206obc.8 for ; Mon, 07 Apr 2014 07:00:35 -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:message-id:date:from:user-agent :mime-version:to:subject:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=ZiVELHt4hhq6igzaZYvrizcMkI2SM9yyI1u5qIX7oNQ=; b=PSxlN8kR5j0XzfshCqHgh+so8gWJj+shWmdb5fB2LFaM8yjKEl8syqoZZWKDiI6G6E oD8Yi3SmMwl2UVvWIl6QJlpdWHg8pDf0moxkjyngsDD7THE8hld2kquz57J2RXplP7UA 0O25gZ33n6e93KbV2DnkWKMaB66QpHBgz8vJCky8DN9OXVTpJzjhrGNsqmRPVuWUpxjI aMlh3Wu2Cb5E0BVpabWKpOEqaX6mJeAALimw2760Qds4a5yrMo3LF4GBY6W1qfRaJi2B sa31Uv625wc7vnuE76MBuXmM64RcbnXu5ZxAGCf6uMzkNERcZWeEptB+N5idaeBfSorj OfbA== X-Gm-Message-State: ALoCoQkmVACB+KWZwM/ep7Uq0GtBLDF0/h30Ym4DIEQQuu5RfEIGgYVLAj0d7l9vu2GPN/ZEF/yi X-Received: by 10.182.200.162 with SMTP id jt2mr8202460obc.34.1396879235128; Mon, 07 Apr 2014 07:00:35 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.22.167 with SMTP id 36ls1666568qgn.55.gmail; Mon, 07 Apr 2014 07:00:35 -0700 (PDT) X-Received: by 10.52.33.176 with SMTP id s16mr140255vdi.49.1396879235018; Mon, 07 Apr 2014 07:00:35 -0700 (PDT) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id uq15si2132974veb.32.2014.04.07.07.00.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 07 Apr 2014 07:00:35 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.182; Received: by mail-ve0-f182.google.com with SMTP id jw12so3748552veb.13 for ; Mon, 07 Apr 2014 07:00:34 -0700 (PDT) X-Received: by 10.52.241.106 with SMTP id wh10mr11183414vdc.16.1396879234831; Mon, 07 Apr 2014 07:00:34 -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.220.12.8 with SMTP id v8csp164350vcv; Mon, 7 Apr 2014 07:00:34 -0700 (PDT) X-Received: by 10.180.20.111 with SMTP id m15mr19540833wie.59.1396879233442; Mon, 07 Apr 2014 07:00:33 -0700 (PDT) Received: from casper.infradead.org (casper.infradead.org. [2001:770:15f::2]) by mx.google.com with ESMTPS id gv10si2544095wib.53.2014.04.07.07.00.32 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Apr 2014 07:00:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:770:15f::2 as permitted sender) client-ip=2001:770:15f::2; Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WXA63-0002ah-Fv; Mon, 07 Apr 2014 14:00:23 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WXA61-0007im-5Z; Mon, 07 Apr 2014 14:00:21 +0000 Received: from mail-ee0-f45.google.com ([74.125.83.45]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WXA5y-0007iE-Aj for linux-arm-kernel@lists.infradead.org; Mon, 07 Apr 2014 14:00:19 +0000 Received: by mail-ee0-f45.google.com with SMTP id d17so679635eek.4 for ; Mon, 07 Apr 2014 06:59:54 -0700 (PDT) X-Received: by 10.14.110.199 with SMTP id u47mr2568864eeg.74.1396879194213; Mon, 07 Apr 2014 06:59:54 -0700 (PDT) Received: from [10.80.2.139] ([185.25.64.249]) by mx.google.com with ESMTPSA id g3sm41941318eet.35.2014.04.07.06.59.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 07 Apr 2014 06:59:53 -0700 (PDT) Message-ID: <5342AF59.3030405@linaro.org> Date: Mon, 07 Apr 2014 14:59:53 +0100 From: Julien Grall User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20131104 Icedove/17.0.10 MIME-Version: 1.0 To: Ian Campbell , Stefano Stabellini , Arnd Bergmann , Russell King - ARM Linux , Olof Johansson Subject: [RFC] Extend zImage format to support notes X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140407_100018_491955_A4690DBF X-CRM114-Status: GOOD ( 14.96 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.83.45 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] Cc: linux-arm-kernel@lists.infradead.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: , 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: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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 Hello all, Currently ELF is supporting notes (see include/linux/elfnote.h) which is used by Xen to know the feature supported by the kernel. On ARM world, the zImage format is mainly used by the distribution. Rather than ELF, it's currently not possible to add notes on it. ==== Current zImage format ==== The header starts at offset 0x24: uint32_t magic /* Magic number: 0x016f2818 */ uint32_t start /* absolute load/run zImage address */ uint32_t end /* zImage end address */ ==== Extension proposed to zImage format === The header stays compatible with the current format and starts at offset 0x24: uint32_t magic0 /* Magic number : 0x16f2818 */ uint32_t start /* absolute load/run zImage address */ uint32_t end /* zImage end address */ uint32_t magic1 /* Magic number : "ARM\x32" */ uint32_t note_start /* Notes section offset */ uint32_t note_end /* Notes sections end */ I was thinking to also add a version field in case we might want to extend the format in the future. The notes section will contains a list of note (see description below). ==== Format of a note ==== The format is compatible with ELF note: Name size : 4 bytes Desc size : 4 bytes Type : 4 bytes: identify the type of the note Name : variable size, padded to 4 byte boundary Desc : variable size, padded to 4 byte boundary : contains data related to the note type. The "Name size", "Desc size" and "Type" fields are interpreted as an integer. I wrote a quick patch to show what would be the modification on Linux side (see below). Comments and questions are welcomed. Sincerely yours, diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S index 066b034..104d862 100644 --- a/arch/arm/boot/compressed/head.S +++ b/arch/arm/boot/compressed/head.S @@ -133,6 +138,12 @@ start: .word 0x016f2818 @ Magic numbers to help the loader .word start @ absolute load/run zImage address .word _edata @ zImage end address + .byte 0x41 @ Magic number, "ARM\x32" + .byte 0x52 + .byte 0x4d + .byte 0x32 + .word _note_start @ Notes section offset + .word _note_end @ Notes section end THUMB( .thumb ) 1: ARM_BE8( setend be ) @ go BE8 if compiled for BE8 diff --git a/arch/arm/boot/compressed/vmlinux.lds.in b/arch/arm/boot/compressed/vmlinux.lds.in index 4919f2a..d3287ff 100644 --- a/arch/arm/boot/compressed/vmlinux.lds.in +++ b/arch/arm/boot/compressed/vmlinux.lds.in @@ -52,6 +52,10 @@ SECTIONS .got : { *(.got) } _got_end = .; + _note_start = .; + .note : { *(.note*) } + _note_end = .; + /* ensure the zImage file size is always a multiple of 64 bits */ /* (without a dummy byte, ld just ignores the empty section) */ .pad : { BYTE(0); . = ALIGN(8); } diff --git a/include/linux/elfnote.h b/include/linux/elfnote.h index 278e3ef..9ad4488 100644 --- a/include/linux/elfnote.h +++ b/include/linux/elfnote.h @@ -39,7 +39,7 @@ * ELFNOTE(XYZCo, 12, .long, 0xdeadbeef) */ #define ELFNOTE_START(name, type, flags) \ -.pushsection .note.name, flags,@note ; \ +.pushsection .note.name, flags,%note ; \ .balign 4 ; \ .long 2f - 1f /* namesz */ ; \ .long 4484f - 3f /* descsz */ ; \