diff options
author | Dave Hansen <dave.hansen@linux.intel.com> | 2018-09-28 12:02:28 -0400 |
---|---|---|
committer | Peter Zijlstra <peterz@infradead.org> | 2018-10-09 10:51:16 -0400 |
commit | 02e983b760c0d4183c28d625a3c99016e2cd8a7f (patch) | |
tree | ad406d36d9187326b1e318edec6da9b262691a2f | |
parent | 88259744e253777e898c186f08670c86dd8199bf (diff) |
x86/mm: Add vsyscall address helper
We will shortly be using this check in two locations. Put it in
a helper before we do so.
Let's also insert PAGE_MASK instead of the open-coded ~0xfff.
It is easier to read and also more obviously correct considering
the implicit type conversion that has to happen when it is not
an implicit 'unsigned long'.
Cc: x86@kernel.org
Cc: Jann Horn <jannh@google.com>
Cc: Sean Christopherson <sean.j.christopherson@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20180928160228.C593509B@viggo.jf.intel.com
-rw-r--r-- | arch/x86/mm/fault.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 57b074b02ebb..7a627ac3a0d2 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c | |||
@@ -840,6 +840,15 @@ show_signal_msg(struct pt_regs *regs, unsigned long error_code, | |||
840 | show_opcodes(regs, loglvl); | 840 | show_opcodes(regs, loglvl); |
841 | } | 841 | } |
842 | 842 | ||
843 | /* | ||
844 | * The (legacy) vsyscall page is the long page in the kernel portion | ||
845 | * of the address space that has user-accessible permissions. | ||
846 | */ | ||
847 | static bool is_vsyscall_vaddr(unsigned long vaddr) | ||
848 | { | ||
849 | return (vaddr & PAGE_MASK) == VSYSCALL_ADDR; | ||
850 | } | ||
851 | |||
843 | static void | 852 | static void |
844 | __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code, | 853 | __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code, |
845 | unsigned long address, u32 *pkey, int si_code) | 854 | unsigned long address, u32 *pkey, int si_code) |
@@ -869,7 +878,7 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code, | |||
869 | * emulation. | 878 | * emulation. |
870 | */ | 879 | */ |
871 | if (unlikely((error_code & X86_PF_INSTR) && | 880 | if (unlikely((error_code & X86_PF_INSTR) && |
872 | ((address & ~0xfff) == VSYSCALL_ADDR))) { | 881 | is_vsyscall_vaddr(address))) { |
873 | if (emulate_vsyscall(regs, address)) | 882 | if (emulate_vsyscall(regs, address)) |
874 | return; | 883 | return; |
875 | } | 884 | } |