mbox series

[00/10] arm64: mm: Use __create_pgd_mapping_locked() in

Message ID 20240313125711.20651-1-piliu@redhat.com (mailing list archive)
Headers show
Series arm64: mm: Use __create_pgd_mapping_locked() in | expand

Message

Pingfan Liu March 13, 2024, 12:56 p.m. UTC
Hi everybody, I tried this stuff again. Last time when I tried this,
Catalin raised concern about the intrumentation, and Ard doubted this
way due to alignement issue with mmu-off.

Last time, the alignment issue looked unsoluable and I gave up.  But
nowadays, when I looked at it, I think it is partially resovable.  (for
detail, please see the commit log in [PATCH 08/10] arm64: mm: Enforce
memory alignment in mmu_head)

Overall, at this very early stage, the using of C routines faces three
challenge:
  PIC
  instrumentation
  alignment

[2/10] resolves instrumentation issue

[3/10] makes mmu_head self-contained and prevent the outside
PIC/ instrumentation/ alignment issues from seeping in. And check the code PIC.

[PATCH 08/10] explains the alignement issue, in theory, it can be
checked and resolved. And in this patch, it is partially resolved.


Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
To: linux-arm-kernel@lists.infradead.org
---

Pingfan Liu (10):
  arm64: mm: Split out routines for code reuse
  arm64: mm: Introduce mmu_head routines without instrumentation
  arm64: mm: Use if-conditon to truncate external dependency
  arm64: head: Enable __create_pgd_mapping() to handle pgtable's paddr
  arm64: mm: Force early mapping aligned on SWAPPER_BLOCK_SIZE
  arm64: mm: Handle scope beyond the capacity of kernel pgtable in
    mmu_head_create_pgd_mapping()
  arm64: mm: Introduce head_pool routines to enable pgtabl allocation
  arm64: mm: Enforce memory alignment in mmu_head
  arm64: head: Use __create_pgd_mapping_locked() to serve the creation
    of pgtable
  arm64: head: Clean up unneeded routines

 arch/arm64/include/asm/kernel-pgtable.h |   1 +
 arch/arm64/include/asm/mmu.h            |   4 +
 arch/arm64/include/asm/pgtable.h        |  11 +-
 arch/arm64/kernel/head.S                | 314 +++++++-----------------
 arch/arm64/mm/Makefile                  |  22 +-
 arch/arm64/mm/mmu.c                     | 289 +---------------------
 arch/arm64/mm/mmu_head.c                | 134 ++++++++++
 arch/arm64/mm/mmu_inc.c                 | 292 ++++++++++++++++++++++
 8 files changed, 558 insertions(+), 509 deletions(-)
 create mode 100644 arch/arm64/mm/mmu_head.c
 create mode 100644 arch/arm64/mm/mmu_inc.c

Comments

Ard Biesheuvel March 13, 2024, 1:05 p.m. UTC | #1
Hello Pingfan,

On Wed, 13 Mar 2024 at 13:57, Pingfan Liu <piliu@redhat.com> wrote:
>
> Hi everybody, I tried this stuff again.

Tried what again? Frankly, I have no idea what the purpose of this
patch series is, and this is v1.

Could you please explain?

Also, the early arm64 startup code is changing substantially - please refer to

https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git/log/?h=for-next/stage1-lpa2

for details.

> Last time when I tried this,
> Catalin raised concern about the intrumentation, and Ard doubted this
> way due to alignement issue with mmu-off.
>
> Last time, the alignment issue looked unsoluable and I gave up.  But
> nowadays, when I looked at it, I think it is partially resovable.  (for
> detail, please see the commit log in [PATCH 08/10] arm64: mm: Enforce
> memory alignment in mmu_head)
>
> Overall, at this very early stage, the using of C routines faces three
> challenge:
>   PIC
>   instrumentation
>   alignment
>
> [2/10] resolves instrumentation issue
>
> [3/10] makes mmu_head self-contained and prevent the outside
> PIC/ instrumentation/ alignment issues from seeping in. And check the code PIC.
>
> [PATCH 08/10] explains the alignement issue, in theory, it can be
> checked and resolved. And in this patch, it is partially resolved.
>
>
> Cc: Ard Biesheuvel <ardb@kernel.org>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: Mark Rutland <mark.rutland@arm.com>
> To: linux-arm-kernel@lists.infradead.org
> ---
>
> Pingfan Liu (10):
>   arm64: mm: Split out routines for code reuse
>   arm64: mm: Introduce mmu_head routines without instrumentation
>   arm64: mm: Use if-conditon to truncate external dependency
>   arm64: head: Enable __create_pgd_mapping() to handle pgtable's paddr
>   arm64: mm: Force early mapping aligned on SWAPPER_BLOCK_SIZE
>   arm64: mm: Handle scope beyond the capacity of kernel pgtable in
>     mmu_head_create_pgd_mapping()
>   arm64: mm: Introduce head_pool routines to enable pgtabl allocation
>   arm64: mm: Enforce memory alignment in mmu_head
>   arm64: head: Use __create_pgd_mapping_locked() to serve the creation
>     of pgtable
>   arm64: head: Clean up unneeded routines
>
>  arch/arm64/include/asm/kernel-pgtable.h |   1 +
>  arch/arm64/include/asm/mmu.h            |   4 +
>  arch/arm64/include/asm/pgtable.h        |  11 +-
>  arch/arm64/kernel/head.S                | 314 +++++++-----------------
>  arch/arm64/mm/Makefile                  |  22 +-
>  arch/arm64/mm/mmu.c                     | 289 +---------------------
>  arch/arm64/mm/mmu_head.c                | 134 ++++++++++
>  arch/arm64/mm/mmu_inc.c                 | 292 ++++++++++++++++++++++
>  8 files changed, 558 insertions(+), 509 deletions(-)
>  create mode 100644 arch/arm64/mm/mmu_head.c
>  create mode 100644 arch/arm64/mm/mmu_inc.c
>
> --
> 2.41.0
>
Pingfan Liu March 14, 2024, 2:54 a.m. UTC | #2
On Wed, Mar 13, 2024 at 9:05 PM Ard Biesheuvel <ardb@kernel.org> wrote:
>
> Hello Pingfan,
>
> On Wed, 13 Mar 2024 at 13:57, Pingfan Liu <piliu@redhat.com> wrote:
> >
> > Hi everybody, I tried this stuff again.
>
> Tried what again? Frankly, I have no idea what the purpose of this
> patch series is, and this is v1.
>

