Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


profiler changes
Jack Lange [Fri, 30 Jan 2009 01:25:00 +0000 (19:25 -0600)]
nominal shadow paging optimization
Makefile documentation changes

build/Makefile
geekos/build/Makefile
geekos/src/geekos/vm.c
palacios/include/palacios/vmm_profiler.h
palacios/src/palacios/vmm_profiler.c
palacios/src/palacios/vmm_shadow_paging.c

index 27d9909..a217d7d 100644 (file)
@@ -1,4 +1,4 @@
-# Makefile for GeekOS kernel, userspace, and tools
+# Top level Makefile for V3Vee
 #
 #  Northwestern University 
 # (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
@@ -6,38 +6,17 @@
 # (c) 2008, Lei Xia <xiaxlei@gmail.com>
 # (c) 2008, The V3VEE Project <http://www.v3vee.org> 
 #
-# Based on GeekOS Makefile:
-# Copyright (c) 2004,2005 David H. Hovemeyer <daveho@cs.umd.edu>
-# $Revision: 1.71 $
-
-
-# This is free software.  You are permitted to use,
-# redistribute, and modify it as specified in the file "COPYING".
-
-# Required software to build GeekOS:
+# Required software to build V3Vee:
 # - GNU Make (http://www.gnu.org/software/make)
-# - gcc 2.95.2 generating code for target (i386/ELF) and host platforms
 # - nasm (http://nasm.sourceforge.net)
 # - Perl5, AWK (any version), egrep
 #
-# Cygwin (http://cygwin.com) may be used to build GeekOS.
-# Make sure that gcc, binutils, nasm, and perl are installed.
 
-# NOTES:
-# - This makefile has been written carefully to work correctly
-#   with the -j (parallel make) option.  I regularly use "make -j 2"
-#   to speed the build process on 2 processor systems.
 
 
 
 
-# ----------------------------------------------------------------------
-# Configuration -
-#   Various options specifying how GeekOS should be built,
-#   what source files to build, which user programs to build,
-#   etc.  This is generally the only section of the makefile
-#   that will need to be modified.
-# ----------------------------------------------------------------------
+
 PROJECT_ROOT := ..
 PALACIOS_BUILD_DIR := $(PROJECT_ROOT)/palacios/build
 GEEKOS_BUILD_DIR := $(PROJECT_ROOT)/geekos/build
@@ -177,6 +156,11 @@ endif
 endif
 
 
+ifeq ($(PROFILE_VMM),1)
+  GEEKOS_FLAGS:= $(GEEKOS_FLAGS) PROFILE_VMM=1
+endif
+
+
 # ----------------------------------------------------------------------
 # Targets -
 #   Specifies files to be built
@@ -208,14 +192,14 @@ geekos: palacios32
        cp $(PALACIOS_BUILD_DIR)/libv3vee.a $(GEEKOS_BUILD_DIR)/palacios/
        cp $(PALACIOS_BUILD_DIR)/../lib/xed/libxed.a $(GEEKOS_BUILD_DIR)/palacios/
        cp $(PALACIOS_BUILD_DIR)/vm_kernel $(GEEKOS_BUILD_DIR)/palacios/
-       (cd $(GEEKOS_BUILD_DIR) && make)
+       (cd $(GEEKOS_BUILD_DIR) && make $(GEEKOS_FLAGS))
 
 
 geekos-full: palacios-full32
        cp $(PALACIOS_BUILD_DIR)/libv3vee.a $(GEEKOS_BUILD_DIR)/palacios/
        cp $(PALACIOS_BUILD_DIR)/../lib/xed/libxed.a $(GEEKOS_BUILD_DIR)/palacios/
        cp $(PALACIOS_BUILD_DIR)/vm_kernel $(GEEKOS_BUILD_DIR)/palacios/
-       (cd $(GEEKOS_BUILD_DIR) && make clean && make)
+       (cd $(GEEKOS_BUILD_DIR) && make clean && make $(GEEKOS_FLAGS))
 
 
 world: geekos-full palacios-full64
index c62d482..352199c 100644 (file)
@@ -51,7 +51,6 @@ VPATH := $(PROJECT_ROOT)/src
 
 
 
-
 #
 #uIP, ON -- used, OFF -- not used
 #
@@ -79,6 +78,9 @@ LWIP=OFF
 #endif
 
 
