Commit Graph

73 Commits

Author SHA1 Message Date
Jussi Kivilinna
dffb8a67e3 Add entropy pool and strong random number generator
Entropy pool gathers environmental noise from device drivers, user-space, etc., and returns good random numbers, suitable for cryptographic use. Based on entropy pool design from *BSDs and uses BLAKE2Xs algorithm for CSPRNG output.

Patch also adds /dev/urandom support for using entropy pool RNG and new 'getrandom' system call for getting randomness without file-descriptor usage (thus avoiding file-descriptor exhaustion attacks). The 'getrandom' interface is similar as 'getentropy' and 'getrandom' available on OpenBSD and Linux respectively.
2017-03-30 07:38:37 -06:00
Gregory Nutt
e1218c4b4b Smaller vector tables: Add irq_mapped_t. 2017-03-03 10:20:40 -06:00
Gregory Nutt
c2b620b4f8 Implements support for smaller interrupt tables as described at http://www.nuttx.org/doku.php?id=wiki:howtos:smallvectors . This is largely the work of Mark Schulte. However, I have made several changes to match with the Wiki document. If you like the change, thanks go to Marc. For any errors you can blame me. 2017-03-03 09:20:25 -06:00
Gregory Nutt
02b1e1ec1a Fixes for coding standard: '*' needs to 'snuggle' with following variable name 2017-02-28 18:22:57 -06:00
Gregory Nutt
840c5935a3 Correct a typo from one of the preceding commits. 2017-02-27 11:58:20 -06:00
Mark Schulte
b3222bbc8a irq_dispatch: Add argument pointer to irq_dispatch
Provide a user defined callback context for irq's, such that when
registering a callback users can provide a pointer that will get
passed back when the isr is called.
2017-02-27 06:27:56 -06:00
Gregory Nutt
9ce4022096 SMP: Fix an error in critical section logic when performing a context switch from an interrupt handler. The g_cpu_irqset bit was not being set for the CPU so other CPUs did not know about the critical section. 2017-01-13 06:48:10 -06:00
Gregory Nutt
e7d2b9f0e8 SMP: Move sharable function to common file as irq_cpu_locked(). Use irq_cpu_locked() in sched_unlock() 2016-12-29 08:17:10 -06:00
Gregory Nutt
96394f339e SMP: Fix a gap where we may try to make modifications to the task lists without being in a critical sections. That permits concurrent access to the tasks lists and many subtle problems. This fix just remains in the critical section throughout the operation (and possible until the task is restore in the event of a context switch). Makes a big difference in stability 2016-12-28 13:58:24 -06:00
Gregory Nutt
849a5dc2a9 SMP: Enforce this rule: Tasks which are normally restored when sched_unlock() is called must remain pending (1) if we are in a critical section, i.e., g_cpu_irqlock is locked , or (2) other CPUs still have pre-emption disabled, i.e., g_cpu_schedlock is locked. In those cases, the release of the pending tasks must be deferred until those conditions are met. 2016-12-26 08:15:02 -06:00
Gregory Nutt
d45a81d643 Revert "SMP: Fix a error introduced in 36b676eea6 and fully decouple disabling of pre-emption from critical sections."
This reverts commit 9aedf1bdec.
2016-12-26 07:48:22 -06:00
Gregory Nutt
9aedf1bdec SMP: Fix a error introduced in 36b676eea6 and fully decouple disabling of pre-emption from critical sections. 2016-12-25 06:54:43 -06:00
Gregory Nutt
efb86382c3 SMP: Back out deferred IRQ locking. This was accidentally merged into master and it looks like it is going to be more work than I thought to get it working again. Changes will go to the irqlock branch. 2016-12-24 19:53:37 -06:00
Gregory Nutt
f55bad863b SMP: Fix logic error in last change: Deferred restoration of IRQ lock only applies if the context switch was on this CPU. 2016-12-24 18:52:58 -06:00
Gregory Nutt
d75a7643d0 Fix a trivial typo 2016-12-23 13:01:20 -06:00
Gregory Nutt
e6fff09ef8 Implement deferred IRQ locking. So far only form ARMv7-M. 2016-12-23 07:55:41 -06:00
Gregory Nutt
9ed0387379 Olimex-LPC1766-STK: Enable procfs in NSH configuration. Automount /proc on startup. 2016-12-05 08:52:40 -06:00
Gregory Nutt
00215fbc98 sched_note: Add spinlock instrumentation; In SMP configurations, select to log only notes from certain CPUs 2016-11-28 10:33:46 -06:00
Gregory Nutt
e3fe320e08 SMP: Add support for linking spinlocks into a special, non-cached memory region. 2016-11-26 08:47:03 -06:00
Gregory Nutt
1d06e786e1 SMP: Clean-up and simplication of logic that I implemented late last night. 2016-11-26 07:05:27 -06:00
Gregory Nutt
a0e1af2614 SMP: Fix yet another potential deadlock 2016-11-25 23:04:27 -06:00
Gregory Nutt
7bec4ffeec Update some comments 2016-11-23 17:40:01 -06:00
Gregory Nutt
f90525a5d1 SMP: Update some comments; trivial improvement by inlining static function. 2016-11-22 16:48:57 -06:00
Gregory Nutt
bac7153609 SMP: Add logic to avoid a deadlock condition when CPU1 is hung waiting for g_cpu_irqlock and CPU0 is waitin for g_cpu_paused 2016-11-22 11:34:16 -06:00
Gregory Nutt
69e9f8638d Most interrupt handling logic interacts with tasks via standard mechanism such as sem_post, sigqueue, mq_send, etc. This all call enter_critical_section and are assumed to be safe in the SMP case.
But certain logic interacts with tasks in different ways.  The only one that comes to mind are wdogs.  There is a tasking interface that to manipulate wdogs, and a different interface in the timer interrupt handling logic to manage wdog expirations.

