Skip to content

Kernel-mode IRQs and Kernel heap demand paging can't be enabled simultaneously #16

@latentPrion

Description

@latentPrion

In __kcore/__classes/heap.cpp, if we allow fakemapping/demand paging the heap, then:

inside of malloc(), while the heap's WaitLock is still held, we'll attempt to initialize a header at the top of new allocations. When initializing this header, we'll encounter a #PF because the new memory will be fakemapped -- and this will trigger the #PF.

If CONFIG_RT_KERNEL_IRQS is enabled, then the kernel will enable local #INTs during exceptions and SWIs. If the kernel enables local #INTs during exceptions, this will include #PFs, of course. Our #PF which was triggered by the fakemapped pages in the heap, will also of course, enable local #INTs.

If an IRQ occurs during this #PF, and that IRQ allocates an object on the heap, then we will get a deadlock because the #PF occured while we still held the heap's WaitLock.

We should probably just disable kernel heap demand paging -- or perhaps all demand paging in the kernel altogether. It was really just a vanity feature and the fact that #PFs can occur while we hold a lock is extremely concerning.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions