From: Jack Lange Date: Tue, 15 Apr 2008 21:34:03 +0000 (+0000) Subject: moved over the a real linked list implementation X-Git-Tag: working-cdboot-physical-but-not-qemu~17 X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=df58bd3c484a52b1e166dc28e7b9b6fd94e5a023 moved over the a real linked list implementation --- diff --git a/palacios/build/Makefile b/palacios/build/Makefile index 95b2af2..41e5652 100644 --- a/palacios/build/Makefile +++ b/palacios/build/Makefile @@ -1,6 +1,6 @@ # Makefile for GeekOS kernel, userspace, and tools # Copyright (c) 2004,2005 David H. Hovemeyer -# $Revision: 1.25 $ +# $Revision: 1.26 $ # This is free software. You are permitted to use, # redistribute, and modify it as specified in the file "COPYING". @@ -124,7 +124,7 @@ VMM_ASM_OBJS := $(VMM_ASM_SRCS:%.asm=palacios/%.o) VMM_C_SRCS := vm_guest.c \ svm.c svm_handler.c vmm.c vmm_util.c svm_ctrl_regs.c \ vmcb.c vmm_mem.c vmm_paging.c vmm_io.c vmm_debug.c svm_io.c \ - vmm_intr.c \ + vmm_intr.c vmm_irq.c\ vmm_shadow_paging.c vm_guest_mem.c \ vm_dev.c vmm_dev_mgr.c \ #\ @@ -134,7 +134,7 @@ VMM_C_OBJS := $(VMM_C_SRCS:%.c=palacios/%.o) VMM_OBJS := $(VMM_C_OBJS) $(VMM_ASM_OBJS) -DEVICE_C_SRCS := nvram.c +DEVICE_C_SRCS := nvram.c timer.c DEVICE_C_OBJS := $(DEVICE_C_SRCS:%.c=devices/%.o) diff --git a/palacios/build/depend.mak b/palacios/build/depend.mak index accf30e..d938c10 100644 --- a/palacios/build/depend.mak +++ b/palacios/build/depend.mak @@ -272,12 +272,13 @@ geekos/vm.o: ../src/geekos/vm.c ../include/geekos/vmm_stubs.h \ ../include/palacios/vm_guest.h ../include/palacios/vmm_io.h \ ../include/palacios/vmm_util.h ../include/palacios/vmm_shadow_paging.h \ ../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \ - ../include/palacios/vmm_dev_mgr.h \ - ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h \ - ../include/geekos/debug.h ../include/geekos/serial.h \ - ../include/geekos/irq.h ../include/geekos/int.h \ - ../include/geekos/string.h ../include/geekos/../libc/string.h \ - ../include/geekos/io.h ../include/geekos/vm.h + ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h \ + ../include/palacios/vmm_irq.h ../include/geekos/debug.h \ + ../include/geekos/serial.h ../include/geekos/irq.h \ + ../include/geekos/int.h ../include/geekos/string.h \ + ../include/geekos/../libc/string.h ../include/geekos/io.h \ + ../include/geekos/vm.h ../include/devices/nvram.h \ + ../include/palacios/vm_dev.h geekos/main.o: ../src/geekos/main.c ../include/geekos/bootinfo.h \ ../include/geekos/string.h ../include/geekos/../libc/string.h \ /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h \ @@ -315,10 +316,10 @@ palacios/vm_guest.o: ../src/palacios/vm_guest.c ../include/palacios/vm_guest.h \ ../include/palacios/vmm_io.h ../include/palacios/vmm_util.h \ ../include/palacios/vmm_shadow_paging.h \ ../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \ - ../include/palacios/vmm_dev_mgr.h \ - ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h \ + ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h \ ../include/palacios/vmm_string.h \ - /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h + /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h \ + ../include/palacios/vmm_irq.h palacios/svm.o: ../src/palacios/svm.c ../include/palacios/svm.h \ ../include/palacios/vmm_util.h ../include/palacios/vmm_types.h \ ../include/geekos/ktypes.h \ @@ -328,10 +329,10 @@ palacios/svm.o: ../src/palacios/svm.c ../include/palacios/svm.h \ ../include/palacios/vmm_mem.h ../include/palacios/vm_guest.h \ ../include/palacios/vmm_io.h ../include/palacios/vmm_shadow_paging.h \ ../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \ - ../include/palacios/vmm_dev_mgr.h \ - ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h \ - ../include/palacios/vmcb.h ../include/palacios/svm_handler.h \ - ../include/palacios/vmm_debug.h ../include/palacios/vm_guest_mem.h + ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h \ + ../include/palacios/vmm_irq.h ../include/palacios/vmcb.h \ + ../include/palacios/svm_handler.h ../include/palacios/vmm_debug.h \ + ../include/palacios/vm_guest_mem.h palacios/svm_handler.o: ../src/palacios/svm_handler.c \ ../include/palacios/svm_handler.h ../include/palacios/svm.h \ ../include/palacios/vmm_util.h ../include/palacios/vmm_types.h \ @@ -342,11 +343,10 @@ palacios/svm_handler.o: ../src/palacios/svm_handler.c \ ../include/palacios/vmm_mem.h ../include/palacios/vm_guest.h \ ../include/palacios/vmm_io.h ../include/palacios/vmm_shadow_paging.h \ ../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \ - ../include/palacios/vmm_dev_mgr.h \ - ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h \ - ../include/palacios/vmcb.h ../include/palacios/vm_guest_mem.h \ - ../include/palacios/vmm_emulate.h ../include/palacios/svm_ctrl_regs.h \ - ../include/palacios/svm_io.h + ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h \ + ../include/palacios/vmm_irq.h ../include/palacios/vmcb.h \ + ../include/palacios/vm_guest_mem.h ../include/palacios/vmm_emulate.h \ + ../include/palacios/svm_ctrl_regs.h ../include/palacios/svm_io.h palacios/vmm.o: ../src/palacios/vmm.c ../include/palacios/vmm.h \ ../include/palacios/vmm_string.h \ /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h \ @@ -356,11 +356,10 @@ palacios/vmm.o: ../src/palacios/vmm.c ../include/palacios/vmm.h \ ../include/palacios/vm_guest.h ../include/palacios/vmm_io.h \ ../include/palacios/vmm_util.h ../include/palacios/vmm_shadow_paging.h \ ../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \ - ../include/palacios/vmm_dev_mgr.h \ - ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h \ - ../include/palacios/svm.h ../include/palacios/vmcb.h \ - ../include/palacios/vmx.h ../include/palacios/vmcs.h \ - ../include/palacios/vmcs_gen.h + ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h \ + ../include/palacios/vmm_irq.h ../include/palacios/svm.h \ + ../include/palacios/vmcb.h ../include/palacios/vmx.h \ + ../include/palacios/vmcs.h ../include/palacios/vmcs_gen.h palacios/vmm_util.o: ../src/palacios/vmm_util.c ../include/palacios/vmm_util.h \ ../include/palacios/vmm_types.h ../include/geekos/ktypes.h \ /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stdbool.h \ @@ -369,8 +368,8 @@ palacios/vmm_util.o: ../src/palacios/vmm_util.c ../include/palacios/vmm_util.h \ ../include/palacios/vmm_mem.h ../include/palacios/vm_guest.h \ ../include/palacios/vmm_io.h ../include/palacios/vmm_shadow_paging.h \ ../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \ - ../include/palacios/vmm_dev_mgr.h \ - ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h + ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h \ + ../include/palacios/vmm_irq.h palacios/svm_ctrl_regs.o: ../src/palacios/svm_ctrl_regs.c \ ../include/palacios/svm_ctrl_regs.h ../include/palacios/vm_guest.h \ ../include/palacios/vmm_mem.h ../include/palacios/vmm_types.h \ @@ -379,13 +378,12 @@ palacios/svm_ctrl_regs.o: ../src/palacios/svm_ctrl_regs.c \ ../include/palacios/vmm_io.h ../include/palacios/vmm_util.h \ ../include/palacios/vmm_shadow_paging.h \ ../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \ - ../include/palacios/vmm_dev_mgr.h \ - ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h \ + ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h \ ../include/palacios/vmm_string.h \ /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h \ - ../include/palacios/vmm.h ../include/palacios/vmcb.h \ - ../include/palacios/vmm_emulate.h ../include/palacios/vm_guest_mem.h \ - ../include/palacios/vmm_ctrl_regs.h + ../include/palacios/vmm_irq.h ../include/palacios/vmm.h \ + ../include/palacios/vmcb.h ../include/palacios/vmm_emulate.h \ + ../include/palacios/vm_guest_mem.h ../include/palacios/vmm_ctrl_regs.h palacios/vmcb.o: ../src/palacios/vmcb.c ../include/palacios/vmcb.h \ ../include/palacios/vmm_types.h ../include/geekos/ktypes.h \ /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stdbool.h \ @@ -395,8 +393,8 @@ palacios/vmcb.o: ../src/palacios/vmcb.c ../include/palacios/vmcb.h \ ../include/palacios/vmm_io.h ../include/palacios/vmm_util.h \ ../include/palacios/vmm_shadow_paging.h \ ../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \ - ../include/palacios/vmm_dev_mgr.h \ - ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h + ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h \ + ../include/palacios/vmm_irq.h palacios/vmm_mem.o: ../src/palacios/vmm_mem.c ../include/palacios/vmm_mem.h \ ../include/palacios/vmm_types.h ../include/geekos/ktypes.h \ /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stdbool.h \ @@ -405,8 +403,8 @@ palacios/vmm_mem.o: ../src/palacios/vmm_mem.c ../include/palacios/vmm_mem.h \ ../include/palacios/vm_guest.h ../include/palacios/vmm_io.h \ ../include/palacios/vmm_util.h ../include/palacios/vmm_shadow_paging.h \ ../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \ - ../include/palacios/vmm_dev_mgr.h \ - ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h + ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h \ + ../include/palacios/vmm_irq.h palacios/vmm_paging.o: ../src/palacios/vmm_paging.c \ ../include/palacios/vmm_paging.h ../include/palacios/vmm_types.h \ ../include/geekos/ktypes.h \ @@ -416,9 +414,8 @@ palacios/vmm_paging.o: ../src/palacios/vmm_paging.c \ /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h \ ../include/palacios/vm_guest.h ../include/palacios/vmm_io.h \ ../include/palacios/vmm_shadow_paging.h ../include/palacios/vmm_intr.h \ - ../include/palacios/vmm_dev_mgr.h \ - ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h \ - ../include/palacios/vm_guest_mem.h + ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h \ + ../include/palacios/vmm_irq.h ../include/palacios/vm_guest_mem.h palacios/vmm_io.o: ../src/palacios/vmm_io.c ../include/palacios/vmm_io.h \ ../include/palacios/vmm_types.h ../include/geekos/ktypes.h \ /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stdbool.h \ @@ -427,8 +424,8 @@ palacios/vmm_io.o: ../src/palacios/vmm_io.c ../include/palacios/vmm_io.h \ ../include/palacios/vmm.h ../include/palacios/vmm_mem.h \ ../include/palacios/vm_guest.h ../include/palacios/vmm_shadow_paging.h \ ../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \ - ../include/palacios/vmm_dev_mgr.h \ - ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h + ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h \ + ../include/palacios/vmm_irq.h palacios/vmm_debug.o: ../src/palacios/vmm_debug.c ../include/palacios/vmm_debug.h \ ../include/palacios/vmm.h ../include/palacios/vmm_string.h \ /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h \ @@ -438,8 +435,8 @@ palacios/vmm_debug.o: ../src/palacios/vmm_debug.c ../include/palacios/vmm_debug. ../include/palacios/vm_guest.h ../include/palacios/vmm_io.h \ ../include/palacios/vmm_util.h ../include/palacios/vmm_shadow_paging.h \ ../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \ - ../include/palacios/vmm_dev_mgr.h \ - ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h + ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h \ + ../include/palacios/vmm_irq.h palacios/svm_io.o: ../src/palacios/svm_io.c ../include/palacios/svm_io.h \ ../include/palacios/vm_guest.h ../include/palacios/vmm_mem.h \ ../include/palacios/vmm_types.h ../include/geekos/ktypes.h \ @@ -447,13 +444,12 @@ palacios/svm_io.o: ../src/palacios/svm_io.c ../include/palacios/svm_io.h \ ../include/palacios/vmm_io.h ../include/palacios/vmm_util.h \ ../include/palacios/vmm_shadow_paging.h \ ../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \ - ../include/palacios/vmm_dev_mgr.h \ - ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h \ + ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h \ ../include/palacios/vmm_string.h \ /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h \ - ../include/palacios/vmcb.h ../include/palacios/vmm.h \ - ../include/palacios/vmm_ctrl_regs.h ../include/palacios/vmm_emulate.h \ - ../include/palacios/vm_guest_mem.h + ../include/palacios/vmm_irq.h ../include/palacios/vmcb.h \ + ../include/palacios/vmm.h ../include/palacios/vmm_ctrl_regs.h \ + ../include/palacios/vmm_emulate.h ../include/palacios/vm_guest_mem.h palacios/vmm_intr.o: ../src/palacios/vmm_intr.c ../include/palacios/vmm_intr.h \ ../include/palacios/vmm_types.h ../include/geekos/ktypes.h \ /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stdbool.h \ @@ -461,9 +457,19 @@ palacios/vmm_intr.o: ../src/palacios/vmm_intr.c ../include/palacios/vmm_intr.h \ ../include/palacios/vmm_io.h ../include/palacios/vmm_util.h \ ../include/palacios/vmm_shadow_paging.h \ ../include/palacios/vmm_paging.h ../include/palacios/vmm_dev_mgr.h \ - ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h \ - ../include/palacios/vmm_string.h \ - /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h + ../include/palacios/vmm_list.h ../include/palacios/vmm_string.h \ + /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h \ + ../include/palacios/vmm_irq.h +palacios/vmm_irq.o: ../src/palacios/vmm_irq.c ../include/palacios/vmm_irq.h \ + ../include/palacios/vmm_types.h ../include/geekos/ktypes.h \ + /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stdbool.h \ + ../include/palacios/vmm.h ../include/palacios/vmm_string.h \ + /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h \ + ../include/palacios/vmm_mem.h ../include/palacios/vm_guest.h \ + ../include/palacios/vmm_io.h ../include/palacios/vmm_util.h \ + ../include/palacios/vmm_shadow_paging.h \ + ../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \ + ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h palacios/vmm_shadow_paging.o: ../src/palacios/vmm_shadow_paging.c \ ../include/palacios/vmm_shadow_paging.h ../include/palacios/vmm_util.h \ ../include/palacios/vmm_types.h ../include/geekos/ktypes.h \ @@ -473,7 +479,7 @@ palacios/vmm_shadow_paging.o: ../src/palacios/vmm_shadow_paging.c \ /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h \ ../include/palacios/vm_guest.h ../include/palacios/vmm_io.h \ ../include/palacios/vmm_intr.h ../include/palacios/vmm_dev_mgr.h \ - ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h \ + ../include/palacios/vmm_list.h ../include/palacios/vmm_irq.h \ ../include/palacios/vm_guest_mem.h palacios/vm_guest_mem.o: ../src/palacios/vm_guest_mem.c \ ../include/palacios/vm_guest_mem.h ../include/palacios/vm_guest.h \ @@ -483,8 +489,40 @@ palacios/vm_guest_mem.o: ../src/palacios/vm_guest_mem.c \ ../include/palacios/vmm_io.h ../include/palacios/vmm_util.h \ ../include/palacios/vmm_shadow_paging.h \ ../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \ - ../include/palacios/vmm_dev_mgr.h \ - ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h \ + ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h \ ../include/palacios/vmm_string.h \ /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h \ - ../include/palacios/vmm.h + ../include/palacios/vmm_irq.h ../include/palacios/vmm.h +palacios/vm_dev.o: ../src/palacios/vm_dev.c ../include/palacios/vm_dev.h \ + ../include/palacios/vmm_types.h ../include/geekos/ktypes.h \ + /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stdbool.h \ + ../include/palacios/vmm_list.h ../include/palacios/vmm_string.h \ + /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h \ + ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm.h \ + ../include/palacios/vmm_mem.h ../include/palacios/vm_guest.h \ + ../include/palacios/vmm_io.h ../include/palacios/vmm_util.h \ + ../include/palacios/vmm_shadow_paging.h \ + ../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \ + ../include/palacios/vmm_irq.h +palacios/vmm_dev_mgr.o: ../src/palacios/vmm_dev_mgr.c ../include/palacios/vm_dev.h \ + ../include/palacios/vmm_types.h ../include/geekos/ktypes.h \ + /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stdbool.h \ + ../include/palacios/vmm_list.h ../include/palacios/vmm_string.h \ + /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h \ + ../include/palacios/vmm_dev_mgr.h ../include/palacios/vm_guest.h \ + ../include/palacios/vmm_mem.h ../include/palacios/vmm_io.h \ + ../include/palacios/vmm_util.h ../include/palacios/vmm_shadow_paging.h \ + ../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \ + ../include/palacios/vmm_irq.h ../include/palacios/vmm.h +devices/nvram.o: ../src/devices/nvram.c ../include/devices/nvram.h \ + ../include/palacios/vm_dev.h ../include/palacios/vmm_types.h \ + ../include/geekos/ktypes.h \ + /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stdbool.h \ + ../include/palacios/vmm_list.h ../include/palacios/vmm_string.h \ + /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h \ + ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm.h \ + ../include/palacios/vmm_mem.h ../include/palacios/vm_guest.h \ + ../include/palacios/vmm_io.h ../include/palacios/vmm_util.h \ + ../include/palacios/vmm_shadow_paging.h \ + ../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \ + ../include/palacios/vmm_irq.h diff --git a/palacios/include/devices/nvram.h b/palacios/include/devices/nvram.h index 3bf96d5..3936fe0 100644 --- a/palacios/include/devices/nvram.h +++ b/palacios/include/devices/nvram.h @@ -5,6 +5,6 @@ -struct vm_device * nvram_create(); +struct vm_device *create_nvram(); #endif diff --git a/palacios/include/palacios/svm_handler.h b/palacios/include/palacios/svm_handler.h index 376b52f..1557ad0 100644 --- a/palacios/include/palacios/svm_handler.h +++ b/palacios/include/palacios/svm_handler.h @@ -174,6 +174,8 @@ int handle_shadow_paging(struct guest_info * info); +int handle_svm_intr(struct guest_info * info); + int handle_svm_exit(struct guest_info * info); #endif diff --git a/palacios/include/palacios/vm_dev.h b/palacios/include/palacios/vm_dev.h index 192a2b5..72914b4 100644 --- a/palacios/include/palacios/vm_dev.h +++ b/palacios/include/palacios/vm_dev.h @@ -37,11 +37,16 @@ struct vm_device { struct guest_info * vm; - struct vm_device *next, *prev; + struct list_head dev_link; - struct dev_io_hook_list io_hooks; - struct dev_mem_hook_list mem_hooks; + uint_t num_io_hooks; + struct list_head io_hooks; + uint_t num_mem_hooks; + struct list_head mem_hooks; + uint_t num_irq_hooks; + struct list_head irq_hooks; + }; @@ -69,7 +74,10 @@ int dev_unhook_mem(struct vm_device * dev, void * end); - +int dev_hook_irq(struct vm_device * dev, + uint_t irq, + int (*handler)(uint_t irq, struct vm_device * dev)); +int dev_unhook_irq(struct vm_device * dev, uint_t irq); #endif diff --git a/palacios/include/palacios/vm_guest.h b/palacios/include/palacios/vm_guest.h index d271972..8e8c6a5 100644 --- a/palacios/include/palacios/vm_guest.h +++ b/palacios/include/palacios/vm_guest.h @@ -7,6 +7,7 @@ #include #include #include +#include typedef ullong_t gpr_t; @@ -55,6 +56,8 @@ struct guest_info { // This structure is how we get interrupts for the guest struct vm_intr intr_state; + + struct vmm_irq_map irq_map; vmm_io_map_t io_map; // device_map diff --git a/palacios/include/palacios/vmm_dev_mgr.h b/palacios/include/palacios/vmm_dev_mgr.h index 6ea56df..0caef8b 100644 --- a/palacios/include/palacios/vmm_dev_mgr.h +++ b/palacios/include/palacios/vmm_dev_mgr.h @@ -2,37 +2,25 @@ #define _VMM_DEV_MGR #include -#include #include #include - struct vm_device; struct guest_info; -struct vm_dev_list { - struct vm_device * head; - uint_t num_devs; -}; - - -struct dev_io_hook_list { - struct dev_io_hook * head; - uint_t num_hooks; -}; - - -struct dev_mem_hook_list { - struct dev_mem_hook * head; - uint_t num_hooks; -}; +struct vmm_dev_mgr { + uint_t num_devs; + struct list_head dev_list; + uint_t num_io_hooks; + struct list_head io_hooks; + + uint_t num_mem_hooks; + struct list_head mem_hooks; -struct vmm_dev_mgr { - struct vm_dev_list dev_list; - struct dev_io_hook_list io_hooks; - struct dev_mem_hook_list mem_hooks; + uint_t num_irq_hooks; + struct list_head irq_hooks; }; @@ -46,20 +34,35 @@ struct dev_io_hook { struct vm_device * dev; // Do not touch anything below this - struct dev_io_hook *dev_next, *dev_prev; - struct dev_io_hook *mgr_next, *mgr_prev; + /* + struct dev_io_hook *dev_next, *dev_prev; + struct dev_io_hook *mgr_next, *mgr_prev; + */ + struct list_head dev_list; + struct list_head mgr_list; }; struct dev_mem_hook { - void *addr_start; - void *addr_end; + void *addr_start; + void *addr_end; + + struct vm_device * dev; // Do not touch anything below this - struct dev_mem_hook *dev_next, *dev_prev; - struct dev_mem_hook *mgr_next, *mgr_prev; + struct list_head dev_list; + struct list_head mgr_list; }; +struct dev_irq_hook { + uint_t irq; + int (*handler)(uint_t irq, struct vm_device * dev); + + struct vm_device * dev; + + struct list_head dev_list; + struct list_head mgr_list; +}; // Registration of devices @@ -81,6 +84,15 @@ int dev_mgr_add_device(struct vmm_dev_mgr * mgr, struct vm_device * dev); int dev_mgr_remove_device(struct vmm_dev_mgr * mgr, struct vm_device * dev); +/* + int dev_mgr_add_io_hook(struct vmm_dev_mgr * mgr, struct dev_io_hook * hook); + int dev_mgr_remove_io_hook(struct vmm_dev_mgr * mgr, struct dev_io_hook * hook); + int dev_add_io_hook(struct vmm_dev_mgr * mgr, struct dev_io_hook * hook); + int dev_remove_io_hook(struct vmm_dev_mgr * mgr, struct dev_io_hook * hook); + struct dev_io_hook * dev_find_io_hook(struct vm_device * dev, ushort_t port); + struct dev_io_hook * dev_mgr_find_io_hook(struct vmm_dev_mgr * mgr, ushort_t port) +*/ + void PrintDebugDevMgr(struct vmm_dev_mgr * mgr); void PrintDebugDev(struct vm_device * dev); void PrintDebugDevIO(struct vm_device * dev); diff --git a/palacios/include/palacios/vmm_device_types.h b/palacios/include/palacios/vmm_device_types.h deleted file mode 100644 index 0d41133..0000000 --- a/palacios/include/palacios/vmm_device_types.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _vmm_device_types -#define _vmm_device_types - - - -enum vmm_device_type { - VMM_DEVICE_PIC, - VMM_DEVICE_APIC, - VMM_DEVICE_NVRAM -}; - -#endif diff --git a/palacios/include/palacios/vmm_intr.h b/palacios/include/palacios/vmm_intr.h index 209a7a1..108c27c 100644 --- a/palacios/include/palacios/vmm_intr.h +++ b/palacios/include/palacios/vmm_intr.h @@ -1,6 +1,7 @@ -#ifndef __VMM_INTR_H -#define __VMM_INTR_H +#ifndef __VMM_INTR_H_ +#define __VMM_INTR_H_ +#include #include #define DE_EXCEPTION 0x00 @@ -46,5 +47,4 @@ int intr_pending(struct vm_intr * intr); uint_t get_intr_number(struct vm_intr * intr); intr_types_t get_intr_type(struct vm_intr * intr); - #endif diff --git a/palacios/include/palacios/vmm_list.h b/palacios/include/palacios/vmm_list.h index 9fcf799..da7a0b2 100644 --- a/palacios/include/palacios/vmm_list.h +++ b/palacios/include/palacios/vmm_list.h @@ -6,6 +6,12 @@ #undef offsetof #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) + +#define container_of(ptr, type, member) ({ \ + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) + + static inline void prefetch(const void *x) {;} /* diff --git a/palacios/src/devices/nvram.c b/palacios/src/devices/nvram.c index e811ec2..52ae710 100644 --- a/palacios/src/devices/nvram.c +++ b/palacios/src/devices/nvram.c @@ -159,7 +159,7 @@ static struct vm_device_ops dev_ops = { -struct vm_device *nvram_create() { +struct vm_device *create_nvram() { struct nvram_internal * nvram_state = os_hooks->malloc(sizeof(struct nvram_internal)); struct vm_device *device = create_device("NVRAM", &dev_ops, nvram_state); diff --git a/palacios/src/geekos/vm.c b/palacios/src/geekos/vm.c index a8ef613..b0e2b3f 100644 --- a/palacios/src/geekos/vm.c +++ b/palacios/src/geekos/vm.c @@ -6,6 +6,7 @@ #include #include #include +#include #define SPEAKER_PORT 0x61 @@ -184,9 +185,11 @@ int RunVMM(struct Boot_Info * bootInfo) { vm_info.cpu_mode = REAL; + init_irq_map(&(vm_info.irq_map)); init_vmm_io_map(&(vm_info.io_map)); init_interrupt_state(&(vm_info.intr_state)); + dev_mgr_init(&(vm_info.dev_mgr)); if (0) { @@ -287,12 +290,19 @@ int RunVMM(struct Boot_Info * bootInfo) { hook_io_port(&(vm_info.io_map), 0x403, &IO_Read, &IO_Write_to_Serial, NULL); { - struct vm_device * nvram = nvram_create(); + struct vm_device * nvram = create_nvram(); + struct vm_device * timer = create_timer(); + attach_device(&(vm_info), nvram); + //attach_device(&(vm_info), timer); PrintDebugDevMgr(&(vm_info.dev_mgr)); + + } + PrintDebug("foo\n"); + vm_info.rip = 0xfff0; vm_info.vm_regs.rsp = 0x0; @@ -305,5 +315,4 @@ int RunVMM(struct Boot_Info * bootInfo) { (vmm_ops).start_guest(&vm_info); return 0; - } diff --git a/palacios/src/palacios/svm.c b/palacios/src/palacios/svm.c index 296559f..4a16070 100644 --- a/palacios/src/palacios/svm.c +++ b/palacios/src/palacios/svm.c @@ -383,8 +383,12 @@ void Init_VMCB_BIOS(vmcb_t * vmcb, struct guest_info vm_info) { ctrl_area->instrs.IOIO_PROT = 1; } - //ctrl_area->instrs.instrs.INTR = 1; + if (vm_info.irq_map.num_hooks > 0) { + PrintDebug("Exiting on interrupts\n"); + ctrl_area->guest_ctrl.V_INTR_MASKING = 1; + ctrl_area->instrs.INTR = 1; + } if (vm_info.page_mode == SHADOW_PAGING) { diff --git a/palacios/src/palacios/svm_handler.c b/palacios/src/palacios/svm_handler.c index f7e39de..c7ee14c 100644 --- a/palacios/src/palacios/svm_handler.c +++ b/palacios/src/palacios/svm_handler.c @@ -60,6 +60,9 @@ int handle_svm_exit(struct guest_info * info) { (info->page_mode == SHADOW_PAGING)) { handle_shadow_paging(info); */ + + } else if (exit_code == VMEXIT_INTR) { + handle_svm_intr(info); } else { addr_t rip_addr = get_addr_linear(info, guest_state->rip, guest_state->cs.selector); char buf[15]; @@ -160,3 +163,29 @@ int handle_shadow_paging(struct guest_info * info) { +int handle_svm_intr(struct guest_info * info) { + vmcb_ctrl_t * guest_ctrl = GET_VMCB_CTRL_AREA((vmcb_t*)(info->vmm_data)); + // vmcb_saved_state_t * guest_state = GET_VMCB_SAVE_STATE_AREA((vmcb_t*)(info->vmm_data)); + + //struct Interrupt_Info * int_info = &(guest_ctrl->exit_int_info); + + //struct vmm_irq_hook * get_irq_hook(&(info->irq_map), int_info->vector); + + PrintDebug("SVM Returned: Exit Code: %x\n",guest_ctrl->exit_code); + PrintDebug("V_INTR_VECTOR: 0x%x\n", guest_ctrl->guest_ctrl.V_INTR_VECTOR); + + + + + while(1); + + + + + + + + + + return 0; +} diff --git a/palacios/src/palacios/vm_dev.c b/palacios/src/palacios/vm_dev.c index 1f2a725..753bfcd 100644 --- a/palacios/src/palacios/vm_dev.c +++ b/palacios/src/palacios/vm_dev.c @@ -13,12 +13,16 @@ struct vm_device * allocate_device() { dev->vm = NULL; dev->private_data = NULL; - dev->next = NULL; - dev->prev = NULL; - dev->io_hooks.head = NULL; - dev->mem_hooks.head = NULL; - dev->io_hooks.num_hooks = 0; - dev->mem_hooks.num_hooks = 0; + + INIT_LIST_HEAD(&(dev->io_hooks)); + dev->num_io_hooks = 0; + + INIT_LIST_HEAD(&(dev->mem_hooks)); + dev->num_mem_hooks = 0; + + INIT_LIST_HEAD(&(dev->irq_hooks)); + dev->num_irq_hooks = 0; + return dev; } @@ -35,3 +39,4 @@ struct vm_device * create_device(char * name, struct vm_device_ops * ops, void * void free_device(struct vm_device * dev) { VMMFree(dev); } + diff --git a/palacios/src/palacios/vmm_dev_mgr.c b/palacios/src/palacios/vmm_dev_mgr.c index 615c8ec..8652209 100644 --- a/palacios/src/palacios/vmm_dev_mgr.c +++ b/palacios/src/palacios/vmm_dev_mgr.c @@ -2,7 +2,7 @@ #include #include #include - +#include extern struct vmm_os_hooks *os_hooks; @@ -11,21 +11,24 @@ extern struct vmm_os_hooks *os_hooks; #endif int dev_mgr_init(struct vmm_dev_mgr * mgr) { - mgr->dev_list.head = NULL; - mgr->dev_list.num_devs = 0; + + INIT_LIST_HEAD(&(mgr->dev_list)); + mgr->num_devs = 0; + + INIT_LIST_HEAD(&(mgr->io_hooks)); + mgr->num_io_hooks = 0; return 0; } -int dev_mgr_deinit(struct vmm_dev_mgr * mgr) -{ - struct vm_device * dev = mgr->dev_list.head; +int dev_mgr_deinit(struct vmm_dev_mgr * mgr) { + struct vm_device * dev; - while (dev) { + list_for_each_entry(dev, &(mgr->dev_list), dev_link) { unattach_device(dev); free_device(dev); - dev = dev->next; } + return 0; } @@ -33,144 +36,77 @@ int dev_mgr_deinit(struct vmm_dev_mgr * mgr) int dev_mgr_add_device(struct vmm_dev_mgr * mgr, struct vm_device * dev) { - dev->next = mgr->dev_list.head; - dev->prev = 0; - if (dev->next) { - dev->next->prev = dev; - } - mgr->dev_list.head = dev; - - mgr->dev_list.num_devs++; + list_add(&(dev->dev_link), &(mgr->dev_list)); + mgr->num_devs++; return 0; } int dev_mgr_remove_device(struct vmm_dev_mgr * mgr, struct vm_device * dev) { - if (mgr->dev_list.head == dev) { - mgr->dev_list.head = dev->next; - } else { - dev->prev->next = dev->next; - } - if (dev->next) { - dev->next->prev = dev->prev; - } - - mgr->dev_list.num_devs--; + list_del(&(dev->dev_link)); + mgr->num_devs--; return 0; } -int dev_mgr_add_io_hook(struct vmm_dev_mgr * mgr, struct dev_io_hook * hook) { - hook->mgr_next = mgr->io_hooks.head; - hook->mgr_prev = NULL; - if (hook->mgr_next) { - hook->mgr_next->mgr_prev = hook; - } - mgr->io_hooks.head = hook; - - mgr->io_hooks.num_hooks++; +/* IO HOOKS */ +int dev_mgr_add_io_hook(struct vmm_dev_mgr * mgr, struct dev_io_hook * hook) { + list_add(&(hook->mgr_list), &(mgr->io_hooks)); + mgr->num_io_hooks++; return 0; } int dev_mgr_remove_io_hook(struct vmm_dev_mgr * mgr, struct dev_io_hook * hook) { - if (mgr->io_hooks.head == hook) { - mgr->io_hooks.head = hook->mgr_next; - } else { - hook->mgr_prev->mgr_next = hook->mgr_next; - } - - if (hook->mgr_next) { - hook->mgr_next->mgr_prev = hook->mgr_prev; - } - - mgr->io_hooks.num_hooks--; + list_del(&(hook->mgr_list)); + mgr->num_io_hooks--; return 0; } int dev_add_io_hook(struct vm_device * dev, struct dev_io_hook * hook) { - hook->dev_next = dev->io_hooks.head; - hook->dev_prev = NULL; - if (hook->dev_next) { - hook->dev_next->dev_prev = hook; - } - dev->io_hooks.head = hook; - - dev->io_hooks.num_hooks++; - + list_add(&(hook->dev_list), &(dev->io_hooks)); + dev->num_io_hooks++; return 0; } int dev_remove_io_hook(struct vm_device * dev, struct dev_io_hook * hook) { - if (dev->io_hooks.head == hook) { - dev->io_hooks.head = hook->dev_next; - } else { - hook->dev_prev->dev_next = hook->dev_next; - } - - if (hook->dev_next) { - hook->dev_next->dev_prev = hook->dev_prev; - } - - dev->io_hooks.num_hooks--; + list_del(&(hook->dev_list)); + dev->num_io_hooks--; return 0; } + + + struct dev_io_hook * dev_mgr_find_io_hook(struct vmm_dev_mgr * mgr, ushort_t port) { - struct dev_io_hook * tmp = mgr->io_hooks.head; + struct dev_io_hook * tmp; - while (tmp) { + list_for_each_entry(tmp, &(mgr->io_hooks), mgr_list) { if (tmp->port == port) { - break; + return tmp; } - tmp = tmp->mgr_next; } - - return tmp; + return NULL; } struct dev_io_hook * dev_find_io_hook(struct vm_device * dev, ushort_t port) { - struct dev_io_hook * tmp = dev->io_hooks.head; + struct dev_io_hook * tmp; - while (tmp) { + list_for_each_entry(tmp, &(dev->io_hooks), dev_list) { if (tmp->port == port) { - break; + return tmp; } - tmp = tmp->dev_next; } - - return tmp; -} - - - - -int attach_device(struct guest_info * vm, struct vm_device * dev) { - struct vmm_dev_mgr *mgr= &(vm->dev_mgr); - - dev->vm = vm; - dev_mgr_add_device(mgr, dev); - dev->ops->init(dev); - - return 0; + return NULL; } -int unattach_device(struct vm_device * dev) { - struct vmm_dev_mgr * mgr = &(dev->vm->dev_mgr); - - dev->ops->deinit(dev); - dev_mgr_remove_device(mgr, dev); - dev->vm = NULL; - - return 0; -} @@ -224,13 +160,151 @@ int dev_unhook_io(struct vm_device *dev, + +/* IRQ HOOKS */ + +int dev_mgr_add_irq_hook(struct vmm_dev_mgr * mgr, struct dev_irq_hook * hook) { + list_add(&(hook->mgr_list), &(mgr->irq_hooks)); + mgr->num_irq_hooks++; + return 0; +} + + +int dev_mgr_remove_irq_hook(struct vmm_dev_mgr * mgr, struct dev_irq_hook * hook) { + list_del(&(hook->mgr_list)); + mgr->num_irq_hooks--; + + return 0; +} + + +int dev_add_irq_hook(struct vm_device * dev, struct dev_irq_hook * hook) { + list_add(&(hook->dev_list), &(dev->irq_hooks)); + dev->num_irq_hooks++; + return 0; +} + + +int dev_remove_irq_hook(struct vm_device * dev, struct dev_irq_hook * hook) { + list_del(&(hook->dev_list)); + dev->num_irq_hooks--; + + return 0; +} + + + + + +struct dev_irq_hook * dev_mgr_find_irq_hook(struct vmm_dev_mgr * mgr, uint_t irq) { + struct dev_irq_hook * tmp; + + list_for_each_entry(tmp, &(mgr->irq_hooks), mgr_list) { + if (tmp->irq == irq) { + return tmp; + } + } + return NULL; +} + +struct dev_irq_hook * dev_find_irq_hook(struct vm_device * dev, uint_t irq) { + struct dev_irq_hook * tmp; + + list_for_each_entry(tmp, &(dev->irq_hooks), dev_list) { + if (tmp->irq == irq) { + return tmp; + } + } + return NULL; +} + + + + +int dev_hook_irq(struct vm_device *dev, + uint_t irq, + int (*handler)(uint_t irq, struct vm_device * dev)) { + + struct dev_irq_hook *hook = os_hooks->malloc(sizeof(struct dev_irq_hook)); + + if (!hook) { + return -1; + } + + + if (hook_irq(&(dev->vm->irq_map), irq, + (int (*)(uint_t, void *))handler, + (void *)dev) == 0) { + + hook->dev = dev; + hook->irq = irq; + hook->handler = handler; + + dev_mgr_add_irq_hook(&(dev->vm->dev_mgr), hook); + dev_add_irq_hook(dev, hook); + } else { + return -1; + } + + return 0; +} + + +int dev_unhook_irq(struct vm_device * dev, + uint_t irq) { + + struct vmm_dev_mgr * mgr = &(dev->vm->dev_mgr); + struct dev_irq_hook * hook = dev_mgr_find_irq_hook(mgr, irq); + + if (!hook) { + return -1; + } + + dev_mgr_remove_irq_hook(mgr, hook); + dev_remove_irq_hook(dev, hook); + + return unhook_irq(&(dev->vm->irq_map), irq); +} + + + + + + + + +int attach_device(struct guest_info * vm, struct vm_device * dev) { + struct vmm_dev_mgr *mgr= &(vm->dev_mgr); + + dev->vm = vm; + dev_mgr_add_device(mgr, dev); + dev->ops->init(dev); + + return 0; +} + +int unattach_device(struct vm_device * dev) { + struct vmm_dev_mgr * mgr = &(dev->vm->dev_mgr); + + dev->ops->deinit(dev); + dev_mgr_remove_device(mgr, dev); + dev->vm = NULL; + + return 0; +} + + + + + int dev_mgr_hook_mem(struct guest_info *vm, struct vm_device *device, void *start, void *end) { - struct dev_mem_hook *hook = os_hooks->malloc(sizeof(struct dev_mem_hook)); + struct dev_mem_hook *hook; + VMMMalloc(struct dev_mem_hook *, hook,sizeof(struct dev_mem_hook)); if (!hook) { return -1; @@ -260,24 +334,18 @@ int dev_mgr_hook_mem(struct guest_info *vm, } -int dev_mgr_unhook_mem(struct guest_info *vm, - struct vm_device *device, - void *start, - void *end) -{ - struct dev_mem_hook *hook = device->mem_hooks.head; - - while (hook) { - if (((hook->addr_start) == start) && (hook->addr_end == end)) { - break; - } - } - +int dev_mgr_unhook_mem(struct vm_device *dev, + addr_t start, + addr_t end) { + /* + struct vmm_dev_mgr * mgr = &(dev->vm->dev_mgr); + struct dev_mem_hook *hook = dev_mgr_find_mem_hook(mgr, start, end); + if (!hook) { // Very bad - unhooking something that doesn't exist! return -1; } - + */ /* not implemented yet return unhook_mem_port(vm->mem_map, @@ -292,11 +360,12 @@ int dev_mgr_unhook_mem(struct guest_info *vm, void PrintDebugDevMgr(struct vmm_dev_mgr * mgr) { - struct vm_device * dev = mgr->dev_list.head; + struct vm_device * dev; + PrintDebug("%d devices registered with manager\n", mgr->num_devs); - while (dev) { + list_for_each_entry(dev, &(mgr->dev_list), dev_link) { PrintDebugDev(dev); - dev = dev->next; + PrintDebug("next..\n"); } return; @@ -314,13 +383,12 @@ void PrintDebugDevMgrIO(struct vmm_dev_mgr * mgr) { } void PrintDebugDevIO(struct vm_device * dev) { - struct dev_io_hook * hook = dev->io_hooks.head; - - PrintDebug("IO Hooks (%d) for Device: %s\n", dev->io_hooks.num_hooks, dev->name); - - while (hook) { + struct dev_io_hook * hook; + + PrintDebug("IO Hooks(%d) for Device: %s\n", dev->num_io_hooks, dev->name); + + list_for_each_entry(hook, &(dev->io_hooks), dev_list) { PrintDebug("\tPort: 0x%x (read=0x%x), (write=0x%x)\n", hook->port, hook->read, hook->write); - hook = hook->dev_next; } return; diff --git a/palacios/src/palacios/vmm_intr.c b/palacios/src/palacios/vmm_intr.c index a326f37..657ddef 100644 --- a/palacios/src/palacios/vmm_intr.c +++ b/palacios/src/palacios/vmm_intr.c @@ -1,4 +1,6 @@ #include + + #include