x86/boot/32: Rewrite test_wp_bit()
authorAndy Lutomirski <luto@kernel.org>
Wed, 29 Mar 2017 23:47:35 +0000 (16:47 -0700)
committerIngo Molnar <mingo@kernel.org>
Thu, 30 Mar 2017 07:08:33 +0000 (09:08 +0200)
commit4af171105144a6475704c1e6024132883d50499e
tree66e11fd4eddef72922a6405b39116f63a794abeb
parent73fa1362a7f337d149f76d26b6c6845cb38c1af9
x86/boot/32: Rewrite test_wp_bit()

This code seems to be very old and has gotten only minor updates.
It's overcomplicated and has a bunch of comments that are, at best,
of purely historical interest.  Nowadays we have a shiny function
probe_kernel_write() that does more or less exactly what we need.
Use it.

I switched the page that we test from swapper_pg_dir to
empty_zero_page because writing zero to empty_zero_page is more
obviously safe than writing to the paging structures.  (It's
extremely unlikely that any of this would cause problems in practice
because the write will fail on any supported CPU.)

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Garnier <thgarnie@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/0b9e64ab0236de30e7572213cea77bf95ae2e990.1490831211.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/mm/init_32.c