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: 9816233 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7DA75603D7 for ; Thu, 29 Jun 2017 08:21:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74DC62003F for ; Thu, 29 Jun 2017 08:21:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 68AB12867D; Thu, 29 Jun 2017 08:21:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CA3B52003F for ; Thu, 29 Jun 2017 08:21:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=ensbsvA5spho9QtWkI30rERLU0O+a06bmizm2N00zVU=; b=bRqiY7uwg+vf3Sv6Bl4jyNEUqz PjTLrEFCZvDy+ueJFWnQmbRYJFTwiAZmlJ0qu5geK4x8G61Md9/9rERhaEP94wScJxVSIfO0FE9oE +BLqj6UbPYNRKh7IN1xZDyQ/YJKWe2lmGZPqh368Y4CbVL19DZ0bfxRgNVFMTSXDcc7KpibqoyCL1 o5R2pQQ9KZe9tnOHEroQxZL6/KUs4rTYIREn0Eghxu/CFjW2rlckfKbtfThPw1iCoNTsulWIu+oU6 QuqVcT2LBbcSvsCKHN+CPJ6fz3igu+3fNJ0mrjTV08Y7VysXOILVuVnUI2sdLzVHv/92pyBIB8gSi VzAiiWoQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dQUh9-0007GI-V6; Thu, 29 Jun 2017 08:20:59 +0000 Received: from mail-wr0-x233.google.com ([2a00:1450:400c:c0c::233]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dQUfo-0004KP-Lf for linux-arm-kernel@lists.infradead.org; Thu, 29 Jun 2017 08:19:41 +0000 Received: by mail-wr0-x233.google.com with SMTP id r103so185583623wrb.0 for ; Thu, 29 Jun 2017 01:19:16 -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=Pqme0I+VPUOer/oVELrTgCybH6Bx5bxacYVJS231lAHZrH6ewqaoWgaSe1ClGInJcN 7e2Bc9vN3Kmf1nVHPk9OAhiZ+xIohqIxdH+HSCGptHcZzoCZQ0NKPBVC/ShjIC82uorG slIMTX9uI4U9DIjDaevxjKpcDUBRJDltbnt91rcmGsmrAT++BUbySMByBcIsbDWGEGOi VvevMelLsGwTMVcyADmraqGh3ozjwDIfZJgfcNopVp/0jOA8D2LQ+EcDBeKMthQ229lN G8kV5GcKwrUiLxkiFWothfUQsRr+hBYvz6V9OaCONa8SfJiZcNsI5e7Xj/z+q6V5ur0w +vFA== X-Gm-Message-State: AKS2vOwTxE5cmZVpgXpUtRRr3SVrK/4teBrTX5tU71WbMduLI4w36aum jKdtQn5hzGcnkskn 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170629_011937_112914_2AEC86D0 X-CRM114-Status: GOOD ( 11.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: matt@codeblueprint.co.uk, leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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(+) 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