From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753556AbcHWDB1 (ORCPT ); Mon, 22 Aug 2016 23:01:27 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:44593 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752840AbcHWDBZ (ORCPT ); Mon, 22 Aug 2016 23:01:25 -0400 X-IBM-Helo: d24dlp01.br.ibm.com X-IBM-MailFrom: bauerman@linux.vnet.ibm.com X-IBM-RcptTo: linux-kernel@vger.kernel.org From: Thiago Jung Bauermann To: Balbir Singh Cc: kexec@lists.infradead.org, Stewart Smith , Benjamin Herrenschmidt , Baoquan He , linuxppc-dev@lists.ozlabs.org, x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org, Ingo Molnar , Paul Mackerras , Eric Biederman , Michael Ellerman , Thomas Gleixner , Dave Young , Andrew Morton , Vivek Goyal Subject: Re: [PATCH v5 04/13] powerpc: Factor out relocation code from module_64.c to elf_util_64.c. Date: Tue, 23 Aug 2016 00:01:15 -0300 User-Agent: KMail/4.14.3 (Linux/3.13.0-93-generic; KDE/4.14.13; x86_64; ; ) In-Reply-To: <3ca4a2de-0d44-dbc6-b57b-c149d10b048f@gmail.com> References: <1470956898-5991-1-git-send-email-bauerman@linux.vnet.ibm.com> <4126991.2tm6WB17SD@hactar> <3ca4a2de-0d44-dbc6-b57b-c149d10b048f@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16082303-0032-0000-0000-00000278B352 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16082303-0033-0000-0000-00000EC14DEA Message-Id: <4586138.sszncvQpYx@hactar> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-08-23_01:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1608230029 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am Dienstag, 16 August 2016, 16:52:54 schrieb Balbir Singh: > On 16/08/16 09:25, Thiago Jung Bauermann wrote: > > Am Montag, 15 August 2016, 17:46:34 schrieb Balbir Singh: > >> On Thu, Aug 11, 2016 at 08:08:09PM -0300, Thiago Jung Bauermann wrote: > >>> +/** > >>> + * elf64_apply_relocate_add - apply 64 bit RELA relocations > >>> + * @elf_info: Support information for the ELF binary being > > > > relocated. > > > >>> + * @strtab: String table for the associated symbol > > > > table. > > > >>> + * @symindex: Section header index for the associated > > > > symbol table. > > > >>> + * @relsec: Section header index for the relocations to > > > > apply. > > > >>> + * @obj_name: The name of the ELF binary, for information > > > > messages. > > > >>> + */ > >>> +int elf64_apply_relocate_add(const struct elf_info *elf_info, > >>> + const char *strtab, unsigned int symindex, > >>> + unsigned int relsec, const char *obj_name) > >>> +{ > >>> + unsigned int i; > >>> + Elf64_Shdr *sechdrs = elf_info->sechdrs; > >>> + Elf64_Rela *rela = (void *)sechdrs[relsec].sh_addr; > >>> + Elf64_Sym *sym; > >>> + unsigned long *location; > >>> + unsigned long value; > >>> + > >> > >> For the relocatable kernel we expect only > >> > >> R_PPC64_RELATIVE > >> R_PPC64_NONE > >> R_PPC64_ADDR64 > >> > >> In the future we can use this to check/assert the usage of this > >> for the core kernel (vmlinux) when loaded. > >> > >> Did we check elf64_apply_relocate_add with zImage and vmlinux? > > > > kexec_file_load doesn't call call elf64_apply_relocate_add on the kernel > > image, it only uses it to relocate the purgatory. So whether it is > > loading a zImage or a vmlinux file, the function will work in the same > > way since the purgatory binary is the same regardless of the kernel > > image format. > Thanks for clarifying. > > > For the same reason, as it currently stands kexec_file_load can't check > > the relocation types used in the kernel image. But it is possible to > > add such a check/assertion in kexec_elf_64.c:build_elf_exec_info if we > > want. > > > > I tested kexec_file_load on both relocatable and non-relocatable vmlinux > > and it works correctly. > > > > I hadn't tested with zImage yet. I just did, and I had two problems: > > > > 1. For some reason, it has an INTERP segment. This patch series doesn't > > support loading program interpreters for ELF binaries, so > > kexec_elf_64.c:build_elf_exec_info refuses to load them. > > > > 2. If I disable the check for the INTERP segment, the zImage file loads > > correctly, but then I get an exception during reboot when loading the > > kexec image, right before jumping into the purgatory. I suspect this is > > because the LOAD segment has a virtual address of 0, and the first > > kernel is not coping well with that. But I still have to debug it > > further. > > > > Is there a reason for the zImage ELF header to request an interpreter > > and to have a virtual address of 0? > > Not that I am aware of. zImage on ppc64 BE is an ELF32 file. This patch set only supports loading ELF files of the same class as the kernel, so a 64 bit kernel can't load an ELF32 file. It would be possible to add such support, but it would be a new feature. The distros I was able to check on ppc64 LE and BE all use vmlinux. kexec-tools with kexec_load also doesn't support zImage. Do you think it is important to support zImage? -- []'s Thiago Jung Bauermann IBM Linux Technology Center