summaryrefslogtreecommitdiff
path: root/Kernel/init.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2018-11-05 13:48:07 +0100
committerAndreas Kling <awesomekling@gmail.com>2018-11-05 13:48:07 +0100
commit2d045d2a647ad5fab57fbb1ec8339a44b9770cc3 (patch)
treef00f3e64819657f25f3d36c56c3e0076d63d82a6 /Kernel/init.cpp
parente85c22fe58a39aa930251ad5e14c7dd6979a163f (diff)
downloadserenity-2d045d2a647ad5fab57fbb1ec8339a44b9770cc3.zip
Implement COW pages! :^)
sys$fork() now clones all writable regions with per-page COW bits. The pages are then mapped read-only and we handle a PF by COWing the pages. This is quite delightful. Obviously there's lots of work to do still, and it needs better data structures, but the general concept works.
Diffstat (limited to 'Kernel/init.cpp')
-rw-r--r--Kernel/init.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/Kernel/init.cpp b/Kernel/init.cpp
index ce41514fcc..aa4a339116 100644
--- a/Kernel/init.cpp
+++ b/Kernel/init.cpp
@@ -100,23 +100,34 @@ static void loadKsyms(const ByteBuffer& buffer)
s_ksyms_ready = true;
}
-void dump_backtrace()
+void dump_backtrace(bool use_ksyms)
{
- if (!current)
+ if (!current) {
+ HANG;
return;
+ }
extern volatile bool ksyms_ready();
- if (!ksyms_ready())
+ if (use_ksyms && !ksyms_ready()) {
+ HANG;
return;
- dword stack_variable;
+ }
struct RecognizedSymbol {
dword address;
const KSym* ksym;
};
Vector<RecognizedSymbol> recognizedSymbols;
- for (dword* stackPtr = &stack_variable; current->isValidAddressForKernel(LinearAddress((dword)stackPtr)); stackPtr = (dword*)*stackPtr) {
- dword retaddr = stackPtr[1];
- if (auto* ksym = ksymbolicate(retaddr))
- recognizedSymbols.append({ retaddr, ksym });
+ if (use_ksyms) {
+ for (dword* stackPtr = (dword*)&use_ksyms; current->isValidAddressForKernel(LinearAddress((dword)stackPtr)); stackPtr = (dword*)*stackPtr) {
+ dword retaddr = stackPtr[1];
+ if (auto* ksym = ksymbolicate(retaddr))
+ recognizedSymbols.append({ retaddr, ksym });
+ }
+ } else{
+ for (dword* stackPtr = (dword*)&use_ksyms; current->isValidAddressForKernel(LinearAddress((dword)stackPtr)); stackPtr = (dword*)*stackPtr) {
+ dword retaddr = stackPtr[1];
+ kprintf("%x (next: %x)\n", retaddr, stackPtr ? (dword*)*stackPtr : 0);
+ }
+ return;
}
size_t bytesNeeded = 0;
for (auto& symbol : recognizedSymbols) {