[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCH v2 4/9] plat/kvm: create separate linker script for QEMU and Firecracker



From: Florian Schmidt <florian.schmidt@xxxxxxxxx>

The linker scripts are very similar, but we need two of them to support
building both QEMU and Firecracker in one build run.

Change-Id: If968ae8c7d25fda506da2e7c27857bd7f79a5c4b
Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
Signed-off-by: Florian Schmidt <florian.schmidt@xxxxxxxxx>
Signed-off-by: Haibo Xu <haibo.xu@xxxxxxx>
---
 plat/kvm/Linker.uk    | 64 -----------------------------------------
 plat/kvm/Linker_fc.uk | 66 +++++++++++++++++++++++++++++++++++++++++++
 plat/kvm/Linker_q.uk  | 66 +++++++++++++++++++++++++++++++++++++++++++
 plat/kvm/Makefile.uk  | 48 +++++++++++++++++++++++++------
 4 files changed, 172 insertions(+), 72 deletions(-)
 delete mode 100644 plat/kvm/Linker.uk
 create mode 100644 plat/kvm/Linker_fc.uk
 create mode 100644 plat/kvm/Linker_q.uk

diff --git a/plat/kvm/Linker.uk b/plat/kvm/Linker.uk
deleted file mode 100644
index 62c3d81..0000000
--- a/plat/kvm/Linker.uk
+++ /dev/null
@@ -1,64 +0,0 @@
-ifeq (x86_64,$(CONFIG_UK_ARCH))
-KVM_LDFLAGS-y += -Wl,-m,elf_x86_64
-else ifeq (arm64,$(CONFIG_UK_ARCH))
-KVM_LDFLAGS-y   += -Wl,-m,aarch64elf
-endif
-
-
-##
-## Link image
-##
-KVM_IMAGE := $(BUILD_DIR)/$(CONFIG_UK_NAME)_kvm-$(CONFIG_UK_ARCH)
-KVM_DEBUG_IMAGE := $(KVM_IMAGE).dbg
-
-KVM_LD_SCRIPT_FLAGS := $(addprefix -Wl$(comma)-dT$(comma),\
-                        $(UK_PLAT_KVM_DEF_LDS))
-KVM_LD_SCRIPT_FLAGS += $(addprefix -Wl$(comma)-T$(comma),\
-                       $(KVM_LD_SCRIPT-y) $(EXTRA_LD_SCRIPT-y))
-
-$(KVM_DEBUG_IMAGE): $(KVM_ALIBS) $(KVM_ALIBS-y) $(KVM_OLIBS) $(KVM_OLIBS-y) \
-                   $(UK_ALIBS) $(UK_ALIBS-y) $(UK_OLIBS) $(UK_OLIBS-y)
-       $(call build_cmd,LD,,$(KVM_IMAGE).ld.o,\
-              $(LD) -r $(LIBLDFLAGS) $(LIBLDFLAGS-y) \
-                       $(KVM_LDFLAGS) $(KVM_LDFLAGS-y) \
-                       $(KVM_OLIBS) $(KVM_OLIBS-y) \
-                       $(UK_OLIBS) $(UK_OLIBS-y) \
-                       -Wl$(comma)--start-group \
-                       $(KVM_ALIBS) $(KVM_ALIBS-y) \
-                       $(UK_ALIBS) $(UK_ALIBS-y) \
-                       -Wl$(comma)--end-group \
-                       -o $(KVM_IMAGE).ld.o)
-       $(call build_cmd,OBJCOPY,,$(KVM_IMAGE).o,\
-               $(OBJCOPY) -w -G kvmos_* -G _libkvmplat_entry \
-                       -G _libkvmplat_start64 $(KVM_IMAGE).ld.o $(KVM_IMAGE).o)
-       $(call build_cmd,LD,,$@,\
-              $(LD) $(LDFLAGS) $(LDFLAGS-y) \
-                    $(KVM_LDFLAGS) $(KVM_LDFLAGS-y) \
-                    $(KVM_LD_SCRIPT_FLAGS) \
-                    $(KVM_IMAGE).o -o $@)
-
-$(KVM_IMAGE): $(KVM_IMAGE).dbg
-       $(call build_cmd,SCSTRIP,,$@,\
-               $(SCRIPTS_DIR)/sect-strip.py \
-                       $(SECT_STRIP_FLAGS) $(SECT_STRIP_FLAGS-y) \
-                       --with-objcopy=$(OBJCOPY) \
-                       $< -o $@ && \
-               $(STRIP) -s $@)
-
-$(KVM_IMAGE).sym: $(KVM_DEBUG_IMAGE)
-       $(call build_cmd,NM,,$@, $(NM) -n $< > $@)
-
-$(KVM_IMAGE).gz: $(KVM_IMAGE)
-       $(call build_cmd,GZ,,$@, $(GZIP) -f -9 -c $< >$@)
-
-# register images to the build
-ifeq ($(CONFIG_PLAT_KVM),y)
-UK_DEBUG_IMAGES-y                     += $(KVM_DEBUG_IMAGE)
-UK_IMAGES-y                           += $(KVM_IMAGE)
-UK_IMAGES-$(CONFIG_OPTIMIZE_SYMFILE)  += $(KVM_IMAGE).sym
-UK_IMAGES-$(CONFIG_OPTIMIZE_COMPRESS) += $(KVM_IMAGE).gz
-endif
-
-# ...for cleaning:
-LIBKVMPLAT_CLEAN += $(call build_clean,$(KVM_IMAGE).o)
-LIBKVMPLAT_CLEAN += $(call build_clean,$(KVM_IMAGE).ld.o)
diff --git a/plat/kvm/Linker_fc.uk b/plat/kvm/Linker_fc.uk
new file mode 100644
index 0000000..1fc9b1d
--- /dev/null
+++ b/plat/kvm/Linker_fc.uk
@@ -0,0 +1,66 @@
+ifeq (x86_64,$(CONFIG_UK_ARCH))
+KVMFC_LDFLAGS-y += -Wl,-m,elf_x86_64
+else ifeq (arm64,$(CONFIG_UK_ARCH))
+KVMFC_LDFLAGS-y         += -Wl,-m,aarch64elf
+endif
+
+##
+## Link image
+##
+KVMFC_IMAGE := $(BUILD_DIR)/$(CONFIG_UK_NAME)_kvmfc-$(CONFIG_UK_ARCH)
+KVMFC_DEBUG_IMAGE := $(KVMFC_IMAGE).dbg
+
+KVMFC_LD_SCRIPT_FLAGS := $(addprefix -Wl$(comma)-dT$(comma),\
+                        $(UK_PLAT_KVM_DEF_LDS))
+KVMFC_LD_SCRIPT_FLAGS += $(addprefix -Wl$(comma)-T$(comma),\
+                       $(KVMFC_LD_SCRIPT-y) $(EXTRA_LD_SCRIPT-y))
+
+$(KVMFC_DEBUG_IMAGE): $(KVM_ALIBS) $(KVM_ALIBS-y) $(KVM_OLIBS) $(KVM_OLIBS-y) \
+                     $(KVMFC_ALIBS) $(KVMFC_ALIBS-y) $(KVMFC_OLIBS) 
$(KVMFC_OLIBS-y) \
+                     $(UK_ALIBS) $(UK_ALIBS-y) $(UK_OLIBS) $(UK_OLIBS-y)
+       $(call build_cmd,LD,,$(KVMFC_IMAGE).ld.o,\
+              $(LD) -r $(LIBLDFLAGS) $(LIBLDFLAGS-y) \
+                       $(KVMFC_LDFLAGS) $(KVMFC_LDFLAGS-y) \
+                       $(KVM_OLIBS) $(KVM_OLIBS-y) \
+                       $(KVMFC_OLIBS) $(KVMFC_OLIBS-y) \
+                       $(UK_OLIBS) $(UK_OLIBS-y) \
+                       -Wl$(comma)--start-group \
+                       $(KVM_ALIBS) $(KVM_ALIBS-y) \
+                       $(KVMFC_ALIBS) $(KVMFC_ALIBS-y) \
+                       $(UK_ALIBS) $(UK_ALIBS-y) \
+                       -Wl$(comma)--end-group \
+                       -o $(KVMFC_IMAGE).ld.o)
+       $(call build_cmd,OBJCOPY,,$(KVMFC_IMAGE).o,\
+               $(OBJCOPY) -w -G kvmos_* -G _libkvmplat_entry \
+                       -G _libkvmplat_start64 $(KVMFC_IMAGE).ld.o 
$(KVMFC_IMAGE).o)
+       $(call build_cmd,LD,,$@,\
+              $(LD) $(LDFLAGS) $(LDFLAGS-y) \
+                    $(KVMFC_LDFLAGS) $(KVMFC_LDFLAGS-y) \
+                    $(KVMFC_LD_SCRIPT_FLAGS) \
+                    $(KVMFC_IMAGE).o -o $@)
+
+$(KVMFC_IMAGE): $(KVMFC_IMAGE).dbg
+       $(call build_cmd,SCSTRIP,,$@,\
+               $(SCRIPTS_DIR)/sect-strip.py \
+                       $(SECT_STRIP_FLAGS) $(SECT_STRIP_FLAGS-y) \
+                       --with-objcopy=$(OBJCOPY) \
+                       $< -o $@ && \
+               $(STRIP) -s $@)
+
+$(KVMFC_IMAGE).sym: $(KVMFC_DEBUG_IMAGE)
+       $(call build_cmd,NM,,$@, $(NM) -n $< > $@)
+
+$(KVMFC_IMAGE).gz: $(KVMFC_IMAGE)
+       $(call build_cmd,GZ,,$@, $(GZIP) -f -9 -c $< >$@)
+
+# register images to the build
+ifeq ($(CONFIG_KVM_VMM_FIRECRACKER),y)
+UK_DEBUG_IMAGES-y                     += $(KVMFC_DEBUG_IMAGE)
+UK_IMAGES-y                           += $(KVMFC_IMAGE)
+UK_IMAGES-$(CONFIG_OPTIMIZE_SYMFILE)  += $(KVMFC_IMAGE).sym
+UK_IMAGES-$(CONFIG_OPTIMIZE_COMPRESS) += $(KVMFC_IMAGE).gz
+endif
+
+# ...for cleaning:
+LIBKVMQPLAT_CLEAN += $(call build_clean,$(KVMFC_IMAGE).o)
+LIBKVMQPLAT_CLEAN += $(call build_clean,$(KVMFC_IMAGE).ld.o)
diff --git a/plat/kvm/Linker_q.uk b/plat/kvm/Linker_q.uk
new file mode 100644
index 0000000..18ab2da
--- /dev/null
+++ b/plat/kvm/Linker_q.uk
@@ -0,0 +1,66 @@
+ifeq (x86_64,$(CONFIG_UK_ARCH))
+KVMQ_LDFLAGS-y += -Wl,-m,elf_x86_64
+else ifeq (arm64,$(CONFIG_UK_ARCH))
+KVMQ_LDFLAGS-y  += -Wl,-m,aarch64elf
+endif
+
+##
+## Link image
+##
+KVMQ_IMAGE := $(BUILD_DIR)/$(CONFIG_UK_NAME)_kvmq-$(CONFIG_UK_ARCH)
+KVMQ_DEBUG_IMAGE := $(KVMQ_IMAGE).dbg
+
+KVMQ_LD_SCRIPT_FLAGS := $(addprefix -Wl$(comma)-dT$(comma),\
+                        $(UK_PLAT_KVM_DEF_LDS))
+KVMQ_LD_SCRIPT_FLAGS += $(addprefix -Wl$(comma)-T$(comma),\
+                       $(KVMQ_LD_SCRIPT-y) $(EXTRA_LD_SCRIPT-y))
+
+$(KVMQ_DEBUG_IMAGE): $(KVM_ALIBS) $(KVM_ALIBS-y) $(KVM_OLIBS) $(KVM_OLIBS-y) \
+                     $(KVMQ_ALIBS) $(KVMQ_ALIBS-y) $(KVMQ_OLIBS) 
$(KVMQ_OLIBS-y) \
+                     $(UK_ALIBS) $(UK_ALIBS-y) $(UK_OLIBS) $(UK_OLIBS-y)
+       $(call build_cmd,LD,,$(KVMQ_IMAGE).ld.o,\
+              $(LD) -r $(LIBLDFLAGS) $(LIBLDFLAGS-y) \
+                       $(KVMQ_LDFLAGS) $(KVMQ_LDFLAGS-y) \
+                       $(KVM_OLIBS) $(KVM_OLIBS-y) \
+                       $(KVMQ_OLIBS) $(KVMQ_OLIBS-y) \
+                       $(UK_OLIBS) $(UK_OLIBS-y) \
+                       -Wl$(comma)--start-group \
+                       $(KVM_ALIBS) $(KVM_ALIBS-y) \
+                       $(KVMQ_ALIBS) $(KVMQ_ALIBS-y) \
+                       $(UK_ALIBS) $(UK_ALIBS-y) \
+                       -Wl$(comma)--end-group \
+                       -o $(KVMQ_IMAGE).ld.o)
+       $(call build_cmd,OBJCOPY,,$(KVMQ_IMAGE).o,\
+               $(OBJCOPY) -w -G kvmos_* -G _libkvmplat_entry \
+                       -G _libkvmplat_start64 $(KVMQ_IMAGE).ld.o 
$(KVMQ_IMAGE).o)
+       $(call build_cmd,LD,,$@,\
+              $(LD) $(LDFLAGS) $(LDFLAGS-y) \
+                    $(KVMQ_LDFLAGS) $(KVMQ_LDFLAGS-y) \
+                    $(KVMQ_LD_SCRIPT_FLAGS) \
+                    $(KVMQ_IMAGE).o -o $@)
+
+$(KVMQ_IMAGE): $(KVMQ_IMAGE).dbg
+       $(call build_cmd,SCSTRIP,,$@,\
+               $(SCRIPTS_DIR)/sect-strip.py \
+                       $(SECT_STRIP_FLAGS) $(SECT_STRIP_FLAGS-y) \
+                       --with-objcopy=$(OBJCOPY) \
+                       $< -o $@ && \
+               $(STRIP) -s $@)
+
+$(KVMQ_IMAGE).sym: $(KVMQ_DEBUG_IMAGE)
+       $(call build_cmd,NM,,$@, $(NM) -n $< > $@)
+
+$(KVMQ_IMAGE).gz: $(KVMQ_IMAGE)
+       $(call build_cmd,GZ,,$@, $(GZIP) -f -9 -c $< >$@)
+
+# register images to the build
+ifeq ($(CONFIG_KVM_VMM_QEMU),y)
+UK_DEBUG_IMAGES-y                     += $(KVMQ_DEBUG_IMAGE)
+UK_IMAGES-y                           += $(KVMQ_IMAGE)
+UK_IMAGES-$(CONFIG_OPTIMIZE_SYMFILE)  += $(KVMQ_IMAGE).sym
+UK_IMAGES-$(CONFIG_OPTIMIZE_COMPRESS) += $(KVMQ_IMAGE).gz
+endif
+
+# ...for cleaning:
+LIBKVMQPLAT_CLEAN += $(call build_clean,$(KVMQ_IMAGE).o)
+LIBKVMQPLAT_CLEAN += $(call build_clean,$(KVMQ_IMAGE).ld.o)
diff --git a/plat/kvm/Makefile.uk b/plat/kvm/Makefile.uk
index 68bcfd9..e862cab 100644
--- a/plat/kvm/Makefile.uk
+++ b/plat/kvm/Makefile.uk
@@ -1,18 +1,33 @@
 ##
 ## KVM platform registration
 ##
