]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
x86/boot/compressed/64: Set up trampoline memory
authorKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Mon, 26 Feb 2018 18:04:50 +0000 (21:04 +0300)
committerIngo Molnar <mingo@kernel.org>
Mon, 12 Mar 2018 08:37:25 +0000 (09:37 +0100)
This patch clears up trampoline memory and copies trampoline code in
place. It's not yet used though.

Tested-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/20180226180451.86788-5-kirill.shutemov@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/boot/compressed/head_64.S
arch/x86/boot/compressed/pgtable.h
arch/x86/boot/compressed/pgtable_64.c

index 8ba0582c65d5d56d5a10c8fb441ba4355f80e3f2..c813cb004056ca170e51a7968b24310f5e214fce 100644 (file)
@@ -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
index 57722a2fe2a0eab0e9cfe95f1f8d61aa48c74091..91f75638f6e68ef5df8da5f428fe54341bef3813 100644 (file)
@@ -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 */
index 01d08d3e3e4357a77167e1575d879a3f1d9dfcbc..810c2c32d98ec765f657ba2203e4d8e2d1e0d1a1 100644 (file)
@@ -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;
 }