|
@@ -1034,30 +1034,41 @@ static inline int ptep_test_and_clear_user_young(struct mm_struct *mm,
|
|
|
|
|
|
static inline void __ptep_ipte(unsigned long address, pte_t *ptep)
|
|
|
{
|
|
|
- if (!(pte_val(*ptep) & _PAGE_INVALID)) {
|
|
|
+ unsigned long pto = (unsigned long) ptep;
|
|
|
+
|
|
|
#ifndef CONFIG_64BIT
|
|
|
- /* pto must point to the start of the segment table */
|
|
|
- pte_t *pto = (pte_t *) (((unsigned long) ptep) & 0x7ffffc00);
|
|
|
-#else
|
|
|
- /* ipte in zarch mode can do the math */
|
|
|
- pte_t *pto = ptep;
|
|
|
+ /* pto in ESA mode must point to the start of the segment table */
|
|
|
+ pto &= 0x7ffffc00;
|
|
|
#endif
|
|
|
- asm volatile(
|
|
|
- " ipte %2,%3"
|
|
|
- : "=m" (*ptep) : "m" (*ptep),
|
|
|
- "a" (pto), "a" (address));
|
|
|
- }
|
|
|
+ /* Invalidation + global TLB flush for the pte */
|
|
|
+ asm volatile(
|
|
|
+ " ipte %2,%3"
|
|
|
+ : "=m" (*ptep) : "m" (*ptep), "a" (pto), "a" (address));
|
|
|
+}
|
|
|
+
|
|
|
+static inline void ptep_flush_direct(struct mm_struct *mm,
|
|
|
+ unsigned long address, pte_t *ptep)
|
|
|
+{
|
|
|
+ if (pte_val(*ptep) & _PAGE_INVALID)
|
|
|
+ return;
|
|
|
+ __ptep_ipte(address, ptep);
|
|
|
}
|
|
|
|
|
|
static inline void ptep_flush_lazy(struct mm_struct *mm,
|
|
|
unsigned long address, pte_t *ptep)
|
|
|
{
|
|
|
- int active = (mm == current->active_mm) ? 1 : 0;
|
|
|
+ int active, count;
|
|
|
|
|
|
- if (atomic_read(&mm->context.attach_count) > active)
|
|
|
- __ptep_ipte(address, ptep);
|
|
|
- else
|
|
|
+ if (pte_val(*ptep) & _PAGE_INVALID)
|
|
|
+ return;
|
|
|
+ active = (mm == current->active_mm) ? 1 : 0;
|
|
|
+ count = atomic_add_return(0x10000, &mm->context.attach_count);
|
|
|
+ if ((count & 0xffff) <= active) {
|
|
|
+ pte_val(*ptep) |= _PAGE_INVALID;
|
|
|
mm->context.flush_mm = 1;
|
|
|
+ } else
|
|
|
+ __ptep_ipte(address, ptep);
|
|
|
+ atomic_sub(0x10000, &mm->context.attach_count);
|
|
|
}
|
|
|
|
|
|
#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
|
|
@@ -1074,7 +1085,7 @@ static inline int ptep_test_and_clear_young(struct vm_area_struct *vma,
|
|
|
}
|
|
|
|
|
|
pte = *ptep;
|
|
|
- __ptep_ipte(addr, ptep);
|
|
|
+ ptep_flush_direct(vma->vm_mm, addr, ptep);
|
|
|
young = pte_young(pte);
|
|
|
pte = pte_mkold(pte);
|
|
|
|
|
@@ -1145,7 +1156,6 @@ static inline pte_t ptep_modify_prot_start(struct mm_struct *mm,
|
|
|
|
|
|
pte = *ptep;
|
|
|
ptep_flush_lazy(mm, address, ptep);
|
|
|
- pte_val(*ptep) |= _PAGE_INVALID;
|
|
|
|
|
|
if (mm_has_pgste(mm)) {
|
|
|
pgste = pgste_update_all(&pte, pgste);
|
|
@@ -1182,7 +1192,7 @@ static inline pte_t ptep_clear_flush(struct vm_area_struct *vma,
|
|
|
}
|
|
|
|
|
|
pte = *ptep;
|
|
|
- __ptep_ipte(address, ptep);
|
|
|
+ ptep_flush_direct(vma->vm_mm, address, ptep);
|
|
|
pte_val(*ptep) = _PAGE_INVALID;
|
|
|
|
|
|
if (mm_has_pgste(vma->vm_mm)) {
|
|
@@ -1263,7 +1273,7 @@ static inline int ptep_set_access_flags(struct vm_area_struct *vma,
|
|
|
pgste = pgste_ipte_notify(vma->vm_mm, address, ptep, pgste);
|
|
|
}
|
|
|
|
|
|
- __ptep_ipte(address, ptep);
|
|
|
+ ptep_flush_direct(vma->vm_mm, address, ptep);
|
|
|
|
|
|
if (mm_has_pgste(vma->vm_mm)) {
|
|
|
pgste_set_pte(ptep, entry);
|
|
@@ -1447,12 +1457,16 @@ static inline pmd_t pmd_mkwrite(pmd_t pmd)
|
|
|
static inline void pmdp_flush_lazy(struct mm_struct *mm,
|
|
|
unsigned long address, pmd_t *pmdp)
|
|
|
{
|
|
|
- int active = (mm == current->active_mm) ? 1 : 0;
|
|
|
+ int active, count;
|
|
|
|
|
|
- if ((atomic_read(&mm->context.attach_count) & 0xffff) > active)
|
|
|
- __pmd_idte(address, pmdp);
|
|
|
- else
|
|
|
+ active = (mm == current->active_mm) ? 1 : 0;
|
|
|
+ count = atomic_add_return(0x10000, &mm->context.attach_count);
|
|
|
+ if ((count & 0xffff) <= active) {
|
|
|
+ pmd_val(*pmdp) |= _SEGMENT_ENTRY_INVALID;
|
|
|
mm->context.flush_mm = 1;
|
|
|
+ } else
|
|
|
+ __pmd_idte(address, pmdp);
|
|
|
+ atomic_sub(0x10000, &mm->context.attach_count);
|
|
|
}
|
|
|
|
|
|
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
|