From patchwork Thu Jun 29 08:18: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: 106614 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp818345qge; Thu, 29 Jun 2017 01:19:06 -0700 (PDT) X-Received: by 10.98.158.29 with SMTP id s29mr15413938pfd.126.1498724346038; Thu, 29 Jun 2017 01:19:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498724346; cv=none; d=google.com; s=arc-20160816; b=kdRnviWpJebAy5200lgD0FDnwrgAbsgzuy+4IGdA9FXseQQNqVsyRjqOB8wIcFjO3M dbN/SYZAs4nPRmxaBj30vLiV0+cNyvPKsU+tnBZsvtW/9NYcqmc4+QqsJrwrtcTxNfXF l3y6x65JMCqss7JPeiHCg7+ybCZk+pkqpLejFFQjOoRuB6H6fksjJsftYsGDfa9+3GRJ +aR7vXLqWHslDnhsKnra1A6UVFJVwMXiwOtSt0je5u9umBUEPHH5YSl1PbRYzE20Ic4C KX2DCwrcY8hofFbMuaByTTVinlV9YQZLEgaEkmf/sCkZ0QTu1lBSy17ASC7uVa8XDBLB IUMw== 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=YjKnJk4r/uQfsIni79W3ZADGD1GotL0HzIhHh7LAKUo=; b=DgmdeYmD6AWs/xxDvk2ZdcipZDqL/LjSAInMHBUwfpxTGgRskiQhGN+vs+X4KeP2k8 T4t4TPNH3rY8GbDRfzKU3U15L0R6iiduOTSlneE1gloQ4tBYyd4abNcDck4LVXljfreS LwhbfCKSsJg5m9xOyo21Ob5NdUPbUsvNWt7FbkEwbAv70om1wwyoCjR7ukOXmYsOVtxJ n+NaNbbpJtOhbTn3CWogOIMMTbhhaZ3YP6sNQzhpsfqUKMfdnGpZjYk0x/VxrrE7HAtV 5CGxifmGo+telJf+7jwNYQjvFrdEMM17aa035aL19TRxVl2FUo8Aj3A0saKoo4yodfNF viQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=Fny/KpIi; 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.05; Thu, 29 Jun 2017 01:19:06 -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=Fny/KpIi; 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 S1751986AbdF2ITF (ORCPT + 2 others); Thu, 29 Jun 2017 04:19:05 -0400 Received: from mail-wr0-f175.google.com ([209.85.128.175]:34265 "EHLO mail-wr0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752042AbdF2ITE (ORCPT ); Thu, 29 Jun 2017 04:19:04 -0400 Received: by mail-wr0-f175.google.com with SMTP id 77so185498403wrb.1 for ; Thu, 29 Jun 2017 01:19:04 -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=5OnNEz2k7EsWVolQ/o4L6fUwBHNmgjzV69WSGfO1v8A=; b=Fny/KpIiTkfocbfB+mrwSIxYq7oscV/ebxNoQDanlaOkRmzMClnIsbRLmA6ow8KNH2 wnZAND/xSY6ytWhoUQ/k54f5TFmFnKVC5CgMeQaDTXGtQLaeCIi8F+/EJtPeR2XVvav4 lFp98qDdS38WfqmKnKWcnIMzQ4SCKesR8zOD8= 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=5OnNEz2k7EsWVolQ/o4L6fUwBHNmgjzV69WSGfO1v8A=; b=P/gywkC35BnMoaRoW3AE28Y9EbZb7HW+JJbR0b2aAzvwUm2VRfLwz37P9Z+b71E/He o+VYjkzQgxIBMZUukoo8o7EfHIVl724B5C6vHjM6fiB+U3zDMpy6+lQq6l9J6qAeTeb9 Qu9P0OniLfJBoWytSgeBGl9nHM9Bqb0ja58bHc0kYT3aYUcwyT0y4hhWKOgk8/qMov3J +yaRVQV53/UCVWqoV1O1qgRHKZzrbDE9DoaLeEbUQb4xigqUkxIUr4g6Zt8VXAdthUDf 5NPfIHnxeBnQ4l72ErI1uEAVTaXg9BEUgGE9/+3QZbOywHaujYRHkBV/+6voj3QssYqH E4IQ== X-Gm-Message-State: AKS2vOxqydk9BtIBcnu2NMhijPvkwuZuI75yotJA4JGVkvgzc+X8A8rr gFuzSSPWGov2qBDRz99Qsg== X-Received: by 10.223.141.138 with SMTP id o10mr24753449wrb.69.1498724342970; Thu, 29 Jun 2017 01:19:02 -0700 (PDT) Received: from localhost.localdomain ([196.90.227.203]) by smtp.gmail.com with ESMTPSA id p34sm5268190wrc.66.2017.06.29.01.19.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Jun 2017 01:19:02 -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 1/7] arm: efi: remove forbidden values from the PE/COFF header Date: Thu, 29 Jun 2017 08:18:43 +0000 Message-Id: <20170629081849.15081-2-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 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 a17ca8d78656..4169b900d9d4 100644 --- a/arch/arm/boot/compressed/efi-header.S +++ b/arch/arm/boot/compressed/efi-header.S @@ -44,7 +44,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. @@ -110,7 +110,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 @@ -121,7 +121,7 @@ section_table: .long 0 @ PointerToLineNumbers .short 0 @ NumberOfRelocations .short 0 @ NumberOfLineNumbers - .long 0xe0500020 @ Characteristics + .long 0xe0000020 @ Characteristics .align 9 __efi_start: From patchwork Thu Jun 29 08:18: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: 106615 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp818379qge; Thu, 29 Jun 2017 01:19:09 -0700 (PDT) X-Received: by 10.99.2.69 with SMTP id 66mr14802807pgc.61.1498724349020; Thu, 29 Jun 2017 01:19:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498724349; cv=none; d=google.com; s=arc-20160816; b=ZHZ4jN8o08cmZBTzH6v3EW/4Pevv4mXroJfrjBNKq/3g4HF77RU4bguULB9FfF21b2 72o6U9+ZF8SMyy4M5eQXD2hliqIQ9h3L2pN4r/3iOAL9gUs7kh1b//AaJUfn/+fDY6bF hUmySa40zwrdgXv/8LIqBuiC/JqjBexdjOzlwSBSVSklPXis3S60iPQdagU3MiSh2huB RQO6d7NUIcuEWHN69la1hVwWiT/HIBpuy/ydP7VGSd3nAGcnliIyvIhTN+wMkprOkc1H 5x6yPVy3w94fGmVExpnebMIYyu94lr3IRCH3QQBrpiJJXRyX0Y8Uo3Y8g8DtB1ekxGLC +Kwg== 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=i0xVy2fGKJza5TOcj8Yzd+/fXYTNpKIBFOCLmhUTA2I=; b=lHtEJg5dZqsRXqnfnrIwAKxk0/lkMWM3XMhN+SKqLLMc2dHwRFeB/lhFpk0yCrJSbT Fr5MsrwGV2tT12O4xYgOkV09l71Buvf85H/99j0sLIbnAAp1ngai5TbiWm6ElsmVIYm7 Z9CKZKuLjJ/it67XOrWqP5yOVO8/90NjH0nSQc+2DlZt5oBsDOT9hp4SETFE8Nf9X1Bp LF/peGzDvWnu/nPPmoIdlx9ziTGobyOtMVzbA88m44ws9izt8PSYo8p0VQFVOKzKMPGE LpfxeSDeD95K8PBDUcPrmYy01iCWdTzHpNHFP8usszg1lIfqOIVF48UEEas7RGxxkE3F oq3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=R6rcOTNU; 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.08; Thu, 29 Jun 2017 01:19:09 -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=R6rcOTNU; 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 S1752103AbdF2ITI (ORCPT + 2 others); Thu, 29 Jun 2017 04:19:08 -0400 Received: from mail-wm0-f41.google.com ([74.125.82.41]:33643 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752042AbdF2ITG (ORCPT ); Thu, 29 Jun 2017 04:19:06 -0400 Received: by mail-wm0-f41.google.com with SMTP id z75so17102912wmc.0 for ; Thu, 29 Jun 2017 01:19: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=vw11mbpfN5ga0cEoTYR17nlhIVR/QPgl0eTTDTCXqPM=; b=R6rcOTNUZq0yMhbkYsrfLlvgFI413Vr0+VT93YCnEnpr39+T1AdbyB/iM9nVdW3Pru aDejAcq2SUT4Qi0yJuNJ28VuwpE/s8AcCPE/CKfKm8AlgZKWvV+zx9gk6iQBB4pBIHa2 T/H3POzaCTdaYn3Ba2+elnGGMFVB7hmOQPHVQ= 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=vw11mbpfN5ga0cEoTYR17nlhIVR/QPgl0eTTDTCXqPM=; b=UVuJOcHpmkmYuvLZqMLDOdvfU5YFRFCQ9374ZcAu5qheKmbINdwVQ5S/OGom+seOVv tf8fwq2uobrSNsxd9oD9CXCKjTwey/RNnIF0yTc+8mBD10ity4tuv6lqWXedqcSSSL0t TNs7OfZ0olhmMHnvgEykm81KfF9ZJvha+npn4jYT8dAYob8PkwtdU0XpRVqOGa1c4qyI CZC8TqCTAvE4bVh55Kwbv95qeK0akoWlT9GFQEwr+7AsjGwrzl7VzHgJ7WhxzI6Bvmqq H4ozFWnIjeRSr8DfT5ombXe4e9QZ5l2ca7ZH4DGWdWNVzBmqxvEola0IrHEgDQPE5Ja4 f1wQ== X-Gm-Message-State: AKS2vOzPCp1ubtypMNf/FM9RiUj/9BDu7YBOVZkGMpixPKUc2W85kXh7 dVPg/WkIsniUmalxeMrH+Q== X-Received: by 10.28.68.139 with SMTP id r133mr10748460wma.90.1498724344879; Thu, 29 Jun 2017 01:19:04 -0700 (PDT) Received: from localhost.localdomain ([196.90.227.203]) by smtp.gmail.com with ESMTPSA id p34sm5268190wrc.66.2017.06.29.01.19.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Jun 2017 01:19:04 -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 2/7] arm: efi: remove pointless dummy .reloc section Date: Thu, 29 Jun 2017 08:18:44 +0000 Message-Id: <20170629081849.15081-3-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 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 4169b900d9d4..309d6198d335 100644 --- a/arch/arm/boot/compressed/efi-header.S +++ b/arch/arm/boot/compressed/efi-header.S @@ -41,7 +41,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 @@ -96,22 +96,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 Thu Jun 29 08:18: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: 106616 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp818403qge; Thu, 29 Jun 2017 01:19:11 -0700 (PDT) X-Received: by 10.84.229.6 with SMTP id b6mr16299563plk.247.1498724351194; Thu, 29 Jun 2017 01:19:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498724351; cv=none; d=google.com; s=arc-20160816; b=IYvE2h3rRqa1icSeDn1f4U/FOumXP9eOe8zjjyHK7gRDV1YqoxwNKaWAKNYif0qFv/ cc/cZrTn52FukJSAWcrfMKH6HJNA4p9lGixQ59c+CE7GoN/UOkA4Z9hUX1SLF93i+May Sqno/iuCXHo+68VPXTD0DXmjrjgWg8LmiQc/O+aN0GqKOveOUBs+JFyFpgldFOkj6nlI st/ZHPmBMJC7FcOQBkKE+Hvya0RiJ1p//KK9OvJA0cKFgiP9WtiSLPzyAL7gTuILRa2O /7MiZ52QQPOOHDDG8JU3aPdwFWgA0S/1cBFQzP5/y01MyyhlAT1R2y2kEDe8rmHoLKGb nBsA== 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=zPi9WsjqgHcILakwHSb0NNe8qqXQAV/gistDq6Tj0Fw=; b=GwhThz/yOY7nLZoX+n/lIFPUrHlsHRTD+r+JBfVho2mYxVBY+ITjJ6gAlaxwP1dfik I4ztavnVGwY80729c4iixF9OnqLLTeg5K6tFeeweAna6XJqv1Z6aZt7zDvJ+ZIr60Deu kPmD0vcLtd6jAog0Prp2Z/9Qeg90SP/KQPsB29Atck03agLJ3+EG4zebmk5vKNHNAPYb 0X5MXQQNfS6mSlMoKAi1UZ+6TbEL8Pf5g8xOj6bS4tnjVaivlaSFH0N6RUn8UHu5hMHC slKHlCiumC3yj/+IYlJ0OBMztCe2ZW5q6me3CS2I6qCOjaKNc4zRAGknAG0MGZHd7l+7 ixGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=KmKQ64Lp; 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.11; Thu, 29 Jun 2017 01:19:11 -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=KmKQ64Lp; 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 S1752136AbdF2ITK (ORCPT + 2 others); Thu, 29 Jun 2017 04:19:10 -0400 Received: from mail-wm0-f46.google.com ([74.125.82.46]:33648 "EHLO mail-wm0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752042AbdF2ITJ (ORCPT ); Thu, 29 Jun 2017 04:19:09 -0400 Received: by mail-wm0-f46.google.com with SMTP id z75so17103157wmc.0 for ; Thu, 29 Jun 2017 01:19:08 -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=UTotW9m3hFPe7MpTkPP7AjLCU6Xa5uOB+VsczY3WayE=; b=KmKQ64Lp+37COIxRGIwqhyDLSqS3kACo/ziAhjWQW8wDUfl96PCuqNLAuHXX4hj/PS KVdlgiEsYSa/pb/pRJpSUHGeDQnXfezM4W14K3u6Sbfep/6XqLbaM1/Qvexx8vZrIJPF Q4XI1bsU3qzOcU68dOjbyMtFSax9f+1vMVrCY= 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=UTotW9m3hFPe7MpTkPP7AjLCU6Xa5uOB+VsczY3WayE=; b=Wj5i2Wyq2lmqnTC02fs054m+7ndvCZpyAlg1ddG2zzVjT96dmAKJwwat6ejFpiJZ5p cEoQcAXK3kQlRg+dBh3ug6iRcbRxf51Fl1Y832wM7DPg4n86hJ+RjhIc7sYJ7BZYz1x8 XOIJ1ckeQ4lrJz0y5qLGU33lfu78nbedfX8ca+hAhwtFI1teu1zISK59Gax5EfVWbPv0 7CcsTxlGdOWkykrq4wt7YGEcqIzQhUmJY5ZUJQjcVjHqhyo+cOwuTncvj7+dRBePTxoi hI2DFtlBGbG/SlKDz7oyl3nBKIO5yP8emZO/ekQvI3Qmxzp3y6mUSkySaxFGbSmU8MR0 DnMA== X-Gm-Message-State: AKS2vOx9VvAgIFh/QgD2hZ95G0o8FyOeCoPCNpr/Fbh2E86SzYw9ZUmB F/Nd48UI9+2YYxWEdajwew== X-Received: by 10.28.12.2 with SMTP id 2mr9849795wmm.39.1498724347256; Thu, 29 Jun 2017 01:19:07 -0700 (PDT) Received: from localhost.localdomain ([196.90.227.203]) by smtp.gmail.com with ESMTPSA id p34sm5268190wrc.66.2017.06.29.01.19.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Jun 2017 01:19:06 -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 3/7] arm: efi: replace open coded constants with symbolic ones Date: Thu, 29 Jun 2017 08:18:45 +0000 Message-Id: <20170629081849.15081-4-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 Replace the various open coded constants in the EFI PE/COFF header with definitions from pe.h, or expressions based on local symbols. Signed-off-by: Ard Biesheuvel --- arch/arm/boot/compressed/efi-header.S | 128 ++++++++++---------- 1 file changed, 67 insertions(+), 61 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 309d6198d335..542e1ad432ae 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,6 +8,9 @@ * published by the Free Software Foundation. */ +#include +#include + .macro __nop #ifdef CONFIG_EFI_STUB @ This is almost but not quite a NOP, since it does clobber the @@ -15,7 +18,7 @@ @ 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 + .inst MZ_MAGIC | (0x1310 << 16) @ tstne r0, #0x4d000 #else AR_CLASS( mov r0, r0 ) M_CLASS( nop.w ) @@ -34,78 +37,81 @@ @ 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. + .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 + .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 __efi_start: From patchwork Thu Jun 29 08:18: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: 106617 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp818418qge; Thu, 29 Jun 2017 01:19:12 -0700 (PDT) X-Received: by 10.84.218.197 with SMTP id g5mr16159170plm.67.1498724352232; Thu, 29 Jun 2017 01:19:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498724352; cv=none; d=google.com; s=arc-20160816; b=hAaere0eemMupR2JcN7xrceBTCExifqL8T7JFK68y83/VwgdOZgdzw6kuv6M+Nx7MF AUiOq5OrigD7QzyTJGinKRwXeoq3fi6zwE82H4JK6l/bww5V6wqDB2Vphb1f/l6VEXCv 4plUABC4D86E9i7jC7/+951k1znbvCT4QfzjCCuJk5r54BEzmHH40c/enq1LXkQ6UbnA WWrmJPQO4ILYm5V8mjqM60LgC4PYODvCXXfrAAgI5wfj3+k0GjBWRbjquD/oEtLEDgGB goz7zKQm+vQ+dEyxdGI50R7I7XD1t+im82rhPvaudyod0kiPe2nTLeGtd9T1XkTCskI1 dtww== 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=KRHI623eSB/vYq/pENq28SnzeKpWtuLKR32mPdhvXEc=; b=kmAjDabXpZLMAABraWwIEI3XP6f497/VqMkG3isXwR1pcoV+wPO50EyrzR3IZ9DQw1 3BFS8yUjpIt//Y9XduSWwzSelBNHq+84BW5gi30uiWWZvmKQqA0fGCKVRzqsf3ZOm69r A4ZMYiB+6ZPKmWtUtgAwQCnOwNzVUsu+jdtIFltCGEy74JS2i18eF+ykRViaLv9OQ3IB bcdrYgKWLy6ou/Sowwfmsr3tlKAlweaD1UAf2CKhoM3/BXE2n9LwyxNXIiPBd+7wkujr E9WAEhKYNNwsGCwURxtjJwmHTp7ntMcWOlj8nH7kgUzcabsWB0IcsxKW2XqyMTjcmKI+ uvbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=iB89xh8i; 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.12; Thu, 29 Jun 2017 01:19:12 -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=iB89xh8i; 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 S1752042AbdF2ITL (ORCPT + 2 others); Thu, 29 Jun 2017 04:19:11 -0400 Received: from mail-wr0-f177.google.com ([209.85.128.177]:35445 "EHLO mail-wr0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751894AbdF2ITK (ORCPT ); Thu, 29 Jun 2017 04:19:10 -0400 Received: by mail-wr0-f177.google.com with SMTP id k67so184864173wrc.2 for ; Thu, 29 Jun 2017 01:19: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=rBOHK/2kmfkrLftRAiAm6/S6MMa8WvDJnUABhBL7unQ=; b=iB89xh8iZX8SNcErXbwsaVAc9otqFSXWPA0pnwBRHOlaUC68KZI9eGuHrZbPoX9OyZ xzHqTv7nSCFUKoLJ2Bptc2MmgtuT97AzOEQMtlhbD1+ed8mmQBf9h8tpRhT85EcjEAhI S4XxGlW3Rfu697v7b23WqV1OP2QjTKiNZbrAs= 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=rBOHK/2kmfkrLftRAiAm6/S6MMa8WvDJnUABhBL7unQ=; b=MRui5oSeeA14tDK3ojcH5m6xdiqUxejNMVwMhr01DwH/SPqrhqa4BL/ksIsc4QS9JV YCHNHNCmIr70khzdJLDoyaNeBIWCQcgO9FqXnIz3IT/TMAyFWhl4dHUzd7FUbzFpQ6Ok R6wRV0C2lzhwNZSBaXlakMgk/4zHVZlCMHSAei3+dOxwoiHSvINnpypZHwNyOm6whzaC Mgcu+5OUe32yz2iMwMnppeIM7Y2d048HQ0HeDHlmc2Ew+olLS1Y5ji62rygkazVtDOfB q10wIo6L+eYvs7Fp4xMPHazfXyzn4PD44D1IMouhHVeM3xamS9/Hpeew+Jy3ITgdh3C7 OYQA== X-Gm-Message-State: AKS2vOyvtVMmx0Z9EpF4eiI2KJ3b9k3TsP7kmSAjNmPLj9eMOJ2bheG7 KVtTeO//ab3b9ZZABjcbfw== X-Received: by 10.223.148.226 with SMTP id 89mr23178002wrr.169.1498724348996; Thu, 29 Jun 2017 01:19:08 -0700 (PDT) Received: from localhost.localdomain ([196.90.227.203]) by smtp.gmail.com with ESMTPSA id p34sm5268190wrc.66.2017.06.29.01.19.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Jun 2017 01:19:08 -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 4/7] arm: compressed: discard ksymtab/kcrctab sections Date: Thu, 29 Jun 2017 08:18:46 +0000 Message-Id: <20170629081849.15081-5-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 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. Cc: Russell King 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 Thu Jun 29 08:18: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: 106618 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp818444qge; Thu, 29 Jun 2017 01:19:14 -0700 (PDT) X-Received: by 10.99.165.28 with SMTP id n28mr14397283pgf.163.1498724354335; Thu, 29 Jun 2017 01:19:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498724354; cv=none; d=google.com; s=arc-20160816; b=Y2XgmBCNIJgEg3B0zIUOiGsVz+RzxkSohehhzTN1fd6UPmebTNHeacOmcj2wnnyygC 4+WTSOzd9aO9EJ0by7b+Fj2cu8bceu4CuP+Z/MqIe7Hgw5czKyXzbPVmTlwvh1YurI68 8J/rhg75VsPusUGGw45OAu4LCMAylp5VRypyWWJfdNHPDy2hiSsbUcNooQPNE7FInoLg ocqo6egq9KAeQQsHbVGFECSpyi9WPwYtqcd7EIMc6q5eCmbEUAmBzDUBxbvugYAItvA4 EdjwCncKJ+Sos/Y2BhwrxTrjIHsZ1tGRX0GFRdg6Gn/PJg/mNeSNvzNyiSBCJd9P7QN9 B4ig== 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=300BPPqbjjuYis0JelbMHLzC+dwmISgjtEdpql+yasc=; b=GJ7eyMU0wLQMnhDdaIZZntZYusTYOlUFmeCaokCf05EIEuVe68SzEodETZDLJGtZMf Nri9u7U6hNEl7u6IsClWEabg7ppFVHZESwbJA/mroWF/SY907ZTEtmqdJl5J36rLG8vT +W0JHv5J819wkiM0z5KFVbAlXHfG9vvRYR5X43ZZSKM1SDUcyXZDctB56oL5KGwojcif H5AZA5Z1dgqQmiVaIk2mVfwq4E42vaey7gMKxqULlyB/QcSKpTPkF9mD/FNHCf1Oo10W hTmgmN1z45yKzJRddp4+ep+Ip0ysB3lsODnDM8EeInXQ174LW3Ky0zsgacpzNfMtdBHN O+Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=c3WYGPnL; 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.14; Thu, 29 Jun 2017 01:19:14 -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=c3WYGPnL; 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 S1751986AbdF2ITN (ORCPT + 2 others); Thu, 29 Jun 2017 04:19:13 -0400 Received: from mail-wm0-f45.google.com ([74.125.82.45]:35938 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752462AbdF2ITM (ORCPT ); Thu, 29 Jun 2017 04:19:12 -0400 Received: by mail-wm0-f45.google.com with SMTP id 62so74837949wmw.1 for ; Thu, 29 Jun 2017 01:19:11 -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=fIGRZsUd+gDQXkO06FSHbXqFTO9GpZ0vqMT0AVtvOjc=; b=c3WYGPnLTfEL0AvnbVmExohylhK3L98Prh12OK5k0va98F5zZ71ulLjyJ5jlMf8m/H rpNk3tHiaG7Ujn+7gJYZyIcGHdqLGqlyxIV12f19M/84JWMtKA3hLAaU962axOSjqcaz fAp3IL9fuAYSPdRfeZIP+GendsTK4W5eQJc4k= 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=fIGRZsUd+gDQXkO06FSHbXqFTO9GpZ0vqMT0AVtvOjc=; b=Y7ovmNCXxQnb6TcWZLS6gO+c2+/GNioDDS5+0uPfXy6Mg+sGQ++dTeh7RvMgltQIvR NrAZeLlg7TE6Ov9b6ExC0JvUioGnF3uKMIbAG35yt2R0QB1ccpsvDtldGvWW+lAPQtu+ jbSe6Mj8jRzI2Pemdlc1E1i/tq5wnbHR/ypowylOq9ogQlRoxBKzbl7cAnyvx6RAG5+k euM6wDUJ9PgY0+855u0Kcfi1YEUJX7a+9Pw6plXi54CfCWSf77AZQT4wMZpDB3QO3DuG CCdtJq4Cp+AYkU2L52e/7WZv/+CGxAp3dlyzjeev8IkdAB1twji2MA6nPu/1aklay/sx fkOA== X-Gm-Message-State: AKS2vOyJD/IJMeUnLRMgzmEvRd8bufCLk+mHxtur2DdIWpOlrbR40C1u mSdx0pGzDuDSfsnTQdIm4g== X-Received: by 10.28.93.197 with SMTP id r188mr10032069wmb.44.1498724350781; Thu, 29 Jun 2017 01:19:10 -0700 (PDT) Received: from localhost.localdomain ([196.90.227.203]) by smtp.gmail.com with ESMTPSA id p34sm5268190wrc.66.2017.06.29.01.19.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Jun 2017 01:19:10 -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 5/7] arm: efi: split zImage code and data into separate PE/COFF sections Date: Thu, 29 Jun 2017 08:18:47 +0000 Message-Id: <20170629081849.15081-6-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 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. Cc: Russell King Signed-off-by: Ard Biesheuvel --- arch/arm/boot/compressed/efi-header.S | 32 ++++++++++++++------ arch/arm/boot/compressed/vmlinux.lds.S | 30 +++++++++++++----- 2 files changed, 46 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 Tested-by: Gregory CLEMENT diff --git a/arch/arm/boot/compressed/efi-header.S b/arch/arm/boot/compressed/efi-header.S index 542e1ad432ae..c94a88ae834d 100644 --- a/arch/arm/boot/compressed/efi-header.S +++ b/arch/arm/boot/compressed/efi-header.S @@ -54,20 +54,22 @@ coff_header: IMAGE_FILE_EXECUTABLE_IMAGE | \ IMAGE_FILE_LINE_NUMS_STRIPPED @ Characteristics +#define __pecoff_code_size (__pecoff_data_start - __efi_start) + 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_code_size @ 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 @@ -77,7 +79,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 @@ -98,9 +100,9 @@ extra_header_fields: section_table: .ascii ".text\0\0\0" - .long _end - __efi_start @ VirtualSize + .long __pecoff_code_size @ VirtualSize .long __efi_start @ VirtualAddress - .long _edata - __efi_start @ SizeOfRawData + .long __pecoff_code_size @ SizeOfRawData .long __efi_start @ PointerToRawData .long 0 @ PointerToRelocations .long 0 @ PointerToLineNumbers @@ -108,12 +110,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 Thu Jun 29 08:18:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 106619 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp818459qge; Thu, 29 Jun 2017 01:19:15 -0700 (PDT) X-Received: by 10.98.76.83 with SMTP id z80mr15205745pfa.87.1498724355606; Thu, 29 Jun 2017 01:19:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498724355; cv=none; d=google.com; s=arc-20160816; b=IwcvMAzPtNl5l8/aWqKHhpdjqlLR/W2E4TpghnJAKYQf5jc2kdmhwD3wZK+3ACCIMg DAy6MrFzxy27By3PaEKVhkUFOWCGUrlg0JWvQn01kW43F/dZnP/ZuD5FbBqhpAhfumnh CkRwFH106zhCbs5mWj8al3cdtOWRNCelGZz2I/TNmDB4ZjWqZDv76K4BYp2d5QNcIvSQ 9JRu9vQgLCXx0SdtHYTQ3Cx9bBf7fBCo4VsJdN2mn7s+QZmVR80TyWFyCCYfl78DtpDs rP4RHejKlVy59wi1KrVK+YIQxFg2WklRZg6gbSw581bpufVu4l6roWyhr1rFHT6N6gDY UoGQ== 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=39aWweblYX21LZPps1KRPlpAJ/qSlA0J6kNhQtqCGUs=; b=c48MMW/Q1xmjmCbvihCpZgXixT6nsqr8wjw1oUc4tqxJTKm3df2nbQ9coLG4glKV+4 UIe562x/t2g7f/PU8i1yRCBQaa4gMvKhOn7jvJcGaVJTmS1ZR2sPR1girc3y7PsTze4r JHORZgOwQUfBnfCwLaJ+dpP6jq0rxXrEHjdUM2I/VB7CM521Y3tOttb9xqM6dqoicL4V lcDN1g/zmsEM6ZS+MrF8Q6RsWwRu3PHTUFB/G3AxaL5JyhzMwAtKEfrhiIr3C2R7bs95 kjwuztStcX1hW9k/ThugAfrsG7UxorNB53Zp3QfyCzrSby6NaHftKiIt/vohegyY0UEA r3CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=IOtfrXI4; 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.15; Thu, 29 Jun 2017 01:19:15 -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=IOtfrXI4; 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 S1752128AbdF2ITP (ORCPT + 2 others); Thu, 29 Jun 2017 04:19:15 -0400 Received: from mail-wm0-f50.google.com ([74.125.82.50]:37397 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751894AbdF2ITO (ORCPT ); Thu, 29 Jun 2017 04:19:14 -0400 Received: by mail-wm0-f50.google.com with SMTP id i127so5845237wma.0 for ; Thu, 29 Jun 2017 01:19: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=MRqzlXx11IU9ovdc7P+x3NKMzzretObdsgiTBFPBceM=; b=IOtfrXI4Bjr9nvdFXoNP7qh390YA7byTz3GkC8BZODl3FIBza4pMcJWNJ0+Jd1wZfT 3bc77nDRCm+K12FPyszIo/GW5cr/6FD7CWEShvYbhSOsd43cA5k+eCLACAX3I85Fhrd2 1NDpWrRfkuCkEXUFINhZxxmJZaJukcSABxlls= 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=MRqzlXx11IU9ovdc7P+x3NKMzzretObdsgiTBFPBceM=; b=JlpwfI1PjaZwIBCHi8PThyCMP3d7OEfsdSDjU78/q4Yc6F+1p5DUZOKoqkqv7LZ7dn 65VDa7qJ/iwnPNy2I0Qs83zc5WcnYwDuxWotGwtA3j6YgEjHoQiF8TRKs5DEqj037Cki hy0ZNZs9S0LP1UVoXhZvQUgJ48SX6mEY/Q7Hc65HF3sQAxJ2nlbB3rgaan/jXtW4qbyo zuaT2VXyzYL1rQMHNl+bp8iCgIEMHp3wy587Eb4j7+NQbHCmEGweWMyhzjB3OM7QvuoK UGcO52WLfjg5Nqcp4apkBDFEe5K6q1Fx663aAfUOyjKi+RJoGlglLS/cO+avv7ljv7CU 4Hmw== X-Gm-Message-State: AKS2vOzFlVLRLaL4Xz/lJjBy6UvypY27F2W/JZtKQ0DZq/u68ZuaHBu1 6IOMGoWoDOcH1+5xS+HY7A== X-Received: by 10.28.134.11 with SMTP id i11mr9380475wmd.77.1498724352597; Thu, 29 Jun 2017 01:19:12 -0700 (PDT) Received: from localhost.localdomain ([196.90.227.203]) by smtp.gmail.com with ESMTPSA id p34sm5268190wrc.66.2017.06.29.01.19.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Jun 2017 01:19:11 -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 6/7] arm: compressed: put zImage header and EFI header in dedicated section Date: Thu, 29 Jun 2017 08:18:48 +0000 Message-Id: <20170629081849.15081-7-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 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. Cc: Russell King 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 c94a88ae834d..a14516f7a27e 100644 --- a/arch/arm/boot/compressed/efi-header.S +++ b/arch/arm/boot/compressed/efi-header.S @@ -129,5 +129,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 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