mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-24 05:04:00 +08:00
c0a32fc5a2
With CONFIG_DEBUG_PAGEALLOC configured, the CPU will generate an exception on access (read,write) to an unallocated page, which permits us to catch code which corrupts memory. However the kernel is trying to maximise memory usage, hence there are usually few free pages in the system and buggy code usually corrupts some crucial data. This patch changes the buddy allocator to keep more free/protected pages and to interlace free/protected and allocated pages to increase the probability of catching corruption. When the kernel is compiled with CONFIG_DEBUG_PAGEALLOC, debug_guardpage_minorder defines the minimum order used by the page allocator to grant a request. The requested size will be returned with the remaining pages used as guard pages. The default value of debug_guardpage_minorder is zero: no change from current behaviour. [akpm@linux-foundation.org: tweak documentation, s/flg/flag/] Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Cc: Mel Gorman <mgorman@suse.de> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: "Rafael J. Wysocki" <rjw@sisk.pl> Cc: Christoph Lameter <cl@linux-foundation.org> Cc: Pekka Enberg <penberg@cs.helsinki.fi> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
30 lines
1015 B
Plaintext
30 lines
1015 B
Plaintext
config DEBUG_PAGEALLOC
|
|
bool "Debug page memory allocations"
|
|
depends on DEBUG_KERNEL
|
|
depends on !HIBERNATION || ARCH_SUPPORTS_DEBUG_PAGEALLOC && !PPC && !SPARC
|
|
depends on !KMEMCHECK
|
|
select PAGE_POISONING if !ARCH_SUPPORTS_DEBUG_PAGEALLOC
|
|
select PAGE_GUARD if ARCH_SUPPORTS_DEBUG_PAGEALLOC
|
|
---help---
|
|
Unmap pages from the kernel linear mapping after free_pages().
|
|
This results in a large slowdown, but helps to find certain types
|
|
of memory corruption.
|
|
|
|
For architectures which don't enable ARCH_SUPPORTS_DEBUG_PAGEALLOC,
|
|
fill the pages with poison patterns after free_pages() and verify
|
|
the patterns before alloc_pages(). Additionally,
|
|
this option cannot be enabled in combination with hibernation as
|
|
that would result in incorrect warnings of memory corruption after
|
|
a resume because free pages are not saved to the suspend image.
|
|
|
|
config WANT_PAGE_DEBUG_FLAGS
|
|
bool
|
|
|
|
config PAGE_POISONING
|
|
bool
|
|
select WANT_PAGE_DEBUG_FLAGS
|
|
|
|
config PAGE_GUARD
|
|
bool
|
|
select WANT_PAGE_DEBUG_FLAGS
|