>From d02ea89423a206e5a11b1bae01fee505580b0225 Mon Sep 17 00:00:00 2001 From: Xiantao Zhang <xiantao.zhang@xxxxxxxxx> 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 <xiantao.zhang@xxxxxxxxx> --- kernel/Kbuild | 1 + kernel/Makefile | 22 ++++++++++++++-------- kernel/ia64/Kbuild | 7 +++++++ kernel/ia64/Makefile.pre | 23 +++++++++++++++++++++++ kernel/ia64/external-module-compat.h | 15 +++++++++++++++ kernel/x86/Makefile.pre | 1 + 6 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 kernel/ia64/Kbuild create mode 100644 kernel/ia64/Makefile.pre create mode 100644 kernel/ia64/external-module-compat.h create mode 100644 kernel/x86/Makefile.pre diff --git a/kernel/Kbuild b/kernel/Kbuild index 7019ca0..ec34c43 100644 --- a/kernel/Kbuild +++ b/kernel/Kbuild @@ -1 +1,2 @@ obj-$(CONFIG_X86) += x86/ +obj-$(CONFIG_IA64) += ia64/ diff --git a/kernel/Makefile b/kernel/Makefile index 94d63bc..0d5d148 100644 --- a/kernel/Makefile +++ b/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/kernel/ia64/Kbuild b/kernel/ia64/Kbuild new file mode 100644 index 0000000..764a493 --- /dev/null +++ b/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/kernel/ia64/Makefile.pre b/kernel/ia64/Makefile.pre new file mode 100644 index 0000000..09f2a73 --- /dev/null +++ b/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/kernel/ia64/external-module-compat.h b/kernel/ia64/external-module-compat.h new file mode 100644 index 0000000..3c4001c --- /dev/null +++ b/kernel/ia64/external-module-compat.h @@ -0,0 +1,15 @@ +/* + * Compatibility header for building as an external module. + */ + +#include <linux/version.h> + +#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/kernel/x86/Makefile.pre b/kernel/x86/Makefile.pre new file mode 100644 index 0000000..e38baf1 --- /dev/null +++ b/kernel/x86/Makefile.pre @@ -0,0 +1 @@ +prerequisite: -- 1.5.6.2
Attachment:
0003-KVM-external-module-Allow-non-x86-archs-to-build-i.patch
Description: 0003-KVM-external-module-Allow-non-x86-archs-to-build-i.patch