From nobody Wed Feb 5 12:50:58 2025 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=cloud.com ARC-Seal: i=1; a=rsa-sha256; t=1736855698; cv=none; d=zohomail.com; s=zohoarc; b=MymQVrQGitUChFTUyEGd22iNROdmO3w1NCta3rrz+pkKk2Ey8S6v/6f+S1464KFWNRSMAbPXXNqmlOy56vAeNot2iU5F0eMvhQEmkjIPcSwjLQ6a2XVSPLD0nhuLcb63cSMA9yhZFQQwq/P0tltWkZ65xTIoszY/LglQ4lXO/3c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1736855698; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Y85RMcDcdplXx55rxPoCT7LP+dU+Acd11R/HOfjnmew=; b=nHYk4bTXz5+FnA4gkQeWRf/ibUvLJR0l3Rid87c8PGLanFSZ1DW/neHdP1wzx0lzJeVEQ3chflfdMBBtKbJbOon5/14bNEook01kyoNcLCZXspK6GDxgF7V50F0luI5wKz49lr4wQuoWxxRynIzVvqTJJmVUqCU0zX/H4wwCoQ0= 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 1736855698159250.29781715898105; Tue, 14 Jan 2025 03:54:58 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.871290.1282320 (Exim 4.92) (envelope-from ) id 1tXfVK-0003IO-QR; Tue, 14 Jan 2025 11:54:42 +0000 Received: by outflank-mailman (output) from mailman id 871290.1282320; Tue, 14 Jan 2025 11:54:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tXfVK-0003IH-Nc; Tue, 14 Jan 2025 11:54:42 +0000 Received: by outflank-mailman (input) for mailman id 871290; Tue, 14 Jan 2025 11:54:41 +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 1tXfVJ-0003IA-0d for xen-devel@lists.xenproject.org; Tue, 14 Jan 2025 11:54:41 +0000 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [2a00:1450:4864:20::329]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 55b07885-d26e-11ef-a0e1-8be0dac302b0; Tue, 14 Jan 2025 12:54:39 +0100 (CET) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-43625c4a50dso38629945e9.0 for ; Tue, 14 Jan 2025 03:54:39 -0800 (PST) Received: from localhost.localdomain (158.79.208.46.dyn.plus.net. [46.208.79.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436ed48f4b2sm160187495e9.24.2025.01.14.03.54.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 03:54:38 -0800 (PST) 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: 55b07885-d26e-11ef-a0e1-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1736855679; x=1737460479; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Y85RMcDcdplXx55rxPoCT7LP+dU+Acd11R/HOfjnmew=; b=U5+VzOgxIFUKQkrgqDsuudGX7tycZLaHUh6wvdrJ487yLOMbnBk6lUTtJS9MdNe9PT 1lboh+TP8sC6BTMkHeEF9v2dtQLPcgirWC7/42k0v7my2KUF+fBj+8VKD/OgPAM5MJwh qv/yBbP+lQsWa18PJeetFuh4CrYEIi3Flc6FM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736855679; x=1737460479; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Y85RMcDcdplXx55rxPoCT7LP+dU+Acd11R/HOfjnmew=; b=UeOFlpM3lUZOv6RaIQlnca1rRpJlG9gSdfdkOPYmzFtN8LCY4hL0LxtFOWLlLz29fi q2iKOGlr1qlRIz5ga1WA7WqyAz/BpZoEbPv8BeUFxUk1M9qyFrIRVRYs74ZsZSjlT9N3 8AfRjwiuHzLuvy0QsFxu2/NMyrKOEV0T1grDKDL1Dnl47RRCPPqMljDk9ftdAxNMkdCm 0Xw3z5l6AUp+DLeoPCSChYx/suFOh7pTrZ8Dkb3Xx0rgrlhzUFfIb9xCTM1hrfXKey7E EyGs4S8BiX70Zv00NtNUezjMJhx2g0iwEWk3G4J7CfX6iRGcdPodF4y6jXBGUAd3kdAi DAGg== X-Gm-Message-State: AOJu0Yz2Nogm2Hl0ckLgcTbcCGfvamBZGWXj8bnJnOsVP2f6u4IWLU8Z f2s8nYRsOY4EmF+LgqJnjCMoJQ0V3EtjlsmQbPpIsd3K7m3Osj16XEAD9QX2G4BRPQg5Rz3MjZE 8 X-Gm-Gg: ASbGncvK48/egECfh51tlTSqF9kHYLoaudLM9ha4ioUU0bRxGH1eX7uQjmHu1TxrZCf ho192sKc+vxw08Xm/yD3zAZ8qr13VZZ1IYu7y5U/0gTcOyn+1Ekxq9qbA2ZvAegrQc5/zU4Z8Xh To1XJo+naXGZJaf90J2rK5ACkB7wnAtacEg3zeSRHFNPXe2w0lygLV9ZJ+7TP5kRHxtmjZgNfVx KEBFFdCThIHMxfGDPeGaPvy/kkVm762sU8uCAgKhPCTmEuArw1XTC39Qa2JyZMg0shoLhejG9bL bnEgj2wHJWSgzH+GzrZhz9ajteg= X-Google-Smtp-Source: AGHT+IGATqBTzThg/NHUDRGkbKgnJSwL/iLwQrLZqisIJB9AcK6h2aIzUMRL6BFym81BO7yJ2o+PVA== X-Received: by 2002:a05:600c:4713:b0:434:ff08:202b with SMTP id 5b1f17b1804b1-436e26970bcmr230811895e9.12.1736855679019; Tue, 14 Jan 2025 03:54:39 -0800 (PST) From: Frediano Ziglio To: xen-devel@lists.xenproject.org Cc: Frediano Ziglio , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Julien Grall , Stefano Stabellini Subject: [PATCH v2] x86/boot: Handle better alignment for 32 bit code Date: Tue, 14 Jan 2025 11:54:30 +0000 Message-Id: <20250114115430.104084-1-frediano.ziglio@cloud.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1736855699334019000 Content-Type: text/plain; charset="utf-8" Output file didn't have correct alignment. Allows alignment into data or code up to 2mb. Intermediate object files are kept in order to copy alignment from object produced by the linker and final object (produced by combine_two_binaries.py script). Signed-off-by: Frediano Ziglio --- xen/arch/x86/boot/Makefile | 12 ++++++++---- xen/tools/combine_two_binaries.py | 7 ++++++- 2 files changed, 14 insertions(+), 5 deletions(-) Changes since v1: - Improve comments and description. diff --git a/xen/arch/x86/boot/Makefile b/xen/arch/x86/boot/Makefile index 13d4583173..a56d8a7e0f 100644 --- a/xen/arch/x86/boot/Makefile +++ b/xen/arch/x86/boot/Makefile @@ -40,8 +40,12 @@ LD32 :=3D $(LD) $(subst x86_64,i386,$(LDFLAGS_DIRECT)) # are affected by both text_diff and text_gap. Ensure the sum of gap and = diff # is greater than 2^16 so that any 16bit relocations if present in the obj= ect # file turns into a build-time error. -text_gap :=3D 0x010200 -text_diff :=3D 0x408020 +# As gap will affect the output section size it should not be huge to avoi= d the +# creation of huge files. +# The sum of gap and diff will affect the possible alignment so should be a +# multiple of the possible alignment. +text_gap :=3D 0x01c240 +text_diff :=3D 0x7e3dc0 =20 $(obj)/build32.base.lds: AFLAGS-y +=3D -DGAP=3D$(text_gap) -DTEXT_DIFF=3D$= (text_diff) $(obj)/build32.offset.lds: AFLAGS-y +=3D -DGAP=3D$(text_gap) -DTEXT_DIFF= =3D$(text_diff) -DAPPLY_OFFSET @@ -69,7 +73,6 @@ $(obj)/built-in-32.%.bin: $(obj)/build32.%.lds $(obj)/bui= lt-in-32.tmp.o $(LD32) $(orphan-handling-y) -N -T $< -o $(@:bin=3Do) $(filter %.o,$^) $(NM) -p --format=3Dbsd $(@:bin=3Do) > $(@:bin=3Dmap) $(OBJCOPY) -j .text -O binary $(@:bin=3Do) $@ - rm -f $(@:bin=3Do) =20 quiet_cmd_combine =3D GEN $@ cmd_combine =3D \ @@ -80,6 +83,7 @@ cmd_combine =3D \ --bin1 $(obj)/built-in-32.base.bin \ --bin2 $(obj)/built-in-32.offset.bin \ --map $(obj)/built-in-32.base.map \ + --align $(shell $(OBJDUMP) -h $(obj)/built-in-32.base.o|= sed '/text.*2\*\*/ {s/.*2\*\*//;p;}; d') \ --exports cmdline_parse_early,reloc,reloc_trampoline32 \ --output $@ =20 @@ -90,4 +94,4 @@ $(obj)/built-in-32.S: $(obj)/built-in-32.base.bin $(obj)/= built-in-32.offset.bin $(srctree)/tools/combine_two_binaries.py FORCE $(call if_changed,combine) =20 -clean-files :=3D built-in-32.*.bin built-in-32.*.map build32.*.lds +clean-files :=3D built-in-32.*.bin built-in-32.*.map built-in-32.*.o build= 32.*.lds diff --git a/xen/tools/combine_two_binaries.py b/xen/tools/combine_two_bina= ries.py index 581e57cbc0..8e587c24fb 100755 --- a/xen/tools/combine_two_binaries.py +++ b/xen/tools/combine_two_binaries.py @@ -26,6 +26,10 @@ parser.add_argument('--text-diff', dest=3D'text_diff', required=3DTrue, type=3Dauto_int, help=3D'Difference between code section start') +parser.add_argument('--align', dest=3D'align', + default=3D2, + type=3Dauto_int, + help=3D'Alignment in power of 2') parser.add_argument('--output', dest=3D'output', help=3D'Output file') parser.add_argument('--map', dest=3D'mapfile', @@ -93,7 +97,7 @@ if size1 > size2: file1, file2 =3D file2, file1 size1, size2 =3D size2, size1 if size2 !=3D size1 + gap: - raise Exception('File sizes do not match') + raise Exception('File sizes do not match %d !=3D %d + %d' % (size2, si= ze1, gap)) del size2 =20 file1.seek(0, 0) @@ -219,6 +223,7 @@ print('''/* * File autogenerated by combine_two_binaries.py DO NOT EDIT */''', file=3Dout) print('\t' + args.section_header, file=3Dout) +print('\t.p2align\t' + str(args.align), file=3Dout) print('obj32_start:', file=3Dout) output(out) print('\n\t.section .note.GNU-stack,"",@progbits', file=3Dout) --=20 2.34.1