From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH 3/3] x86/EFI: don't accept 64-bit base relocations on page tables Date: Fri, 19 Aug 2016 13:39:44 +0100 Message-ID: References: <57B6D3C3020000780010743E@prv-mh.provo.novell.com> <57B6D6C40200007800107465@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8524208989559156175==" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1baj5v-0000Ly-Nl for xen-devel@lists.xenproject.org; Fri, 19 Aug 2016 12:40:19 +0000 In-Reply-To: <57B6D6C40200007800107465@prv-mh.provo.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: Jan Beulich , xen-devel List-Id: xen-devel@lists.xenproject.org --===============8524208989559156175== Content-Type: multipart/alternative; boundary="------------C6B862D0B51B870445E99A1D" --------------C6B862D0B51B870445E99A1D Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit On 19/08/16 08:52, Jan Beulich wrote: > Page tables get pre-populated with physical addresses which, due to > living inside the Xen image, will never exceed 32 bits in width. That > in turn results in the tool generating the relocations to produce > 32-bit relocations for them instead of the 64-bit ones needed for > relocating virtual addresses. Hence instead of special casing page > tables in the processing of 64-bit relocations, let's be more rigid > and refuse them (as being indicative of something else having gone > wrong in the build process). > > Signed-off-by: Jan Beulich Is it an ABI requirement to use the minimal available relocation? It is certainly suboptimal to use a 64bit relocation when a 32bit one would do, but I wouldn't bet that it is unconditional avoided by all toolchains. It is currently the case that Xen needs to live below 4GB physical, so from that point of view a 64bit relocation will not be required in the pagetables. ~Andrew > > --- a/xen/arch/x86/efi/efi-boot.h > +++ b/xen/arch/x86/efi/efi-boot.h > @@ -81,12 +81,9 @@ static void __init efi_arch_relocate_ima > } > break; > case PE_BASE_RELOC_DIR64: > - if ( delta ) > - { > - *(u64 *)addr += delta; > - if ( in_page_tables(addr) ) > - *(intpte_t *)addr += xen_phys_start; > - } > + if ( in_page_tables(addr) ) > + blexit(L"Unexpected relocation type"); > + *(u64 *)addr += delta; > break; > default: > blexit(L"Unsupported relocation type"); > > > > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > https://lists.xen.org/xen-devel --------------C6B862D0B51B870445E99A1D Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: 8bit
On 19/08/16 08:52, Jan Beulich wrote:
Page tables get pre-populated with physical addresses which, due to
living inside the Xen image, will never exceed 32 bits in width. That
in turn results in the tool generating the relocations to produce
32-bit relocations for them instead of the 64-bit ones needed for
relocating virtual addresses. Hence instead of special casing page
tables in the processing of 64-bit relocations, let's be more rigid
and refuse them (as being indicative of something else having gone
wrong in the build process).

Signed-off-by: Jan Beulich <jbeulich@suse.com>

Is it an ABI requirement to use the minimal available relocation?  It is certainly suboptimal to use a 64bit relocation when a 32bit one would do, but I wouldn't bet that it is unconditional avoided by all toolchains.

It is currently the case that Xen needs to live below 4GB physical, so from that point of view a 64bit relocation will not be required in the pagetables.

~Andrew


--- a/xen/arch/x86/efi/efi-boot.h
+++ b/xen/arch/x86/efi/efi-boot.h
@@ -81,12 +81,9 @@ static void __init efi_arch_relocate_ima
                 }
                 break;
             case PE_BASE_RELOC_DIR64:
-                if ( delta )
-                {
-                    *(u64 *)addr += delta;
-                    if ( in_page_tables(addr) )
-                        *(intpte_t *)addr += xen_phys_start;
-                }
+                if ( in_page_tables(addr) )
+                    blexit(L"Unexpected relocation type");
+                *(u64 *)addr += delta;
                 break;
             default:
                 blexit(L"Unsupported relocation type");





_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

--------------C6B862D0B51B870445E99A1D-- --===============8524208989559156175== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwczovL2xpc3RzLnhlbi5v cmcveGVuLWRldmVsCg== --===============8524208989559156175==--