~n-muench/ubuntu/oneiric/open-vm-tools/open-vm-tools.fix-836277

« back to all changes in this revision

Viewing changes to modules/linux/vmci/compat_pgtable.h

  • Committer: Bazaar Package Importer
  • Author(s): Devid Antonio Filoni
  • Date: 2008-08-15 21:21:40 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080815212140-05fhxj8wroosysmj
Tags: 2008.08.08-109361-1ubuntu1
* Merge from Debian unstable (LP: #258393), remaining Ubuntu change:
  - add ubuntu_toolchain_FTBFS.dpatch patch, fix FTBFS
* Update ubuntu_toolchain_FTBFS.dpatch patch for the new version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*********************************************************
 
2
 * Copyright (C) 2002 VMware, Inc. All rights reserved.
 
3
 *
 
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.
 
7
 *
 
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
 
11
 * for more details.
 
12
 *
 
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
 
16
 *
 
17
 *********************************************************/
 
18
 
 
19
#ifndef __COMPAT_PGTABLE_H__
 
20
#   define __COMPAT_PGTABLE_H__
 
21
 
 
22
 
 
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)
 
28
#   endif
 
29
#endif
 
30
#include <asm/pgtable.h>
 
31
 
 
32
 
 
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
 
36
#else
 
37
#   include "compat_page.h"
 
38
 
 
39
#   define compat_pte_page(_pte) virt_to_page(pte_page(_pte))
 
40
#endif
 
41
 
 
42
 
 
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
 
49
#   else
 
50
#      define pte_offset_map pte_offset
 
51
#      define pte_unmap(_pte)
 
52
#   endif
 
53
#endif
 
54
 
 
55
 
 
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)
 
60
#endif
 
61
 
 
62
 
 
63
/*
 
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.
 
68
 */
 
69
#ifdef PUD_MASK
 
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;
 
83
#else
 
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;
 
90
#endif
 
91
 
 
92
 
 
93
#define compat_pgd_offset_k(mm, address) pgd_offset_k(address)
 
94
 
 
95
 
 
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))
 
99
#endif
 
100
 
 
101
 
 
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)
 
105
#else
 
106
#   define compat_get_page_table_lock(_mm) NULL
 
107
#endif
 
108
 
 
109
 
 
110
/*
 
111
 * Define VM_PAGE_KERNEL_EXEC for vmapping executable pages.
 
112
 *
 
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.
 
116
 *
 
117
 * For ia32 kernels before 2.6.8.1 we use PAGE_KERNEL directly, these kernels
 
118
 * do not have noexec support.
 
119
 *
 
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).
 
123
 */
 
124
#ifdef CONFIG_X86
 
125
#ifdef _PAGE_NX
 
126
#define VM_PAGE_KERNEL_EXEC __pgprot(__PAGE_KERNEL & ~_PAGE_NX)
 
127
#else
 
128
#define VM_PAGE_KERNEL_EXEC PAGE_KERNEL
 
129
#endif
 
130
#else
 
131
#ifdef PAGE_KERNEL_EXECUTABLE
 
132
#define VM_PAGE_KERNEL_EXEC PAGE_KERNEL_EXECUTABLE
 
133
#else
 
134
#define VM_PAGE_KERNEL_EXEC PAGE_KERNEL_EXEC
 
135
#endif
 
136
#endif
 
137
 
 
138
 
 
139
#endif /* __COMPAT_PGTABLE_H__ */