From patchwork Tue May 30 18:36:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 100725 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp352531qge; Tue, 30 May 2017 11:37:01 -0700 (PDT) X-Received: by 10.84.238.200 with SMTP id l8mr82899599pln.85.1496169421210; Tue, 30 May 2017 11:37:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496169421; cv=none; d=google.com; s=arc-20160816; b=Eg5YLgw4Be4YXF5ISZeJwE1cYUywIqUnivXgSEzLdNaDcR3nT04YXCyNN4YwUQWDAj Zm81D/D3buIXlRtuTB/4n3E+Mztrqx2EgQUVqbThUXUYpS+cDVUMV/FjKso3kXpJ52my CIlqC9JwA482jhtgWrXz12fIeAyCtXndw5hfTowqVT1Jf5ZMie58P90WAJ1xWCESO5Ax 0pvl2U1DdXf/j0gvSdBgGp6yyEY2wS5jPEfU0NQ2gUsaOehyIi8iKWiAJQPFc2SwyXzX THropNlzoASYjHlnPIF0negpUaoUAEIYcOcKiVySyMRvDx9BnuetHltkaTnzMPYWbfzW te0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Id0jI2tvpSrE/XvVhjyDxlxHF3ERFVB52LVXRA9mHbE=; b=Gct1cUkXX0X9mC5McX3KYYnqd806jIlEdZCFnTmp3c+13xPDSJ5i5p+pvY7tQYnv+o ts1R3tZ+h4FKekigq/5VhqjaA12N+tVW7E+EFfUYlMZkKFhe2dxxUwppu3k9zBGRx+wK 54CsXtjHwagklaILCFYjT/svaBAF7ZJeW6FcU7hnw8BZAU1jthh/4wNLNoGXoSPEO+kY CuK+Pt8MGR8kp0AQ3FeWZnYMN6heQJWhRZ8S4dvViBa6giv4tQEZN3zO1It3YuB8eH9u zzVv/1A24lndWxmwlo0NQjfvZdO5TWo/6+AS7QCqmkwJoex9U29z8x6mN7HfBS+DtPeW kBGw== ARC-Authentication-Results: i=1; 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-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 203si14035057pfc.344.2017.05.30.11.37.01; Tue, 30 May 2017 11:37:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; 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-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751053AbdE3ShA (ORCPT + 2 others); Tue, 30 May 2017 14:37:00 -0400 Received: from mail-wr0-f176.google.com ([209.85.128.176]:34567 "EHLO mail-wr0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750938AbdE3Sg7 (ORCPT ); Tue, 30 May 2017 14:36:59 -0400 Received: by mail-wr0-f176.google.com with SMTP id g76so5639840wrd.1 for ; Tue, 30 May 2017 11:36:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dQ+msJy45rjvscVKh6DRpdIVGLjjrmSGquKYhpKhRKc=; b=PbRmgqGCAZnqqamJ4m84v8pyvGcfbP0HdPliVbPqIZBLxtYXUJ0g19AlCk2ZjwOhHK +/C3DA8cqRZHsvlUXRj2xBo9uUyEaL8pBeTY0ikMXeKA07ij9mptZSLSH11CieiYFFoU IaOTYxw/yuZeI4qCMR6quoIrE6jMPLf1dg28c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dQ+msJy45rjvscVKh6DRpdIVGLjjrmSGquKYhpKhRKc=; b=mI6C+n9ewTY3Jn1q6LVeAntHzKNsHfkl2nSsXGIgWOeQj2Q2moFHEOEvZLes3N5mt3 otEBhyEgpKCqi+d8IBPTszREmR+mbJaZSkg7o6S06YmgZ0xOjibr8cFO0CKOWUS7zlh9 ZzR6TbOqkOKlGYRrxyL4KELFIkCmFFEscyM20X6rybZVeBMwwRLIcimGopKNocK3yW5k YA5NW1R+vtNgViFyoNggP74Vc8aG+Kr6FK22qF2io9OVgeJquWpQdWjYgcVAd6tsk9xR X6OwiYPuFEPsqtHvCtCS/MBuruGDNBmGwKnlg9e3fmayN0LHTwzvuSIoQB/bY9l2Glm+ Qqfw== X-Gm-Message-State: AODbwcCjc39xrOmGhb46n//hZ72kkuaZgUPrCmFLYHl0tNz83MLHUovM /qIQjXl57FXPKmGoUrTEsA== X-Received: by 10.223.177.155 with SMTP id q27mr15117888wra.173.1496169417742; Tue, 30 May 2017 11:36:57 -0700 (PDT) Received: from localhost.localdomain ([154.144.49.177]) by smtp.gmail.com with ESMTPSA id b8sm15935997wrb.7.2017.05.30.11.36.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 May 2017 11:36:56 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, linux@armlinux.org.uk Cc: linux-arm-kernel@lists.infradead.org, matt@codeblueprint.co.uk, leif.lindholm@linaro.org, Ard Biesheuvel Subject: [PATCH 1/7] arm: efi: remove forbidden values from the PE/COFF header Date: Tue, 30 May 2017 18:36:41 +0000 Message-Id: <20170530183647.28557-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170530183647.28557-1-ard.biesheuvel@linaro.org> References: <20170530183647.28557-1-ard.biesheuvel@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Bring the PE/COFF header in line with the PE/COFF spec, by setting NumberOfSymbols to 0, and removing the section alignment flags. Signed-off-by: Ard Biesheuvel --- arch/arm/boot/compressed/efi-header.S | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm/boot/compressed/efi-header.S b/arch/arm/boot/compressed/efi-header.S index 3f7d1b74c5e0..f9e91ba4d0b1 100644 --- a/arch/arm/boot/compressed/efi-header.S +++ b/arch/arm/boot/compressed/efi-header.S @@ -43,7 +43,7 @@ coff_header: .short 2 @ nr_sections .long 0 @ TimeDateStamp .long 0 @ PointerToSymbolTable - .long 1 @ NumberOfSymbols + .long 0 @ NumberOfSymbols .short section_table - optional_header @ SizeOfOptionalHeader .short 0x306 @ Characteristics. @@ -109,7 +109,7 @@ section_table: .long 0 @ PointerToLineNumbers .short 0 @ NumberOfRelocations .short 0 @ NumberOfLineNumbers - .long 0x42100040 @ Characteristics + .long 0x42000040 @ Characteristics .ascii ".text\0\0\0" .long _end - __efi_start @ VirtualSize @@ -120,7 +120,7 @@ section_table: .long 0 @ PointerToLineNumbers .short 0 @ NumberOfRelocations .short 0 @ NumberOfLineNumbers - .long 0xe0500020 @ Characteristics + .long 0xe0000020 @ Characteristics .align 9 __efi_start: From patchwork Tue May 30 18:36:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 100728 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp352691qge; Tue, 30 May 2017 11:37:23 -0700 (PDT) X-Received: by 10.84.132.98 with SMTP id 89mr84034129ple.29.1496169443241; Tue, 30 May 2017 11:37:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496169443; cv=none; d=google.com; s=arc-20160816; b=FZ8cw8w5w6KnbyeRXaM1mpzwDiOkJTjOpwQPs4XMNY+7zgx9xBlQN1lOOwDryr33Gk rhANpWsGvdLnFwSZD7q7dauZYkEkFDLvga28HKlcwXgw0FkC4oS4XWa6nplYHH/7Ivso wTob6Zoz2kT9tIRkQ9479V0GeOdLSVoFq9r1ocFaZFw2r5NGbPx8e7iyLkf4n5QIw6DA hBd2CZ6KrqIYf6vgzNaEqK6SdjnUQhBhmwibtP4i9gausch/CdogzzYutJVkHdVFBowe TmzOIObGnLu2ExBgHhCg4j5hBGNrQ+GasE0YS3GC7r6Bf55O46ihnGoOG6spS0GzgKTh X4CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=q7QQLjMhyMA8ON7WH6n1LNDrqwZBWbetJWbw9E4/QjY=; b=wnoyXTvYzNyxH1iGZVdl+xRWqF7hX5r+cIOx2qu2ZMU/sN/hVufOvYGOGzp6nlV0KK z8XxNUJc6eHbEbvrnwLhPHym7t3co4owJKYFb3ugjJ44ygIOCupOwQtozCVj0zvOAytn sT7zEHxVmRWINdigMr5Q/tIgb+j/CKWrSpmIZf7ZCdWODjuoTDS0f0IQleoEL+ld6Pou xc0xpFTDnKBQ/SDwPcFX/0+XHbTrQnTpanFB40XL6E002s7fd/TtdVh0uBff2ffrO8M9 JKIHXg3RNYq36U/19Pi1XUhpeHaRQpfIgLbX9n+nHgnoKN5zXB9jI5tEaY2QeJsZyVFK QacA== ARC-Authentication-Results: i=1; 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-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33si44904691plf.190.2017.05.30.11.37.22; Tue, 30 May 2017 11:37:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; 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-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751209AbdE3ShO (ORCPT + 2 others); Tue, 30 May 2017 14:37:14 -0400 Received: from mail-wm0-f45.google.com ([74.125.82.45]:35970 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751234AbdE3ShL (ORCPT ); Tue, 30 May 2017 14:37:11 -0400 Received: by mail-wm0-f45.google.com with SMTP id 7so99021824wmo.1 for ; Tue, 30 May 2017 11:37:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=I1sTB5ahI02iYwJJM3Y8VreDzUCl2Pn2ToPN8htznMY=; b=FK0W92TQKI0H+1kH+z+dzOh39hl0AEjlizrK/dqciXYr/Pxo1IMpxtPSeSga5lon1A Tve6YI4rz88kemNjrw4oE1zMMJRHmZr2D4fyGu/OVD1wWjlFXLrYT0td9v4+EP+Fa14x OFmjrGVh7Sc22nhMHfUCJYYdaYxzEXJy/dtCw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=I1sTB5ahI02iYwJJM3Y8VreDzUCl2Pn2ToPN8htznMY=; b=CragX7SeKEdSGd8sE8SfkQDjH/kT1XxyeAeWZb5IqbcmzgSUJXSTPP9E/bQ47pKxQI wyg1DP4fgLasjeEGZU6d/e4M4w01SOBqRXkkh0WfPpEEFQ/yOGkFvlmfuyXKUfnDTIJs RZi9CRKIziFGTMephOmaG8ThdlwY9MUvkhmnXWz+4OoKj6aYA4YUwWTgRyLk9jpHyq2g 2TfzC1vUADhdEW1ErnlNUCzYilhH0g0g9go2N+ZIaGVagSUzSk/kD2KMirdYAhLcGYoT 8L29OenTWPifN2FI/1AIVJSHZnzt/amJEd+xg8UAeTOHKHe6TT44CmKQeMjE6s0ip3T1 byog== X-Gm-Message-State: AODbwcBQ1Bqirod855yoTcPLl5qBFBZ2gzAmaGVsDAiSwWGKvg8rCQkT ffPZO85c46hOHd0x8oHACQ== X-Received: by 10.28.216.129 with SMTP id p123mr2613728wmg.55.1496169419611; Tue, 30 May 2017 11:36:59 -0700 (PDT) Received: from localhost.localdomain ([154.144.49.177]) by smtp.gmail.com with ESMTPSA id b8sm15935997wrb.7.2017.05.30.11.36.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 May 2017 11:36:58 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, linux@armlinux.org.uk Cc: linux-arm-kernel@lists.infradead.org, matt@codeblueprint.co.uk, leif.lindholm@linaro.org, Ard Biesheuvel Subject: [PATCH 2/7] arm: efi: remove pointless dummy .reloc section Date: Tue, 30 May 2017 18:36:42 +0000 Message-Id: <20170530183647.28557-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170530183647.28557-1-ard.biesheuvel@linaro.org> References: <20170530183647.28557-1-ard.biesheuvel@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org The kernel's EFI PE/COFF header contains a dummy .reloc section, and an explanatory comment that claims that this is required for the EFI application loader to accept the Image as a relocatable image (i.e., one that can be loaded at any offset and fixed up in place) This was inherited from the x86 implementation, which has elaborate host tooling to mangle the PE/COFF header post-link time, and which populates the .reloc section with a single dummy base relocation. On ARM, no such tooling exists, and the .reloc section remains empty, and is never even exposed via the BaseRelocationTable directory entry, which is where the PE/COFF loader looks for it. The PE/COFF spec is unclear about relocatable images that do not require any fixups, but the EDK2 implementation, which is the de facto reference for PE/COFF in the UEFI space, clearly does not care, and explicitly mentions (in a comment) that relocatable images with no base relocations are perfectly fine, as long as they don't have the RELOCS_STRIPPED attribute set (which is not the case for our PE/COFF image) So simply remove the .reloc section altogether. Signed-off-by: Ard Biesheuvel --- arch/arm/boot/compressed/efi-header.S | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) -- 2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm/boot/compressed/efi-header.S b/arch/arm/boot/compressed/efi-header.S index f9e91ba4d0b1..97f595970916 100644 --- a/arch/arm/boot/compressed/efi-header.S +++ b/arch/arm/boot/compressed/efi-header.S @@ -40,7 +40,7 @@ pe_header: coff_header: .short 0x01c2 @ ARM or Thumb - .short 2 @ nr_sections + .short 1 @ nr_sections .long 0 @ TimeDateStamp .long 0 @ PointerToSymbolTable .long 0 @ NumberOfSymbols @@ -95,22 +95,6 @@ extra_header_fields: .quad 0 @ BaseRelocationTable section_table: - @ - @ The EFI application loader requires a relocation section - @ because EFI applications must be relocatable. This is a - @ dummy section as far as we are concerned. - @ - .ascii ".reloc\0\0" - .long 0 @ VirtualSize - .long 0 @ VirtualAddress - .long 0 @ SizeOfRawData - .long 0 @ PointerToRawData - .long 0 @ PointerToRelocations - .long 0 @ PointerToLineNumbers - .short 0 @ NumberOfRelocations - .short 0 @ NumberOfLineNumbers - .long 0x42000040 @ Characteristics - .ascii ".text\0\0\0" .long _end - __efi_start @ VirtualSize .long __efi_start @ VirtualAddress From patchwork Tue May 30 18:36:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 100726 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp352679qge; Tue, 30 May 2017 11:37:22 -0700 (PDT) X-Received: by 10.84.238.199 with SMTP id l7mr86128914pln.153.1496169442218; Tue, 30 May 2017 11:37:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496169442; cv=none; d=google.com; s=arc-20160816; b=i4b1TD/tQa+dxeMeT8ju5eJVerergXKRvKfD0ydo862227DKg4wG634Z2ZFFg4536V ZtxRsmRPQ8p6S3VV7DmCC7SBpOVZr2qDsy5jkcmdLlOgSB+8Jfr7g6oCYr55gEoZi8DK CP72QDE2QfHHbTsbqraAnOopYUiAN5ihQhOWQbwKYXKAu+5HCj5Hp0M688yjVrJoOhWS 95yR8tIzl/hsZOAM4C4y85P8tAJCuutdlMQEacGveMWxbX4VLtS6BpgHb/vZ56aS7cHJ vhd1qJ3BX8VLEFJxzLQ0Tu6xnaNwDfx0E0IAbKA47UHJZsj+f0D3auJN8hb+j+aCojvE aneQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=YVDb5y57tC6NtjLJqxbVx9QgwuXhbNYapctseOSoUDQ=; b=cRfQubv+DGbvT569OjEyjP8p/SCV1K8h/fTOfx1NffdUGFlmPsVbr9kShWuJ1bhK40 x0H1xIFvOq7I4e797u3HBsrIpnd7DuF7BpsPKqTRFFamAwmO6GZL2cs6X1lFvmFOTrEK /2E6HzPN12euZjLyIvq9NUtuqThemla9jt1Wh7c5/TRvFWJYRpdnQviRBolXeFIJFYp9 9auNBcu3TMQqHrQ+k6KEYVm5dxvTp3wCbPLBMANLs0EEQW1FKp4qRt37uc+fvNojh+3n xtzFE/yXAl3spN5po8Rt5Qg4Sih8dFishdgZcpEJ+OreObYIn9M36CeLRT+4wwQd3q/j q7pQ== ARC-Authentication-Results: i=1; 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-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33si44904691plf.190.2017.05.30.11.37.22; Tue, 30 May 2017 11:37:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; 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-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750938AbdE3ShF (ORCPT + 2 others); Tue, 30 May 2017 14:37:05 -0400 Received: from mail-wr0-f173.google.com ([209.85.128.173]:34588 "EHLO mail-wr0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750951AbdE3ShE (ORCPT ); Tue, 30 May 2017 14:37:04 -0400 Received: by mail-wr0-f173.google.com with SMTP id g76so5640818wrd.1 for ; Tue, 30 May 2017 11:37:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dta/JGct3yUIcFxu+bS532loXs0K0cd71RxDbBatIyo=; b=RmHqiixoYwj5u8THfXkbDNMqTh0/IBKA7TheYDp0VrD8sFeJ2v5FD4GdZlBuDZ/uNo JjVR5LJ3L+0m3mXiBaRZcM8UK5sfnf23gLL08tNSLTxR6kxyqles47HyC0n6BObyYDRL lzUZ6cXM5NprRMqYo7x1gOfpuo0QpKXKqNZPs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dta/JGct3yUIcFxu+bS532loXs0K0cd71RxDbBatIyo=; b=mHiSVtSTDkU9mjwgme6DknMrHGMRZG6pwaT6vzl0PxfkeUKtC1QfVuTKG5X3WsuNP2 EtxhziO5m/TtGhLlJ/Eezc2sek4kjZ2JJHjl7FZ6C81/JbjBc4HCvQ5+RBGUEQVzF5GM IHsKd2fzKr5/DepwRPqis33yyoqr6fmxAF20ePoOhs9LEj/dykZncR0wkUCQ1wR90FDN +Q+KI/MTXJoNpSud09/ndqxhTeeKNJkkvWGiinSSGBfGbJFAXhPsFOsxoBrmDA9LMeco lIdzzAbQZsmEqCSdRCl5YSzng/IbK+nkClU8R3iRHDE+B2ql8H+yQRX5RdMFRDGCHzZS xg7w== X-Gm-Message-State: AODbwcDv6IO7GYgA/faLdWBIUoX5TieaSTB+VAR7eOS9I/vQRxnkGJm6 Ips0dQSqdx6hH8JD95F0CA== X-Received: by 10.223.183.30 with SMTP id l30mr9835526wre.115.1496169422349; Tue, 30 May 2017 11:37:02 -0700 (PDT) Received: from localhost.localdomain ([154.144.49.177]) by smtp.gmail.com with ESMTPSA id b8sm15935997wrb.7.2017.05.30.11.36.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 May 2017 11:37:01 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, linux@armlinux.org.uk Cc: linux-arm-kernel@lists.infradead.org, matt@codeblueprint.co.uk, leif.lindholm@linaro.org, Ard Biesheuvel Subject: [PATCH 3/7] arm: efi: replace open coded constants with symbolic ones Date: Tue, 30 May 2017 18:36:43 +0000 Message-Id: <20170530183647.28557-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170530183647.28557-1-ard.biesheuvel@linaro.org> References: <20170530183647.28557-1-ard.biesheuvel@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Replace the various open coded constants in the EFI PE/COFF header with definitions from pe.h, or expressions based on local symbols. Note that this patch also changes the indentation to make room for the symbolic constant names. Signed-off-by: Ard Biesheuvel --- arch/arm/boot/compressed/efi-header.S | 172 ++++++++++---------- 1 file changed, 89 insertions(+), 83 deletions(-) -- 2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm/boot/compressed/efi-header.S b/arch/arm/boot/compressed/efi-header.S index 97f595970916..4699c432a2e2 100644 --- a/arch/arm/boot/compressed/efi-header.S +++ b/arch/arm/boot/compressed/efi-header.S @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013-2015 Linaro Ltd + * Copyright (C) 2013-2017 Linaro Ltd * Authors: Roy Franz * Ard Biesheuvel * @@ -8,105 +8,111 @@ * published by the Free Software Foundation. */ - .macro __nop +#include +#include + + .macro __nop #ifdef CONFIG_EFI_STUB - @ This is almost but not quite a NOP, since it does clobber the - @ condition flags. But it is the best we can do for EFI, since - @ PE/COFF expects the magic string "MZ" at offset 0, while the - @ ARM/Linux boot protocol expects an executable instruction - @ there. - .inst 'M' | ('Z' << 8) | (0x1310 << 16) @ tstne r0, #0x4d000 + @ This is almost but not quite a NOP, since it does clobber the + @ condition flags. But it is the best we can do for EFI, since + @ PE/COFF expects the magic string "MZ" at offset 0, while the + @ ARM/Linux boot protocol expects an executable instruction + @ there. + .inst MZ_MAGIC | (0x1310 << 16) @ tstne r0, #0x4d000 #else - W(mov) r0, r0 + W(mov) r0, r0 #endif - .endm + .endm - .macro __EFI_HEADER + .macro __EFI_HEADER #ifdef CONFIG_EFI_STUB - .set start_offset, __efi_start - start - .org start + 0x3c - @ - @ The PE header can be anywhere in the file, but for - @ simplicity we keep it together with the MSDOS header - @ The offset to the PE/COFF header needs to be at offset - @ 0x3C in the MSDOS header. - @ The only 2 fields of the MSDOS header that are used are this - @ PE/COFF offset, and the "MZ" bytes at offset 0x0. - @ - .long pe_header - start @ Offset to the PE header. + .set start_offset, __efi_start - start + .org start + 0x3c + @ + @ The PE header can be anywhere in the file, but for + @ simplicity we keep it together with the MSDOS header + @ The offset to the PE/COFF header needs to be at offset + @ 0x3C in the MSDOS header. + @ The only 2 fields of the MSDOS header that are used are this + @ PE/COFF offset, and the "MZ" bytes at offset 0x0. + @ + .long pe_header - start @ Offset to the PE header. pe_header: - .ascii "PE\0\0" + .long PE_MAGIC coff_header: - .short 0x01c2 @ ARM or Thumb - .short 1 @ nr_sections - .long 0 @ TimeDateStamp - .long 0 @ PointerToSymbolTable - .long 0 @ NumberOfSymbols - .short section_table - optional_header - @ SizeOfOptionalHeader - .short 0x306 @ Characteristics. - @ IMAGE_FILE_32BIT_MACHINE | - @ IMAGE_FILE_DEBUG_STRIPPED | - @ IMAGE_FILE_EXECUTABLE_IMAGE | - @ IMAGE_FILE_LINE_NUMS_STRIPPED + .short IMAGE_FILE_MACHINE_THUMB @ Machine + .short section_count @ NumberOfSections + .long 0 @ TimeDateStamp + .long 0 @ PointerToSymbolTable + .long 0 @ NumberOfSymbols + .short section_table - optional_header @ SizeOfOptionalHeader + .short IMAGE_FILE_32BIT_MACHINE | \ + IMAGE_FILE_DEBUG_STRIPPED | \ + IMAGE_FILE_EXECUTABLE_IMAGE | \ + IMAGE_FILE_LINE_NUMS_STRIPPED @ Characteristics optional_header: - .short 0x10b @ PE32 format - .byte 0x02 @ MajorLinkerVersion - .byte 0x14 @ MinorLinkerVersion - .long _end - __efi_start @ SizeOfCode - .long 0 @ SizeOfInitializedData - .long 0 @ SizeOfUninitializedData - .long efi_stub_entry - start @ AddressOfEntryPoint - .long start_offset @ BaseOfCode - .long 0 @ data + .short PE_OPT_MAGIC_PE32 @ PE32 format + .byte 0x02 @ MajorLinkerVersion + .byte 0x14 @ MinorLinkerVersion + .long _end - __efi_start @ SizeOfCode + .long 0 @ SizeOfInitializedData + .long 0 @ SizeOfUninitializedData + .long efi_stub_entry - start @ AddressOfEntryPoint + .long start_offset @ BaseOfCode + .long 0 @ BaseOfData extra_header_fields: - .long 0 @ ImageBase - .long 0x200 @ SectionAlignment - .long 0x200 @ FileAlignment - .short 0 @ MajorOperatingSystemVersion - .short 0 @ MinorOperatingSystemVersion - .short 0 @ MajorImageVersion - .short 0 @ MinorImageVersion - .short 0 @ MajorSubsystemVersion - .short 0 @ MinorSubsystemVersion - .long 0 @ Win32VersionValue + .long 0 @ ImageBase + .long SZ_512 @ SectionAlignment + .long SZ_512 @ FileAlignment + .short 0 @ MajorOsVersion + .short 0 @ MinorOsVersion + .short 0 @ MajorImageVersion + .short 0 @ MinorImageVersion + .short 0 @ MajorSubsystemVersion + .short 0 @ MinorSubsystemVersion + .long 0 @ Win32VersionValue - .long _end - start @ SizeOfImage - .long start_offset @ SizeOfHeaders - .long 0 @ CheckSum - .short 0xa @ Subsystem (EFI application) - .short 0 @ DllCharacteristics - .long 0 @ SizeOfStackReserve - .long 0 @ SizeOfStackCommit - .long 0 @ SizeOfHeapReserve - .long 0 @ SizeOfHeapCommit - .long 0 @ LoaderFlags - .long 0x6 @ NumberOfRvaAndSizes + .long _end - start @ SizeOfImage + .long start_offset @ SizeOfHeaders + .long 0 @ CheckSum + .short IMAGE_SUBSYSTEM_EFI_APPLICATION @ Subsystem + .short 0 @ DllCharacteristics + .long 0 @ SizeOfStackReserve + .long 0 @ SizeOfStackCommit + .long 0 @ SizeOfHeapReserve + .long 0 @ SizeOfHeapCommit + .long 0 @ LoaderFlags + .long (section_table - .) / 8 @ NumberOfRvaAndSizes - .quad 0 @ ExportTable - .quad 0 @ ImportTable - .quad 0 @ ResourceTable - .quad 0 @ ExceptionTable - .quad 0 @ CertificationTable - .quad 0 @ BaseRelocationTable + .quad 0 @ ExportTable + .quad 0 @ ImportTable + .quad 0 @ ResourceTable + .quad 0 @ ExceptionTable + .quad 0 @ CertificationTable + .quad 0 @ BaseRelocationTable section_table: - .ascii ".text\0\0\0" - .long _end - __efi_start @ VirtualSize - .long __efi_start @ VirtualAddress - .long _edata - __efi_start @ SizeOfRawData - .long __efi_start @ PointerToRawData - .long 0 @ PointerToRelocations - .long 0 @ PointerToLineNumbers - .short 0 @ NumberOfRelocations - .short 0 @ NumberOfLineNumbers - .long 0xe0000020 @ Characteristics + .ascii ".text\0\0\0" + .long _end - __efi_start @ VirtualSize + .long __efi_start @ VirtualAddress + .long _edata - __efi_start @ SizeOfRawData + .long __efi_start @ PointerToRawData + .long 0 @ PointerToRelocations + .long 0 @ PointerToLineNumbers + .short 0 @ NumberOfRelocations + .short 0 @ NumberOfLineNumbers + .long IMAGE_SCN_CNT_CODE | \ + IMAGE_SCN_MEM_READ | \ + IMAGE_SCN_MEM_WRITE | \ + IMAGE_SCN_MEM_EXECUTE @ Characteristics + + .set section_count, (. - section_table) / 40 - .align 9 + .align 9 __efi_start: #endif - .endm + .endm From patchwork Tue May 30 18:36:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 100731 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp352701qge; Tue, 30 May 2017 11:37:23 -0700 (PDT) X-Received: by 10.84.173.195 with SMTP id p61mr84485057plb.83.1496169443835; Tue, 30 May 2017 11:37:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496169443; cv=none; d=google.com; s=arc-20160816; b=LkjmmjvVGZbNthMVi7U/71xVT419kgQQ0UYW/Bmo9Ax+exh7r80+WgUD7xwbjSvY39 VQKuwvGWkSFp8QgVCsQoBBkUOOAnpVsqUWWTGICSHT9CHnG+d9TD2bYq0qgEVsdRb70l 2Lw7m/sLkcB6AWitdsSMU6uxDcMnn8aDJYPKkFCsaUAB1X4anIbWJZHZf9PdLf+DZ3VP u0E7IDNvECgmjl7np6qAlhGAx/r8ZVVhWHBpysk0pjXW5RNK+0ltWQ6dQTYZAj9bETbH SFeRuRVAoDmwgSs03IHeRtDCBmPTeD07DpiaVbZ/auCLCWtbBwyq6+Amt2PdRZyy8zHd 94bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=PLS/rjLbsTGnrOlXYBE6wmSLw6Ww1OT1UMHNC66Yhek=; b=O6LeCR1iFq6A3VJOvJfTRpc8ZLRiXLCZviOMtmstSUOTenUNjjDMNvhoeLtZQjDk4L BiComxYaqDk3cKsx9V4x1NAfjK9Mg1p1Wt+/wcKRDtaDRYW+lBimxNEceZjhh+64SIa3 CmBXvHTvJjnhSopTspzF6vF2lKjs66aHSZ1Nr+dZYQ5koRIhHdATFcU1lC35SrrP+VKG KRFyoAKhfcHXb8oEdRHqhXBsqmmzBb2BoK2itEvjRURuh0uf3hw+T3mttUNuLeTlXAl2 t76xVUChjua3YilaCm+/7U73Jc3UcR3HeTzVdP8mS0H8sde12u+nYmMXILyYHNOeV+BS Y2bw== ARC-Authentication-Results: i=1; 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-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33si44904691plf.190.2017.05.30.11.37.23; Tue, 30 May 2017 11:37:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; 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-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751063AbdE3ShS (ORCPT + 2 others); Tue, 30 May 2017 14:37:18 -0400 Received: from mail-wr0-f171.google.com ([209.85.128.171]:34598 "EHLO mail-wr0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751234AbdE3ShP (ORCPT ); Tue, 30 May 2017 14:37:15 -0400 Received: by mail-wr0-f171.google.com with SMTP id g76so5641249wrd.1 for ; Tue, 30 May 2017 11:37:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cHlZi4W2GBCQ5cy2lIHp1CNSKU+Yan7awOrq+N42SKg=; b=kKy3CuRnoUh63ZRduaHunDQ3/9Gd3a+L3Mb9JYqg3HACQhk+N/8ko3qGWPKpbidnOo mmQdO1tWzXLQjdVJ5MvZDOx+ERpgd16XrBrl7vL+QGWHSu6TMhzyluuNJV9gGeFrSzDl hFEZBa4PxSS/8hbjZGbcTmLhUlCHVInB71zys= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cHlZi4W2GBCQ5cy2lIHp1CNSKU+Yan7awOrq+N42SKg=; b=E0g9Yfc4PgH+2Pk7xBZO+HwTigYudwYgzI/MDRA+JvaTmc9/3z+0GEQN4QIj1QueZv NzudYHye5WXdof59Z8y2YTOkD0j7eJ8QbShhd3cBDMFWwFNaJLcUPL7v/B2+9UhBZySV 7ydgaGZ3nbpe3CU3bEoP4NQIinDET/oEq6PsnkZ5vd72fKFoipQK4l+27bwBqmBfkwvj Se+kM5WkooBWJDeBav9hNvXgSBKbeQFGPInIfBTcHuOXhyjkrNS5z3FC2r/EByoatEB8 t5gl75INSzW65Ihzvuyu7C9abKS8/fXSgQCqiAuLga7w+lSq2qwhktcQdABt6cjKx5/j 5YUA== X-Gm-Message-State: AODbwcCRRuaMKWHWQVJ0kM0PuUj3LgYXnhsq1K7fWmf6n4adse/DMW0x uGFA1XnYWfZpa5XmmNfIHg== X-Received: by 10.223.177.219 with SMTP id r27mr15122684wra.148.1496169424125; Tue, 30 May 2017 11:37:04 -0700 (PDT) Received: from localhost.localdomain ([154.144.49.177]) by smtp.gmail.com with ESMTPSA id b8sm15935997wrb.7.2017.05.30.11.37.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 May 2017 11:37:03 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, linux@armlinux.org.uk Cc: linux-arm-kernel@lists.infradead.org, matt@codeblueprint.co.uk, leif.lindholm@linaro.org, Ard Biesheuvel Subject: [PATCH 4/7] arm: compressed: discard ksymtab/kcrctab sections Date: Tue, 30 May 2017 18:36:44 +0000 Message-Id: <20170530183647.28557-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170530183647.28557-1-ard.biesheuvel@linaro.org> References: <20170530183647.28557-1-ard.biesheuvel@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org With UEFI support added to the decompressor, we may end up including C code that is part of the kernel proper, but is rebuilt for the decompressor. This may result in ksymtab/kcrctab metadata being duplicated into the decompressor, so discard such regions explicitly. Signed-off-by: Ard Biesheuvel --- arch/arm/boot/compressed/vmlinux.lds.S | 5 +++++ 1 file changed, 5 insertions(+) -- 2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm/boot/compressed/vmlinux.lds.S b/arch/arm/boot/compressed/vmlinux.lds.S index 81c493156ce8..1fa62432e283 100644 --- a/arch/arm/boot/compressed/vmlinux.lds.S +++ b/arch/arm/boot/compressed/vmlinux.lds.S @@ -29,6 +29,11 @@ SECTIONS * of the text/got segments. */ *(.data) + /* + * C code that is shared with the kernel proper (but rebuilt for the + * decompressor) may contain exports that we have no use for here. + */ + *(*ksymtab* *kcrctab*) } . = TEXT_START; From patchwork Tue May 30 18:36:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 100729 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp352694qge; Tue, 30 May 2017 11:37:23 -0700 (PDT) X-Received: by 10.98.73.214 with SMTP id r83mr25351489pfi.12.1496169443419; Tue, 30 May 2017 11:37:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496169443; cv=none; d=google.com; s=arc-20160816; b=Rr1Q03VBJ4H7MDCpjMistqhAwBbpZYtof8fby10l9fESI289IiA5DiEi6fKaFkONDY y0apfkitDzguQbdS7F1GN7+8eDIaPfJOmsXSJbvHzagggigKRrdrgmUNM63qiszO8PdD qDFHb+vaRfjOSvOMPMZmuIhHbH98ziB4vsuTgn3vLYYwMHyuk92ijXcYYM5xCXofKwuz XgO6B+W9idk6IQ/YqVtIw951rCwUdWQkWna9M9X8Getoj040jWhaVaf1Z3jYjDezu7tP 6p8svjcOFwo2IrIstbIp0GygvboCxso5NwqlKNeX9lSiA3Cyr0JfC/mJ68St38DhAb3l /r3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=SqZkN1lRxkEX0086HFJlTOX64vyyKviGgbkOSCC2PTY=; b=s5foAJsGy4Ljm9HkEzdAUSlbH92iE2R7z+TKqLF/UsEgVWrweduXeV25IsdOdm+Odr Z+OsBF+lLjupjYhNhCWe3lIITZejhvf7PJz2JLiinuSf2weEJhWV/sBEx5otdHHpObT6 TzhEOZ6OAFRezFUVMqaO0xK1VYRZCrLBUk//qGom88GHgyWxOvAbX8ndwLSoL6eeYFlA EpHyva46kSb90McLPbtDYb7F9HXn+YjgJazrcfn6+cMFZtr+Kc2ib4txVrgtQx5J6oCF /f8nU0qN2OcRC4ImkhqWixxKtzF5eFxmTNuHG5UxsD0pl8v3hq0v7BPawKho/kjW1vTR aLSQ== ARC-Authentication-Results: i=1; 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-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33si44904691plf.190.2017.05.30.11.37.23; Tue, 30 May 2017 11:37:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; 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-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750821AbdE3ShR (ORCPT + 2 others); Tue, 30 May 2017 14:37:17 -0400 Received: from mail-wm0-f46.google.com ([74.125.82.46]:36019 "EHLO mail-wm0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751218AbdE3ShI (ORCPT ); Tue, 30 May 2017 14:37:08 -0400 Received: by mail-wm0-f46.google.com with SMTP id 7so99024063wmo.1 for ; Tue, 30 May 2017 11:37:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Rh13DzP8RS2xlmnfFIZlhniU6tQQooT74gnOuizD2f0=; b=U8Eqo0tLB1/nSBNR3OfWG5B9lbQlkV7AqFB2wiws2DaFsZWFX800DZ1o2WqSYehbJs egN2VBi0hvULCzpKh2enrDynsMWlsCOsb3k6nEBW9IGCA4u84Ag09Oo2hgCwQfl4diG1 0gUc5FNuEF8zP7t1TmpKrNn8ZruAQXl0cNNeE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Rh13DzP8RS2xlmnfFIZlhniU6tQQooT74gnOuizD2f0=; b=Jdmf2b36+bkltgXqCl/V2EiNBHPBGgsADfelMKX+GHe6vqVJJTN9V3LO6uHeBXnx6/ jEIkJFCb4wgsOVf2XH6lzwHRqu+G9/D08QuzPXeI+Ep7c0fNuj4VgyPYH/RVHYU9hO1H DChIHen2sfvKx7cRJFa174+kgzQFwy5QOC85xHEFgh15fQhM3SFo/Iwofx17aGMP62/a 1kdHVIz1PuHWjCLGyx55NysTGVKNRbj9rRvmnZLbiN0S5TvwfsvlHyv4yH9XdZDq0FdJ y7UMhESrNqVNMEdy/PaZ8/2psV2V4Lzwhnt5ROAaT+0wtWu2uVPjZ7nqRoYJSFR4wxnX t7UA== X-Gm-Message-State: AODbwcBkvy1R0O1klSV6hHPMM+3tlcBHG+LlYCN9S1Ggdsm0GpR0OE2M m746bnWGpbpNB7CMz1/wfQ== X-Received: by 10.28.136.85 with SMTP id k82mr2602263wmd.55.1496169426579; Tue, 30 May 2017 11:37:06 -0700 (PDT) Received: from localhost.localdomain ([154.144.49.177]) by smtp.gmail.com with ESMTPSA id b8sm15935997wrb.7.2017.05.30.11.37.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 May 2017 11:37:05 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, linux@armlinux.org.uk Cc: linux-arm-kernel@lists.infradead.org, matt@codeblueprint.co.uk, leif.lindholm@linaro.org, Ard Biesheuvel Subject: [PATCH 5/7] arm: efi: split zImage code and data into separate PE/COFF sections Date: Tue, 30 May 2017 18:36:45 +0000 Message-Id: <20170530183647.28557-6-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170530183647.28557-1-ard.biesheuvel@linaro.org> References: <20170530183647.28557-1-ard.biesheuvel@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org To prevent unintended modifications to the kernel text (malicious or otherwise) while running the EFI stub, describe the kernel image as two separate sections: a .text section with read-execute permissions, covering .text, .rodata, .piggytext and the GOT sections (which the stub does not care about anyway), and a .data section with read-write permissions, covering .data and .bss. This relies on the firmware to actually take the section permission flags into account, but this is something that is currently being implemented in EDK2, which means we will likely start seeing it in the wild between one and two years from now. Signed-off-by: Ard Biesheuvel --- arch/arm/boot/compressed/efi-header.S | 30 ++++++++++++++------ arch/arm/boot/compressed/vmlinux.lds.S | 30 +++++++++++++++----- 2 files changed, 44 insertions(+), 16 deletions(-) -- 2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm/boot/compressed/efi-header.S b/arch/arm/boot/compressed/efi-header.S index 4699c432a2e2..3b1d95f43f2b 100644 --- a/arch/arm/boot/compressed/efi-header.S +++ b/arch/arm/boot/compressed/efi-header.S @@ -57,16 +57,16 @@ optional_header: .short PE_OPT_MAGIC_PE32 @ PE32 format .byte 0x02 @ MajorLinkerVersion .byte 0x14 @ MinorLinkerVersion - .long _end - __efi_start @ SizeOfCode - .long 0 @ SizeOfInitializedData + .long __pecoff_data_start - __efi_start @ SizeOfCode + .long __pecoff_data_size @ SizeOfInitializedData .long 0 @ SizeOfUninitializedData .long efi_stub_entry - start @ AddressOfEntryPoint .long start_offset @ BaseOfCode - .long 0 @ BaseOfData + .long __pecoff_data_start - start @ BaseOfData extra_header_fields: .long 0 @ ImageBase - .long SZ_512 @ SectionAlignment + .long SZ_4K @ SectionAlignment .long SZ_512 @ FileAlignment .short 0 @ MajorOsVersion .short 0 @ MinorOsVersion @@ -76,7 +76,7 @@ extra_header_fields: .short 0 @ MinorSubsystemVersion .long 0 @ Win32VersionValue - .long _end - start @ SizeOfImage + .long __pecoff_end - start @ SizeOfImage .long start_offset @ SizeOfHeaders .long 0 @ CheckSum .short IMAGE_SUBSYSTEM_EFI_APPLICATION @ Subsystem @@ -97,9 +97,9 @@ extra_header_fields: section_table: .ascii ".text\0\0\0" - .long _end - __efi_start @ VirtualSize + .long __pecoff_data_start - __efi_start @ VirtualSize .long __efi_start @ VirtualAddress - .long _edata - __efi_start @ SizeOfRawData + .long __pecoff_data_start - __efi_start @ SizeOfRawData .long __efi_start @ PointerToRawData .long 0 @ PointerToRelocations .long 0 @ PointerToLineNumbers @@ -107,12 +107,24 @@ section_table: .short 0 @ NumberOfLineNumbers .long IMAGE_SCN_CNT_CODE | \ IMAGE_SCN_MEM_READ | \ - IMAGE_SCN_MEM_WRITE | \ IMAGE_SCN_MEM_EXECUTE @ Characteristics + .ascii ".data\0\0\0" + .long __pecoff_data_size @ VirtualSize + .long __pecoff_data_start - start @ VirtualAddress + .long __pecoff_data_rawsize @ SizeOfRawData + .long __pecoff_data_start - start @ PointerToRawData + .long 0 @ PointerToRelocations + .long 0 @ PointerToLineNumbers + .short 0 @ NumberOfRelocations + .short 0 @ NumberOfLineNumbers + .long IMAGE_SCN_CNT_INITIALIZED_DATA | \ + IMAGE_SCN_MEM_READ | \ + IMAGE_SCN_MEM_WRITE @ Characteristics + .set section_count, (. - section_table) / 40 - .align 9 + .align 12 __efi_start: #endif .endm diff --git a/arch/arm/boot/compressed/vmlinux.lds.S b/arch/arm/boot/compressed/vmlinux.lds.S index 1fa62432e283..dfcc2baa0077 100644 --- a/arch/arm/boot/compressed/vmlinux.lds.S +++ b/arch/arm/boot/compressed/vmlinux.lds.S @@ -53,13 +53,6 @@ SECTIONS *(.rodata) *(.rodata.*) } - .data : { - /* - * The EFI stub always executes from RAM, and runs strictly before the - * decompressor, so we can make an exception for its r/w data, and keep it - */ - *(.data.efistub) - } .piggydata : { *(.piggydata) } @@ -75,6 +68,26 @@ SECTIONS /* 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); } + +#ifdef CONFIG_EFI_STUB + .data : ALIGN(4096) { + __pecoff_data_start = .; + /* + * The EFI stub always executes from RAM, and runs strictly before the + * decompressor, so we can make an exception for its r/w data, and keep it + */ + *(.data.efistub) + __pecoff_data_end = .; + + /* + * PE/COFF mandates a file size which is a multiple of 512 bytes if the + * section size equals or exceeds 4 KB + */ + . = ALIGN(512); + } + __pecoff_data_rawsize = . - ADDR(.data); +#endif + _edata = .; _magic_sig = ZIMAGE_MAGIC(0x016f2818); @@ -89,6 +102,9 @@ SECTIONS . = ALIGN(8); /* the stack must be 64-bit aligned */ .stack : { *(.stack) } + PROVIDE(__pecoff_data_size = ALIGN(512) - ADDR(.data)); + PROVIDE(__pecoff_end = ALIGN(512)); + .stab 0 : { *(.stab) } .stabstr 0 : { *(.stabstr) } .stab.excl 0 : { *(.stab.excl) } From patchwork Tue May 30 18:36:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 100727 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp352687qge; Tue, 30 May 2017 11:37:23 -0700 (PDT) X-Received: by 10.99.109.73 with SMTP id i70mr27503025pgc.62.1496169442917; Tue, 30 May 2017 11:37:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496169442; cv=none; d=google.com; s=arc-20160816; b=BMX4yQs5/ENnFW5shmybpaL/9H/Va9U10LGbNiV+ygEne4EeznWXDl8zcsWI99RzMI k950iHopT9ssaqgDgOB5d67Un5CjdOhFAlfd/P3RVYbrgweEjtwXYYHAK3qyn1znPHmM tQqBTkRHZUaAm1II3tSbREuPvrRRKjqInT1gDVB4r+icZJ2vLx75j6WXrNLSFCtRXUxO 0tHCSJ1qPLuy5rufBUy18qkAQsMVS5NRGuSRT+Ntr6Auq+1j+CrKI/rYYl89wZKLtlmv II2sFABszbna0vqzH1TgKw0oBNwIylzfFr8dXh4Bent0R79mcmwQey8v2nSV8oVUFbuV EYHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=h8PRqFVlBWEB4A3qvusA7fZkarv0TD//BuxaF7u139s=; b=PQq977R9WKoIJWITfystqQIHk6sheH4/Z4v87XF9jS03gtXN0zH2cLl5/smdjbTBqD 2IIubartidIMaANkMz7ISAx5QN9/HX0+y82PcqBsJ+fFTjxxnaKqWffPQKeb2eU2JnFR 9Vj/tiMB3+CxHK5h2l2Qx1C8je2D2fzHHQtAptgPCtzjqRqm+GKN7EcNCJj4xTwQWFoZ ORZC4evaQTszklceEXPg3worcnoCB4696jd8WyE2dX/Q/0l8UKYusP82O40sfhMo0ETo +HRAvxx01yEcjqLDy+H1ONz4XCvmyj43YtbhZR/2981xYunmuGH+wzF/IlTihs8ai1mW nUqg== ARC-Authentication-Results: i=1; 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-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33si44904691plf.190.2017.05.30.11.37.22; Tue, 30 May 2017 11:37:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; 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-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751241AbdE3ShM (ORCPT + 2 others); Tue, 30 May 2017 14:37:12 -0400 Received: from mail-wr0-f182.google.com ([209.85.128.182]:33312 "EHLO mail-wr0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751162AbdE3ShK (ORCPT ); Tue, 30 May 2017 14:37:10 -0400 Received: by mail-wr0-f182.google.com with SMTP id v104so5599228wrb.0 for ; Tue, 30 May 2017 11:37:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ufzn2wMF2X0ewfs984gzAqMIZGKBj40W7XprtCQlYDM=; b=A5XcwNlOJvTrV9m5Do1bX24OYFZUjgz42jLr4GZDVtc8AmGXcmeRX3bKfh6n9lSSjS 9nTSZug+XeLNwA8Q4s0L+QgZirIrisDHCHKX0XqV0yTDsLtimuk2GwqshdGp25eP5Oie 6Wor7zIr+LeaX6JyWeySCuaIVok2kTiP+j0ns= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Ufzn2wMF2X0ewfs984gzAqMIZGKBj40W7XprtCQlYDM=; b=FzJfeRgUgC2+39Qd/67h9gud3QpLC4bUun/69aKlFxC/vlBev2OgCw6LtXbdoySjUT 0MRrvCzKw4tIOqUcHrkq4lGWZTindHIlLahDwzZUHBcLBrjPBh5FZEqGesscXEt/dZtZ Lq9obySbC4hymZG7aXRt0gq8fA8QodQBjECL2NF/aVb99/5gL8F9Xz8NV0bGibuk0ylf gVQnJowGGheK1NzpGaZoE5YdKYw0/X6Rmg8MzB7TiokFOM1/P0y0KBjq7+BZ6r3nz47e vMYM8bLOY/ROZTib7ObRnDz1UB+qVkrUX0yXo4q7ZT2KxyrCDXhP2TnR44dla1ZTtSNE UA2A== X-Gm-Message-State: AODbwcCtD1Rb2wq/Ep/Ef8atbzTZraX15wVIcnODwfR0BmZtY9Wlcnff hWBmk/L7lMSW1UqNgbdvJg== X-Received: by 10.223.176.25 with SMTP id f25mr11830115wra.74.1496169429190; Tue, 30 May 2017 11:37:09 -0700 (PDT) Received: from localhost.localdomain ([154.144.49.177]) by smtp.gmail.com with ESMTPSA id b8sm15935997wrb.7.2017.05.30.11.37.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 May 2017 11:37:08 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, linux@armlinux.org.uk Cc: linux-arm-kernel@lists.infradead.org, matt@codeblueprint.co.uk, leif.lindholm@linaro.org, Ard Biesheuvel Subject: [PATCH 6/7] arm: compressed: put zImage header and EFI header in dedicated section Date: Tue, 30 May 2017 18:36:46 +0000 Message-Id: <20170530183647.28557-7-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170530183647.28557-1-ard.biesheuvel@linaro.org> References: <20170530183647.28557-1-ard.biesheuvel@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org To align the PE/COFF and the ELF headers of the decompressor binary, put the zImage header and the EFI header in a separate .start section, and emit it at the start of the Image. This change is necessary for UEFI based debug tooling to be able to use the vmlinux ELF binary, since it gets confused if the PE/COFF .text section and the ELF .text section live at different offsets. Signed-off-by: Ard Biesheuvel --- arch/arm/boot/compressed/efi-header.S | 1 + arch/arm/boot/compressed/vmlinux.lds.S | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) -- 2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm/boot/compressed/efi-header.S b/arch/arm/boot/compressed/efi-header.S index 3b1d95f43f2b..a0567ed366c6 100644 --- a/arch/arm/boot/compressed/efi-header.S +++ b/arch/arm/boot/compressed/efi-header.S @@ -126,5 +126,6 @@ section_table: .align 12 __efi_start: + .text #endif .endm diff --git a/arch/arm/boot/compressed/vmlinux.lds.S b/arch/arm/boot/compressed/vmlinux.lds.S index dfcc2baa0077..aa0ee9b5affe 100644 --- a/arch/arm/boot/compressed/vmlinux.lds.S +++ b/arch/arm/boot/compressed/vmlinux.lds.S @@ -39,9 +39,11 @@ SECTIONS . = TEXT_START; _text = .; - .text : { + .start : { _start = .; *(.start) + } + .text : { *(.text) *(.text.*) *(.fixup) From patchwork Tue May 30 18:36:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 100730 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp352697qge; Tue, 30 May 2017 11:37:23 -0700 (PDT) X-Received: by 10.99.157.196 with SMTP id i187mr27635577pgd.132.1496169443651; Tue, 30 May 2017 11:37:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496169443; cv=none; d=google.com; s=arc-20160816; b=D+t9Iw5xTQHMccYrPDStTPMA+MEFjCyW0JOca0/yQJpOBCQ5nOp2dsWNFAhs2H4IC8 zqk0ukaMBMZVT7FiqvBDcli4gR2Dnv7tFVi81WM42AGgsqpPx8N/uW1veIUll57Rle2b 07jdcod+ULoh+qhuvEMMJ+PxeTqqtDeIzYuCphMKKckDvSoLr3LQWj+jnlRxpabs2RNM XnyOpLgE4d2HeASzpG6+WJrozEjxUihPFoA0FlxN4BFnC9vJ3IrQ716N2M7+mSpvpKPZ 3BG8TXdj72j7kSXQ5lQ42KKijToVm2RQZMyYZdEv/9QUxoIBFflRu+ROP9BjRonuRxhf 8bGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=mlVxWHI273EkZhy45WjHac/SQ/0iXYP2V4V3QlUQrqA=; b=algTPrBsFZphNFrgdtiOjzokPgQnnwBPbWuCo5nEUwlQmUnXUJSeK2AL3zh3yVQXZ6 6JXMq0YQE0bgdtAbKlEcztbxp+QtZBC63eRAO/Wa4JfFc1GhctXGDmE6Lo+KaH3V6DSA 9QNQkdCootGQbfBdaNW8wYO/UX8tFUd9dPc7Xz6NDj+StNHlEXdSJkEV18JmOfL9iku7 z+y1JKfYU5TQlWKpynde9yaCkPnPMG5Z8V51bt7ftmX83Kx4+ziYH0xwbTXr/vOw+CQi mVKkxB98LDZv4UyvOT1vxqvkxz6B4fRr+Z7Rbj99cJAr83yovDDXycjD+XOM2glWN03t wJ9g== ARC-Authentication-Results: i=1; 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-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33si44904691plf.190.2017.05.30.11.37.23; Tue, 30 May 2017 11:37:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; 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-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751437AbdE3ShQ (ORCPT + 2 others); Tue, 30 May 2017 14:37:16 -0400 Received: from mail-wr0-f182.google.com ([209.85.128.182]:35374 "EHLO mail-wr0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751162AbdE3ShN (ORCPT ); Tue, 30 May 2017 14:37:13 -0400 Received: by mail-wr0-f182.google.com with SMTP id q97so10881274wrb.2 for ; Tue, 30 May 2017 11:37:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VahZKvVUPAW7guFVAVjnXYvJLRsuBGOrnJMKjd3ZDU8=; b=NQZAmYSFEXjLPQrEGfpRewM0q74Lr2klp5stbQNIb4OQt1mGJZo78gjK6inde8JWSk kax3GOgzHvYDctdl6+iz7e0Nmzsw4381BhQCUzgEy9jT2HGwsJM96Uu4VjBEGhhMMCvT KMGFHzF8ZDjhVw4iNVxywMbPzY4WaGf2+gn9A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VahZKvVUPAW7guFVAVjnXYvJLRsuBGOrnJMKjd3ZDU8=; b=Jsn5uNFZxxA712ocbkHiRPRWKh2BOzvX7afWxIIIM46LVHE/1SCZXf815nKykIDXwX PscWekDco2qeT6/8KokP+7QhjJJZIAFqAfbK8X3ZPnGPLDJNXX9+6qVOtsRiTz+GhWR7 XOFE16LmlH1kSl/mNvGOO7c8QMc4bcN2bJN670QqvRPRyIN1gFZKHx3Cm6Ini+kCX0ml Zl7ZTEIRtYFxKu02AFIlgzuztMbUKtTuQjz8d3YHrx1l0QIf78YwhOglyMbwH8wwOrzK yiVKapaoEhjZ4BzD0tdOGeBWS+v2q2IBJQwKCN2IkDM+Aikhtam3sWearAgId8nyo6Q1 op9A== X-Gm-Message-State: AODbwcBmUC17HszJ52JfwBqM4O/t4n/iDn0EcwZTu7dtZv+MjsTq8YP1 JGOP9hG2pOAXEKAThgt2xQ== X-Received: by 10.223.153.244 with SMTP id y107mr12954051wrb.96.1496169432021; Tue, 30 May 2017 11:37:12 -0700 (PDT) Received: from localhost.localdomain ([154.144.49.177]) by smtp.gmail.com with ESMTPSA id b8sm15935997wrb.7.2017.05.30.11.37.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 May 2017 11:37:11 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, linux@armlinux.org.uk Cc: linux-arm-kernel@lists.infradead.org, matt@codeblueprint.co.uk, leif.lindholm@linaro.org, Ard Biesheuvel Subject: [PATCH 7/7] arm: efi: add PE/COFF debug table to EFI header Date: Tue, 30 May 2017 18:36:47 +0000 Message-Id: <20170530183647.28557-8-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170530183647.28557-1-ard.biesheuvel@linaro.org> References: <20170530183647.28557-1-ard.biesheuvel@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org This updates the PE/COFF header to emit the absolute path to the decompressor vmlinux ELF file into a so-called NB10 Codeview entry. This is hugely helpful when debugging the firmware->stub handover. Signed-off-by: Ard Biesheuvel --- arch/arm/boot/compressed/Makefile | 4 ++ arch/arm/boot/compressed/efi-header.S | 40 ++++++++++++++++++++ 2 files changed, 44 insertions(+) -- 2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile index d50430c40045..6b978bdbac3e 100644 --- a/arch/arm/boot/compressed/Makefile +++ b/arch/arm/boot/compressed/Makefile @@ -196,3 +196,7 @@ AFLAGS_hyp-stub.o := -Wa,-march=armv7-a $(obj)/hyp-stub.S: $(srctree)/arch/$(SRCARCH)/kernel/hyp-stub.S $(call cmd,shipped) + +ifeq ($(CONFIG_EFI)$(CONFIG_DEBUG_INFO),yy) +AFLAGS_head.o += -DVMLINUX_PATH="\"$(realpath $(obj)/vmlinux)\"" +endif diff --git a/arch/arm/boot/compressed/efi-header.S b/arch/arm/boot/compressed/efi-header.S index a0567ed366c6..3dedaab49cb8 100644 --- a/arch/arm/boot/compressed/efi-header.S +++ b/arch/arm/boot/compressed/efi-header.S @@ -124,6 +124,46 @@ section_table: .set section_count, (. - section_table) / 40 +#ifdef CONFIG_DEBUG_INFO + /* + * The debug table is referenced via its Relative Virtual Address (RVA), + * which is only defined for those parts of the image that are covered + * by a section declaration. Since this header is not covered by any + * section, the debug table must be emitted elsewhere. So stick it in + * the .init.rodata section instead. + * + * Note that the EFI debug entry itself may legally have a zero RVA, + * which means we can simply put it right after the section headers. + */ + .section ".rodata", #alloc + + .align 2 +efi_debug_table: + // EFI_IMAGE_DEBUG_DIRECTORY_ENTRY + .long 0 @ Characteristics + .long 0 @ TimeDateStamp + .short 0 @ MajorVersion + .short 0 @ MinorVersion + .long IMAGE_DEBUG_TYPE_CODEVIEW @ Type + .long efi_debug_entry_size @ SizeOfData + .long 0 @ RVA + .long efi_debug_entry - start @ FileOffset + + .set efi_debug_table_size, . - efi_debug_table + .previous + +efi_debug_entry: + // EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY + .ascii "NB10" @ Signature + .long 0 @ Unknown + .long 0 @ Unknown2 + .long 0 @ Unknown3 + + .asciz VMLINUX_PATH + + .set efi_debug_entry_size, . - efi_debug_entry +#endif + .align 12 __efi_start: .text