diff for duplicates of <1310725418.2586.309.camel@twins> diff --git a/a/1.txt b/N1/1.txt index a17c72c..c84e571 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -1,20 +1,16 @@ On Fri, 2011-07-15 at 16:07 +0800, Shan Hai wrote: -> The kernel has no write permission on COW pages by default on e500 core, = -this -> will cause endless loop in futex_lock_pi, because futex code assumes the = -kernel -> has write permission on COW pages. Grant write permission to the kernel o= -n COW +> The kernel has no write permission on COW pages by default on e500 core, this +> will cause endless loop in futex_lock_pi, because futex code assumes the kernel +> has write permission on COW pages. Grant write permission to the kernel on COW > pages when access violation page fault occurs. ->=20 +> > Signed-off-by: Shan Hai <haishan.bai@gmail.com> > --- > arch/powerpc/include/asm/futex.h | 11 ++++++++++- > arch/powerpc/include/asm/tlb.h | 25 +++++++++++++++++++++++++ > 2 files changed, 35 insertions(+), 1 deletions(-) ->=20 -> diff --git a/arch/powerpc/include/asm/futex.h b/arch/powerpc/include/asm/= -futex.h +> +> diff --git a/arch/powerpc/include/asm/futex.h b/arch/powerpc/include/asm/futex.h > index c94e4a3..54c3e74 100644 > --- a/arch/powerpc/include/asm/futex.h > +++ b/arch/powerpc/include/asm/futex.h @@ -23,37 +19,34 @@ futex.h > #include <asm/synch.h> > #include <asm/asm-compat.h> > +#include <asm/tlb.h> -> =20 +> > #define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \ > __asm__ __volatile ( \ -> @@ -113,7 +114,15 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user = -*uaddr, +> @@ -113,7 +114,15 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, > : "cc", "memory"); -> =20 -> *uval =3D prev; +> +> *uval = prev; > - return ret; > + > + /* Futex assumes the kernel has permission to write to > + * COW pages, grant the kernel write permission on COW > + * pages because it has none by default. > + */ -> + if (ret =3D=3D -EFAULT) +> + if (ret == -EFAULT) > + __tlb_fixup_write_permission(current->mm, (unsigned long)uaddr); > + > + return ret; > } -> =20 +> > #endif /* __KERNEL__ */ -> diff --git a/arch/powerpc/include/asm/tlb.h b/arch/powerpc/include/asm/tl= -b.h +> diff --git a/arch/powerpc/include/asm/tlb.h b/arch/powerpc/include/asm/tlb.h > index e2b428b..3863c6a 100644 > --- a/arch/powerpc/include/asm/tlb.h > +++ b/arch/powerpc/include/asm/tlb.h -> @@ -45,5 +45,30 @@ static inline void __tlb_remove_tlb_entry(struct mmu_g= -ather *tlb, pte_t *ptep, +> @@ -45,5 +45,30 @@ static inline void __tlb_remove_tlb_entry(struct mmu_gather *tlb, pte_t *ptep, > #endif > } -> =20 +> > +/* Grant write permission to the kernel on a page. */ > +static inline void __tlb_fixup_write_permission(struct mm_struct *mm, > + unsigned long address) @@ -68,7 +61,7 @@ ather *tlb, pte_t *ptep, > + > + struct vm_area_struct *vma; > + -> + vma =3D find_vma(mm, address); +> + vma = find_vma(mm, address); Uhm, find_vma() needs mmap_sem, and futex_atomic_cmpxchg_inatomic() is most certainly not called with that lock held. @@ -79,7 +72,7 @@ most certainly not called with that lock held. > + handle_mm_fault(mm, vma, address, FAULT_FLAG_WRITE); So how can this toggle your sw dirty/young tracking, that's pretty much -what gup(.write=3D1) does too! +what gup(.write=1) does too! > + flush_tlb_page(vma, address); > + } diff --git a/a/content_digest b/N1/content_digest index 499a5ea..029fa17 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -4,34 +4,31 @@ "Subject\0Re: [PATCH 1/1] Fixup write permission of TLB on powerpc e500 core\0" "Date\0Fri, 15 Jul 2011 12:23:38 +0200\0" "To\0Shan Hai <haishan.bai@gmail.com>\0" - "Cc\0tony.luck@intel.com" - linux-kernel@vger.kernel.org - cmetcalf@tilera.com - dhowells@redhat.com + "Cc\0benh@kernel.crashing.org" paulus@samba.org tglx@linutronix.de walken@google.com + dhowells@redhat.com + cmetcalf@tilera.com + tony.luck@intel.com + akpm@linux-foundation.org linuxppc-dev@lists.ozlabs.org - " akpm@linux-foundation.org\0" + " linux-kernel@vger.kernel.org\0" "\00:1\0" "b\0" "On Fri, 2011-07-15 at 16:07 +0800, Shan Hai wrote:\n" - "> The kernel has no write permission on COW pages by default on e500 core, =\n" - "this\n" - "> will cause endless loop in futex_lock_pi, because futex code assumes the =\n" - "kernel\n" - "> has write permission on COW pages. Grant write permission to the kernel o=\n" - "n COW\n" + "> The kernel has no write permission on COW pages by default on e500 core, this\n" + "> will cause endless loop in futex_lock_pi, because futex code assumes the kernel\n" + "> has write permission on COW pages. Grant write permission to the kernel on COW\n" "> pages when access violation page fault occurs.\n" - ">=20\n" + "> \n" "> Signed-off-by: Shan Hai <haishan.bai@gmail.com>\n" "> ---\n" "> arch/powerpc/include/asm/futex.h | 11 ++++++++++-\n" "> arch/powerpc/include/asm/tlb.h | 25 +++++++++++++++++++++++++\n" "> 2 files changed, 35 insertions(+), 1 deletions(-)\n" - ">=20\n" - "> diff --git a/arch/powerpc/include/asm/futex.h b/arch/powerpc/include/asm/=\n" - "futex.h\n" + "> \n" + "> diff --git a/arch/powerpc/include/asm/futex.h b/arch/powerpc/include/asm/futex.h\n" "> index c94e4a3..54c3e74 100644\n" "> --- a/arch/powerpc/include/asm/futex.h\n" "> +++ b/arch/powerpc/include/asm/futex.h\n" @@ -40,37 +37,34 @@ "> #include <asm/synch.h>\n" "> #include <asm/asm-compat.h>\n" "> +#include <asm/tlb.h>\n" - "> =20\n" + "> \n" "> #define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \\\n" "> __asm__ __volatile ( \\\n" - "> @@ -113,7 +114,15 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user =\n" - "*uaddr,\n" + "> @@ -113,7 +114,15 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,\n" "> : \"cc\", \"memory\");\n" - "> =20\n" - "> \t*uval =3D prev;\n" + "> \n" + "> \t*uval = prev;\n" "> - return ret;\n" "> +\n" "> +\t/* Futex assumes the kernel has permission to write to\n" "> +\t * COW pages, grant the kernel write permission on COW\n" "> +\t * pages because it has none by default.\n" "> +\t */\n" - "> +\tif (ret =3D=3D -EFAULT)\n" + "> +\tif (ret == -EFAULT)\n" "> +\t\t__tlb_fixup_write_permission(current->mm, (unsigned long)uaddr);\n" "> +\n" "> +\treturn ret;\n" "> }\n" - "> =20\n" + "> \n" "> #endif /* __KERNEL__ */\n" - "> diff --git a/arch/powerpc/include/asm/tlb.h b/arch/powerpc/include/asm/tl=\n" - "b.h\n" + "> diff --git a/arch/powerpc/include/asm/tlb.h b/arch/powerpc/include/asm/tlb.h\n" "> index e2b428b..3863c6a 100644\n" "> --- a/arch/powerpc/include/asm/tlb.h\n" "> +++ b/arch/powerpc/include/asm/tlb.h\n" - "> @@ -45,5 +45,30 @@ static inline void __tlb_remove_tlb_entry(struct mmu_g=\n" - "ather *tlb, pte_t *ptep,\n" + "> @@ -45,5 +45,30 @@ static inline void __tlb_remove_tlb_entry(struct mmu_gather *tlb, pte_t *ptep,\n" "> #endif\n" "> }\n" - "> =20\n" + "> \n" "> +/* Grant write permission to the kernel on a page. */\n" "> +static inline void __tlb_fixup_write_permission(struct mm_struct *mm,\n" "> +\t\t\t\t\t\tunsigned long address)\n" @@ -85,7 +79,7 @@ "> +\n" "> +\tstruct vm_area_struct *vma;\n" "> +\n" - "> +\tvma =3D find_vma(mm, address);\n" + "> +\tvma = find_vma(mm, address);\n" "\n" "Uhm, find_vma() needs mmap_sem, and futex_atomic_cmpxchg_inatomic() is\n" "most certainly not called with that lock held.\n" @@ -96,7 +90,7 @@ "> +\t\t\thandle_mm_fault(mm, vma, address, FAULT_FLAG_WRITE);\n" "\n" "So how can this toggle your sw dirty/young tracking, that's pretty much\n" - "what gup(.write=3D1) does too!\n" + "what gup(.write=1) does too!\n" "\n" "> +\t\t\tflush_tlb_page(vma, address);\n" "> +\t\t}\n" @@ -107,4 +101,4 @@ "> #endif /* __KERNEL__ */\n" > #endif /* __ASM_POWERPC_TLB_H */ -9ec865806271c3bf4cfbbadb3329e15bc12519bad8b09cb49c0ee60500941d68 +645bfbc8c2f2a5e5e6fad277b557bb861faad3a072aa1623ef5a2d9b05e269aa
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.