lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1427096800-30452-5-git-send-email-james.t.kukunas@linux.intel.com>
Date:	Mon, 23 Mar 2015 00:46:33 -0700
From:	Jim Kukunas <james.t.kukunas@...ux.intel.com>
To:	Linux Kernel <linux-kernel@...r.kernel.org>,
	tom.zanussi@...ux.intel.com
Cc:	Arjan van de Ven <arjan@...ux.intel.com>,
	"H. Peter Anvin" <hpa@...or.com>, tglx@...utronix.de,
	mingo@...hat.com, x86@...nel.org
Subject: [PATCH 04/11] x86/xip: XIP boot trampoline page tables

Constructs the trampoline page tables for early XIP boot.

Signed-off-by: Jim Kukunas <james.t.kukunas@...ux.intel.com>
---
 arch/x86/kernel/head_32.S | 85 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)

diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
index 80f344a..642d73b 100644
--- a/arch/x86/kernel/head_32.S
+++ b/arch/x86/kernel/head_32.S
@@ -227,6 +227,90 @@ xip_data_cp:
 	movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
 #else	/* Not PAE */
 
+#ifdef CONFIG_XIP_KERNEL
+	movl $pa(__brk_base), %edi
+	movl $pa(initial_page_table), %edx
+
+	movl $PTE_IDENT_ATTR, %eax	/* EAX holds identity mapping addr */
+	movl $__PAGE_OFFSET + PTE_IDENT_ATTR, %ebx /* EBX holds kernel addr */
+
+.Lxip_mapping:
+/* Allocate or Load Identity PDE */
+	leal -PTE_IDENT_ATTR(%eax), %ebp
+	andl $0xFFC00000, %ebp
+	shrl $20, %ebp
+	movl (%edx, %ebp), %ecx
+
+	test %ecx, %ecx
+	jnz .Lskip_ident_pde_alloc
+	leal PDE_IDENT_ATTR(%edi), %ecx
+	addl $4096, %edi
+	movl %ecx, (%edx, %ebp)
+
+.Lskip_ident_pde_alloc:
+	leal -PDE_IDENT_ATTR(%ecx), %ecx
+	leal -PTE_IDENT_ATTR(%eax), %ebp
+	andl $0x3FF000, %ebp
+	shrl $10, %ebp
+	movl %eax, (%ecx, %ebp)
+
+/* Allocate or Load PAGE_OFFSET PDE */
+	leal -PTE_IDENT_ATTR(%ebx), %ebp
+	andl $0xFFC00000, %ebp
+	shrl $20, %ebp
+	movl (%edx, %ebp), %ecx
+
+	test %ecx, %ecx
+	jnz .Lskip_offset_pde_alloc
+	leal PDE_IDENT_ATTR(%edi), %ecx
+	addl $4096, %edi
+	movl %ecx, (%edx, %ebp)
+
+.Lskip_offset_pde_alloc:
+	leal -PDE_IDENT_ATTR(%ecx), %ecx
+	leal -PTE_IDENT_ATTR(%ebx), %ebp
+	andl $0x3FF000, %ebp
+	shrl $10, %ebp
+	movl %eax, (%ecx, %ebp)
+
+	addl $4096, %eax
+	addl $4096, %ebx
+
+	cmpl $CONFIG_PHYSICAL_START + PTE_IDENT_ATTR, %eax
+	je   .Lsetup_text_addr
+
+	cmpl $phys_sdata + PTE_IDENT_ATTR, %eax
+	je   .Lsetup_data_addr
+
+	cmpl $pa(_end) + MAPPING_BEYOND_END + PTE_IDENT_ATTR, %eax
+	je   .Ldone
+
+	jmp  .Lxip_mapping
+
+.Lsetup_text_addr:
+	movl $CONFIG_XIP_BASE + 4096 + PTE_IDENT_ATTR, %eax
+	movl $_text, %ebx
+	addl $PTE_IDENT_ATTR, %ebx
+	jmp  .Lxip_mapping
+
+.Lsetup_data_addr:
+	movl $pa(_sdata), %eax
+	addl $PTE_IDENT_ATTR, %eax
+	movl $_sdata, %ebx
+	addl $PTE_IDENT_ATTR, %ebx
+	jmp  .Lxip_mapping
+.Ldone:
+	addl $__PAGE_OFFSET, %edi
+	movl %edi, pa(_brk_end)
+	movl $pa(_end) + MAPPING_BEYOND_END + PTE_IDENT_ATTR, %eax
+	shrl $12, %eax
+	movl %eax, pa(max_pfn_mapped)
+
+	movl $pa(initial_pg_fixmap) + PTE_IDENT_ATTR, %eax
+	movl %eax, pa(initial_page_table + 0xFFC)
+
+#else
+
 page_pde_offset = (__PAGE_OFFSET >> 20);
 
 	movl $pa(__brk_base), %edi
@@ -257,6 +341,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
 	movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
 	movl %eax,pa(initial_page_table+0xffc)
 #endif
+#endif
 
 #ifdef CONFIG_PARAVIRT
 	/* This is can only trip for a broken bootloader... */
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