]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
makefiles: Build jailhouse-{amd,intel} together
authorValentine Sinitsyn <valentine.sinitsyn@gmail.com>
Tue, 23 Sep 2014 17:10:27 +0000 (23:10 +0600)
committerJan Kiszka <jan.kiszka@siemens.com>
Sat, 1 Nov 2014 08:09:09 +0000 (09:09 +0100)
This build system update brings an ability to build "jailhouse.bin"
firmware for different architecture "variants" (currently, AMD and
Intel on x86_64) simultaneously. Corresponding firmware files are
called 'jailhouse-$variant.bin'. Variants are introduced in
$(BUILD_VARIANTS) in hypervisor/Makefile and also in corresponding
arch Makefiles. Having per-variant compilation options inside one
architecture is not supported.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Makefile
hypervisor/Makefile
hypervisor/arch/x86/Makefile

index ec7deb212a69f8778eb28d5badc13c4d3423ed86..05b8265cd8c332d767566180e2e4c12efe8459f5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -29,8 +29,6 @@ kbuild = -C $(KDIR) M=$$PWD $@
 modules:
        $(Q)$(MAKE) $(kbuild)
 
-hypervisor/jailhouse.bin: modules
-
 # recursive build of tools
 tools:
        $(Q)$(MAKE) -C tools
@@ -51,8 +49,8 @@ clean:        docs_clean
 modules_install: modules
        $(Q)$(MAKE) $(kbuild)
 
-firmware_install: hypervisor/jailhouse.bin $(DESTDIR)$(firmwaredir)
-       $(INSTALL_DATA) $^
+firmware_install: $(DESTDIR)$(firmwaredir) modules
+       $(INSTALL_DATA) hypervisor/jailhouse*.bin $<
 
 install: modules_install firmware_install
        $(Q)$(MAKE) -C tools $@
index 5c8e7fbfbf82131979057aa6503d6c4af3482c8e..55f60859e2006a0432367bbbfbdb808a490a61de 100644 (file)
@@ -2,9 +2,11 @@
 # Jailhouse, a Linux-based partitioning hypervisor
 #
 # Copyright (c) Siemens AG, 2013
+# Copyright (c) Valentine Sinitsyn, 2014
 #
 # Authors:
 #  Jan Kiszka <jan.kiszka@siemens.com>
+#  Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
 #
 # This work is licensed under the terms of the GNU GPL, version 2.  See
 # the COPYING file in the top-level directory.
@@ -19,21 +21,13 @@ KBUILD_CFLAGS := -g -Os -Wall -Wstrict-prototypes -Wtype-limits \
 ifeq ($(SRCARCH),x86)
 KBUILD_CFLAGS += -mcmodel=kernel
 KBUILD_CPPFLAGS += -m64
+BUILD_VARIANTS := amd intel
 endif
 
 ifneq ($(wildcard $(obj)/include/jailhouse/config.h),)
 KBUILD_CFLAGS += -include $(obj)/include/jailhouse/config.h
 endif
 
-$(obj)/arch/$(SRCARCH)/built-in.o: FORCE
-       $(Q)$(MAKE) $(build)=$(obj)/arch/$(SRCARCH)
-
-always := jailhouse.bin
-
-hypervisor-y := setup.o printk.o paging.o control.o lib.o \
-       arch/$(SRCARCH)/built-in.o hypervisor.lds
-targets += $(hypervisor-y)
-
 define filechk_version
        $(src)/../scripts/gen_version_h $(src)/..
 endef
@@ -45,16 +39,42 @@ $(obj)/include/jailhouse/version.h: $(src)/Makefile FORCE
 
 $(obj)/setup.o: $(obj)/include/jailhouse/version.h
 
-HYPERVISOR_OBJS = $(addprefix $(obj)/,$(hypervisor-y))
+arch-builtin: FORCE
+       $(Q)$(MAKE) $(build)=$(obj)/arch/$(SRCARCH)
+
+always :=
+
+define BUILD_JAILHOUSE_template
+always += jailhouse$(1).bin
 
-LDFLAGS_hypervisor.o := -T
+hypervisor$(1)-y := setup.o printk.o paging.o control.o lib.o \
+       arch/$$(SRCARCH)/built-in$(1).o hypervisor.lds
+targets += $$(hypervisor$(1)-y)
 
-targets += hypervisor.o
-$(obj)/hypervisor.o: $(src)/hypervisor.lds $(HYPERVISOR_OBJS)
-       $(call if_changed,ld)
+# Need fake recipe here so make will consider this a volatile target
+$$(obj)/arch/$$(SRCARCH)/built-in$(1).o: arch-builtin
+       @
 
-OBJCOPYFLAGS_jailhouse.bin := -O binary -R .eh_frame
+HYPERVISOR$(1)_OBJS = $$(addprefix $$(obj)/,$$(hypervisor$(1)-y))
+
+LDFLAGS_hypervisor$(1).o := -T
+
+targets += hypervisor$(1).o
+$$(obj)/hypervisor$(1).o: $$(src)/hypervisor.lds $$(HYPERVISOR$(1)_OBJS)
+       $$(call if_changed,ld)
+
+OBJCOPYFLAGS_jailhouse$(1).bin := -O binary -R .eh_frame
+
+targets += jailhouse$(1).bin
+$$(obj)/jailhouse$(1).bin: $$(obj)/hypervisor$(1).o
+       $$(call if_changed,objcopy)
+endef
+
+ifneq ($(BUILD_VARIANTS),)
+$(foreach variant,$(BUILD_VARIANTS),\
+       $(eval $(call BUILD_JAILHOUSE_template,-$(variant))))
+else
+$(eval $(call BUILD_JAILHOUSE_template,))
+endif
 
-targets += jailhouse.bin
-$(obj)/jailhouse.bin: $(obj)/hypervisor.o
-       $(call if_changed,objcopy)
+.PHONY: arch-builtin
index 1749fd6951cc6c4403acd35ebfa0e00546bcfac8..67e1ab8f639a1c4c7abe2c71879f79e8cddccede 100644 (file)
@@ -2,15 +2,23 @@
 # Jailhouse, a Linux-based partitioning hypervisor
 #
 # Copyright (c) Siemens AG, 2013
+# Copyright (c) Valentine Sinitsyn, 2014
 #
 # Authors:
 #  Jan Kiszka <jan.kiszka@siemens.com>
+#  Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
 #
 # This work is licensed under the terms of the GNU GPL, version 2.  See
 # the COPYING file in the top-level directory.
 #
 
-always := built-in.o
+BUILT_IN_OBJECTS := built-in-amd.o built-in-intel.o
+COMMON_OBJECTS := apic.o dbg-write.o entry.o setup.o control.o mmio.o \
+                 paging.o ../../pci.o pci.o ioapic.o i8042.o vcpu.o
 
-obj-y := apic.o dbg-write.o entry.o setup.o vmx.o control.o mmio.o \
-        vtd.o paging.o ../../pci.o pci.o ioapic.o i8042.o vmx-vmexit.o vcpu.o
+always := $(BUILT_IN_OBJECTS)
+
+obj-y := $(BUILT_IN_OBJECTS)
+
+built-in-amd-y := $(COMMON_OBJECTS) svm.o amd_iommu.o svm-vmexit.o
+built-in-intel-y := $(COMMON_OBJECTS) vmx.o vtd.o vmx-vmexit.o