mbox series

[0/3] Move kernel mapping outside the linear mapping

Message ID 20210225080453.1314-1-alex@ghiti.fr (mailing list archive)
Headers show
Series Move kernel mapping outside the linear mapping | expand

Message

Alexandre Ghiti Feb. 25, 2021, 8:04 a.m. UTC
I decided to split sv48 support in small series to ease the review.

This patchset pushes the kernel mapping (modules and BPF too) to the last
4GB of the 64bit address space, this allows to:
- implement relocatable kernel (that will come later in another
  patchset) that requires to move the kernel mapping out of the linear
  mapping to avoid to copy the kernel at a different physical address.
- have a single kernel that is not relocatable (and then that avoids the
  performance penalty imposed by PIC kernel) for both sv39 and sv48.

The first patch implements this behaviour, the second patch introduces a
documentation that describes the virtual address space layout of the 64bit
kernel and the last patch is taken from my sv48 series where I simply added
the dump of the modules/kernel/BPF mapping.

I removed the Reviewed-by on the first patch since it changed enough from
last time and deserves a second look.

Alexandre Ghiti (3):
  riscv: Move kernel mapping outside of linear mapping
  Documentation: riscv: Add documentation that describes the VM layout
  riscv: Prepare ptdump for vm layout dynamic addresses

 Documentation/riscv/index.rst       |  1 +
 Documentation/riscv/vm-layout.rst   | 61 ++++++++++++++++++++++
 arch/riscv/boot/loader.lds.S        |  3 +-
 arch/riscv/include/asm/page.h       | 18 ++++++-
 arch/riscv/include/asm/pgtable.h    | 37 +++++++++----
 arch/riscv/include/asm/set_memory.h |  1 +
 arch/riscv/kernel/head.S            |  3 +-
 arch/riscv/kernel/module.c          |  6 +--
 arch/riscv/kernel/setup.c           |  3 ++
 arch/riscv/kernel/vmlinux.lds.S     |  3 +-
 arch/riscv/mm/fault.c               | 13 +++++
 arch/riscv/mm/init.c                | 81 +++++++++++++++++++++++------
 arch/riscv/mm/kasan_init.c          |  9 ++++
 arch/riscv/mm/physaddr.c            |  2 +-
 arch/riscv/mm/ptdump.c              | 67 +++++++++++++++++++-----
 15 files changed, 258 insertions(+), 50 deletions(-)
 create mode 100644 Documentation/riscv/vm-layout.rst

Comments

Palmer Dabbelt March 10, 2021, 2:54 a.m. UTC | #1
On Thu, 25 Feb 2021 00:04:50 PST (-0800), alex@ghiti.fr wrote:
> I decided to split sv48 support in small series to ease the review.
>
> This patchset pushes the kernel mapping (modules and BPF too) to the last
> 4GB of the 64bit address space, this allows to:
> - implement relocatable kernel (that will come later in another
>   patchset) that requires to move the kernel mapping out of the linear
>   mapping to avoid to copy the kernel at a different physical address.
> - have a single kernel that is not relocatable (and then that avoids the
>   performance penalty imposed by PIC kernel) for both sv39 and sv48.
>
> The first patch implements this behaviour, the second patch introduces a
> documentation that describes the virtual address space layout of the 64bit
> kernel and the last patch is taken from my sv48 series where I simply added
> the dump of the modules/kernel/BPF mapping.
>
> I removed the Reviewed-by on the first patch since it changed enough from
> last time and deserves a second look.
>
> Alexandre Ghiti (3):
>   riscv: Move kernel mapping outside of linear mapping
>   Documentation: riscv: Add documentation that describes the VM layout
>   riscv: Prepare ptdump for vm layout dynamic addresses
>
>  Documentation/riscv/index.rst       |  1 +
>  Documentation/riscv/vm-layout.rst   | 61 ++++++++++++++++++++++
>  arch/riscv/boot/loader.lds.S        |  3 +-
>  arch/riscv/include/asm/page.h       | 18 ++++++-
>  arch/riscv/include/asm/pgtable.h    | 37 +++++++++----
>  arch/riscv/include/asm/set_memory.h |  1 +
>  arch/riscv/kernel/head.S            |  3 +-
>  arch/riscv/kernel/module.c          |  6 +--
>  arch/riscv/kernel/setup.c           |  3 ++
>  arch/riscv/kernel/vmlinux.lds.S     |  3 +-
>  arch/riscv/mm/fault.c               | 13 +++++
>  arch/riscv/mm/init.c                | 81 +++++++++++++++++++++++------
>  arch/riscv/mm/kasan_init.c          |  9 ++++
>  arch/riscv/mm/physaddr.c            |  2 +-
>  arch/riscv/mm/ptdump.c              | 67 +++++++++++++++++++-----
>  15 files changed, 258 insertions(+), 50 deletions(-)
>  create mode 100644 Documentation/riscv/vm-layout.rst

