]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
x86: return the page table level in lookup_address()
authorIngo Molnar <mingo@elte.hu>
Wed, 30 Jan 2008 12:33:43 +0000 (13:33 +0100)
committerIngo Molnar <mingo@elte.hu>
Wed, 30 Jan 2008 12:33:43 +0000 (13:33 +0100)
based on this patch from Andi Kleen:

|  Subject: CPA: Return the page table level in lookup_address()
|  From: Andi Kleen <ak@suse.de>
|
|  Needed for the next change.
|
|  And change all the callers.

and ported it to x86.git.

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>
arch/x86/mm/fault_32.c
arch/x86/mm/init_32.c
arch/x86/mm/pageattr_32.c
arch/x86/mm/pageattr_64.c
arch/x86/xen/mmu.c
include/asm-x86/pgtable_32.h
include/asm-x86/pgtable_64.h

index f7972ae7da07522a03078d5bb01957c94c6b843d..f4f8c324715f5abdf835fdf80c444f024fdedaf8 100644 (file)
@@ -613,7 +613,8 @@ no_context:
 
 #ifdef CONFIG_X86_PAE
                if (error_code & PF_INSTR) {
-                       pte_t *pte = lookup_address(address);
+                       int level;
+                       pte_t *pte = lookup_address(address, &level);
 
                        if (pte && pte_present(*pte) && !pte_exec(*pte))
                                printk(KERN_CRIT "kernel tried to execute "
index 5080646da77106f03f995d87962ad50fd1915c1c..206e3f6800b911a70608fbc3ed0c311072fc27c9 100644 (file)
@@ -535,11 +535,12 @@ int __init set_kernel_exec(unsigned long vaddr, int enable)
 {
        pte_t *pte;
        int ret = 1;
+       int level;
 
        if (!nx_enabled)
                goto out;
 
-       pte = lookup_address(vaddr);
+       pte = lookup_address(vaddr, &level);
        BUG_ON(!pte);
 
        if (!pte_exec(*pte))
index be4656403d77db5abf098417ad4603ae830dab18..523fd5b37df96fa3404808727ed4c21ae6e857c2 100644 (file)
@@ -18,7 +18,7 @@
 static DEFINE_SPINLOCK(cpa_lock);
 static struct list_head df_list = LIST_HEAD_INIT(df_list);
 
-pte_t *lookup_address(unsigned long address)
+pte_t *lookup_address(unsigned long address, int *level)
 {
        pgd_t *pgd = pgd_offset_k(address);
        pud_t *pud;
@@ -32,8 +32,10 @@ pte_t *lookup_address(unsigned long address)
        pmd = pmd_offset(pud, address);
        if (pmd_none(*pmd))
                return NULL;
+       *level = 2;
        if (pmd_large(*pmd))
                return (pte_t *)pmd;
+       *level = 3;
 
        return pte_offset_kernel(pmd, address);
 }
@@ -156,11 +158,12 @@ static int __change_page_attr(struct page *page, pgprot_t prot)
        struct page *kpte_page;
        unsigned long address;
        pte_t *kpte;
+       int level;
 
        BUG_ON(PageHighMem(page));
        address = (unsigned long)page_address(page);
 
-       kpte = lookup_address(address);
+       kpte = lookup_address(address, &level);
        if (!kpte)
                return -EINVAL;
 
index 14ab327cde0c920d1ca8a8a4870fee2fae6d97c0..59cd066f67414faaa6abacedd9efb9c9aa131724 100644 (file)
@@ -14,7 +14,7 @@
 #include <asm/uaccess.h>
 #include <asm/io.h>
 
-pte_t *lookup_address(unsigned long address)
+pte_t *lookup_address(unsigned long address, int *level)
 {
        pgd_t *pgd = pgd_offset_k(address);
        pud_t *pud;
@@ -29,8 +29,10 @@ pte_t *lookup_address(unsigned long address)
        pmd = pmd_offset(pud, address);
        if (!pmd_present(*pmd))
                return NULL;
+       *level = 3;
        if (pmd_large(*pmd))
                return (pte_t *)pmd;
+       *level = 4;
 
        pte = pte_offset_kernel(pmd, address);
        if (pte && !pte_present(*pte))
@@ -140,8 +142,9 @@ __change_page_attr(unsigned long address, unsigned long pfn, pgprot_t prot,
        struct page *kpte_page;
        pgprot_t ref_prot2;
        pte_t *kpte;
+       int level;
 
-       kpte = lookup_address(address);
+       kpte = lookup_address(address, &level);
        if (!kpte)
                return 0;
 
index e6184735545f82ed5da6a2dc36b4f3a23ae6f492..45aa771e73a9221792f703e99c980ada406c8fa9 100644 (file)
@@ -58,7 +58,8 @@
 
 xmaddr_t arbitrary_virt_to_machine(unsigned long address)
 {
-       pte_t *pte = lookup_address(address);
+       int level;
+       pte_t *pte = lookup_address(address, &level);
        unsigned offset = address & PAGE_MASK;
 
        BUG_ON(pte == NULL);
@@ -70,8 +71,9 @@ void make_lowmem_page_readonly(void *vaddr)
 {
        pte_t *pte, ptev;
        unsigned long address = (unsigned long)vaddr;
+       int level;
 
-       pte = lookup_address(address);
+       pte = lookup_address(address, &level);
        BUG_ON(pte == NULL);
 
        ptev = pte_wrprotect(*pte);
@@ -84,8 +86,9 @@ void make_lowmem_page_readwrite(void *vaddr)
 {
        pte_t *pte, ptev;
        unsigned long address = (unsigned long)vaddr;
+       int level;
 
-       pte = lookup_address(address);
+       pte = lookup_address(address, &level);
        BUG_ON(pte == NULL);
 
        ptev = pte_mkwrite(*pte);
index eb8cccfa6a490eb12dc7e4ad38f467e89c33979e..9381bd37b9b1c268a81b141e73bad9ed5a508e5c 100644 (file)
@@ -182,7 +182,7 @@ static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
  * NOTE: the return type is pte_t but if the pmd is PSE then we return it
  * as a pte too.
  */
-extern pte_t *lookup_address(unsigned long address);
+extern pte_t *lookup_address(unsigned long address, int *level);
 
 /*
  * Make a given kernel text page executable/non-executable.
index 29fdeb8111bba2d761353e45aa1e945559d7c11e..139da50cd510d47c2ba88fff39a643952d76ee17 100644 (file)
@@ -240,7 +240,7 @@ extern struct list_head pgd_list;
 
 extern int kern_addr_valid(unsigned long addr); 
 
-pte_t *lookup_address(unsigned long addr);
+pte_t *lookup_address(unsigned long addr, int *level);
 
 #define io_remap_pfn_range(vma, vaddr, pfn, size, prot)                \
                remap_pfn_range(vma, vaddr, pfn, size, prot)