Commit Graph

701 Commits

Author SHA1 Message Date
Justin C. Miller
7ce418aabc Fix KVM page faults from lack of 1GB page support 2019-07-04 02:51:50 -07:00
Justin C. Miller
6285517ef7 Rename Popcorn to jsix.
See README.md for more information.
2019-05-27 14:07:29 -07:00
Justin C. Miller
a653c55941 Use 0 instead of syscall_invalid in syscall jump list 2019-05-18 18:11:08 -07:00
Justin C. Miller
ce035d2a43 Finish address_manager to vm_space transition 2019-05-18 18:06:57 -07:00
Justin C. Miller
2d54eb5143 Add vmem log area 2019-05-11 11:32:22 -07:00
Justin C. Miller
88315c25a5 Allow vm_space to merge ranges 2019-04-18 00:22:01 -07:00
Justin C. Miller
806bfd1fbf First pass at vm_space (address_manager replacement) 2019-04-17 19:16:54 -07:00
Justin C. Miller
910b5116f4 Fix stack overruns 2019-04-16 23:39:52 -07:00
Justin C. Miller
6302e8b73a Overhaul memory allocation model
This commit makes several fundamental changes to memory handling:

- the frame allocator is now only an allocator for free frames, and does
  not track used frames.
- the frame allocator now stores its free list inside the free frames
  themselves, as a hybrid stack/span model.
  - This has the implication that all frames must currently fit within
    the offset area.
- kutil has a new allocator interface, which is the only allowed way for
  any code outside of src/kernel to allocate. Code under src/kernel
  _may_ use new/delete, but should prefer the allocator interface.
- the heap manager has become heap_allocator, which is merely an
  implementation of kutil::allocator which doles out sections of a given
  address range.
- the heap manager now only writes block headers when necessary,
  avoiding page faults until they're actually needed
- page_manager now has a page fault handler, which checks with the
  address_manager to see if the address is known, and provides a frame
  mapping if it is, allowing heap manager to work with its entire
  address size from the start. (Currently 32GiB.)
2019-04-16 01:13:09 -07:00
Justin C. Miller
fd1adc0262 Put MAX_SYSCALLS in hex to match syscalls list 2019-04-09 23:35:32 -07:00
Justin C. Miller
070be0b005 Allow map_page call with 0 address to allocate address space 2019-04-09 23:20:27 -07:00
Justin C. Miller
5034ffbe59 Increase max kernel heap allocation to 4MiB 2019-04-09 22:31:06 -07:00
Justin C. Miller
cd13b88540 Log about additional CPU/APICs 2019-04-08 14:33:10 -07:00
Justin C. Miller
e050d6f151 Move more logging infrastructure into kutil 2019-04-06 18:25:09 -07:00
Justin C. Miller
863555ec6b Clean up process memory on exit.
Additionally, there were several bug fixes needed to allow this:
- frame_allocator was allocating its frame_blocks from the heap, causing
  a circular dependency. Now it gives itself a page on its own when
  needed.
- frame_allocator::free was putting any trailing pages in a block back
  into the list after the current block, so they would be the next block
  iterated to.
- frame_allocator::free was updating the address it was looking for
  after freeing some pages, but not the count it was looking for, so it
  would eventually free all pages after the initial address.
