[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-32fcefa2bfc8961987e91d1daeb00624b4176d2e@git.kernel.org>
Date: Mon, 12 Mar 2018 02:29:32 -0700
From: "tip-bot for Kirill A. Shutemov" <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: peterz@...radead.org, torvalds@...ux-foundation.org,
willy@...radead.org, jgross@...e.com, hpa@...or.com,
keescook@...omium.org, ebiederm@...ssion.com,
andy.shevchenko@...il.com, bp@...e.de, luto@...capital.net,
mingo@...nel.org, gorcunov@...nvz.org, tglx@...utronix.de,
linux-kernel@...r.kernel.org, kirill.shutemov@...ux.intel.com
Subject: [tip:x86/mm] x86/boot/compressed/64: Set up trampoline memory
Commit-ID: 32fcefa2bfc8961987e91d1daeb00624b4176d2e
Gitweb: https://git.kernel.org/tip/32fcefa2bfc8961987e91d1daeb00624b4176d2e
Author: Kirill A. Shutemov <kirill.shutemov@...ux.intel.com>
AuthorDate: Mon, 26 Feb 2018 21:04:50 +0300
Committer: Ingo Molnar <mingo@...nel.org>
CommitDate: Mon, 12 Mar 2018 09:37:25 +0100
x86/boot/compressed/64: Set up trampoline memory
This patch clears up trampoline memory and copies trampoline code in
place. It's not yet used though.
Tested-by: Borislav Petkov <bp@...e.de>
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@...ux.intel.com>
Cc: Andy Lutomirski <luto@...capital.net>
Cc: Andy Shevchenko <andy.shevchenko@...il.com>
Cc: Cyrill Gorcunov <gorcunov@...nvz.org>
Cc: Eric Biederman <ebiederm@...ssion.com>
Cc: H. Peter Anvin <hpa@...or.com>
Cc: Juergen Gross <jgross@...e.com>
Cc: Kees Cook <keescook@...omium.org>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Matthew Wilcox <willy@...radead.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: linux-mm@...ck.org
Link: http://lkml.kernel.org/r/20180226180451.86788-5-kirill.shutemov@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
arch/x86/boot/compressed/head_64.S | 3 ++-
arch/x86/boot/compressed/pgtable.h | 9 +++++++++
arch/x86/boot/compressed/pgtable_64.c | 7 +++++++
3 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
index 8ba0582c65d5..c813cb004056 100644
--- a/arch/x86/boot/compressed/head_64.S
+++ b/arch/x86/boot/compressed/head_64.S
@@ -501,8 +501,9 @@ relocated:
jmp *%rax
.code32
+ENTRY(trampoline_32bit_src)
compatible_mode:
- /* Setup data and stack segments */
+ /* Set up data and stack segments */
movl $__KERNEL_DS, %eax
movl %eax, %ds
movl %eax, %ss
diff --git a/arch/x86/boot/compressed/pgtable.h b/arch/x86/boot/compressed/pgtable.h
index 57722a2fe2a0..91f75638f6e6 100644
--- a/arch/x86/boot/compressed/pgtable.h
+++ b/arch/x86/boot/compressed/pgtable.h
@@ -3,9 +3,18 @@
#define TRAMPOLINE_32BIT_SIZE (2 * PAGE_SIZE)
+#define TRAMPOLINE_32BIT_PGTABLE_OFFSET 0
+
+#define TRAMPOLINE_32BIT_CODE_OFFSET PAGE_SIZE
+#define TRAMPOLINE_32BIT_CODE_SIZE 0x60
+
+#define TRAMPOLINE_32BIT_STACK_END TRAMPOLINE_32BIT_SIZE
+
#ifndef __ASSEMBLER__
extern unsigned long *trampoline_32bit;
+extern void trampoline_32bit_src(void *return_ptr);
+
#endif /* __ASSEMBLER__ */
#endif /* BOOT_COMPRESSED_PAGETABLE_H */
diff --git a/arch/x86/boot/compressed/pgtable_64.c b/arch/x86/boot/compressed/pgtable_64.c
index 01d08d3e3e43..810c2c32d98e 100644
--- a/arch/x86/boot/compressed/pgtable_64.c
+++ b/arch/x86/boot/compressed/pgtable_64.c
@@ -76,6 +76,13 @@ struct paging_config paging_prepare(void)
/* Preserve trampoline memory */
memcpy(trampoline_save, trampoline_32bit, TRAMPOLINE_32BIT_SIZE);
+ /* Clear trampoline memory first */
+ memset(trampoline_32bit, 0, TRAMPOLINE_32BIT_SIZE);
+
+ /* Copy trampoline code in place */
+ memcpy(trampoline_32bit + TRAMPOLINE_32BIT_CODE_OFFSET / sizeof(unsigned long),
+ &trampoline_32bit_src, TRAMPOLINE_32BIT_CODE_SIZE);
+
return paging_config;
}
Powered by blists - more mailing lists