From nobody Sun Nov 24 15:21:06 2024 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=1724340638; cv=none; d=zohomail.com; s=zohoarc; b=RRtBqdnsMV8rIxMSzKTO8ABVYsHsTBqF7ctTkzyrNG2mCn9ZH5jZMXiD3pGH36q3KFSxU+RVCMTmwMiigWcAEk7CSse1j3qICTToKeZWKjAtmKdKq+jsr6Ln+kwmOaN7XIHdsQEL0lFohNF9HAl6W7GhPZWovqeuOGbie7h+HhA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724340638; 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=H8/O+XAPl/QbSGBgMlq8pwRffeZEEcEmslfFS5zb4s8=; b=fW0Reo7XQ3uQBN+ao6E9/IBxYUB4hi3o6thS38QrML0+356ayKJ8wVPifuWRJsuWfzcCAQajAzGD9/bBa8wzt+TmigowJZY67klEJTA7cxEDMgPbuJBFGH+FwtqBuPSmNhniyRt7IGZXNFXWn2706XsBB7Lw6yfR12wFdKEsRH4= 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 1724340638925190.54763651143162; Thu, 22 Aug 2024 08:30:38 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.781923.1191416 (Exim 4.92) (envelope-from ) id 1sh9lK-0008Qr-TR; Thu, 22 Aug 2024 15:30:10 +0000 Received: by outflank-mailman (output) from mailman id 781923.1191416; Thu, 22 Aug 2024 15:30:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sh9lK-0008Qk-Qa; Thu, 22 Aug 2024 15:30:10 +0000 Received: by outflank-mailman (input) for mailman id 781923; Thu, 22 Aug 2024 15:30:10 +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 1sh9lK-0008Qe-1V for xen-devel@lists.xenproject.org; Thu, 22 Aug 2024 15:30:10 +0000 Received: from mail-ot1-x332.google.com (mail-ot1-x332.google.com [2607:f8b0:4864:20::332]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 69296f36-609b-11ef-a50a-bb4a2ccca743; Thu, 22 Aug 2024 17:30:08 +0200 (CEST) Received: by mail-ot1-x332.google.com with SMTP id 46e09a7af769-7093472356dso634401a34.0 for ; Thu, 22 Aug 2024 08:30:07 -0700 (PDT) Received: from fziglio-xenia-fedora.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-454fe0f436dsm7786131cf.49.2024.08.22.08.30.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 08:30:06 -0700 (PDT) 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: 69296f36-609b-11ef-a50a-bb4a2ccca743 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1724340606; x=1724945406; 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=H8/O+XAPl/QbSGBgMlq8pwRffeZEEcEmslfFS5zb4s8=; b=AX8NugHCZScxNDibQvrPW3myN8hrtL96DRJ4odKO9w3QKPnnFC7ETXeskMar6JRV+W Nv08ZzpuSUq2gWbACnkm4G6HoDMxHFtBVf+A+tDNwh74HG/TZiG7uRRd748llKxr7jhF oXkhE7C2A0BS50wRgWHYzYLpSIoILTRxt4vLY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724340606; x=1724945406; 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=H8/O+XAPl/QbSGBgMlq8pwRffeZEEcEmslfFS5zb4s8=; b=syXFNBJfMI8Hye1FKuEmGBi35xWqc6/U/D6Ng+JU7+gVN1MafAlomOmPHbQskIC4Pb DJSUMn3yh+EFlopMO78K70s3pVyhSJM/+815hDaBIOfC5rk8r3T5FkowDJNVdCn0e8a/ f401UqytBbOaM7WL0pRA141IHTkr38ws99u6FdXxBKPvjRIYL6ZP+sqLeIPEddZSeI9g b/FUsszyWDxNV/fOWtBOZl0j1srNxYOmKfqbxFeorBvEMXOzRGBiyicfT1GGdctlJcLc dlI4Y1P8NpRehC2ORokw8MlcsKH96fhSjcpdunuYTyjbVSsGQKy11YwC5QPPUqk0IrMY UicA== X-Gm-Message-State: AOJu0YyFKHec7GsVstZNe8tSwrBrBQQJyNp4b57UJTkD6v9jX0HvJCv8 rat6Kq65uwl94HD35kSDfOCHOd+dUg6tFHHZQRvObkdSE0wuaIxi5nZJt4xdduT89yuAvY/OVeO Q X-Google-Smtp-Source: AGHT+IHojBVGHlDnRnHtYNhrvvyH3Ndv53rdneGOEakuYJ4P94fC6ZKkytP2uY0gFCQDmiUZkibDlA== X-Received: by 2002:a05:6808:2226:b0:3d9:245c:4225 with SMTP id 5614622812f47-3de19c77a7fmr7450539b6e.6.1724340606557; Thu, 22 Aug 2024 08:30:06 -0700 (PDT) From: Frediano Ziglio To: xen-devel@lists.xenproject.org Cc: Frediano Ziglio , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , "Alejandro Vallejo" Subject: [PATCH] Avoid additional relocations in trampoline code Date: Thu, 22 Aug 2024 16:29:51 +0100 Message-ID: <20240822152953.489136-1-frediano.ziglio@cloud.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1724340641064116600 Content-Type: text/plain; charset="utf-8" The trampoline could have "manual" relocation entries (created by assembly macros and some code to use them) and (in case of PE) normal executable relocations. Remove all normal executable ones. In this way we don't have to worry about applying both correctly (they need proper order which is hard to spot looking at the code). Signed-off-by: Frediano Ziglio --- xen/arch/x86/boot/trampoline.S | 4 ++-- xen/arch/x86/boot/wakeup.S | 6 +++--- xen/arch/x86/xen.lds.S | 7 ++++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/boot/trampoline.S b/xen/arch/x86/boot/trampoline.S index b8ab0ffdcb..0724c953e2 100644 --- a/xen/arch/x86/boot/trampoline.S +++ b/xen/arch/x86/boot/trampoline.S @@ -73,7 +73,7 @@ trampoline_protmode_entry: mov %ecx,%cr4 =20 /* Load pagetable base register. */ - mov $sym_offs(idle_pg_table),%eax + mov $idle_pg_table_pa, %eax add bootsym_rel(trampoline_xen_phys_start,4,%eax) mov %eax,%cr3 =20 @@ -113,7 +113,7 @@ trampoline_protmode_entry: .code64 start64: /* Jump to high mappings. */ - movabs $__high_start, %rdi + movabs $__high_start_pa + __XEN_VIRT_START, %rdi jmpq *%rdi =20 #include "video.h" diff --git a/xen/arch/x86/boot/wakeup.S b/xen/arch/x86/boot/wakeup.S index 08447e1934..ebe72e1fdd 100644 --- a/xen/arch/x86/boot/wakeup.S +++ b/xen/arch/x86/boot/wakeup.S @@ -99,7 +99,7 @@ wakeup_32: mov $bootsym_rel(wakeup_stack, 4, %esp) =20 # check saved magic again - mov $sym_offs(saved_magic),%eax + mov $saved_magic_pa, %eax add bootsym_rel(trampoline_xen_phys_start, 4, %eax) mov (%eax), %eax cmp $0x9abcdef0, %eax @@ -112,7 +112,7 @@ wakeup_32: mov %ecx, %cr4 =20 /* Load pagetable base register */ - mov $sym_offs(idle_pg_table),%eax + mov $idle_pg_table_pa ,%eax add bootsym_rel(trampoline_xen_phys_start,4,%eax) mov %eax,%cr3 =20 @@ -156,7 +156,7 @@ wakeup_32: .code64 wakeup_64: /* Jump to high mappings and the higher-level wakeup code. */ - movabs $s3_resume, %rbx + movabs $s3_resume_pa + __XEN_VIRT_START, %rbx jmp *%rbx =20 bogus_saved_magic: diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S index 9a1dfe1b34..8e604dde48 100644 --- a/xen/arch/x86/xen.lds.S +++ b/xen/arch/x86/xen.lds.S @@ -71,7 +71,12 @@ SECTIONS __2M_text_start =3D .; /* Start of 2M superpages, mapped RX. */ #endif =20 - start_pa =3D ABSOLUTE(start - __XEN_VIRT_START); +#define DEFINE_PA_ADDRESS(sym) sym ## _pa =3D ABSOLUTE(sym - __XEN_VIRT_ST= ART) + DEFINE_PA_ADDRESS(start); + DEFINE_PA_ADDRESS(saved_magic); + DEFINE_PA_ADDRESS(idle_pg_table); + DEFINE_PA_ADDRESS(__high_start); + DEFINE_PA_ADDRESS(s3_resume); =20 . =3D __XEN_VIRT_START + XEN_IMG_OFFSET; _start =3D .; --=20 2.46.0