linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: leroy christophe <christophe.leroy@c-s.fr>
To: Scott Wood <scottwood@freescale.com>
Cc: Paul Mackerras <paulus@samba.org>,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [v4,17/21] powerpc/8xx: set PTE bit 22 off TLBmiss
Date: Fri, 07 Nov 2014 09:00:46 +0100	[thread overview]
Message-ID: <545C7C2E.3060109@c-s.fr> (raw)
In-Reply-To: <20141107033745.GA23796@home.buserror.net>


Le 07/11/2014 04:37, Scott Wood a écrit :
> On Fri, Sep 19, 2014 at 10:36:09AM +0200, LEROY Christophe wrote:
>> No need to re-set this bit at each TLB miss. Let's set it in the PTE.
>>
>> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
>> ---
>> Changes in v2:
>> - None
>>
>> Changes in v3:
>> - Removed PPC405 related macro from PPC8xx specific code
>> - PTE_NONE_MASK doesn't need PAGE_ACCESSED in Linux 2.6
>>
>> Changes in v4:
>> - None
>>
>>   arch/powerpc/include/asm/pgtable-ppc32.h | 20 ++++++++++++++++++++
>>   arch/powerpc/include/asm/pte-8xx.h       |  7 +++++--
>>   arch/powerpc/kernel/head_8xx.S           | 10 ++--------
>>   3 files changed, 27 insertions(+), 10 deletions(-)
>>
>> diff --git a/arch/powerpc/include/asm/pgtable-ppc32.h b/arch/powerpc/include/asm/pgtable-ppc32.h
>> index 47edde8..35a9b44 100644
>> --- a/arch/powerpc/include/asm/pgtable-ppc32.h
>> +++ b/arch/powerpc/include/asm/pgtable-ppc32.h
>> @@ -172,6 +172,25 @@ static inline unsigned long pte_update(pte_t *p,
>>   #ifdef PTE_ATOMIC_UPDATES
>>   	unsigned long old, tmp;
>>   
>> +#ifdef CONFIG_PPC_8xx
>> +	unsigned long tmp2;
>> +
>> +	__asm__ __volatile__("\
>> +1:	lwarx	%0,0,%4\n\
>> +	andc	%1,%0,%5\n\
>> +	or	%1,%1,%6\n\
>> +	/* 0x200 == Extended encoding, bit 22 */ \
>> +	/* Bit 22 has to be 1 if neither _PAGE_USER nor _PAGE_RW are set */ \
>> +	rlwimi	%1,%1,32-2,0x200\n /* get _PAGE_USER */ \
>> +	rlwinm	%3,%1,32-1,0x200\n /* get _PAGE_RW */ \
>> +	or	%1,%3,%1\n\
>> +	xori	%1,%1,0x200\n"
>> +"	stwcx.	%1,0,%4\n\
>> +	bne-	1b"
> Why do you need this...
>
>> diff --git a/arch/powerpc/include/asm/pte-8xx.h b/arch/powerpc/include/asm/pte-8xx.h
>> index d44826e..daa4616 100644
>> --- a/arch/powerpc/include/asm/pte-8xx.h
>> +++ b/arch/powerpc/include/asm/pte-8xx.h
>> @@ -48,19 +48,22 @@
>>    */
>>   #define _PAGE_RW	0x0400	/* lsb PP bits, inverted in HW */
>>   #define _PAGE_USER	0x0800	/* msb PP bits */
>> +/* set when neither _PAGE_USER nor _PAGE_RW are set */
>> +#define _PAGE_KNLRO	0x0200
>>   
>>   #define _PMD_PRESENT	0x0001
>>   #define _PMD_BAD	0x0ff0
>>   #define _PMD_PAGE_MASK	0x000c
>>   #define _PMD_PAGE_8M	0x000c
>>   
>> -#define _PTE_NONE_MASK _PAGE_ACCESSED
>> +#define _PTE_NONE_MASK _PAGE_KNLRO
>>   
>>   /* Until my rework is finished, 8xx still needs atomic PTE updates */
>>   #define PTE_ATOMIC_UPDATES	1
>>   
>>   /* We need to add _PAGE_SHARED to kernel pages */
>> -#define _PAGE_KERNEL_RO	(_PAGE_SHARED)
>> +#define _PAGE_KERNEL_RO	(_PAGE_SHARED | _PAGE_KNLRO)
>> +#define _PAGE_KERNEL_ROX	(_PAGE_EXEC | _PAGE_KNLRO)
>>   #define _PAGE_KERNEL_RW	(_PAGE_DIRTY | _PAGE_RW | _PAGE_HWWRITE)
> ...if 0x200 is already being set in the PTE here?
>
If I understand well the way it works, those defines are used for 
setting the PTE the first time.
Then, pte_update() is used to modify the pte settings on an existing pte

0x200 must be set when and only when the page is a RO kernel page. If 
later on pte_update() is called for instance to set the page to RW, the 
0x200 has to be removed. Same, if pte_update() is called to remove 
_PAGE_RW (ptep_set_wrprotect() does this), 0x200 must be set back.

Christophe

  reply	other threads:[~2014-11-07  8:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-19  8:36 [PATCH v4 17/21] powerpc/8xx: set PTE bit 22 off TLBmiss Christophe Leroy
2014-11-07  3:37 ` [v4,17/21] " Scott Wood
2014-11-07  8:00   ` leroy christophe [this message]
2014-11-08  0:08     ` Scott Wood
2014-11-18 20:07       ` christophe leroy
2014-11-26  1:58         ` Scott Wood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=545C7C2E.3060109@c-s.fr \
    --to=christophe.leroy@c-s.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=paulus@samba.org \
    --cc=scottwood@freescale.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).