linux-brain/arch/x86
Karol Herbst 721d4b0249 x86/mm/kmmio: Fix mmiotrace for page unaligned addresses
[ Upstream commit 6d60ce384d ]

If something calls ioremap() with an address not aligned to PAGE_SIZE, the
returned address might be not aligned as well. This led to a probe
registered on exactly the returned address, but the entire page was armed
for mmiotracing.

On calling iounmap() the address passed to unregister_kmmio_probe() was
PAGE_SIZE aligned by the caller leading to a complete freeze of the
machine.

We should always page align addresses while (un)registerung mappings,
because the mmiotracer works on top of pages, not mappings. We still keep
track of the probes based on their real addresses and lengths though,
because the mmiotrace still needs to know what are mapped memory regions.

Also move the call to mmiotrace_iounmap() prior page aligning the address,
so that all probes are unregistered properly, otherwise the kernel ends up
failing memory allocations randomly after disabling the mmiotracer.

Tested-by: Lyude <lyude@redhat.com>
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Acked-by: Pekka Paalanen <ppaalanen@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: nouveau@lists.freedesktop.org
Link: http://lkml.kernel.org/r/20171127075139.4928-1-kherbst@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-02-25 11:08:03 +01:00
..
boot x86/mm/pti: Add infrastructure for page table isolation 2018-01-02 20:30:56 +01:00
configs x86/unwind: Rename unwinder config options to 'CONFIG_UNWINDER_*' 2017-12-25 14:26:13 +01:00
crypto crypto: x86/twofish-3way - Fix %rbp usage 2018-02-25 11:07:49 +01:00
entry x86/entry/64: Fix CR3 restore in paranoid_exit() 2018-02-22 15:42:24 +01:00
events x86/cpu: Rename cpu_data.x86_mask to cpu_data.x86_stepping 2018-02-22 15:42:24 +01:00
hyperv x86/virt: Add enum for hypervisors to replace x86_hyper 2017-12-25 14:26:20 +01:00
ia32 License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
include x86/mm, mm/hwpoison: Don't unconditionally unmap kernel 1:1 pages 2018-02-22 15:42:31 +01:00
kernel x86/mm, mm/hwpoison: Don't unconditionally unmap kernel 1:1 pages 2018-02-22 15:42:31 +01:00
kvm KVM: VMX: fix page leak in hardware_setup() 2018-02-25 11:07:59 +01:00
lib x86/cpu: Rename cpu_data.x86_mask to cpu_data.x86_stepping 2018-02-22 15:42:24 +01:00
math-emu License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mm x86/mm/kmmio: Fix mmiotrace for page unaligned addresses 2018-02-25 11:08:03 +01:00
net bpf: fix bpf_tail_call() x64 JIT 2017-10-03 16:04:44 -07:00
oprofile x86/oprofile/ppro: Do not use __this_cpu*() in preemptible context 2017-11-08 13:01:54 +01:00
pci x86/PCI: Make broadcom_postcore_init() check acpi_disabled 2017-12-14 09:52:53 +01:00
platform x86/mm: Rename flush_tlb_single() and flush_tlb_one() to __flush_tlb_one_[user|kernel]() 2018-02-22 15:42:24 +01:00
power x86/entry: Remap the TSS into the CPU entry area 2017-12-25 14:26:22 +01:00
purgatory License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
ras License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
realmode License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
tools License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
um x86/entry: Use SYSCALL_DEFINE() macros for sys_modify_ldt() 2017-12-10 13:40:41 +01:00
video x86/video: Don't assume all FB devices are PCI devices 2016-03-15 11:08:26 +01:00
xen xen: Fix {set,clear}_foreign_p2m_mapping on autotranslating guests 2018-02-22 15:42:28 +01:00
.gitignore
Kbuild Merge branch 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2017-09-07 09:25:15 -07:00
Kconfig kmemcheck: rip it out 2018-02-22 15:42:24 +01:00
Kconfig.cpu License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Kconfig.debug x86/unwind: Make CONFIG_UNWINDER_ORC=y the default in kconfig for 64-bit 2017-12-25 14:26:14 +01:00
Makefile kmemcheck: remove annotations 2018-02-22 15:42:23 +01:00
Makefile_32.cpu License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Makefile.um License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00