From nobody Mon Feb 9 00:37:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1643108507; cv=none; d=zohomail.com; s=zohoarc; b=evKQHGdO5/Phel6DL6TSJcEsBxl8QHIcAwf8X8P1JPJDQ1DYe3ppK3LpizhdA4ndNRCty1l0J4KmJHSARuMJs9YgVbFtQOo1X34JAJPoU1fPVJe8E26VK+/xOZ9Ibt+Jf5X+p6a3f208e3ROZhuVbm3BeMA7Ie+JNf05g8nHm74= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643108507; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9PgTPHLiBtd51Ucu9vXwfjpr2d7759DgTvsaNut/p3Y=; b=hYQBiGISqTed0UnWhuhG9o7/Z1sWZs/EARuTzY1d1NJBWrHNfzZLs3epFipJcc0yiU0m2Aj7JEq1obl5dvAUI6Fouis9hC99ss/KkxOYOCiAzErPE01skjDBOX4sr9DpvIGBwi0p+yI+E60587+jAhDJXIMNYr7Xase4rhSOIpM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1643108507976946.9541461979683; Tue, 25 Jan 2022 03:01:47 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.260062.449080 (Exim 4.92) (envelope-from ) id 1nCJZb-0006UA-JF; Tue, 25 Jan 2022 11:01:15 +0000 Received: by outflank-mailman (output) from mailman id 260062.449080; Tue, 25 Jan 2022 11:01:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nCJZb-0006S8-FD; Tue, 25 Jan 2022 11:01:15 +0000 Received: by outflank-mailman (input) for mailman id 260062; Tue, 25 Jan 2022 11:01:14 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nCJZa-0006Mn-3N for xen-devel@lists.xenproject.org; Tue, 25 Jan 2022 11:01:14 +0000 Received: from esa6.hc3370-68.iphmx.com (esa6.hc3370-68.iphmx.com [216.71.155.175]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1b1576b6-7dce-11ec-8fa7-f31e035a9116; Tue, 25 Jan 2022 12:01:12 +0100 (CET) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1b1576b6-7dce-11ec-8fa7-f31e035a9116 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1643108472; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AnOSnJwU7XBTWsJ/6UnK/xN2yhLgLGPIzUJ+QOu+uf0=; b=NMN2vg1SHp0OjgsEniIV4AbxAIxLSgkDolva287hlvlRTJcs7Q65dVP9 2IljBzGkTST9uMD7B4pcK/FZ1pDKGj9VgVBoRg/zovjb/3omehLLDWY3e 0GSY3NsmLrafBkIMopA3uZqZokL5Ne9fN3aioptjE951lIjLGU3VGYC08 A=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: PlAjJtaYJiDGtANVh5yBEAeQgHRJjotC05a2vwE4oLKpqGJeFSfO601sBqiXlj7ZYBU36vTOUI c4mX3vduYH0mwmsCcC319zy5iB8uK+m4SuaQcbQDmyXZDiALDDJDlTDANJ23IeEUcViTqWaZ4U Ri7sl3dc/JpdkMLAl/FHYe3IoB4lj5b7jFphE+AD8jPLTwRVzfDtPYBwYECstchiBM6QQVuCV5 BkeZ+KrizHhP6qmX3a0T3sb6kjoNJerl5AI81WFjOZB6hnuFYCTI0NTjqFPltN75DZlmsSI8+R tZd/25RtlZCDfA4diW1yZC8/ X-SBRS: 5.2 X-MesageID: 62618907 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:Gt2jD6pSqITHM0oiHQFtd1hNc0VeBmLkYhIvgKrLsJaIsI4StFCzt garIBmDOPaDZGLwfIwladm09RgCu5/Sxt42TwJurC88F38V8puZCYyVIHmrMnLJJKUvbq7GA +byyDXkBJppJpMJjk71atANlZT4vE2xbuKU5NTsY0idfic5Dndx4f5fs7Rh2NQw2ILkW1rlV e7a+KUzBnf0g1aYDUpMg06zgEsHUCPa4W5wUvQWPJinjXeG/5UnJMt3yZKZdhMUdrJ8DO+iL 9sv+Znilo/vE7XBPfv++lrzWhVirrc/pmFigFIOM0SpqkAqSiDfTs/XnRfTAKtao2zhojx/9 DlCncSwEzw4Oq/iosYmfjNqGHh8P4Bnw6CSdBBTseTLp6HHW37lwvEoB0AqJ4wIvO1wBAmi9 9RBdmpLNErawbvrnvTrEYGAhex6RCXvFIoZpnFnyyCfFfs8SIrPa67L+cVZzHE7gcUm8fP2O ZBHMGo+NEuojxtnEQclNrYjv8uRpEbuSi0AmEmfmrQP2j2GpOB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+Ify4JXKgQv50HBJPm11gwwVZYbJ2AUiL77fljsTmX3pXG9 tNMuJf/ug== IronPort-HdrOrdr: A9a23:9WEfe6z7WCaENjuDpgdhKrPwEL1zdoMgy1knxilNoHtuA6ilfq GV7ZEmPHDP+VUssR0b+OxoW5PvfZq/z+8T3WB5B97LNmTbUQOTXedfBODZsl/d8kPFltK1/J 0QCpSXV7bLZmSS9/yU3OATKadZ/DD9ysyVuds= X-IronPort-AV: E=Sophos;i="5.88,314,1635220800"; d="scan'208";a="62618907" From: Anthony PERARD To: CC: Anthony PERARD , Andrew Cooper , George Dunlap , "Jan Beulich" , Julien Grall , "Stefano Stabellini" , Wei Liu , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [XEN PATCH v9 01/30] build: set XEN_BUILD_EFI earlier Date: Tue, 25 Jan 2022 11:00:34 +0000 Message-ID: <20220125110103.3527686-2-anthony.perard@citrix.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220125110103.3527686-1-anthony.perard@citrix.com> References: <20220125110103.3527686-1-anthony.perard@citrix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1643108513846100002 Content-Type: text/plain; charset="utf-8" We are going to need the variable XEN_BUILD_EFI earlier. But a side effect of calculating the value of $(XEN_BUILD_EFI) is to also to generate "efi/check.o" which is used for further checks. Thus the whole chain that check for EFI support is moved to "arch.mk". Some other changes are made to avoid too much duplication: - $(efi-check): Used to avoid repeating "efi/check.*". We don't set it to the path to the source as it would be wrong as soon as we support out-of-tree build. - $(LD_PE_check_cmd): As it is called twice, with an updated $(EFI_LDFLAGS). $(nr-fixups) is renamed to $(efi-nr-fixups) as the former might be a bit too generic. In order to avoid exporting MKRELOC, the variable is added to $(MAKE) command line. The only modification needed is in target "build", the modification target "$(TARGET)" will be needed with a following patch "build: avoid re-executing the main Makefile by introducing build.mk". We can now revert 24b0ce9a5da2, we don't need to override efi-y on recursion anymore. Signed-off-by: Anthony PERARD Reviewed-by: Jan Beulich --- Notes: v9: - change $(efi-check) to hold the $(basename ) of check.c, and rename the variable from $(efi-check-0). - unexport MKRELOC, pass it down via command line instead. - remove efi-y override which reverts 24b0ce9a5da2 =20 v8: - rename to efi-nr-fixups rather than efi-check-relocs - use :=3D when assigning variable in makefile when recursive expansion isn't needed. - no more check of $(efi-y) value for "CFLAGS-$(XEN_BUILD_EFI) +=3D -DXEN_BUILD_EFI". =20 v7: - Do the whole check for EFI support in arch.mk. So efi/check.o is produce there and used there, and produce efi/check.efi and use it th= ere. Thus avoid the need to repeat the test done for XEN_BUILD_EFI. xen/Makefile | 4 ++-- xen/arch/x86/Makefile | 46 ++++++------------------------------------- xen/arch/x86/arch.mk | 42 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 42 deletions(-) diff --git a/xen/Makefile b/xen/Makefile index 1e10d9f68080..f3ff03a7170e 100644 --- a/xen/Makefile +++ b/xen/Makefile @@ -296,7 +296,7 @@ endif # need-config .PHONY: build install uninstall clean distclean MAP build install uninstall debug clean distclean MAP:: ifneq ($(XEN_TARGET_ARCH),x86_32) - $(MAKE) -f Rules.mk _$@ + $(MAKE) -f Rules.mk MKRELOC=3D$(MKRELOC) _$@ else echo "*** Xen x86/32 target no longer supported!" endif @@ -404,7 +404,7 @@ $(TARGET): FORCE $(MAKE) -f $(BASEDIR)/Rules.mk -C include $(MAKE) -f $(BASEDIR)/Rules.mk -C arch/$(TARGET_ARCH) include $(MAKE) -f $(BASEDIR)/Rules.mk arch/$(TARGET_ARCH)/include/asm/asm-offset= s.h - $(MAKE) -f $(BASEDIR)/Rules.mk -C arch/$(TARGET_ARCH) $@ + $(MAKE) -f $(BASEDIR)/Rules.mk -C arch/$(TARGET_ARCH) MKRELOC=3D$(MKRELOC= ) $@ =20 quiet_cmd_banner =3D BANNER $@ define cmd_banner diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index 8db4cb98edbb..9fc884813cb5 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -121,44 +121,8 @@ $(TARGET): $(TARGET)-syms $(efi-y) boot/mkelf32 { echo "No Multiboot2 header found" >&2; false; } mv $(TMP) $(TARGET) =20 -ifneq ($(efi-y),) - -# Check if the compiler supports the MS ABI. -export XEN_BUILD_EFI :=3D $(shell $(CC) $(XEN_CFLAGS) -c efi/check.c -o ef= i/check.o 2>/dev/null && echo y) CFLAGS-$(XEN_BUILD_EFI) +=3D -DXEN_BUILD_EFI =20 -# Check if the linker supports PE. -EFI_LDFLAGS =3D $(patsubst -m%,-mi386pep,$(XEN_LDFLAGS)) --subsystem=3D10 -XEN_BUILD_PE :=3D $(if $(XEN_BUILD_EFI),$(call ld-option,$(EFI_LDFLAGS) --= image-base=3D0x100000000 -o efi/check.efi efi/check.o)) -# If the above failed, it may be merely because of the linker not dealing = well -# with debug info. Try again with stripping it. -ifeq ($(CONFIG_DEBUG_INFO)-$(XEN_BUILD_PE),y-n) -EFI_LDFLAGS +=3D --strip-debug -XEN_BUILD_PE :=3D $(call ld-option,$(EFI_LDFLAGS) --image-base=3D0x1000000= 00 -o efi/check.efi efi/check.o) -endif - -ifeq ($(XEN_BUILD_PE),y) - -# Check if the linker produces fixups in PE by default -nr-fixups :=3D $(shell $(OBJDUMP) -p efi/check.efi | grep '^[[:blank:]]*re= loc[[:blank:]]*[0-9][[:blank:]].*DIR64$$' | wc -l) -ifeq ($(nr-fixups),2) -MKRELOC :=3D : -relocs-dummy :=3D -else -MKRELOC :=3D efi/mkreloc -relocs-dummy :=3D efi/relocs-dummy.o -# If the linker produced fixups but not precisely two of them, we need to -# disable it doing so. But if it didn't produce any fixups, it also would= n't -# recognize the option. -ifneq ($(nr-fixups),0) -EFI_LDFLAGS +=3D --disable-reloc-section -endif -endif - -endif # $(XEN_BUILD_PE) - -endif # $(efi-y) - ALL_OBJS :=3D $(BASEDIR)/arch/x86/boot/built_in.o $(BASEDIR)/arch/x86/efi/= built_in.o $(ALL_OBJS) =20 ifeq ($(CONFIG_LTO),y) @@ -182,13 +146,13 @@ $(TARGET)-syms: prelink.o xen.lds $(NM) -pa --format=3Dsysv $(@D)/.$(@F).0 \ | $(BASEDIR)/tools/symbols $(all_symbols) --sysv --sort \ >$(@D)/.$(@F).0.S - $(MAKE) -f $(BASEDIR)/Rules.mk efi-y=3D $(@D)/.$(@F).0.o + $(MAKE) -f $(BASEDIR)/Rules.mk $(@D)/.$(@F).0.o $(LD) $(XEN_LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \ $(@D)/.$(@F).0.o -o $(@D)/.$(@F).1 $(NM) -pa --format=3Dsysv $(@D)/.$(@F).1 \ | $(BASEDIR)/tools/symbols $(all_symbols) --sysv --sort $(syms-warn-dup-= y) \ >$(@D)/.$(@F).1.S - $(MAKE) -f $(BASEDIR)/Rules.mk efi-y=3D $(@D)/.$(@F).1.o + $(MAKE) -f $(BASEDIR)/Rules.mk $(@D)/.$(@F).1.o $(LD) $(XEN_LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \ $(@D)/.$(@F).1.o -o $@ $(NM) -pa --format=3Dsysv $(@D)/$(@F) \ @@ -217,8 +181,10 @@ endif =20 $(TARGET).efi: VIRT_BASE =3D 0x$(shell $(NM) efi/relocs-dummy.o | sed -n '= s, A VIRT_START$$,,p') ifeq ($(MKRELOC),:) +relocs-dummy :=3D $(TARGET).efi: ALT_BASE :=3D else +relocs-dummy :=3D efi/relocs-dummy.o $(TARGET).efi: ALT_BASE =3D 0x$(shell $(NM) efi/relocs-dummy.o | sed -n 's= , A ALT_START$$,,p') endif =20 @@ -250,14 +216,14 @@ endif $(MKRELOC) $(foreach base,$(VIRT_BASE) $(ALT_BASE),$(@D)/.$(@F).$(base).0= ) >$(@D)/.$(@F).0r.S $(NM) -pa --format=3Dsysv $(@D)/.$(@F).$(VIRT_BASE).0 \ | $(BASEDIR)/tools/symbols $(all_symbols) --sysv --sort >$(@D)/.$(@F).0s= .S - $(MAKE) -f $(BASEDIR)/Rules.mk efi-y=3D $(@D)/.$(@F).0r.o $(@D)/.$(@F).0s= .o + $(MAKE) -f $(BASEDIR)/Rules.mk $(@D)/.$(@F).0r.o $(@D)/.$(@F).0s.o $(foreach base, $(VIRT_BASE) $(ALT_BASE), \ $(LD) $(call EFI_LDFLAGS,$(base)) -T efi.lds -N $< \ $(@D)/.$(@F).0r.o $(@D)/.$(@F).0s.o $(note_file_option) -= o $(@D)/.$(@F).$(base).1 &&) : $(MKRELOC) $(foreach base,$(VIRT_BASE) $(ALT_BASE),$(@D)/.$(@F).$(base).1= ) >$(@D)/.$(@F).1r.S $(NM) -pa --format=3Dsysv $(@D)/.$(@F).$(VIRT_BASE).1 \ | $(BASEDIR)/tools/symbols $(all_symbols) --sysv --sort >$(@D)/.$(@F).1s= .S - $(MAKE) -f $(BASEDIR)/Rules.mk efi-y=3D $(@D)/.$(@F).1r.o $(@D)/.$(@F).1s= .o + $(MAKE) -f $(BASEDIR)/Rules.mk $(@D)/.$(@F).1r.o $(@D)/.$(@F).1s.o $(LD) $(call EFI_LDFLAGS,$(VIRT_BASE)) -T efi.lds -N $< \ $(@D)/.$(@F).1r.o $(@D)/.$(@F).1s.o $(note_file_option) -= o $@ $(NM) -pa --format=3Dsysv $(@D)/$(@F) \ diff --git a/xen/arch/x86/arch.mk b/xen/arch/x86/arch.mk index eea320e618b9..a93fa6d2e4c9 100644 --- a/xen/arch/x86/arch.mk +++ b/xen/arch/x86/arch.mk @@ -60,5 +60,47 @@ ifeq ($(CONFIG_UBSAN),y) $(call cc-option-add,CFLAGS_UBSAN,CC,-fno-sanitize=3Dalignment) endif =20 +ifneq ($(CONFIG_PV_SHIM_EXCLUSIVE),y) + +efi-check :=3D arch/x86/efi/check + +# Check if the compiler supports the MS ABI. +XEN_BUILD_EFI :=3D $(call if-success,$(CC) $(CFLAGS) -c $(efi-check).c -o = $(efi-check).o,y) + +# Check if the linker supports PE. +EFI_LDFLAGS :=3D $(patsubst -m%,-mi386pep,$(LDFLAGS)) --subsystem=3D10 +LD_PE_check_cmd =3D $(call ld-option,$(EFI_LDFLAGS) --image-base=3D0x10000= 0000 -o $(efi-check).efi $(efi-check).o) +XEN_BUILD_PE :=3D $(LD_PE_check_cmd) + +# If the above failed, it may be merely because of the linker not dealing = well +# with debug info. Try again with stripping it. +ifeq ($(CONFIG_DEBUG_INFO)-$(XEN_BUILD_PE),y-n) +EFI_LDFLAGS +=3D --strip-debug +XEN_BUILD_PE :=3D $(LD_PE_check_cmd) +endif + +ifeq ($(XEN_BUILD_PE),y) + +# Check if the linker produces fixups in PE by default +efi-nr-fixups :=3D $(shell $(OBJDUMP) -p $(efi-check).efi | grep '^[[:blan= k:]]*reloc[[:blank:]]*[0-9][[:blank:]].*DIR64$$' | wc -l) + +ifeq ($(efi-nr-fixups),2) +MKRELOC :=3D : +else +MKRELOC :=3D efi/mkreloc +# If the linker produced fixups but not precisely two of them, we need to +# disable it doing so. But if it didn't produce any fixups, it also would= n't +# recognize the option. +ifneq ($(efi-nr-fixups),0) +EFI_LDFLAGS +=3D --disable-reloc-section +endif +endif + +endif # $(XEN_BUILD_PE) + +export XEN_BUILD_EFI XEN_BUILD_PE +export EFI_LDFLAGS +endif + # Set up the assembler include path properly for older toolchains. CFLAGS +=3D -Wa,-I$(BASEDIR)/include --=20 Anthony PERARD