From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.4135.1591660848434598492 for ; Mon, 08 Jun 2020 17:00:48 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=tXw18W1T; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: jiewen.yao@intel.com) IronPort-SDR: LHl49tW3jPjuArSz2GEQV6BOcWcOL9LEmfl7wVEh/l7wMpvh35sh8KJ+HaLOP4h88ZLU6VGzqu YspynAWk4mfw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jun 2020 17:00:47 -0700 IronPort-SDR: BzXFCrycXA66cj9biyPWBiI4iacCf+7VDMcaASazv40kQiJYasLuGiLDbjhVD5YmYFqTKTp8eS hKCPGsaW4wGw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,489,1583222400"; d="scan'208";a="472885722" Received: from orsmsx109.amr.corp.intel.com ([10.22.240.7]) by fmsmga005.fm.intel.com with ESMTP; 08 Jun 2020 17:00:47 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX109.amr.corp.intel.com (10.22.240.7) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 8 Jun 2020 17:00:46 -0700 Received: from orsmsx604.amr.corp.intel.com (10.22.229.17) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 8 Jun 2020 17:00:45 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by orsmsx604.amr.corp.intel.com (10.22.229.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Mon, 8 Jun 2020 17:00:45 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.107) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 8 Jun 2020 17:00:43 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Nc18798PrN2KN6uhzOFEnbD93TGnAypbZrD9BNgKq36KEw82zqOfvdQlkg64BlLi+C/fniS9FtvgPGPjvJCCbT+lkSuoY4CDSBRSPm8qTH3PoMaTfnakbim5LFvzfRYaMqENJbk15h44YmMftonCAaoUT58I+XmGJjikLinwi/CJzeziCGPSRWu2ihhjgOgsornpPuecbrhGZu97/9TNKjlKMZ5jGZnI4O34A0qFmxk+1NyGs9zzeW7etsmQAbWb7KOu6uu0SpmcTsyboYXCUji/mculKqiC5nRSRUGLUitI/RsJM2zHDjQmMvb5bCR+fUn7SACM09OUJ24d5PYBbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BRstsQ9bRD4Fjj+m5A4URAdExNhDG9ZQeUudTLxKnbo=; b=kLyau3XMcY3PKHoZ80VJviB8j3tACgd67J3JvohkV93GYvp8PitT59VHtgiTAcUW3z6LD3kD9jUmJS3XRNmhzHlfsvLSnSzgajPVxuO0yVp5S3u+cmzADwDTa/VmI2VhYG6f+fyZQEZg3iaUVRJbhrFqx/FzgSQHoMbnYlbZ/nFOpdz8KPnq8b7VbAUiIQ/A9NcfUpWynCFrTSCI+kpe4BQznpE8DBAhbvbaNwYhRQ+USiWoFuPY07KLyIWUcccJJAzf2iGCrfN9RI8RGX+P26pquGVWhlMipU/ovYsnyjkEkyWoudOPYPmUCqGs1hRs/Bxu2Vl2jj/i0EOs+anR2w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BRstsQ9bRD4Fjj+m5A4URAdExNhDG9ZQeUudTLxKnbo=; b=tXw18W1TMNVjwk1K1y0bDGMZIPTDUujHBFUPAQG5mTGAwYAlg1mb09J6jVeaqKFUZc20lbwKmgyDqnRC9/3IcsFv6rbiigdxvFRjbnaLdlFiYNqy5cCvw7X5Rs2nqYu9kUcAMmctnnRjJpdlSAlEf1zPQqHi1Al9U28LwEGzMrk= Received: from BL0PR11MB3412.namprd11.prod.outlook.com (2603:10b6:208:7c::32) by BL0PR11MB3107.namprd11.prod.outlook.com (2603:10b6:208:7c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.22; Tue, 9 Jun 2020 00:00:40 +0000 Received: from BL0PR11MB3412.namprd11.prod.outlook.com ([fe80::a0dd:b860:2661:de87]) by BL0PR11MB3412.namprd11.prod.outlook.com ([fe80::a0dd:b860:2661:de87%6]) with mapi id 15.20.3066.023; Tue, 9 Jun 2020 00:00:40 +0000 From: "Yao, Jiewen" To: Ard Biesheuvel , "devel@edk2.groups.io" CC: "Feng, Bob C" , "Gao, Liming" , Laszlo Ersek , Leif Lindholm , Ilias Apalodimas , "Julien Grall" Subject: Re: [PATCH 0/4] ArmVirtPkg: use PE/COFF metadata for self relocation Thread-Topic: [PATCH 0/4] ArmVirtPkg: use PE/COFF metadata for self relocation Thread-Index: AQHWPbsXY5lKo7BHCEWT/F98m5bhFKjPZkyw Date: Tue, 9 Jun 2020 00:00:40 +0000 Message-ID: References: <20200608173413.1100679-1-ard.biesheuvel@arm.com> In-Reply-To: <20200608173413.1100679-1-ard.biesheuvel@arm.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiN2Q5NWJlODQtMmU0NC00ZDlmLThhZTQtYjcyZDAyNDUzOTEzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiOEcxVHhaWmVUbzFEQXQ0anpUK1lPc3lCRVMxcmRiaDBVcU96NHpGQjNjcThNbkRHUnR1NjFEdGkxOGkyTWQzTiJ9 x-ctpclassification: CTP_NT dlp-version: 11.2.0.6 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.52.209] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1f573a0d-e91e-459c-dd75-08d80c0825a9 x-ms-traffictypediagnostic: BL0PR11MB3107: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-forefront-prvs: 042957ACD7 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: KeLv9+vtWcZL4yf4Yrp+1nhypxNJ6/zmamnedxU4vlLnHFRTEL63r0o/2F2fgK1tNrOjGEHut4m6dHWOv1aFnuxWVA41fumt55fAk4Jk8oHO0akQ+8bMJicJhvK5UsZpWSO0XTihqnGHAw1yAqdFYZcDAjgkJUpqJ/RrGqhnbzWfw9QklhRvoxXJi7k/e6eJ/evxQHSLaSB2wnnDaWK9XI5gHLPoOO1jcq5nrCgCBq5CcWdgHyBk5PMpTC2f3sFwcTq5PXHGReeO7qfacDTg5sja4boJvLAfaPCfYfPubQ0+mcSAlxw1iuzrCw58i+e88Qw5VOrfHL3Zuu5c8ARPqYZj+OBEQJ6hD/nP6NdaaAw4sbu/7kQsONh5fVSxmCWYT+P4ThWTgbYq17X0uDEvKQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL0PR11MB3412.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(376002)(346002)(39860400002)(396003)(136003)(366004)(966005)(110136005)(54906003)(4326008)(5660300002)(52536014)(33656002)(66556008)(76116006)(66946007)(83380400001)(64756008)(66446008)(86362001)(7696005)(66476007)(8936002)(2906002)(8676002)(71200400001)(55016002)(6506007)(478600001)(9686003)(53546011)(19627235002)(26005)(316002)(186003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: V+S7dm6zQRJIwzLCCOrLlkjPjSXP/4oxJst0al3a3cuNUP3L1dEo9cmXgP+8RosVGHyCwiBT7lvHm9i7XZ2sjq5V+/JioYx1+Qwgu6JodXkXtrM5d2HpOHsdXjzMQpXzwU7O+8b/DmF0LSJ2LJc3vGDKK4PnpirFOgnaiZRwNN95timn0gUdGZX6bFB9gX7udm1O2+xc98JjwO2OUKDXwuM54VI1w7XI5yHOf0vq3scbVIBLLCDzGymKb97XaAWcQJceZuSaHSpNaZDE2RktE9a4G17s4rwsTQynX6UL4KmhY7X53z/gUQPYHsdUEHE0EFl6aWlwhbODwIYam4CXUVYLL4l2QEa5ra4gwuSQtcUzIrPvFFSMAoFALquq9JS6UzkD/Tgfn9bLhLW8oC1lGXJLqFpBF7RDo04ccMnq5SPm9nOAwLLpzTHAzrazne9BNoMaldrjyiTNWEMvwZBRt7sXlW6EVwuviKKM2Zw2YGNYQ1wLoCvnvOh4MFiVIECi MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 1f573a0d-e91e-459c-dd75-08d80c0825a9 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Jun 2020 00:00:40.1617 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: OoVnhpKxd3fGmaWwt6C+/WX2eOt2DDAdo1M2JaWBYMtTSoZJNSou8gDH1NU1DH4gYgGZzQAJ7slHJdoPd9KsJA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR11MB3107 Return-Path: jiewen.yao@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Thank you Ard. Good catch on jump-table stuff. Acked-by: Jiewen Yao > -----Original Message----- > From: Ard Biesheuvel > Sent: Tuesday, June 9, 2020 1:34 AM > To: devel@edk2.groups.io > Cc: Ard Biesheuvel ; Feng, Bob C > ; Gao, Liming ; Laszlo Ersek > ; Leif Lindholm ; Ilias Apalodimas > ; Julien Grall ; Yao, Jiewen > > Subject: [PATCH 0/4] ArmVirtPkg: use PE/COFF metadata for self relocation >=20 > As suggested by Jiewen in response to Ilias RFC [0], it is better to use > the PE/COFF metadata for self-relocating executables than to rely on ELF > metadata, given how the latter is only available when using ELF based > toolchains. Also, we have had some maintenance issues with this code in > the past, as PIE linking of non-position independent objects is not a wel= l > tested code path in toolchains in general. >=20 > So implement this for the self-relocating PrePi in ArmVirtPkg first. >=20 > First, we need to ensure that the module in question is emitted with its > PE/COFF relocation metadata preserved, by creating a special FDF rule. >=20 > We also need to provide a way for the code to refer to the start of the > image directly, by adding it to the linker script. >=20 > Then, it is simply a matter of swapping out the two assembly routines, > and adding the C code that serves the same purpose but based on PE/COFF > base relocations. >=20 > Note that PE/COFF relocations are considerably more compact than ELF RELA > relocations, so this does not impact the memory footprint of the resultin= g > image adversely. >=20 > [0] https://edk2.groups.io/g/devel/message/60835 >=20 > Cc: Bob Feng > Cc: Liming Gao > Cc: Laszlo Ersek > Cc: Leif Lindholm > Cc: Ilias Apalodimas > Cc: Julien Grall > Cc: Jiewen Yao >=20 > Ard Biesheuvel (4): > ArmVirtPkg: add FDF rule for self-relocating PrePi > BaseTools/Scripts/GccBase.lds: export image base symbol > ArmVirtPkg/PrePi: use standard PeCoff routines for self-relocation > ArmVirtPkg: remove unused files >=20 > ArmVirtPkg/ArmVirtQemuKernel.dsc | 10 ++-- > ArmVirtPkg/ArmVirtXen.dsc | 10 ++-- > ArmVirtPkg/ArmVirtQemuKernel.fdf | 2 +- > ArmVirtPkg/ArmVirtXen.fdf | 2 +- > ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf | 4 +- > ArmVirtPkg/Include/Platform/Hidden.h | 22 --------- > ArmVirtPkg/PrePi/PrePi.c | 21 +++++++++ > ArmVirtPkg/ArmVirtRules.fdf.inc | 5 ++ > ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S | 49 +++++----------= ----- > ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S | 47 +++++----------= ---- > ArmVirtPkg/PrePi/Scripts/PrePi-PIE.lds | 41 ---------------= - > BaseTools/Scripts/GccBase.lds | 2 + > 12 files changed, 63 insertions(+), 152 deletions(-) > delete mode 100644 ArmVirtPkg/Include/Platform/Hidden.h > delete mode 100644 ArmVirtPkg/PrePi/Scripts/PrePi-PIE.lds >=20 > -- > 2.26.2