From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
To: Ingo Molnar <mingo@redhat.com>,
x86@kernel.org, Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>, Borislav Petkov <bp@suse.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Andy Lutomirski <luto@amacapital.net>,
Cyrill Gorcunov <gorcunov@openvz.org>,
Andi Kleen <ak@linux.intel.com>,
Matthew Wilcox <willy@infradead.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Subject: [PATCH 4/5] x86/boot/compressed/64: Set up trampoline memory
Date: Mon, 26 Feb 2018 21:04:50 +0300 [thread overview]
Message-ID: <20180226180451.86788-5-kirill.shutemov@linux.intel.com> (raw)
In-Reply-To: <20180226180451.86788-1-kirill.shutemov@linux.intel.com>
This patch clears up trampoline memory and copies trampoline code in
place. It's not yet used though.
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
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;
}
--
2.16.1
next prev parent reply other threads:[~2018-02-26 18:05 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-26 18:04 [PATCH 0/5] x86/boot/compressed/64: Prepare trampoline memory Kirill A. Shutemov
2018-02-26 18:04 ` [PATCH 1/5] x86/boot/compressed/64: Describe the logic behind LA57 check Kirill A. Shutemov
2018-03-12 9:27 ` [tip:x86/mm] x86/boot/compressed/64: Describe the logic behind the " tip-bot for Kirill A. Shutemov
2018-03-12 12:40 ` Peter Zijlstra
2018-03-12 12:43 ` Kirill A. Shutemov
2018-03-12 13:10 ` Peter Zijlstra
2018-03-12 14:04 ` Kirill A. Shutemov
2018-03-12 14:32 ` Ingo Molnar
2018-03-12 14:50 ` Kirill A. Shutemov
2018-03-12 16:42 ` Linus Torvalds
2018-03-12 17:06 ` Andy Lutomirski
2018-03-12 17:12 ` Linus Torvalds
2018-03-12 17:41 ` Ingo Molnar
2018-03-12 17:21 ` Dave Hansen
2018-03-12 14:52 ` Cyrill Gorcunov
2018-02-26 18:04 ` [PATCH 2/5] x86/boot/compressed/64: Find a place for 32-bit trampoline Kirill A. Shutemov
2018-02-26 22:30 ` Borislav Petkov
2018-02-27 8:14 ` Kirill A. Shutemov
2018-03-12 9:28 ` [tip:x86/mm] " tip-bot for Kirill A. Shutemov
2018-02-26 18:04 ` [PATCH 3/5] x86/boot/compressed/64: Save and restore trampoline memory Kirill A. Shutemov
2018-03-12 9:29 ` [tip:x86/mm] " tip-bot for Kirill A. Shutemov
2018-02-26 18:04 ` Kirill A. Shutemov [this message]
2018-03-12 9:29 ` [tip:x86/mm] x86/boot/compressed/64: Set up " tip-bot for Kirill A. Shutemov
2018-02-26 18:04 ` [PATCH 5/5] x86/boot/compressed/64: Prepare new top-level page table for trampoline Kirill A. Shutemov
2018-03-12 9:30 ` [tip:x86/mm] " tip-bot for Kirill A. Shutemov
2018-02-26 19:32 ` [PATCH 0/5] x86/boot/compressed/64: Prepare trampoline memory Borislav Petkov
2018-02-26 20:55 ` Kirill A. Shutemov
2018-02-27 9:32 ` Borislav Petkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180226180451.86788-5-kirill.shutemov@linux.intel.com \
--to=kirill.shutemov@linux.intel.com \
--cc=ak@linux.intel.com \
--cc=bp@suse.de \
--cc=gorcunov@openvz.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=luto@amacapital.net \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=willy@infradead.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).