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

[Xen-devel] [PATCH v2 39/62] tools/firmware: Build and install xen-shim



From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

Link a minimum set of files to build the shim. The linkfarm rune can
handle creation and deletion of files. Introduce build-shim and
install-shim targets in xen/Makefile.

We can do better by properly generate the dependency from the list of
files but that's an improvement for later.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
v2: Introduce a top-level build-shim target. Split the xen-shim build
    with normal build.
---
 .gitignore                         |  4 ++
 tools/firmware/Makefile            |  9 ++++
 tools/firmware/xen-dir/Makefile    | 59 ++++++++++++++++++++++++++
 tools/firmware/xen-dir/shim.config | 87 ++++++++++++++++++++++++++++++++++++++
 xen/Makefile                       | 16 +++++--
 5 files changed, 172 insertions(+), 3 deletions(-)
 create mode 100644 tools/firmware/xen-dir/Makefile
 create mode 100644 tools/firmware/xen-dir/shim.config

diff --git a/.gitignore b/.gitignore
index 8da67daf31..f6cc61a701 100644
--- a/.gitignore
+++ b/.gitignore
@@ -155,6 +155,10 @@ tools/firmware/rombios/rombios[^/]*.s
 tools/firmware/rombios/32bit/32bitbios_flat.h
 tools/firmware/vgabios/vbetables-gen
 tools/firmware/vgabios/vbetables.h
