linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hugh Dickins <hughd@google.com>
To: maobibo <maobibo@loongson.cn>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
	"Thomas Bogendoerfer" <tsbogend@alpha.franken.de>,
	"Jiaxun Yang" <jiaxun.yang@flygoat.com>,
	"Huacai Chen" <chenhc@lemote.com>,
	"Paul Burton" <paulburton@kernel.org>,
	"Dmitry Korotin" <dkorotin@wavecomp.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Stafford Horne" <shorne@gmail.com>,
	"Steven Price" <steven.price@arm.com>,
	"Anshuman Khandual" <anshuman.khandual@arm.com>,
	linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Mike Rapoport" <rppt@linux.ibm.com>,
	"Sergei Shtylyov" <sergei.shtylyov@cogentembedded.com>,
	"Maciej W. Rozycki" <macro@wdc.com>,
	linux-mm@kvack.org, "David Hildenbrand" <david@redhat.com>
Subject: Re: [PATCH v3 3/3] mm/memory.c: Add memory read privilege before filling PTE entry
Date: Wed, 27 May 2020 13:55:18 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LSU.2.11.2005271329050.6217@eggly.anvils> (raw)
In-Reply-To: <d1646320-51ec-4b5f-bcad-41eba85b78cf@loongson.cn>

On Tue, 19 May 2020, maobibo wrote:
> On 05/19/2020 04:57 AM, Andrew Morton wrote:
> > On Mon, 18 May 2020 13:08:49 +0800 Bibo Mao <maobibo@loongson.cn> wrote:
> > 
> >> On mips platform, hw PTE entry valid bit is set in pte_mkyoung
> >> function, it is used to set physical page with readable privilege.
> > 
> > pte_mkyoung() seems to be a strange place to set the pte's valid bit. 
> > Why is it done there?  Can it be done within mips's mk_pte()?
> On MIPS system hardware cannot set PAGE_ACCESS bit when accessing the page,
> software sets PAGE_ACCESS software bit and PAGE_VALID hw bit together during page
> fault stage.
> 
> If mk_pte is called in page fault flow, it is ok to set both bits. If it is not 
> called in page fault, PAGE_ACCESS is set however there is no actual memory accessing.

Sorry for joining in so late, but would you please explain that some more:
preferably in the final commit message, if not here.

I still don't understand why this is not done in the same way as on other
architectures - those that care (I just checked x86, powerpc, arm, arm64,
but not all of them) make sure that all the bits they want are there in
mm/mmap.c's protection_map[16], which then feeds into vma->vm_page_prot,
and so into mk_pte() as Andrew indicated.

And I can see that arch/mips/mm/cache.c has a setup_protection_map()
to do that: why does it not set the additional bits that you want?
including the valid bit and the accessed (young) bit, as others do.
Are you saying that there are circumstances in which it is wrong
for mk_pte() to set the additional bits?

I'm afraid that generic mm developers will have no clue as to whether
or not to add a pte_sw_mkyoung() after a mk_pte(); and generic source
will be the cleaner if it turns out not to be needed (but thank you
for making sure that it does nothing on the other architectures).

Hugh

  parent reply	other threads:[~2020-05-27 20:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-18  5:08 [PATCH v3 1/3] MIPS: Do not flush tlb page when updating PTE entry Bibo Mao
2020-05-18  5:08 ` [PATCH v3 2/3] mm/memory.c: Update local TLB if PTE entry exists Bibo Mao
2020-05-18  5:08 ` [PATCH v3 3/3] mm/memory.c: Add memory read privilege before filling PTE entry Bibo Mao
2020-05-18 20:57   ` Andrew Morton
2020-05-19  3:22     ` maobibo
2020-05-19  3:34       ` Andrew Morton
2020-05-27 20:55       ` Hugh Dickins [this message]
2020-05-28  4:33         ` maobibo

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=alpine.LSU.2.11.2005271329050.6217@eggly.anvils \
    --to=hughd@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=anshuman.khandual@arm.com \
    --cc=chenhc@lemote.com \
    --cc=david@redhat.com \
    --cc=dkorotin@wavecomp.com \
    --cc=f4bug@amsat.org \
    --cc=jiaxun.yang@flygoat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=macro@wdc.com \
    --cc=maobibo@loongson.cn \
    --cc=paulburton@kernel.org \
    --cc=rppt@linux.ibm.com \
    --cc=sergei.shtylyov@cogentembedded.com \
    --cc=shorne@gmail.com \
    --cc=steven.price@arm.com \
    --cc=tsbogend@alpha.franken.de \
    /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).