mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-10 21:01:49 +00:00
hw: replace lock-safe log variants in kernel
As far as possible remove usage of warning/error/log in the kernel, otherwise the kernel context might try to take a lock hold by a core thread, which results in a syscall to block. Fix #3277
This commit is contained in:
parent
9e238d624e
commit
0ca199f89a
@ -63,7 +63,7 @@ void Cpu_job::_interrupt(unsigned const /* cpu_id */)
|
||||
/* it needs to be a user interrupt */
|
||||
User_irq * irq = User_irq::object(irq_id);
|
||||
if (irq) irq->occurred();
|
||||
else Genode::warning("Unknown interrupt ", irq_id);
|
||||
else Genode::raw("Unknown interrupt ", irq_id);
|
||||
}
|
||||
|
||||
/* end interrupt request at controller */
|
||||
|
@ -174,7 +174,7 @@ void Ipc_node::send_request(Ipc_node &callee, capid_t capid, bool help,
|
||||
unsigned rcv_caps)
|
||||
{
|
||||
if (_state != INACTIVE) {
|
||||
Genode::error("IPC send request: bad state");
|
||||
Genode::raw("IPC send request: bad state");
|
||||
return;
|
||||
}
|
||||
Genode::Allocator &slab = pd().platform_pd().capability_slab();
|
||||
@ -201,7 +201,7 @@ Ipc_node * Ipc_node::helping_sink() {
|
||||
bool Ipc_node::await_request(unsigned rcv_caps)
|
||||
{
|
||||
if (_state != INACTIVE) {
|
||||
Genode::error("IPC await request: bad state");
|
||||
Genode::raw("IPC await request: bad state");
|
||||
return true;
|
||||
}
|
||||
Genode::Allocator &slab = pd().platform_pd().capability_slab();
|
||||
|
@ -276,7 +276,7 @@ void Thread::_call_restart_thread()
|
||||
Thread &thread = *thread_ptr;
|
||||
|
||||
if (!_core && (&pd() != &thread.pd())) {
|
||||
warning(*this, ": failed to lookup thread ", (unsigned)user_arg_1(),
|
||||
raw(*this, ": failed to lookup thread ", (unsigned)user_arg_1(),
|
||||
" to restart it");
|
||||
_die();
|
||||
return;
|
||||
@ -320,10 +320,10 @@ void Thread::_cancel_blocking()
|
||||
case ACTIVE:
|
||||
return;
|
||||
case DEAD:
|
||||
Genode::error("can't cancel blocking of dead thread");
|
||||
Genode::raw("can't cancel blocking of dead thread");
|
||||
return;
|
||||
case AWAITS_START:
|
||||
Genode::error("can't cancel blocking of not yet started thread");
|
||||
Genode::raw("can't cancel blocking of not yet started thread");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -394,7 +394,7 @@ void Thread::timeout_triggered()
|
||||
Signal_context * const c =
|
||||
pd().cap_tree().find<Signal_context>(_timeout_sigid);
|
||||
if (!c || c->submit(1))
|
||||
Genode::warning(*this, ": failed to submit timeout signal");
|
||||
Genode::raw(*this, ": failed to submit timeout signal");
|
||||
}
|
||||
|
||||
|
||||
@ -403,7 +403,7 @@ void Thread::_call_send_request_msg()
|
||||
Object_identity_reference * oir = pd().cap_tree().find(user_arg_1());
|
||||
Thread * const dst = (oir) ? oir->object<Thread>() : nullptr;
|
||||
if (!dst) {
|
||||
Genode::warning(*this, ": cannot send to unknown recipient ",
|
||||
Genode::raw(*this, ": cannot send to unknown recipient ",
|
||||
(unsigned)user_arg_1());
|
||||
_become_inactive(AWAITS_IPC);
|
||||
return;
|
||||
@ -449,14 +449,14 @@ void Thread::_call_await_signal()
|
||||
/* lookup receiver */
|
||||
Signal_receiver * const r = pd().cap_tree().find<Signal_receiver>(user_arg_1());
|
||||
if (!r) {
|
||||
Genode::warning(*this, ": cannot await, unknown signal receiver ",
|
||||
Genode::raw(*this, ": cannot await, unknown signal receiver ",
|
||||
(unsigned)user_arg_1());
|
||||
user_arg_0(-1);
|
||||
return;
|
||||
}
|
||||
/* register handler at the receiver */
|
||||
if (r->add_handler(this)) {
|
||||
Genode::warning("failed to register handler at signal receiver");
|
||||
Genode::raw("failed to register handler at signal receiver");
|
||||
user_arg_0(-1);
|
||||
return;
|
||||
}
|
||||
@ -469,7 +469,7 @@ void Thread::_call_pending_signal()
|
||||
/* lookup receiver */
|
||||
Signal_receiver * const r = pd().cap_tree().find<Signal_receiver>(user_arg_1());
|
||||
if (!r) {
|
||||
Genode::warning(*this, ": cannot await, unknown signal receiver ",
|
||||
Genode::raw(*this, ": cannot await, unknown signal receiver ",
|
||||
(unsigned)user_arg_1());
|
||||
user_arg_0(-1);
|
||||
return;
|
||||
@ -496,7 +496,7 @@ void Thread::_call_cancel_next_await_signal()
|
||||
/* kill the caller if the capability of the target thread is invalid */
|
||||
Thread * const thread = pd().cap_tree().find<Thread>(user_arg_1());
|
||||
if (!thread || (&pd() != &thread->pd())) {
|
||||
error(*this, ": failed to lookup thread ", (unsigned)user_arg_1());
|
||||
raw(*this, ": failed to lookup thread ", (unsigned)user_arg_1());
|
||||
_die();
|
||||
return;
|
||||
}
|
||||
@ -515,14 +515,14 @@ void Thread::_call_submit_signal()
|
||||
/* lookup signal context */
|
||||
Signal_context * const c = pd().cap_tree().find<Signal_context>(user_arg_1());
|
||||
if(!c) {
|
||||
Genode::warning(*this, ": cannot submit unknown signal context");
|
||||
Genode::raw(*this, ": cannot submit unknown signal context");
|
||||
user_arg_0(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
/* trigger signal context */
|
||||
if (c->submit(user_arg_2())) {
|
||||
Genode::warning("failed to submit signal context");
|
||||
Genode::raw("failed to submit signal context");
|
||||
user_arg_0(-1);
|
||||
return;
|
||||
}
|
||||
@ -535,7 +535,7 @@ void Thread::_call_ack_signal()
|
||||
/* lookup signal context */
|
||||
Signal_context * const c = pd().cap_tree().find<Signal_context>(user_arg_1());
|
||||
if (!c) {
|
||||
Genode::warning(*this, ": cannot ack unknown signal context");
|
||||
Genode::raw(*this, ": cannot ack unknown signal context");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -549,14 +549,14 @@ void Thread::_call_kill_signal_context()
|
||||
/* lookup signal context */
|
||||
Signal_context * const c = pd().cap_tree().find<Signal_context>(user_arg_1());
|
||||
if (!c) {
|
||||
Genode::warning(*this, ": cannot kill unknown signal context");
|
||||
Genode::raw(*this, ": cannot kill unknown signal context");
|
||||
user_arg_0(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
/* kill signal context */
|
||||
if (c->kill(this)) {
|
||||
Genode::warning("failed to kill signal context");
|
||||
Genode::raw("failed to kill signal context");
|
||||
user_arg_0(-1);
|
||||
return;
|
||||
}
|
||||
@ -567,7 +567,7 @@ void Thread::_call_new_irq()
|
||||
{
|
||||
Signal_context * const c = pd().cap_tree().find<Signal_context>(user_arg_3());
|
||||
if (!c) {
|
||||
Genode::warning(*this, ": invalid signal context for interrupt");
|
||||
Genode::raw(*this, ": invalid signal context for interrupt");
|
||||
user_arg_0(-1);
|
||||
return;
|
||||
}
|
||||
@ -589,7 +589,7 @@ void Thread::_call_new_obj()
|
||||
if (!thread ||
|
||||
(static_cast<Core_object<Thread>*>(thread)->capid() != ref->capid())) {
|
||||
if (thread)
|
||||
Genode::warning("faked thread", thread);
|
||||
Genode::raw("faked thread", thread);
|
||||
user_arg_0(cap_id_invalid());
|
||||
return;
|
||||
}
|
||||
@ -670,7 +670,7 @@ void Thread::_call()
|
||||
default:
|
||||
/* check wether this is a core thread */
|
||||
if (!_core) {
|
||||
Genode::warning(*this, ": not entitled to do kernel call");
|
||||
Genode::raw(*this, ": not entitled to do kernel call");
|
||||
_die();
|
||||
return;
|
||||
}
|
||||
@ -708,7 +708,7 @@ void Thread::_call()
|
||||
case call_id_new_obj(): _call_new_obj(); return;
|
||||
case call_id_delete_obj(): _call_delete_obj(); return;
|
||||
default:
|
||||
Genode::warning(*this, ": unknown kernel call");
|
||||
Genode::raw(*this, ": unknown kernel call");
|
||||
_die();
|
||||
return;
|
||||
}
|
||||
@ -723,12 +723,12 @@ void Thread::_mmu_exception()
|
||||
_fault.ip = regs->ip;
|
||||
|
||||
if (_fault.type == Thread_fault::UNKNOWN) {
|
||||
Genode::error(*this, " raised unhandled MMU fault ", _fault);
|
||||
Genode::raw(*this, " raised unhandled MMU fault ", _fault);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_core)
|
||||
Genode::error(*this, " raised a fault, which should never happen ",
|
||||
Genode::raw(*this, " raised a fault, which should never happen ",
|
||||
_fault);
|
||||
|
||||
if (_pager) _pager->submit(1);
|
||||
|
45
repos/base-hw/src/core/spec/arm/kernel/panic.cc
Normal file
45
repos/base-hw/src/core/spec/arm/kernel/panic.cc
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* \brief Kernel panic
|
||||
* \author Stefan Kalkowski
|
||||
* \date 2019-04-05
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2019 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#include <kernel/cpu.h>
|
||||
#include <kernel/kernel.h>
|
||||
|
||||
|
||||
void Kernel::panic(Genode::Cpu_state * state) {
|
||||
|
||||
Genode::raw("Kernel panic !!!");
|
||||
Genode::raw("Last saved cpu context follows:");
|
||||
Genode::raw("exc : ", state->cpu_exception);
|
||||
Genode::raw("r0 : ", (void*)state->r0);
|
||||
Genode::raw("r1 : ", (void*)state->r1);
|
||||
Genode::raw("r2 : ", (void*)state->r2);
|
||||
Genode::raw("r3 : ", (void*)state->r3);
|
||||
Genode::raw("r4 : ", (void*)state->r4);
|
||||
Genode::raw("r5 : ", (void*)state->r5);
|
||||
Genode::raw("r6 : ", (void*)state->r6);
|
||||
Genode::raw("r7 : ", (void*)state->r7);
|
||||
Genode::raw("r8 : ", (void*)state->r8);
|
||||
Genode::raw("r9 : ", (void*)state->r9);
|
||||
Genode::raw("r10 : ", (void*)state->r10);
|
||||
Genode::raw("r11 : ", (void*)state->r11);
|
||||
Genode::raw("r12 : ", (void*)state->r12);
|
||||
Genode::raw("lr : ", (void*)state->lr);
|
||||
Genode::raw("sp : ", (void*)state->sp);
|
||||
Genode::raw("ip : ", (void*)state->ip);
|
||||
Genode::raw("cpsr : ", (void*)state->cpsr);
|
||||
Genode::raw("dfar : ", Cpu::Dfar::read());
|
||||
Genode::raw("dfsr : ", Cpu::Dfsr::read());
|
||||
Genode::raw("ifar : ", Cpu::Ifar::read());
|
||||
Genode::raw("ifsr : ", Cpu::Ifsr::read());
|
||||
while (true) { ; }
|
||||
}
|
@ -37,15 +37,15 @@ void Thread::exception(Cpu & cpu)
|
||||
_interrupt(cpu.id());
|
||||
return;
|
||||
case Cpu::Context::UNDEFINED_INSTRUCTION:
|
||||
Genode::warning(*this, ": undefined instruction at ip=",
|
||||
Genode::Hex(regs->ip));
|
||||
Genode::raw(*this, ": undefined instruction at ip=",
|
||||
Genode::Hex(regs->ip));
|
||||
_die();
|
||||
return;
|
||||
case Cpu::Context::RESET:
|
||||
return;
|
||||
default:
|
||||
Genode::warning(*this, ": triggered an unknown exception ",
|
||||
regs->cpu_exception);
|
||||
Genode::raw(*this, ": triggered an unknown exception ",
|
||||
regs->cpu_exception);
|
||||
_die();
|
||||
return;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ void Vm::proceed(Cpu & cpu)
|
||||
unsigned const irq = _state->irq_injection;
|
||||
if (irq) {
|
||||
if (pic().secure(irq)) {
|
||||
Genode::warning("Refuse to inject secure IRQ into VM");
|
||||
Genode::raw("Refuse to inject secure IRQ into VM");
|
||||
} else {
|
||||
pic().trigger(irq);
|
||||
_state->irq_injection = 0;
|
||||
|
@ -70,7 +70,7 @@ struct Kernel::Vm_irq : Kernel::Irq
|
||||
Cpu_job & job = cpu_pool().executing_cpu().scheduled_job();
|
||||
Vm *vm = dynamic_cast<Vm*>(&job);
|
||||
if (!vm)
|
||||
Genode::error("VM timer interrupt while VM is not runnning!");
|
||||
Genode::raw("VM timer interrupt while VM is not runnning!");
|
||||
else
|
||||
vm->inject_irq(_irq_nr);
|
||||
}
|
||||
|
@ -43,9 +43,9 @@ void Thread::exception(Cpu & cpu)
|
||||
_mmu_exception();
|
||||
break;
|
||||
default:
|
||||
Genode::error(*this, ": unhandled exception ", regs->cpu_exception,
|
||||
" at ip=", (void*)regs->ip,
|
||||
" addr=", Genode::Hex(Genode::Cpu::Sbadaddr::read()));
|
||||
Genode::raw(*this, ": unhandled exception ", regs->cpu_exception,
|
||||
" at ip=", (void*)regs->ip,
|
||||
" addr=", Genode::Hex(Genode::Cpu::Sbadaddr::read()));
|
||||
_die();
|
||||
}
|
||||
}
|
||||
|
@ -29,11 +29,11 @@ void Thread::exception(Cpu & cpu)
|
||||
return;
|
||||
case Cpu_state::NO_MATH_COPROC:
|
||||
if (_cpu->fpu().fault(*regs)) { return; }
|
||||
Genode::warning(*this, ": FPU error");
|
||||
Genode::raw(*this, ": FPU error");
|
||||
_die();
|
||||
return;
|
||||
case Cpu_state::UNDEFINED_INSTRUCTION:
|
||||
Genode::warning(*this, ": undefined instruction at ip=", (void*)regs->ip);
|
||||
Genode::raw(*this, ": undefined instruction at ip=", (void*)regs->ip);
|
||||
_die();
|
||||
return;
|
||||
case Cpu_state::SUPERVISOR_CALL:
|
||||
@ -45,8 +45,8 @@ void Thread::exception(Cpu & cpu)
|
||||
_interrupt(cpu.id());
|
||||
return;
|
||||
}
|
||||
Genode::warning(*this, ": triggered unknown exception ", regs->trapno,
|
||||
" with error code ", regs->errcode, " at ip=", (void*)regs->ip, " sp=", (void*)regs->sp);
|
||||
Genode::raw(*this, ": triggered unknown exception ", regs->trapno,
|
||||
" with error code ", regs->errcode, " at ip=", (void*)regs->ip, " sp=", (void*)regs->sp);
|
||||
|
||||
_die();
|
||||
}
|
||||
|
@ -27,11 +27,11 @@ void Thread::exception(Cpu & cpu)
|
||||
return;
|
||||
case Cpu::Context::NO_MATH_COPROC:
|
||||
if (_cpu->fpu().fault(*regs)) { return; }
|
||||
Genode::warning(*this, ": FPU error");
|
||||
Genode::raw(*this, ": FPU error");
|
||||
_die();
|
||||
return;
|
||||
case Cpu::Context::UNDEFINED_INSTRUCTION:
|
||||
Genode::warning(*this, ": undefined instruction at ip=", (void*)regs->ip);
|
||||
Genode::raw(*this, ": undefined instruction at ip=", (void*)regs->ip);
|
||||
_die();
|
||||
return;
|
||||
case Cpu::Context::SUPERVISOR_CALL:
|
||||
@ -44,7 +44,7 @@ void Thread::exception(Cpu & cpu)
|
||||
_interrupt(cpu.id());
|
||||
return;
|
||||
}
|
||||
Genode::warning(*this, ": triggered unknown exception ", regs->trapno,
|
||||
" with error code ", regs->errcode, " at ip=", (void*)regs->ip);
|
||||
Genode::raw(*this, ": triggered unknown exception ", regs->trapno,
|
||||
" with error code ", regs->errcode, " at ip=", (void*)regs->ip);
|
||||
_die();
|
||||
}
|
||||
|
@ -49,8 +49,8 @@ void Kernel::Vm::exception(Cpu & cpu)
|
||||
_context->submit(1);
|
||||
return;
|
||||
}
|
||||
Genode::warning("VM: triggered unknown exception ", _state->trapno,
|
||||
" with error code ", _state->errcode);
|
||||
Genode::raw("VM: triggered unknown exception ", _state->trapno,
|
||||
" with error code ", _state->errcode);
|
||||
|
||||
ASSERT_NEVER_CALLED;
|
||||
}
|
||||
|
@ -34,20 +34,20 @@ Timer_driver::Timer_driver(unsigned) : ticks_per_ms(sinfo()->get_tsc_khz()), sta
|
||||
const struct Sinfo::Resource_type *
|
||||
region = sinfo()->get_resource("timed_event", Sinfo::RES_MEMORY);
|
||||
if (!region) {
|
||||
error("muen-timer: Unable to retrieve timed event region");
|
||||
raw("muen-timer: Unable to retrieve timed event region");
|
||||
throw Invalid_region();
|
||||
}
|
||||
|
||||
event_page = (Subject_timed_event *)
|
||||
Platform::mmio_to_virt(region->data.mem.address);
|
||||
event_page->event_nr = Board::TIMER_EVENT_KERNEL;
|
||||
log("muen-timer: Page @", Hex(region->data.mem.address), ", "
|
||||
raw("muen-timer: Page @", Hex(region->data.mem.address), ", "
|
||||
"frequency ", ticks_per_ms, " kHz, "
|
||||
"event ", (unsigned)event_page->event_nr);
|
||||
|
||||
region = sinfo()->get_resource("monitor_timed_event", Sinfo::RES_MEMORY);
|
||||
if (region) {
|
||||
log("muen-timer: Found guest timed event page @", Hex(region->data.mem.address),
|
||||
raw("muen-timer: Found guest timed event page @", Hex(region->data.mem.address),
|
||||
" -> enabling preemption");
|
||||
guest_event_page = (Subject_timed_event *)
|
||||
Platform::mmio_to_virt(region->data.mem.address);
|
||||
|
@ -67,7 +67,7 @@ Timer_driver::Timer_driver(unsigned)
|
||||
div && ticks_per_ms < TIMER_MIN_TICKS_PER_MS; div--)
|
||||
{
|
||||
if (!div){
|
||||
error("Failed to calibrate timer frequency");
|
||||
raw("Failed to calibrate timer frequency");
|
||||
throw Calibration_failed();
|
||||
}
|
||||
write<Divide_configuration::Divide_value>(div);
|
||||
|
@ -117,7 +117,7 @@ Sinfo::Sinfo(const addr_t base_addr)
|
||||
sched_info = ((Scheduling_info_type *)(base_addr + sinfo_page_size));
|
||||
|
||||
if (!check_magic()) {
|
||||
Genode::error("muen-sinfo: Subject information MAGIC mismatch");
|
||||
Genode::warning("muen-sinfo: Subject information MAGIC mismatch");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user