Skip to content

Commit

Permalink
x86: simplify cpa largepage split, #3
Browse files Browse the repository at this point in the history
simplify cpa largepage split: push the reference protection bits
into the largepage-splitting function.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Ingo Molnar committed Jan 30, 2008
1 parent 5508a74 commit 7afe15b
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions arch/x86/mm/pageattr_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ static void set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
spin_unlock_irqrestore(&pgd_lock, flags);
}

static int
split_large_page(pte_t *kpte, unsigned long address, pgprot_t ref_prot)
static int split_large_page(pte_t *kpte, unsigned long address)
{
int i, level;
pgprot_t ref_prot = pte_pgprot(pte_clrhuge(*kpte));
unsigned long addr;
pte_t *pbase, *tmp;
struct page *base;
int i, level;

base = alloc_pages(GFP_KERNEL, 0);
if (!base)
Expand Down Expand Up @@ -109,11 +109,9 @@ split_large_page(pte_t *kpte, unsigned long address, pgprot_t ref_prot)

static int __change_page_attr(struct page *page, pgprot_t prot)
{
pgprot_t ref_prot = PAGE_KERNEL;
struct page *kpte_page;
unsigned long address;
int level, err = 0;
pgprot_t oldprot;
pte_t *kpte;

BUG_ON(PageHighMem(page));
Expand All @@ -124,7 +122,6 @@ static int __change_page_attr(struct page *page, pgprot_t prot)
if (!kpte)
return -EINVAL;

oldprot = pte_pgprot(*kpte);
kpte_page = virt_to_page(kpte);
BUG_ON(PageLRU(kpte_page));
BUG_ON(PageCompound(kpte_page));
Expand All @@ -137,16 +134,10 @@ static int __change_page_attr(struct page *page, pgprot_t prot)
address < (unsigned long)&_etext &&
(pgprot_val(prot) & _PAGE_NX));

if ((address & LARGE_PAGE_MASK) < (unsigned long)&_etext)
ref_prot = PAGE_KERNEL_EXEC;

ref_prot = canon_pgprot(ref_prot);
prot = canon_pgprot(prot);

if (level == 3) {
set_pte_atomic(kpte, mk_pte(page, prot));
set_pte_atomic(kpte, mk_pte(page, canon_pgprot(prot)));
} else {
err = split_large_page(kpte, address, ref_prot);
err = split_large_page(kpte, address);
if (!err)
goto repeat;
}
Expand Down

0 comments on commit 7afe15b

Please sign in to comment.