4
12
Fork
You've already forked LensorOS
4

fork and exec system calls, and everything that goes with them #17

Merged
LensPlaysGames merged 47 commits from fork_exec into main 2023年02月18日 20:19:05 +01:00

In this PR, we introduce a few new system calls to handle basic userspace multiprocessing techniques, like fork and exec.

fork creates a duplicate of the process that called it, and resumes the child at the same point as the parent, with the only difference being the return value of fork. This allows a child to know it's a child, and the parent to know it's apparently a parent, and alter control flow accordingly.

exec replaces the process that called it with a new one. The stack, program itself, and any allocated memory are removed and the stack, program, etc of a new executable are loaded in it's place. This allows, for example, the child of a fork to replace itself with any process. This gives the parent the ability to "run" any process while staying running itself.

waitpid alter's a process' state to SLEEPING, meaning the scheduler will no longer schedule it. This sleeping process is added to a waiting list on the process with the given PID; when that process exits, every process on the waiting list will have it's state set to RUNNING. This allows for a process to wait for another.

With these three system calls, a basic shell can be implemented, and from there we can begin to do crazy, whacky, userspace things

TODO:
exec has a lot of debug output because without it there is some sort of race condition or something and it crashes with a #PF or #GP; obviously, this needs fixed.

In this PR, we introduce a few new system calls to handle basic userspace multiprocessing techniques, like `fork` and `exec`. `fork` creates a duplicate of the process that called it, and resumes the child at the same point as the parent, with the only difference being the return value of `fork`. This allows a child to know it's a child, and the parent to know it's apparently a parent, and alter control flow accordingly. `exec` replaces the process that called it with a new one. The stack, program itself, and any allocated memory are removed and the stack, program, etc of a new executable are loaded in it's place. This allows, for example, the child of a `fork` to replace itself with any process. This gives the parent the ability to "run" any process while staying running itself. `waitpid` alter's a process' state to `SLEEPING`, meaning the scheduler will no longer schedule it. This sleeping process is added to a waiting list on the process with the given PID; when that process exits, every process on the waiting list will have it's state set to `RUNNING`. This allows for a process to wait for another. With these three system calls, a basic shell can be implemented, and from there we can begin to do crazy, whacky, userspace things TODO: `exec` has a *lot* of debug output because without it there is some sort of race condition or something and it crashes with a #PF or #GP; obviously, this needs fixed.
This is a collection of a lot of the things I've tried that haven't
worked, as well as some minor comments and formatting.
The OS does boot now, without #PFs out the wazoo, but only because the
child process is started sleeping, and never exits that state. If it
is ever attempted to run the child process, things break
heavily. Obviously, this is non-ideal and we are working tirelessly to
find a solution.
This doesn't help me at all in my *current* debugging, but lets hope
in a little bit it will pay off.
`fork` is now working as expected! It turns out it was the higher
levels of paging flags being overwritten by multiple map commands with
different permissions in a close area. With this fixed, we now have
the ability to duplicate the control flow of any program! How cool is
that?
There is a debug message at the end of `exec` that makes it not
crash. If it's removed, there is a #PF. Don't really know why.
The current process was hard coded into a lot of these things.
Kernel heap expansions need to be mapped in *all* processes page
tables.
It's a very basic shell, for testing purposes...
This was at the end of a long comment and got skipped, apparently.
Get rid of horrid forever loop and just use yield. It will return into
a new process, ending the interrupt.
It still doesn't work without the debug print statement, but now it is
commented out so anyone pulling will crash after pressing `a` a few
times.
Author
Owner
Copy link

I have no clue how to fix the bugs I'm encountering and it hurts my soul to even try to work on this at this point

I have no clue how to fix the bugs I'm encountering and it hurts my soul to even try to work on this at this point
Author
Owner
Copy link

Currently, QEMU reaches an unreachable assertion or something and just exits...

[kstage1]: Enabling interrupts
 Faulty Address: 0x00000000004000c0
 PageTable Address: 0x000000000075b000
4th lvl permissions | RW US AC NX
3rd lvl permissions | RW US AC NX
2nd lvl permissions | RW US AC NX
1st lvl permissions | US
PHYS 0x0000000001697000 at VIRT 0x00000000004000c0
 Instruction fetch
 From ring 3
 Read
CurrentProcess->ProcessID == 1
Present: 0x0000000000400000 to 0x0000000000408000 | US
Present: 0x0000000000408000 to 0x00000000004fd000 | RW US NX
Present: 0x0000000001794000 to 0x0000000001798000 | RW US
**
ERROR:../../../target/i386/tcg/sysemu/excp_helper.c:517:raise_stage2: code should not be reached
Bail out! ERROR:../../../target/i386/tcg/sysemu/excp_helper.c:517:raise_stage2: code should not be reached

... so that's fun. How did it come to this???

Currently, QEMU reaches an unreachable assertion or something and just exits... ``` [kstage1]: Enabling interrupts Faulty Address: 0x00000000004000c0 PageTable Address: 0x000000000075b000 4th lvl permissions | RW US AC NX 3rd lvl permissions | RW US AC NX 2nd lvl permissions | RW US AC NX 1st lvl permissions | US PHYS 0x0000000001697000 at VIRT 0x00000000004000c0 Instruction fetch From ring 3 Read CurrentProcess->ProcessID == 1 Present: 0x0000000000400000 to 0x0000000000408000 | US Present: 0x0000000000408000 to 0x00000000004fd000 | RW US NX Present: 0x0000000001794000 to 0x0000000001798000 | RW US ** ERROR:../../../target/i386/tcg/sysemu/excp_helper.c:517:raise_stage2: code should not be reached Bail out! ERROR:../../../target/i386/tcg/sysemu/excp_helper.c:517:raise_stage2: code should not be reached ``` ... so that's fun. How did it come to this???
Author
Owner
Copy link

The stupid part is that if we add back in the debug statement that used to fix things, this now happens

[kstage1]: Enabling interrupts
 Faulty Address: 0x00000000004000c0
 PageTable Address: 0x000000000075b000
4th lvl permissions | RW US AC NX
3rd lvl permissions | RW US AC NX
2nd lvl permissions | RW US AC NX
1st lvl permissions | US
PHYS 0x0000000001697000 at VIRT 0x00000000004000c0
 Instruction fetch
 From ring 3
 Read
CurrentProcess->ProcessID == 1
Present: 0x0000000000400000 to 0x0000000000408000 | US
Present: 0x0000000000408000 to 0x00000000004fd000 | RW US NX
Present: 0x0000000001794000 to 0x0000000001798000 | RW US
LensorOS PANIC
 General protection fault detected (0)!
 Error Code: 0x0000000000000000
 Instruction Address: 0xffffffff801207e4
 Stack Pointer: 0xffffffff80160b08
 GDT Selector Index: 0
The stupid part is that if we add *back* in the debug statement that used to fix things, this now happens ``` [kstage1]: Enabling interrupts Faulty Address: 0x00000000004000c0 PageTable Address: 0x000000000075b000 4th lvl permissions | RW US AC NX 3rd lvl permissions | RW US AC NX 2nd lvl permissions | RW US AC NX 1st lvl permissions | US PHYS 0x0000000001697000 at VIRT 0x00000000004000c0 Instruction fetch From ring 3 Read CurrentProcess->ProcessID == 1 Present: 0x0000000000400000 to 0x0000000000408000 | US Present: 0x0000000000408000 to 0x00000000004fd000 | RW US NX Present: 0x0000000001794000 to 0x0000000001798000 | RW US LensorOS PANIC General protection fault detected (0)! Error Code: 0x0000000000000000 Instruction Address: 0xffffffff801207e4 Stack Pointer: 0xffffffff80160b08 GDT Selector Index: 0 ```
We should probably move these into their own directory (like
`user/bin`), or just not provide pre-built userspace executables.
It has the cheese touch!
In actuality, the NX flag is still set in virtual pages, just not in
any of the hierarchical parent page structures.
Author
Owner
Copy link

bb8bacb3d5 has fixed the above #GP fault (with race condition debug output included)

[kstage1]: Enabling interrupts
[SYS$]: exit(420) -- Removed process 1
[kstage1]: Interrupts enabled
!===--- You have now booted into LensorOS ---===!
LensorOS Copyright (C) 2022, Contributors To LensorOS.
test
test2
test3
test4
Quitting.
[SYS$]: exit(0) -- Removed process 2
https://codeberg.org/LensPlaysGames/LensorOS/commit/bb8bacb3d5b018595308f43e7646a827311eec4d has fixed the above #GP fault (with race condition debug output included) ``` [kstage1]: Enabling interrupts [SYS$]: exit(420) -- Removed process 1 [kstage1]: Interrupts enabled !===--- You have now booted into LensorOS ---===! LensorOS Copyright (C) 2022, Contributors To LensorOS. test test2 test3 test4 Quitting. [SYS$]: exit(0) -- Removed process 2 ```
Author
Owner
Copy link

And the same for without the race condition debug output!

[kstage1]: Enabling interrupts
[SYS$]: exit(420) -- Removed process 1
[kstage1]: Interrupts enabled
!===--- You have now booted into LensorOS ---===!
LensorOS Copyright (C) 2022, Contributors To LensorOS.
test
test2
test3
test4
Quitting.
[SYS$]: exit(0) -- Removed process 2
And the same for without the race condition debug output! ``` [kstage1]: Enabling interrupts [SYS$]: exit(420) -- Removed process 1 [kstage1]: Interrupts enabled !===--- You have now booted into LensorOS ---===! LensorOS Copyright (C) 2022, Contributors To LensorOS. test test2 test3 test4 Quitting. [SYS$]: exit(0) -- Removed process 2 ```
Author
Owner
Copy link

Finally, here is what the output looks like when a process (specifically stdout) tries to fork and exec the child into the blazeit process.

[kstage1]: Enabling interrupts
[SYS$]: exit(420) -- Removed process 1
[kstage1]: Interrupts enabled
!===--- You have now booted into LensorOS ---===!
LensorOS Copyright (C) 2022, Contributors To LensorOS.
[SCHED]: Added process.
[SCHED]: Debug information:
 Process Queue:
 Process 0 at 0xffffffff8014c0a0
 CR3: 0x0000000000020000
 RAX: 0x0000000000000431
 RBX: 0x0000000000000000
 RCX: 0x0000000000000000
 RDX: 0xffffff80000eab50
 RSI: 0xffffff80000eab50
 RDI: 0x00000000c00eab50
 RBP: 0xffffffff801617c0
 RSP: 0xffffffff801616e0
 R8: 0x0000000000000190
 R9: 0x00000000ffffffff
 R10: 0xffffffff8014c065
 R11: 0xffffffff8014c068
 R12: 0xffffffff8013ed7d
 R13: 0x0000000000000013
 R14: 0xffffffff8013ed6a
 R15: 0x0000000000000012
 Frame:
 RIP: 0xffffffff8011b59e
 CS: 0x0000000000000008
 RFLAGS: 0x0000000000000293
 RSP: 0xffffffff80161790
 SS: 0x0000000000000010
 File Descriptors:
 Process 2 at 0xffffffffff0020e3
 CR3: 0x000000000179d000
 RAX: 0x000000000000000a
 RBX: 0x0000000000000000
 RCX: 0x0000000000000000
 RDX: 0x0000000000000000
 RSI: 0x0000000000408791
 RDI: 0x0000000000408338
 RBP: 0x00000000019e0f59
 RSP: 0x00000000019e0ef9
 R8: 0x0000000000000000
 R9: 0x0000000000000000
 R10: 0x0000000000000000
 R11: 0x0000000000000000
 R12: 0x0000000000000000
 R13: 0x0000000000000000
 R14: 0x0000000000000000
 R15: 0x0000000000000000
 Frame:
 RIP: 0x00000000004002aa
 CS: 0x000000000000001b
 RFLAGS: 0x0000000000000246
 RSP: 0x00000000019e0ef9
 SS: 0x0000000000000023
 File Descriptors:
 0 -> 4
 1 -> 5
 2 -> 6
 Process 3 at 0xffffffffff0037e5
 CR3: 0x00000000019e1000
 RAX: 0x0000000000000000
 RBX: 0x0000000000000000
 RCX: 0x0000000000000000
 RDX: 0x0000000000000000
 RSI: 0x0000000000408791
 RDI: 0x0000000000408338
 RBP: 0x00000000019e0f59
 RSP: 0x00000000019e0ef9
 R8: 0x0000000000000000
 R9: 0x0000000000000000
 R10: 0x0000000000000000
 R12: 0x0000000000000000
 R13: 0x0000000000000000
 R14: 0x0000000000000000
 R15: 0x0000000000000000
 Frame:
 RIP: 0x00000000004002aa
 CS: 0x000000000000001b
 RFLAGS: 0x0000000000000246
 RSP: 0x00000000019e0ef9
 SS: 0x0000000000000023
 File Descriptors:
 0 -> 3
 1 -> 2
 2 -> 1
test
test2
test3
test4
Child
 Faulty Address: 0xffffffff80160e58
 PageTable Address: 0x00000000019e1000
4th lvl permissions | RW AC
3rd lvl permissions | RW AC
2nd lvl permissions | RW AC
1st lvl permissions | RW AC DT
PHYS 0x0000000000160000 at VIRT 0xffffffff80160e58
 Data Access
 From ring 3
 Read
CurrentProcess->ProcessID == 3
Present: 0x0000000000400000 to 0x0000000000408000 | US
Present: 0x0000000000408000 to 0x00000000004fd000 | RW US NX
Present: 0x0000000001c21000 to 0x0000000001c24000 | RW US
Present: 0x0000000001c24000 to 0x0000000001c25000 | RW US AC DT
LensorOS PANIC
 #PF: User process attempted to read from a page and caused a protection fault
 Error Code: 0x0000000000000005
 Instruction Address: 0x00000000004000c0
 Stack Pointer: 0x0000000001c24ff0

As you can see, this makes no f$*#!^& sense and is why I don't like working on this.

A userspace process is, somehow, trying to read from a kernel address...

As you can see by the debug output generated the previous fork call: process with PID 3 has no kernel addresses set in it's registers.

Finally, here is what the output looks like when a process (specifically `stdout`) tries to fork and exec the child into the `blazeit` process. ``` [kstage1]: Enabling interrupts [SYS$]: exit(420) -- Removed process 1 [kstage1]: Interrupts enabled !===--- You have now booted into LensorOS ---===! LensorOS Copyright (C) 2022, Contributors To LensorOS. [SCHED]: Added process. [SCHED]: Debug information: Process Queue: Process 0 at 0xffffffff8014c0a0 CR3: 0x0000000000020000 RAX: 0x0000000000000431 RBX: 0x0000000000000000 RCX: 0x0000000000000000 RDX: 0xffffff80000eab50 RSI: 0xffffff80000eab50 RDI: 0x00000000c00eab50 RBP: 0xffffffff801617c0 RSP: 0xffffffff801616e0 R8: 0x0000000000000190 R9: 0x00000000ffffffff R10: 0xffffffff8014c065 R11: 0xffffffff8014c068 R12: 0xffffffff8013ed7d R13: 0x0000000000000013 R14: 0xffffffff8013ed6a R15: 0x0000000000000012 Frame: RIP: 0xffffffff8011b59e CS: 0x0000000000000008 RFLAGS: 0x0000000000000293 RSP: 0xffffffff80161790 SS: 0x0000000000000010 File Descriptors: Process 2 at 0xffffffffff0020e3 CR3: 0x000000000179d000 RAX: 0x000000000000000a RBX: 0x0000000000000000 RCX: 0x0000000000000000 RDX: 0x0000000000000000 RSI: 0x0000000000408791 RDI: 0x0000000000408338 RBP: 0x00000000019e0f59 RSP: 0x00000000019e0ef9 R8: 0x0000000000000000 R9: 0x0000000000000000 R10: 0x0000000000000000 R11: 0x0000000000000000 R12: 0x0000000000000000 R13: 0x0000000000000000 R14: 0x0000000000000000 R15: 0x0000000000000000 Frame: RIP: 0x00000000004002aa CS: 0x000000000000001b RFLAGS: 0x0000000000000246 RSP: 0x00000000019e0ef9 SS: 0x0000000000000023 File Descriptors: 0 -> 4 1 -> 5 2 -> 6 Process 3 at 0xffffffffff0037e5 CR3: 0x00000000019e1000 RAX: 0x0000000000000000 RBX: 0x0000000000000000 RCX: 0x0000000000000000 RDX: 0x0000000000000000 RSI: 0x0000000000408791 RDI: 0x0000000000408338 RBP: 0x00000000019e0f59 RSP: 0x00000000019e0ef9 R8: 0x0000000000000000 R9: 0x0000000000000000 R10: 0x0000000000000000 R12: 0x0000000000000000 R13: 0x0000000000000000 R14: 0x0000000000000000 R15: 0x0000000000000000 Frame: RIP: 0x00000000004002aa CS: 0x000000000000001b RFLAGS: 0x0000000000000246 RSP: 0x00000000019e0ef9 SS: 0x0000000000000023 File Descriptors: 0 -> 3 1 -> 2 2 -> 1 test test2 test3 test4 Child Faulty Address: 0xffffffff80160e58 PageTable Address: 0x00000000019e1000 4th lvl permissions | RW AC 3rd lvl permissions | RW AC 2nd lvl permissions | RW AC 1st lvl permissions | RW AC DT PHYS 0x0000000000160000 at VIRT 0xffffffff80160e58 Data Access From ring 3 Read CurrentProcess->ProcessID == 3 Present: 0x0000000000400000 to 0x0000000000408000 | US Present: 0x0000000000408000 to 0x00000000004fd000 | RW US NX Present: 0x0000000001c21000 to 0x0000000001c24000 | RW US Present: 0x0000000001c24000 to 0x0000000001c25000 | RW US AC DT LensorOS PANIC #PF: User process attempted to read from a page and caused a protection fault Error Code: 0x0000000000000005 Instruction Address: 0x00000000004000c0 Stack Pointer: 0x0000000001c24ff0 ``` As you can see, this makes no f$\*#!^& sense and is why I don't like working on this. A **userspace process** is, *somehow*, trying to read from a **kernel address**... As you can see by the debug output generated the previous `fork` call: process with PID 3 has no kernel addresses set in it's registers.
Author
Owner
Copy link

