Commit 97f99fed authored by Ingo Molnar's avatar Ingo Molnar

x86: simplify 32-bit cpa largepage splitting

simplify 32-bit cpa largepage splitting: do a pure split and repeat
the pte lookup to get the new pte modified.
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 78c94aba
...@@ -38,7 +38,7 @@ pte_t *lookup_address(unsigned long address, int *level) ...@@ -38,7 +38,7 @@ pte_t *lookup_address(unsigned long address, int *level)
} }
static struct page * static struct page *
split_large_page(unsigned long address, pgprot_t prot, pgprot_t ref_prot) split_large_page(unsigned long address, pgprot_t ref_prot)
{ {
unsigned long addr; unsigned long addr;
struct page *base; struct page *base;
...@@ -58,10 +58,9 @@ split_large_page(unsigned long address, pgprot_t prot, pgprot_t ref_prot) ...@@ -58,10 +58,9 @@ split_large_page(unsigned long address, pgprot_t prot, pgprot_t ref_prot)
pbase = (pte_t *)page_address(base); pbase = (pte_t *)page_address(base);
paravirt_alloc_pt(&init_mm, page_to_pfn(base)); paravirt_alloc_pt(&init_mm, page_to_pfn(base));
for (i = 0; i < PTRS_PER_PTE; i++, addr += PAGE_SIZE) { for (i = 0; i < PTRS_PER_PTE; i++, addr += PAGE_SIZE)
set_pte(&pbase[i], pfn_pte(addr >> PAGE_SHIFT, set_pte(&pbase[i], pfn_pte(addr >> PAGE_SHIFT, ref_prot));
addr == address ? prot : ref_prot));
}
return base; return base;
} }
...@@ -101,6 +100,7 @@ static int __change_page_attr(struct page *page, pgprot_t prot) ...@@ -101,6 +100,7 @@ static int __change_page_attr(struct page *page, pgprot_t prot)
BUG_ON(PageHighMem(page)); BUG_ON(PageHighMem(page));
address = (unsigned long)page_address(page); address = (unsigned long)page_address(page);
repeat:
kpte = lookup_address(address, &level); kpte = lookup_address(address, &level);
if (!kpte) if (!kpte)
return -EINVAL; return -EINVAL;
...@@ -128,7 +128,8 @@ static int __change_page_attr(struct page *page, pgprot_t prot) ...@@ -128,7 +128,8 @@ static int __change_page_attr(struct page *page, pgprot_t prot)
set_pte_atomic(kpte, mk_pte(page, prot)); set_pte_atomic(kpte, mk_pte(page, prot));
} else { } else {
struct page *split; struct page *split;
split = split_large_page(address, prot, ref_prot);
split = split_large_page(address, ref_prot);
if (!split) if (!split)
return -ENOMEM; return -ENOMEM;
...@@ -136,6 +137,7 @@ static int __change_page_attr(struct page *page, pgprot_t prot) ...@@ -136,6 +137,7 @@ static int __change_page_attr(struct page *page, pgprot_t prot)
* There's a small window here to waste a bit of RAM: * There's a small window here to waste a bit of RAM:
*/ */
set_pmd_pte(kpte, address, mk_pte(split, ref_prot)); set_pmd_pte(kpte, address, mk_pte(split, ref_prot));
goto repeat;
} }
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment