1
/*********************************************************
2
* Copyright (C) 2002 VMware, Inc. All rights reserved.
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License as published by the
6
* Free Software Foundation version 2 and no later version.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13
* You should have received a copy of the GNU General Public License along
14
* with this program; if not, write to the Free Software Foundation, Inc.,
15
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
*********************************************************/
19
#ifndef __COMPAT_PGTABLE_H__
20
# define __COMPAT_PGTABLE_H__
23
#if defined(CONFIG_PARAVIRT) && defined(CONFIG_HIGHPTE)
24
# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 21)
25
# include <asm/paravirt.h>
26
# undef paravirt_map_pt_hook
27
# define paravirt_map_pt_hook(type, va, pfn) do {} while (0)
30
#include <asm/pgtable.h>
33
/* pte_page() API modified in 2.3.23 to return a struct page * --hpreg */
34
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 3, 23)
35
# define compat_pte_page pte_page
37
# include "compat_page.h"
39
# define compat_pte_page(_pte) virt_to_page(pte_page(_pte))
43
/* Appeared in 2.5.5 --hpreg */
44
#ifndef pte_offset_map
45
/* Appeared in SuSE 8.0's 2.4.18 --hpreg */
46
# ifdef pte_offset_atomic
47
# define pte_offset_map pte_offset_atomic
48
# define pte_unmap pte_kunmap
50
# define pte_offset_map pte_offset
51
# define pte_unmap(_pte)
56
/* Appeared in 2.5.74-mmX --petr */
57
#ifndef pmd_offset_map
58
# define pmd_offset_map(pgd, address) pmd_offset(pgd, address)
59
# define pmd_unmap(pmd)
64
* Appeared in 2.6.10-rc2-mm1. Older kernels did L4 page tables as
65
* part of pgd_offset, or they did not have L4 page tables at all.
66
* In 2.6.11 pml4 -> pgd -> pmd -> pte hierarchy was replaced by
67
* pgd -> pud -> pmd -> pte hierarchy.
70
# define compat_pgd_offset(mm, address) pgd_offset(mm, address)
71
# define compat_pgd_present(pgd) pgd_present(pgd)
72
# define compat_pud_offset(pgd, address) pud_offset(pgd, address)
73
# define compat_pud_present(pud) pud_present(pud)
74
typedef pgd_t compat_pgd_t;
75
typedef pud_t compat_pud_t;
76
#elif defined(pml4_offset)
77
# define compat_pgd_offset(mm, address) pml4_offset(mm, address)
78
# define compat_pgd_present(pml4) pml4_present(pml4)
79
# define compat_pud_offset(pml4, address) pml4_pgd_offset(pml4, address)
80
# define compat_pud_present(pgd) pgd_present(pgd)
81
typedef pml4_t compat_pgd_t;
82
typedef pgd_t compat_pud_t;
84
# define compat_pgd_offset(mm, address) pgd_offset(mm, address)
85
# define compat_pgd_present(pgd) pgd_present(pgd)
86
# define compat_pud_offset(pgd, address) (pgd)
87
# define compat_pud_present(pud) (1)
88
typedef pgd_t compat_pgd_t;
89
typedef pgd_t compat_pud_t;
93
#define compat_pgd_offset_k(mm, address) pgd_offset_k(address)
96
/* Introduced somewhere in 2.6.0, + backported to some 2.4 RedHat kernels */
97
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0) && !defined(pte_pfn)
98
# define pte_pfn(pte) page_to_pfn(compat_pte_page(pte))
102
/* A page_table_lock field is added to struct mm_struct in 2.3.10 --hpreg */
103
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 3, 10)
104
# define compat_get_page_table_lock(_mm) (&(_mm)->page_table_lock)
106
# define compat_get_page_table_lock(_mm) NULL
111
* Define VM_PAGE_KERNEL_EXEC for vmapping executable pages.
113
* On ia32 PAGE_KERNEL_EXEC was introduced in 2.6.8.1. Unfortunately it accesses
114
* __PAGE_KERNEL_EXEC which is not exported for modules. So we use
115
* __PAGE_KERNEL and just cut _PAGE_NX bit from it.
117
* For ia32 kernels before 2.6.8.1 we use PAGE_KERNEL directly, these kernels
118
* do not have noexec support.
120
* On x86-64 situation is a bit better: they always supported noexec, but
121
* before 2.6.8.1 flag was named PAGE_KERNEL_EXECUTABLE, and it was renamed
122
* to PAGE_KERNEL_EXEC when ia32 got noexec too (see above).
126
#define VM_PAGE_KERNEL_EXEC __pgprot(__PAGE_KERNEL & ~_PAGE_NX)
128
#define VM_PAGE_KERNEL_EXEC PAGE_KERNEL
131
#ifdef PAGE_KERNEL_EXECUTABLE
132
#define VM_PAGE_KERNEL_EXEC PAGE_KERNEL_EXECUTABLE
134
#define VM_PAGE_KERNEL_EXEC PAGE_KERNEL_EXEC
139
#endif /* __COMPAT_PGTABLE_H__ */