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

risc-v/mpfs: ihc: cleanup DEBUGASSERTs and reboot #183

Merged
merged 1 commit into from
Nov 15, 2023
Merged

Conversation

eenurkka
Copy link

@eenurkka eenurkka commented Nov 14, 2023

Replace DEBUGASSERTs with sanity checks. DEBUGASSERT()s are not necessarily enabled at all, thus risking the functionality especially in that case.

Don't enable the ihc irq too early. If enabled, and the master is already up, the irq is being issued so that the system gets stuck or is severely slowed down. Master may be already if this NuttX hart is rebooted, for example.

Summary

DP-7330 (partial fix)
DP-6809 (complete fix)

Impact

Testing

SalukiV2 / AMP mode with kernel / ping -A and rebooting NuttX

@pussuw
Copy link

pussuw commented Nov 14, 2023

I would convert the PANIC() into simply return; where possible. If there is a clear error and the code should not continue, then PANIC() is the correct operation, but when an incoming parameter is invalid, it is better to just not do the operation.

I can figure out two reasons for doing the return instead of panic:

  • Panic crashes the system
  • As the system crashes, an attacker knows an operation has failed (it gives the attacker feedback when he's trying to get in), it is better to just do nothing if some operation is detected as an attack (potential attack)

@pussuw
Copy link

pussuw commented Nov 14, 2023

Not very familiar with the driver but LGTM now !

@eenurkka eenurkka force-pushed the rpmsg-cleanup branch 2 times, most recently from b1267e9 to 586132b Compare November 15, 2023 05:25
Replace DEBUGASSERTs with sanity checks. DEBUGASSERT()s are
not necessarily enabled at all, thus risking the functionality
especially in that case. Remove PANICs as well.

Don't enable the ihc irq too early. If enabled, and the master
is already up, the irq is being issued so that the system gets
stuck or is severely slowed down. Master may be already if this
NuttX hart is rebooted, for example.

Signed-off-by: Eero Nurkkala <[email protected]>
@eenurkka eenurkka merged commit 4c460ae into master Nov 15, 2023
8 checks passed
@eenurkka eenurkka deleted the rpmsg-cleanup branch November 17, 2023 08:38
@@ -1256,8 +1284,12 @@ static void mpfs_rptun_worker(void *arg)
return;
}

DEBUGASSERT((g_vq_idx - VRING0_NOTIFYID) < VRINGS);
info = &g_mpfs_virtqueue_table[g_vq_idx - VRING0_NOTIFYID];
if (g_vq_idx >= VRINGS)
Copy link

Choose a reason for hiding this comment

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

This is safe as it is. I'm just wondering, does it no longer support 2 channels / CONFIG_MPFS_IHC_RPMSG_CH2 (VRINGS = 2, VRING0_NOTIFYID = 2 or VRING1_NOTIFYID = 3) ? Not even sure we're ever going to need it, just out of curiosity.

Copy link
Author

@eenurkka eenurkka Dec 6, 2023

Choose a reason for hiding this comment

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

I was thinking of that also, but as 2x channels are currently not needed / hard to test, it's there waiting to be fixed if it will ever be needed. Maybe a comment should be written there.

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

Successfully merging this pull request may close these issues.

3 participants