Sorry that I should paste the original link for the history:
https://lore.kernel.org/all/20210531084540.78546-1-kernelfans@gmail.com/

> Could you please explain?
>

It is about calling the C routine of  __create_pgd_mapping() at the
stage of mmu-off.

> Also, the early arm64 startup code is changing substantially - please refer to
>
> https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git/log/?h=for-next/stage1-lpa2
>
> for details.
>

Oh, it seems that most of the ideas in my series have been
implemented.  I will dive it for more detail.

Thank you very much.


Regards,

Pingfan

> > Last time when I tried this,
> > Catalin raised concern about the intrumentation, and Ard doubted this
> > way due to alignement issue with mmu-off.
> >
> > Last time, the alignment issue looked unsoluable and I gave up.  But
> > nowadays, when I looked at it, I think it is partially resovable.  (for
> > detail, please see the commit log in [PATCH 08/10] arm64: mm: Enforce
> > memory alignment in mmu_head)
> >
> > Overall, at this very early stage, the using of C routines faces three
> > challenge:
> >   PIC
> >   instrumentation
> >   alignment
> >
> > [2/10] resolves instrumentation issue
> >
> > [3/10] makes mmu_head self-contained and prevent the outside
> > PIC/ instrumentation/ alignment issues from seeping in. And check the code PIC.
> >
> > [PATCH 08/10] explains the alignement issue, in theory, it can be
> > checked and resolved. And in this patch, it is partially resolved.
> >
> >
> > Cc: Ard Biesheuvel <ardb@kernel.org>
> > Cc: Catalin Marinas <catalin.marinas@arm.com>
> > Cc: Will Deacon <will@kernel.org>
> > Cc: Mark Rutland <mark.rutland@arm.com>
> > To: linux-arm-kernel@lists.infradead.org
> > ---
> >
> > Pingfan Liu (10):
> >   arm64: mm: Split out routines for code reuse
> >   arm64: mm: Introduce mmu_head routines without instrumentation
> >   arm64: mm: Use if-conditon to truncate external dependency
> >   arm64: head: Enable __create_pgd_mapping() to handle pgtable's paddr
> >   arm64: mm: Force early mapping aligned on SWAPPER_BLOCK_SIZE
> >   arm64: mm: Handle scope beyond the capacity of kernel pgtable in
> >     mmu_head_create_pgd_mapping()
> >   arm64: mm: Introduce head_pool routines to enable pgtabl allocation
> >   arm64: mm: Enforce memory alignment in mmu_head
> >   arm64: head: Use __create_pgd_mapping_locked() to serve the creation
> >     of pgtable
> >   arm64: head: Clean up unneeded routines
> >
> >  arch/arm64/include/asm/kernel-pgtable.h |   1 +
> >  arch/arm64/include/asm/mmu.h            |   4 +
> >  arch/arm64/include/asm/pgtable.h        |  11 +-
> >  arch/arm64/kernel/head.S                | 314 +++++++-----------------
> >  arch/arm64/mm/Makefile                  |  22 +-
> >  arch/arm64/mm/mmu.c                     | 289 +---------------------
> >  arch/arm64/mm/mmu_head.c                | 134 ++++++++++
> >  arch/arm64/mm/mmu_inc.c                 | 292 ++++++++++++++++++++++
> >  8 files changed, 558 insertions(+), 509 deletions(-)
> >  create mode 100644 arch/arm64/mm/mmu_head.c
> >  create mode 100644 arch/arm64/mm/mmu_inc.c
> >
> > --
> > 2.41.0
> >
>
Catalin Marinas March 14, 2024, 5:25 p.m. UTC | #3
On Thu, Mar 14, 2024 at 10:54:12AM +0800, Pingfan Liu wrote:
> On Wed, Mar 13, 2024 at 9:05 PM Ard Biesheuvel <ardb@kernel.org> wrote:
> > Also, the early arm64 startup code is changing substantially - please refer to
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git/log/?h=for-next/stage1-lpa2
> >
> > for details.
> 
> Oh, it seems that most of the ideas in my series have been
> implemented.  I will dive it for more detail.

Yeah, better post after 6.9-rc1 when this stuff will land.