aboutsummaryrefslogtreecommitdiffstats
path: root/manual/PRESENTATION_ExSyn
diff options
context:
space:
mode:
Diffstat (limited to 'manual/PRESENTATION_ExSyn')
0 files changed, 0 insertions, 0 deletions
='n41' href='#n41'>41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
#ifndef _X86_64_PGALLOC_H
#define _X86_64_PGALLOC_H

#include <asm/processor.h>
#include <asm/fixmap.h>
#include <asm/pda.h>
#include <linux/threads.h>
#include <linux/mm.h>
#include <asm/io.h>		/* for phys_to_virt and page_to_pseudophys */

void make_page_readonly(void *va);
void make_page_writable(void *va);
void make_pages_readonly(void *va, unsigned int nr);
void make_pages_writable(void *va, unsigned int nr);

#define __user_pgd(pgd) ((pgd) + PTRS_PER_PGD)

static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte)
{
	set_pmd(pmd, __pmd(_PAGE_TABLE | __pa(pte)));
}

static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *pte)
{
	set_pmd(pmd, __pmd(_PAGE_TABLE | (page_to_pfn(pte) << PAGE_SHIFT)));
}

static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
{
	set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
}

/*
 * We need to use the batch mode here, but pgd_pupulate() won't be
 * be called frequently.
 */
static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
{
        set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
        set_pgd(__user_pgd(pgd), __pgd(_PAGE_TABLE | __pa(pud)));
}

extern __inline__ pmd_t *get_pmd(void)
{
        pmd_t *pmd = (pmd_t *)get_zeroed_page(GFP_KERNEL);
        if (!pmd)
		return NULL;
        make_page_readonly(pmd);
        xen_pmd_pin(__pa(pmd));
	return pmd;
}

extern __inline__ void pmd_free(pmd_t *pmd)
{
	BUG_ON((unsigned long)pmd & (PAGE_SIZE-1));
        xen_pmd_unpin(__pa(pmd));
        make_page_writable(pmd);
	free_page((unsigned long)pmd);
}

static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
{
        pmd_t *pmd = (pmd_t *) get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
        if (!pmd)
		return NULL;
        make_page_readonly(pmd);
        xen_pmd_pin(__pa(pmd)); 
        return pmd;
}

static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
{
        pud_t *pud = (pud_t *) get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
        if (!pud)
		return NULL;
        make_page_readonly(pud);
        xen_pud_pin(__pa(pud)); 
        return pud;
}

static inline void pud_free(pud_t *pud)