+ifeq ($(PROFILE_VMM),1)
+  EXTRA_C_OPTS:= -DPROFILE_VMM
+endif
 
 
 # ----------------------------------------------------------------------
index 39144b0..da04444 100644 (file)
@@ -107,8 +107,12 @@ int RunVMM(struct Boot_Info * bootInfo) {
     
     region_start += rombios->length;
 
+#ifdef PROFILE_VMM
+    vm_config.enable_profiling = 1;
+#else
     vm_config.enable_profiling = 0;
-    
+#endif
+
     vm_config.vgabios = region_start;
     vm_config.vgabios_size = vgabios->length;
   }
index b083232..7861a7b 100644 (file)
@@ -33,6 +33,8 @@ struct v3_profiler {
   ullong_t start_time;
   ullong_t end_time;
 
+  uint_t guest_pf_cnt;
+
   struct rb_root root;
 };
 
index 02bac15..46a9e5e 100644 (file)
@@ -37,6 +37,7 @@ void v3_init_profiler(struct guest_info * info) {
 
   info->profiler.start_time = 0;
   info->profiler.end_time = 0;  
+  info->profiler.guest_pf_cnt = 0;
 
   info->profiler.root.rb_node = NULL;
 }
@@ -119,7 +120,11 @@ void v3_profile_exit(struct guest_info * info, uint_t exit_code) {
     insert_event(info, evt);
   }
 
-  evt->handler_time += time;
+  
+
+  evt->handler_time = (evt->handler_time * .99) + (time * .01);
+
+
   evt->exit_count++;
   
   info->profiler.total_exits++;
@@ -130,6 +135,8 @@ void v3_print_profile(struct guest_info * info) {
   struct exit_event * evt = NULL;
   struct rb_node * node = v3_rb_first(&(info->profiler.root));
   
+  PrintDebug("GUEST_PF: %u\n", info->profiler.guest_pf_cnt);
+
   do {
     evt = rb_entry(node, struct exit_event, tree_node);
     const char * code_str = vmexit_code_to_str(evt->exit_code);
index 9b89157..55920ed 100644 (file)
@@ -374,6 +374,10 @@ addr_t v3_create_new_shadow_pt() {
 
 
 static void inject_guest_pf(struct guest_info * info, addr_t fault_addr, pf_error_t error_code) {
+  if (info->enable_profiler) {
+    info->profiler.guest_pf_cnt++;
+  }
+
   info->ctrl_regs.cr2 = fault_addr;
   v3_raise_exception_with_error(info, PF_EXCEPTION, *(uint_t *)&error_code);
 }
@@ -533,7 +537,20 @@ static int handle_shadow_pagefault_32(struct guest_info * info, addr_t fault_add
       shadow_pde->pt_base_addr = PAGE_BASE_ADDR((addr_t)V3_PAddr(shadow_pt));
       
       if (guest_pde->large_page == 0) {
+       pte32_t * guest_pt = NULL;
        shadow_pde->writable = guest_pde->writable;
+
+       if (guest_pa_to_host_va(info, BASE_TO_PAGE_ADDR(guest_pde->pt_base_addr), (addr_t*)&guest_pt) == -1) {
+         // Machine check the guest
+         PrintDebug("Invalid Guest PTE Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(guest_pde->pt_base_addr));
+         v3_raise_exception(info, MC_EXCEPTION);
+         return 0;
+       }
+
+       if (handle_shadow_pte32_fault(info, fault_addr, error_code, shadow_pt, guest_pt)  == -1) {
+         PrintError("Error handling Page fault caused by PTE\n");
+         return -1;
+       }
       } else {
        // ??  What if guest pde is dirty a this point?
        ((pde32_4MB_t *)guest_pde)->dirty = 0;
@@ -549,6 +566,7 @@ static int handle_shadow_pagefault_32(struct guest_info * info, addr_t fault_add
 
       if (guest_pde->large_page == 0) {
        pte32_t * guest_pt = NULL;
+
        if (guest_pa_to_host_va(info, BASE_TO_PAGE_ADDR(guest_pde->pt_base_addr), (addr_t*)&guest_pt) == -1) {
          // Machine check the guest
          PrintDebug("Invalid Guest PTE Address: 0x%p\n", (void *)BASE_TO_PAGE_ADDR(guest_pde->pt_base_addr));