From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752501AbbCWH56 (ORCPT ); Mon, 23 Mar 2015 03:57:58 -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 S1751935AbbCWHzJ (ORCPT ); Mon, 23 Mar 2015 03:55:09 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,450,1422950400"; d="scan'208";a="544809133" 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 03/11] x86/xip: copy writable sections into RAM Date: Mon, 23 Mar 2015 00:46:32 -0700 Message-Id: <1427096800-30452-4-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 Loads all writable and non-zero sections into their VMA. Signed-off-by: Jim Kukunas --- arch/x86/include/asm/sections.h | 4 ++++ arch/x86/kernel/head_32.S | 22 ++++++++++++++++++++++ arch/x86/kernel/vmlinux.lds.S | 4 ++++ 3 files changed, 30 insertions(+) diff --git a/arch/x86/include/asm/sections.h b/arch/x86/include/asm/sections.h index 0a52424..9535e95 100644 --- a/arch/x86/include/asm/sections.h +++ b/arch/x86/include/asm/sections.h @@ -11,4 +11,8 @@ extern struct exception_table_entry __stop___ex_table[]; extern char __end_rodata_hpage_align[]; #endif +#ifdef CONFIG_XIP_KERNEL +extern char phys_sdata[]; +#endif + #endif /* _ASM_X86_SECTIONS_H */ diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S index f36bd42..80f344a 100644 --- a/arch/x86/kernel/head_32.S +++ b/arch/x86/kernel/head_32.S @@ -86,6 +86,28 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE) */ __HEAD ENTRY(startup_32) + +#ifdef CONFIG_XIP_KERNEL + /* + * Copy writable sections into RAM + */ + + movl %esi, %ebp # Preserve pointer to zero-page + + leal pa(_sdata), %edi + leal phys_edata, %ecx + leal phys_sdata, %esi + subl %esi, %ecx + + cld +xip_data_cp: + lodsb + stosb + loop xip_data_cp + + movl %ebp, %esi +#endif + movl pa(stack_start),%ecx /* test KEEP_SEGMENTS flag to see if the bootloader is asking diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S index 414a1ac..59a9edb 100644 --- a/arch/x86/kernel/vmlinux.lds.S +++ b/arch/x86/kernel/vmlinux.lds.S @@ -133,6 +133,9 @@ SECTIONS RO_DATA(PAGE_SIZE) X64_ALIGN_DEBUG_RODATA_END + phys_sdata = LOADADDR(.data); + phys_edata = phys_sdata + (_end_nonzero - _sdata); + /* Data */ .data : AT(ADDR(.data) - LOAD_OFFSET) DATA_ALIGN { /* Start of data section */ @@ -319,6 +322,7 @@ SECTIONS NOSAVE_DATA } #endif + _end_nonzero = .; /* BSS */ . = ALIGN(PAGE_SIZE); -- 2.1.0