In the normal case, this is fine.  Since the tasking level code calls enter_critical_section, interrupts are disabled an no conflicts can occur.  But that may not be the case in the SMP case.  Most architectures do not permit disabling interrupts on other CPUs so enter_critical_section must work differently:  Locks are required to protect code.

So this change adds locking (via enter_critical section) to wdog expiration logic for the the case if the SMP configuration.
2016-11-18 13:57:30 -06:00
Gregory Nutt
78fd358023 Update some comments. 2016-11-18 08:20:52 -06:00
Gregory Nutt
8602e8a8a9 SMP: irq_csection() has a bad assumption. It assumed that the state of certain variables. That was true on entry into the interrupt handler, but might change to the execution of logic within the interrupt handler. 2016-11-18 07:38:16 -06:00
Gregory Nutt
8e029f019b Update comments 2016-11-17 17:30:12 -06:00
Gregory Nutt
47b52a2633 Fix an error in manually bringing in Sebastien's changes; Update some comments. 2016-11-17 16:15:06 -06:00
Gregory Nutt
9acd57c819 Fix up some naming and update some comments. 2016-11-17 15:50:39 -06:00
Gregory Nutt
558f4049d4 sched/irq/irq_csection: Fix a bad DEBUG assertion when SMP is enabled. 2016-11-17 15:36:27 -06:00
Gregory Nutt
2c314464a8 Fix a typo in a comment 2016-11-17 08:03:45 -06:00
Gregory Nutt
ccdc11d8ff Fix typo in variable naming. g_cpu_irqset should be g_cpu_irqlock. 2016-11-17 06:37:24 -06:00
Gregory Nutt
1c1564f0c1 Add logic to handled nested calls to enter_critical_section() from interrupts handlers (with SMP). 2016-11-16 22:45:08 -06:00
Gregory Nutt
0c3207e86e Fix backward logic in an assertion. 2016-11-16 21:48:27 -06:00
Gregory Nutt
16f0b8fa96 Fix typos in DEBUASSERT statements 2016-11-16 19:58:51 -06:00
Gregory Nutt
f1e4951a8d Fix some comments 2016-11-16 19:11:31 -06:00
Gregory Nutt
4ca653a1cc Add some experimental changes to enter/leave_critical_section to deal with the case where interrupts are disabled only on the local CPU 2016-11-16 18:28:35 -06:00
Gregory Nutt
5ce3b399d5 Correct some typos in comments 2016-11-15 16:48:40 -06:00
Gregory Nutt
40d7216a22 Back out 65ab12 and parts of 21f92b 2016-11-15 15:44:43 -06:00
Gregory Nutt
6683f01444 Trivial change to comment 2016-11-15 13:38:43 -06:00
Gregory Nutt
21f92ba601 Review some SMP logic; update comments; refresh configuration. 2016-11-15 09:24:00 -06:00
Gregory Nutt
65ab12fbb9 If SMP is enabled, if any interrupt handler calls enter_critical_section(), it should take the spinlock. 2016-11-15 08:37:58 -06:00
Gregory Nutt
b53866c872 sched/irq: Change order for SMP case in enter_critical_section: Disble local interrupts BEFORE taking spinlock. 2016-11-15 07:54:18 -06:00
Sagitta Li
9fa1024eef vector table should have dimension NR_IRQS, not NR_IRQS+1 2016-09-22 07:56:12 -06:00
Gregory Nutt
2a751068e6 Without lowsyslog() *llerr() is not useful. Eliminate and replace with *err(). 2016-06-20 12:44:38 -06:00
Gregory Nutt
0c8c7fecf0 Add _ to the beginning of all debug macros to avoid name collisions 2016-06-16 12:33:32 -06:00
Gregory Nutt
13cac3b592 sched/: Change some *err() message to *info() messages if what was a *dbg() message does not indicate and error condition. 2016-06-11 16:42:42 -06:00
Gregory Nutt
e99301d7c2 Rename *lldbg to *llerr 2016-06-11 14:55:27 -06:00
Gregory Nutt
07acd5327a SMP: Clean CPU0 D-Cache before starting new CPU; Invalidate D-Cache when new CPU started. 2016-05-20 12:39:02 -06:00