Skip to content
Snippets Groups Projects
Commit ec7ed8cd authored by Glauber Costa's avatar Glauber Costa Committed by Avi Kivity
Browse files

enable interrupts during page fault handling


Context: going to wait with irqs_disabled is a call for disaster.  While it is
true that not every time we call wait we actually end up waiting, that should
be an invalid call, due to the times we may wait. Because of that, it would
be good to express that nonsense in an assertion.

There is however, places we sleep with irqs disabled currently. Although they
are technically safe, because we implicitly enable interrupts, they end up
reaching wait() in a non-safe state. That happens in the page fault handler.
Explicitly enabling interrupts will allow us to test for valid / invalid wait
status.

With this test applied, all tests in our whitelist still passes.

Signed-off-by: default avatarGlauber Costa <glommer@cloudius-systems.com>
Signed-off-by: default avatarAvi Kivity <avi@cloudius-systems.com>
parent 12d2efdf
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@
* BSD license as described in the LICENSE file in the top-level directory.
*/
#include "arch.hh"
#include "arch-cpu.hh"
#include "debug.hh"
#include "sched.hh"
......@@ -26,6 +27,9 @@ void page_fault(exception_frame *ef)
assert(sched::preemptable());
assert(ef->rflags & processor::rflags_if);
// And since we may sleep, make sure interrupts are enabled.
arch::irq_enable();
sched::inplace_arch_fpu fpu;
fpu.save();
mmu::vm_fault(addr, ef);
......
......@@ -8,6 +8,7 @@
#ifndef SCHED_HH_
#define SCHED_HH_
#include "arch.hh"
#include "arch-thread-state.hh"
#include "arch-cpu.hh"
#include <functional>
......@@ -587,6 +588,9 @@ template <class Mutex, class Pred>
inline
void thread::do_wait_until(Mutex& mtx, Pred pred)
{
assert(arch::irq_enabled());
assert(preemptable());
thread* me = current();
while (true) {
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment