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

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



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

Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
Signed-off-by: Florian Schmidt <florian.schmidt@xxxxxxxxx>
---
 plat/kvm/Linker_fc.uk               | 67 +++++++++++++++++++++++++++++
 plat/kvm/{Linker.uk => Linker_q.uk} | 41 ++++++++++--------
 plat/kvm/Makefile.uk                | 42 +++++++++++++++---
 3 files changed, 126 insertions(+), 24 deletions(-)
 create mode 100644 plat/kvm/Linker_fc.uk
 rename plat/kvm/{Linker.uk => Linker_q.uk} (50%)

diff --git a/plat/kvm/Linker_fc.uk b/plat/kvm/Linker_fc.uk
new file mode 100644
index 00000000..992f6c86
--- /dev/null
+++ b/plat/kvm/Linker_fc.uk
@@ -0,0 +1,67 @@
+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
+
+KVMFC_LDSCRIPT     := $(call src2lds,libkvmfcplat,$(KVM_LDSCRIPT_SRC-y))
+
+##
+## Link image
+##
+KVMFC_IMAGE := $(BUILD_DIR)/$(CONFIG_UK_NAME)_kvmfc-$(CONFIG_UK_ARCH)
+
+KVMFC_LD_SCRIPT_FLAGS := $(addprefix -Wl$(comma)-T$(comma),\
+                       $(KVMFC_LD_SCRIPT-y) $(EXTRA_LD_SCRIPT-y))
+
+$(KVMFC_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) \
+              $(KVMFC_LDSCRIPT)
+       $(call build_cmd,LD,,$@.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 $@.ld.o)
+       $(call build_cmd,OBJCOPY,,$@.o,\
+              $(OBJCOPY) -w -G kvmos_* -G _libkvmplat_entry \
+                       -G _libkvmplat_start64 $@.ld.o $@.o)
+ifneq ($(filter x86_64 arm64,$(CONFIG_UK_ARCH)),)
+       $(call build_cmd,LD,,$@.dbg,\
+              $(LD) $(LDFLAGS) $(LDFLAGS-y) \
+                    $(KVMFC_LDFLAGS) $(KVMFC_LDFLAGS-y) \
+                    -Wl$(comma)-dT$(comma)$(call strip,$(KVMFC_LDSCRIPT)) \
+                    $(KVMFC_LD_SCRIPT_FLAGS) \
+                    $@.o -o $@.dbg)
+       $(call verbose_cmd,SCSTRIP,$(notdir $@),\
+               $(SCRIPTS_DIR)/sect-strip.py \
+                       $(SECT_STRIP_FLAGS) $(SECT_STRIP_FLAGS-y) \
+                       --with-objcopy=$(OBJCOPY) \
+                       $@.dbg -o $@)
+       $(call verbose_cmd,STRIP,$(notdir $@), $(STRIP) -s $@)
+
+ifeq ($(CONFIG_OPTIMIZE_SYMFILE),y)
+       $(call build_cmd,NM,,$@.sym,\
+              $(NM) -n $@.dbg > $@.sym)
+endif
+       $(call build_cmd,GZ,,$@.gz,\
+              $(GZIP) -f -9 -c $@ >$@.gz)
+endif
+
+# register image to the build
+UK_IMAGES-$(CONFIG_KVM_VMM_FIRECRACKER) += $(KVMFC_IMAGE)
+
+# ...for cleaning:
+LIBKVMFCPLAT_CLEAN += $(call build_clean,$(KVMFC_IMAGE))
+LIBKVMFCPLAT_CLEAN += $(call build_clean,$(KVMFC_IMAGE).gz)
+LIBKVMFCPLAT_CLEAN += $(call build_clean,$(KVMFC_IMAGE).dbg)
+LIBKVMFCPLAT_CLEAN += $(call build_clean,$(KVMFC_IMAGE).sym)
+LIBKVMFCPLAT_CLEAN += $(call build_clean,$(KVMFC_IMAGE).o)
+LIBKVMFCPLAT_CLEAN += $(call build_clean,$(KVMFC_IMAGE).ld.o)
diff --git a/plat/kvm/Linker.uk b/plat/kvm/Linker_q.uk
similarity index 50%
rename from plat/kvm/Linker.uk
rename to plat/kvm/Linker_q.uk
index 9be40612..a603b5d1 100644
--- a/plat/kvm/Linker.uk
+++ b/plat/kvm/Linker_q.uk
@@ -1,29 +1,32 @@
 ifeq (x86_64,$(CONFIG_UK_ARCH))
-KVM_LDFLAGS-y += -Wl,-m,elf_x86_64
+KVMQ_LDFLAGS-y += -Wl,-m,elf_x86_64
 else ifeq (arm64,$(CONFIG_UK_ARCH))
-KVM_LDFLAGS-y   += -Wl,-m,aarch64elf
+KVMQ_LDFLAGS-y  += -Wl,-m,aarch64elf
 endif
 
-KVM_LDSCRIPT     := $(call src2lds,libkvmplat,$(KVM_LDSCRIPT_SRC-y))
+KVMQ_LDSCRIPT     := $(call src2lds,libkvmqplat,$(KVM_LDSCRIPT_SRC-y))
 
 ##
 ## Link image
 ##