2019-04-06 11:19:38 -07:00
Justin C. Miller
c605793a9d Fix fork() for new task switching model 2019-04-03 10:08:26 -07:00
Justin C. Miller
8375870af6 Improve syscall definitions
- Allow constant id specification
- Define function signature in SYSCALL macro
- Move implementation into src/kernel/syscalls/*.cpp
2019-04-03 10:03:15 -07:00
Justin C. Miller
11a53e792f Improve syscalls for new task switching
There are a lot of under the hood changes here:
- Move syscalls to be a dispatch table, defined by syscalls.inc
- Don't need a full process state (push_all) in syscalls now
- In push_all, define REGS instead of using offsets
- Save TWO stack pointers as well as current saved stack pointer in TCB:
  - rsp0 is the base of the kernel stack for interrupts
  - rsp3 is the saved user stack from cpu_data
- Update syscall numbers in nulldrv
- Some asm-debugging enhancements to the gdb script
- fork() still not working
2019-04-02 00:25:36 -07:00
Justin C. Miller
ca2362f858 Simplify task switches
No longer using the rsp from the entry to the kernel, but instead
switching rsp at task-switching time in assembly.

This currently breaks fork()
2019-03-31 22:49:24 -07:00
Justin C. Miller
5cdbedd4d1 Move console to use kutil's printf 2019-03-31 22:43:37 -07:00
Justin C. Miller
39baec852b Allow larger initrd images 2019-03-25 01:42:36 -07:00
Justin C. Miller
ed3f9410a6 Make nulldrv a small C++ program 2019-03-24 13:44:25 -07:00
Justin C. Miller
b18243f098 Improve process switching and syscall log spam 2019-03-22 17:43:29 -07:00
Justin C. Miller
9472dab522 Fix asm int call for LLVM 8 2019-03-22 17:42:51 -07:00
Justin C. Miller
9067f8d298 Add kernel logging task
- Enable creating kernel tasks
- Create kernel task that disables immediate-mode logging and prints
  logs to the console forever
2019-03-20 23:45:01 -07:00
Justin C. Miller
866073ae8a Fix RFLAGS-clobbering syscalls 2019-03-20 23:42:42 -07:00
Justin C. Miller
91cb00fde2 Add immediate log output for early kernel 2019-03-20 20:58:44 -07:00
Justin C. Miller
c435bcfb67 Removed empty unused output_log 2019-03-20 20:58:44 -07:00
Justin C. Miller
7fe1b7d1f5 Add temporary log output
Currently the kernel idle process is an infinite loop printing logs,
with no locking.
2019-03-20 20:58:44 -07:00
Justin C. Miller
39524b2b9f Move kernel over to new logger 2019-03-20 20:58:44 -07:00
Justin C. Miller
c592f5f537 Add buffer-based logging system 2019-03-20 20:58:44 -07:00
Justin C. Miller
94c491d286 Update to LLVM 8.0 2019-03-20 15:40:01 -07:00
Justin C. Miller
645938a194 Add bip buffer and constexpr hash 2019-03-17 10:02:57 -07:00
Justin C. Miller
73756820bd Fix page_manager::unmap_pages() free tracking 2019-03-16 00:36:45 -07:00
Justin C. Miller
33374ab257 Clean up process loader
- cpu_state was being passed 'by value' to modify outer stack frame
- don't pass loader args as rax, rbx, etc - pass in ABI order
2019-03-15 01:05:45 -07:00
Justin C. Miller
bf8286d15f Improve debugging functions
- More sensible stack tracer, in C++ (no symbols yet)
- Was forgetting to add null frame to new kernel stacks
- __kernel_assert was using an old vector
- A GP fault will only print its associated table entry
2019-03-15 00:47:46 -07:00
Justin C. Miller
6410c898c5 Switch push/pop_all macros from push/pop to mov 2019-03-14 23:25:26 -07:00
Justin C. Miller
be007c6278 Implement exit syscall 2019-03-14 22:28:21 -07:00
Justin C. Miller
f7558e3d18 Implement fast syscall/sysret for sytem calls 2019-03-13 23:51:29 -07:00
Justin C. Miller
97e8f2c69a Add get_gsbase() 2019-03-13 22:49:20 -07:00
Justin C. Miller
49bdf47514 Remove segments from push_all 2019-03-13 22:45:02 -07:00
Justin C. Miller
870ca1db45 Allow debug option to be communicated at boot 2019-03-11 03:04:57 -07:00
Justin C. Miller
74a5c301f8 Add guid_device_path GUIDs 2019-03-10 23:35:23 -07:00
Justin C. Miller
722ee4c52c Recycle old initial pml4 2019-03-10 00:51:39 -08:00
Justin C. Miller
67b9f45004 Offset-map the entire offset region with 1G pages
Instead of building nested page tables for the offset region, just
offset map the entire thing into kernel memory with one PDP mapping
1GiB large pages. This is more efficient and avoids the "need a
page table to map in a page table" dependency loop.
2019-03-09 14:55:48 -08:00
Justin C. Miller
2035fffa1c Fix loading large process images.
2MiB large pages were being used for any large page mapping, but the
page manager doesn't correctly handle them everywhere yet. Now only
allow them for offset pointers (eg MMIO space) that will never be
unmapped.
2019-03-09 13:10:10 -08:00
Justin C. Miller
97ac3c09fa Implement initial fork syscall 2019-03-09 12:18:21 -08:00
Justin C. Miller
241e1dacb0 Consolidate testing memory setup 2019-03-07 23:53:38 -08:00
Justin C. Miller
ac19d3f532 Allow page table copying and unmapping
Lots of rearranging in page_manager as well, moving constants out as
well as helper structs.
2019-03-03 01:52:21 -08:00
Justin C. Miller
194527e0fe Fix address-marking bugs
* Non-blocksize-aligned regions could fail to be found. Have the
  bootloader load them aligned.
* Consolidating used frame blocks in the bootstrap means these would
  have been impossible to free as address space
* mark_permanent wasn't actually removing blocks from the free list
2019-03-03 01:42:32 -08:00