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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1405452884-25688-4-git-send-email-toshi.kani@hp.com>
Date:	Tue, 15 Jul 2014 13:34:36 -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 3/11] x86, mm, pat: Change reserve_memtype() to handle WT type

This patch changes reserve_memtype() to handle the new WT type.
When (!pat_enabled && new_type), it continues to set either WB
or UC- to *new_type.  When pat_enabled, it can reserve a given
non-RAM range for WT.  At this point, it may not reserve a RAM
range for WT since reserve_ram_pages_type() uses the page flags
limited to three memory types, WB, WC and UC.

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

diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
index 9863ee3..c80a3a1 100644
--- a/arch/x86/include/asm/cacheflush.h
+++ b/arch/x86/include/asm/cacheflush.h
@@ -42,6 +42,8 @@ static inline void set_page_memtype(struct page *pg, unsigned long memtype)
 	unsigned long old_flags;
 	unsigned long new_flags;
 
+	BUG_ON(memtype == _PAGE_CACHE_WT);
+
 	switch (memtype) {
 	case _PAGE_CACHE_WC:
 		memtype_flags = _PGMT_WC;
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
index 176d4d6..8a8be17 100644
--- a/arch/x86/mm/pat.c
+++ b/arch/x86/mm/pat.c
@@ -203,6 +203,8 @@ static int pat_pagerange_is_ram(resource_size_t start, resource_size_t end)
 
 /*
  * For RAM pages, we use page flags to mark the pages with appropriate type.
+ * The page flags are currently limited to three types, WB, WC and UC. Hence,
+ * any request to WT will fail with -EINVAL.
  * Here we do two pass:
  * - Find the memtype of all the pages in the range, look for any conflicts
  * - In case of no conflicts, set the new memtype for pages in the range
@@ -213,6 +215,9 @@ static int reserve_ram_pages_type(u64 start, u64 end, unsigned long req_type,
 	struct page *page;
 	u64 pfn;
 
+	if (req_type == _PAGE_CACHE_WT)
+		return -EINVAL;
+
 	for (pfn = (start >> PAGE_SHIFT); pfn < (end >> PAGE_SHIFT); ++pfn) {
 		unsigned long type;
 
@@ -254,6 +259,7 @@ static int free_ram_pages_type(u64 start, u64 end)
  * req_type typically has one of the:
  * - _PAGE_CACHE_WB
  * - _PAGE_CACHE_WC
+ * - _PAGE_CACHE_WT
  * - _PAGE_CACHE_UC_MINUS
  *
  * If new_type is NULL, function will return an error if it cannot reserve the
@@ -274,10 +280,10 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type,
 	if (!pat_enabled) {
 		/* This is identical to page table setting without PAT */
 		if (new_type) {
-			if (req_type == _PAGE_CACHE_WC)
-				*new_type = _PAGE_CACHE_UC_MINUS;
+			if (req_type == _PAGE_CACHE_WB)
+				*new_type = _PAGE_CACHE_WB;
 			else
-				*new_type = req_type & _PAGE_CACHE_MASK;
+				*new_type = _PAGE_CACHE_UC_MINUS;
 		}
 		return 0;
 	}
diff --git a/arch/x86/mm/pat_internal.h b/arch/x86/mm/pat_internal.h
index 2593d40..7ae6b37 100644
--- a/arch/x86/mm/pat_internal.h
+++ b/arch/x86/mm/pat_internal.h
@@ -20,6 +20,7 @@ static inline char *cattr_name(unsigned long flags)
 	case _PAGE_CACHE_UC_MINUS:	return "uncached-minus";
 	case _PAGE_CACHE_WB:		return "write-back";
 	case _PAGE_CACHE_WC:		return "write-combining";
+	case _PAGE_CACHE_WT:		return "write-through";
 	default:			return "broken";
 	}
 }
--
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