From 860e785a14245b167a77c1ef4d2b2df83230812a Mon Sep 17 00:00:00 2001 From: James Foster Date: Tue, 5 May 2020 16:30:40 -0700 Subject: [PATCH 1/2] Explain that panic() will produce a page fault if there is no console. --- k-ahci.cc | 2 ++ k-proc.cc | 2 ++ k-vmiter.cc | 2 ++ lib.hh | 2 ++ p-testkalloc.cc | 2 ++ u-lib.cc | 2 ++ 6 files changed, 12 insertions(+) diff --git a/k-ahci.cc b/k-ahci.cc index 4f15c87..6afb5dc 100644 --- a/k-ahci.cc +++ b/k-ahci.cc @@ -175,6 +175,8 @@ void ahcistate::handle_error_interrupt() { pr_->serror = ~0U; pr_->command |= pcmd_start; // XXX must `READ LOG EXT` to clear error + // Note that panic() will prouce a page fault if there is no console + // (https://github.com/CS161/chickadee/issues/14) panic("SATA disk error"); } diff --git a/k-proc.cc b/k-proc.cc index 70a8e88..ec90478 100644 --- a/k-proc.cc +++ b/k-proc.cc @@ -70,6 +70,8 @@ void proc::init_kernel(pid_t pid, void (*f)()) { // Called when `k-exception.S` tries to run a non-runnable proc. void proc::panic_nonrunnable() { + // Note that panic() will prouce a page fault if there is no console + // (https://github.com/CS161/chickadee/issues/14) panic("Trying to resume proc %d, which is not runnable\n" "(proc state %d, last user %%rip %p)", id_, pstate_.load(), last_user_rip_); diff --git a/k-vmiter.cc b/k-vmiter.cc index dbb0b6c..39ef52f 100644 --- a/k-vmiter.cc +++ b/k-vmiter.cc @@ -11,6 +11,8 @@ void vmiter::down() { pep_ = &pt->entry[pageindex(va_, level_)]; } if ((*pep_ & PTE_PAMASK) >= 0x100000000UL) { + // Note that panic() will prouce a page fault if there is no console + // (https://github.com/CS161/chickadee/issues/14) panic("Page table %p may contain uninitialized memory!\n" "(Page table contents: %p)\n", pt_, *pep_); } diff --git a/lib.hh b/lib.hh index 08f3adb..4d61d0c 100644 --- a/lib.hh +++ b/lib.hh @@ -474,6 +474,8 @@ assert_memeq_fail(const char* file, int line, const char* msg, // panic(format, ...) // Prints the message determined by `format` and fails. +// Note that panic() will prouce a page fault if there is no console +// (https://github.com/CS161/chickadee/issues/14) void __attribute__((noinline, noreturn, cold)) panic(const char* format, ...); diff --git a/p-testkalloc.cc b/p-testkalloc.cc index 5c5f02b..dd350c2 100644 --- a/p-testkalloc.cc +++ b/p-testkalloc.cc @@ -5,5 +5,7 @@ void process_main() { // Running `testkalloc` should cause the kernel to run buddy allocator // tests. How you make this work is up to you. + // Note that panic() will prouce a page fault if there is no console + // (https://github.com/CS161/chickadee/issues/14) panic("testkalloc not implemented!\n"); } diff --git a/u-lib.cc b/u-lib.cc index ef249cb..7605878 100644 --- a/u-lib.cc +++ b/u-lib.cc @@ -36,6 +36,8 @@ int printf(const char* format, ...) { // panic, assert_fail // Call the SYSCALL_PANIC system call so the kernel loops until Control-C. +// Note that panic() will prouce a page fault if there is no console +// (https://github.com/CS161/chickadee/issues/14) void panic(const char* format, ...) { va_list val; From ba1833fada7b4ac8c7dc086f546447dbe4c601a3 Mon Sep 17 00:00:00 2001 From: James Foster Date: Tue, 5 May 2020 16:40:18 -0700 Subject: [PATCH 2/2] Additional comment on panic(). --- k-hardware.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/k-hardware.cc b/k-hardware.cc index 92e7f1c..6e149d9 100644 --- a/k-hardware.cc +++ b/k-hardware.cc @@ -413,6 +413,8 @@ void __cxa_guard_release(long long* arg) { // __cxa_pure_virtual() // Used as a placeholder for pure virtual functions. void __cxa_pure_virtual() { + // Note that panic() will prouce a page fault if there is no console + // (https://github.com/CS161/chickadee/issues/14) panic("pure virtual function called in kernel!\n"); }