From patchwork Thu Jun 29 08:18:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 106620 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp818482qge; Thu, 29 Jun 2017 01:19:17 -0700 (PDT) X-Received: by 10.84.128.67 with SMTP id 61mr17111302pla.246.1498724357881; Thu, 29 Jun 2017 01:19:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498724357; cv=none; d=google.com; s=arc-20160816; b=VAegDlFrcaWOH6PztjGXDVFgpSmfl8fRW201UNIY/FfFU/OpPIIiO1xKft0YjDxJhN xHWclHPRxI+d9lahqog9VuSxZiUFT4l2GzK5FbhQK1x2tZpl1ESWUQBTxXFT7sxthovo 3EKEVqGcnjO2iArxtA4rUYHA3y27zLpOSkVjND4QdIpLuszxlgOvb+AqSPO94I5BT/7L cC6yIublO5IyuykE/iIsNgMFwyyzKMivaizJ4z0Mu4PfD4Dzi0VhcMXLtE5FZ+bZLfCH TUFAHBPT3/6hM7lCKWytPOp+gfIhmjjNegLUNesEb/ITqJH5f2CQyfI36Gc8afe3EsMZ iRUQ== 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=O0DCnmwx+7yH+kxWyVop071x3EnfKo31qsFRvFMMgcU=; b=cYwynb0KeThNcZiXrheRopthO2W/bcZON1C53+xBaOx0iuO3aP0ASnvPj6pkR1i6h6 7T5ImQClmUcUQVhRuyp4ssHUVn6mkcw8K8YDUw/u02w6ERfG1begbazXEyiwB2p6NRpD OPag7LOwgSwSknyVU4v6pM0mP43BoiJJyXtEzaR8rreRx3u/TjcCiOa5/4y/lh5+qWfo Q4fG9D6H1fpZSS+tGtK30e+EqbYLEBkeKoYMDf3Samt85UCWdL8YBHPY91cOrCp+bu9W UxorU6z4W3DXxXUufttKccfgu5kw23jepknrLtbE8fQPCkoqzPplFaEsuHCYV2tRabPt Tifg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=dRqyUMeN; 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 h68si3195921pfc.73.2017.06.29.01.19.17; Thu, 29 Jun 2017 01:19:17 -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 header.b=dRqyUMeN; 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 S1752103AbdF2ITR (ORCPT + 2 others); Thu, 29 Jun 2017 04:19:17 -0400 Received: from mail-wr0-f174.google.com ([209.85.128.174]:35476 "EHLO mail-wr0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751894AbdF2ITQ (ORCPT ); Thu, 29 Jun 2017 04:19:16 -0400 Received: by mail-wr0-f174.google.com with SMTP id k67so184865482wrc.2 for ; Thu, 29 Jun 2017 01:19:15 -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=2g4ye38krl4zPjNmbfaxc3egXSiKEm459Z51is+QQYY=; b=dRqyUMeNygJkb0RgdbXQWPOGF3hN1okGuonogWmZcz6el/u7lPh92dPeSAjGnVzjRT 7pJzr4hVwGfLylrajEsdBRjOJrcGDsPLmgISQMTyBmvFMdHDCWJNVxzJNV6HJfims09E hGt6TNEniNv6BPu7L2QWlB0GeBToiuxc1LSwQ= 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=2g4ye38krl4zPjNmbfaxc3egXSiKEm459Z51is+QQYY=; b=SNTo7hRIs/pH+Pz5k2YguNI7xUl5RMfLSC77JCP5n0RGjL0QD6uAwlZ9zeJyx0Zaa7 Y01EBB+nOLMxaiJqSDBGTtgO9XFocrADS1uS5suDNeOvlrFFW9GBDXGlz3k9AdG/uPrF yhNymawii4TWsEh2Nc8EBTDb9wfwFP3bDgQQ8lAIRvWaRUcNV8CJQT99COlkP86LOwwP I/qpNDafCENqX6NFVRif2LCOOQ+AyZta6yq8Q41dPfM3HFGy5+BF3f77aN8l1dt0pWov R7WVm1QH2/JM25RoKYkDjjYXWLLAq2ITB4hPYCjCwsvDPk44djSMFLykk0b0jovL0rtP VOcA== X-Gm-Message-State: AKS2vOwzmdSJvhDrs5JWnZRp8eiiAizomXkdlDCXheJkMH6UuObpVTH5 g05CmrdRX6ENf0PJHF4POw== X-Received: by 10.223.166.139 with SMTP id t11mr20572788wrc.39.1498724354769; Thu, 29 Jun 2017 01:19:14 -0700 (PDT) Received: from localhost.localdomain ([196.90.227.203]) by smtp.gmail.com with ESMTPSA id p34sm5268190wrc.66.2017.06.29.01.19.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Jun 2017 01:19:13 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux@armlinux.org.uk Cc: matt@codeblueprint.co.uk, leif.lindholm@linaro.org, Ard Biesheuvel Subject: [PATCH v2 7/7] arm: efi: add PE/COFF debug table to EFI header Date: Thu, 29 Jun 2017 08:18:49 +0000 Message-Id: <20170629081849.15081-8-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170629081849.15081-1-ard.biesheuvel@linaro.org> References: <20170629081849.15081-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. Cc: Russell King Signed-off-by: Ard Biesheuvel --- arch/arm/boot/compressed/Makefile | 4 ++ arch/arm/boot/compressed/efi-header.S | 47 ++++++++++++++++++++ 2 files changed, 51 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 a14516f7a27e..e902414e90b6 100644 --- a/arch/arm/boot/compressed/efi-header.S +++ b/arch/arm/boot/compressed/efi-header.S @@ -98,6 +98,11 @@ extra_header_fields: .quad 0 @ CertificationTable .quad 0 @ BaseRelocationTable +#ifdef CONFIG_DEBUG_INFO + .long efi_debug_table - start @ DebugTable + .long efi_debug_table_size +#endif + section_table: .ascii ".text\0\0\0" .long __pecoff_code_size @ VirtualSize @@ -127,6 +132,48 @@ 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 .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