linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Pingfan Liu <kernelfans@gmail.com>
Cc: Ard Biesheuvel <ardb@kernel.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	Will Deacon <will@kernel.org>, Marc Zyngier <maz@kernel.org>,
	Kristina Martsenko <kristina.martsenko@arm.com>,
	James Morse <james.morse@arm.com>,
	Steven Price <steven.price@arm.com>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>,
	Pavel Tatashin <pasha.tatashin@soleen.com>,
	Anshuman Khandual <anshuman.khandual@arm.com>,
	Atish Patra <atish.patra@wdc.com>,
	Mike Rapoport <rppt@kernel.org>,
	Logan Gunthorpe <logang@deltatee.com>,
	Mark Brown <broonie@kernel.org>
Subject: Re: [PATCHv3 0/5] use __create_pgd_mapping() to implement idmap and unify codes
Date: Tue, 8 Jun 2021 18:38:07 +0100	[thread overview]
Message-ID: <20210608173806.GA10662@arm.com> (raw)
In-Reply-To: <CAFgQCTv0yf_dn0a0Ci09_HnCk7p-DyJUhONJHp9BmNek+Jr7dQ@mail.gmail.com>

On Tue, Jun 01, 2021 at 05:25:49PM +0800, Pingfan Liu wrote:
> On Tue, Jun 1, 2021 at 3:50 AM Ard Biesheuvel <ardb@kernel.org> wrote:
> > On Mon, 31 May 2021 at 10:46, Pingfan Liu <kernelfans@gmail.com> wrote:
> > > v2 -> v3:
> > >   -1. leave out the part of redefinition the CONFIG_PGTABLE_LEVEL,
> > > concentrate on sharing __create_pgd_mapping() in head.S as the first
> > > step.
> > >   -2. make IDMAP_PGTABLE_LEVELS use the max value ([3/5])
> > >
> > > rfc -> v2:
> > >   more debug and test
> > >
> > > *** Goal of this series ***
> > >
> > > __create_pgd_mapping() sets up the pgtable for mapping __va(paddr) ->
> > > paddr under the MMU-on situation.  Since pgtable upper level holds the
> > > paddr of the lower level, with a slight adaptation,
> > > __create_pgd_mapping() can also set up the mapping under the MMU-off
> > > situation. ([4/5])
> > >
> > > After that, both idmap_pg_dir and init_pg_dir can be created by
> > > __create_pgd_mapping(). And the counterpart asm code can be simplified.
> >
> > I understand the desire to simplify the page table construction code
> > in head.S, but up until now, we have been very careful to avoid
> > calling into C code with the MMU off. There are simply too many
> > assumptions in the compiler about the context the generated code will
> > execute in: one example is unaligned access, which must be disabled
> > for source files that may be called with the MMU off, as otherwise,
> > the compiler is permitted to emit loads and stores that are not
> > allowed on device memory (which is the default memory type used for
> > all memory with the MMU off)
>
> You are right. These C routines happen to use "unsigned long", which
> can exclude this unaligned case.
> To make an guarantee, is "-mno-unaligned-access" good enough?
> 
> Besides unaligned-access, any further risk originating from compiler
> assumption? (I think that the common optimization: reordering,
> merging, reloading on this "device" memory has no bad effect)

There's also instrumentation that needs disabling (kasan, ubsan, kcov,
gcov). You can look at arch/arm64/kvm/hyp/nvhe/Makefile for various
flags added or filtered out, though the KVM hyp code runs with the MMU
on. I'm not sure what other flags are needed to guarantee the generated
code can run with the MMU off but we can always ask the toolchain folk.

However, I'm still not convinced about sharing __create_pgd_mapping()
with the early head.S code. A better option would be a separate,
stand-alone file where we have more control on what gets called or
accessed (of course, if there's any value in going this route).

> > Do you have a killer use case for this feature? Or is it just a nice cleanup?
>
> Yes, in the omitted part in v2, I had planned to provide an unified
> page table manipulation routine, and provide an create_idmap() API. So
> there can be an handy interface to create a whole RAM addressable
> idmapX where needed.

Where would this be needed?

-- 
Catalin

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-06-08 17:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-31  8:45 [PATCHv3 0/5] use __create_pgd_mapping() to implement idmap and unify codes Pingfan Liu
2021-05-31  8:45 ` [PATCHv3 1/5] arm64/mm: introduce pgtable allocator for idmap_pg_dir and init_pg_dir Pingfan Liu
2021-05-31  8:45 ` [PATCHv3 2/5] arm64/mm: disable WARN_ON() and BUG_ON() in __create_pgd_mapping() if too early Pingfan Liu
2021-05-31  8:45 ` [PATCHv3 3/5] arm64/mm: unconditionally set IDMAP_PGTABLE_LEVELS to max pgtable level Pingfan Liu
2021-05-31  8:45 ` [PATCHv3 4/5] arm64/mm: make __create_pgd_mapping() capable to handle pgtable's paddr Pingfan Liu
2021-05-31  8:45 ` [PATCHv3 5/5] arm64/mm: use __create_pgd_mapping() to create pgtable for idmap_pg_dir and init_pg_dir Pingfan Liu
2021-05-31 19:50 ` [PATCHv3 0/5] use __create_pgd_mapping() to implement idmap and unify codes Ard Biesheuvel
2021-06-01  9:25   ` Pingfan Liu
2021-06-08 17:38     ` Catalin Marinas [this message]
2021-06-09  9:25       ` Pingfan Liu

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=20210608173806.GA10662@arm.com \
    --to=catalin.marinas@arm.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=anshuman.khandual@arm.com \
    --cc=ardb@kernel.org \
    --cc=atish.patra@wdc.com \
    --cc=broonie@kernel.org \
    --cc=james.morse@arm.com \
    --cc=kernelfans@gmail.com \
    --cc=kristina.martsenko@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=logang@deltatee.com \
    --cc=maz@kernel.org \
    --cc=pasha.tatashin@soleen.com \
    --cc=rppt@kernel.org \
    --cc=steven.price@arm.com \
    --cc=will@kernel.org \
    /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).