From patchwork Mon Jun 20 15:09:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9187763 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 37E446075E for ; Mon, 20 Jun 2016 15:10:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2580726861 for ; Mon, 20 Jun 2016 15:10:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A697279E0; Mon, 20 Jun 2016 15:10:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 147FC26861 for ; Mon, 20 Jun 2016 15:10:58 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bF0ow-0003sA-6R; Mon, 20 Jun 2016 15:09:02 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bF0ou-0003rS-BI for xen-devel@lists.xenproject.org; Mon, 20 Jun 2016 15:09:00 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id 33/9C-09256-B0708675; Mon, 20 Jun 2016 15:08:59 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOLMWRWlGSWpSXmKPExsVysyfVTZebPSP cYNFMZovvWyYzOTB6HP5whSWAMYo1My8pvyKBNePc1AdsBQu0Kh5fO8vUwLhRuYuRi0NIYBOj xKZNnYwQzgpGib9XngE5nBxsAroSO26+ZgaxRQTUJXp2fWEBKWIW+ANUNK+dDSQhLGApcXj2Q lYQm0VAVWLi/89gDbwCVhJbLi0Gi0sIyEk0nL8PFucUsJaYu3MS2AIhoJoPfxaxTGDkXsDIsI pRvTi1qCy1SNdQL6koMz2jJDcxM0fX0MBMLze1uDgxPTUnMalYLzk/dxMj0MMMQLCDcedzp0O MkhxMSqK805+khwvxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4K1kzQgXEixKTU+tSMvMAYYaTFqC g0dJhLceJM1bXJCYW5yZDpE6xagoJc5bB5IQAElklObBtcHC+xKjrJQwLyPQIUI8BalFuZklq PKvGMU5GJWEeQ+CTOHJzCuBm/4KaDET0OJl/ekgi0sSEVJSDYz+Pke0Fs0SsWMU/NEYN8vq39 JFVtF3uY7lWbbYLWgy/Mbis2Pm8XzjhWG5E35/P7fm7fsDu16I8T/fsMvRPXZywPd7l/gee3H ZNBcGnWiVTd7wYNvuCQwTVsot8Mn7yp0s5HM1+uKNF888Vj0zy3fzOGIwl+udb/WBrQ/Pz31k tSOHdfODlm4PJZbijERDLeai4kQAM5EkMmoCAAA= X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-5.tower-21.messagelabs.com!1466435338!19857375!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests=UPPERCASE_25_50 X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 44392 invoked from network); 20 Jun 2016 15:08:58 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-5.tower-21.messagelabs.com with SMTP; 20 Jun 2016 15:08:58 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 82BF33B9; Mon, 20 Jun 2016 08:09:43 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.203.153]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BB4CB3F246; Mon, 20 Jun 2016 08:08:56 -0700 (PDT) From: Andre Przywara To: Mark Rutland Date: Mon, 20 Jun 2016 16:09:31 +0100 Message-Id: <20160620150934.1729-2-andre.przywara@arm.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160620150934.1729-1-andre.przywara@arm.com> References: <20160620150934.1729-1-andre.przywara@arm.com> Cc: Jean-Philippe Brucker , Julien Grall , Christoffer Dall , Ian Campbell , xen-devel@lists.xenproject.org, linux-arm-kernel@lists.infradead.org Subject: [Xen-devel] [PATCH 1/4] Support for building in a Xen binary X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Christoffer Dall Add support for building a Xen binary which includes a Dom0 image and the Dom0 command-line. If the user specifies --with-xen=, where Xen is an appropriate AArch64 Xen binary, the build system will generate a xen-system.axf instead of a linux-system.axf. Original patch from Ian Campbell, but I modified most of it so all bugs are probably mine. [Andre: adapt to newest boot-wrapper branch, increase load address] Cc: Ian Campbell Signed-off-by: Christoffer Dall Signed-off-by: Andre Przywara --- .gitignore | 1 + Makefile.am | 12 ++++++++---- boot_common.c | 4 ++-- configure.ac | 14 ++++++++++++++ model.lds.S | 14 ++++++++++++++ 5 files changed, 39 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 8653852..80770c0 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ configure dtc fdt.dtb Image +Xen install-sh Makefile Makefile.in diff --git a/Makefile.am b/Makefile.am index 692d2cc..1a801c0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -85,7 +85,6 @@ TEXT_LIMIT := 0x80080000 endif LD_SCRIPT := model.lds.S -IMAGE := linux-system.axf FS_OFFSET := 0x10000000 FILESYSTEM_START:= $(shell echo $$(($(PHYS_OFFSET) + $(FS_OFFSET)))) @@ -108,6 +107,11 @@ CHOSEN_NODE := chosen { \ }; endif +if XEN +XEN := -DXEN=$(XEN_IMAGE) +XEN_OFFSET := 0x08200000 +endif + CPPFLAGS += $(INITRD_FLAGS) CFLAGS += -Iinclude/ -I$(ARCH_SRC)/include/ CFLAGS += -Wall -fomit-frame-pointer @@ -117,11 +121,11 @@ LDFLAGS += --gc-sections OFILES += boot_common.o bakery_lock.o platform.o $(GIC) cache.o lib.o OFILES += $(addprefix $(ARCH_SRC),boot.o stack.o $(BOOTMETHOD) utils.o) -all: $(IMAGE) +all: $(IMAGE) $(XIMAGE) CLEANFILES = $(IMAGE) $(OFILES) model.lds fdt.dtb -$(IMAGE): $(OFILES) model.lds fdt.dtb $(KERNEL_IMAGE) $(FILESYSTEM) +$(IMAGE): $(OFILES) model.lds fdt.dtb $(KERNEL_IMAGE) $(FILESYSTEM) $(XEN_IMAGE) $(LD) $(LDFLAGS) $(OFILES) -o $@ --script=model.lds %.o: %.S Makefile @@ -131,7 +135,7 @@ $(IMAGE): $(OFILES) model.lds fdt.dtb $(KERNEL_IMAGE) $(FILESYSTEM) $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c -o $@ $< model.lds: $(LD_SCRIPT) Makefile - $(CPP) $(CPPFLAGS) -ansi -DPHYS_OFFSET=$(PHYS_OFFSET) -DMBOX_OFFSET=$(MBOX_OFFSET) -DKERNEL_OFFSET=$(KERNEL_OFFSET) -DFDT_OFFSET=$(FDT_OFFSET) -DFS_OFFSET=$(FS_OFFSET) -DKERNEL=$(KERNEL_IMAGE) -DFILESYSTEM=$(FILESYSTEM) -DTEXT_LIMIT=$(TEXT_LIMIT) -P -C -o $@ $< + $(CPP) $(CPPFLAGS) -ansi -DPHYS_OFFSET=$(PHYS_OFFSET) -DMBOX_OFFSET=$(MBOX_OFFSET) -DKERNEL_OFFSET=$(KERNEL_OFFSET) -DFDT_OFFSET=$(FDT_OFFSET) -DFS_OFFSET=$(FS_OFFSET) $(XEN) -DXEN_OFFSET=$(XEN_OFFSET) -DKERNEL=$(KERNEL_IMAGE) -DFILESYSTEM=$(FILESYSTEM) -DTEXT_LIMIT=$(TEXT_LIMIT) -P -C -o $@ $< fdt.dtb: $(KERNEL_DTB) Makefile gen-cpu-nodes.sh ( $(DTC) -O dts -I dtb $(KERNEL_DTB) ; echo "/ { $(CHOSEN_NODE) $(PSCI_NODE) $(CPUS_NODE) };" ) | $(DTC) -O dtb -o $@ - diff --git a/boot_common.c b/boot_common.c index 4947fe3..e7b8e1d 100644 --- a/boot_common.c +++ b/boot_common.c @@ -9,7 +9,7 @@ #include #include -extern unsigned long kernel; +extern unsigned long entrypoint; extern unsigned long dtb; void init_platform(void); @@ -67,7 +67,7 @@ void __noreturn first_spin(unsigned int cpu, unsigned long *mbox, if (cpu == 0) { init_platform(); - *mbox = (unsigned long)&kernel; + *mbox = (unsigned long)&entrypoint; sevl(); spin(mbox, invalid, 1); } else { diff --git a/configure.ac b/configure.ac index ab8f5b3..2441f8b 100644 --- a/configure.ac +++ b/configure.ac @@ -40,6 +40,15 @@ AC_ARG_WITH([dtb], AS_HELP_STRING([--with-dtb], [Specify a particular DTB to use]), [KERN_DTB="$withval"]) +AC_ARG_WITH([xen], + AS_HELP_STRING([--with-xen], [Compile for Xen, and Specify a particular Xen to use]), + X_IMAGE=$withval) + +AS_IF([test "x$X_IMAGE" == "x"], [], + [AC_CHECK_FILE([$X_IMAGE], [], AC_MSG_ERROR([No such file or directory: $X_IMAGE]))]) +AC_SUBST([XEN_IMAGE], [$X_IMAGE]) +AM_CONDITIONAL([XEN], [test "x$X_IMAGE" != "x"]) + # Ensure that the user has provided us with a sane kernel dir. m4_define([CHECKFILES], [KERN_DIR, KERN_DTB, @@ -50,6 +59,10 @@ m4_foreach([checkfile], [CHECKFILES], AC_SUBST([KERNEL_IMAGE], [$KERN_IMAGE]) AC_SUBST([KERNEL_DTB], [$KERN_DTB]) +AS_IF([test "x$X_IMAGE" != "x"], + [AC_SUBST([IMAGE], ["xen-system.axf"])], + [AC_SUBST([IMAGE], ["linux-system.axf"])] +) # Allow a user to pass --enable-psci AC_ARG_ENABLE([psci], @@ -119,4 +132,5 @@ echo " CPU IDs: ${CPU_IDS}" echo " Use GICv3? ${USE_GICV3}" echo " Boot-wrapper execution state: AArch${BOOTWRAPPER_ES}" echo " Kernel execution state: AArch${KERNEL_ES}" +echo " Xen image ${X_IMAGE:-NONE}" echo "" diff --git a/model.lds.S b/model.lds.S index 51c5684..511f552 100644 --- a/model.lds.S +++ b/model.lds.S @@ -16,6 +16,9 @@ OUTPUT_ARCH(aarch64) #endif TARGET(binary) +#ifdef XEN +INPUT(XEN) +#endif INPUT(KERNEL) INPUT(./fdt.dtb) @@ -36,6 +39,17 @@ SECTIONS KERNEL } +#ifdef XEN + .xen (PHYS_OFFSET + XEN_OFFSET): { + xen = .; + XEN + } + + entrypoint = xen; +#else + entrypoint = kernel; +#endif + .dtb (PHYS_OFFSET + FDT_OFFSET): { dtb = .; ./fdt.dtb