| 1 |
/* |
| 2 |
* This file is subject to the terms and conditions of the GNU General Public |
| 3 |
* License. See the file "COPYING" in the main directory of this archive |
| 4 |
* for more details. |
| 5 |
* |
| 6 |
* Copyright (C) 2008, 2009 Cavium Networks, Inc. |
| 7 |
*/ |
| 8 |
|
| 9 |
#ifndef __ASM_HUGETLB_H |
| 10 |
#define __ASM_HUGETLB_H |
| 11 |
|
| 12 |
#include <asm/page.h> |
| 13 |
|
| 14 |
#define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEAR |
| 15 |
static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm, |
| 16 |
unsigned long addr, pte_t *ptep, |
| 17 |
unsigned long sz) |
| 18 |
{ |
| 19 |
pte_t clear; |
| 20 |
pte_t pte = *ptep; |
| 21 |
|
| 22 |
pte_val(clear) = (unsigned long)invalid_pte_table; |
| 23 |
set_pte_at(mm, addr, ptep, clear); |
| 24 |
return pte; |
| 25 |
} |
| 26 |
|
| 27 |
#define __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH |
| 28 |
static inline pte_t huge_ptep_clear_flush(struct vm_area_struct *vma, |
| 29 |
unsigned long addr, pte_t *ptep) |
| 30 |
{ |
| 31 |
pte_t pte; |
| 32 |
unsigned long sz = huge_page_size(hstate_vma(vma)); |
| 33 |
|
| 34 |
/* |
| 35 |
* clear the huge pte entry firstly, so that the other smp threads will |
| 36 |
* not get old pte entry after finishing flush_tlb_page and before |
| 37 |
* setting new huge pte entry |
| 38 |
*/ |
| 39 |
pte = huge_ptep_get_and_clear(vma->vm_mm, addr, ptep, sz); |
| 40 |
flush_tlb_page(vma, addr); |
| 41 |
return pte; |
| 42 |
} |
| 43 |
|
| 44 |
#define __HAVE_ARCH_HUGE_PTE_NONE |
| 45 |
static inline int huge_pte_none(pte_t pte) |
| 46 |
{ |
| 47 |
unsigned long val = pte_val(pte) & ~_PAGE_GLOBAL; |
| 48 |
return !val || (val == (unsigned long)invalid_pte_table); |
| 49 |
} |
| 50 |
|
| 51 |
#define __HAVE_ARCH_HUGE_PTEP_SET_ACCESS_FLAGS |
| 52 |
static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma, |
| 53 |
unsigned long addr, |
| 54 |
pte_t *ptep, pte_t pte, |
| 55 |
int dirty) |
| 56 |
{ |
| 57 |
int changed = !pte_same(*ptep, pte); |
| 58 |
|
| 59 |
if (changed) { |
| 60 |
set_pte_at(vma->vm_mm, addr, ptep, pte); |
| 61 |
/* |
| 62 |
* There could be some standard sized pages in there, |
| 63 |
* get them all. |
| 64 |
*/ |
| 65 |
flush_tlb_range(vma, addr, addr + HPAGE_SIZE); |
| 66 |
} |
| 67 |
return changed; |
| 68 |
} |
| 69 |
|
| 70 |
#include <asm-generic/hugetlb.h> |
| 71 |
|
| 72 |
#endif /* __ASM_HUGETLB_H */ |