mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:07:45 +00:00
Kernel: Make use of interrupts as an entropy source
Booting old computers without RDRAND/RDSEED and without a disk makes the system severely starved for entropy. Uses interrupts as a source to side-step that issue. Also warn whenever the system is starved of entropy, because that's a non-obvious failure mode.
This commit is contained in:
parent
cb89d3b780
commit
7eaefa5aa6
3 changed files with 16 additions and 2 deletions
|
@ -147,11 +147,21 @@ class EntropySource {
|
|||
};
|
||||
|
||||
public:
|
||||
enum class Static : size_t {
|
||||
Interrupts,
|
||||
MaxHardcodedSourceIndex,
|
||||
};
|
||||
|
||||
EntropySource()
|
||||
: m_source(next_source++)
|
||||
{
|
||||
}
|
||||
|
||||
EntropySource(Static hardcoded_source)
|
||||
: m_source(static_cast<size_t>(hardcoded_source))
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void add_random_event(const T& event_data)
|
||||
{
|
||||
|
@ -166,7 +176,6 @@ private:
|
|||
static size_t next_source;
|
||||
size_t m_pool { 0 };
|
||||
size_t m_source;
|
||||
Lock m_lock;
|
||||
};
|
||||
|
||||
// NOTE: These API's are primarily about expressing intent/needs in the calling code.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue