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: 3945691 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 0665B9F370 for ; Mon, 7 Apr 2014 14:00:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 171522026F for ; Mon, 7 Apr 2014 14:00:30 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C3C3220145 for ; Mon, 7 Apr 2014 14:00:28 +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 1WXA63-0002ag-Fn; 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-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:content-type:content-transfer-encoding; bh=hTX/PPLbmio1V2D7EWBQ3ZledvOq+5PVHOkp6cXthcw=; b=NkNf3bCYNpVUJxHgWzguXLjcp3JQTNQylDLDjNpqVFhy/CuMH14jHoZhzqKaYYB0UK 1xmioirywzysLU915NoT9QxO2MgyLRHLTJsqQqNY2BVtxuzePr5ujuaSiJQfisdFuRsF oT1lAwP0yszfqwTDMhfKQ4eF1tzN9uTsOj7KaS314zbgAnMXXv+rJSWwLfIGdHpk4a9v 7+4FncL8Xgfo5wJvvS5A8rjAwrDChs79/GKDZf2fePd8D/B8W+iBo87/tbJRVuRbSbGM aFPazTLGztTvGUyKg9VvahVHmuRhszyEF+qMPYd2dTguOD+6fLrCrX7BkyT91YEtJkZX Ogkw== X-Gm-Message-State: ALoCoQn0UZl5VmoTNJkGgasYliTOUe0fZi/+NgDkn9QNNWRyMRI0LTo+YAJ53wX35de8TX1irBF4 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 (--) 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.5 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 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 */ ; \