summaryrefslogtreecommitdiff
path: root/Kernel/Bus/VirtIO/RNG.h
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2021-09-04 08:42:31 +0300
committerAndreas Kling <kling@serenityos.org>2021-09-04 16:36:02 +0200
commited6c1f53afbb6207450045b07552effa5335ceb1 (patch)
treedb576e877f69cafedd27e5da4ada89e8c531058f /Kernel/Bus/VirtIO/RNG.h
parente490c17bdedf48ea252a1f9fe04b748e63cbd9b7 (diff)
downloadserenity-ed6c1f53afbb6207450045b07552effa5335ceb1.zip
Kernel/VirtIO: Defer initialization of device out of the constructor
This ensures we safely handle interrupts (which can call virtual functions), so they don't happen in the constructor - this pattern can lead to a crash, if we are still in the constructor context because not all methods are available for usage (some are pure virtual, so it's possible to call __cxa_pure_virtual). Also, under some conditions like adding a PCI device via PCI-passthrough mechanism in QEMU, it became exposed to the eye that the code asserts on RNG::handle_device_config_change(). That device has no configuration but if the hypervisor still misbehaves and tries to configure it, we should simply return false to indicate nothing happened.
Diffstat (limited to 'Kernel/Bus/VirtIO/RNG.h')
-rw-r--r--Kernel/Bus/VirtIO/RNG.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/Kernel/Bus/VirtIO/RNG.h b/Kernel/Bus/VirtIO/RNG.h
index ac0c92d719..c1e6d3c440 100644
--- a/Kernel/Bus/VirtIO/RNG.h
+++ b/Kernel/Bus/VirtIO/RNG.h
@@ -23,6 +23,8 @@ public:
virtual StringView purpose() const override { return class_name(); }
virtual ~RNG() override = default;
+ virtual void initialize() override;
+
private:
virtual StringView class_name() const override { return "VirtIOConsole"; }
explicit RNG(PCI::Address);