* [PATCH 2/4] powerpc32: properly clear page table when 0 is not a good default PTE value
@ 2014-12-10 18:00 Christophe Leroy
2014-12-11 0:07 ` Scott Wood
0 siblings, 1 reply; 2+ messages in thread
From: Christophe Leroy @ 2014-12-10 18:00 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
scottwood
Cc: linuxppc-dev, linux-kernel
Some HW invert some PTE bits. In some case, __pte(0) is not 0 so the PTEs shall
be properly set prior to being used.
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/mm/pgtable_32.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
index a349089..71a2821 100644
--- a/arch/powerpc/mm/pgtable_32.c
+++ b/arch/powerpc/mm/pgtable_32.c
@@ -96,6 +96,14 @@ void pgd_free(struct mm_struct *mm, pgd_t *pgd)
#endif
}
+static inline void pte_alloc_clear(pte_t *pte)
+{
+ int i;
+
+ for (i = 0; i < PTRS_PER_PTE; i++)
+ pte[i] = __pte(0);
+}
+
__init_refok pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
{
pte_t *pte;
@@ -109,18 +117,24 @@ __init_refok pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long add
if (pte)
clear_page(pte);
}
+ if (pte && !pte_none(*pte))
+ pte_alloc_clear(pte);
return pte;
}
pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address)
{
struct page *ptepage;
+ pte_t *pte;
gfp_t flags = GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO;
ptepage = alloc_pages(flags, 0);
if (!ptepage)
return NULL;
+ pte = (pte_t *)pfn_to_kaddr(page_to_pfn(ptepage));
+ if (!pte_none(*pte))
+ pte_alloc_clear(pte);
if (!pgtable_page_ctor(ptepage)) {
__free_page(ptepage);
return NULL;
--
2.1.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 2/4] powerpc32: properly clear page table when 0 is not a good default PTE value
2014-12-10 18:00 [PATCH 2/4] powerpc32: properly clear page table when 0 is not a good default PTE value Christophe Leroy
@ 2014-12-11 0:07 ` Scott Wood
0 siblings, 0 replies; 2+ messages in thread
From: Scott Wood @ 2014-12-11 0:07 UTC (permalink / raw)
To: Christophe Leroy; +Cc: linuxppc-dev, Paul Mackerras, linux-kernel
On Wed, 2014-12-10 at 19:00 +0100, Christophe Leroy wrote:
> Some HW invert some PTE bits. In some case, __pte(0) is not 0 so the PTEs shall
> be properly set prior to being used.
__pte(0) is always zero. If that changes in a future patch, that patch
is not doing the right thing. The __pte()/pte_val() accesors should not
do anything beyond boxing/unboxing the value in a struct. The right
place for special 8xx handling of the inverted bit is in pte_mkwrite()
and such.
I don't see any other architecture using __pte()/pte_val() this way.
-Scott
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-12-11 0:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-10 18:00 [PATCH 2/4] powerpc32: properly clear page table when 0 is not a good default PTE value Christophe Leroy
2014-12-11 0:07 ` Scott Wood
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).