提交 a5c62514 编写于 作者: I Ingo Molnar

x86: clean up and simplify 64-bit split_large_page()

Signed-off-by: NIngo Molnar <mingo@elte.hu>
Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
上级 5e5224a7
...@@ -46,7 +46,7 @@ pte_t *lookup_address(unsigned long address, int *level) ...@@ -46,7 +46,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;
...@@ -60,10 +60,9 @@ split_large_page(unsigned long address, pgprot_t prot, pgprot_t ref_prot) ...@@ -60,10 +60,9 @@ split_large_page(unsigned long address, pgprot_t prot, pgprot_t ref_prot)
address = __pa(address); address = __pa(address);
addr = address & LARGE_PAGE_MASK; addr = address & LARGE_PAGE_MASK;
pbase = (pte_t *)page_address(base); pbase = (pte_t *)page_address(base);
for (i = 0; i < PTRS_PER_PTE; i++, addr += PAGE_SIZE) { for (i = 0; i < PTRS_PER_PTE; i++, addr += PAGE_SIZE)
pbase[i] = pfn_pte(addr >> PAGE_SHIFT, pbase[i] = pfn_pte(addr >> PAGE_SHIFT, ref_prot);
addr == address ? prot : ref_prot);
}
return base; return base;
} }
...@@ -76,6 +75,7 @@ __change_page_attr(unsigned long address, unsigned long pfn, pgprot_t prot, ...@@ -76,6 +75,7 @@ __change_page_attr(unsigned long address, unsigned long pfn, pgprot_t prot,
pgprot_t ref_prot2, oldprot; pgprot_t ref_prot2, oldprot;
int level; int level;
repeat:
kpte = lookup_address(address, &level); kpte = lookup_address(address, &level);
if (!kpte) if (!kpte)
return 0; return 0;
...@@ -98,12 +98,12 @@ __change_page_attr(unsigned long address, unsigned long pfn, pgprot_t prot, ...@@ -98,12 +98,12 @@ __change_page_attr(unsigned long address, unsigned long pfn, pgprot_t prot,
struct page *split; struct page *split;
ref_prot2 = pte_pgprot(pte_clrhuge(*kpte)); ref_prot2 = pte_pgprot(pte_clrhuge(*kpte));
split = split_large_page(address, prot, ref_prot2); split = split_large_page(address, ref_prot2);
if (!split) if (!split)
return -ENOMEM; return -ENOMEM;
pgprot_val(ref_prot2) &= ~_PAGE_NX; pgprot_val(ref_prot2) &= ~_PAGE_NX;
set_pte(kpte, mk_pte(split, ref_prot2)); set_pte(kpte, mk_pte(split, ref_prot2));
kpte_page = split; goto repeat;
} }
} else { } else {
if (level == 4) { if (level == 4) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册