diff options
author | Andy Lutomirski <luto@kernel.org> | 2017-06-12 13:26:14 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-06-13 02:48:09 -0400 |
commit | 6c690ee1039b251e583fc65b28da30e97d6a7385 (patch) | |
tree | 44898545622f632411caf72c54cd3ffd1ff107b3 /arch/x86/power | |
parent | 3f365cf304ba3d316b3df2474af8d7df6edd2455 (diff) |
x86/mm: Split read_cr3() into read_cr3_pa() and __read_cr3()
The kernel has several code paths that read CR3. Most of them assume that
CR3 contains the PGD's physical address, whereas some of them awkwardly
use PHYSICAL_PAGE_MASK to mask off low bits.
Add explicit mask macros for CR3 and convert all of the CR3 readers.
This will keep them from breaking when PCID is enabled.
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: xen-devel <xen-devel@lists.xen.org>
Link: http://lkml.kernel.org/r/883f8fb121f4616c1c1427ad87350bb2f5ffeca1.1497288170.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/power')
-rw-r--r-- | arch/x86/power/cpu.c | 2 | ||||
-rw-r--r-- | arch/x86/power/hibernate_64.c | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c index 6b05a9219ea2..78459a6d455a 100644 --- a/arch/x86/power/cpu.c +++ b/arch/x86/power/cpu.c | |||
@@ -129,7 +129,7 @@ static void __save_processor_state(struct saved_context *ctxt) | |||
129 | */ | 129 | */ |
130 | ctxt->cr0 = read_cr0(); | 130 | ctxt->cr0 = read_cr0(); |
131 | ctxt->cr2 = read_cr2(); | 131 | ctxt->cr2 = read_cr2(); |
132 | ctxt->cr3 = read_cr3(); | 132 | ctxt->cr3 = __read_cr3(); |
133 | ctxt->cr4 = __read_cr4(); | 133 | ctxt->cr4 = __read_cr4(); |
134 | #ifdef CONFIG_X86_64 | 134 | #ifdef CONFIG_X86_64 |
135 | ctxt->cr8 = read_cr8(); | 135 | ctxt->cr8 = read_cr8(); |
diff --git a/arch/x86/power/hibernate_64.c b/arch/x86/power/hibernate_64.c index a6e21fee22ea..e3e62c8a8e70 100644 --- a/arch/x86/power/hibernate_64.c +++ b/arch/x86/power/hibernate_64.c | |||
@@ -150,7 +150,8 @@ static int relocate_restore_code(void) | |||
150 | memcpy((void *)relocated_restore_code, &core_restore_code, PAGE_SIZE); | 150 | memcpy((void *)relocated_restore_code, &core_restore_code, PAGE_SIZE); |
151 | 151 | ||
152 | /* Make the page containing the relocated code executable */ | 152 | /* Make the page containing the relocated code executable */ |
153 | pgd = (pgd_t *)__va(read_cr3()) + pgd_index(relocated_restore_code); | 153 | pgd = (pgd_t *)__va(read_cr3_pa()) + |
154 | pgd_index(relocated_restore_code); | ||
154 | p4d = p4d_offset(pgd, relocated_restore_code); | 155 | p4d = p4d_offset(pgd, relocated_restore_code); |
155 | if (p4d_large(*p4d)) { | 156 | if (p4d_large(*p4d)) { |
156 | set_p4d(p4d, __p4d(p4d_val(*p4d) & ~_PAGE_NX)); | 157 | set_p4d(p4d, __p4d(p4d_val(*p4d) & ~_PAGE_NX)); |