1. 25 Oct, 2016 24 commits
    • Charlie Jacobsen's avatar
      Basic lcd module create, run, and destroy. · e0193fa4
      Charlie Jacobsen authored
      This code is ugly, but it's working.
      
      Tested with basic module, and appears to be working
      properly. I will soon incorporate the patched
      modprobe into the kernel tree, and then this code
      will be usable by everyone.
      
      The ipc code is still unimplemented. The only
      hypercall handled is yield. Also note that other
      exit conditions (e.g. external interrupt) have not
      been fully tested.
      
      Overview:
      -- kernel code calls lcd_create_as_module with
         the module's name
      -- lcd_create_as_module loads the module using
         request_lcd_module (request_lcd_module calls
         the patched modprobe to load the module, and
         the patched modprobe calls back into the lcd
         driver via the ioctrl interface to load the
         module)
      -- lcd_create_as_module then finds the loaded
         module, spawns a kernel thread and passes off
         the module to it
      -- the kernel thread initializes the lcd and
         maps the module inside it, then suspends itself
      -- lcd_run_as_module wakes up the kernel thread
         and tells it to run
      -- lcd_delete_as_module stops the kernel thread
         and deletes the module from the host kernel
      
      File-by-file details:
      
      arch/x86/include/asm/lcd-domains-arch.h
      arch/x86/lcd-domains/lcd-domains-arch-tests.c
      arch/x86/lcd-domains/lcd-domains-arch.c
      -- lcd was not running in 64-bit mode, and my
         checks had one subtle bug
      -- fixed %cr3 load to properly load vmcs first
      -- fixed set program counter to use guest virtual
         rather than guest physical address
      
      include/linux/sched.h
      -- added struct lcd to task_struct
      
      include/linux/init_task.h
      -- lcd pointer set to null when task_struct is
         initialized
      
      include/linux/module.h
      kernel/module.c
      -- made init_module and delete_module system calls
         callable from kernel code
      -- available in module.h via do_sys_init_module and
         do_sys_delete_module
      -- simply moved the majority of the guts of the
         system calls into a non-system call, exported
         routine
      -- take an extra flag, for_lcd; when set, the init
         code skips over running (and deallocating) the
         module's init code, and the delete code skips
         over running the module exit
      -- system calls from user code set for_lcd = 0; this
         ensures existing code still works
      
      include/linux/kmod.h
      kernel/kmod.c
      kernel/sysctl.c
      -- changed __request_module to __do_request_module; takes
         one extra argument, for_lcd
      -- __request_module   ==>  __do_request_module with for_lcd = 0
      -- request_lcd_module ==>  __do_request_module with for_lcd = 1
      -- call_modprobe conditionally uses lcd_modprobe_path, the path
         to a patched modprobe accessible via sysfs
      
      include/lcd-domains/lcd-domains.h
      -- added lcd status enum; see source code doc
      -- three routines for creating/running/destroying
         lcd's that use modules; see source code doc
      
      include/uapi/linux/lcd-domains.h
      -- added interface defns for patched modprobe to call into
         lcd driver for module init; lcd driver loads
         module (via slightly refactored module.c code) on behalf
         of modprobe
      
      virt/lcd-domains/lcd-domains.c
      -- implementation of routines for modules inside lcd's
      -- implementation of module init / delete for lcd's
         (uses patched module.c code)
      
      virt/lcd-domains/Kconfig
      virt/lcd-domains/Makefile
      virt/lcd-domains/lcd-module-load-test.c
      virt/lcd-domains/lcd-tests.c
      -- added test module for lcd module code
      -- test runs automatically when lcd module is inserted
      e0193fa4
    • Charles Jacobsen's avatar
      Simple blob successfully runs and returns in vmx. · c4fc774c
      Charles Jacobsen authored
      In the process of debugging, major corrections and
      debug checks implemented (this is a big squash):
      -- coded up entry checks documented in Intel SDM
         V3 chp 26 (this should help later if settings
         are changed, make it less risky to experiment
         and give more confidence)
      -- fixed host tr base addr bug (the worst bug! caused
         system to hang and then crash, since the tss
         was erroneous...)
      -- fixed vmx_entry to properly set host rsp before
         entry
      -- setting host sysenter and idt info
      -- fixed cs ar bytes bug
      -- fixed gdt limit bug
      -- fixed tr type bug
      -- extra settings added to cr0 and cr4, but may
         not be needed ... (debug fix attempt)
      -- lstar mstar autoload, may not be needed ...
         (debug fix attempt)
      c4fc774c
    • Charles Jacobsen's avatar
      Fixed build errors, all tests passing. · 78569fe2
      Charles Jacobsen authored
      Fixed (another) nasty casting bug in the
      code that initializes the ept pointer. I
      was using the old way of casting, and overlooking
      that I was storing a host virtual pointer
      inside a host physical pointer. This caused
      invept to fail (invept checks if the eptp is
      valid).
      
      I also fixed invept and invvpid to print an
      error message (like vmload and vmclear), rather
      than generate an invalid opcode exception. It's
      easier to debug and understand the problem.
      
      In the future, we could more carefully parse the
      error returned.
      78569fe2
    • Charles Jacobsen's avatar
      Most build errors fixed. · e6442a9d
      Charles Jacobsen authored
      e6442a9d
    • Charlie Jacobsen's avatar
      364254ba
    • Charles Jacobsen's avatar
      Guest virtual paging now appears to be working. · bdc65df6
      Charles Jacobsen authored
      Nasty casting bug. (I should create separate
      types for gpa, hpa, hva, gva...).
      bdc65df6
    • Charles Jacobsen's avatar
      Debugging pud lookup. · a00b76d8
      Charles Jacobsen authored
      a00b76d8
    • Charles Jacobsen's avatar
      b9f6d8fb
    • Charlie Jacobsen's avatar
      Shifted gpa map / unmap range to arch-dep code. · f9b52a46
      Charlie Jacobsen authored
      Updated tests.
      f9b52a46
    • Charles Jacobsen's avatar
      Minor stylistic changes. · d12f83e3
      Charles Jacobsen authored
      d12f83e3
    • Charles Jacobsen's avatar
      Fixed some bugs related to test 6,7. · e29685aa
      Charles Jacobsen authored
      e29685aa
    • Charlie Jacobsen's avatar
      Simple high-level test for gv paging. · 32f96272
      Charlie Jacobsen authored
      32f96272
    • Charles Jacobsen's avatar
      All lcd tests through 5 are passing. · a81d9641
      Charles Jacobsen authored
      Added pgd_pfn to asm/pgtables.h.
      a81d9641
    • Charlie Jacobsen's avatar
      Test 05 for pmd lookup. · 66f1c386
      Charlie Jacobsen authored
      66f1c386
    • Charles Jacobsen's avatar
      Test 04 now passing. · f5ea240c
      Charles Jacobsen authored
      I needed to mask off the flags in the lower part
      of the pte ...
      f5ea240c
    • Charles Jacobsen's avatar
      d9213d82
    • Charlie Jacobsen's avatar
      Second test for gva: page table lookup. · 63bccfa7
      Charlie Jacobsen authored
      63bccfa7
    • Charles Jacobsen's avatar
      bd433045
    • Charlie Jacobsen's avatar
      Small test for gva. · ca4a1ebc
      Charlie Jacobsen authored
      For paging mem allocation.
      ca4a1ebc
    • Charles Jacobsen's avatar
      Fixed paging mem alloc to map in ept. · 71ecd50c
      Charles Jacobsen authored
      71ecd50c
    • Charlie Jacobsen's avatar
      Added a stress test for guest virtual. · 64bf35a5
      Charlie Jacobsen authored
      64bf35a5
    • Charlie Jacobsen's avatar
      Test for gva init. · aa50347d
      Charlie Jacobsen authored
      aa50347d
    • Charles Jacobsen's avatar
      Fixed build errors for first test. · 8a1846ba
      Charles Jacobsen authored
      Pushing in case of crash ...
      8a1846ba
    • Charlie Jacobsen's avatar
      a2e997e8