Page MenuHomeFreeBSD

riscv: Add a sysentvec for the SV48 user ABI
ClosedPublic

Authored by markj on Feb 14 2022, 10:30 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Apr 3, 9:29 PM
Unknown Object (File)
Fri, Mar 29, 10:42 AM
Unknown Object (File)
Jan 22 2024, 8:52 PM
Unknown Object (File)
Jan 14 2024, 7:40 AM
Unknown Object (File)
Dec 20 2023, 7:32 AM
Unknown Object (File)
Nov 30 2023, 3:52 AM
Unknown Object (File)
Nov 30 2023, 3:52 AM
Unknown Object (File)
Nov 30 2023, 3:52 AM
Subscribers

Details

Summary

A sysinit determines whether the pmap has enabled SV48 mode and
registers the corresponding sysentvec. In particular, only one ABI will
be in use in a running kernel. This is modelled after LA57 support on
amd64.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 44496
Build 41384: arc lint + arc unit

Event Timeline

I must say that in light of the fact we'll need to duplicate all of this for freebsd64 downstream, I wonder if it wouldn't be simpler to set the members that vary in elf64_register_sysvec instead (and keep a single sysvec)? That is something like:

static void
elf64_register_sysvec(void *arg __unused)
{
    switch (pmap_mode) {
    case PMAP_MODE_SV39:
       elf64_freebsd_sysvec.sv_usrstack = USRSTACK_SV39;
       ...
       break;
    case PMAP_MODE_SV48:
       elf64_freebsd_sysvec.sv_usrstack = USRSTACK_SV48;
       ...
       break;
   }
}

You could even leave the INIT_SYSENTVEC as-is. It might be nice to actually have the fixup function take the sysvec pointer as its void *arg as in CheriBSD we will have to invoke it on two separate sysentvec's (one for stock freebsd64 and one for CHERI).

In D34274#775810, @jhb wrote:

I must say that in light of the fact we'll need to duplicate all of this for freebsd64 downstream, I wonder if it wouldn't be simpler to set the members that vary in elf64_register_sysvec instead (and keep a single sysvec)? That is something like:

static void
elf64_register_sysvec(void *arg __unused)
{
    switch (pmap_mode) {
    case PMAP_MODE_SV39:
       elf64_freebsd_sysvec.sv_usrstack = USRSTACK_SV39;
       ...
       break;
    case PMAP_MODE_SV48:
       elf64_freebsd_sysvec.sv_usrstack = USRSTACK_SV48;
       ...
       break;
   }
}

You could even leave the INIT_SYSENTVEC as-is. It might be nice to actually have the fixup function take the sysvec pointer as its void *arg as in CheriBSD we will have to invoke it on two separate sysentvec's (one for stock freebsd64 and one for CHERI).

That seems reasonable and I implemented it. I wish we could make these structures const but there are already other fields that get filled in later during boot (relating to the shared page IIRC).

Use a single sysentvec and brandinfo.

jhb added inline comments.
sys/riscv/riscv/elf_machdep.c
156

Presumably you could execute this as soon as you know the pmap mode (that is, it could be earlier in case someone is nervous about the sysentvec not being initialized when the existing sysinits are executed?) That said, I think it probably doesn't really matter as we don't really use the sysentvec fields until we try to exec init.

This revision is now accepted and ready to land.Feb 15 2022, 5:45 PM
markj marked an inline comment as done.

Fixup sysentvec entries earlier during boot.

This revision now requires review to proceed.Feb 16 2022, 2:36 PM
This revision is now accepted and ready to land.Feb 16 2022, 7:10 PM
alc added inline comments.
sys/riscv/riscv/elf_machdep.c
61

Unnecessary. Already included by vm/pmap.h.

markj marked an inline comment as done.

Remove unneeded include.

This revision now requires review to proceed.Feb 18 2022, 2:02 PM
This revision was not accepted when it landed; it landed in state Needs Review.Mar 1 2022, 2:40 PM
This revision was automatically updated to reflect the committed changes.