-$(eval $(call addplat_s,kvm,$(CONFIG_PLAT_KVM)))
+$(eval $(call addplat_s,kvmq,$(CONFIG_KVM_VMM_QEMU)))
+UK_PLAT_KVMQ_LINKER := $(UK_PLAT_KVMQ_BASE)/Linker_q.uk
+$(eval $(call addplat_s,kvmfc,$(CONFIG_KVM_VMM_FIRECRACKER)))
+UK_PLAT_KVMFC_LINKER := $(UK_PLAT_KVMFC_BASE)/Linker_fc.uk
+
+##
+## Populate LIBKVMPLAT_BASE for common files
+##
+ifeq ($(CONFIG_KVM_VMM_QEMU),y)
+LIBKVMPLAT_BASE := $(UK_PLAT_KVMQ_BASE)
+else ifeq ($(CONFIG_KVM_VMM_FIRECRACKER),y)
+LIBKVMPLAT_BASE := $(UK_PLAT_KVMFC_BASE)
+endif
 
 ##
 ## KVM platform library registration
 ##
-$(eval $(call addplatlib,kvm,libkvmplat))
-$(eval $(call addplatlib_s,kvm,libkvmpci,$(CONFIG_KVM_PCI)))
-$(eval $(call addplatlib_s,kvm,libkvmvirtio,$(CONFIG_VIRTIO_BUS)))
-$(eval $(call addplatlib_s,kvm,libkvmvirtionet,$(CONFIG_VIRTIO_NET)))
-$(eval $(call addplatlib_s,kvm,libkvmvirtio9p,$(CONFIG_VIRTIO_9P)))
-$(eval $(call addplatlib_s,kvm,libkvmofw,$(CONFIG_LIBOFW)))
-$(eval $(call addplatlib_s,kvm,libkvmgicv2,$(CONFIG_LIBGICV2)))
+$(eval $(call addplatlib,kvmq,libkvmqplat,$(CONFIG_KVM_VMM_QEMU)))
+$(eval $(call addplatlib,kvmfc,libkvmfcplat,$(CONFIG_KVM_VMM_FIRECRACKER)))
+$(eval $(call addplatlib_s,kvmq,libkvmpci,$(CONFIG_KVM_PCI)))
+$(eval $(call addplatlib_s,kvmq,libkvmvirtio,$(CONFIG_VIRTIO_BUS)))
+$(eval $(call addplatlib_s,kvmq,libkvmvirtionet,$(CONFIG_VIRTIO_NET)))
+$(eval $(call addplatlib_s,kvmq,libkvmvirtio9p,$(CONFIG_VIRTIO_9P)))
+$(eval $(call addplatlib_s,kvmq,libkvmofw,$(CONFIG_LIBOFW)))
+$(eval $(call addplatlib_s,kvmq,libkvmgicv2,$(CONFIG_LIBGICV2)))
+$(eval $(call addplatlib_s,kvmfc,libkvmvirtio,$(CONFIG_VIRTIO_BUS)))
+$(eval $(call addplatlib_s,kvmfc,libkvmvirtionet,$(CONFIG_VIRTIO_NET)))
 
 ##
 ## Platform library definitions