I tried increasing the size of the kernel stack through the prekernel known good stack allocation, but to no avail

I tried increasing the size of the kernel stack through the prekernel known good stack allocation, but to no avail
Author
Owner
Copy link

The new output (crashing after first exec)

[kstage1]: Enabling interrupts
[SYS$]: exit(420) -- Removed process 1
[kstage1]: Interrupts enabled
!===--- You have now booted into LensorOS ---===!
LensorOS Copyright (C) 2022, Contributors To LensorOS.
[SCHED]: Added process.
[SCHED]: Debug information:
 Process Queue:
 Process 0 at 0xffffffff8014c0a0
 CR3: 0x0000000000020000
 RAX: 0x0000000000000000
 RBX: 0x0000000004b6f2f8
 RCX: 0x0000000000000005
 RDX: 0x0000000000000018
 RSI: 0x0000000000000004
 RDI: 0xffffffff80148020
 RBP: 0xffffffff80161760
 RSP: 0xffffffff80161650
 R8: 0x0000000004b6f2f8
 R9: 0x00000000ffffffff
 R10: 0xffffffff8014c065
 R11: 0xffffffff8014c068
 R12: 0xffffffff8013ed7d
 R13: 0x0000000000000013
 R14: 0xffffffff8013ed6a
 R15: 0x0000000000000012
 Frame:
 RIP: 0xffffffff80104d2d
 CS: 0x0000000000000008
 RFLAGS: 0x0000000000000246
 RSP: 0xffffffff80161700
 SS: 0x0000000000000010
 File Descriptors:
 Process 2 at 0xffffffffff0020e3
 CR3: 0x000000000179d000
 RAX: 0x000000000000000a
 RBX: 0x0000000000000000
 RCX: 0x0000000000000000
 RDX: 0x0000000000000000
 RSI: 0x0000000000408791
 RDI: 0x0000000000408338
 RBP: 0x00000000019e0f59
 RSP: 0x00000000019e0ef9
 R8: 0x0000000000000000
 R9: 0x0000000000000000
 R10: 0x0000000000000000
 R11: 0x0000000000000000
 R12: 0x0000000000000000
 R13: 0x0000000000000000
 R14: 0x0000000000000000
 R15: 0x0000000000000000
 Frame:
 RIP: 0x00000000004002aa
 CS: 0x000000000000001b
 RFLAGS: 0x0000000000000246
 RSP: 0x00000000019e0ef9
 SS: 0x0000000000000023
 File Descriptors:
 0 -> 4
 1 -> 5
 2 -> 6
 Process 3 at 0xffffffffff0037e5
 CR3: 0x00000000019e1000
 RAX: 0x0000000000000000
 RBX: 0x0000000000000000
 RCX: 0x0000000000000000
 RDX: 0x0000000000000000
 RSI: 0x0000000000408791
 RDI: 0x0000000000408338
 RBP: 0x00000000019e0f59
 RSP: 0x00000000019e0ef9
 R8: 0x0000000000000000
 R9: 0x0000000000000000
 R10: 0x0000000000000000
 R12: 0x0000000000000000
 R13: 0x0000000000000000
 R14: 0x0000000000000000
 R15: 0x0000000000000000
 Frame:
 RIP: 0x00000000004002aa
 CS: 0x000000000000001b
 RFLAGS: 0x0000000000000246
 RSP: 0x00000000019e0ef9
 SS: 0x0000000000000023
 File Descriptors:
 0 -> 3
 1 -> 2
 2 -> 1
test
test2
test3
test4
Child
 Faulty Address: 0xffffffff80160e58
 PageTable Address: 0x00000000019e1000
4th lvl permissions | RW AC
3rd lvl permissions | RW AC
2nd lvl permissions | RW AC
1st lvl permissions | RW AC DT
PHYS 0x0000000000160000 at VIRT 0xffffffff80160e58
 Data Access
 From ring 3
 Read
CurrentProcess->ProcessID == 3
Present: 0x0000000000400000 to 0x0000000000408000 | US
Present: 0x0000000000408000 to 0x00000000004fd000 | RW US
Present: 0x0000000001c21000 to 0x0000000001c24000 | RW US
Present: 0x0000000001c24000 to 0x0000000001c25000 | RW US AC DT
LensorOS PANIC
 #PF: User process attempted to read from a page and caused a protection fault
 Error Code: 0x0000000000000005
 Instruction Address: 0x00000000004000c0
 Stack Pointer: 0x0000000001c24ff0

Here is the kicker (yes, that's not the crazy part): the disassembly at the instruction address causing the "read" fault...

00000000004000c0 <_start>:
 4000c0: f3 0f 1e fa endbr64
 4000c4: 48 31 ed xor %rbp,%rbp
 4000c7: 55 push %rbp
 4000c8: 48 89 e5 mov %rsp,%rbp
 4000cb: 48 8b 7c 24 08 mov 0x8(%rsp),%rdi
 4000d0: 48 8d 74 24 10 lea 0x10(%rsp),%rsi
 4000d5: 50 push %rax
 4000d6: e8 2e 04 00 00 call 400509 <__libc_run_main>
 4000db: 48 89 c7 mov %rax,%rdi
 4000de: e8 ab 42 00 00 call 40438e <_Exit>
 4000e3: 66 2e 0f 1f 84 00 00 cs nopw 0x0(%rax,%rax,1)
 4000ea: 00 00 00
 4000ed: 0f 1f 00 nopl (%rax)
 4000f0: 55 push %rbp
 4000f1: 48 89 e5 mov %rsp,%rbp
 4000f4: 53 push %rbx
 4000f5: 48 89 fb mov %rdi,%rbx
 4000f8: 48 83 ec 08 sub 0ドルx8,%rsp
 4000fc: e8 27 2a 00 00 call 402b28 <__memcpy_naive>
 400101: 48 89 d8 mov %rbx,%rax
 400104: 48 8b 5d f8 mov -0x8(%rbp),%rbx
 400108: c9 leave
 400109: c3 ret
 40010a: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1)
