From patchwork Wed Feb 8 11:55:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 93619 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2649284qgi; Wed, 8 Feb 2017 04:06:07 -0800 (PST) X-Received: by 10.84.136.75 with SMTP id 69mr33947442plk.172.1486555567010; Wed, 08 Feb 2017 04:06:07 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e5si6944883pgg.25.2017.02.08.04.06.06; Wed, 08 Feb 2017 04:06:07 -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 S932748AbdBHMFb (ORCPT + 2 others); Wed, 8 Feb 2017 07:05:31 -0500 Received: from mail-wr0-f177.google.com ([209.85.128.177]:33052 "EHLO mail-wr0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754111AbdBHMET (ORCPT ); Wed, 8 Feb 2017 07:04:19 -0500 Received: by mail-wr0-f177.google.com with SMTP id i10so59292525wrb.0 for ; Wed, 08 Feb 2017 04:04:16 -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=0cK7+Ar28vcoVuW/0Wuc/om69UhlFVxMa0GtSvxNHl0=; b=Ye7p26xVb9HSbT+TmLocgUr7EaVCiqcaRf1jmc6Nd9kjLeL+uu0PV3SuBHMhLTw+8b grKZPUc+aGi5wH2shGeVYkdfRhsrDctHiVkKpjE+bbmxYwDqGx+JEwd+nNhvLnwin9FQ 8fDmNeU75vcSluh0VnO5S9b+st64QlUpIuaWM= 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=0cK7+Ar28vcoVuW/0Wuc/om69UhlFVxMa0GtSvxNHl0=; b=C6HIja6wI9vIz9N/A8NZ8C3fH1q4GoNT8YioZLhvxc3AIHgJGzdq3Z6mo5yNCvnhzu btguiSBFAQoUIQdYyjBwjaTVsL9Y9hFs05gYSrS0fCDWDBx8TCIcKK7sv/7lxlLyaEsK lg1SLgt9Fuh+kDDJJSfe9dkgWFN5MYsvRJI22oVhQ8n27gUSf1hHTfA3OdMueINianpN 3+wdil64NSqB9fjTLX3IMvVptClmwxjqYgGMEQfvfqCtR1bwnZjIvjENOHmTx5EuVVXx CSH+KmplkWnkhfwFKjPmTraphNIBmHiJNY/Rgw0W4GNAx4Bw8Vr3oBCjeI2oxx+kUPwG j1JQ== X-Gm-Message-State: AIkVDXJNK0cpuqOT0gZ8eLijQX9pnrb9Pb8ZKX4gdfAAm9iBIcLX3wTSkb0RjG4/2fz90ity X-Received: by 10.223.154.114 with SMTP id z105mr18662738wrb.89.1486554981376; Wed, 08 Feb 2017 03:56:21 -0800 (PST) Received: from localhost.localdomain ([160.169.163.122]) by smtp.gmail.com with ESMTPSA id 123sm2974815wml.6.2017.02.08.03.56.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Feb 2017 03:56:20 -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 07/14] arm64: efi: replace open coded constants with symbolic ones Date: Wed, 8 Feb 2017 11:55:40 +0000 Message-Id: <1486554947-3964-8-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 Replace open coded constants with symbolic ones throughout the Image and the EFI headers. No binary level changes are intended. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/efi-header.S | 38 +++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) -- 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 Acked-by: Mark Rutland diff --git a/arch/arm64/kernel/efi-header.S b/arch/arm64/kernel/efi-header.S index 8786d58af2df..7637226ea9ca 100644 --- a/arch/arm64/kernel/efi-header.S +++ b/arch/arm64/kernel/efi-header.S @@ -7,22 +7,24 @@ * published by the Free Software Foundation. */ +#include +#include + .macro __EFI_PE_HEADER - .ascii "PE" - .short 0 + .long PE_MAGIC coff_header: - .short 0xaa64 // AArch64 - .short 1 // nr_sections + .short IMAGE_FILE_MACHINE_ARM64 // Machine + .short section_count // NumberOfSections .long 0 // TimeDateStamp .long 0 // PointerToSymbolTable .long 0 // NumberOfSymbols .short section_table - optional_header // SizeOfOptionalHeader - .short 0x206 // Characteristics. - // IMAGE_FILE_DEBUG_STRIPPED | - // IMAGE_FILE_EXECUTABLE_IMAGE | - // IMAGE_FILE_LINE_NUMS_STRIPPED + .short IMAGE_FILE_DEBUG_STRIPPED | \ + IMAGE_FILE_EXECUTABLE_IMAGE | \ + IMAGE_FILE_LINE_NUMS_STRIPPED // Characteristics + optional_header: - .short 0x20b // PE32+ format + .short PE_OPT_MAGIC_PE32PLUS // PE32+ format .byte 0x02 // MajorLinkerVersion .byte 0x14 // MinorLinkerVersion .long _end - efi_header_end // SizeOfCode @@ -33,7 +35,7 @@ optional_header: extra_header_fields: .quad 0 // ImageBase - .long 0x1000 // SectionAlignment + .long SZ_4K // SectionAlignment .long PECOFF_FILE_ALIGNMENT // FileAlignment .short 0 // MajorOperatingSystemVersion .short 0 // MinorOperatingSystemVersion @@ -48,7 +50,7 @@ extra_header_fields: // Everything before the kernel image is considered part of the header .long efi_header_end - _head // SizeOfHeaders .long 0 // CheckSum - .short 0xa // Subsystem (EFI application) + .short IMAGE_SUBSYSTEM_EFI_APPLICATION // Subsystem .short 0 // DllCharacteristics .quad 0 // SizeOfStackReserve .quad 0 // SizeOfStackCommit @@ -71,10 +73,7 @@ extra_header_fields: // Section table section_table: - .ascii ".text" - .byte 0 - .byte 0 - .byte 0 // end of 0 padding of section name + .ascii ".text\0\0\0" .long _end - efi_header_end // VirtualSize .long efi_header_end - _head // VirtualAddress .long _edata - efi_header_end // SizeOfRawData @@ -84,7 +83,12 @@ section_table: .long 0 // PointerToLineNumbers .short 0 // NumberOfRelocations .short 0 // NumberOfLineNumbers - .long 0xe0000020 // Characteristics + .long IMAGE_SCN_CNT_CODE | \ + IMAGE_SCN_MEM_EXECUTE | \ + IMAGE_SCN_MEM_READ | \ + IMAGE_SCN_MEM_WRITE // Characteristics + + .set section_count, (. - section_table) / 40 #ifdef CONFIG_DEBUG_EFI /* @@ -106,7 +110,7 @@ efi_debug_table: .long 0 // TimeDateStamp .short 0 // MajorVersion .short 0 // MinorVersion - .long 2 // Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW + .long IMAGE_DEBUG_TYPE_CODEVIEW // Type .long efi_debug_entry_size // SizeOfData .long 0 // RVA .long efi_debug_entry - _head // FileOffset