From: KAMEZAWA Hiroyuki * add pte_present_exec_user() * remove pte_user * fixed comments. Signed-off-by: KAMEZAWA Hiroyuki Cc: "Luck, Tony" Cc: Christoph Lameter Cc: Hugh Dickins Cc: Nick Piggin Signed-off-by: Andrew Morton --- include/asm-ia64/pgtable.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff -puN include/asm-ia64/pgtable.h~flush-icache-before-set_pte-on-ia64-flush-icache-at-set_pte-fix-update include/asm-ia64/pgtable.h --- a/include/asm-ia64/pgtable.h~flush-icache-before-set_pte-on-ia64-flush-icache-at-set_pte-fix-update +++ a/include/asm-ia64/pgtable.h @@ -297,7 +297,6 @@ ia64_phys_addr_valid (unsigned long addr /* * The following have defined behavior only work if pte_present() is true. */ -#define pte_user(pte) ((pte_val(pte) & _PAGE_PL_MASK) == _PAGE_PL_3) #define pte_write(pte) ((unsigned) (((pte_val(pte) & _PAGE_AR_MASK) >> _PAGE_AR_SHIFT) - 2) <= 4) #define pte_exec(pte) ((pte_val(pte) & _PAGE_AR_RX) != 0) #define pte_dirty(pte) ((pte_val(pte) & _PAGE_D) != 0) @@ -324,14 +323,20 @@ ia64_phys_addr_valid (unsigned long addr * set_pte() is also called by the kernel, but we can expect that the kernel * flushes icache explicitly if necessary. */ +#define pte_present_exec_user(pte)\ + ((pte_val(pte) & (_PAGE_P | _PAGE_PL_MASK | _PAGE_AR_RX)) == \ + (_PAGE_P | _PAGE_PL_3 | _PAGE_AR_RX)) + extern void __ia64_sync_icache_dcache(pte_t pteval); static inline void set_pte(pte_t *ptep, pte_t pteval) { - if (pte_present(pteval) &&// swap out ? - pte_exec(pteval) && // flush only new executable page. - pte_user(pteval) && // ignore kernel page - (!pte_present(*ptep) ||// do_no_page or swap in, migration, - pte_pfn(*ptep) != pte_pfn(pteval))) // do_wp_page(), page copy + /* page is present && page is user && page is executable + * && (page swapin or new page or page migraton + * || copy_on_write with page copying.) + */ + if (pte_present_exec_user(pteval) && + (!pte_present(*ptep) || + pte_pfn(*ptep) != pte_pfn(pteval))) /* load_module() calles flush_icache_range() explicitly*/ __ia64_sync_icache_dcache(pteval); *ptep = pteval; _