The new output (crashing after first exec) ``` [kstage1]: Enabling interrupts [SYS$]: exit(420) -- Removed process 1 [kstage1]: Interrupts enabled !===--- You have now booted into LensorOS ---===! LensorOS Copyright (C) 2022, Contributors To LensorOS. [SCHED]: Added process. [SCHED]: Debug information: Process Queue: Process 0 at 0xffffffff8014c0a0 CR3: 0x0000000000020000 RAX: 0x0000000000000000 RBX: 0x0000000004b6f2f8 RCX: 0x0000000000000005 RDX: 0x0000000000000018 RSI: 0x0000000000000004 RDI: 0xffffffff80148020 RBP: 0xffffffff80161760 RSP: 0xffffffff80161650 R8: 0x0000000004b6f2f8 R9: 0x00000000ffffffff R10: 0xffffffff8014c065 R11: 0xffffffff8014c068 R12: 0xffffffff8013ed7d R13: 0x0000000000000013 R14: 0xffffffff8013ed6a R15: 0x0000000000000012 Frame: RIP: 0xffffffff80104d2d CS: 0x0000000000000008 RFLAGS: 0x0000000000000246 RSP: 0xffffffff80161700 SS: 0x0000000000000010 File Descriptors: Process 2 at 0xffffffffff0020e3 CR3: 0x000000000179d000 RAX: 0x000000000000000a RBX: 0x0000000000000000 RCX: 0x0000000000000000 RDX: 0x0000000000000000 RSI: 0x0000000000408791 RDI: 0x0000000000408338 RBP: 0x00000000019e0f59 RSP: 0x00000000019e0ef9 R8: 0x0000000000000000 R9: 0x0000000000000000 R10: 0x0000000000000000 R11: 0x0000000000000000 R12: 0x0000000000000000 R13: 0x0000000000000000 R14: 0x0000000000000000 R15: 0x0000000000000000 Frame: RIP: 0x00000000004002aa CS: 0x000000000000001b RFLAGS: 0x0000000000000246 RSP: 0x00000000019e0ef9 SS: 0x0000000000000023 File Descriptors: 0 -> 4 1 -> 5 2 -> 6 Process 3 at 0xffffffffff0037e5 CR3: 0x00000000019e1000 RAX: 0x0000000000000000 RBX: 0x0000000000000000 RCX: 0x0000000000000000 RDX: 0x0000000000000000 RSI: 0x0000000000408791 RDI: 0x0000000000408338 RBP: 0x00000000019e0f59 RSP: 0x00000000019e0ef9 R8: 0x0000000000000000 R9: 0x0000000000000000 R10: 0x0000000000000000 R12: 0x0000000000000000 R13: 0x0000000000000000 R14: 0x0000000000000000 R15: 0x0000000000000000 Frame: RIP: 0x00000000004002aa CS: 0x000000000000001b RFLAGS: 0x0000000000000246 RSP: 0x00000000019e0ef9 SS: 0x0000000000000023 File Descriptors: 0 -> 3 1 -> 2 2 -> 1 test test2 test3 test4 Child Faulty Address: 0xffffffff80160e58 PageTable Address: 0x00000000019e1000 4th lvl permissions | RW AC 3rd lvl permissions | RW AC 2nd lvl permissions | RW AC 1st lvl permissions | RW AC DT PHYS 0x0000000000160000 at VIRT 0xffffffff80160e58 Data Access From ring 3 Read CurrentProcess->ProcessID == 3 Present: 0x0000000000400000 to 0x0000000000408000 | US Present: 0x0000000000408000 to 0x00000000004fd000 | RW US Present: 0x0000000001c21000 to 0x0000000001c24000 | RW US Present: 0x0000000001c24000 to 0x0000000001c25000 | RW US AC DT LensorOS PANIC #PF: User process attempted to read from a page and caused a protection fault Error Code: 0x0000000000000005 Instruction Address: 0x00000000004000c0 Stack Pointer: 0x0000000001c24ff0 ``` **Here** is the kicker (yes, that's not the crazy part): the disassembly at the instruction address causing the "read" fault... ``` 00000000004000c0 <_start>: 4000c0: f3 0f 1e fa endbr64 4000c4: 48 31 ed xor %rbp,%rbp 4000c7: 55 push %rbp 4000c8: 48 89 e5 mov %rsp,%rbp 4000cb: 48 8b 7c 24 08 mov 0x8(%rsp),%rdi 4000d0: 48 8d 74 24 10 lea 0x10(%rsp),%rsi 4000d5: 50 push %rax 4000d6: e8 2e 04 00 00 call 400509 <__libc_run_main> 4000db: 48 89 c7 mov %rax,%rdi 4000de: e8 ab 42 00 00 call 40438e <_Exit> 4000e3: 66 2e 0f 1f 84 00 00 cs nopw 0x0(%rax,%rax,1) 4000ea: 00 00 00 4000ed: 0f 1f 00 nopl (%rax) 4000f0: 55 push %rbp 4000f1: 48 89 e5 mov %rsp,%rbp 4000f4: 53 push %rbx 4000f5: 48 89 fb mov %rdi,%rbx 4000f8: 48 83 ec 08 sub 0ドルx8,%rsp 4000fc: e8 27 2a 00 00 call 402b28 <__memcpy_naive> 400101: 48 89 d8 mov %rbx,%rax 400104: 48 8b 5d f8 mov -0x8(%rbp),%rbx 400108: c9 leave 400109: c3 ret 40010a: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1) ```
Author
Owner
Copy link

Sometimes, it crashes here, in the kernel:

[kstage1]: Enabling interrupts
[SYS$]: exit(420) -- Removed process 1
[kstage1]: Interrupts enabled
!===--- You have now booted into LensorOS ---===!
LensorOS Copyright (C) 2022, Contributors To LensorOS.
[SCHED]: Added process.
[SCHED]: Debug information:
 Process Queue:
 Process 0 at 0xffffffff8014c0a0
 CR3: 0x0000000000020000
 RAX: 0x000000000000000a
 RBX: 0x0000000000000013
 RCX: 0x00000000000003d4
 RDX: 0x0000000000000070
 RSI: 0x000000000000000a
 RDI: 0x0000000000000070
 RBP: 0xffffffff80161800
 RSP: 0xffffffff80161740
 R8: 0x0000000000000190
 R9: 0x00000000ffffffff
 R10: 0xffffffff8014c065
 R11: 0xffffffff8014c068
 R12: 0xffffffff8013ed7d
 R13: 0x0000000000000013
 R14: 0xffffffff8013ed6a
 R15: 0x0000000000000012
 Frame:
 RIP: 0xffffffff80127297
 CS: 0x0000000000000008
 RFLAGS: 0x0000000000000296
 RSP: 0xffffffff801617f0
 SS: 0x0000000000000010
 File Descriptors:
 Process 2 at 0xffffffffff0020e3
 CR3: 0x000000000179d000
 RAX: 0x000000000000000a
 RBX: 0x0000000000000000
 RCX: 0x0000000000000000
 RDX: 0x0000000000000000
 RSI: 0x0000000000408791
 RDI: 0x0000000000408338
 RBP: 0x00000000019e0f59
 RSP: 0x00000000019e0ef9
 R8: 0x0000000000000000
 R9: 0x0000000000000000
 R10: 0x0000000000000000
 R11: 0x0000000000000000
 R12: 0x0000000000000000
 R13: 0x0000000000000000
 R14: 0x0000000000000000
 R15: 0x0000000000000000
 Frame:
 RIP: 0x00000000004002aa
 CS: 0x000000000000001b
 RFLAGS: 0x0000000000000246
 RSP: 0x00000000019e0ef9
 SS: 0x0000000000000023
 File Descriptors:
 0 -> 4
 1 -> 5
 2 -> 6
 Process 3 at 0xffffffffff0037e5
 CR3: 0x00000000019e1000
 RAX: 0x0000000000000000
 RBX: 0x0000000000000000
 RCX: 0x0000000000000000
 RDX: 0x0000000000000000
 RSI: 0x0000000000408791
 RDI: 0x0000000000408338
 RBP: 0x00000000019e0f59
 RSP: 0x00000000019e0ef9
 R8: 0x0000000000000000
 R9: 0x0000000000000000
 R10: 0x0000000000000000
 R11: 0x0000000000000000
 R12: 0x0000000000000000
 R13: 0x0000000000000000
 R14: 0x0000000000000000
 R15: 0x0000000000000000
 Frame:
 RIP: 0x00000000004002aa
 CS: 0x000000000000001b
 RFLAGS: 0x0000000000000246
 RSP: 0x00000000019e0ef9
 SS: 0x0000000000000023
 File Descriptors:
 0 -> 3
 1 -> 2
 2 -> 1
test
test2
test3
test4
Child
test
test2
test3
test4
Parent
[SYS$]: exit(420) -- Removed process 3
Parent
Parent waited
a[SCHED]: Added process.
[SCHED]: Debug information:
 Process Queue:
 Process 0 at 0xffffffff8014c0a0
 CR3: 0x0000000000020000
 RAX: 0x0000000000000009
 RBX: 0x0000000000000013
 RCX: 0x00000000000003d4
 RDX: 0x0000000000000070
 RSI: 0x0000000000000009
 RDI: 0x0000000000000070
 RBP: 0xffffffff801617e0
 RSP: 0xffffffff80161720
 R8: 0x0000000000000190
 R9: 0x00000000ffffffff
 R10: 0xffffffff8014c065
 R11: 0xffffffff8014c068
 R12: 0xffffffff8013ed7d
 R13: 0x0000000000000013
 R14: 0xffffffff8013ed6a
 R15: 0x0000000000000012
 Frame:
 RIP: 0xffffffff80114ed7
 CS: 0x0000000000000008
 RFLAGS: 0x0000000000000296
 RSP: 0xffffffff801617d0
 SS: 0x0000000000000010
 File Descriptors:
 Process 2 at 0xffffffffff0020e3
 CR3: 0x000000000179d000
 RAX: 0x000000000000000a
 RBX: 0x0000000000000000
 RCX: 0x0000000000000000
 RDX: 0x0000000000000000
 RSI: 0x0000000000408791
 RDI: 0x0000000000408338
 RBP: 0x00000000019e0f59
 RSP: 0x00000000019e0ef9
 R8: 0x0000000000000000
 R9: 0x0000000000000000
 R10: 0x0000000000000000
 R11: 0x0000000000000000
 R12: 0x0000000000000000
 R13: 0x0000000000000000
 R14: 0x0000000000000000
 R15: 0x0000000000000000
 Frame:
 RIP: 0x00000000004002aa
 CS: 0x000000000000001b
 RFLAGS: 0x0000000000000246
 RSP: 0x00000000019e0ef9
 SS: 0x0000000000000023
 File Descriptors:
 0 -> 4
 1 -> 5
 2 -> 6
 Process 4 at 0xffffffffff003c7e
 CR3: 0x0000000001b24000
 RAX: 0x0000000000000000
 RBX: 0x0000000000000000
 RCX: 0x0000000000000000
 RDX: 0x0000000000000000
 RSI: 0x0000000000408791
 RDI: 0x0000000000408338
 RBP: 0x00000000019e0f59
 RSP: 0x00000000019e0ef9
 R8: 0x0000000000000000
 R10: 0x0000000000000000
 R11: 0x0000000000000000
 R12: 0x0000000000000000
 R13: 0x0000000000000000
 R14: 0x0000000000000000
 R15: 0x0000000000000000
 Frame:
 RIP: 0x00000000004002aa
 CS: 0x000000000000001b
 RFLAGS: 0x0000000000000246
 RSP: 0x00000000019e0ef9
 SS: 0x0000000000000023
 File Descriptors:
 0 -> 1
 1 -> 2
 2 -> 3
Parent
Child
 Faulty Address: 0xffffffff80160e58
 PageTable Address: 0x0000000001b24000
4th lvl permissions | RW AC
3rd lvl permissions | RW AC
2nd lvl permissions | RW AC
1st lvl permissions | RW AC DT
PHYS 0x0000000000160000 at VIRT 0xffffffff80160e58
 Data Access
 From ring 3
 Read
CurrentProcess->ProcessID == 4
Present: 0x0000000000400000 to 0x0000000000408000 | US
Present: 0x0000000000408000 to 0x00000000004fd000 | RW US
Present: 0x0000000001d64000 to 0x0000000001d67000 | RW US
Present: 0x0000000001d67000 to 0x0000000001d68000 | RW US AC DT
LensorOS PANIC
 General protection fault detected (0)!
 Error Code: 0x0000000000000000
 Instruction Address: 0xffffffff80120619
 Stack Pointer: 0xffffffff80160b08
 GDT Selector Index: 0

And here is the disassembly of that address.

ffffffff801204a8 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE>:
ffffffff801204a8: 55 push %rbp
ffffffff801204a9: 48 89 e5 mov %rsp,%rbp
ffffffff801204ac: 41 57 push %r15
ffffffff801204ae: 41 56 push %r14
ffffffff801204b0: 41 55 push %r13
ffffffff801204b2: 41 54 push %r12
ffffffff801204b4: 53 push %rbx
ffffffff801204b5: 48 81 ec 08 01 00 00 sub 0ドルx108,%rsp
ffffffff801204bc: 48 89 bd 68 ff ff ff mov %rdi,-0x98(%rbp)
ffffffff801204c3: 48 89 b5 60 ff ff ff mov %rsi,-0xa0(%rbp)
ffffffff801204ca: 48 c7 45 80 ff ff ff movq 0ドルxffffffffffffffff,-0x80(%rbp)
ffffffff801204d1: ff
ffffffff801204d2: 48 c7 85 78 ff ff ff movq 0ドルxffffffffffffffff,-0x88(%rbp)
ffffffff801204d9: ff ff ff ff
ffffffff801204dd: 48 c7 45 c8 ff ff ff movq 0ドルxffffffffffffffff,-0x38(%rbp)
ffffffff801204e4: ff
ffffffff801204e5: 48 c7 85 70 ff ff ff movq 0ドルx0,-0x90(%rbp)
ffffffff801204ec: 00 00 00 00
ffffffff801204f0: 48 c7 45 c0 00 00 00 movq 0ドルx0,-0x40(%rbp)
ffffffff801204f7: 00
ffffffff801204f8: e9 3f 05 00 00 jmp ffffffff80120a3c <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x594>
ffffffff801204fd: 48 8b 95 68 ff ff ff mov -0x98(%rbp),%rdx
ffffffff80120504: 48 8b 45 c0 mov -0x40(%rbp),%rax
ffffffff80120508: 48 8b 04 c2 mov (%rdx,%rax,8),%rax
ffffffff8012050c: 48 89 85 70 ff ff ff mov %rax,-0x90(%rbp)
ffffffff80120513: 48 8d 85 70 ff ff ff lea -0x90(%rbp),%rax
ffffffff8012051a: be 01 00 00 00 mov 0ドルx1,%esi
ffffffff8012051f: 48 89 c7 mov %rax,%rdi
ffffffff80120522: e8 1b 09 00 00 call ffffffff80120e42 <_ZN6Memory18PageDirectoryEntry4flagENS_13PageTableFlagE>
ffffffff80120527: 0f b6 c0 movzbl %al,%eax
ffffffff8012052a: 85 c0 test %eax,%eax
ffffffff8012052c: 0f 94 c0 sete %al
ffffffff8012052f: 84 c0 test %al,%al
ffffffff80120531: 0f 85 ff 04 00 00 jne ffffffff80120a36 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x58e>
ffffffff80120537: 48 8d 85 70 ff ff ff lea -0x90(%rbp),%rax
ffffffff8012053e: 48 89 c7 mov %rax,%rdi
ffffffff80120541: e8 7c 08 00 00 call ffffffff80120dc2 <_ZN6Memory18PageDirectoryEntry7addressEv>
ffffffff80120546: 48 c1 e0 0c shl 0ドルxc,%rax
ffffffff8012054a: 48 89 45 a0 mov %rax,-0x60(%rbp)
ffffffff8012054e: 48 c7 45 b8 00 00 00 movq 0ドルx0,-0x48(%rbp)
ffffffff80120555: 00
ffffffff80120556: e9 cb 04 00 00 jmp ffffffff80120a26 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x57e>
ffffffff8012055b: 48 8b 55 a0 mov -0x60(%rbp),%rdx
ffffffff8012055f: 48 8b 45 b8 mov -0x48(%rbp),%rax
ffffffff80120563: 48 8b 04 c2 mov (%rdx,%rax,8),%rax
ffffffff80120567: 48 89 85 70 ff ff ff mov %rax,-0x90(%rbp)
ffffffff8012056e: 48 8d 85 70 ff ff ff lea -0x90(%rbp),%rax
ffffffff80120575: be 01 00 00 00 mov 0ドルx1,%esi
ffffffff8012057a: 48 89 c7 mov %rax,%rdi
ffffffff8012057d: e8 c0 08 00 00 call ffffffff80120e42 <_ZN6Memory18PageDirectoryEntry4flagENS_13PageTableFlagE>
ffffffff80120582: 0f b6 c0 movzbl %al,%eax
ffffffff80120585: 85 c0 test %eax,%eax
ffffffff80120587: 0f 94 c0 sete %al
ffffffff8012058a: 84 c0 test %al,%al
ffffffff8012058c: 0f 85 8e 04 00 00 jne ffffffff80120a20 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x578>
ffffffff80120592: 48 8d 85 70 ff ff ff lea -0x90(%rbp),%rax
ffffffff80120599: 48 89 c7 mov %rax,%rdi
ffffffff8012059c: e8 21 08 00 00 call ffffffff80120dc2 <_ZN6Memory18PageDirectoryEntry7addressEv>
ffffffff801205a1: 48 c1 e0 0c shl 0ドルxc,%rax
ffffffff801205a5: 48 89 45 98 mov %rax,-0x68(%rbp)
ffffffff801205a9: 48 c7 45 b0 00 00 00 movq 0ドルx0,-0x50(%rbp)
ffffffff801205b0: 00
ffffffff801205b1: e9 5a 04 00 00 jmp ffffffff80120a10 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x568>
ffffffff801205b6: 48 8b 55 98 mov -0x68(%rbp),%rdx
ffffffff801205ba: 48 8b 45 b0 mov -0x50(%rbp),%rax
ffffffff801205be: 48 8b 04 c2 mov (%rdx,%rax,8),%rax
ffffffff801205c2: 48 89 85 70 ff ff ff mov %rax,-0x90(%rbp)
ffffffff801205c9: 48 8d 85 70 ff ff ff lea -0x90(%rbp),%rax
ffffffff801205d0: be 01 00 00 00 mov 0ドルx1,%esi
ffffffff801205d5: 48 89 c7 mov %rax,%rdi
ffffffff801205d8: e8 65 08 00 00 call ffffffff80120e42 <_ZN6Memory18PageDirectoryEntry4flagENS_13PageTableFlagE>
ffffffff801205dd: 0f b6 c0 movzbl %al,%eax
ffffffff801205e0: 85 c0 test %eax,%eax
ffffffff801205e2: 0f 94 c0 sete %al
ffffffff801205e5: 84 c0 test %al,%al
ffffffff801205e7: 0f 85 1d 04 00 00 jne ffffffff80120a0a <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x562>
ffffffff801205ed: 48 8d 85 70 ff ff ff lea -0x90(%rbp),%rax
ffffffff801205f4: 48 89 c7 mov %rax,%rdi
ffffffff801205f7: e8 c6 07 00 00 call ffffffff80120dc2 <_ZN6Memory18PageDirectoryEntry7addressEv>
ffffffff801205fc: 48 c1 e0 0c shl 0ドルxc,%rax
ffffffff80120600: 48 89 45 90 mov %rax,-0x70(%rbp)
ffffffff80120604: 48 c7 45 a8 00 00 00 movq 0ドルx0,-0x58(%rbp)
ffffffff8012060b: 00
ffffffff8012060c: e9 e9 03 00 00 jmp ffffffff801209fa <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x552>
ffffffff80120611: 48 8b 55 90 mov -0x70(%rbp),%rdx
ffffffff80120615: 48 8b 45 a8 mov -0x58(%rbp),%rax
ffffffff80120619: 48 8b 04 c2 mov (%rdx,%rax,8),%rax
ffffffff8012061d: 48 89 85 70 ff ff ff mov %rax,-0x90(%rbp)
ffffffff80120624: 48 c7 45 88 00 00 00 movq 0ドルx0,-0x78(%rbp)
ffffffff8012062b: 00
ffffffff8012062c: 48 8b 45 c0 mov -0x40(%rbp),%rax
ffffffff80120630: 48 c1 e0 1b shl 0ドルx1b,%rax
ffffffff80120634: 48 89 c2 mov %rax,%rdx
ffffffff80120637: 48 b8 00 00 00 f8 0f movabs 0ドルxff8000000,%rax
ffffffff8012063e: 00 00 00
ffffffff80120641: 48 21 d0 and %rdx,%rax
ffffffff80120644: 48 09 45 88 or %rax,-0x78(%rbp)
ffffffff80120648: 48 8b 45 b8 mov -0x48(%rbp),%rax
ffffffff8012064c: 48 c1 e0 12 shl 0ドルx12,%rax
ffffffff80120650: 25 00 00 fc 07 and 0ドルx7fc0000,%eax
ffffffff80120655: 48 09 45 88 or %rax,-0x78(%rbp)
ffffffff80120659: 48 8b 45 b0 mov -0x50(%rbp),%rax
ffffffff8012065d: 48 c1 e0 09 shl 0ドルx9,%rax
ffffffff80120661: 25 00 fe 03 00 and 0ドルx3fe00,%eax
ffffffff80120666: 48 09 45 88 or %rax,-0x78(%rbp)
ffffffff8012066a: 48 8b 45 a8 mov -0x58(%rbp),%rax
ffffffff8012066e: 25 ff 01 00 00 and 0ドルx1ff,%eax
ffffffff80120673: 48 09 45 88 or %rax,-0x78(%rbp)
ffffffff80120677: 48 c1 65 88 0c shlq 0ドルxc,-0x78(%rbp)
ffffffff8012067c: 48 8b 45 88 mov -0x78(%rbp),%rax
ffffffff80120680: 48 89 85 78 ff ff ff mov %rax,-0x88(%rbp)
ffffffff80120687: 48 83 7d c8 ff cmpq 0ドルxffffffffffffffff,-0x38(%rbp)
ffffffff8012068c: 74 1c je ffffffff801206aa <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x202>
ffffffff8012068e: 48 8d 85 70 ff ff ff lea -0x90(%rbp),%rax
ffffffff80120695: 48 89 c7 mov %rax,%rdi
ffffffff80120698: e8 c9 07 00 00 call ffffffff80120e66 <_ZN6Memory18PageDirectoryEntry5flagsEv>
ffffffff8012069d: 48 39 45 c8 cmp %rax,-0x38(%rbp)
ffffffff801206a1: 74 07 je ffffffff801206aa <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x202>
ffffffff801206a3: b8 01 00 00 00 mov 0ドルx1,%eax
ffffffff801206a8: eb 05 jmp ffffffff801206af <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x207>
ffffffff801206aa: b8 00 00 00 00 mov 0ドルx0,%eax
ffffffff801206af: 84 c0 test %al,%al
ffffffff801206b1: 0f 84 0f 03 00 00 je ffffffff801209c6 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x51e>
ffffffff801206b7: 48 8b 45 c8 mov -0x38(%rbp),%rax
ffffffff801206bb: 83 e0 01 and 0ドルx1,%eax
ffffffff801206be: 48 85 c0 test %rax,%rax
ffffffff801206c1: 0f 84 df 02 00 00 je ffffffff801209a6 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x4fe>
ffffffff801206c7: 48 8b 45 c8 mov -0x38(%rbp),%rax
ffffffff801206cb: 48 23 85 60 ff ff ff and -0xa0(%rbp),%rax
ffffffff801206d2: 48 39 85 60 ff ff ff cmp %rax,-0xa0(%rbp)
ffffffff801206d9: 0f 85 c7 02 00 00 jne ffffffff801209a6 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x4fe>
ffffffff801206df: 48 c7 85 d0 fe ff ff movq 0ドルxffffffff80141378,-0x130(%rbp)
ffffffff801206e6: 78 13 14 80
ffffffff801206ea: 48 c7 85 d8 fe ff ff movq 0ドルx1f,-0x128(%rbp)
ffffffff801206f1: 1f 00 00 00
ffffffff801206f5: 48 8d bd 78 ff ff ff lea -0x88(%rbp),%rdi
ffffffff801206fc: 48 8d 75 80 lea -0x80(%rbp),%rsi
ffffffff80120700: 48 8b 85 d0 fe ff ff mov -0x130(%rbp),%rax
ffffffff80120707: 48 8b 95 d8 fe ff ff mov -0x128(%rbp),%rdx
ffffffff8012070e: 48 89 c1 mov %rax,%rcx
ffffffff80120711: 48 89 d3 mov %rdx,%rbx
ffffffff80120714: 49 89 c8 mov %rcx,%r8
ffffffff80120717: 48 89 d0 mov %rdx,%rax
ffffffff8012071a: 48 89 f9 mov %rdi,%rcx
ffffffff8012071d: 48 89 f2 mov %rsi,%rdx
ffffffff80120720: 4c 89 c7 mov %r8,%rdi
ffffffff80120723: 48 89 c6 mov %rax,%rsi
ffffffff80120726: e8 71 0a 00 00 call ffffffff8012119c <_ZSt5printIJRmS0_EEvSt19basic_format_stringIcJDpNSt13type_identityIT_E4typeEEEDpOS3_>
ffffffff8012072b: 48 8b 45 c8 mov -0x38(%rbp),%rax
ffffffff8012072f: 83 e0 02 and 0ドルx2,%eax
ffffffff80120732: 48 85 c0 test %rax,%rax
ffffffff80120735: 74 38 je ffffffff8012076f <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x2c7>
ffffffff80120737: 48 c7 85 e0 fe ff ff movq 0ドルxffffffff80141398,-0x120(%rbp)
ffffffff8012073e: 98 13 14 80
ffffffff80120742: 48 c7 85 e8 fe ff ff movq 0ドルx3,-0x118(%rbp)
ffffffff80120749: 03 00 00 00
ffffffff8012074d: 48 8b 85 e0 fe ff ff mov -0x120(%rbp),%rax
ffffffff80120754: 48 8b 95 e8 fe ff ff mov -0x118(%rbp),%rdx
ffffffff8012075b: 48 89 c1 mov %rax,%rcx
ffffffff8012075e: 48 89 d3 mov %rdx,%rbx
ffffffff80120761: 48 89 d0 mov %rdx,%rax
ffffffff80120764: 48 89 cf mov %rcx,%rdi
ffffffff80120767: 48 89 c6 mov %rax,%rsi
ffffffff8012076a: e8 e7 05 fe ff call ffffffff80100d56 <_ZSt5printIJEEvSt19basic_format_stringIcJDpNSt13type_identityIT_E4typeEEEDpOS2_>
ffffffff8012076f: 48 8b 45 c8 mov -0x38(%rbp),%rax
ffffffff80120773: 83 e0 04 and 0ドルx4,%eax
ffffffff80120776: 48 85 c0 test %rax,%rax
ffffffff80120779: 74 38 je ffffffff801207b3 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x30b>
ffffffff8012077b: 48 c7 85 f0 fe ff ff movq 0ドルxffffffff8014139c,-0x110(%rbp)
ffffffff80120782: 9c 13 14 80
ffffffff80120786: 48 c7 85 f8 fe ff ff movq 0ドルx3,-0x108(%rbp)
ffffffff8012078d: 03 00 00 00
ffffffff80120791: 48 8b 85 f0 fe ff ff mov -0x110(%rbp),%rax
ffffffff80120798: 48 8b 95 f8 fe ff ff mov -0x108(%rbp),%rdx
ffffffff8012079f: 48 89 c1 mov %rax,%rcx
ffffffff801207a2: 48 89 d3 mov %rdx,%rbx
ffffffff801207a5: 48 89 d0 mov %rdx,%rax
ffffffff801207a8: 48 89 cf mov %rcx,%rdi
ffffffff801207ab: 48 89 c6 mov %rax,%rsi
ffffffff801207ae: e8 a3 05 fe ff call ffffffff80100d56 <_ZSt5printIJEEvSt19basic_format_stringIcJDpNSt13type_identityIT_E4typeEEEDpOS2_>
ffffffff801207b3: 48 8b 45 c8 mov -0x38(%rbp),%rax
ffffffff801207b7: 83 e0 08 and 0ドルx8,%eax
ffffffff801207ba: 48 85 c0 test %rax,%rax
ffffffff801207bd: 74 38 je ffffffff801207f7 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x34f>
ffffffff801207bf: 48 c7 85 00 ff ff ff movq 0ドルxffffffff801413a0,-0x100(%rbp)
ffffffff801207c6: a0 13 14 80
ffffffff801207ca: 48 c7 85 08 ff ff ff movq 0ドルx3,-0xf8(%rbp)
ffffffff801207d1: 03 00 00 00
ffffffff801207d5: 48 8b 85 00 ff ff ff mov -0x100(%rbp),%rax
ffffffff801207dc: 48 8b 95 08 ff ff ff mov -0xf8(%rbp),%rdx
ffffffff801207e3: 48 89 c1 mov %rax,%rcx
ffffffff801207e6: 48 89 d3 mov %rdx,%rbx
ffffffff801207e9: 48 89 d0 mov %rdx,%rax
ffffffff801207ec: 48 89 cf mov %rcx,%rdi
ffffffff801207ef: 48 89 c6 mov %rax,%rsi
ffffffff801207f2: e8 5f 05 fe ff call ffffffff80100d56 <_ZSt5printIJEEvSt19basic_format_stringIcJDpNSt13type_identityIT_E4typeEEEDpOS2_>
ffffffff801207f7: 48 8b 45 c8 mov -0x38(%rbp),%rax
ffffffff801207fb: 83 e0 10 and 0ドルx10,%eax
ffffffff801207fe: 48 85 c0 test %rax,%rax
ffffffff80120801: 74 38 je ffffffff8012083b <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x393>
ffffffff80120803: 48 c7 85 10 ff ff ff movq 0ドルxffffffff801413a4,-0xf0(%rbp)
ffffffff8012080a: a4 13 14 80
ffffffff8012080e: 48 c7 85 18 ff ff ff movq 0ドルx3,-0xe8(%rbp)
ffffffff80120815: 03 00 00 00
ffffffff80120819: 48 8b 85 10 ff ff ff mov -0xf0(%rbp),%rax
ffffffff80120820: 48 8b 95 18 ff ff ff mov -0xe8(%rbp),%rdx
ffffffff80120827: 48 89 c1 mov %rax,%rcx
ffffffff8012082a: 48 89 d3 mov %rdx,%rbx
ffffffff8012082d: 48 89 d0 mov %rdx,%rax
ffffffff80120830: 48 89 cf mov %rcx,%rdi
ffffffff80120833: 48 89 c6 mov %rax,%rsi
ffffffff80120836: e8 1b 05 fe ff call ffffffff80100d56 <_ZSt5printIJEEvSt19basic_format_stringIcJDpNSt13type_identityIT_E4typeEEEDpOS2_>
ffffffff8012083b: 48 8b 45 c8 mov -0x38(%rbp),%rax
ffffffff8012083f: 83 e0 20 and 0ドルx20,%eax
ffffffff80120842: 48 85 c0 test %rax,%rax
ffffffff80120845: 74 38 je ffffffff8012087f <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x3d7>
ffffffff80120847: 48 c7 85 20 ff ff ff movq 0ドルxffffffff801413a8,-0xe0(%rbp)
ffffffff8012084e: a8 13 14 80
ffffffff80120852: 48 c7 85 28 ff ff ff movq 0ドルx3,-0xd8(%rbp)
ffffffff80120859: 03 00 00 00
ffffffff8012085d: 48 8b 85 20 ff ff ff mov -0xe0(%rbp),%rax
ffffffff80120864: 48 8b 95 28 ff ff ff mov -0xd8(%rbp),%rdx
ffffffff8012086b: 48 89 c1 mov %rax,%rcx
ffffffff8012086e: 48 89 d3 mov %rdx,%rbx
ffffffff80120871: 48 89 d0 mov %rdx,%rax
ffffffff80120874: 48 89 cf mov %rcx,%rdi
ffffffff80120877: 48 89 c6 mov %rax,%rsi
ffffffff8012087a: e8 d7 04 fe ff call ffffffff80100d56 <_ZSt5printIJEEvSt19basic_format_stringIcJDpNSt13type_identityIT_E4typeEEEDpOS2_>
ffffffff8012087f: 48 8b 45 c8 mov -0x38(%rbp),%rax
ffffffff80120883: 83 e0 40 and 0ドルx40,%eax
ffffffff80120886: 48 85 c0 test %rax,%rax
ffffffff80120889: 74 38 je ffffffff801208c3 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x41b>
ffffffff8012088b: 48 c7 85 30 ff ff ff movq 0ドルxffffffff801413ac,-0xd0(%rbp)
ffffffff80120892: ac 13 14 80
ffffffff80120896: 48 c7 85 38 ff ff ff movq 0ドルx3,-0xc8(%rbp)
ffffffff8012089d: 03 00 00 00
ffffffff801208a1: 48 8b 85 30 ff ff ff mov -0xd0(%rbp),%rax
ffffffff801208a8: 48 8b 95 38 ff ff ff mov -0xc8(%rbp),%rdx
ffffffff801208af: 48 89 c1 mov %rax,%rcx
ffffffff801208b2: 48 89 d3 mov %rdx,%rbx
ffffffff801208b5: 48 89 d0 mov %rdx,%rax
ffffffff801208b8: 48 89 cf mov %rcx,%rdi
ffffffff801208bb: 48 89 c6 mov %rax,%rsi
ffffffff801208be: e8 93 04 fe ff call ffffffff80100d56 <_ZSt5printIJEEvSt19basic_format_stringIcJDpNSt13type_identityIT_E4typeEEEDpOS2_>
ffffffff801208c3: 48 8b 45 c8 mov -0x38(%rbp),%rax
ffffffff801208c7: 25 80 00 00 00 and 0ドルx80,%eax
ffffffff801208cc: 48 85 c0 test %rax,%rax
ffffffff801208cf: 74 38 je ffffffff80120909 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x461>
ffffffff801208d1: 48 c7 85 40 ff ff ff movq 0ドルxffffffff801413b0,-0xc0(%rbp)
ffffffff801208d8: b0 13 14 80
ffffffff801208dc: 48 c7 85 48 ff ff ff movq 0ドルx3,-0xb8(%rbp)
ffffffff801208e3: 03 00 00 00
ffffffff801208e7: 48 8b 85 40 ff ff ff mov -0xc0(%rbp),%rax
ffffffff801208ee: 48 8b 95 48 ff ff ff mov -0xb8(%rbp),%rdx
ffffffff801208f5: 48 89 c1 mov %rax,%rcx
ffffffff801208f8: 48 89 d3 mov %rdx,%rbx
ffffffff801208fb: 48 89 d0 mov %rdx,%rax
ffffffff801208fe: 48 89 cf mov %rcx,%rdi
ffffffff80120901: 48 89 c6 mov %rax,%rsi
ffffffff80120904: e8 4d 04 fe ff call ffffffff80100d56 <_ZSt5printIJEEvSt19basic_format_stringIcJDpNSt13type_identityIT_E4typeEEEDpOS2_>
ffffffff80120909: 48 8b 45 c8 mov -0x38(%rbp),%rax
ffffffff8012090d: 25 00 01 00 00 and 0ドルx100,%eax
ffffffff80120912: 48 85 c0 test %rax,%rax
ffffffff80120915: 74 38 je ffffffff8012094f <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x4a7>
ffffffff80120917: 48 c7 85 50 ff ff ff movq 0ドルxffffffff801413b4,-0xb0(%rbp)
ffffffff8012091e: b4 13 14 80
ffffffff80120922: 48 c7 85 58 ff ff ff movq 0ドルx3,-0xa8(%rbp)
ffffffff80120929: 03 00 00 00
ffffffff8012092d: 48 8b 85 50 ff ff ff mov -0xb0(%rbp),%rax
ffffffff80120934: 48 8b 95 58 ff ff ff mov -0xa8(%rbp),%rdx
ffffffff8012093b: 48 89 c1 mov %rax,%rcx
ffffffff8012093e: 48 89 d3 mov %rdx,%rbx
ffffffff80120941: 48 89 d0 mov %rdx,%rax
ffffffff80120944: 48 89 cf mov %rcx,%rdi
ffffffff80120947: 48 89 c6 mov %rax,%rsi
ffffffff8012094a: e8 07 04 fe ff call ffffffff80100d56 <_ZSt5printIJEEvSt19basic_format_stringIcJDpNSt13type_identityIT_E4typeEEEDpOS2_>
ffffffff8012094f: 48 8b 45 c8 mov -0x38(%rbp),%rax
ffffffff80120953: 48 85 c0 test %rax,%rax
ffffffff80120956: 79 27 jns ffffffff8012097f <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x4d7>
ffffffff80120958: 49 c7 c6 b8 13 14 80 mov 0ドルxffffffff801413b8,%r14
ffffffff8012095f: 41 bf 03 00 00 00 mov 0ドルx3,%r15d
ffffffff80120965: 4c 89 f1 mov %r14,%rcx
ffffffff80120968: 4c 89 fb mov %r15,%rbx
ffffffff8012096b: 4c 89 f0 mov %r14,%rax
ffffffff8012096e: 4c 89 fa mov %r15,%rdx
ffffffff80120971: 48 89 d0 mov %rdx,%rax
ffffffff80120974: 48 89 cf mov %rcx,%rdi
ffffffff80120977: 48 89 c6 mov %rax,%rsi
ffffffff8012097a: e8 d7 03 fe ff call ffffffff80100d56 <_ZSt5printIJEEvSt19basic_format_stringIcJDpNSt13type_identityIT_E4typeEEEDpOS2_>
ffffffff8012097f: 49 c7 c4 bc 13 14 80 mov 0ドルxffffffff801413bc,%r12
ffffffff80120986: 41 bd 01 00 00 00 mov 0ドルx1,%r13d
ffffffff8012098c: 4c 89 e1 mov %r12,%rcx
ffffffff8012098f: 4c 89 eb mov %r13,%rbx
ffffffff80120992: 4c 89 e0 mov %r12,%rax
ffffffff80120995: 4c 89 ea mov %r13,%rdx
ffffffff80120998: 48 89 d0 mov %rdx,%rax
ffffffff8012099b: 48 89 cf mov %rcx,%rdi
ffffffff8012099e: 48 89 c6 mov %rax,%rsi
ffffffff801209a1: e8 b0 03 fe ff call ffffffff80100d56 <_ZSt5printIJEEvSt19basic_format_stringIcJDpNSt13type_identityIT_E4typeEEEDpOS2_>
ffffffff801209a6: 48 8b 85 78 ff ff ff mov -0x88(%rbp),%rax
ffffffff801209ad: 48 89 45 80 mov %rax,-0x80(%rbp)
ffffffff801209b1: 48 8d 85 70 ff ff ff lea -0x90(%rbp),%rax
ffffffff801209b8: 48 89 c7 mov %rax,%rdi
ffffffff801209bb: e8 a6 04 00 00 call ffffffff80120e66 <_ZN6Memory18PageDirectoryEntry5flagsEv>
ffffffff801209c0: 48 89 45 c8 mov %rax,-0x38(%rbp)
ffffffff801209c4: eb 2f jmp ffffffff801209f5 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x54d>
ffffffff801209c6: 48 8b 45 80 mov -0x80(%rbp),%rax
ffffffff801209ca: 48 83 f8 ff cmp 0ドルxffffffffffffffff,%rax
ffffffff801209ce: 75 0b jne ffffffff801209db <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x533>
ffffffff801209d0: 48 8b 85 78 ff ff ff mov -0x88(%rbp),%rax
ffffffff801209d7: 48 89 45 80 mov %rax,-0x80(%rbp)
ffffffff801209db: 48 83 7d c8 ff cmpq 0ドルxffffffffffffffff,-0x38(%rbp)
ffffffff801209e0: 75 13 jne ffffffff801209f5 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x54d>
ffffffff801209e2: 48 8d 85 70 ff ff ff lea -0x90(%rbp),%rax
ffffffff801209e9: 48 89 c7 mov %rax,%rdi
ffffffff801209ec: e8 75 04 00 00 call ffffffff80120e66 <_ZN6Memory18PageDirectoryEntry5flagsEv>
ffffffff801209f1: 48 89 45 c8 mov %rax,-0x38(%rbp)
ffffffff801209f5: 48 83 45 a8 01 addq 0ドルx1,-0x58(%rbp)
ffffffff801209fa: 48 81 7d a8 ff 01 00 cmpq 0ドルx1ff,-0x58(%rbp)
ffffffff80120a01: 00
ffffffff80120a02: 0f 86 09 fc ff ff jbe ffffffff80120611 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x169>
ffffffff80120a08: eb 01 jmp ffffffff80120a0b <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x563>
ffffffff80120a0a: 90 nop
ffffffff80120a0b: 48 83 45 b0 01 addq 0ドルx1,-0x50(%rbp)
ffffffff80120a10: 48 81 7d b0 ff 01 00 cmpq 0ドルx1ff,-0x50(%rbp)
ffffffff80120a17: 00
ffffffff80120a18: 0f 86 98 fb ff ff jbe ffffffff801205b6 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x10e>
ffffffff80120a1e: eb 01 jmp ffffffff80120a21 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x579>
ffffffff80120a20: 90 nop
ffffffff80120a21: 48 83 45 b8 01 addq 0ドルx1,-0x48(%rbp)
ffffffff80120a26: 48 81 7d b8 ff 01 00 cmpq 0ドルx1ff,-0x48(%rbp)
ffffffff80120a2d: 00
ffffffff80120a2e: 0f 86 27 fb ff ff jbe ffffffff8012055b <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0xb3>
ffffffff80120a34: eb 01 jmp ffffffff80120a37 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x58f>
ffffffff80120a36: 90 nop
ffffffff80120a37: 48 83 45 c0 01 addq 0ドルx1,-0x40(%rbp)
ffffffff80120a3c: 48 81 7d c0 ff 01 00 cmpq 0ドルx1ff,-0x40(%rbp)
ffffffff80120a43: 00
ffffffff80120a44: 0f 86 b3 fa ff ff jbe ffffffff801204fd <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x55>
ffffffff80120a4a: 90 nop
ffffffff80120a4b: 90 nop
ffffffff80120a4c: 48 81 c4 08 01 00 00 add 0ドルx108,%rsp
ffffffff80120a53: 5b pop %rbx
ffffffff80120a54: 41 5c pop %r12
ffffffff80120a56: 41 5d pop %r13
ffffffff80120a58: 41 5e pop %r14
ffffffff80120a5a: 41 5f pop %r15
ffffffff80120a5c: 5d pop %rbp
ffffffff80120a5d: c3 ret
Sometimes, it crashes here, in the kernel: ``` [kstage1]: Enabling interrupts [SYS$]: exit(420) -- Removed process 1 [kstage1]: Interrupts enabled !===--- You have now booted into LensorOS ---===! LensorOS Copyright (C) 2022, Contributors To LensorOS. [SCHED]: Added process. [SCHED]: Debug information: Process Queue: Process 0 at 0xffffffff8014c0a0 CR3: 0x0000000000020000 RAX: 0x000000000000000a RBX: 0x0000000000000013 RCX: 0x00000000000003d4 RDX: 0x0000000000000070 RSI: 0x000000000000000a RDI: 0x0000000000000070 RBP: 0xffffffff80161800 RSP: 0xffffffff80161740 R8: 0x0000000000000190 R9: 0x00000000ffffffff R10: 0xffffffff8014c065 R11: 0xffffffff8014c068 R12: 0xffffffff8013ed7d R13: 0x0000000000000013 R14: 0xffffffff8013ed6a R15: 0x0000000000000012 Frame: RIP: 0xffffffff80127297 CS: 0x0000000000000008 RFLAGS: 0x0000000000000296 RSP: 0xffffffff801617f0 SS: 0x0000000000000010 File Descriptors: Process 2 at 0xffffffffff0020e3 CR3: 0x000000000179d000 RAX: 0x000000000000000a RBX: 0x0000000000000000 RCX: 0x0000000000000000 RDX: 0x0000000000000000 RSI: 0x0000000000408791 RDI: 0x0000000000408338 RBP: 0x00000000019e0f59 RSP: 0x00000000019e0ef9 R8: 0x0000000000000000 R9: 0x0000000000000000 R10: 0x0000000000000000 R11: 0x0000000000000000 R12: 0x0000000000000000 R13: 0x0000000000000000 R14: 0x0000000000000000 R15: 0x0000000000000000 Frame: RIP: 0x00000000004002aa CS: 0x000000000000001b RFLAGS: 0x0000000000000246 RSP: 0x00000000019e0ef9 SS: 0x0000000000000023 File Descriptors: 0 -> 4 1 -> 5 2 -> 6 Process 3 at 0xffffffffff0037e5 CR3: 0x00000000019e1000 RAX: 0x0000000000000000 RBX: 0x0000000000000000 RCX: 0x0000000000000000 RDX: 0x0000000000000000 RSI: 0x0000000000408791 RDI: 0x0000000000408338 RBP: 0x00000000019e0f59 RSP: 0x00000000019e0ef9 R8: 0x0000000000000000 R9: 0x0000000000000000 R10: 0x0000000000000000 R11: 0x0000000000000000 R12: 0x0000000000000000 R13: 0x0000000000000000 R14: 0x0000000000000000 R15: 0x0000000000000000 Frame: RIP: 0x00000000004002aa CS: 0x000000000000001b RFLAGS: 0x0000000000000246 RSP: 0x00000000019e0ef9 SS: 0x0000000000000023 File Descriptors: 0 -> 3 1 -> 2 2 -> 1 test test2 test3 test4 Child test test2 test3 test4 Parent [SYS$]: exit(420) -- Removed process 3 Parent Parent waited a[SCHED]: Added process. [SCHED]: Debug information: Process Queue: Process 0 at 0xffffffff8014c0a0 CR3: 0x0000000000020000 RAX: 0x0000000000000009 RBX: 0x0000000000000013 RCX: 0x00000000000003d4 RDX: 0x0000000000000070 RSI: 0x0000000000000009 RDI: 0x0000000000000070 RBP: 0xffffffff801617e0 RSP: 0xffffffff80161720 R8: 0x0000000000000190 R9: 0x00000000ffffffff R10: 0xffffffff8014c065 R11: 0xffffffff8014c068 R12: 0xffffffff8013ed7d R13: 0x0000000000000013 R14: 0xffffffff8013ed6a R15: 0x0000000000000012 Frame: RIP: 0xffffffff80114ed7 CS: 0x0000000000000008 RFLAGS: 0x0000000000000296 RSP: 0xffffffff801617d0 SS: 0x0000000000000010 File Descriptors: Process 2 at 0xffffffffff0020e3 CR3: 0x000000000179d000 RAX: 0x000000000000000a RBX: 0x0000000000000000 RCX: 0x0000000000000000 RDX: 0x0000000000000000 RSI: 0x0000000000408791 RDI: 0x0000000000408338 RBP: 0x00000000019e0f59 RSP: 0x00000000019e0ef9 R8: 0x0000000000000000 R9: 0x0000000000000000 R10: 0x0000000000000000 R11: 0x0000000000000000 R12: 0x0000000000000000 R13: 0x0000000000000000 R14: 0x0000000000000000 R15: 0x0000000000000000 Frame: RIP: 0x00000000004002aa CS: 0x000000000000001b RFLAGS: 0x0000000000000246 RSP: 0x00000000019e0ef9 SS: 0x0000000000000023 File Descriptors: 0 -> 4 1 -> 5 2 -> 6 Process 4 at 0xffffffffff003c7e CR3: 0x0000000001b24000 RAX: 0x0000000000000000 RBX: 0x0000000000000000 RCX: 0x0000000000000000 RDX: 0x0000000000000000 RSI: 0x0000000000408791 RDI: 0x0000000000408338 RBP: 0x00000000019e0f59 RSP: 0x00000000019e0ef9 R8: 0x0000000000000000 R10: 0x0000000000000000 R11: 0x0000000000000000 R12: 0x0000000000000000 R13: 0x0000000000000000 R14: 0x0000000000000000 R15: 0x0000000000000000 Frame: RIP: 0x00000000004002aa CS: 0x000000000000001b RFLAGS: 0x0000000000000246 RSP: 0x00000000019e0ef9 SS: 0x0000000000000023 File Descriptors: 0 -> 1 1 -> 2 2 -> 3 Parent Child Faulty Address: 0xffffffff80160e58 PageTable Address: 0x0000000001b24000 4th lvl permissions | RW AC 3rd lvl permissions | RW AC 2nd lvl permissions | RW AC 1st lvl permissions | RW AC DT PHYS 0x0000000000160000 at VIRT 0xffffffff80160e58 Data Access From ring 3 Read CurrentProcess->ProcessID == 4 Present: 0x0000000000400000 to 0x0000000000408000 | US Present: 0x0000000000408000 to 0x00000000004fd000 | RW US Present: 0x0000000001d64000 to 0x0000000001d67000 | RW US Present: 0x0000000001d67000 to 0x0000000001d68000 | RW US AC DT LensorOS PANIC General protection fault detected (0)! Error Code: 0x0000000000000000 Instruction Address: 0xffffffff80120619 Stack Pointer: 0xffffffff80160b08 GDT Selector Index: 0 ``` And here is the disassembly of that address. ``` ffffffff801204a8 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE>: ffffffff801204a8: 55 push %rbp ffffffff801204a9: 48 89 e5 mov %rsp,%rbp ffffffff801204ac: 41 57 push %r15 ffffffff801204ae: 41 56 push %r14 ffffffff801204b0: 41 55 push %r13 ffffffff801204b2: 41 54 push %r12 ffffffff801204b4: 53 push %rbx ffffffff801204b5: 48 81 ec 08 01 00 00 sub 0ドルx108,%rsp ffffffff801204bc: 48 89 bd 68 ff ff ff mov %rdi,-0x98(%rbp) ffffffff801204c3: 48 89 b5 60 ff ff ff mov %rsi,-0xa0(%rbp) ffffffff801204ca: 48 c7 45 80 ff ff ff movq 0ドルxffffffffffffffff,-0x80(%rbp) ffffffff801204d1: ff ffffffff801204d2: 48 c7 85 78 ff ff ff movq 0ドルxffffffffffffffff,-0x88(%rbp) ffffffff801204d9: ff ff ff ff ffffffff801204dd: 48 c7 45 c8 ff ff ff movq 0ドルxffffffffffffffff,-0x38(%rbp) ffffffff801204e4: ff ffffffff801204e5: 48 c7 85 70 ff ff ff movq 0ドルx0,-0x90(%rbp) ffffffff801204ec: 00 00 00 00 ffffffff801204f0: 48 c7 45 c0 00 00 00 movq 0ドルx0,-0x40(%rbp) ffffffff801204f7: 00 ffffffff801204f8: e9 3f 05 00 00 jmp ffffffff80120a3c <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x594> ffffffff801204fd: 48 8b 95 68 ff ff ff mov -0x98(%rbp),%rdx ffffffff80120504: 48 8b 45 c0 mov -0x40(%rbp),%rax ffffffff80120508: 48 8b 04 c2 mov (%rdx,%rax,8),%rax ffffffff8012050c: 48 89 85 70 ff ff ff mov %rax,-0x90(%rbp) ffffffff80120513: 48 8d 85 70 ff ff ff lea -0x90(%rbp),%rax ffffffff8012051a: be 01 00 00 00 mov 0ドルx1,%esi ffffffff8012051f: 48 89 c7 mov %rax,%rdi ffffffff80120522: e8 1b 09 00 00 call ffffffff80120e42 <_ZN6Memory18PageDirectoryEntry4flagENS_13PageTableFlagE> ffffffff80120527: 0f b6 c0 movzbl %al,%eax ffffffff8012052a: 85 c0 test %eax,%eax ffffffff8012052c: 0f 94 c0 sete %al ffffffff8012052f: 84 c0 test %al,%al ffffffff80120531: 0f 85 ff 04 00 00 jne ffffffff80120a36 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x58e> ffffffff80120537: 48 8d 85 70 ff ff ff lea -0x90(%rbp),%rax ffffffff8012053e: 48 89 c7 mov %rax,%rdi ffffffff80120541: e8 7c 08 00 00 call ffffffff80120dc2 <_ZN6Memory18PageDirectoryEntry7addressEv> ffffffff80120546: 48 c1 e0 0c shl 0ドルxc,%rax ffffffff8012054a: 48 89 45 a0 mov %rax,-0x60(%rbp) ffffffff8012054e: 48 c7 45 b8 00 00 00 movq 0ドルx0,-0x48(%rbp) ffffffff80120555: 00 ffffffff80120556: e9 cb 04 00 00 jmp ffffffff80120a26 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x57e> ffffffff8012055b: 48 8b 55 a0 mov -0x60(%rbp),%rdx ffffffff8012055f: 48 8b 45 b8 mov -0x48(%rbp),%rax ffffffff80120563: 48 8b 04 c2 mov (%rdx,%rax,8),%rax ffffffff80120567: 48 89 85 70 ff ff ff mov %rax,-0x90(%rbp) ffffffff8012056e: 48 8d 85 70 ff ff ff lea -0x90(%rbp),%rax ffffffff80120575: be 01 00 00 00 mov 0ドルx1,%esi ffffffff8012057a: 48 89 c7 mov %rax,%rdi ffffffff8012057d: e8 c0 08 00 00 call ffffffff80120e42 <_ZN6Memory18PageDirectoryEntry4flagENS_13PageTableFlagE> ffffffff80120582: 0f b6 c0 movzbl %al,%eax ffffffff80120585: 85 c0 test %eax,%eax ffffffff80120587: 0f 94 c0 sete %al ffffffff8012058a: 84 c0 test %al,%al ffffffff8012058c: 0f 85 8e 04 00 00 jne ffffffff80120a20 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x578> ffffffff80120592: 48 8d 85 70 ff ff ff lea -0x90(%rbp),%rax ffffffff80120599: 48 89 c7 mov %rax,%rdi ffffffff8012059c: e8 21 08 00 00 call ffffffff80120dc2 <_ZN6Memory18PageDirectoryEntry7addressEv> ffffffff801205a1: 48 c1 e0 0c shl 0ドルxc,%rax ffffffff801205a5: 48 89 45 98 mov %rax,-0x68(%rbp) ffffffff801205a9: 48 c7 45 b0 00 00 00 movq 0ドルx0,-0x50(%rbp) ffffffff801205b0: 00 ffffffff801205b1: e9 5a 04 00 00 jmp ffffffff80120a10 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x568> ffffffff801205b6: 48 8b 55 98 mov -0x68(%rbp),%rdx ffffffff801205ba: 48 8b 45 b0 mov -0x50(%rbp),%rax ffffffff801205be: 48 8b 04 c2 mov (%rdx,%rax,8),%rax ffffffff801205c2: 48 89 85 70 ff ff ff mov %rax,-0x90(%rbp) ffffffff801205c9: 48 8d 85 70 ff ff ff lea -0x90(%rbp),%rax ffffffff801205d0: be 01 00 00 00 mov 0ドルx1,%esi ffffffff801205d5: 48 89 c7 mov %rax,%rdi ffffffff801205d8: e8 65 08 00 00 call ffffffff80120e42 <_ZN6Memory18PageDirectoryEntry4flagENS_13PageTableFlagE> ffffffff801205dd: 0f b6 c0 movzbl %al,%eax ffffffff801205e0: 85 c0 test %eax,%eax ffffffff801205e2: 0f 94 c0 sete %al ffffffff801205e5: 84 c0 test %al,%al ffffffff801205e7: 0f 85 1d 04 00 00 jne ffffffff80120a0a <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x562> ffffffff801205ed: 48 8d 85 70 ff ff ff lea -0x90(%rbp),%rax ffffffff801205f4: 48 89 c7 mov %rax,%rdi ffffffff801205f7: e8 c6 07 00 00 call ffffffff80120dc2 <_ZN6Memory18PageDirectoryEntry7addressEv> ffffffff801205fc: 48 c1 e0 0c shl 0ドルxc,%rax ffffffff80120600: 48 89 45 90 mov %rax,-0x70(%rbp) ffffffff80120604: 48 c7 45 a8 00 00 00 movq 0ドルx0,-0x58(%rbp) ffffffff8012060b: 00 ffffffff8012060c: e9 e9 03 00 00 jmp ffffffff801209fa <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x552> ffffffff80120611: 48 8b 55 90 mov -0x70(%rbp),%rdx ffffffff80120615: 48 8b 45 a8 mov -0x58(%rbp),%rax ffffffff80120619: 48 8b 04 c2 mov (%rdx,%rax,8),%rax ffffffff8012061d: 48 89 85 70 ff ff ff mov %rax,-0x90(%rbp) ffffffff80120624: 48 c7 45 88 00 00 00 movq 0ドルx0,-0x78(%rbp) ffffffff8012062b: 00 ffffffff8012062c: 48 8b 45 c0 mov -0x40(%rbp),%rax ffffffff80120630: 48 c1 e0 1b shl 0ドルx1b,%rax ffffffff80120634: 48 89 c2 mov %rax,%rdx ffffffff80120637: 48 b8 00 00 00 f8 0f movabs 0ドルxff8000000,%rax ffffffff8012063e: 00 00 00 ffffffff80120641: 48 21 d0 and %rdx,%rax ffffffff80120644: 48 09 45 88 or %rax,-0x78(%rbp) ffffffff80120648: 48 8b 45 b8 mov -0x48(%rbp),%rax ffffffff8012064c: 48 c1 e0 12 shl 0ドルx12,%rax ffffffff80120650: 25 00 00 fc 07 and 0ドルx7fc0000,%eax ffffffff80120655: 48 09 45 88 or %rax,-0x78(%rbp) ffffffff80120659: 48 8b 45 b0 mov -0x50(%rbp),%rax ffffffff8012065d: 48 c1 e0 09 shl 0ドルx9,%rax ffffffff80120661: 25 00 fe 03 00 and 0ドルx3fe00,%eax ffffffff80120666: 48 09 45 88 or %rax,-0x78(%rbp) ffffffff8012066a: 48 8b 45 a8 mov -0x58(%rbp),%rax ffffffff8012066e: 25 ff 01 00 00 and 0ドルx1ff,%eax ffffffff80120673: 48 09 45 88 or %rax,-0x78(%rbp) ffffffff80120677: 48 c1 65 88 0c shlq 0ドルxc,-0x78(%rbp) ffffffff8012067c: 48 8b 45 88 mov -0x78(%rbp),%rax ffffffff80120680: 48 89 85 78 ff ff ff mov %rax,-0x88(%rbp) ffffffff80120687: 48 83 7d c8 ff cmpq 0ドルxffffffffffffffff,-0x38(%rbp) ffffffff8012068c: 74 1c je ffffffff801206aa <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x202> ffffffff8012068e: 48 8d 85 70 ff ff ff lea -0x90(%rbp),%rax ffffffff80120695: 48 89 c7 mov %rax,%rdi ffffffff80120698: e8 c9 07 00 00 call ffffffff80120e66 <_ZN6Memory18PageDirectoryEntry5flagsEv> ffffffff8012069d: 48 39 45 c8 cmp %rax,-0x38(%rbp) ffffffff801206a1: 74 07 je ffffffff801206aa <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x202> ffffffff801206a3: b8 01 00 00 00 mov 0ドルx1,%eax ffffffff801206a8: eb 05 jmp ffffffff801206af <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x207> ffffffff801206aa: b8 00 00 00 00 mov 0ドルx0,%eax ffffffff801206af: 84 c0 test %al,%al ffffffff801206b1: 0f 84 0f 03 00 00 je ffffffff801209c6 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x51e> ffffffff801206b7: 48 8b 45 c8 mov -0x38(%rbp),%rax ffffffff801206bb: 83 e0 01 and 0ドルx1,%eax ffffffff801206be: 48 85 c0 test %rax,%rax ffffffff801206c1: 0f 84 df 02 00 00 je ffffffff801209a6 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x4fe> ffffffff801206c7: 48 8b 45 c8 mov -0x38(%rbp),%rax ffffffff801206cb: 48 23 85 60 ff ff ff and -0xa0(%rbp),%rax ffffffff801206d2: 48 39 85 60 ff ff ff cmp %rax,-0xa0(%rbp) ffffffff801206d9: 0f 85 c7 02 00 00 jne ffffffff801209a6 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x4fe> ffffffff801206df: 48 c7 85 d0 fe ff ff movq 0ドルxffffffff80141378,-0x130(%rbp) ffffffff801206e6: 78 13 14 80 ffffffff801206ea: 48 c7 85 d8 fe ff ff movq 0ドルx1f,-0x128(%rbp) ffffffff801206f1: 1f 00 00 00 ffffffff801206f5: 48 8d bd 78 ff ff ff lea -0x88(%rbp),%rdi ffffffff801206fc: 48 8d 75 80 lea -0x80(%rbp),%rsi ffffffff80120700: 48 8b 85 d0 fe ff ff mov -0x130(%rbp),%rax ffffffff80120707: 48 8b 95 d8 fe ff ff mov -0x128(%rbp),%rdx ffffffff8012070e: 48 89 c1 mov %rax,%rcx ffffffff80120711: 48 89 d3 mov %rdx,%rbx ffffffff80120714: 49 89 c8 mov %rcx,%r8 ffffffff80120717: 48 89 d0 mov %rdx,%rax ffffffff8012071a: 48 89 f9 mov %rdi,%rcx ffffffff8012071d: 48 89 f2 mov %rsi,%rdx ffffffff80120720: 4c 89 c7 mov %r8,%rdi ffffffff80120723: 48 89 c6 mov %rax,%rsi ffffffff80120726: e8 71 0a 00 00 call ffffffff8012119c <_ZSt5printIJRmS0_EEvSt19basic_format_stringIcJDpNSt13type_identityIT_E4typeEEEDpOS3_> ffffffff8012072b: 48 8b 45 c8 mov -0x38(%rbp),%rax ffffffff8012072f: 83 e0 02 and 0ドルx2,%eax ffffffff80120732: 48 85 c0 test %rax,%rax ffffffff80120735: 74 38 je ffffffff8012076f <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x2c7> ffffffff80120737: 48 c7 85 e0 fe ff ff movq 0ドルxffffffff80141398,-0x120(%rbp) ffffffff8012073e: 98 13 14 80 ffffffff80120742: 48 c7 85 e8 fe ff ff movq 0ドルx3,-0x118(%rbp) ffffffff80120749: 03 00 00 00 ffffffff8012074d: 48 8b 85 e0 fe ff ff mov -0x120(%rbp),%rax ffffffff80120754: 48 8b 95 e8 fe ff ff mov -0x118(%rbp),%rdx ffffffff8012075b: 48 89 c1 mov %rax,%rcx ffffffff8012075e: 48 89 d3 mov %rdx,%rbx ffffffff80120761: 48 89 d0 mov %rdx,%rax ffffffff80120764: 48 89 cf mov %rcx,%rdi ffffffff80120767: 48 89 c6 mov %rax,%rsi ffffffff8012076a: e8 e7 05 fe ff call ffffffff80100d56 <_ZSt5printIJEEvSt19basic_format_stringIcJDpNSt13type_identityIT_E4typeEEEDpOS2_> ffffffff8012076f: 48 8b 45 c8 mov -0x38(%rbp),%rax ffffffff80120773: 83 e0 04 and 0ドルx4,%eax ffffffff80120776: 48 85 c0 test %rax,%rax ffffffff80120779: 74 38 je ffffffff801207b3 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x30b> ffffffff8012077b: 48 c7 85 f0 fe ff ff movq 0ドルxffffffff8014139c,-0x110(%rbp) ffffffff80120782: 9c 13 14 80 ffffffff80120786: 48 c7 85 f8 fe ff ff movq 0ドルx3,-0x108(%rbp) ffffffff8012078d: 03 00 00 00 ffffffff80120791: 48 8b 85 f0 fe ff ff mov -0x110(%rbp),%rax ffffffff80120798: 48 8b 95 f8 fe ff ff mov -0x108(%rbp),%rdx ffffffff8012079f: 48 89 c1 mov %rax,%rcx ffffffff801207a2: 48 89 d3 mov %rdx,%rbx ffffffff801207a5: 48 89 d0 mov %rdx,%rax ffffffff801207a8: 48 89 cf mov %rcx,%rdi ffffffff801207ab: 48 89 c6 mov %rax,%rsi ffffffff801207ae: e8 a3 05 fe ff call ffffffff80100d56 <_ZSt5printIJEEvSt19basic_format_stringIcJDpNSt13type_identityIT_E4typeEEEDpOS2_> ffffffff801207b3: 48 8b 45 c8 mov -0x38(%rbp),%rax ffffffff801207b7: 83 e0 08 and 0ドルx8,%eax ffffffff801207ba: 48 85 c0 test %rax,%rax ffffffff801207bd: 74 38 je ffffffff801207f7 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x34f> ffffffff801207bf: 48 c7 85 00 ff ff ff movq 0ドルxffffffff801413a0,-0x100(%rbp) ffffffff801207c6: a0 13 14 80 ffffffff801207ca: 48 c7 85 08 ff ff ff movq 0ドルx3,-0xf8(%rbp) ffffffff801207d1: 03 00 00 00 ffffffff801207d5: 48 8b 85 00 ff ff ff mov -0x100(%rbp),%rax ffffffff801207dc: 48 8b 95 08 ff ff ff mov -0xf8(%rbp),%rdx ffffffff801207e3: 48 89 c1 mov %rax,%rcx ffffffff801207e6: 48 89 d3 mov %rdx,%rbx ffffffff801207e9: 48 89 d0 mov %rdx,%rax ffffffff801207ec: 48 89 cf mov %rcx,%rdi ffffffff801207ef: 48 89 c6 mov %rax,%rsi ffffffff801207f2: e8 5f 05 fe ff call ffffffff80100d56 <_ZSt5printIJEEvSt19basic_format_stringIcJDpNSt13type_identityIT_E4typeEEEDpOS2_> ffffffff801207f7: 48 8b 45 c8 mov -0x38(%rbp),%rax ffffffff801207fb: 83 e0 10 and 0ドルx10,%eax ffffffff801207fe: 48 85 c0 test %rax,%rax ffffffff80120801: 74 38 je ffffffff8012083b <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x393> ffffffff80120803: 48 c7 85 10 ff ff ff movq 0ドルxffffffff801413a4,-0xf0(%rbp) ffffffff8012080a: a4 13 14 80 ffffffff8012080e: 48 c7 85 18 ff ff ff movq 0ドルx3,-0xe8(%rbp) ffffffff80120815: 03 00 00 00 ffffffff80120819: 48 8b 85 10 ff ff ff mov -0xf0(%rbp),%rax ffffffff80120820: 48 8b 95 18 ff ff ff mov -0xe8(%rbp),%rdx ffffffff80120827: 48 89 c1 mov %rax,%rcx ffffffff8012082a: 48 89 d3 mov %rdx,%rbx ffffffff8012082d: 48 89 d0 mov %rdx,%rax ffffffff80120830: 48 89 cf mov %rcx,%rdi ffffffff80120833: 48 89 c6 mov %rax,%rsi ffffffff80120836: e8 1b 05 fe ff call ffffffff80100d56 <_ZSt5printIJEEvSt19basic_format_stringIcJDpNSt13type_identityIT_E4typeEEEDpOS2_> ffffffff8012083b: 48 8b 45 c8 mov -0x38(%rbp),%rax ffffffff8012083f: 83 e0 20 and 0ドルx20,%eax ffffffff80120842: 48 85 c0 test %rax,%rax ffffffff80120845: 74 38 je ffffffff8012087f <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x3d7> ffffffff80120847: 48 c7 85 20 ff ff ff movq 0ドルxffffffff801413a8,-0xe0(%rbp) ffffffff8012084e: a8 13 14 80 ffffffff80120852: 48 c7 85 28 ff ff ff movq 0ドルx3,-0xd8(%rbp) ffffffff80120859: 03 00 00 00 ffffffff8012085d: 48 8b 85 20 ff ff ff mov -0xe0(%rbp),%rax ffffffff80120864: 48 8b 95 28 ff ff ff mov -0xd8(%rbp),%rdx ffffffff8012086b: 48 89 c1 mov %rax,%rcx ffffffff8012086e: 48 89 d3 mov %rdx,%rbx ffffffff80120871: 48 89 d0 mov %rdx,%rax ffffffff80120874: 48 89 cf mov %rcx,%rdi ffffffff80120877: 48 89 c6 mov %rax,%rsi ffffffff8012087a: e8 d7 04 fe ff call ffffffff80100d56 <_ZSt5printIJEEvSt19basic_format_stringIcJDpNSt13type_identityIT_E4typeEEEDpOS2_> ffffffff8012087f: 48 8b 45 c8 mov -0x38(%rbp),%rax ffffffff80120883: 83 e0 40 and 0ドルx40,%eax ffffffff80120886: 48 85 c0 test %rax,%rax ffffffff80120889: 74 38 je ffffffff801208c3 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x41b> ffffffff8012088b: 48 c7 85 30 ff ff ff movq 0ドルxffffffff801413ac,-0xd0(%rbp) ffffffff80120892: ac 13 14 80 ffffffff80120896: 48 c7 85 38 ff ff ff movq 0ドルx3,-0xc8(%rbp) ffffffff8012089d: 03 00 00 00 ffffffff801208a1: 48 8b 85 30 ff ff ff mov -0xd0(%rbp),%rax ffffffff801208a8: 48 8b 95 38 ff ff ff mov -0xc8(%rbp),%rdx ffffffff801208af: 48 89 c1 mov %rax,%rcx ffffffff801208b2: 48 89 d3 mov %rdx,%rbx ffffffff801208b5: 48 89 d0 mov %rdx,%rax ffffffff801208b8: 48 89 cf mov %rcx,%rdi ffffffff801208bb: 48 89 c6 mov %rax,%rsi ffffffff801208be: e8 93 04 fe ff call ffffffff80100d56 <_ZSt5printIJEEvSt19basic_format_stringIcJDpNSt13type_identityIT_E4typeEEEDpOS2_> ffffffff801208c3: 48 8b 45 c8 mov -0x38(%rbp),%rax ffffffff801208c7: 25 80 00 00 00 and 0ドルx80,%eax ffffffff801208cc: 48 85 c0 test %rax,%rax ffffffff801208cf: 74 38 je ffffffff80120909 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x461> ffffffff801208d1: 48 c7 85 40 ff ff ff movq 0ドルxffffffff801413b0,-0xc0(%rbp) ffffffff801208d8: b0 13 14 80 ffffffff801208dc: 48 c7 85 48 ff ff ff movq 0ドルx3,-0xb8(%rbp) ffffffff801208e3: 03 00 00 00 ffffffff801208e7: 48 8b 85 40 ff ff ff mov -0xc0(%rbp),%rax ffffffff801208ee: 48 8b 95 48 ff ff ff mov -0xb8(%rbp),%rdx ffffffff801208f5: 48 89 c1 mov %rax,%rcx ffffffff801208f8: 48 89 d3 mov %rdx,%rbx ffffffff801208fb: 48 89 d0 mov %rdx,%rax ffffffff801208fe: 48 89 cf mov %rcx,%rdi ffffffff80120901: 48 89 c6 mov %rax,%rsi ffffffff80120904: e8 4d 04 fe ff call ffffffff80100d56 <_ZSt5printIJEEvSt19basic_format_stringIcJDpNSt13type_identityIT_E4typeEEEDpOS2_> ffffffff80120909: 48 8b 45 c8 mov -0x38(%rbp),%rax ffffffff8012090d: 25 00 01 00 00 and 0ドルx100,%eax ffffffff80120912: 48 85 c0 test %rax,%rax ffffffff80120915: 74 38 je ffffffff8012094f <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x4a7> ffffffff80120917: 48 c7 85 50 ff ff ff movq 0ドルxffffffff801413b4,-0xb0(%rbp) ffffffff8012091e: b4 13 14 80 ffffffff80120922: 48 c7 85 58 ff ff ff movq 0ドルx3,-0xa8(%rbp) ffffffff80120929: 03 00 00 00 ffffffff8012092d: 48 8b 85 50 ff ff ff mov -0xb0(%rbp),%rax ffffffff80120934: 48 8b 95 58 ff ff ff mov -0xa8(%rbp),%rdx ffffffff8012093b: 48 89 c1 mov %rax,%rcx ffffffff8012093e: 48 89 d3 mov %rdx,%rbx ffffffff80120941: 48 89 d0 mov %rdx,%rax ffffffff80120944: 48 89 cf mov %rcx,%rdi ffffffff80120947: 48 89 c6 mov %rax,%rsi ffffffff8012094a: e8 07 04 fe ff call ffffffff80100d56 <_ZSt5printIJEEvSt19basic_format_stringIcJDpNSt13type_identityIT_E4typeEEEDpOS2_> ffffffff8012094f: 48 8b 45 c8 mov -0x38(%rbp),%rax ffffffff80120953: 48 85 c0 test %rax,%rax ffffffff80120956: 79 27 jns ffffffff8012097f <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x4d7> ffffffff80120958: 49 c7 c6 b8 13 14 80 mov 0ドルxffffffff801413b8,%r14 ffffffff8012095f: 41 bf 03 00 00 00 mov 0ドルx3,%r15d ffffffff80120965: 4c 89 f1 mov %r14,%rcx ffffffff80120968: 4c 89 fb mov %r15,%rbx ffffffff8012096b: 4c 89 f0 mov %r14,%rax ffffffff8012096e: 4c 89 fa mov %r15,%rdx ffffffff80120971: 48 89 d0 mov %rdx,%rax ffffffff80120974: 48 89 cf mov %rcx,%rdi ffffffff80120977: 48 89 c6 mov %rax,%rsi ffffffff8012097a: e8 d7 03 fe ff call ffffffff80100d56 <_ZSt5printIJEEvSt19basic_format_stringIcJDpNSt13type_identityIT_E4typeEEEDpOS2_> ffffffff8012097f: 49 c7 c4 bc 13 14 80 mov 0ドルxffffffff801413bc,%r12 ffffffff80120986: 41 bd 01 00 00 00 mov 0ドルx1,%r13d ffffffff8012098c: 4c 89 e1 mov %r12,%rcx ffffffff8012098f: 4c 89 eb mov %r13,%rbx ffffffff80120992: 4c 89 e0 mov %r12,%rax ffffffff80120995: 4c 89 ea mov %r13,%rdx ffffffff80120998: 48 89 d0 mov %rdx,%rax ffffffff8012099b: 48 89 cf mov %rcx,%rdi ffffffff8012099e: 48 89 c6 mov %rax,%rsi ffffffff801209a1: e8 b0 03 fe ff call ffffffff80100d56 <_ZSt5printIJEEvSt19basic_format_stringIcJDpNSt13type_identityIT_E4typeEEEDpOS2_> ffffffff801209a6: 48 8b 85 78 ff ff ff mov -0x88(%rbp),%rax ffffffff801209ad: 48 89 45 80 mov %rax,-0x80(%rbp) ffffffff801209b1: 48 8d 85 70 ff ff ff lea -0x90(%rbp),%rax ffffffff801209b8: 48 89 c7 mov %rax,%rdi ffffffff801209bb: e8 a6 04 00 00 call ffffffff80120e66 <_ZN6Memory18PageDirectoryEntry5flagsEv> ffffffff801209c0: 48 89 45 c8 mov %rax,-0x38(%rbp) ffffffff801209c4: eb 2f jmp ffffffff801209f5 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x54d> ffffffff801209c6: 48 8b 45 80 mov -0x80(%rbp),%rax ffffffff801209ca: 48 83 f8 ff cmp 0ドルxffffffffffffffff,%rax ffffffff801209ce: 75 0b jne ffffffff801209db <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x533> ffffffff801209d0: 48 8b 85 78 ff ff ff mov -0x88(%rbp),%rax ffffffff801209d7: 48 89 45 80 mov %rax,-0x80(%rbp) ffffffff801209db: 48 83 7d c8 ff cmpq 0ドルxffffffffffffffff,-0x38(%rbp) ffffffff801209e0: 75 13 jne ffffffff801209f5 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x54d> ffffffff801209e2: 48 8d 85 70 ff ff ff lea -0x90(%rbp),%rax ffffffff801209e9: 48 89 c7 mov %rax,%rdi ffffffff801209ec: e8 75 04 00 00 call ffffffff80120e66 <_ZN6Memory18PageDirectoryEntry5flagsEv> ffffffff801209f1: 48 89 45 c8 mov %rax,-0x38(%rbp) ffffffff801209f5: 48 83 45 a8 01 addq 0ドルx1,-0x58(%rbp) ffffffff801209fa: 48 81 7d a8 ff 01 00 cmpq 0ドルx1ff,-0x58(%rbp) ffffffff80120a01: 00 ffffffff80120a02: 0f 86 09 fc ff ff jbe ffffffff80120611 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x169> ffffffff80120a08: eb 01 jmp ffffffff80120a0b <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x563> ffffffff80120a0a: 90 nop ffffffff80120a0b: 48 83 45 b0 01 addq 0ドルx1,-0x50(%rbp) ffffffff80120a10: 48 81 7d b0 ff 01 00 cmpq 0ドルx1ff,-0x50(%rbp) ffffffff80120a17: 00 ffffffff80120a18: 0f 86 98 fb ff ff jbe ffffffff801205b6 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x10e> ffffffff80120a1e: eb 01 jmp ffffffff80120a21 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x579> ffffffff80120a20: 90 nop ffffffff80120a21: 48 83 45 b8 01 addq 0ドルx1,-0x48(%rbp) ffffffff80120a26: 48 81 7d b8 ff 01 00 cmpq 0ドルx1ff,-0x48(%rbp) ffffffff80120a2d: 00 ffffffff80120a2e: 0f 86 27 fb ff ff jbe ffffffff8012055b <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0xb3> ffffffff80120a34: eb 01 jmp ffffffff80120a37 <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x58f> ffffffff80120a36: 90 nop ffffffff80120a37: 48 83 45 c0 01 addq 0ドルx1,-0x40(%rbp) ffffffff80120a3c: 48 81 7d c0 ff 01 00 cmpq 0ドルx1ff,-0x40(%rbp) ffffffff80120a43: 00 ffffffff80120a44: 0f 86 b3 fa ff ff jbe ffffffff801204fd <_ZN6Memory14print_page_mapEPNS_9PageTableENS_13PageTableFlagE+0x55> ffffffff80120a4a: 90 nop ffffffff80120a4b: 90 nop ffffffff80120a4c: 48 81 c4 08 01 00 00 add 0ドルx108,%rsp ffffffff80120a53: 5b pop %rbx ffffffff80120a54: 41 5c pop %r12 ffffffff80120a56: 41 5d pop %r13 ffffffff80120a58: 41 5e pop %r14 ffffffff80120a5a: 41 5f pop %r15 ffffffff80120a5c: 5d pop %rbp ffffffff80120a5d: c3 ret ```
Author
Owner
Copy link

I think I might have solved it conceptually: if the process is asking for argv, could we be putting it in the wrong place, and therefore it is thinking the kernel return address on the stack or something is argv?

I think I *might* have solved it conceptually: if the process is asking for argv, could we be putting it in the wrong place, and therefore it is thinking the kernel return address on the stack or something is argv?
Author
Owner
Copy link

<format> is now crashing due to somehow being compiled with SSE registers

EDIT: Or maybe that's not why it's crashing??? Why is it crashing?!

[kstage1]: Enabling interrupts
[SYS$]: exit(420) -- Removed process 1
[kstage1]: Interrupts enabled
!===--- You have now booted into LensorOS ---===!
LensorOS Copyright (C) 2022, Contributors To LensorOS.
[SCHED]: Added process.
[SCHED]: Debug information:
 Process Queue:
 Process 0 at 0xffffffff8014d0a0
 CR3: 0x0000000000020000
 RAX: 0x0000000000000000
 RBX: 0x0000000004b6f348
 RCX: 0x0000000000000005
 RDX: 0x0000000000000000
 RSI: 0x0000000000000004
 RDI: 0xffffffff80149020
 RBP: 0xffffffff801626f0
 RSP: 0xffffffff801625e0
 R8: 0x0000000004b6f348
 R9: 0x00000000ffffffff
 R10: 0xffffffff8014d065
 R11: 0xffffffff8014d068
 R12: 0xffffffff8014d061
 R13: 0xffffffff8013ff68
 R14: 0xffffffff8014009a
 R15: 0x0000000000000012
 Frame:
 RIP: 0xffffffff80104d2d
 CS: 0x0000000000000008
 RFLAGS: 0x0000000000000246
 RSP: 0xffffffff80162690
 SS: 0x0000000000000010
 File Descriptors:
 Process 2 at 0xffffffffff0020e3
 CR3: 0x000000000179e000
 RAX: 0x000000000000000a
 RBX: 0x0000000000000000
 RCX: 0x0000000000000000
 RDX: 0x0000000000000000
 RSI: 0x0000000000408791
 RDI: 0x0000000000408338
 RBP: 0x00000000019e1f59
 RSP: 0x00000000019e1ef9
 R8: 0x0000000000000000
 R9: 0x0000000000000000
 R10: 0x0000000000000000
 R11: 0x0000000000000000
 R12: 0x0000000000000000
 R13: 0x0000000000000000
 R14: 0x0000000000000000
 R15: 0x0000000000000000
 Frame:
 RIP: 0x00000000004002aa
 CS: 0x000000000000001b
 RFLAGS: 0x0000000000000246
 RSP: 0x00000000019e1ef9
 SS: 0x0000000000000023
 File Descriptors:
 0 -> 4
 1 -> 5
 Process 3 at 0xffffffffff0037e5
 CR3: 0x00000000019e2000
 RAX: 0x0000000000000000
 RBX: 0x0000000000000000
 RCX: 0x0000000000000000
 RDX: 0x0000000000000000
 RSI: 0x0000000000408791
 RDI: 0x0000000000408338
 RBP: 0x00000000019e1f59
 RSP: 0x00000000019e1ef9
 R8: 0x0000000000000000
 R9: 0x0000000000000000
 R10: 0x0000000000000000
 R11: 0x0000000000000000
 R12: 0x0000000000000000
 R13: 0x0000000000000000
 R14: 0x0000000000000000
 R15: 0x0000000000000000
 Frame:
 RIP: 0x00000000004002aa
 CS: 0x000000000000001b
 RFLAGS: 0x0000000000000246
 RSP: 0x00000000019e1ef9
 SS: 0x0000000000000023
 File Descriptors:
 0 -> 3
 1 -> 2
 2 -> 1
test
test2
test3
test4
Child
Attempting to add userspace process from file descriptor
LensorOS PANIC
 General protection fault detected (0)!
 Error Code: 0x0000000000000000
 Instruction Address: 0xffffffff8010dfb0
 Stack Pointer: 0xffffffff80161898
 GDT Selector Index: 0
ffffffff8010df8c <_ZNSt8__detail11__format_toINS_28__kernel_log_insert_iteratorES1_cJEEEvOT0_St17basic_string_viewIT1_EDpOT2_>:
ffffffff8010df8c: 55 push %rbp
ffffffff8010df8d: 48 89 e5 mov %rsp,%rbp
ffffffff8010df90: 48 83 ec 70 sub 0ドルx70,%rsp
ffffffff8010df94: 48 89 7d a8 mov %rdi,-0x58(%rbp)
ffffffff8010df98: 48 89 d1 mov %rdx,%rcx
ffffffff8010df9b: 48 89 f0 mov %rsi,%rax
ffffffff8010df9e: 48 89 fa mov %rdi,%rdx
ffffffff8010dfa1: 48 89 ca mov %rcx,%rdx
ffffffff8010dfa4: 48 89 45 90 mov %rax,-0x70(%rbp)
ffffffff8010dfa8: 48 89 55 98 mov %rdx,-0x68(%rbp)
ffffffff8010dfac: 66 0f ef c0 pxor %xmm0,%xmm0
ffffffff8010dfb0: 0f 29 45 d0 movaps %xmm0,-0x30(%rbp)
ffffffff8010dfb4: 66 0f d6 45 e0 movq %xmm0,-0x20(%rbp)
ffffffff8010dfb9: 48 8b 45 a8 mov -0x58(%rbp),%rax
ffffffff8010dfbd: 48 89 c7 mov %rax,%rdi
ffffffff8010dfc0: e8 49 60 ff ff call ffffffff8010400e <_ZSt7forwardINSt8__detail28__kernel_log_insert_iteratorEEOT_RNSt16remove_referenceIS2_E4typeE>
ffffffff8010dfc5: 48 8d 55 d0 lea -0x30(%rbp),%rdx
ffffffff8010dfc9: 48 8d 45 f0 lea -0x10(%rbp),%rax
ffffffff8010dfcd: 48 89 d6 mov %rdx,%rsi
ffffffff8010dfd0: 48 89 c7 mov %rax,%rdi
ffffffff8010dfd3: e8 72 33 ff ff call ffffffff8010134a <_ZNSt17basic_format_argsISt20basic_format_contextINSt8__detail28__kernel_log_insert_iteratorEcEEC1IJEEERKSt18__format_arg_storeIS3_JDpT_EE>
ffffffff8010dfd8: 48 8b 4d f0 mov -0x10(%rbp),%rcx
ffffffff8010dfdc: 48 8b 55 f8 mov -0x8(%rbp),%rdx
ffffffff8010dfe0: 48 8d 45 b0 lea -0x50(%rbp),%rax
ffffffff8010dfe4: 48 89 ce mov %rcx,%rsi
ffffffff8010dfe7: 48 89 c7 mov %rax,%rdi
ffffffff8010dfea: e8 9f 33 ff ff call ffffffff8010138e <_ZNSt20basic_format_contextINSt8__detail28__kernel_log_insert_iteratorEcEC1ES1_St17basic_format_argsIS2_E>
ffffffff8010dfef: 48 8d 45 b0 lea -0x50(%rbp),%rax
ffffffff8010dff3: 48 89 c7 mov %rax,%rdi
ffffffff8010dff6: e8 a8 42 ff ff call ffffffff801022a3 <_ZSt4moveIRSt20basic_format_contextINSt8__detail28__kernel_log_insert_iteratorEcEEONSt12remove_cvrefIT_E4typeEOS6_>
ffffffff8010dffb: 48 89 c1 mov %rax,%rcx
ffffffff8010dffe: 48 8b 55 90 mov -0x70(%rbp),%rdx
ffffffff8010e002: 48 8b 45 98 mov -0x68(%rbp),%rax
ffffffff8010e006: 48 89 d6 mov %rdx,%rsi
ffffffff8010e009: 48 89 c2 mov %rax,%rdx
ffffffff8010e00c: 48 89 cf mov %rcx,%rdi
ffffffff8010e00f: e8 e9 3e ff ff call ffffffff80101efd <_ZNSt8__detail8__formatINS_28__kernel_log_insert_iteratorEcEEvOSt20basic_format_contextIT_T0_ESt17basic_string_viewIS4_E>
ffffffff8010e014: 90 nop
ffffffff8010e015: c9 leave
ffffffff8010e016: c3 ret
`<format>` is now crashing due to somehow being compiled with SSE registers EDIT: Or maybe that's not why it's crashing??? Why is it crashing?! ``` [kstage1]: Enabling interrupts [SYS$]: exit(420) -- Removed process 1 [kstage1]: Interrupts enabled !===--- You have now booted into LensorOS ---===! LensorOS Copyright (C) 2022, Contributors To LensorOS. [SCHED]: Added process. [SCHED]: Debug information: Process Queue: Process 0 at 0xffffffff8014d0a0 CR3: 0x0000000000020000 RAX: 0x0000000000000000 RBX: 0x0000000004b6f348 RCX: 0x0000000000000005 RDX: 0x0000000000000000 RSI: 0x0000000000000004 RDI: 0xffffffff80149020 RBP: 0xffffffff801626f0 RSP: 0xffffffff801625e0 R8: 0x0000000004b6f348 R9: 0x00000000ffffffff R10: 0xffffffff8014d065 R11: 0xffffffff8014d068 R12: 0xffffffff8014d061 R13: 0xffffffff8013ff68 R14: 0xffffffff8014009a R15: 0x0000000000000012 Frame: RIP: 0xffffffff80104d2d CS: 0x0000000000000008 RFLAGS: 0x0000000000000246 RSP: 0xffffffff80162690 SS: 0x0000000000000010 File Descriptors: Process 2 at 0xffffffffff0020e3 CR3: 0x000000000179e000 RAX: 0x000000000000000a RBX: 0x0000000000000000 RCX: 0x0000000000000000 RDX: 0x0000000000000000 RSI: 0x0000000000408791 RDI: 0x0000000000408338 RBP: 0x00000000019e1f59 RSP: 0x00000000019e1ef9 R8: 0x0000000000000000 R9: 0x0000000000000000 R10: 0x0000000000000000 R11: 0x0000000000000000 R12: 0x0000000000000000 R13: 0x0000000000000000 R14: 0x0000000000000000 R15: 0x0000000000000000 Frame: RIP: 0x00000000004002aa CS: 0x000000000000001b RFLAGS: 0x0000000000000246 RSP: 0x00000000019e1ef9 SS: 0x0000000000000023 File Descriptors: 0 -> 4 1 -> 5 Process 3 at 0xffffffffff0037e5 CR3: 0x00000000019e2000 RAX: 0x0000000000000000 RBX: 0x0000000000000000 RCX: 0x0000000000000000 RDX: 0x0000000000000000 RSI: 0x0000000000408791 RDI: 0x0000000000408338 RBP: 0x00000000019e1f59 RSP: 0x00000000019e1ef9 R8: 0x0000000000000000 R9: 0x0000000000000000 R10: 0x0000000000000000 R11: 0x0000000000000000 R12: 0x0000000000000000 R13: 0x0000000000000000 R14: 0x0000000000000000 R15: 0x0000000000000000 Frame: RIP: 0x00000000004002aa CS: 0x000000000000001b RFLAGS: 0x0000000000000246 RSP: 0x00000000019e1ef9 SS: 0x0000000000000023 File Descriptors: 0 -> 3 1 -> 2 2 -> 1 test test2 test3 test4 Child Attempting to add userspace process from file descriptor LensorOS PANIC General protection fault detected (0)! Error Code: 0x0000000000000000 Instruction Address: 0xffffffff8010dfb0 Stack Pointer: 0xffffffff80161898 GDT Selector Index: 0 ``` ``` ffffffff8010df8c <_ZNSt8__detail11__format_toINS_28__kernel_log_insert_iteratorES1_cJEEEvOT0_St17basic_string_viewIT1_EDpOT2_>: ffffffff8010df8c: 55 push %rbp ffffffff8010df8d: 48 89 e5 mov %rsp,%rbp ffffffff8010df90: 48 83 ec 70 sub 0ドルx70,%rsp ffffffff8010df94: 48 89 7d a8 mov %rdi,-0x58(%rbp) ffffffff8010df98: 48 89 d1 mov %rdx,%rcx ffffffff8010df9b: 48 89 f0 mov %rsi,%rax ffffffff8010df9e: 48 89 fa mov %rdi,%rdx ffffffff8010dfa1: 48 89 ca mov %rcx,%rdx ffffffff8010dfa4: 48 89 45 90 mov %rax,-0x70(%rbp) ffffffff8010dfa8: 48 89 55 98 mov %rdx,-0x68(%rbp) ffffffff8010dfac: 66 0f ef c0 pxor %xmm0,%xmm0 ffffffff8010dfb0: 0f 29 45 d0 movaps %xmm0,-0x30(%rbp) ffffffff8010dfb4: 66 0f d6 45 e0 movq %xmm0,-0x20(%rbp) ffffffff8010dfb9: 48 8b 45 a8 mov -0x58(%rbp),%rax ffffffff8010dfbd: 48 89 c7 mov %rax,%rdi ffffffff8010dfc0: e8 49 60 ff ff call ffffffff8010400e <_ZSt7forwardINSt8__detail28__kernel_log_insert_iteratorEEOT_RNSt16remove_referenceIS2_E4typeE> ffffffff8010dfc5: 48 8d 55 d0 lea -0x30(%rbp),%rdx ffffffff8010dfc9: 48 8d 45 f0 lea -0x10(%rbp),%rax ffffffff8010dfcd: 48 89 d6 mov %rdx,%rsi ffffffff8010dfd0: 48 89 c7 mov %rax,%rdi ffffffff8010dfd3: e8 72 33 ff ff call ffffffff8010134a <_ZNSt17basic_format_argsISt20basic_format_contextINSt8__detail28__kernel_log_insert_iteratorEcEEC1IJEEERKSt18__format_arg_storeIS3_JDpT_EE> ffffffff8010dfd8: 48 8b 4d f0 mov -0x10(%rbp),%rcx ffffffff8010dfdc: 48 8b 55 f8 mov -0x8(%rbp),%rdx ffffffff8010dfe0: 48 8d 45 b0 lea -0x50(%rbp),%rax ffffffff8010dfe4: 48 89 ce mov %rcx,%rsi ffffffff8010dfe7: 48 89 c7 mov %rax,%rdi ffffffff8010dfea: e8 9f 33 ff ff call ffffffff8010138e <_ZNSt20basic_format_contextINSt8__detail28__kernel_log_insert_iteratorEcEC1ES1_St17basic_format_argsIS2_E> ffffffff8010dfef: 48 8d 45 b0 lea -0x50(%rbp),%rax ffffffff8010dff3: 48 89 c7 mov %rax,%rdi ffffffff8010dff6: e8 a8 42 ff ff call ffffffff801022a3 <_ZSt4moveIRSt20basic_format_contextINSt8__detail28__kernel_log_insert_iteratorEcEEONSt12remove_cvrefIT_E4typeEOS6_> ffffffff8010dffb: 48 89 c1 mov %rax,%rcx ffffffff8010dffe: 48 8b 55 90 mov -0x70(%rbp),%rdx ffffffff8010e002: 48 8b 45 98 mov -0x68(%rbp),%rax ffffffff8010e006: 48 89 d6 mov %rdx,%rsi ffffffff8010e009: 48 89 c2 mov %rax,%rdx ffffffff8010e00c: 48 89 cf mov %rcx,%rdi ffffffff8010e00f: e8 e9 3e ff ff call ffffffff80101efd <_ZNSt8__detail8__formatINS_28__kernel_log_insert_iteratorEcEEvOSt20basic_format_contextIT_T0_ESt17basic_string_viewIS4_E> ffffffff8010e014: 90 nop ffffffff8010e015: c9 leave ffffffff8010e016: c3 ret ```
Author
Owner
Copy link

It is crashing here everytime now, even with the magical debug output...

[kstage1]: Enabling interrupts
[SYS$]: exit(420) -- Removed process 1
[kstage1]: Interrupts enabled
!===--- You have now booted into LensorOS ---===!
LensorOS Copyright (C) 2022, Contributors To LensorOS.
[SCHED]: Added process.
[SCHED]: Debug information:
 Process Queue:
 Process 0 at 0xffffffff8014d0a0
 CR3: 0x0000000000020000
 RAX: 0x0000000000000431
 RBX: 0x0000000000000000
 RCX: 0x0000000000000000
 RDX: 0xffffff80001f01d0
 RSI: 0xffffff80001eff50
 RDI: 0x00000000c01eff50
 RBP: 0xffffffff801627c0
 RSP: 0xffffffff801626e0
 R8: 0x0000000000000190
 R9: 0x00000000ffffffff
 R10: 0xffffffff8014d065
 R11: 0xffffffff8014d068
 R12: 0xffffffff801400ad
 R13: 0x0000000000000013
 R14: 0xffffffff8014009a
 R15: 0x0000000000000012
 Frame:
 RIP: 0xffffffff8011cd96
 CS: 0x0000000000000008
 RFLAGS: 0x0000000000000297
 RSP: 0xffffffff80162790
 SS: 0x0000000000000010
 File Descriptors:
 Process 2 at 0xffffffffff0020e3
 CR3: 0x000000000179e000
 RAX: 0x000000000000000a
 RBX: 0x0000000000000000
 RCX: 0x0000000000000000
 RDX: 0x0000000000000000
 RSI: 0x0000000000408791
 RDI: 0x0000000000408338
 RBP: 0x00000000019e1f59
 RSP: 0x00000000019e1ef9
 R8: 0x0000000000000000
 R9: 0x0000000000000000
 R10: 0x0000000000000000
 R11: 0x0000000000000000
 R12: 0x0000000000000000
 R13: 0x0000000000000000
 R14: 0x0000000000000000
 R15: 0x0000000000000000
 Frame:
 RIP: 0x00000000004002aa
 CS: 0x000000000000001b
 RFLAGS: 0x0000000000000246
 RSP: 0x00000000019e1ef9
 SS: 0x0000000000000023
 File Descriptors:
 0 -> 4
 1 -> 5
 Process 3 at 0xffffffffff0037e5
 CR3: 0x00000000019e2000
 RAX: 0x0000000000000000
 RBX: 0x0000000000000000
 RCX: 0x0000000000000000
 RDX: 0x0000000000000000
 RSI: 0x0000000000408791
 RDI: 0x0000000000408338
 RBP: 0x00000000019e1f59
 RSP: 0x00000000019e1ef9
 R8: 0x0000000000000000
 R9: 0x0000000000000000
 R10: 0x0000000000000000
 R11: 0x0000000000000000
 R12: 0x0000000000000000
 R13: 0x0000000000000000
 R14: 0x0000000000000000
 R15: 0x0000000000000000
 Frame:
 RIP: 0x00000000004002aa
 CS: 0x000000000000001b
 RFLAGS: 0x0000000000000246
 RSP: 0x00000000019e1ef9
 SS: 0x0000000000000023
 File Descriptors:
 0 -> 3
 1 -> 2
 2 -> 1
test
test2
test3
test4
Child
Attempting to add userspace process from file descriptor
LensorOS PANIC
 General protection fault detected (0)!
 Error Code: 0x0000000000000000
 Instruction Address: 0xffffffff8010e01c
 Stack Pointer: 0xffffffff80161898
 GDT Selector Index: 0

Which is here in the disassembly:

ffffffff8010dff8 <_ZNSt8__detail11__format_toINS_28__kernel_log_insert_iteratorES1_cJEEEvOT0_St17basic_string_viewIT1_EDpOT2_>:
ffffffff8010dff8: 55 push %rbp
ffffffff8010dff9: 48 89 e5 mov %rsp,%rbp
ffffffff8010dffc: 48 83 ec 70 sub 0ドルx70,%rsp
ffffffff8010e000: 48 89 7d a8 mov %rdi,-0x58(%rbp)
ffffffff8010e004: 48 89 d1 mov %rdx,%rcx
ffffffff8010e007: 48 89 f0 mov %rsi,%rax
ffffffff8010e00a: 48 89 fa mov %rdi,%rdx
ffffffff8010e00d: 48 89 ca mov %rcx,%rdx
ffffffff8010e010: 48 89 45 90 mov %rax,-0x70(%rbp)
ffffffff8010e014: 48 89 55 98 mov %rdx,-0x68(%rbp)
ffffffff8010e018: 66 0f ef c0 pxor %xmm0,%xmm0
ffffffff8010e01c: 0f 29 45 d0 movaps %xmm0,-0x30(%rbp)
ffffffff8010e020: 66 0f d6 45 e0 movq %xmm0,-0x20(%rbp)
ffffffff8010e025: 48 8b 45 a8 mov -0x58(%rbp),%rax
ffffffff8010e029: 48 89 c7 mov %rax,%rdi
ffffffff8010e02c: e8 dd 5f ff ff call ffffffff8010400e <_ZSt7forwardINSt8__detail28__kernel_log_insert_iteratorEEOT_RNSt16remove_referenceIS2_E4typeE>
ffffffff8010e031: 48 8d 55 d0 lea -0x30(%rbp),%rdx
ffffffff8010e035: 48 8d 45 f0 lea -0x10(%rbp),%rax
ffffffff8010e039: 48 89 d6 mov %rdx,%rsi
ffffffff8010e03c: 48 89 c7 mov %rax,%rdi
ffffffff8010e03f: e8 06 33 ff ff call ffffffff8010134a <_ZNSt17basic_format_argsISt20basic_format_contextINSt8__detail28__kernel_log_insert_iteratorEcEEC1IJEEERKSt18__format_arg_storeIS3_JDpT_EE>
ffffffff8010e044: 48 8b 4d f0 mov -0x10(%rbp),%rcx
ffffffff8010e048: 48 8b 55 f8 mov -0x8(%rbp),%rdx
ffffffff8010e04c: 48 8d 45 b0 lea -0x50(%rbp),%rax
ffffffff8010e050: 48 89 ce mov %rcx,%rsi
ffffffff8010e053: 48 89 c7 mov %rax,%rdi
ffffffff8010e056: e8 33 33 ff ff call ffffffff8010138e <_ZNSt20basic_format_contextINSt8__detail28__kernel_log_insert_iteratorEcEC1ES1_St17basic_format_argsIS2_E>
ffffffff8010e05b: 48 8d 45 b0 lea -0x50(%rbp),%rax
ffffffff8010e05f: 48 89 c7 mov %rax,%rdi
ffffffff8010e062: e8 3c 42 ff ff call ffffffff801022a3 <_ZSt4moveIRSt20basic_format_contextINSt8__detail28__kernel_log_insert_iteratorEcEEONSt12remove_cvrefIT_E4typeEOS6_>
ffffffff8010e067: 48 89 c1 mov %rax,%rcx
ffffffff8010e06a: 48 8b 55 90 mov -0x70(%rbp),%rdx
ffffffff8010e06e: 48 8b 45 98 mov -0x68(%rbp),%rax
ffffffff8010e072: 48 89 d6 mov %rdx,%rsi
ffffffff8010e075: 48 89 c2 mov %rax,%rdx
ffffffff8010e078: 48 89 cf mov %rcx,%rdi
ffffffff8010e07b: e8 7d 3e ff ff call ffffffff80101efd <_ZNSt8__detail8__formatINS_28__kernel_log_insert_iteratorEcEEvOSt20basic_format_contextIT_T0_ESt17basic_string_viewIS4_E>
ffffffff8010e080: 90 nop
ffffffff8010e081: c9 leave
ffffffff8010e082: c3 ret

AKA the exact same movaps instruction as before, within __kernel_log_insert_iterator

It is crashing here everytime now, even with the magical debug output... ``` [kstage1]: Enabling interrupts [SYS$]: exit(420) -- Removed process 1 [kstage1]: Interrupts enabled !===--- You have now booted into LensorOS ---===! LensorOS Copyright (C) 2022, Contributors To LensorOS. [SCHED]: Added process. [SCHED]: Debug information: Process Queue: Process 0 at 0xffffffff8014d0a0 CR3: 0x0000000000020000 RAX: 0x0000000000000431 RBX: 0x0000000000000000 RCX: 0x0000000000000000 RDX: 0xffffff80001f01d0 RSI: 0xffffff80001eff50 RDI: 0x00000000c01eff50 RBP: 0xffffffff801627c0 RSP: 0xffffffff801626e0 R8: 0x0000000000000190 R9: 0x00000000ffffffff R10: 0xffffffff8014d065 R11: 0xffffffff8014d068 R12: 0xffffffff801400ad R13: 0x0000000000000013 R14: 0xffffffff8014009a R15: 0x0000000000000012 Frame: RIP: 0xffffffff8011cd96 CS: 0x0000000000000008 RFLAGS: 0x0000000000000297 RSP: 0xffffffff80162790 SS: 0x0000000000000010 File Descriptors: Process 2 at 0xffffffffff0020e3 CR3: 0x000000000179e000 RAX: 0x000000000000000a RBX: 0x0000000000000000 RCX: 0x0000000000000000 RDX: 0x0000000000000000 RSI: 0x0000000000408791 RDI: 0x0000000000408338 RBP: 0x00000000019e1f59 RSP: 0x00000000019e1ef9 R8: 0x0000000000000000 R9: 0x0000000000000000 R10: 0x0000000000000000 R11: 0x0000000000000000 R12: 0x0000000000000000 R13: 0x0000000000000000 R14: 0x0000000000000000 R15: 0x0000000000000000 Frame: RIP: 0x00000000004002aa CS: 0x000000000000001b RFLAGS: 0x0000000000000246 RSP: 0x00000000019e1ef9 SS: 0x0000000000000023 File Descriptors: 0 -> 4 1 -> 5 Process 3 at 0xffffffffff0037e5 CR3: 0x00000000019e2000 RAX: 0x0000000000000000 RBX: 0x0000000000000000 RCX: 0x0000000000000000 RDX: 0x0000000000000000 RSI: 0x0000000000408791 RDI: 0x0000000000408338 RBP: 0x00000000019e1f59 RSP: 0x00000000019e1ef9 R8: 0x0000000000000000 R9: 0x0000000000000000 R10: 0x0000000000000000 R11: 0x0000000000000000 R12: 0x0000000000000000 R13: 0x0000000000000000 R14: 0x0000000000000000 R15: 0x0000000000000000 Frame: RIP: 0x00000000004002aa CS: 0x000000000000001b RFLAGS: 0x0000000000000246 RSP: 0x00000000019e1ef9 SS: 0x0000000000000023 File Descriptors: 0 -> 3 1 -> 2 2 -> 1 test test2 test3 test4 Child Attempting to add userspace process from file descriptor LensorOS PANIC General protection fault detected (0)! Error Code: 0x0000000000000000 Instruction Address: 0xffffffff8010e01c Stack Pointer: 0xffffffff80161898 GDT Selector Index: 0 ``` Which is here in the disassembly: ``` ffffffff8010dff8 <_ZNSt8__detail11__format_toINS_28__kernel_log_insert_iteratorES1_cJEEEvOT0_St17basic_string_viewIT1_EDpOT2_>: ffffffff8010dff8: 55 push %rbp ffffffff8010dff9: 48 89 e5 mov %rsp,%rbp ffffffff8010dffc: 48 83 ec 70 sub 0ドルx70,%rsp ffffffff8010e000: 48 89 7d a8 mov %rdi,-0x58(%rbp) ffffffff8010e004: 48 89 d1 mov %rdx,%rcx ffffffff8010e007: 48 89 f0 mov %rsi,%rax ffffffff8010e00a: 48 89 fa mov %rdi,%rdx ffffffff8010e00d: 48 89 ca mov %rcx,%rdx ffffffff8010e010: 48 89 45 90 mov %rax,-0x70(%rbp) ffffffff8010e014: 48 89 55 98 mov %rdx,-0x68(%rbp) ffffffff8010e018: 66 0f ef c0 pxor %xmm0,%xmm0 ffffffff8010e01c: 0f 29 45 d0 movaps %xmm0,-0x30(%rbp) ffffffff8010e020: 66 0f d6 45 e0 movq %xmm0,-0x20(%rbp) ffffffff8010e025: 48 8b 45 a8 mov -0x58(%rbp),%rax ffffffff8010e029: 48 89 c7 mov %rax,%rdi ffffffff8010e02c: e8 dd 5f ff ff call ffffffff8010400e <_ZSt7forwardINSt8__detail28__kernel_log_insert_iteratorEEOT_RNSt16remove_referenceIS2_E4typeE> ffffffff8010e031: 48 8d 55 d0 lea -0x30(%rbp),%rdx ffffffff8010e035: 48 8d 45 f0 lea -0x10(%rbp),%rax ffffffff8010e039: 48 89 d6 mov %rdx,%rsi ffffffff8010e03c: 48 89 c7 mov %rax,%rdi ffffffff8010e03f: e8 06 33 ff ff call ffffffff8010134a <_ZNSt17basic_format_argsISt20basic_format_contextINSt8__detail28__kernel_log_insert_iteratorEcEEC1IJEEERKSt18__format_arg_storeIS3_JDpT_EE> ffffffff8010e044: 48 8b 4d f0 mov -0x10(%rbp),%rcx ffffffff8010e048: 48 8b 55 f8 mov -0x8(%rbp),%rdx ffffffff8010e04c: 48 8d 45 b0 lea -0x50(%rbp),%rax ffffffff8010e050: 48 89 ce mov %rcx,%rsi ffffffff8010e053: 48 89 c7 mov %rax,%rdi ffffffff8010e056: e8 33 33 ff ff call ffffffff8010138e <_ZNSt20basic_format_contextINSt8__detail28__kernel_log_insert_iteratorEcEC1ES1_St17basic_format_argsIS2_E> ffffffff8010e05b: 48 8d 45 b0 lea -0x50(%rbp),%rax ffffffff8010e05f: 48 89 c7 mov %rax,%rdi ffffffff8010e062: e8 3c 42 ff ff call ffffffff801022a3 <_ZSt4moveIRSt20basic_format_contextINSt8__detail28__kernel_log_insert_iteratorEcEEONSt12remove_cvrefIT_E4typeEOS6_> ffffffff8010e067: 48 89 c1 mov %rax,%rcx ffffffff8010e06a: 48 8b 55 90 mov -0x70(%rbp),%rdx ffffffff8010e06e: 48 8b 45 98 mov -0x68(%rbp),%rax ffffffff8010e072: 48 89 d6 mov %rdx,%rsi ffffffff8010e075: 48 89 c2 mov %rax,%rdx ffffffff8010e078: 48 89 cf mov %rcx,%rdi ffffffff8010e07b: e8 7d 3e ff ff call ffffffff80101efd <_ZNSt8__detail8__formatINS_28__kernel_log_insert_iteratorEcEEvOSt20basic_format_contextIT_T0_ESt17basic_string_viewIS4_E> ffffffff8010e080: 90 nop ffffffff8010e081: c9 leave ffffffff8010e082: c3 ret ``` **AKA** the exact same `movaps` instruction as before, within `__kernel_log_insert_iterator`
Author
Owner
Copy link

NOTE: The movaps instruction is included even with -fno-tree-vectorize

NOTE: The `movaps` instruction is included even with `-fno-tree-vectorize`
Author
Owner
Copy link

Does yield_asm or something make stack not aligned anymore? Or scheduler interrupt handler?

Does `yield_asm` or something make stack not aligned anymore? Or scheduler interrupt handler?
Author
Owner
Copy link

Compiling with -Ox where x is anything other than 0 breaks std::format horribly

Compiling with `-Ox` where x is anything other than `0` breaks std::format horribly
Author
Owner
Copy link

Commenting out body of std::print in <format> (L869) makes it error somewhere else, I think? It's hard to tell because we can't print anything out :3

Commenting out body of `std::print` in `<format>` (L869) makes it error somewhere else, I think? It's hard to tell because we can't print anything out :3
Author
Owner
Copy link
Related? https://gcc-bugs.gcc.gnu.narkive.com/Rmku4Ok5/regarding-gcc-emitting-movaps-to-unaligned-memory
Author
Owner
Copy link
Related? https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87421
Author
Owner
Copy link

I've "fixed" the issue!!!

Not really fixed, persay, but definitely at least somewhat avoided it!

I used -mno-sse, -mno-sse2, AND -fno-tree-vectorize on BOTH the interrupts and kernel targets. This means we can no longer use those registers in the kernel, but that's not really a big deal; Linux, for example, famously didn't allow floating point operations in the kernel until recently, where they added a shoddy manual save/restore feature that is never actually used, haha.

I've "fixed" the issue!!! Not really fixed, persay, but definitely at least somewhat avoided it! I used `-mno-sse`, `-mno-sse2`, AND `-fno-tree-vectorize` on BOTH the interrupts and kernel targets. This means we can no longer use those registers in the kernel, but that's not really a big deal; Linux, for example, famously didn't allow floating point operations in the kernel until recently, where they added a shoddy manual save/restore feature that is never actually used, haha.
Author
Owner
Copy link

There are still reliability issues...
This error occured after forking/execcing like four times in a row

Child
Attempting to add userspace process from file descriptor procfd:3
Program header: type=1, offset=0
 filesz=0x0000000000007c64, memsz=0x0000000000007c64
[ELF]: Loaded program header (31844 bytes) from file procfd:3 at byte offset 0
Program header: type=1, offset=32768
 filesz=0x0000000000000178, memsz=0x00000000000f44d0
[ELF]: Loaded program header (376 bytes) from file procfd:3 at byte offset 32768
[ELF] Program Arguments
 stack: 0x0000000001ea9ff0
 argv: 0x0000000001ea9ff8
 Faulty Address: 0x0000000000000016
 PageTable Address: 0x0000000001c66000
4th lvl permissions | RW US AC
3rd lvl permissions | RW US AC
2nd lvl permissions | RW AC
1st lvl permissions | RW AC DT
PHYS 0x0000000000000000 at VIRT 0x0000000000000016
 Data Access
 From ring 3
 Read
CurrentProcess->ProcessID == 5
Present: 0x0000000000400000 to 0x0000000000408000 | US
Present: 0x0000000000408000 to 0x00000000004fd000 | RW US
Present: 0x0000000001ea6000 to 0x0000000001ea9000 | RW US
Present: 0x0000000001ea9000 to 0x0000000001eaa000 | RW US AC DT
**
ERROR:../../../target/i386/tcg/sysemu/excp_helper.c:517:raise_stage2: code should not be reached
Bail out! ERROR:../../../target/i386/tcg/sysemu/excp_helper.c:517:raise_stage2: code should not be reached
There are still reliability issues... This error occured after forking/execcing like four times in a row ``` Child Attempting to add userspace process from file descriptor procfd:3 Program header: type=1, offset=0 filesz=0x0000000000007c64, memsz=0x0000000000007c64 [ELF]: Loaded program header (31844 bytes) from file procfd:3 at byte offset 0 Program header: type=1, offset=32768 filesz=0x0000000000000178, memsz=0x00000000000f44d0 [ELF]: Loaded program header (376 bytes) from file procfd:3 at byte offset 32768 [ELF] Program Arguments stack: 0x0000000001ea9ff0 argv: 0x0000000001ea9ff8 Faulty Address: 0x0000000000000016 PageTable Address: 0x0000000001c66000 4th lvl permissions | RW US AC 3rd lvl permissions | RW US AC 2nd lvl permissions | RW AC 1st lvl permissions | RW AC DT PHYS 0x0000000000000000 at VIRT 0x0000000000000016 Data Access From ring 3 Read CurrentProcess->ProcessID == 5 Present: 0x0000000000400000 to 0x0000000000408000 | US Present: 0x0000000000408000 to 0x00000000004fd000 | RW US Present: 0x0000000001ea6000 to 0x0000000001ea9000 | RW US Present: 0x0000000001ea9000 to 0x0000000001eaa000 | RW US AC DT ** ERROR:../../../target/i386/tcg/sysemu/excp_helper.c:517:raise_stage2: code should not be reached Bail out! ERROR:../../../target/i386/tcg/sysemu/excp_helper.c:517:raise_stage2: code should not be reached ```
Author
Owner
Copy link

So somehow there is a user process dereferencing 0x16 memory address...

So somehow there is a user process dereferencing `0x16` memory address...
Handles strings and characters only, right now.
It actually collects commands now! So that's cool.
A prompt: Check.
A line that refreshes as you type: Check.
An ability to run (at least one) command: Check.
Migration from doubles to integers
This disables the runtime loop in the kernel, as well as use of
gRend/gText after initial boot. Basically, the kernel now hands the ux
entirely off to userspace init process.
Some things to note:
1. The way of passing the framebuffer details from kernel to userspace
through `argv` string arguments is ... let's say this: *not ideal*.
2. It's probably a good idea to rename `stdout` to `init` and make
another process that simply writes to stdout
LensPlaysGames changed title from (削除) WIP: fork and exec system calls, and everything that goes with them (削除ここまで) to fork and exec system calls, and everything that goes with them 2023年02月07日 19:21:29 +01:00
Author
Owner
Copy link

Can probably merge this PR any time now
Pog

Can probably merge this PR any time now Pog
Author
Owner
Copy link

You know it's OSdev when you make changes, it causes a crash, you undo them, and the crash is still there 😠

You know it's OSdev when you make changes, it causes a crash, you undo them, and the crash is still there :angry:
`exit` syscall no longer prints unconditionally; requires DEBUG
define.
Code formatting: remove braces from single-expression `if`.
TODO: floating point context needs saved
TODO: ExFAT went and changed cluster definitions; we have them, just
need to use them.
Fixed invalid access of variable `process` in DBGMSG (I assume it was
renamed, and since the define wasn't in place, the code isn't
compiled, and errors aren't found).
Also some minor formatting here and there, and removal of unused code.
Author
Owner
Copy link

It's definitely time for a merge. I'll be doing that very soon 👀

It's definitely time for a merge. I'll be doing that very soon :eyes:
Author
Owner
Copy link

There was definitely at least one major bug fixed in cb052b3603 related to waitpid not saving CPU state off of the stack into the Process structure, as the Scheduler switch process does. It should be noted this is required anytime yield is called.

There was definitely at least one major bug fixed in https://codeberg.org/LensPlaysGames/LensorOS/commit/cb052b3603d5e352f4d661071ed4b5ac31f05d96 related to `waitpid` not saving CPU state off of the stack into the Process structure, as the Scheduler switch process does. It should be noted this is required anytime `yield` is called.
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
LensPlaysGames/LensorOS!17
Reference in a new issue
LensPlaysGames/LensorOS
No description provided.
Delete branch "fork_exec"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?