lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 15 Jul 2014 13:34:41 -0600
From:	Toshi Kani <toshi.kani@...com>
To:	hpa@...or.com, tglx@...utronix.de, mingo@...hat.com,
	akpm@...ux-foundation.org, arnd@...db.de, konrad.wilk@...cle.com,
	plagnioj@...osoft.com, tomi.valkeinen@...com
Cc:	linux-mm@...ck.org, linux-kernel@...r.kernel.org,
	stefan.bader@...onical.com, luto@...capital.net, airlied@...il.com,
	bp@...en8.de, Toshi Kani <toshi.kani@...com>
Subject: [RFC PATCH 8/11] x86, mm, pat: Keep pgprot_<type>() slot-independent

The pgrot_<type>() interfaces only set the _PAGE_PCD and/or
_PAGE_PWT bits by assuming that a given pgprot_t value is always
set to the PA0 slot.

This patch changes the pgrot_<type>() interfaces to assure that
a requested memory type is set to the given pgprot_t regardless
of the original pgprot_t value.

Signed-off-by: Toshi Kani <toshi.kani@...com>
---
 arch/x86/include/asm/pgtable.h       |    2 +-
 arch/x86/include/asm/pgtable_types.h |    4 ++++
 arch/x86/mm/pat.c                    |    4 ++--
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 0ec0560..df18b14 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -11,7 +11,7 @@
  */
 #define pgprot_noncached(prot)					\
 	((boot_cpu_data.x86 > 3)				\
-	 ? (__pgprot(pgprot_val(prot) | _PAGE_CACHE_UC_MINUS))	\
+	 ? pgprot_set_cache(prot, _PAGE_CACHE_UC_MINUS)		\
 	 : (prot))
 
 #ifndef __ASSEMBLY__
diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
index 1fe8af7..81a3859 100644
--- a/arch/x86/include/asm/pgtable_types.h
+++ b/arch/x86/include/asm/pgtable_types.h
@@ -136,6 +136,10 @@
 #define _PAGE_CACHE_UC_MINUS	(_PAGE_PCD)
 #define _PAGE_CACHE_UC		(_PAGE_CACHE_UC_MINUS)
 
+/* Macro to set a page cache value */
+#define pgprot_set_cache(_prot, _type)					\
+	__pgprot((pgprot_val(_prot) & ~_PAGE_CACHE_MASK) | (_type))
+
 #define PAGE_NONE	__pgprot(_PAGE_PROTNONE | _PAGE_ACCESSED)
 #define PAGE_SHARED	__pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | \
 				 _PAGE_ACCESSED | _PAGE_NX)
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
index a987071..0be7ebd 100644
--- a/arch/x86/mm/pat.c
+++ b/arch/x86/mm/pat.c
@@ -790,7 +790,7 @@ void untrack_pfn(struct vm_area_struct *vma, unsigned long pfn,
 pgprot_t pgprot_writecombine(pgprot_t prot)
 {
 	if (pat_enabled)
-		return __pgprot(pgprot_val(prot) | _PAGE_CACHE_WC);
+		return pgprot_set_cache(prot, _PAGE_CACHE_WC);
 	else
 		return pgprot_noncached(prot);
 }
@@ -799,7 +799,7 @@ EXPORT_SYMBOL_GPL(pgprot_writecombine);
 pgprot_t pgprot_writethrough(pgprot_t prot)
 {
 	if (pat_enabled)
-		return __pgprot(pgprot_val(prot) | _PAGE_CACHE_WT);
+		return pgprot_set_cache(prot, _PAGE_CACHE_WT);
 	else
 		return pgprot_noncached(prot);
 }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