From: Dave Hansen <dave.han...@linux.intel.com>

We will shortly be using this check in two locations.  Put it in
a helper before we do so.

Signed-off-by: Dave Hansen <dave.han...@linux.intel.com>
Cc: Sean Christopherson <sean.j.christopher...@intel.com>
Cc: "Peter Zijlstra (Intel)" <pet...@infradead.org>
Cc: Thomas Gleixner <t...@linutronix.de>
Cc: x...@kernel.org
Cc: Andy Lutomirski <l...@kernel.org>
---

 b/arch/x86/mm/fault.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff -puN arch/x86/mm/fault.c~is-vsyscall-addr arch/x86/mm/fault.c
--- a/arch/x86/mm/fault.c~is-vsyscall-addr      2018-09-07 11:21:48.208751897 
-0700
+++ b/arch/x86/mm/fault.c       2018-09-07 11:21:48.211751897 -0700
@@ -841,6 +841,15 @@ show_signal_msg(struct pt_regs *regs, un
        show_opcodes((u8 *)regs->ip, loglvl);
 }
 
+/*
+ * The (legacy) vsyscall page is the long page in the kernel portion
+ * of the address space that has user-accessible permissions.
+ */
+static bool is_vsyscall_vaddr(unsigned long vaddr)
+{
+       return (vaddr & ~0xfff) == VSYSCALL_ADDR;
+}
+
 static void
 __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
                       unsigned long address, u32 *pkey, int si_code)
@@ -870,7 +879,7 @@ __bad_area_nosemaphore(struct pt_regs *r
                 * emulation.
                 */
                if (unlikely((error_code & X86_PF_INSTR) &&
-                            ((address & ~0xfff) == VSYSCALL_ADDR))) {
+                            is_vsyscall_vaddr(address))) {
                        if (emulate_vsyscall(regs, address))
                                return;
                }
_

Reply via email to