From patchwork Mon Oct 19 10:59:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Nesterov X-Patchwork-Id: 7435091 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8BB4EBEEA4 for ; Mon, 19 Oct 2015 11:03:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AFA002072E for ; Mon, 19 Oct 2015 11:03:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A4565205B9 for ; Mon, 19 Oct 2015 11:03:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752721AbbJSLDQ (ORCPT ); Mon, 19 Oct 2015 07:03:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52233 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752259AbbJSLDP (ORCPT ); Mon, 19 Oct 2015 07:03:15 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id AF994C0C1890; Mon, 19 Oct 2015 11:03:15 +0000 (UTC) Received: from tranklukator.brq.redhat.com (dhcp-1-102.brq.redhat.com [10.34.1.102]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t9JB3D99025709; Mon, 19 Oct 2015 07:03:14 -0400 Received: by tranklukator.brq.redhat.com (nbSMTP-1.00) for uid 500 oleg@redhat.com; Mon, 19 Oct 2015 12:59:47 +0200 (CEST) Date: Mon, 19 Oct 2015 12:59:45 +0200 From: Oleg Nesterov To: Andre Przywara , Dimitri Ledkov , Ingo Molnar , Pekka Enberg , Will Deacon Cc: kvm@vger.kernel.org Subject: [PATCH 2/3] kvmtool/build: introduce GUEST_PRE_INIT target Message-ID: <20151019105945.GA12428@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20151019105930.GA12411@redhat.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This comes as a separate patch because I do not really understand /usr/bin/make, probably it should be updated. Change the main Makefile so that if an arch defines ARCH_PRE_INIT then we - build $GUEST_INIT without "-static" - add -DCONFIG_GUEST_PRE_INIT to $CFLAGS - build $ARCH_PRE_INIT as guest/guest_pre_init.o and embed it into lkvm the same as we do with guest/guest_init.o This also means that ARCH_PRE_INIT case doesn't depend on glibc-static, we can relax the SOURCE_STATIC check later. Signed-off-by: Oleg Nesterov --- .gitignore | 1 + Makefile | 25 ++++++++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index f10d3c5..697a63f 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ include/common-cmds.h tests/boot/boot_test.iso tests/boot/rootfs/ guest/init +guest/pre_init guest/init_stage2 KVMTOOLS-VERSION-FILE /x86/bios/bios.bin diff --git a/Makefile b/Makefile index f1701aa..0f8e003 100644 --- a/Makefile +++ b/Makefile @@ -281,6 +281,14 @@ ifeq ($(call try-build,$(SOURCE_STATIC),,-static),y) CFLAGS += -DCONFIG_GUEST_INIT GUEST_INIT := guest/init GUEST_OBJS = guest/guest_init.o + ifeq ($(ARCH_PRE_INIT),) + GUEST_INIT_FLAGS += -static + else + CFLAGS += -DCONFIG_GUEST_PRE_INIT + GUEST_INIT_FLAGS += -DCONFIG_GUEST_PRE_INIT + GUEST_PRE_INIT := guest/pre_init + GUEST_OBJS += guest/guest_pre_init.o + endif else $(warning No static libc found. Skipping guest init) NOTFOUND += static-libc @@ -346,7 +354,7 @@ ifneq ($(WERROR),0) CFLAGS += -Werror endif -all: $(PROGRAM) $(PROGRAM_ALIAS) $(GUEST_INIT) +all: $(PROGRAM) $(PROGRAM_ALIAS) $(GUEST_INIT) $(GUEST_PRE_INIT) # CFLAGS used when building objects # This is intentionally not assigned using := @@ -360,11 +368,11 @@ c_flags = -Wp,-MD,$(depfile) $(CFLAGS) # STATIC_OBJS = $(patsubst %.o,%.static.o,$(OBJS) $(OBJS_STATOPT)) -$(PROGRAM)-static: $(STATIC_OBJS) $(OTHEROBJS) $(GUEST_INIT) +$(PROGRAM)-static: $(STATIC_OBJS) $(OTHEROBJS) $(GUEST_INIT) $(GUEST_PRE_INIT) $(E) " LINK " $@ $(Q) $(CC) -static $(CFLAGS) $(STATIC_OBJS) $(OTHEROBJS) $(GUEST_OBJS) $(LIBS) $(LIBS_STATOPT) -o $@ -$(PROGRAM): $(OBJS) $(OBJS_DYNOPT) $(OTHEROBJS) $(GUEST_INIT) +$(PROGRAM): $(OBJS) $(OBJS_DYNOPT) $(OTHEROBJS) $(GUEST_INIT) $(GUEST_PRE_INIT) $(E) " LINK " $@ $(Q) $(CC) $(CFLAGS) $(OBJS) $(OBJS_DYNOPT) $(OTHEROBJS) $(GUEST_OBJS) $(LIBS) $(LIBS_DYNOPT) -o $@ @@ -372,9 +380,16 @@ $(PROGRAM_ALIAS): $(PROGRAM) $(E) " LN " $@ $(Q) ln -f $(PROGRAM) $@ +ifneq ($(ARCH_PRE_INIT),) +$(GUEST_PRE_INIT): $(ARCH_PRE_INIT) + $(E) " LINK " $@ + $(Q) $(CC) -s -nostdlib $(ARCH_PRE_INIT) -o $@ + $(Q) $(LD) $(LDFLAGS) -r -b binary -o guest/guest_pre_init.o $(GUEST_PRE_INIT) +endif + $(GUEST_INIT): guest/init.c $(E) " LINK " $@ - $(Q) $(CC) -static guest/init.c -o $@ + $(Q) $(CC) $(GUEST_INIT_FLAGS) guest/init.c -o $@ $(Q) $(LD) $(LDFLAGS) -r -b binary -o guest/guest_init.o $(GUEST_INIT) %.s: %.c @@ -473,7 +488,7 @@ clean: $(Q) rm -f x86/bios/bios-rom.h $(Q) rm -f tests/boot/boot_test.iso $(Q) rm -rf tests/boot/rootfs/ - $(Q) rm -f $(DEPS) $(OBJS) $(OTHEROBJS) $(OBJS_DYNOPT) $(STATIC_OBJS) $(PROGRAM) $(PROGRAM_ALIAS) $(PROGRAM)-static $(GUEST_INIT) $(GUEST_OBJS) + $(Q) rm -f $(DEPS) $(OBJS) $(OTHEROBJS) $(OBJS_DYNOPT) $(STATIC_OBJS) $(PROGRAM) $(PROGRAM_ALIAS) $(PROGRAM)-static $(GUEST_INIT) $(GUEST_PRE_INIT) $(GUEST_OBJS) $(Q) rm -f cscope.* $(Q) rm -f tags $(Q) rm -f TAGS