This generally looks good, but I'm getting a bunch of checkpatch warnings and 
some conflicts, do you mind fixing those up (and including your other kasan 
patch, as that's likely to conflict)?
Alexandre Ghiti March 13, 2021, 9:26 a.m. UTC | #2
Hi Palmer,

Le 3/9/21 à 9:54 PM, Palmer Dabbelt a écrit :
> On Thu, 25 Feb 2021 00:04:50 PST (-0800), alex@ghiti.fr wrote:
>> I decided to split sv48 support in small series to ease the review.
>>
>> This patchset pushes the kernel mapping (modules and BPF too) to the last
>> 4GB of the 64bit address space, this allows to:
>> - implement relocatable kernel (that will come later in another
>>   patchset) that requires to move the kernel mapping out of the linear
>>   mapping to avoid to copy the kernel at a different physical address.
>> - have a single kernel that is not relocatable (and then that avoids the
>>   performance penalty imposed by PIC kernel) for both sv39 and sv48.
>>
>> The first patch implements this behaviour, the second patch introduces a
>> documentation that describes the virtual address space layout of the 
>> 64bit
>> kernel and the last patch is taken from my sv48 series where I simply 
>> added
>> the dump of the modules/kernel/BPF mapping.
>>
>> I removed the Reviewed-by on the first patch since it changed enough from
>> last time and deserves a second look.
>>
>> Alexandre Ghiti (3):
>>   riscv: Move kernel mapping outside of linear mapping
>>   Documentation: riscv: Add documentation that describes the VM layout
>>   riscv: Prepare ptdump for vm layout dynamic addresses
>>
>>  Documentation/riscv/index.rst       |  1 +
>>  Documentation/riscv/vm-layout.rst   | 61 ++++++++++++++++++++++
>>  arch/riscv/boot/loader.lds.S        |  3 +-
>>  arch/riscv/include/asm/page.h       | 18 ++++++-
>>  arch/riscv/include/asm/pgtable.h    | 37 +++++++++----
>>  arch/riscv/include/asm/set_memory.h |  1 +
>>  arch/riscv/kernel/head.S            |  3 +-
>>  arch/riscv/kernel/module.c          |  6 +--
>>  arch/riscv/kernel/setup.c           |  3 ++
>>  arch/riscv/kernel/vmlinux.lds.S     |  3 +-
>>  arch/riscv/mm/fault.c               | 13 +++++
>>  arch/riscv/mm/init.c                | 81 +++++++++++++++++++++++------
>>  arch/riscv/mm/kasan_init.c          |  9 ++++
>>  arch/riscv/mm/physaddr.c            |  2 +-
>>  arch/riscv/mm/ptdump.c              | 67 +++++++++++++++++++-----
>>  15 files changed, 258 insertions(+), 50 deletions(-)
>>  create mode 100644 Documentation/riscv/vm-layout.rst
> 
> This generally looks good, but I'm getting a bunch of checkpatch 
> warnings and some conflicts, do you mind fixing those up (and including 
> your other kasan patch, as that's likely to conflict)?


I fixed a few checkpatch warnings and rebased on top of for-next but had 
not conflicts.

I have just sent the v2.

Thanks,

Alex
Palmer Dabbelt March 17, 2021, 5:05 a.m. UTC | #3
On Sat, 13 Mar 2021 01:26:47 PST (-0800), alex@ghiti.fr wrote:
> Hi Palmer,
>
> Le 3/9/21 à 9:54 PM, Palmer Dabbelt a écrit :
>> On Thu, 25 Feb 2021 00:04:50 PST (-0800), alex@ghiti.fr wrote:
>>> I decided to split sv48 support in small series to ease the review.
>>>
>>> This patchset pushes the kernel mapping (modules and BPF too) to the last
>>> 4GB of the 64bit address space, this allows to:
>>> - implement relocatable kernel (that will come later in another
>>>   patchset) that requires to move the kernel mapping out of the linear
>>>   mapping to avoid to copy the kernel at a different physical address.
>>> - have a single kernel that is not relocatable (and then that avoids the
>>>   performance penalty imposed by PIC kernel) for both sv39 and sv48.
>>>
>>> The first patch implements this behaviour, the second patch introduces a
>>> documentation that describes the virtual address space layout of the
>>> 64bit
>>> kernel and the last patch is taken from my sv48 series where I simply
>>> added
>>> the dump of the modules/kernel/BPF mapping.
>>>
>>> I removed the Reviewed-by on the first patch since it changed enough from
>>> last time and deserves a second look.
>>>
>>> Alexandre Ghiti (3):
>>>   riscv: Move kernel mapping outside of linear mapping
>>>   Documentation: riscv: Add documentation that describes the VM layout
>>>   riscv: Prepare ptdump for vm layout dynamic addresses
>>>
>>>  Documentation/riscv/index.rst       |  1 +
>>>  Documentation/riscv/vm-layout.rst   | 61 ++++++++++++++++++++++
>>>  arch/riscv/boot/loader.lds.S        |  3 +-
>>>  arch/riscv/include/asm/page.h       | 18 ++++++-
>>>  arch/riscv/include/asm/pgtable.h    | 37 +++++++++----
>>>  arch/riscv/include/asm/set_memory.h |  1 +
>>>  arch/riscv/kernel/head.S            |  3 +-
>>>  arch/riscv/kernel/module.c          |  6 +--
>>>  arch/riscv/kernel/setup.c           |  3 ++
>>>  arch/riscv/kernel/vmlinux.lds.S     |  3 +-
>>>  arch/riscv/mm/fault.c               | 13 +++++
>>>  arch/riscv/mm/init.c                | 81 +++++++++++++++++++++++------
>>>  arch/riscv/mm/kasan_init.c          |  9 ++++
>>>  arch/riscv/mm/physaddr.c            |  2 +-
>>>  arch/riscv/mm/ptdump.c              | 67 +++++++++++++++++++-----
>>>  15 files changed, 258 insertions(+), 50 deletions(-)
>>>  create mode 100644 Documentation/riscv/vm-layout.rst
>>
>> This generally looks good, but I'm getting a bunch of checkpatch
>> warnings and some conflicts, do you mind fixing those up (and including
>> your other kasan patch, as that's likely to conflict)?
>
>
> I fixed a few checkpatch warnings and rebased on top of for-next but had
> not conflicts.
>
> I have just sent the v2.

Thanks.  These (and the second patch of the one I just put on fixes) are
for-next things, so I'm not going to get a look at them tonight because I want
to make sure we don't have any more fixes outstanding.
Alexandre Ghiti March 20, 2021, 8:48 a.m. UTC | #4
Le 3/9/21 à 9:54 PM, Palmer Dabbelt a écrit :
> On Thu, 25 Feb 2021 00:04:50 PST (-0800), alex@ghiti.fr wrote:
>> I decided to split sv48 support in small series to ease the review.
>>
>> This patchset pushes the kernel mapping (modules and BPF too) to the last
>> 4GB of the 64bit address space, this allows to:
>> - implement relocatable kernel (that will come later in another
>>   patchset) that requires to move the kernel mapping out of the linear
>>   mapping to avoid to copy the kernel at a different physical address.
>> - have a single kernel that is not relocatable (and then that avoids the
>>   performance penalty imposed by PIC kernel) for both sv39 and sv48.
>>
>> The first patch implements this behaviour, the second patch introduces a
>> documentation that describes the virtual address space layout of the 
>> 64bit
>> kernel and the last patch is taken from my sv48 series where I simply 
>> added
>> the dump of the modules/kernel/BPF mapping.
>>
>> I removed the Reviewed-by on the first patch since it changed enough from
>> last time and deserves a second look.
>>
>> Alexandre Ghiti (3):
>>   riscv: Move kernel mapping outside of linear mapping
>>   Documentation: riscv: Add documentation that describes the VM layout
>>   riscv: Prepare ptdump for vm layout dynamic addresses
>>
>>  Documentation/riscv/index.rst       |  1 +
>>  Documentation/riscv/vm-layout.rst   | 61 ++++++++++++++++++++++
>>  arch/riscv/boot/loader.lds.S        |  3 +-
>>  arch/riscv/include/asm/page.h       | 18 ++++++-
>>  arch/riscv/include/asm/pgtable.h    | 37 +++++++++----
>>  arch/riscv/include/asm/set_memory.h |  1 +
>>  arch/riscv/kernel/head.S            |  3 +-
>>  arch/riscv/kernel/module.c          |  6 +--
>>  arch/riscv/kernel/setup.c           |  3 ++
>>  arch/riscv/kernel/vmlinux.lds.S     |  3 +-
>>  arch/riscv/mm/fault.c               | 13 +++++
>>  arch/riscv/mm/init.c                | 81 +++++++++++++++++++++++------
>>  arch/riscv/mm/kasan_init.c          |  9 ++++
>>  arch/riscv/mm/physaddr.c            |  2 +-
>>  arch/riscv/mm/ptdump.c              | 67 +++++++++++++++++++-----
>>  15 files changed, 258 insertions(+), 50 deletions(-)
>>  create mode 100644 Documentation/riscv/vm-layout.rst
> 
> This generally looks good, but I'm getting a bunch of checkpatch 
> warnings and some conflicts, do you mind fixing those up (and including 
> your other kasan patch, as that's likely to conflict)?

I have just tried to rebase this on for-next, and that quite conflicts 
with Vitaly's XIP patch, I'm fixing this and post a v3.

Alex