+tools/firmware/xen-dir/*.old
+tools/firmware/xen-dir/linkfarm.stamp*
+tools/firmware/xen-dir/xen-root
+tools/firmware/xen-dir/xen-shim
 tools/flask/utils/flask-getenforce
 tools/flask/utils/flask-get-bool
 tools/flask/utils/flask-loadpolicy
diff --git a/tools/firmware/Makefile b/tools/firmware/Makefile
index 868b506920..9387cc0878 100644
--- a/tools/firmware/Makefile
+++ b/tools/firmware/Makefile
@@ -1,6 +1,8 @@
 XEN_ROOT = $(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
+CONFIG_PV_SHIM := y
+
 # hvmloader is a 32-bit protected mode binary.
 TARGET      := hvmloader/hvmloader
 INST_DIR := $(DESTDIR)$(XENFIRMWAREDIR)
@@ -11,6 +13,7 @@ SUBDIRS-$(CONFIG_SEABIOS) += seabios-dir
 SUBDIRS-$(CONFIG_ROMBIOS) += rombios
 SUBDIRS-$(CONFIG_ROMBIOS) += vgabios
 SUBDIRS-$(CONFIG_ROMBIOS) += etherboot
+SUBDIRS-$(CONFIG_PV_SHIM) += xen-dir
 SUBDIRS-y += hvmloader
 
 LD32BIT-$(CONFIG_FreeBSD) := LD32BIT_FLAG=-melf_i386_fbsd
@@ -48,6 +51,9 @@ endif
 ifeq ($(CONFIG_OVMF),y)
        $(INSTALL_DATA) ovmf-dir/ovmf.bin $(INST_DIR)/ovmf.bin
 endif
+ifeq ($(CONFIG_PV_SHIM),y)
+       $(INSTALL_DATA) xen-dir/xen-shim $(INST_DIR)/xen-shim
+endif
 
 .PHONY: uninstall
 uninstall:
@@ -58,6 +64,9 @@ endif
 ifeq ($(CONFIG_OVMF),y)
        rm -f $(INST_DIR)/ovmf.bin
 endif
+ifeq ($(CONFIG_PV_SHIM),y)
+       rm -f $(INST_DIR)/xen-shim
+endif
 
 .PHONY: clean
 clean: subdirs-clean
diff --git a/tools/firmware/xen-dir/Makefile b/tools/firmware/xen-dir/Makefile
new file mode 100644
index 0000000000..adf6c31e8d
--- /dev/null
+++ b/tools/firmware/xen-dir/Makefile
@@ -0,0 +1,59 @@
+XEN_ROOT = $(CURDIR)/../../..
+
+all: xen-shim
+
+.PHONY: FORCE
+FORCE:
+
+D=xen-root
+
+# Minimun set of files / directories go get Xen to build
+LINK_DIRS=config xen
+LINK_FILES=Config.mk
+
+DEP_DIRS=$(foreach i, $(LINK_DIRS), $(XEN_ROOT)/$(i))
+DEP_FILES=$(foreach i, $(LINK_FILES), $(XEN_ROOT)/$(i))
+
+linkfarm.stamp: $(DEP_DIRS) $(DEP_FILES) FORCE
+       mkdir -p $(D)
+       set -e
+       rm -f linkfarm.stamp.tmp
+       $(foreach d, $(LINK_DIRS), \
+                (mkdir -p $(D)/$(d); \
+                 cd $(D)/$(d); \
+                 find $(XEN_ROOT)/$(d)/ -type d -printf "./%P\n" |  xargs 
mkdir -p);)
+       $(foreach d, $(LINK_DIRS), \
+               (cd $(XEN_ROOT); \
+                find $(d) ! -type l -type f \
+                $(addprefix ! -path , '*.[oda1]' '*.d[12]')) \
+                >> linkfarm.stamp.tmp ; )
+       $(foreach f, $(LINK_FILES), \
+               echo $(f) >> linkfarm.stamp.tmp ;)
+       cmp -s linkfarm.stamp.tmp linkfarm.stamp && \
+               rm linkfarm.stamp.tmp || { \
+               mv linkfarm.stamp.tmp linkfarm.stamp; \
+               cat linkfarm.stamp | while read f; \
+                 do rm -f "$(D)/$$f"; ln -s "$(XEN_ROOT)/$$f" "$(D)/$$f"; done 
\
+               }
+
+# Copy enough of the tree to build the shim hypervisor
+$(D): linkfarm.stamp
+       $(MAKE) -C $(D)/xen distclean
+
+.PHONY: shim-%config
+shim-%config: $(D) FORCE
+       $(MAKE) -C $(D)/xen $*config \
+               XEN_CONFIG_EXPERT=y \
+               KCONFIG_CONFIG=$(CURDIR)/shim.config
+
+xen-shim: $(D) shim-olddefconfig
+       $(MAKE) -C $(D)/xen install-shim \
+               XEN_CONFIG_EXPERT=y \
+               KCONFIG_CONFIG=$(CURDIR)/shim.config \
+               DESTDIR=$(CURDIR)
+
+.PHONY: distclean clean
+distclean clean:
+       rm -f xen-shim *.old
+       rm -rf $(D)
+       rm -f linkfarm.stamp*
diff --git a/tools/firmware/xen-dir/shim.config 
b/tools/firmware/xen-dir/shim.config
new file mode 100644
index 0000000000..227a12fb4c
--- /dev/null
+++ b/tools/firmware/xen-dir/shim.config
@@ -0,0 +1,87 @@
+#
+# Automatically generated file; DO NOT EDIT.
+# Xen/x86 4.11-unstable Configuration
+#
+CONFIG_X86_64=y
+CONFIG_X86=y
+CONFIG_ARCH_DEFCONFIG="arch/x86/configs/x86_64_defconfig"
+
+#
+# Architecture Features
+#
+CONFIG_NR_CPUS=32
+CONFIG_PV=y
+CONFIG_PV_LINEAR_PT=y
+CONFIG_HVM=y
+# CONFIG_SHADOW_PAGING is not set
+# CONFIG_BIGMEM is not set
+# CONFIG_HVM_FEP is not set
+# CONFIG_TBOOT is not set
+CONFIG_XEN_GUEST=y
+CONFIG_PVH_GUEST=y
+CONFIG_PV_SHIM=y
+CONFIG_PV_SHIM_EXCLUSIVE=y
+
+#
+# Common Features
+#
+CONFIG_COMPAT=y
+CONFIG_CORE_PARKING=y
+CONFIG_HAS_ALTERNATIVE=y
+CONFIG_HAS_EX_TABLE=y
+CONFIG_HAS_MEM_ACCESS=y
+CONFIG_HAS_MEM_PAGING=y
+CONFIG_HAS_MEM_SHARING=y
+CONFIG_HAS_PDX=y
+CONFIG_HAS_UBSAN=y
+CONFIG_HAS_KEXEC=y
+CONFIG_HAS_GDBSX=y
+CONFIG_HAS_IOPORTS=y
+# CONFIG_KEXEC is not set
+# CONFIG_TMEM is not set
+# CONFIG_XENOPROF is not set
+# CONFIG_XSM is not set
+
+#
+# Schedulers
+#
+CONFIG_SCHED_CREDIT=y
+# CONFIG_SCHED_CREDIT2 is not set
+# CONFIG_SCHED_RTDS is not set
+# CONFIG_SCHED_ARINC653 is not set
+CONFIG_SCHED_NULL=y
+# CONFIG_SCHED_CREDIT_DEFAULT is not set
+CONFIG_SCHED_NULL_DEFAULT=y
+CONFIG_SCHED_DEFAULT="null"
+# CONFIG_LIVEPATCH is not set
+# CONFIG_SUPPRESS_DUPLICATE_SYMBOL_WARNINGS is not set
+CONFIG_CMDLINE=""
+
+#
+# Device Drivers
+#
+CONFIG_ACPI=y
+CONFIG_ACPI_LEGACY_TABLES_LOOKUP=y
+CONFIG_NUMA=y
+CONFIG_HAS_NS16550=y
+CONFIG_HAS_EHCI=y
+CONFIG_HAS_CPUFREQ=y
+CONFIG_HAS_PASSTHROUGH=y
+CONFIG_HAS_PCI=y
+CONFIG_VIDEO=y
+CONFIG_VGA=y
+CONFIG_DEFCONFIG_LIST="$ARCH_DEFCONFIG"
+CONFIG_ARCH_SUPPORTS_INT128=y
+
+#
+# Debugging Options
+#
+# CONFIG_DEBUG is not set
+# CONFIG_CRASH_DEBUG is not set
+# CONFIG_FRAME_POINTER is not set
+# CONFIG_GCOV is not set
+# CONFIG_LOCK_PROFILE is not set
+# CONFIG_PERF_COUNTERS is not set
+# CONFIG_VERBOSE_DEBUG is not set
+# CONFIG_SCRUB_DEBUG is not set
+# CONFIG_UBSAN is not set
diff --git a/xen/Makefile b/xen/Makefile
index 044e7c82a3..027c5adfdd 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -37,10 +37,10 @@ default: build
 .PHONY: dist
 dist: install
 
-build install:: include/config/auto.conf
+build install build-shim:: include/config/auto.conf
 
-.PHONY: build install uninstall clean distclean cscope TAGS tags MAP gtags 
tests
-build install uninstall debug clean distclean cscope TAGS tags MAP gtags 
tests::
+.PHONY: build install uninstall clean distclean cscope TAGS tags MAP gtags 
tests install-shim build-shim
+build install uninstall debug clean distclean cscope TAGS tags MAP gtags tests 
install-shim build-shim::
 ifneq ($(XEN_TARGET_ARCH),x86_32)
        $(MAKE) -f Rules.mk _$@
 else
@@ -80,6 +80,13 @@ _install: $(TARGET)$(CONFIG_XEN_INSTALL_SUFFIX)
                fi; \
        fi
 
+.PHONY: _build-shim
+_build-shim: $(TARGET)-shim
+
+.PHONY: _install-shim
+_install-shim: build-shim
+       $(INSTALL_DATA) $(TARGET)-shim $(DESTDIR)
+
 .PHONY: _tests
 _tests:
        $(MAKE) -f $(BASEDIR)/Rules.mk -C test tests
@@ -144,6 +151,9 @@ $(TARGET): delete-unfresh-files
        $(MAKE) -f $(BASEDIR)/Rules.mk include/asm-$(TARGET_ARCH)/asm-offsets.h
        $(MAKE) -f $(BASEDIR)/Rules.mk -C arch/$(TARGET_ARCH) $(TARGET)
 
+$(TARGET)-shim: $(TARGET)
+       $(MAKE) -f $(BASEDIR)/Rules.mk -C arch/$(TARGET_ARCH) $(TARGET)-shim
+
 # drivers/char/console.o contains static banner/compile info. Blow it away.
 # Don't refresh these files during e.g., 'sudo make install'
 .PHONY: delete-unfresh-files
-- 
2.11.0


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

 


Rackspace

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