From patchwork Mon Jul 21 15:16:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 33982 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qg0-f72.google.com (mail-qg0-f72.google.com [209.85.192.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 26C1520672 for ; Mon, 21 Jul 2014 15:19:41 +0000 (UTC) Received: by mail-qg0-f72.google.com with SMTP id q107sf14939361qgd.3 for ; Mon, 21 Jul 2014 08:19:40 -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 :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=OpnA3QTgZpcNsalAVvMZX6m6s1Tv5zxTya25b8rTKM8=; b=acOLHxtwmU7IPr33NQJdNvgv6RDY5pqKw4YQ4vTcZKKiFbYnKIeSDNDxwNdDRDPECo WkIyR8EwV5RkpvyDrPoABwT1xhwpoVD2p+95yh8MB6IHFOboAuohXden7z90cAxFCih6 ArgN6TPB3Xc9H+PJ/B3OxGPw60H8RY+e1bcb+LuAciQv756kf1cy+CkGQrrpO7J1Kvfi 7Z5J6T0sK8F8SVla6WIrGyY60nPbnFjRrsZ7J8DXm+/1UI5KZyQ65II962sfJq+Il8pu XU+o+ax0XlHqy0Xn5OR9gXhvupN6ipiGLVlM2Z+ztznxx9K+CZowWbOy1kysbrETXV8R JXBA== X-Gm-Message-State: ALoCoQnR9KMvAYjwnKBnljQuKlav53H8iAJ0oq9WBP8+KzNOJwv7T5bp1igiDkQZJ4IW3fXrIRSB X-Received: by 10.236.171.234 with SMTP id r70mr11146958yhl.45.1405955979970; Mon, 21 Jul 2014 08:19:39 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.20.23 with SMTP id 23ls1894283qgi.26.gmail; Mon, 21 Jul 2014 08:19:39 -0700 (PDT) X-Received: by 10.52.164.11 with SMTP id ym11mr4221798vdb.74.1405955979797; Mon, 21 Jul 2014 08:19:39 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id cj10si11536445vdc.68.2014.07.21.08.19.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 21 Jul 2014 08:19:35 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id hy4so12137635vcb.8 for ; Mon, 21 Jul 2014 08:19:35 -0700 (PDT) X-Received: by 10.220.15.8 with SMTP id i8mr18144438vca.45.1405955975153; Mon, 21 Jul 2014 08:19:35 -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.221.37.5 with SMTP id tc5csp121012vcb; Mon, 21 Jul 2014 08:19:34 -0700 (PDT) X-Received: by 10.70.136.194 with SMTP id qc2mr11011109pdb.109.1405955974324; Mon, 21 Jul 2014 08:19:34 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id fw12si2502769pdb.124.2014.07.21.08.19.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jul 2014 08:19:34 -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 1X9FME-0008Ej-Mx; Mon, 21 Jul 2014 15:18:30 +0000 Received: from mail-wi0-f177.google.com ([209.85.212.177]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X9FLK-00072V-M9 for linux-arm-kernel@lists.infradead.org; Mon, 21 Jul 2014 15:17:35 +0000 Received: by mail-wi0-f177.google.com with SMTP id ho1so4274308wib.10 for ; Mon, 21 Jul 2014 08:17:11 -0700 (PDT) X-Received: by 10.194.76.99 with SMTP id j3mr24563148wjw.85.1405955830943; Mon, 21 Jul 2014 08:17:10 -0700 (PDT) Received: from ards-macbook-pro.local ([212.91.105.246]) by mx.google.com with ESMTPSA id ft17sm38327602wjc.14.2014.07.21.08.17.08 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 21 Jul 2014 08:17:10 -0700 (PDT) From: Ard Biesheuvel To: matt.fleming@intel.com, linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, will.deacon@arm.com, leif.lindholm@linaro.org Subject: [RFC PATCH 05/10] arm64/efi: update the PE/COFF header to be endian agnostic Date: Mon, 21 Jul 2014 17:16:20 +0200 Message-Id: <1405955785-13477-6-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1405955785-13477-1-git-send-email-ard.biesheuvel@linaro.org> References: <1405955785-13477-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140721_081734_905857_24D2EE03 X-CRM114-Status: GOOD ( 10.94 ) 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 [209.85.212.177 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.212.177 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: roy.franz@linaro.org, victor.kamensky@linaro.org, steve.capper@linaro.org, Ard Biesheuvel , msalter@redhat.com 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.220.177 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 Update the PE/COFF header to use explicit little endian constants and use explicit little endian linker symbols so that the PE/COFF header is always emitted in little endian regardless of the endiannes of the kernel. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/head.S | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index c63f44f20ae3..5179d3df1024 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -123,7 +123,10 @@ efi_head: .byte 0x4d .byte 0x64 #ifdef CONFIG_EFI - .long pe_header - efi_head // Offset to the PE header. + .byte pe_header - efi_head // Offset to the PE header. + .byte 0 + .byte 0 + .byte 0 #else .word 0 // reserved #endif @@ -136,30 +139,31 @@ pe_header: .ascii "PE" .short 0 coff_header: - .short 0xaa64 // AArch64 - .short 2 // nr_sections + le16 0xaa64 // AArch64 + le16 2 // nr_sections .long 0 // TimeDateStamp .long 0 // PointerToSymbolTable - .long 1 // NumberOfSymbols - .short section_table - optional_header // SizeOfOptionalHeader - .short 0x206 // Characteristics. + le32 1 // NumberOfSymbols + .byte section_table - optional_header // SizeOfOptionalHeader + .byte 0 + le16 0x206 // Characteristics. // IMAGE_FILE_DEBUG_STRIPPED | // IMAGE_FILE_EXECUTABLE_IMAGE | // IMAGE_FILE_LINE_NUMS_STRIPPED optional_header: - .short 0x20b // PE32+ format + le16 0x20b // PE32+ format .byte 0x02 // MajorLinkerVersion .byte 0x14 // MinorLinkerVersion - .long _end - stext // SizeOfCode + .long _efi_code_virtsize_le // SizeOfCode .long 0 // SizeOfInitializedData .long 0 // SizeOfUninitializedData - .long efi_stub_entry - efi_head // AddressOfEntryPoint - .long stext_offset // BaseOfCode + .long _efi_entry_point_le // AddressOfEntryPoint + .long _efi_stext_offset_le // BaseOfCode extra_header_fields: .quad 0 // ImageBase - .long 0x20 // SectionAlignment - .long 0x8 // FileAlignment + le32 0x20 // SectionAlignment + le32 0x8 // FileAlignment .short 0 // MajorOperatingSystemVersion .short 0 // MinorOperatingSystemVersion .short 0 // MajorImageVersion @@ -168,19 +172,19 @@ extra_header_fields: .short 0 // MinorSubsystemVersion .long 0 // Win32VersionValue - .long _end - efi_head // SizeOfImage + .long _efi_image_size_le // SizeOfImage // Everything before the kernel image is considered part of the header - .long stext_offset // SizeOfHeaders + .long _efi_stext_offset_le // SizeOfHeaders .long 0 // CheckSum - .short 0xa // Subsystem (EFI application) + le16 0xa // Subsystem (EFI application) .short 0 // DllCharacteristics .quad 0 // SizeOfStackReserve .quad 0 // SizeOfStackCommit .quad 0 // SizeOfHeapReserve .quad 0 // SizeOfHeapCommit .long 0 // LoaderFlags - .long 0x6 // NumberOfRvaAndSizes + le32 0x6 // NumberOfRvaAndSizes .quad 0 // ExportTable .quad 0 // ImportTable @@ -208,23 +212,23 @@ section_table: .long 0 // PointerToLineNumbers .short 0 // NumberOfRelocations .short 0 // NumberOfLineNumbers - .long 0x42100040 // Characteristics (section flags) + le32 0x42100040 // Characteristics (section flags) .ascii ".text" .byte 0 .byte 0 .byte 0 // end of 0 padding of section name - .long _end - stext // VirtualSize - .long stext_offset // VirtualAddress - .long _edata - stext // SizeOfRawData - .long stext_offset // PointerToRawData + .long _efi_code_virtsize_le // VirtualSize + .long _efi_stext_offset_le // VirtualAddress + .long _efi_code_rawsize_le // SizeOfRawData + .long _efi_stext_offset_le // PointerToRawData .long 0 // PointerToRelocations (0 for executables) .long 0 // PointerToLineNumbers (0 for executables) .short 0 // NumberOfRelocations (0 for executables) .short 0 // NumberOfLineNumbers (0 for executables) - .long 0xe0500020 // Characteristics (section flags) + le32 0xe0500020 // Characteristics (section flags) .align 5 #endif