Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/mm/pat: Change reserve_memtype() for Write-Through type

When a target range is in RAM, reserve_ram_pages_type() verifies
the requested type. Change it to fail WT and WP requests with
-EINVAL since set_page_memtype() is limited to handle three
types: WB, WC and UC-.

Signed-off-by: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Elliott@hp.com
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Luis R. Rodriguez <mcgrof@suse.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: arnd@arndb.de
Cc: hch@lst.de
Cc: hmh@hmh.eng.br
Cc: jgross@suse.com
Cc: konrad.wilk@oracle.com
Cc: linux-mm <linux-mm@kvack.org>
Cc: linux-nvdimm@lists.01.org
Cc: stefan.bader@canonical.com
Cc: yigal@plexistor.com
Link: http://lkml.kernel.org/r/1433436928-31903-6-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Toshi Kani and committed by
Ingo Molnar
0d69bdff d79a40ca

+14 -3
+14 -3
arch/x86/mm/pat.c
··· 401 401 402 402 /* 403 403 * For RAM pages, we use page flags to mark the pages with appropriate type. 404 - * Here we do two pass: 405 - * - Find the memtype of all the pages in the range, look for any conflicts 406 - * - In case of no conflicts, set the new memtype for pages in the range 404 + * The page flags are limited to three types, WB, WC and UC-. WT and WP requests 405 + * fail with -EINVAL, and UC gets redirected to UC-. 406 + * 407 + * Here we do two passes: 408 + * - Find the memtype of all the pages in the range, look for any conflicts. 409 + * - In case of no conflicts, set the new memtype for pages in the range. 407 410 */ 408 411 static int reserve_ram_pages_type(u64 start, u64 end, 409 412 enum page_cache_mode req_type, ··· 414 411 { 415 412 struct page *page; 416 413 u64 pfn; 414 + 415 + if ((req_type == _PAGE_CACHE_MODE_WT) || 416 + (req_type == _PAGE_CACHE_MODE_WP)) { 417 + if (new_type) 418 + *new_type = _PAGE_CACHE_MODE_UC_MINUS; 419 + return -EINVAL; 420 + } 417 421 418 422 if (req_type == _PAGE_CACHE_MODE_UC) { 419 423 /* We do not support strong UC */ ··· 471 461 * - _PAGE_CACHE_MODE_WC 472 462 * - _PAGE_CACHE_MODE_UC_MINUS 473 463 * - _PAGE_CACHE_MODE_UC 464 + * - _PAGE_CACHE_MODE_WT 474 465 * 475 466 * If new_type is NULL, function will return an error if it cannot reserve the 476 467 * region with req_type. If new_type is non-NULL, function will return