From 7632c450ceb906abd596e0bea51e043cc2ce2a1e Mon Sep 17 00:00:00 2001 From: Xiantao Zhang Date: Wed, 2 Jul 2008 17:04:19 +0800 Subject: [PATCH] kvm: external module: Allow non-x86 archs to build in userspace This patch targets for allowing kvm/ia64 to build in userspace. For other archs. it just needs to add its arch-specific stuff. Signed-off-by: Xiantao Zhang Signed-off-by: Avi Kivity --- kvm/kernel/Kbuild | 1 + kvm/kernel/Makefile | 22 ++++++++++++++-------- kvm/kernel/ia64/Kbuild | 7 +++++++ kvm/kernel/ia64/Makefile.pre | 23 +++++++++++++++++++++++ kvm/kernel/ia64/external-module-compat.h | 15 +++++++++++++++ kvm/kernel/x86/Makefile.pre | 1 + 6 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 kvm/kernel/ia64/Kbuild create mode 100644 kvm/kernel/ia64/Makefile.pre create mode 100644 kvm/kernel/ia64/external-module-compat.h create mode 100644 kvm/kernel/x86/Makefile.pre diff --git a/kvm/kernel/Kbuild b/kvm/kernel/Kbuild index 7019ca00e8..ec34c43e7f 100644 --- a/kvm/kernel/Kbuild +++ b/kvm/kernel/Kbuild @@ -1 +1,2 @@ obj-$(CONFIG_X86) += x86/ +obj-$(CONFIG_IA64) += ia64/ diff --git a/kvm/kernel/Makefile b/kvm/kernel/Makefile index 94d63bc4fa..0d5d148896 100644 --- a/kvm/kernel/Makefile +++ b/kvm/kernel/Makefile @@ -7,6 +7,8 @@ KVERREL = $(patsubst /lib/modules/%/build,%,$(KERNELDIR)) DESTDIR= +MAKEFILE_PRE = $(ARCH_DIR)/Makefile.pre + INSTALLDIR = $(patsubst %/build,%/extra,$(KERNELDIR)) ORIGMODDIR = $(patsubst %/build,%/kernel,$(KERNELDIR)) @@ -27,10 +29,11 @@ unifdef = mv $1 $1.orig && \ hack = $(call _hack,$T/$(strip $1)) hack-files-x86 = kvm_main.c mmu.c vmx.c svm.c x86.c irq.h lapic.c i8254.c +hack-files-ia64 = hack-files = $(hack-files-$(ARCH_DIR)) -all:: +all:: header-link # include header priority 1) $LINUX 2) $KERNELDIR 3) include-compat $(MAKE) -C $(KERNELDIR) M=`pwd` \ LINUXINCLUDE="-I`pwd`/include -Iinclude -I`pwd`/include-compat \ @@ -38,7 +41,12 @@ all:: -include `pwd`/$(ARCH_DIR)/external-module-compat.h" "$$@" -sync: header-sync source-sync +sync: header-sync source-sync header-link prerequisite + +header-link: + rm -f include/asm + ln -sf asm-$(ARCH_DIR) include/asm + ln -sf asm-$(ARCH_DIR) include-compat/asm T = $(subst -sync,,$@)-tmp @@ -56,15 +64,11 @@ header-sync: do mkdir -p $$(dirname $$i); cmp -s $$i $T/$$i || cp $T/$$i $$i; done rm -rf $T - rm -f include/asm - ln -sf asm-$(ARCH_DIR) include/asm - ln -sf asm-$(ARCH_DIR) include-compat/asm - source-sync: rm -rf $T rsync --exclude='*.mod.c' -R \ - "$(LINUX)"/arch/$(ARCH_DIR)/kvm/./*.[ch] \ - "$(LINUX)"/virt/kvm/./*.[ch] \ + "$(LINUX)"/arch/$(ARCH_DIR)/kvm/./*.[cSh] \ + "$(LINUX)"/virt/kvm/./*.[cSh] \ $T/ set -e && for i in $(find $T -name '*.c'); do \ @@ -77,6 +81,8 @@ source-sync: do cmp -s $(ARCH_DIR)/$$i $T/$$i || cp $T/$$i $(ARCH_DIR)/$$i; done rm -rf $T +include $(MAKEFILE_PRE) + install: mkdir -p $(DESTDIR)/$(INSTALLDIR) cp $(ARCH_DIR)/*.ko $(DESTDIR)/$(INSTALLDIR) diff --git a/kvm/kernel/ia64/Kbuild b/kvm/kernel/ia64/Kbuild new file mode 100644 index 0000000000..764a493544 --- /dev/null +++ b/kvm/kernel/ia64/Kbuild @@ -0,0 +1,7 @@ +obj-m := kvm.o kvm-intel.o + +kvm-objs := kvm_main.o ioapic.o coalesced_mmio.o kvm-ia64.o kvm_fw.o + +EXTRA_CFLAGS_vcpu.o += -mfixed-range=f2-f5,f12-f127 +kvm-intel-objs := vmm.o vmm_ivt.o trampoline.o vcpu.o optvfault.o mmio.o \ + vtlb.o process.o memset.o memcpy.o diff --git a/kvm/kernel/ia64/Makefile.pre b/kvm/kernel/ia64/Makefile.pre new file mode 100644 index 0000000000..484fe80e59 --- /dev/null +++ b/kvm/kernel/ia64/Makefile.pre @@ -0,0 +1,23 @@ +prerequisite: asm-offsets.h ia64/memset.S ia64/memcpy.S + cp -f $(LINUX)/arch/ia64/lib/memcpy.S ia64/memcpy.S + cp -f $(LINUX)/arch/ia64/lib/memset.S ia64/memset.S + cmp -s asm-offset.h ia64/asm-offset.h || mv -f asm-offsets.* ia64/ + +asm-offsets.h: asm-offsets.s + @(set -e; \ + echo "/*"; \ + echo " * DO NOT MODIFY."; \ + echo " *"; \ + echo " * This file was auto-generated from $<"; \ + echo " *"; \ + echo " */"; \ + echo ""; \ + echo "#ifndef __KVM_ASM_OFFSETS_H__"; \ + echo "#define __KVM_ASM_OFFSETS_H__"; \ + echo ""; \ + sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \ + echo ""; \ + echo "#endif") <$< >$@ + +asm-offsets.s: ia64/asm-offsets.c + gcc -S -D__KERNEL__ -I$(LINUX)/include -I./include ia64/asm-offsets.c diff --git a/kvm/kernel/ia64/external-module-compat.h b/kvm/kernel/ia64/external-module-compat.h new file mode 100644 index 0000000000..3c4001c1ce --- /dev/null +++ b/kvm/kernel/ia64/external-module-compat.h @@ -0,0 +1,15 @@ +/* + * Compatibility header for building as an external module. + */ + +#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) +#error "KVM/IA-64 Can't be compiled if kernel version < 2.6.26" +#endif + +#ifndef CONFIG_PREEMPT_NOTIFIERS +/*Now, Just print an error message if no preempt notifiers configured!! + TODO: Implement it later! */ +#error "KVM/IA-64 depends on preempt notifiers in kernel." +#endif diff --git a/kvm/kernel/x86/Makefile.pre b/kvm/kernel/x86/Makefile.pre new file mode 100644 index 0000000000..e38baf1347 --- /dev/null +++ b/kvm/kernel/x86/Makefile.pre @@ -0,0 +1 @@ +prerequisite: -- 2.11.4.GIT