Skip to content

Commit 0d69bdf

Browse files
Toshi Kaniingomolnar
authored andcommitted
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>
1 parent d79a40c commit 0d69bdf

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

‎arch/x86/mm/pat.c‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,12 @@ static int pat_pagerange_is_ram(resource_size_t start, resource_size_t end)
401401

402402
/*
403403
* 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.
407410
*/
408411
static int reserve_ram_pages_type(u64 start, u64 end,
409412
enum page_cache_mode req_type,
@@ -412,6 +415,13 @@ static int reserve_ram_pages_type(u64 start, u64 end,
412415
struct page *page;
413416
u64 pfn;
414417

418+
if ((req_type == _PAGE_CACHE_MODE_WT) ||
419+
(req_type == _PAGE_CACHE_MODE_WP)) {
420+
if (new_type)
421+
*new_type = _PAGE_CACHE_MODE_UC_MINUS;
422+
return -EINVAL;
423+
}
424+
415425
if (req_type == _PAGE_CACHE_MODE_UC) {
416426
/* We do not support strong UC */
417427
WARN_ON_ONCE(1);
@@ -461,6 +471,7 @@ static int free_ram_pages_type(u64 start, u64 end)
461471
* - _PAGE_CACHE_MODE_WC
462472
* - _PAGE_CACHE_MODE_UC_MINUS
463473
* - _PAGE_CACHE_MODE_UC
474+
* - _PAGE_CACHE_MODE_WT
464475
*
465476
* If new_type is NULL, function will return an error if it cannot reserve the
466477
* region with req_type. If new_type is non-NULL, function will return

0 commit comments

Comments
 (0)