2005-04-16 22:20:36 +00:00
|
|
|
#ifndef _I386_PAGE_H
|
|
|
|
#define _I386_PAGE_H
|
|
|
|
|
|
|
|
/* PAGE_SHIFT determines the page size */
|
|
|
|
#define PAGE_SHIFT 12
|
|
|
|
#define PAGE_SIZE (1UL << PAGE_SHIFT)
|
|
|
|
#define PAGE_MASK (~(PAGE_SIZE-1))
|
|
|
|
|
|
|
|
#define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1))
|
|
|
|
#define LARGE_PAGE_SIZE (1UL << PMD_SHIFT)
|
|
|
|
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
|
2008-01-30 12:31:09 +00:00
|
|
|
#include <linux/string.h>
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#ifdef CONFIG_X86_USE_3DNOW
|
|
|
|
|
|
|
|
#include <asm/mmx.h>
|
|
|
|
|
2008-01-30 12:31:09 +00:00
|
|
|
static inline void clear_page(void *page)
|
|
|
|
{
|
|
|
|
mmx_clear_page(page);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void copy_page(void *to, void *from)
|
|
|
|
{
|
|
|
|
mmx_copy_page(to, from);
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
/*
|
|
|
|
* On older X86 processors it's not a win to use MMX here it seems.
|
|
|
|
* Maybe the K6-III ?
|
|
|
|
*/
|
|
|
|
|
2008-01-30 12:31:09 +00:00
|
|
|
static inline void clear_page(void *page)
|
|
|
|
{
|
|
|
|
memset(page, 0, PAGE_SIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void copy_page(void *to, void *from)
|
|
|
|
{
|
|
|
|
memcpy(to, from, PAGE_SIZE);
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2008-01-30 12:31:09 +00:00
|
|
|
struct page;
|
|
|
|
|
|
|
|
static void inline clear_user_page(void *page, unsigned long vaddr,
|
|
|
|
struct page *pg)
|
|
|
|
{
|
|
|
|
clear_page(page);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void inline copy_user_page(void *to, void *from, unsigned long vaddr,
|
|
|
|
struct page *topage)
|
|
|
|
{
|
|
|
|
copy_page(to, from);
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-07-17 11:03:05 +00:00
|
|
|
#define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \
|
|
|
|
alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr)
|
2005-04-16 22:20:36 +00:00
|
|
|
#define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
|
|
|
|
|
|
|
|
/*
|
|
|
|
* These are used to make use of C type-checking..
|
|
|
|
*/
|
|
|
|
extern int nx_enabled;
|
2007-05-02 17:27:13 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#ifdef CONFIG_X86_PAE
|
|
|
|
typedef struct { unsigned long pte_low, pte_high; } pte_t;
|
|
|
|
typedef struct { unsigned long long pmd; } pmd_t;
|
|
|
|
typedef struct { unsigned long long pgd; } pgd_t;
|
|
|
|
typedef struct { unsigned long long pgprot; } pgprot_t;
|
2007-05-02 17:27:13 +00:00
|
|
|
|
|
|
|
static inline unsigned long long native_pgd_val(pgd_t pgd)
|
|
|
|
{
|
|
|
|
return pgd.pgd;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned long long native_pmd_val(pmd_t pmd)
|
|
|
|
{
|
|
|
|
return pmd.pmd;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned long long native_pte_val(pte_t pte)
|
|
|
|
{
|
|
|
|
return pte.pte_low | ((unsigned long long)pte.pte_high << 32);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline pgd_t native_make_pgd(unsigned long long val)
|
|
|
|
{
|
|
|
|
return (pgd_t) { val };
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline pmd_t native_make_pmd(unsigned long long val)
|
|
|
|
{
|
|
|
|
return (pmd_t) { val };
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline pte_t native_make_pte(unsigned long long val)
|
|
|
|
{
|
|
|
|
return (pte_t) { .pte_low = val, .pte_high = (val >> 32) } ;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef CONFIG_PARAVIRT
|
|
|
|
#define pmd_val(x) native_pmd_val(x)
|
|
|
|
#define __pmd(x) native_make_pmd(x)
|
|
|
|
#endif
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#define HPAGE_SHIFT 21
|
2006-12-07 01:14:08 +00:00
|
|
|
#include <asm-generic/pgtable-nopud.h>
|
2007-05-02 17:27:13 +00:00
|
|
|
#else /* !CONFIG_X86_PAE */
|
2005-04-16 22:20:36 +00:00
|
|
|
typedef struct { unsigned long pte_low; } pte_t;
|
|
|
|
typedef struct { unsigned long pgd; } pgd_t;
|
|
|
|
typedef struct { unsigned long pgprot; } pgprot_t;
|
|
|
|
#define boot_pte_t pte_t /* or would you rather have a typedef */
|
2007-05-02 17:27:13 +00:00
|
|
|
|
|
|
|
static inline unsigned long native_pgd_val(pgd_t pgd)
|
|
|
|
{
|
|
|
|
return pgd.pgd;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned long native_pte_val(pte_t pte)
|
|
|
|
{
|
|
|
|
return pte.pte_low;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline pgd_t native_make_pgd(unsigned long val)
|
|
|
|
{
|
|
|
|
return (pgd_t) { val };
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline pte_t native_make_pte(unsigned long val)
|
|
|
|
{
|
|
|
|
return (pte_t) { .pte_low = val };
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#define HPAGE_SHIFT 22
|
2006-12-07 01:14:08 +00:00
|
|
|
#include <asm-generic/pgtable-nopmd.h>
|
2007-05-02 17:27:13 +00:00
|
|
|
#endif /* CONFIG_X86_PAE */
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#define PTE_MASK PAGE_MASK
|
|
|
|
|
|
|
|
#ifdef CONFIG_HUGETLB_PAGE
|
|
|
|
#define HPAGE_SIZE ((1UL) << HPAGE_SHIFT)
|
|
|
|
#define HPAGE_MASK (~(HPAGE_SIZE - 1))
|
|
|
|
#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
|
|
|
|
#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define pgprot_val(x) ((x).pgprot)
|
|
|
|
#define __pgprot(x) ((pgprot_t) { (x) } )
|
|
|
|
|
2007-05-02 17:27:13 +00:00
|
|
|
#ifndef CONFIG_PARAVIRT
|
|
|
|
#define pgd_val(x) native_pgd_val(x)
|
|
|
|
#define __pgd(x) native_make_pgd(x)
|
|
|
|
#define pte_val(x) native_pte_val(x)
|
|
|
|
#define __pte(x) native_make_pte(x)
|
|
|
|
#endif
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif /* !__ASSEMBLY__ */
|
|
|
|
|
|
|
|
/* to align the pointer to the (next) page boundary */
|
|
|
|
#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This handles the memory map.. We could make this a config
|
|
|
|
* option, but too many people screw it up, and too few need
|
|
|
|
* it.
|
|
|
|
*
|
|
|
|
* A __PAGE_OFFSET of 0xC0000000 means that the kernel has
|
|
|
|
* a virtual address space of one gigabyte, which limits the
|
|
|
|
* amount of physical memory you can use to about 950MB.
|
|
|
|
*
|
|
|
|
* If you want more physical memory than this then see the CONFIG_HIGHMEM4G
|
|
|
|
* and CONFIG_HIGHMEM64G options in the kernel configuration.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
|
[PATCH] vdso: randomize the i386 vDSO by moving it into a vma
Move the i386 VDSO down into a vma and thus randomize it.
Besides the security implications, this feature also helps debuggers, which
can COW a vma-backed VDSO just like a normal DSO and can thus do
single-stepping and other debugging features.
It's good for hypervisors (Xen, VMWare) too, which typically live in the same
high-mapped address space as the VDSO, hence whenever the VDSO is used, they
get lots of guest pagefaults and have to fix such guest accesses up - which
slows things down instead of speeding things up (the primary purpose of the
VDSO).
There's a new CONFIG_COMPAT_VDSO (default=y) option, which provides support
for older glibcs that still rely on a prelinked high-mapped VDSO. Newer
distributions (using glibc 2.3.3 or later) can turn this option off. Turning
it off is also recommended for security reasons: attackers cannot use the
predictable high-mapped VDSO page as syscall trampoline anymore.
There is a new vdso=[0|1] boot option as well, and a runtime
/proc/sys/vm/vdso_enabled sysctl switch, that allows the VDSO to be turned
on/off.
(This version of the VDSO-randomization patch also has working ELF
coredumping, the previous patch crashed in the coredumping code.)
This code is a combined work of the exec-shield VDSO randomization
code and Gerd Hoffmann's hypervisor-centric VDSO patch. Rusty Russell
started this patch and i completed it.
[akpm@osdl.org: cleanups]
[akpm@osdl.org: compile fix]
[akpm@osdl.org: compile fix 2]
[akpm@osdl.org: compile fix 3]
[akpm@osdl.org: revernt MAXMEM change]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Arjan van de Ven <arjan@infradead.org>
Cc: Gerd Hoffmann <kraxel@suse.de>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Zachary Amsden <zach@vmware.com>
Cc: Andi Kleen <ak@muc.de>
Cc: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-27 09:53:50 +00:00
|
|
|
struct vm_area_struct;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* This much address space is reserved for vmalloc() and iomap()
|
|
|
|
* as well as fixmap mappings.
|
|
|
|
*/
|
|
|
|
extern unsigned int __VMALLOC_RESERVE;
|
|
|
|
|
|
|
|
extern int sysctl_legacy_va_layout;
|
|
|
|
|
2005-06-23 07:07:41 +00:00
|
|
|
extern int page_is_ram(unsigned long pagenr);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
|
|
|
|
#ifdef __ASSEMBLY__
|
2006-02-01 11:06:11 +00:00
|
|
|
#define __PAGE_OFFSET CONFIG_PAGE_OFFSET
|
2005-04-16 22:20:36 +00:00
|
|
|
#else
|
2006-02-01 11:06:11 +00:00
|
|
|
#define __PAGE_OFFSET ((unsigned long)CONFIG_PAGE_OFFSET)
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET)
|
|
|
|
#define VMALLOC_RESERVE ((unsigned long)__VMALLOC_RESERVE)
|
|
|
|
#define MAXMEM (-__PAGE_OFFSET-__VMALLOC_RESERVE)
|
|
|
|
#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
|
2006-12-07 01:14:03 +00:00
|
|
|
/* __pa_symbol should be used for C visible symbols.
|
|
|
|
This seems to be the official gcc blessed way to do such arithmetic. */
|
|
|
|
#define __pa_symbol(x) __pa(RELOC_HIDE((unsigned long)(x),0))
|
2005-04-16 22:20:36 +00:00
|
|
|
#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
|
|
|
|
#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
|
2005-06-23 07:07:57 +00:00
|
|
|
#ifdef CONFIG_FLATMEM
|
2005-04-16 22:20:36 +00:00
|
|
|
#define pfn_valid(pfn) ((pfn) < max_mapnr)
|
2005-06-23 07:07:57 +00:00
|
|
|
#endif /* CONFIG_FLATMEM */
|
2005-04-16 22:20:36 +00:00
|
|
|
#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
|
|
|
|
|
|
|
|
#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
|
|
|
|
|
|
|
|
#define VM_DATA_DEFAULT_FLAGS \
|
|
|
|
(VM_READ | VM_WRITE | \
|
|
|
|
((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
|
|
|
|
VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
|
|
|
|
|
2006-03-27 09:15:33 +00:00
|
|
|
#include <asm-generic/memory_model.h>
|
2005-09-03 22:54:30 +00:00
|
|
|
#include <asm-generic/page.h>
|
|
|
|
|
[PATCH] vdso: randomize the i386 vDSO by moving it into a vma
Move the i386 VDSO down into a vma and thus randomize it.
Besides the security implications, this feature also helps debuggers, which
can COW a vma-backed VDSO just like a normal DSO and can thus do
single-stepping and other debugging features.
It's good for hypervisors (Xen, VMWare) too, which typically live in the same
high-mapped address space as the VDSO, hence whenever the VDSO is used, they
get lots of guest pagefaults and have to fix such guest accesses up - which
slows things down instead of speeding things up (the primary purpose of the
VDSO).
There's a new CONFIG_COMPAT_VDSO (default=y) option, which provides support
for older glibcs that still rely on a prelinked high-mapped VDSO. Newer
distributions (using glibc 2.3.3 or later) can turn this option off. Turning
it off is also recommended for security reasons: attackers cannot use the
predictable high-mapped VDSO page as syscall trampoline anymore.
There is a new vdso=[0|1] boot option as well, and a runtime
/proc/sys/vm/vdso_enabled sysctl switch, that allows the VDSO to be turned
on/off.
(This version of the VDSO-randomization patch also has working ELF
coredumping, the previous patch crashed in the coredumping code.)
This code is a combined work of the exec-shield VDSO randomization
code and Gerd Hoffmann's hypervisor-centric VDSO patch. Rusty Russell
started this patch and i completed it.
[akpm@osdl.org: cleanups]
[akpm@osdl.org: compile fix]
[akpm@osdl.org: compile fix 2]
[akpm@osdl.org: compile fix 3]
[akpm@osdl.org: revernt MAXMEM change]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Arjan van de Ven <arjan@infradead.org>
Cc: Gerd Hoffmann <kraxel@suse.de>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Zachary Amsden <zach@vmware.com>
Cc: Andi Kleen <ak@muc.de>
Cc: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-27 09:53:50 +00:00
|
|
|
#define __HAVE_ARCH_GATE_AREA 1
|
2006-04-27 14:48:08 +00:00
|
|
|
#endif /* __KERNEL__ */
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif /* _I386_PAGE_H */
|