From patchwork Wed Aug 2 11:30:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 9876635 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6284B602BC for ; Wed, 2 Aug 2017 11:33:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4DBE12878C for ; Wed, 2 Aug 2017 11:33:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4254628795; Wed, 2 Aug 2017 11:33:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A43B42878C for ; Wed, 2 Aug 2017 11:33:07 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dcrr5-0007Yz-Px; Wed, 02 Aug 2017 11:30:23 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dcrr4-0007Yt-JE for xen-devel@lists.xenproject.org; Wed, 02 Aug 2017 11:30:22 +0000 Received: from [85.158.143.35] by server-4.bemta-6.messagelabs.com id 9D/EA-02962-DC7B1895; Wed, 02 Aug 2017 11:30:21 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrJIsWRWlGSWpSXmKPExsUSWsbIpXtme2O kQddlbYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNWPpS66C5c4Vd95MZW1gvGLfxcjFwSJwjE1i 7+JdjCCOkMAaRonjk++wdzFycvAKmEqcPL2HCcQWFoiWeLPhEyuIzSagLXFgx0kWEFtEQFni8 /OVzCA2s4CPxM3LBxhBbBYBVYkfP+6A2ZwC9hJtJw+xQCxYzSRxfMZkVoiGeomt/96BLZAAGt rZPRvI5gBaLCjxd4cwSL2EQAujxNuth5knMPLNQtIyC6EMIqwp0br9NzuErS2xbOFrZgjbVmL /1ZVQtqnE66MfGSFsRYkp3Q/ZFzCyr2JUL04tKkst0jXTSyrKTM8oyU3MzNE1NDDTy00tLk5M T81JTCrWS87P3cQIDGYGINjBOO+E/yFGSQ4mJVFexZ76SCG+pPyUyozE4oz4otKc1OJDjDIcH EoSvKbbGiOFBItS01Mr0jJzgHEFk5bg4FES4Q0BSfMWFyTmFmemQ6ROMepyvJrw/xuTEEtefl 6qlDjEDAGQoozSPLgRsBi/xCgrJczLCHSUEE9BalFuZgmq/CtGcQ5GJWHeKJApPJl5JXCbXgE dwQR0xJ86sCNKEhFSUg2MAh/rDuh7GsdHL+NdvinuZG9nyDqVr46nipmj7wVuN9p53PDb1Zqp b3O/xuwLKAhwXVeSk6rNuv7DeqcqLlbjG1xTOPrVfvw40n30dsSNzSvWMsc923SsI1aGa/lf8 U1xvCddcubo9Zb7Cy1IP7u8lneqztngc0I/brHzMs1gKHD8L5GfvGGVEktxRqKhFnNRcSIAc0 /5EewCAAA= X-Env-Sender: BATV+b75b72a48a44adce404b+5092+infradead.org+dwmw2@casper.s rs.infradead.org X-Msg-Ref: server-9.tower-21.messagelabs.com!1501673420!75983906!1 X-Originating-IP: [85.118.1.10] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 48920 invoked from network); 2 Aug 2017 11:30:20 -0000 Received: from casper.infradead.org (HELO casper.infradead.org) (85.118.1.10) by server-9.tower-21.messagelabs.com with AES256-GCM-SHA384 encrypted SMTP; 2 Aug 2017 11:30:20 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Mime-Version:Content-Type:References: In-Reply-To:Date:Cc:To:From:Subject:Message-ID:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=rTekT9/jpx191qJ4KxYiYhmHXe8Lk8Xba4WoM21KNGM=; b=p8A8uqR87QqEXdcu1u6MotWE6 gmAXiMCJo24WAASjgHcJ3d7hQ4uGUeX+P/9FeqfdLeHcFb16bYdt8o21lRzsc4EOyAP6DYybPjKMl FFq7AtgHMhlV7/Bl0t9kEDSeCmxscZGX+e3nHRNb46Rwoo8pKdLhT6ug+PfgJsL+Dv/t6W19jI2Ew 8vXM5yktG5AK663ihOG8zujGWGP0mMslNB2IGrX08PgYgZVuckgFvMTo/1PbLOf9ACEewQzq9xcQm 43RRjBuDIlYFJzbEFjYUQ0FqA8dVBPo63CbAY731iSPqi87WOfT7SbI2umDxUniBKLI9AZuS+AzWP yFzEOY1GA==; Received: from i7.infradead.org ([90.155.92.213]) by casper.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1dcrqv-00033y-Tm; Wed, 02 Aug 2017 11:30:13 +0000 Message-ID: <1501673413.20068.15.camel@infradead.org> From: David Woodhouse To: Jan Beulich Date: Wed, 02 Aug 2017 12:30:13 +0100 In-Reply-To: <598198C30200007800103235@prv-mh.provo.novell.com> References: <1500564043.4400.15.camel@infradead.org> <597D79BD0200007800102F92@prv-mh.provo.novell.com> <1501498940.4771.251.camel@infradead.org> <597F2D860200007800103049@prv-mh.provo.novell.com> <1501516597.4771.328.camel@infradead.org> <598198C30200007800103235@prv-mh.provo.novell.com> X-Mailer: Evolution 3.22.4 (3.22.4-2.fc25) Mime-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Cc: xen-devel@lists.xenproject.org, jiewen.yao@intel.com, jeff.fan@intel.com Subject: [Xen-devel] [PATCH] x86/efi: Do not write relocations in efi_arch_relocate_image() first pass X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP The function is invoked with delta=0 before ExitBootServices() is called, as a dummy run purely to validate that all the relocations can be handled. This allows us to exit gracefully with an error message. However, we have relocations in read-only sections such as .rodata and .init.te(xt). Recent versions of UEFI will actually make those sections read-only, which will cause a fault. This functionaity was added in EDK2 commit d0e92aad4 ("MdeModulePkg/DxeCore: Add UEFI image protection.") It's OK to actually make the changes in the later pass because UEFI will tear down the protection when ExitBootServices() is called, because it knows we're going to need to do this kind of thing. Signed-off-by: David Woodhouse --- This basically means that new versions of UEFI are going to break (all?) existing EFI Xen versions? Or at least any that have relocations in .init.text. xen/arch/x86/efi/efi-boot.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h index bedac5c..8d295ff 100644 --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -87,7 +87,8 @@ static void __init efi_arch_relocate_image(unsigned long delta) case PE_BASE_RELOC_DIR64: if ( in_page_tables(addr) ) blexit(L"Unexpected relocation type"); - *(u64 *)addr += delta; + if ( delta ) + *(u64 *)addr += delta; break; default: blexit(L"Unsupported relocation type");