x86: Clean up cr4 manipulation

CR4 manipulation was split, seemingly at random, between direct
(write_cr4) and using a helper (set/clear_in_cr4).  Unfortunately,
the set_in_cr4 and clear_in_cr4 helpers also poke at the boot code,
which only a small subset of users actually wanted.

This patch replaces all cr4 access in functions that don't leave cr4
exactly the way they found it with new helpers cr4_set_bits,
cr4_clear_bits, and cr4_set_bits_and_update_boot.

Signed-off-by: Andy Lutomirski <[email protected]>
Reviewed-by: Thomas Gleixner <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Andrea Arcangeli <[email protected]>
Cc: Vince Weaver <[email protected]>
Cc: "hillf.zj" <[email protected]>
Cc: Valdis Kletnieks <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Linus Torvalds <[email protected]>
Link: http://lkml.kernel.org/r/495a10bdc9e67016b8fd3945700d46cfd5c12c2f.1414190806.git.luto@amacapital.net
Signed-off-by: Ingo Molnar <[email protected]>
This commit is contained in:
Andy Lutomirski 2014-10-24 15:58:07 -07:00 • committed by Ingo Molnar
commit 375074cc73
15 changed files with 70 additions and 57 deletions

View file

@ -47,6 +47,7 @@
#include <asm/lguest.h>
#include <asm/uaccess.h>
#include <asm/i387.h>
#include <asm/tlbflush.h>
#include "../lg.h"
static int cpu_had_pge;
@ -452,9 +453,9 @@ void lguest_arch_handle_trap(struct lg_cpu *cpu)
static void adjust_pge(void *on)
{
if (on)
write_cr4(read_cr4() | X86_CR4_PGE);
cr4_set_bits(X86_CR4_PGE);
else
write_cr4(read_cr4() & ~X86_CR4_PGE);
cr4_clear_bits(X86_CR4_PGE);
}
/*H:020