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