From patchwork Wed Feb 8 11:55: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: 93614 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2648639qgi; Wed, 8 Feb 2017 04:04:46 -0800 (PST) X-Received: by 10.99.174.71 with SMTP id e7mr26864626pgp.3.1486555486223; Wed, 08 Feb 2017 04:04:46 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z126si6908390pfz.272.2017.02.08.04.04.46; Wed, 08 Feb 2017 04:04:46 -0800 (PST) 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 S932093AbdBHMEj (ORCPT + 2 others); Wed, 8 Feb 2017 07:04:39 -0500 Received: from mail-wm0-f50.google.com ([74.125.82.50]:33894 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753651AbdBHMEh (ORCPT ); Wed, 8 Feb 2017 07:04:37 -0500 Received: by mail-wm0-f50.google.com with SMTP id 196so49852034wmm.1 for ; Wed, 08 Feb 2017 04:04:36 -0800 (PST) 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=VcjIRD+xVA6HQExNHmIkYbEp2LMFJF8VPZKdYKkEofA=; b=fWMO7WvosqT24PcdLfCxVkzEDSvcbPfNdJ3tIZ/0nyFPr/X87UPzzxY2nh4MbKkt7D /sYvZpGRGGN8fVEpnyf4xSPL/5FkCaonqTyUDqKV5Hre4zGdf8DgxnrQ4IuTZSjrzTzT 5q5+BC8ApF5B3rIuGoflyhVjw/s2k0beU7lhw= 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=VcjIRD+xVA6HQExNHmIkYbEp2LMFJF8VPZKdYKkEofA=; b=Yk0JOVcnrFEmUFdy+RhocdZCzwD6Rzm1hXXKjbNi+1Efk0ViWQxCFIehvkaRiwJF1u dhujYH0QxwjlzxBP/BV2F2A3A72xwD/ReHPdvmy8eIo8c/l/SYRXquhND/JfZuxWM6Y6 t20a5l16qgzaKRw0AGKgRyqEsUUxesCW3eDpKci4+5jWZvk5PFgVbXS3tawsJfpbc6b6 7Y9lSsVd01l+qH+oxb74+yl/cLUWD/xNzWvgu/Zunnptghq3m6R+pJsKAror+neyUyPR ojPcbQhHSM+ex/M8TIWtpxgGGbwnDAfW5Kyj0pb3u+p0eLAAyrORdXSgrPe6cFiEeuQ3 lOuA== X-Gm-Message-State: AMke39nPFKV2uINqEPYvn4FN9P1ifOVrMIh2xp4JS4jIpI/l5NhQSmJfHENZyBpD/2q/yeP/ X-Received: by 10.28.1.216 with SMTP id 207mr18541148wmb.7.1486554999749; Wed, 08 Feb 2017 03:56:39 -0800 (PST) Received: from localhost.localdomain ([160.169.163.122]) by smtp.gmail.com with ESMTPSA id 123sm2974815wml.6.2017.02.08.03.56.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Feb 2017 03:56:39 -0800 (PST) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com, leif.lindholm@linaro.org Cc: catalin.marinas@arm.com, linux@armlinux.org.uk, kernel-hardening@lists.openwall.com, labbott@fedoraproject.org, Ard Biesheuvel Subject: [PATCH v2 14/14] arm: efi: add PE/COFF debug table to EFI header Date: Wed, 8 Feb 2017 11:55:47 +0000 Message-Id: <1486554947-3964-15-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1486554947-3964-1-git-send-email-ard.biesheuvel@linaro.org> References: <1486554947-3964-1-git-send-email-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 | 45 ++++++++++++++++++++ 2 files changed, 49 insertions(+) -- 2.7.4 -- 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 3cf09f7efced..dff3c72c7c5a 100644 --- a/arch/arm/boot/compressed/efi-header.S +++ b/arch/arm/boot/compressed/efi-header.S @@ -95,6 +95,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_data_start - __efi_start @ VirtualSize @@ -124,6 +129,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: #endif