From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: [PATCH 3/3] x86/EFI: don't accept 64-bit base relocations on page tables Date: Fri, 19 Aug 2016 01:52:04 -0600 Message-ID: <57B6D6C40200007800107465@prv-mh.provo.novell.com> References: <57B6D3C3020000780010743E@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part87B16BB4.1__=" Return-path: Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1baeb0-0005n2-F7 for xen-devel@lists.xenproject.org; Fri, 19 Aug 2016 07:52:06 +0000 In-Reply-To: <57B6D3C3020000780010743E@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: xen-devel Cc: Andrew Cooper List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part87B16BB4.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 --- 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 +=3D delta; - if ( in_page_tables(addr) ) - *(intpte_t *)addr +=3D xen_phys_start; - } + if ( in_page_tables(addr) ) + blexit(L"Unexpected relocation type"); + *(u64 *)addr +=3D delta; break; default: blexit(L"Unsupported relocation type"); --=__Part87B16BB4.1__= Content-Type: text/plain; name="x86-EFI-64bit-reloc-pgtab.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-EFI-64bit-reloc-pgtab.patch" x86/EFI: don't accept 64-bit base relocations on page tables=0A=0APage = tables get pre-populated with physical addresses which, due to=0Aliving = inside the Xen image, will never exceed 32 bits in width. That=0Ain turn = results in the tool generating the relocations to produce=0A32-bit = relocations for them instead of the 64-bit ones needed for=0Arelocating = virtual addresses. Hence instead of special casing page=0Atables in the = processing of 64-bit relocations, let's be more rigid=0Aand refuse them = (as being indicative of something else having gone=0Awrong in the build = process).=0A=0ASigned-off-by: Jan Beulich =0A=0A--- = a/xen/arch/x86/efi/efi-boot.h=0A+++ b/xen/arch/x86/efi/efi-boot.h=0A@@ = -81,12 +81,9 @@ static void __init efi_arch_relocate_ima=0A = }=0A break;=0A case PE_BASE_RELOC_DIR64:=0A- = if ( delta )=0A- {=0A- = *(u64 *)addr +=3D delta;=0A- if ( in_page_tables(addr) = )=0A- *(intpte_t *)addr +=3D xen_phys_start;=0A- = }=0A+ if ( in_page_tables(addr) )=0A+ = blexit(L"Unexpected relocation type");=0A+ *(u64 = *)addr +=3D delta;=0A break;=0A default:=0A = blexit(L"Unsupported relocation type");=0A --=__Part87B16BB4.1__= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwczovL2xpc3RzLnhlbi5v cmcveGVuLWRldmVsCg== --=__Part87B16BB4.1__=--