From: Joerg Roedel <joro@8bytes.org>
To: Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>
Cc: hpa@zytor.com, Linus Torvalds <torvalds@linux-foundation.org>,
Dave Hansen <dave.hansen@intel.com>,
Andy Lutomirski <luto@amacapital.net>,
Borislav Petkov <bp@alien8.de>, Jiri Kosina <jkosina@suse.cz>,
linux-kernel@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
x86@kernel.org, Joerg Roedel <jroedel@suse.de>
Subject: [PATCH 1/3] x86/pti: Move pti_init() code out of __init
Date: Tue, 3 Jul 2018 13:52:24 +0200 [thread overview]
Message-ID: <1530618746-23116-2-git-send-email-joro@8bytes.org> (raw)
In-Reply-To: <1530618746-23116-1-git-send-email-joro@8bytes.org>
From: Joerg Roedel <jroedel@suse.de>
This removes the __init annotations from pti_init() and everything it
calls on x86. The pti_init() function sets up the kernel-mappings
visible in the user-space page-table when PTI is enabled, which only
makes sense after the relevant kernel mappings have been finished.
The kernel mappings are finished when the appropriate read-only and
no-execute protections are established for the kernel text, rodata and
data sections, which happens after the init-code/data has been freed by
the kernel.
So to call pti_init() at the right place it can't be __init anymore.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
arch/x86/entry/vsyscall/vsyscall_64.c | 2 +-
arch/x86/mm/pti.c | 16 ++++++++--------
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/arch/x86/entry/vsyscall/vsyscall_64.c b/arch/x86/entry/vsyscall/vsyscall_64.c
index 82ed001..6cd5cbf 100644
--- a/arch/x86/entry/vsyscall/vsyscall_64.c
+++ b/arch/x86/entry/vsyscall/vsyscall_64.c
@@ -340,7 +340,7 @@ int in_gate_area_no_mm(unsigned long addr)
* vsyscalls but leave the page not present. If so, we skip calling
* this.
*/
-void __init set_vsyscall_pgtable_user_bits(pgd_t *root)
+void set_vsyscall_pgtable_user_bits(pgd_t *root)
{
pgd_t *pgd;
p4d_t *p4d;
diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
index 4d418e7..8a80522 100644
--- a/arch/x86/mm/pti.c
+++ b/arch/x86/mm/pti.c
@@ -234,7 +234,7 @@ static pmd_t *pti_user_pagetable_walk_pmd(unsigned long address)
*
* Returns a pointer to a PTE on success, or NULL on failure.
*/
-static __init pte_t *pti_user_pagetable_walk_pte(unsigned long address)
+static pte_t *pti_user_pagetable_walk_pte(unsigned long address)
{
gfp_t gfp = (GFP_KERNEL | __GFP_NOTRACK | __GFP_ZERO);
pmd_t *pmd = pti_user_pagetable_walk_pmd(address);
@@ -262,7 +262,7 @@ static __init pte_t *pti_user_pagetable_walk_pte(unsigned long address)
return pte;
}
-static void __init pti_setup_vsyscall(void)
+static void pti_setup_vsyscall(void)
{
pte_t *pte, *target_pte;
unsigned int level;
@@ -279,7 +279,7 @@ static void __init pti_setup_vsyscall(void)
set_vsyscall_pgtable_user_bits(kernel_to_user_pgdp(swapper_pg_dir));
}
#else
-static void __init pti_setup_vsyscall(void) { }
+static void pti_setup_vsyscall(void) { }
#endif
static void
@@ -348,7 +348,7 @@ pti_clone_pmds(unsigned long start, unsigned long end, pmdval_t clear)
* Clone a single p4d (i.e. a top-level entry on 4-level systems and a
* next-level entry on 5-level systems.
*/
-static void __init pti_clone_p4d(unsigned long addr)
+static void pti_clone_p4d(unsigned long addr)
{
p4d_t *kernel_p4d, *user_p4d;
pgd_t *kernel_pgd;
@@ -362,7 +362,7 @@ static void __init pti_clone_p4d(unsigned long addr)
/*
* Clone the CPU_ENTRY_AREA into the user space visible page table.
*/
-static void __init pti_clone_user_shared(void)
+static void pti_clone_user_shared(void)
{
pti_clone_p4d(CPU_ENTRY_AREA_BASE);
}
@@ -370,7 +370,7 @@ static void __init pti_clone_user_shared(void)
/*
* Clone the ESPFIX P4D into the user space visible page table
*/
-static void __init pti_setup_espfix64(void)
+static void pti_setup_espfix64(void)
{
#ifdef CONFIG_X86_ESPFIX64
pti_clone_p4d(ESPFIX_BASE_ADDR);
@@ -380,7 +380,7 @@ static void __init pti_setup_espfix64(void)
/*
* Clone the populated PMDs of the entry and irqentry text and force it RO.
*/
-static void __init pti_clone_entry_text(void)
+static void pti_clone_entry_text(void)
{
pti_clone_pmds((unsigned long) __entry_text_start,
(unsigned long) __irqentry_text_end,
@@ -486,7 +486,7 @@ void pti_set_kernel_image_nonglobal(void)
/*
* Initialize kernel page table isolation
*/
-void __init pti_init(void)
+void pti_init(void)
{
if (!static_cpu_has(X86_FEATURE_PTI))
return;
--
2.7.4
next prev parent reply other threads:[~2018-07-03 11:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-03 11:52 [PATCH 0/3] x86/pti: Call pti_init() after mark_readonly() Joerg Roedel
2018-07-03 11:52 ` Joerg Roedel [this message]
2018-07-03 11:52 ` [PATCH 2/3] " Joerg Roedel
2018-07-03 11:52 ` [PATCH 3/3] x86/pti: Call pti_clone_kernel_text() from pti_init() Joerg Roedel
2018-07-10 13:19 ` [PATCH 0/3] x86/pti: Call pti_init() after mark_readonly() Joerg Roedel
2018-07-10 20:25 ` Thomas Gleixner
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=1530618746-23116-2-git-send-email-joro@8bytes.org \
--to=joro@8bytes.org \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=hpa@zytor.com \
--cc=jkosina@suse.cz \
--cc=jroedel@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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
Powered by JetHome