aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndi Kleen <ak@suse.de>2008-01-30 07:33:52 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:33:52 -0500
commit895bdc29956e5c9e9e101b2b1c2f0ed34130f945 (patch)
treee95aed8be8660bfac8ca73037cd1e0f0c7e2cdad
parent3c868823413d76bdd80c643603be8ab09dcb4d65 (diff)
x86: c_p_a() make it more robust against use of PAT bits
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> Acked-by: Jan Beulich <jbeulich@novell.com> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r--arch/x86/mm/pageattr_32.c4
-rw-r--r--arch/x86/mm/pageattr_64.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/arch/x86/mm/pageattr_32.c b/arch/x86/mm/pageattr_32.c
index 5cb5c7101f41..66688a630839 100644
--- a/arch/x86/mm/pageattr_32.c
+++ b/arch/x86/mm/pageattr_32.c
@@ -172,7 +172,7 @@ static int __change_page_attr(struct page *page, pgprot_t prot)
172 BUG_ON(PageCompound(kpte_page)); 172 BUG_ON(PageCompound(kpte_page));
173 173
174 if (pgprot_val(prot) != pgprot_val(PAGE_KERNEL)) { 174 if (pgprot_val(prot) != pgprot_val(PAGE_KERNEL)) {
175 if (!pte_huge(*kpte)) { 175 if (level == 3) {
176 set_pte_atomic(kpte, mk_pte(page, prot)); 176 set_pte_atomic(kpte, mk_pte(page, prot));
177 } else { 177 } else {
178 struct page *split; 178 struct page *split;
@@ -190,7 +190,7 @@ static int __change_page_attr(struct page *page, pgprot_t prot)
190 } 190 }
191 page_private(kpte_page)++; 191 page_private(kpte_page)++;
192 } else { 192 } else {
193 if (!pte_huge(*kpte)) { 193 if (level == 3) {
194 set_pte_atomic(kpte, mk_pte(page, PAGE_KERNEL)); 194 set_pte_atomic(kpte, mk_pte(page, PAGE_KERNEL));
195 BUG_ON(page_private(kpte_page) == 0); 195 BUG_ON(page_private(kpte_page) == 0);
196 page_private(kpte_page)--; 196 page_private(kpte_page)--;
diff --git a/arch/x86/mm/pageattr_64.c b/arch/x86/mm/pageattr_64.c
index 3ccdb1401e67..73dbbb4048e6 100644
--- a/arch/x86/mm/pageattr_64.c
+++ b/arch/x86/mm/pageattr_64.c
@@ -153,7 +153,7 @@ __change_page_attr(unsigned long address, unsigned long pfn, pgprot_t prot,
153 BUG_ON(PageLRU(kpte_page)); 153 BUG_ON(PageLRU(kpte_page));
154 BUG_ON(PageCompound(kpte_page)); 154 BUG_ON(PageCompound(kpte_page));
155 if (pgprot_val(prot) != pgprot_val(ref_prot)) { 155 if (pgprot_val(prot) != pgprot_val(ref_prot)) {
156 if (!pte_huge(*kpte)) { 156 if (level == 4) {
157 set_pte(kpte, pfn_pte(pfn, prot)); 157 set_pte(kpte, pfn_pte(pfn, prot));
158 } else { 158 } else {
159 /* 159 /*
@@ -172,7 +172,7 @@ __change_page_attr(unsigned long address, unsigned long pfn, pgprot_t prot,
172 } 172 }
173 page_private(kpte_page)++; 173 page_private(kpte_page)++;
174 } else { 174 } else {
175 if (!pte_huge(*kpte)) { 175 if (level == 4) {
176 set_pte(kpte, pfn_pte(pfn, ref_prot)); 176 set_pte(kpte, pfn_pte(pfn, ref_prot));
177 BUG_ON(page_private(kpte_page) == 0); 177 BUG_ON(page_private(kpte_page) == 0);
178 page_private(kpte_page)--; 178 page_private(kpte_page)--;