-KVM_IMAGE := $(BUILD_DIR)/$(CONFIG_UK_NAME)_kvm-$(CONFIG_UK_ARCH)
+KVMQ_IMAGE := $(BUILD_DIR)/$(CONFIG_UK_NAME)_kvmq-$(CONFIG_UK_ARCH)
 
-KVM_LD_SCRIPT_FLAGS := $(addprefix -Wl$(comma)-T$(comma),\
-                       $(KVM_LD_SCRIPT-y) $(EXTRA_LD_SCRIPT-y))
+KVMQ_LD_SCRIPT_FLAGS := $(addprefix -Wl$(comma)-T$(comma),\
+                       $(KVMQ_LD_SCRIPT-y) $(EXTRA_LD_SCRIPT-y))
 
-$(KVM_IMAGE): $(KVM_ALIBS) $(KVM_ALIBS-y) $(KVM_OLIBS) $(KVM_OLIBS-y) \
+$(KVMQ_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) \
-              $(KVM_LDSCRIPT)
+              $(KVMQ_LDSCRIPT)
        $(call build_cmd,LD,,$@.ld.o,\
               $(LD) -r $(LIBLDFLAGS) $(LIBLDFLAGS-y) \
-                       $(KVM_LDFLAGS) $(KVM_LDFLAGS-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 $@.ld.o)
@@ -33,9 +36,9 @@ $(KVM_IMAGE): $(KVM_ALIBS) $(KVM_ALIBS-y) $(KVM_OLIBS) 
$(KVM_OLIBS-y) \
 ifneq ($(filter x86_64 arm64,$(CONFIG_UK_ARCH)),)
        $(call build_cmd,LD,,$@.dbg,\
               $(LD) $(LDFLAGS) $(LDFLAGS-y) \
-                    $(KVM_LDFLAGS) $(KVM_LDFLAGS-y) \
-                    -Wl$(comma)-dT$(comma)$(call strip,$(KVM_LDSCRIPT)) \
-                    $(KVM_LD_SCRIPT_FLAGS) \
+                    $(KVMQ_LDFLAGS) $(KVMQ_LDFLAGS-y) \
+                    -Wl$(comma)-dT$(comma)$(call strip,$(KVMQ_LDSCRIPT)) \
+                    $(KVMQ_LD_SCRIPT_FLAGS) \
                     $@.o -o $@.dbg)
        $(call verbose_cmd,SCSTRIP,$(notdir $@),\
                $(SCRIPTS_DIR)/sect-strip.py \
@@ -53,12 +56,12 @@ endif
 endif
 
 # register image to the build
-UK_IMAGES-$(CONFIG_PLAT_KVM) += $(KVM_IMAGE)
+UK_IMAGES-$(CONFIG_KVM_VMM_QEMU) += $(KVMQ_IMAGE)
 
 # ...for cleaning:
-LIBKVMPLAT_CLEAN += $(call build_clean,$(KVM_IMAGE))
-LIBKVMPLAT_CLEAN += $(call build_clean,$(KVM_IMAGE).gz)
-LIBKVMPLAT_CLEAN += $(call build_clean,$(KVM_IMAGE).dbg)
-LIBKVMPLAT_CLEAN += $(call build_clean,$(KVM_IMAGE).sym)
-LIBKVMPLAT_CLEAN += $(call build_clean,$(KVM_IMAGE).o)
-LIBKVMPLAT_CLEAN += $(call build_clean,$(KVM_IMAGE).ld.o)
+LIBKVMQPLAT_CLEAN += $(call build_clean,$(KVMQ_IMAGE))
+LIBKVMQPLAT_CLEAN += $(call build_clean,$(KVMQ_IMAGE).gz)
+LIBKVMQPLAT_CLEAN += $(call build_clean,$(KVMQ_IMAGE).dbg)
+LIBKVMQPLAT_CLEAN += $(call build_clean,$(KVMQ_IMAGE).sym)
+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 633348ab..9516c58d 100644
--- a/plat/kvm/Makefile.uk
+++ b/plat/kvm/Makefile.uk
@@ -1,15 +1,30 @@
 ##
 ## 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,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,kvmfc,libkvmvirtio,$(CONFIG_VIRTIO_BUS)))
+$(eval $(call addplatlib_s,kvmq,libkvmvirtionet,$(CONFIG_VIRTIO_NET)))
+$(eval $(call addplatlib_s,kvmfc,libkvmvirtionet,$(CONFIG_VIRTIO_NET)))
 
 ##
 ## Platform library definitions
@@ -80,6 +95,23 @@ LIBKVMPLAT_SRCS-y              += 
$(UK_PLAT_COMMON_BASE)/lcpu.c|common
 LIBKVMPLAT_SRCS-y              += $(UK_PLAT_COMMON_BASE)/memory.c|common
 LIBKVMPLAT_SRCS-y              += $(KVM_LDSCRIPT_SRC-y)
 
+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.21.0


_______________________________________________
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®.