1. 03 Apr, 2017 1 commit
  2. 27 Nov, 2016 1 commit
  3. 26 Oct, 2016 17 commits
    • Charles Jacobsen's avatar
      Starting to adjust Anton's stack trace code for new design. · 5c5080d9
      Charles Jacobsen authored
      Going to take a bit more work because the struct module is no
      longer directly available on the host side, so starting a new branch ...
      5c5080d9
    • Charlie Jacobsen's avatar
      test-v2: Update address -> cptr to return offset into memory object. · 5bc7d324
      Charlie Jacobsen authored
      Updated kliblcd, liblcd, and string example.
      5bc7d324
    • Charles Jacobsen's avatar
      test-v2: RAM map tests pass. · c543053a
      Charles Jacobsen authored
      Couple duplicate memory interval tree inserts/deletes were leading
      to some use-after-frees/page faults. Cleaned that up. Added some
      resource tree debug code along the way.
      
      Also, caught something subtle (noted in code). I didn't consider
      the following scenario: Heap tries to allocate pages; the allocator
      notices it needs to bring in more fresh pages, and notifies the
      heap (via a callback); the heap allocs the fresh pages (from the
      microkernel), maps them, and inserts those pages into the memory interval
      tree; the memory interval tree kmallocs a tree node; kmalloc
      calls back into the heap to grow a slab cache.
      
      That last bit could be a potential problem (recursive call back
      into the heap before we finish the original call). Lucky for me,
      I designed the heap/allocator so that (1) the pages from the first
      call are already marked as in use (not on a free list); (2) the
      fresh pages are mapped first *before* inserting the corresponding
      cptr into the memory interval tree.
      
      The Linux kernel deals with these same recursive issues (they
      resolve them using special GFP_ flags so that you don't get
      recursion). In my case, the recursion is risky, but works.
      c543053a
    • Charles Jacobsen's avatar
      test-v2: kmalloc tests pass, big page alloc test passes. · 42ad48cc
      Charles Jacobsen authored
      Caught a bug in heap allocator - wasn't setting an out
      parameter (that design pattern I use - out params - will be the
      death of me).
      
      Updated max page allocation order to match the host. The microkernel
      uses the host page allocator, so that is the only limiting
      factor now (so e.g., on x86_64, you can now allocate up to
      2^10 = 1024 pages = 4 MBs inside the LCD, and this is the maximum
      you could allocate in non-isolated code too). Before, the allocation
      size was limited to about 2^6 = 64 pages = 256 KBs.
      42ad48cc
    • Charles Jacobsen's avatar
      test-v2: Fix more allocator bugs. · 94bbac3f
      Charles Jacobsen authored
      I needed to re-think the free lists initialization.
      Also bug in demand paging.
      
      Heap and kmalloc now initialize, but I still crash afterward.
      94bbac3f
    • Charles Jacobsen's avatar
      test-v2: Add rb tree code to liblcd, fix unresolved mutex symbols. · 87fbf2ff
      Charles Jacobsen authored
      There is a limitation with my preprocessor hacks: If a header
      invokes a function inside another static inline function, I
      can't modify the call site (that is the key) using a macro
      undef/re-define. Instead, I need to just define the function
      in another source file.
      
      Another limitation (yet to be encountered) is a problematic
      macro function invoked in a header. I can't re-define the
      macro function before the call site using the post hooks. Will
      cross that bridge when I get there.
      87fbf2ff
    • Charles Jacobsen's avatar
      test-v2: LCD module create functioning. · 38d3c5d0
      Charles Jacobsen authored
      Host can successfully load LCD, using new interval tree/memory
      object logic. (Still get EPT fault while booting LCD.)
      
      Some fixes/changes:
      
          1 - Need to use page-level granularity for memory objects.
              Unlike alloc_pages, vmalloc is page-granularity (rather
              than power-of-2 page granularity).
          2 - The kernel module region base virtual address needs to
              match the host's upper 2GB address, because of how address
              calculations are done internally and because we use the
              host module loader with no linkage changes (it's possible,
              but not worth it right now). Add assertion to make sure
              this is the case.
          3 - Needed to make LCD the owner of its cspace (set owner
              pointer).
      38d3c5d0
    • Charles Jacobsen's avatar
      4ca91d0c
    • Charlie Jacobsen's avatar
      liblcd-v2: Add slab dependencies. · 1b64ac34
      Charlie Jacobsen authored
      1b64ac34
    • Charlie Jacobsen's avatar
      a94f0e92
    • Charlie Jacobsen's avatar
      liblcd-v2: Fix generalized page alloc metadata alloc/free. · 2979d763
      Charlie Jacobsen authored
      It seemed dumb to have the generalized page allocator code
      repeatedly call out to the user to get memory for metadata.
      For one thing, it was buggy. For another, in many use cases
      we can alloc the metadata in one shot.
      
      RAM map allocator partially started.
      2979d763
    • Charlie Jacobsen's avatar
      liblcd-v2: Make room for RAM map region (separate from heap). · b9ce0034
      Charlie Jacobsen authored
      This is kind of like an mmap region, but only for RAM. (The guest
      virtual page tables will be configured for write back).
      
      Use case: You get a RAM capability from some other guy, and you
      want to map it into your physical/virtual address space. This is
      reasonable to figure out manually for big RAM chunks that are
      mapped one/two times. But for little tedious ones (string sharing),
      it's helpful to have an allocator to assist and track free parts
      of guest physical.
      
      The RAM map region uses very course-grained physical address space
      allocation (minimum 64 MBs). This leads to a lot of internal
      fragmentation, but it should be tolerable since the region is big.
      It also means we have a smaller bit of metadata for tracking the
      region.
      b9ce0034
    • Charlie Jacobsen's avatar
      liblcd-v2: Add higher-level interface code for page allocator. · 39a20ffe
      Charlie Jacobsen authored
      vmalloc is not implemented for now.
      39a20ffe
    • Charlie Jacobsen's avatar
      liblcd-v2: Heap allocator internals in place, first draft. · fa0aea92
      Charlie Jacobsen authored
      Uses the "generalized" allocator to manage 16 MBs of guest physical
      address space for a heap. Only the initial 4 MBs will be backed,
      and host memory is sucked in at 4 MB granularity.
      
      Some tuning of parameters will be necessary soon.
      fa0aea92
    • Charlie Jacobsen's avatar
      liblcd-v2: Low-level mmap done. Tweaked low-level mmap interface. · 9829af71
      Charlie Jacobsen authored
      Easier to have caller pass memory object order and gpa base for
      _lcd_mmap and _lcd_munmap, since in liblcd we can look those
      things up easily.
      9829af71
    • Charlie Jacobsen's avatar
      liblcd-v2: Low-level system call wrappers. · 7fe276a9
      Charlie Jacobsen authored
      I need to pause liblcd-v2 and redo the resource tree logic
      for kliblcd. Now that I'm working on liblcd, I'm seeing the way
      it should be.
      7fe276a9
    • Charlie Jacobsen's avatar
      liblcd-v2: Add memory itree code, simple LCD create code. · c99648ed
      Charlie Jacobsen authored
      Memory itree code initializes resource tree needed for
      address -> cptr translation. Provides interface for other liblcd
      code to add/remove from tree (page allocator will use that).
      
      Removed redundant nr_pages_order field from resource tree node. Its
      size can be computed from the interval tree node.
      
      Filled in some simple functions that are part of the liblcd
      interface. Some are no-ops for isolated code.
      c99648ed