Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753188AbcKTCqA (ORCPT ); Sat, 19 Nov 2016 21:46:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47152 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753033AbcKTCp7 (ORCPT ); Sat, 19 Nov 2016 21:45:59 -0500 Date: Sun, 20 Nov 2016 10:45:46 +0800 From: Dave Young To: Thiago Jung Bauermann Cc: kexec@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, x86@kernel.org, Eric Biederman , Vivek Goyal , Baoquan He , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Stewart Smith , Mimi Zohar , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Andrew Morton , Stephen Rothwell Subject: Re: [PATCH v10 04/10] kexec_file: Add support for purgatory built as PIE. Message-ID: <20161120024546.GA4413@dhcp-128-65.nay.redhat.com> References: <1478748449-3894-1-git-send-email-bauerman@linux.vnet.ibm.com> <1478748449-3894-5-git-send-email-bauerman@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1478748449-3894-5-git-send-email-bauerman@linux.vnet.ibm.com> User-Agent: Mutt/1.7.1 (2016-10-04) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Sun, 20 Nov 2016 02:45:58 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1726 Lines: 43 On 11/10/16 at 01:27am, Thiago Jung Bauermann wrote: > powerpc's purgatory.ro has 12 relocation types when built as > a relocatable object. To implement support for them requires > arch_kexec_apply_relocations_add to duplicate a lot of code with > module_64.c:apply_relocate_add. > > When built as a Position Independent Executable there are only 4 > relocation types in purgatory.ro, so it becomes practical for the powerpc > implementation of kexec_file to have its own relocation implementation. > > Also, the purgatory is an executable and not an intermediary output from > the compiler so it makes sense conceptually that it is easier to build > it as a PIE than as a partially linked object. > > Apart from the greatly reduced number of relocations, there are two > differences between a relocatable object and a PIE: > > 1. __kexec_load_purgatory needs to use the program headers rather than the > section headers to figure out how to load the binary. > 2. Symbol values are absolute addresses instead of relative to the > start of the section. > > This patch adds the support needed in generic code for the differences > above and allows powerpc to load and relocate a position independent > purgatory. > [snip] The kexec-tools machine_apply_elf_rel is pretty simple for ppc64, it is not that complex. So could you look into simplify your kexec_file implementation? kernel/kexec_file.c kexec_apply_relocations only do limited things and some of the logic is in arch/x86, so move general code out of arch code, then I guess the arch code will be simpler and then we probably do not need this PIE stuff anymore. BTW, __kexec_really_load_purgatory looks worse than ___kexec_load_purgatory ;) Thanks Dave