From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752167AbbCWHzO (ORCPT ); Mon, 23 Mar 2015 03:55:14 -0400 Received: from mga11.intel.com ([192.55.52.93]:59190 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752066AbbCWHzI (ORCPT ); Mon, 23 Mar 2015 03:55:08 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,450,1422950400"; d="scan'208";a="544809132" From: Jim Kukunas To: Linux Kernel , tom.zanussi@linux.intel.com Cc: Arjan van de Ven , "H. Peter Anvin" , tglx@linutronix.de, mingo@redhat.com, x86@kernel.org Subject: [PATCH 02/11] x86/xip: Update address of sections in linker script Date: Mon, 23 Mar 2015 00:46:31 -0700 Message-Id: <1427096800-30452-3-git-send-email-james.t.kukunas@linux.intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1427096800-30452-1-git-send-email-james.t.kukunas@linux.intel.com> References: <1427096800-30452-1-git-send-email-james.t.kukunas@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to update the LMA for each section, according to CONFIG_XIP_BASE, this patch uses the preprocessor to change the arguments passed to the AT keyword. Each LMA is updated to that symbol's physical address. The text section is aligned to a page so that the ELF header at the beginning of XIP_BASE isn't mapped into the linear address space. Also the initial location counter is incremented to account for the ELF header. Signed-off-by: Jim Kukunas --- arch/x86/include/asm/boot.h | 4 ++++ arch/x86/kernel/vmlinux.lds.S | 17 +++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h index 4fa687a..a128c71 100644 --- a/arch/x86/include/asm/boot.h +++ b/arch/x86/include/asm/boot.h @@ -10,6 +10,10 @@ + (CONFIG_PHYSICAL_ALIGN - 1)) \ & ~(CONFIG_PHYSICAL_ALIGN - 1)) +#ifdef CONFIG_XIP_KERNEL +#define PHYS_XIP_OFFSET (CONFIG_XIP_BASE - (LOAD_OFFSET + LOAD_PHYSICAL_ADDR)) +#endif + /* Minimum kernel alignment, as a power of two */ #ifdef CONFIG_X86_64 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S index 00bf300..414a1ac 100644 --- a/arch/x86/kernel/vmlinux.lds.S +++ b/arch/x86/kernel/vmlinux.lds.S @@ -20,6 +20,15 @@ #define LOAD_OFFSET __START_KERNEL_map #endif +#ifdef CONFIG_XIP_KERNEL +#define AT(x) AT(x + LOAD_OFFSET + PHYS_XIP_OFFSET) +#define TEXT_ALIGN ALIGN(0x1000) +#define DATA_ALIGN ALIGN(0x200000) +#else +#define TEXT_ALIGN +#define DATA_ALIGN +#endif + #include #include #include @@ -89,8 +98,12 @@ SECTIONS phys_startup_64 = startup_64 - LOAD_OFFSET; #endif +#ifdef CONFIG_XIP_KERNEL + . += SIZEOF_HEADERS; +#endif + /* Text and read-only data */ - .text : AT(ADDR(.text) - LOAD_OFFSET) { + .text : AT(ADDR(.text) - LOAD_OFFSET) TEXT_ALIGN { _text = .; /* bootstrapping code */ HEAD_TEXT @@ -121,7 +134,7 @@ SECTIONS X64_ALIGN_DEBUG_RODATA_END /* Data */ - .data : AT(ADDR(.data) - LOAD_OFFSET) { + .data : AT(ADDR(.data) - LOAD_OFFSET) DATA_ALIGN { /* Start of data section */ _sdata = .; -- 2.1.0