# Re: \[PATCH v2 2/4\] powerpc: Fixes for CONFIG\_PTE\_64BIT for SMP support

- From: Becky Bruce \<hidden\>
- Date: 2008-08-29 15:50:31 
- List: linuxppc-dev
- Page: https://ratatoskr.run/linuxppc-dev/2008/08/9444844
- Thread: https://ratatoskr.run/linuxppc-dev/2008/08/9444836/t.md

```text

On Aug 29, 2008, at 8:56 AM, Kumar Gala wrote:

> There are some minor issues with support 64-bit PTEs on a 32-bit processor
> when dealing with SMP.
>
> * We need to order the stores in set_pte_at to make sure the flag word
>  is set second.
> * Change pte_clear to use pte_update so only the flag word is cleared
>
> Signed-off-by: Kumar Gala <redacted>

>
> ---
> arch/powerpc/include/asm/pgtable-ppc32.h |   14 ++++++++++----
> 1 files changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/pgtable-ppc32.h b/arch/powerpc/include/asm/pgtable-ppc32.h
> index 6fe39e3..db2e7bd 100644
> --- a/arch/powerpc/include/asm/pgtable-ppc32.h
> +++ b/arch/powerpc/include/asm/pgtable-ppc32.h
> @@ -517,7 +517,7 @@ extern unsigned long bad_call_to_PMD_PAGE_SIZE(void);
>
> #define pte_none(pte)		((pte_val(pte) & ~_PTE_NONE_MASK) == 0)
> #define pte_present(pte)	(pte_val(pte) & _PAGE_PRESENT)
> -#define pte_clear(mm,addr,ptep)	do { set_pte_at((mm), (addr), (ptep), __pte(0)); } while (0)
> +#define pte_clear(mm,addr,ptep)	do { pte_update(ptep, ~0, 0); } while (0)
>
> #define pmd_none(pmd)		(!pmd_val(pmd))
> #define	pmd_bad(pmd)		(pmd_val(pmd) & _PMD_BAD)
> @@ -612,9 +612,6 @@ static inline unsigned long pte_update(pte_t *p,
> 	return old;
> }
> #else /* CONFIG_PTE_64BIT */
> -/* TODO: Change that to only modify the low word and move set_pte_at()
> - * out of line
> - */
> static inline unsigned long long pte_update(pte_t *p,
> 					    unsigned long clr,
> 					    unsigned long set)
> @@ -658,8 +655,17 @@ static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
> #if _PAGE_HASHPTE != 0
> 	pte_update(ptep, ~_PAGE_HASHPTE, pte_val(pte) & ~_PAGE_HASHPTE);
> #else
> +#if defined(CONFIG_PTE_64BIT) && defined(CONFIG_SMP)
> +	__asm__ __volatile__("\
> +		stw%U0%X0 %2,%0\n\
> +		eieio\n\
> +		stw%U0%X0 %L2,%1"
> +	: "=m" (*ptep), "=m" (*((unsigned char *)ptep+4))
> +	: "r" (pte) : "memory");

I know it's a nit, but can you put the clobber on a new line?  I totally missed it the first time I read this, and got all worked up about it :)

Cheers,
B
```