@@ -94,6 +109,23 @@ LIBKVMPLAT_SRCS-y              += 
$(UK_PLAT_COMMON_BASE)/lcpu.c|common
 LIBKVMPLAT_SRCS-y              += $(UK_PLAT_COMMON_BASE)/memory.c|common
 LIBKVMPLAT_SRCS-y              += $(UK_PLAT_KVM_DEF_LDS)
 
+ifeq ($(CONFIG_KVM_VMM_QEMU),y)
+LIBKVMQPLAT_SRCS-y        := $(LIBKVMPLAT_SRCS-y)
+LIBKVMQPLAT_ASINCLUDES-y  := $(LIBKVMPLAT_ASINCLUDES-y)
+LIBKVMQPLAT_CINCLUDES-y   := $(LIBKVMPLAT_CINCLUDES-y)
+LIBKVMQPLAT_ASFLAGS       := $(LIBKVMPLAT_ASFLAGS) -DKVMQPLAT
+LIBKVMQPLAT_CFLAGS        := $(LIBKVMPLAT_CFLAGS) -DKVMQPLAT
+LIBKVMQPLAT_CXXFLAGS      := $(LIBKVMPLAT_CXXFLAGS) -DKVMQPLAT
+endif
+ifeq ($(CONFIG_KVM_VMM_FIRECRACKER),y)
+LIBKVMFCPLAT_SRCS-y        := $(LIBKVMPLAT_SRCS-y)
+LIBKVMFCPLAT_ASINCLUDES-y  := $(LIBKVMPLAT_ASINCLUDES-y)
+LIBKVMFCPLAT_CINCLUDES-y   := $(LIBKVMPLAT_CINCLUDES-y)
+LIBKVMFCPLAT_ASFLAGS       := $(LIBKVMPLAT_ASFLAGS) -DKVMFCPLAT
+LIBKVMFCPLAT_CFLAGS        := $(LIBKVMPLAT_CFLAGS) -DKVMFCPLAT
+LIBKVMFCPLAT_CXXFLAGS      := $(LIBKVMPLAT_CXXFLAGS) -DKVMFCPLAT
+endif
+
 ##
 ## PCI library definitions
 ##
-- 
2.17.1


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.