From: Toshi Kani <toshi.k...@hp.com>

__ioremap_caller() calls reserve_memtype() and the passed down @new_pcm
contains the actual page cache type it reserved in the success case.

is_new_memtype_allowed() verifies if converting to the new page cache
type is allowed when @pcm (the requested type) is different from
@new_pcm.

When WT is requested, the caller expects that writes are ordered and
uncached. Therefore, enhance is_new_memtype_allowed() to disallow the
following cases:

 - If the request is WT, mapping type cannot be WB
 - If the request is WT, mapping type cannot be WC

Signed-off-by: Toshi Kani <toshi.k...@hp.com>
Reviewed-by: Thomas Gleixner <t...@linutronix.de>
Cc: Andrew Morton <a...@linux-foundation.org>
Cc: Andy Lutomirski <l...@amacapital.net>
Cc: a...@arndb.de
Cc: elli...@hp.com
Cc: h...@lst.de
Cc: h...@hmh.eng.br
Cc: H. Peter Anvin <h...@zytor.com>
Cc: Ingo Molnar <mi...@redhat.com>
Cc: jgr...@suse.com
Cc: konrad.w...@oracle.com
Cc: linux-mm <linux...@kvack.org>
Cc: linux-nvd...@lists.01.org
Cc: Luis R. Rodriguez <mcg...@suse.com>
Cc: stefan.ba...@canonical.com
Cc: x86-ml <x...@kernel.org>
Cc: yi...@plexistor.com
Link: 
http://lkml.kernel.org/r/1433187393-22688-4-git-send-email-toshi.k...@hp.com
Signed-off-by: Borislav Petkov <b...@suse.de>
---
 arch/x86/include/asm/pgtable.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index fe57e7a98839..2562e303405b 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -398,11 +398,17 @@ static inline int is_new_memtype_allowed(u64 paddr, 
unsigned long size,
         * requested memtype:
         * - request is uncached, return cannot be write-back
         * - request is write-combine, return cannot be write-back
+        * - request is write-through, return cannot be write-back
+        * - request is write-through, return cannot be write-combine
         */
        if ((pcm == _PAGE_CACHE_MODE_UC_MINUS &&
             new_pcm == _PAGE_CACHE_MODE_WB) ||
            (pcm == _PAGE_CACHE_MODE_WC &&
-            new_pcm == _PAGE_CACHE_MODE_WB)) {
+            new_pcm == _PAGE_CACHE_MODE_WB) ||
+           (pcm == _PAGE_CACHE_MODE_WT &&
+            new_pcm == _PAGE_CACHE_MODE_WB) ||
+           (pcm == _PAGE_CACHE_MODE_WT &&
+            new_pcm == _PAGE_CACHE_MODE_WC)) {
                return 0;
        }
 
-- 
2.3.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to