Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mpfs_opensbi: Re-organize SBI areas so that RW areas follow each other #185

Open
wants to merge 138 commits into
base: master
Choose a base branch
from

Conversation

pussuw
Copy link

@pussuw pussuw commented Nov 27, 2023

Change the ordering of the SBI areas so that:

  • The first area is the executable area (.text)
  • The second area is the heap (RW)
  • The last area is the scratch registers (RW)

This makes it easier to encode PMP areas for OpenSBI.

jlaitine and others added 30 commits August 25, 2023 15:08
- boots from eNVM
- uses lim memory for RAM
- has console on uart 0
- has procfs enabled
- has most of nsh commands enabled

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
- Change git repository urls to point to our tiiuae repos for nuttx & nuttx apps
- Remove most of the the build steps, leave just arm-12 and riscv;
	arm-12 has a build for stm32f7, and riscv for mpfs

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
…ptimized version in tiiuae repo

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
…iver to re-initialize on rx timeout

If the interface is UP, and no packets are received in 30s, re-initialize the interface by calling the
already implemented mpfs_txtimeout_expiry.

This is a temporary workaround for a bug where IF might be UP and working but packets can only
be transmitted. Receive side just doesn't work at all.

The original bug can be re-produced easily by disconnecting and reconnecting the ethernet cable while
the IF is up.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
SD-card clock speed is just forced to 50MHz. Note that to be correct, one should first set the SD-card
into high-speed mode, but currently NuttX doesn't support this.

With our cards, just setting the interface to 50MHz seems to work fine, and it removes the issue with
25MHZ clock causing disturbance on GPS bands. Typically cards which support high-speed mode just work with
50MHz interface clock.

This patch should be reverted when the NuttX supports high-speed mode, and we can properly set it.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
…ootloader

This removes the need to have all the DDR/clock configuration related
"LIBERODEFS" flags defined, when not building a standalone/coldboot
configuration

All of this code is unused when not building with CONFIG_MPFS_BOOTLOADER

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
This is not the correct way to do this, but it gives a nice perf. boost
Disable macOS builds for now.
All other commands are disabled in send_recv().

Signed-off-by: Jani Paalijarvi <jani.paalijarvi@unikie.com>
Signed-off-by: Jani Paalijarvi <jani.paalijarvi@unikie.com>
…ef and forward declare devif_loopback

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
Remove unnecessary VQID shifting (16 -> 0).
Give an error if RPTUN init fails.
Enable LINUX_ON_HART4 in rpmsg-ch2 defconfig of ICICLE board.
Remove LINUX_ON_HART4 config from rpmsg-ch1 defconfig of ICICLE board.
Fix build warning when CONFIG_STM32F7_AUTONEG is not set

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
…ved IO area in protected build

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
Just a temporary patch, need to implement some kind of scalable solution
for this. It might be a good idea to map something else for the user
to avoid using ecall to enter the kernel for simple reads ?

Also, increase the L3 table size
eenurkka and others added 21 commits October 13, 2023 07:01
Version 1.3.1 is the latest tagged version.  This patch
prepares the required changes to make v1.3.1 work.

Signed-off-by: Eero Nurkkala <eero.nurkkala@offcode.fi>
Change bgtz t0, mpfs_opensbi_prepare_hart to tail-call to ensure there
will be no link time error due to the jump offset being too large.
Fix case where NULL is de-referenced via tx/rx buffer or descriptor. Only
1 queue is currently set up for each, so the indices 1,2,3 are not valid
and should not be handled.
Instead of releasing rx descriptor twice and tx buffer twice.
Initially clear PMP for all harts, this fixes random warm reset issues.

Signed-off-by: Ville Juven <ville.juven@unikie.com>
After read training, check also that the eye is centered properly. Sometimes
after the training the width is long enough, but it is not centered.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
Just verify that the delay for the selected clock != 0

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
Corrections to CA training verify step. The original copied from HSS didn't
make sense in all aspects:
- The check is not per lane, so it should be out of the "for (lane_sel" loop.
- The check wasn't proper. The expected outcome is just a vector of increasing numbers
  separated enough

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
PMPCFG_A_TOR region may have zero size. The pmp configuration
currently fails for zero-sized TOR. This patch bypasses such a
restriction.

