1. 25 Oct, 2016 16 commits
    • Charlie Jacobsen's avatar
      Finished arch-dep ept code. · 8f65d678
      Charlie Jacobsen authored
      lcd_arch_epte_t type for arch abstraction.
      
      lcd_arch_ept_walk
      -- simple lookup of ept entry
      -- optionally allocate ept data structures
         along the way
      
      lcd_arch_ept_set
      -- set the host physical address in the
         (final level) ept entry, along with
         default flags
      
      lcd_arch_ept_hpa
      -- returns host physical address stored in
         an ept entry
      
      Remaining old code will be put in arch-indep
      code.
      8f65d678
    • Charlie Jacobsen's avatar
      Loads / stores to cr3 now handled (untested). · 40de4ae2
      Charlie Jacobsen authored
      This is necessary for e.g. the emulab machines (loads /
      stores to cr3 are not allowed in non-root, so must be
      handled by hypervisor). Code simply copies values between
      fields in lcd data structure.
      40de4ae2
    • Charlie Jacobsen's avatar
      Simple EPT fault handling code in place (untested). · c37435a0
      Charlie Jacobsen authored
      Removed the `auto' memory alloc and map from the
      original handler. The new handler is simple for now;
      it just reads the guest virtual and physical addresses
      involved in the fault. The arch-indepent code will be
      responsible for deciding what to do.
      c37435a0
    • Charlie Jacobsen's avatar
      External interrupt code in place (untested). · 1abf5ea6
      Charlie Jacobsen authored
      vmx_handle_external_intr
      -- pretty much a straight copy over of the old code,
         but with comments
      -- one big difference: interrupts are assumed to be
         enabled when this routine is called (I can't see
         how kvm is allowing the handling of external interrupts
         because it disables them when it enters vmx non-root.
         See the kvm code in x86.c:vcpu_enter_guest.)
      1abf5ea6
    • Charlie Jacobsen's avatar
      Set up simple lcd run (no loop) and some handling (untested). · 070e2688
      Charlie Jacobsen authored
      lcd_arch_run:
      -- disables kernel preemption while lcd is running
      -- simple switch on vmx exit conditions
      
      vmx_handle_exception_nmi
      -- for nmi's and exceptions generated by lcd
      
      vmx_handle_hard_exception
      -- for `hardware exceptions': page faults, traps,
         machine checks
      070e2688
    • Charlie Jacobsen's avatar
      Simple re-naming to arch-agnostic names for arch-dep interface. · c8a88195
      Charlie Jacobsen authored
      -- Moved some vmx-specific data structures into implementation file.
      -- lcd_vmx_* => lcd_arch_*
      -- updated virt/lcd/lcd-domains.c
      c8a88195
    • Charlie Jacobsen's avatar
      a46b6017
    • Charlie Jacobsen's avatar
    • Charlie Jacobsen's avatar
      Added header doc to lcd-vmx.h and lcd_vmx_destroy. · 4cdb5e83
      Charlie Jacobsen authored
      lcd_destroy => lcd_vmx_destroy. Pretty much a straight
      copy over, but removed some unneeded code.
      4cdb5e83
    • Charles Jacobsen's avatar
      Fixed bugs in lcd_vmx_create and dependencies. Clean build. · 4d27a893
      Charles Jacobsen authored
      Conditional compilation on number of autoload msr's.
      
      Untested.
      4d27a893
    • Charlie Jacobsen's avatar
      Finished lcd_vmx_create and its dependencies (untested). · 7607ec9a
      Charlie Jacobsen authored
      vmx_setup_vmcs ==> vmx_setup_vmcs_guest_settings and
      vmx_setup_vmcs_host.
      
      vmx_setup_vmcs_guest_settings
      -- execution control (e.g., interrupt handling)
      -- ept pointer
      -- %cr0 and %cr4 access control
      
      vmx_setup_vmcs_guest_regs
      -- initial %cr0, %cr4
      -- segmentation--bases, limits, selectors
      -- guest EFER (long mode enabled, no syscall/sysret)
      -- initial activity and interrupt state
      
      vmx_setup_vmcs_host
      -- control and segmentation regs
      -- host EFER
      -- no saving of syscall/sysret msrs since these are
         disabled in guest
      -- no page attribute table
      7607ec9a
    • Charlie Jacobsen's avatar
      About half way done with vmcs initialization code. · acbb9533
      Charlie Jacobsen authored
      lcd_create --> lcd_vmx_create, with a lot of code
      re-factored or removed for now, to keep it simple
      (no gdt, idt, isr, paging bitmap, address space
      init, etc.).
      -- basic ept initialization
      -- vmcs loading on a cpu
         -- re-factored __vmx_setup_cpu to use built-in
            segment descriptor access functions in desc.h
         -- removed host sys_enter storage, since this
            msr is disabled right now anyway
         -- more doc to understand vmcs load process
      acbb9533
    • Charles Jacobsen's avatar
      Successful build with lcd_vmx_init and lcd_vmx_exit. · 62e4ac37
      Charles Jacobsen authored
      Added straight copy from old code of lcd_vmx_exit.
      
      Shifted lcd_vmx_init and lcd_vmx_exit to
      arch/x86/include/asm/lcd-vmx.h. Ideally, if we want
      this to be arch-independent, probably want to change
      header to asm/lcd.h, and routines to lcd_arch_init
      and lcd_arch_exit, or something similar.
      62e4ac37
    • Charles Jacobsen's avatar
      Fixed build system for lcd, and most compiler errors. · 7c05c7a0
      Charles Jacobsen authored
      Two components to the lcd build now:
      -- arch/x86/lcd/Makefile: for building x86 lcd code
      -- virt/lcd/Makefile: for building arch-indep lcd code
      
      Modified the build system just slightly for a cleaner
      build:
      -- virt/ directory treated like ipc/, usr/, etc. directories
      -- added Kconfig and Makefile to virt/, mirroring drivers/
      -- updated top-level Makefile to include virt/ as vmlinux
         directory / dependency, so build system will recur into
         virt/
      -- updated arch/x86/Kconfig to include virt/Kconfig, so it
         will be included as a menu item
      -- updated arch/x86/Kbuild to include arch/x86/lcd/
      
      Removed old capabilities code in cap/.
      
      Removed lcd syscall.
      
      Temporarily turned off build for drivers/lcd.
      
      Fixed most bugs in lcd-vmx (still need to do lcd_vmx_exit).
      -- minor naming issues in lcd-vmx.h
      -- straight copy over of vmx_disable_intercepts_for_msr,
         but with more doc
      -- removed VMX_EPT_INDIVIDUAL_ADDR macro from vmx.h (where
         did this come from? it's not documented in the intel manual,
         nor is it used in kvm)
      7c05c7a0
    • Charlie Jacobsen's avatar
      Finished lcd_vmx_init and its dependencies. · 18122896
      Charlie Jacobsen authored
      Added a few missing macros to arch/x86/include/vmx.h,
      and RESERVED masks for easily determining which bits
      in a vmx control are reserved (needed in adjust_vmx_controls).
      
      Re-factored setup_vmcs_config and adjust_vmx_controls.
      setup_vmcs_config does pretty much the same thing, but it
      fails immediately if a control isn't available --
      adjust_vmx_controls confirms that the exact desired
      controls are available, and sets the reserved bits to
      1 or 0 as needed. Cleaner comments and organization.
      Re-factored the vmx basic settings to
      vmcs_config_basic_settings.
      
      Removed some of the vmx feature check code that was in
      the original lcd_vmx_init, as setup_vmcs_config now does
      that.
      
      Essentially a straight copy over of:
      
      -- __vmx_enable
      -- vmx_enable
      -- vmx_disable
      -- vmx_free_vmxon_areas
      -- __vmxon
      -- __vmxoff
      
      The only difference is I shifted tbl and cache
      invalidation to vmx_enable (originally in __vmx_enable)
      and added some comments.
      
      Straight copy over of
      -- vmx_alloc_vmcs
      -- vmx_free_vmcs
      -- invvpid, invept code, with slight renaming
      18122896
    • Charlie Jacobsen's avatar
      Starting a fresh lcd-vmx arch-dependent interface. · 8a6ad472
      Charlie Jacobsen authored
      Arch-dependent code will go in arch/x86/lcd, and the
      header(s) will reside in arch/x86/include/asm.
      
      For now, I have only moved some of the arch-dependent
      junk that was in include/lcd/lcd.h into
      arch/x86/include/asm/lcd-vmx.h.
      8a6ad472