[PATCH] [18/31] CPA: Make change_page_attr() more robust against use of PAT bits

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-kernel@...>, <jbeulich@...>, <mingo@...>, <tglx@...>
Date: Monday, January 14, 2008 - 6:16 pm

Use the page table level instead of the PSE bit to check if the PTE 
is for a 4K page or not. This makes the code more robust when the PAT
bit is changed because the PAT bit on 4K pages is in the same position as the
PSE bit.

Signed-off-by: Andi Kleen <ak@suse.de>

---
 arch/x86/mm/pageattr_32.c |    4 ++--
 arch/x86/mm/pageattr_64.c |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

Index: linux/arch/x86/mm/pageattr_32.c
===================================================================
--- linux.orig/arch/x86/mm/pageattr_32.c
+++ linux/arch/x86/mm/pageattr_32.c
@@ -209,7 +209,7 @@ __change_page_attr(struct page *page, pg
 	set_tlb_flush(address);
 
 	if (pgprot_val(prot) != pgprot_val(PAGE_KERNEL)) { 
-		if (!pte_huge(*kpte)) {
+		if (level == 3) {
 			set_pte_atomic(kpte, mk_pte(page, prot)); 
 		} else {
 			pgprot_t ref_prot;
@@ -225,7 +225,7 @@ __change_page_attr(struct page *page, pg
 			kpte_page = split;
 		}
 		page_private(kpte_page)++;
-	} else if (!pte_huge(*kpte)) {
+	} else if (level == 3) {
 		set_pte_atomic(kpte, mk_pte(page, PAGE_KERNEL));
 		BUG_ON(page_private(kpte_page) == 0);
 		page_private(kpte_page)--;
Index: linux/arch/x86/mm/pageattr_64.c
===================================================================
--- linux.orig/arch/x86/mm/pageattr_64.c
+++ linux/arch/x86/mm/pageattr_64.c
@@ -184,7 +184,7 @@ __change_page_attr(unsigned long address
 	set_tlb_flush(address);
 
 	if (pgprot_val(prot) != pgprot_val(ref_prot)) { 
-		if (!pte_huge(*kpte)) {
+		if (level == 4) {
 			set_pte(kpte, pfn_pte(pfn, prot));
 		} else {
 			/*
@@ -201,7 +201,7 @@ __change_page_attr(unsigned long address
 			kpte_page = split;
 		}
 		page_private(kpte_page)++;
-	} else if (!pte_huge(*kpte)) {
+	} else if (level == 4) {
 		set_pte(kpte, pfn_pte(pfn, ref_prot));
 		BUG_ON(page_private(kpte_page) == 0);
 		page_private(kpte_page)--;
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] [31/31] Clean up pte_exec, Andi Kleen, (Mon Jan 14, 6:17 pm)
[PATCH] [30/31] Remove set_kernel_exec, Andi Kleen, (Mon Jan 14, 6:17 pm)
[PATCH] [18/31] CPA: Make change_page_attr() more robust aga..., Andi Kleen, (Mon Jan 14, 6:16 pm)
[PATCH] [9/31] CPA: Add simple self test at boot, Andi Kleen, (Mon Jan 14, 6:16 pm)
Re: [PATCH] [9/31] CPA: Add simple self test at boot, Harvey Harrison, (Tue Jan 15, 6:37 am)
[PATCH] [6/31] CPA: Undo white space changes, Andi Kleen, (Mon Jan 14, 6:16 pm)
[PATCH] [4/31] Add pte_pgprot on i386, Andi Kleen, (Mon Jan 14, 6:16 pm)
Re: [PATCH] [4/31] Add pte_pgprot on i386, Johannes Weiner, (Tue Jan 15, 9:00 am)
[PATCH] [3/31] Add pte accessors for the global bit, Andi Kleen, (Mon Jan 14, 6:16 pm)
[PATCH] [2/31] CPA: Do a simple self test at boot, Andi Kleen, (Mon Jan 14, 6:16 pm)
Re: [PATCH] [2/31] CPA: Do a simple self test at boot, Harvey Harrison, (Tue Jan 15, 4:47 am)
Re: [PATCH] [2/31] CPA: Do a simple self test at boot, Harvey Harrison, (Tue Jan 15, 6:07 am)