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: <20080616125821.GA5213@alberich.amd.com>
Date:	Mon, 16 Jun 2008 14:58:21 +0200
From:	Andreas Herrmann <andreas.herrmann3@....com>
To:	Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...e.hu>,
	"H. Peter Anvin" <hpa@...or.com>
CC:	linux-kernel@...r.kernel.org,
	Venkatesh Pallipadi <venkatesh.pallipadi@...el.com>,
	Suresh B Siddha <suresh.b.siddha@...el.com>
Subject: [PATCH 5/5 v2] x86: PAT: make pat_x_mtrr_type() more readable

I've found it inconvenient to review pat_x_mtrr_type().
Thus I slightly changed it and added some comment to make
it more readable.

I've also added BUG statements for (some) unused/unhandled PAT/MTRR
types.

Signed-off-by: Andreas Herrmann <andreas.herrmann3@....com>
---
New patch version. (against current tip/x86/pat - v2.6.26-rc6-105-gfaeca31)
Previous version had some conflict with another commit in tip/master.

Regards,
Andreas

 arch/x86/mm/pat.c |   50 +++++++++++++++++++++++++++-----------------------
 1 files changed, 27 insertions(+), 23 deletions(-)

diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
index 4beccea..cdf2c15 100644
--- a/arch/x86/mm/pat.c
+++ b/arch/x86/mm/pat.c
@@ -169,35 +169,39 @@ static int pat_x_mtrr_type(u64 start, u64 end, unsigned long prot,
 	prot &= (~_PAGE_CACHE_MASK);
 
 	/*
-	 * We return the PAT request directly for types where PAT takes
-	 * precedence with respect to MTRR and for UC_MINUS.
+	 * We return the PAT request directly for types where PAT
+	 * takes precedence with respect to MTRR and for UC_MINUS. In
+	 * case of pat_type==WB we have to know mtrr_type to get the
+	 * effective type.
+	 *
+	 *    effective type                ret_prot
+	 *  pat \ mtrr  WB WC UC    pat \ mtrr  WB  WC  UC
+	 *  WC          WC WC WC    WC          WC  WC  WC
+	 *  UC-         UC WC UC    UC-         UC- UC- UC-
+	 *  UC          UC UC UC    UC          UC  UC  UC
+	 *  WB          WB WC UC    WB          WB  WC  UC
+	 *
 	 * Consistency checks with other PAT requests is done later
 	 * while going through memtype list.
 	 */
-	if (pat_type == _PAGE_CACHE_WC) {
+	if (pat_type == _PAGE_CACHE_WC)
 		*ret_prot = prot | _PAGE_CACHE_WC;
-		return 0;
-	} else if (pat_type == _PAGE_CACHE_UC_MINUS) {
+	else if (pat_type == _PAGE_CACHE_UC_MINUS)
 		*ret_prot = prot | _PAGE_CACHE_UC_MINUS;
-		return 0;
-	} else if (pat_type == _PAGE_CACHE_UC) {
-		*ret_prot = prot | _PAGE_CACHE_UC;
-		return 0;
-	}
-
-	/*
-	 * Look for MTRR hint to get the effective type in case where PAT
-	 * request is for WB.
-	 */
-	mtrr_type = mtrr_type_lookup(start, end);
-
-	if (mtrr_type == MTRR_TYPE_UNCACHABLE) {
+	else if (pat_type == _PAGE_CACHE_UC)
 		*ret_prot = prot | _PAGE_CACHE_UC;
-	} else if (mtrr_type == MTRR_TYPE_WRCOMB) {
-		*ret_prot = prot | _PAGE_CACHE_WC;
-	} else {
-		*ret_prot = prot | _PAGE_CACHE_WB;
-	}
+	else if (pat_type == _PAGE_CACHE_WB) {
+		mtrr_type = mtrr_type_lookup(start, end);
+		if (mtrr_type == MTRR_TYPE_WRBACK)
+			*ret_prot = prot | _PAGE_CACHE_WB;
+		else if (mtrr_type == MTRR_TYPE_WRCOMB)
+			*ret_prot = prot | _PAGE_CACHE_WC;
+		else if (mtrr_type == MTRR_TYPE_UNCACHABLE)
+			*ret_prot = prot | _PAGE_CACHE_UC;
+		else
+			BUG();
+	} else
+		  BUG();
 
 	return 0;
 }
-- 
1.5.5.4




--
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