Skip to content

Commit

Permalink
x86: add PG_LEVEL enum
Browse files Browse the repository at this point in the history
this way PG_LEVEL_1GB will be an easy change.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Thomas Gleixner authored and Ingo Molnar committed Jan 30, 2008
1 parent 0a66308 commit 30551bb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 1 addition & 3 deletions arch/x86/mm/pageattr-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@

enum {
NTEST = 400,
LOWEST_LEVEL = PG_LEVEL_4K,
#ifdef CONFIG_X86_64
LOWEST_LEVEL = 4,
LPS = (1 << PMD_SHIFT),
#elif defined(CONFIG_X86_PAE)
LOWEST_LEVEL = 4,
LPS = (1 << PMD_SHIFT),
#else
LOWEST_LEVEL = 4, /* lookup_address lies here */
LPS = (1 << 22),
#endif
GPS = (1<<30)
Expand Down
9 changes: 6 additions & 3 deletions arch/x86/mm/pageattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ pte_t *lookup_address(unsigned long address, int *level)
pud_t *pud;
pmd_t *pmd;

*level = PG_LEVEL_NONE;

if (pgd_none(*pgd))
return NULL;
pud = pud_offset(pgd, address);
Expand All @@ -36,11 +38,12 @@ pte_t *lookup_address(unsigned long address, int *level)
pmd = pmd_offset(pud, address);
if (pmd_none(*pmd))
return NULL;
*level = 3;

*level = PG_LEVEL_2M;
if (pmd_large(*pmd))
return (pte_t *)pmd;
*level = 4;

*level = PG_LEVEL_4K;
return pte_offset_kernel(pmd, address);
}

Expand Down Expand Up @@ -145,7 +148,7 @@ __change_page_attr(unsigned long address, struct page *page, pgprot_t prot)
address < (unsigned long)&_etext &&
(pgprot_val(prot) & _PAGE_NX));

if (level == 4) {
if (level == PG_LEVEL_4K) {
set_pte_atomic(kpte, mk_pte(page, canon_pgprot(prot)));
} else {
err = split_large_page(kpte, address);
Expand Down
6 changes: 6 additions & 0 deletions include/asm-x86/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,12 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)

#ifndef __ASSEMBLY__

enum {
PG_LEVEL_NONE,
PG_LEVEL_4K,
PG_LEVEL_2M,
};

/*
* Helper function that returns the kernel pagetable entry controlling
* the virtual address 'address'. NULL means no pagetable entry present.
Expand Down

0 comments on commit 30551bb

Please sign in to comment.