Also replace log2ceil with LOG2_CEIL from lib/math32.h.

Signed-off-by: Eero Nurkkala <eero.nurkkala@offcode.fi>
These options are just wrong and a result of misunderstanding of the
Polarfire SoC spec. There are no feature limitations in the CPU PMP
implementation -> remove any configuration options added.
For TOR: Any size and 4-byte aligned address is required
For NA4: Only size 4 and 4-byte aligned address is good
For NAPOT: Minimum size is 8 bytes, minimum base alignment is 8 bytes,
           and size must be power-of-two aligned with base

This commit simplifies these checks and removes all the nonsense added
by a misunderstanding of how the MPFS / Polarfire SoC's PMP works.
The PMP setup should be done in the board specific code, at a much
earlier stage. Granting all access is a security risk anyway.
Open PMP before the hart payload starts to execute
This adds option to do PMP configuration via mpfs_board_pmp_setup instead
of just opening up everything. In this case, it is up to the specific
board to implement the PMP configuration in whichever way it sees fit.
There is a problem when vfork() calls execv() (or execl()) to start a new application:
When the parent thread calls vfork() it receives and gets the pid of the vforked task,
and not the pid of the desired execv'ed application.
see issue apache#3334

Signed-off-by: yangyalei <yangyalei@xiaomi.com>
Handle task spawn attributes as task spawn file actions are handled.

Why? This removes the need for sched_lock() when the task is being
spawned. When loading the new task from a file the scheduler can be
locked for a VERY LONG time, in the order of hundreds of milliseconds!

This is unacceptable for real time operation.

Also fixes a latent bug in exec_module, spawn_file_actions is executed
at a bad location; when CONFIG_ARCH_ADDRENV=y actions will point to the
new process's address environment (as it is temporarily instantiated at
that point). Fix this by moving it to after addrenv_restore.
…nsole off

By setting "isconsole" to false, mpfs_serial stops outputting to console.

This can be used to disable output to debug console in low level.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
priv->msgid may grow past its boundaries, causing
struct i2c_msg_s *msg = &priv->msgv[priv->msgid]
to read data out of boundaris.

Signed-off-by: Eero Nurkkala <eero.nurkkala@offcode.fi>
This adds support for detecting various tamper events.
The interrupt handler makes noise at every detection.

Perhaps easiest test is to attach JTAG debugger.

TAMPER_TESTS -define has some nonexisting (not in repos)
calls, perhaps could remove it alltogether.

Signed-off-by: Eero Nurkkala <eero.nurkkala@offcode.fi>
Use only tests that will trigger a tamper event. Leave
other tests outside.

Signed-off-by: Eero Nurkkala <eero.nurkkala@offcode.fi>
@pussuw
Copy link
Author

pussuw commented Nov 27, 2023

Not sure how this will fit to upstream, as the linker scripts differ a bit. Should be doable by something like:

    .text.sbi : {
      _ssbi_ddr = ABSOLUTE(.);
      sbi*
      riscv_atomic*
      riscv_locks*
      riscv_asm*
      _esbi_ddr = ABSOLUTE(.);
      . = ALIGN(0x2000);
      _sbi_heap_start = ABSOLUTE(.);
      . += 16k; /* OpenSBI heap, aligned, at least 16k */
      _sbi_heap_end = ABSOLUTE(.);
    } > ddr

    PROVIDE(_sbi_heap_size = _sbi_heap_end - _sbi_heap_start);

Change the ordering of the SBI areas so that:
- The first area is the executable area (.text)
- The second area is the heap (RW)
- The last area is the scratch registers (RW)

This makes it easier to encode PMP areas for OpenSBI.
@pussuw
Copy link
Author

pussuw commented Nov 27, 2023

Looks like the arm target is broken in upstream as well

Copy link

@gpoulios gpoulios left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet