Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755547AbdLGNYM (ORCPT ); Thu, 7 Dec 2017 08:24:12 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:48270 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753860AbdLGNYK (ORCPT ); Thu, 7 Dec 2017 08:24:10 -0500 Subject: Re: [PATCH] [powerpc-next] Fix powerpc64 alignment of .toc section in kernel modules To: Michael Ellerman , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, amodra@gmail.com Cc: benh@kernel.crashing.org, paulus@samba.org, ard.biesheuvel@linaro.org, rusty@rustcorp.com.au References: <20171206191228.30830-1-desnesn@linux.vnet.ibm.com> <877etylo6i.fsf@concordia.ellerman.id.au> From: =?UTF-8?Q?Desnes_Augusto_Nunes_do_Ros=c3=a1rio?= Date: Thu, 7 Dec 2017 11:24:01 -0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <877etylo6i.fsf@concordia.ellerman.id.au> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 17120713-0020-0000-0000-00000D20B6E5 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008166; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000244; SDB=6.00956741; UDB=6.00483659; IPR=6.00736773; BA=6.00005729; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00018405; XFM=3.00000015; UTC=2017-12-07 13:24:07 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17120713-0021-0000-0000-00005F34AB65 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-12-07_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1712070198 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2474 Lines: 82 Hello Michael, On 12/07/2017 10:25 AM, Michael Ellerman wrote: > Hi Desnes, > > Am I right that Alan largely wrote this patch? > > If so it should probably be From: him, so that he is the author in the > git log. Yes, Alan Modra is the main author and I am just committing it with minor changes. Thus, the author change is necessary. > > > Desnes Augusto Nunes do Rosario writes: >> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile >> index 1381693..c472f5b 100644 >> --- a/arch/powerpc/Makefile >> +++ b/arch/powerpc/Makefile >> @@ -63,6 +63,7 @@ UTS_MACHINE := $(subst $(space),,$(machine-y)) >> ifdef CONFIG_PPC32 >> KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o >> else >> +KBUILD_LDFLAGS_MODULE += -T arch/powerpc/kernel/module.lds > > This needs to be: > > KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/powerpc/kernel/module.lds > > Otherwise building with O=../build fails with: > > ld: cannot open linker script file arch/powerpc/kernel/module.lds: No such file or directory > > I'll fix it up. Indeed; this change is necessary to avoid any path errors. > >> diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c >> index 759104b..9b2c5c1 100644 >> --- a/arch/powerpc/kernel/module_64.c >> +++ b/arch/powerpc/kernel/module_64.c >> @@ -374,11 +377,13 @@ int module_frob_arch_sections(Elf64_Ehdr *hdr, >> } >> >> /* r2 is the TOC pointer: it actually points 0x8000 into the TOC (this >> - gives the value maximum span in an instruction which uses a signed >> - offset) */ >> + * gives the value maximum span in an instruction which uses a signed >> + * offset). Round down to a 256 byte boundary for the odd case where >> + * we are setting up r2 without a .toc section. >> + */ >> static inline unsigned long my_r2(const Elf64_Shdr *sechdrs, struct module *me) >> { >> - return sechdrs[me->arch.toc_section].sh_addr + 0x8000; >> + return (sechdrs[me->arch.toc_section].sh_addr & -256) + 0x8000; > > I think it's more typical in the kernel to write -256 as ~0xff. > > Again I can fix it up. Good to know! > > cheers > Lastly, will you fix it up or do you want me to send a second version then? Whatever is best for you. Thank you for the review. -- Desnes Augusto Nunes do Rosário ------------------------------------------ Linux Developer - IBM / Brazil M.Sc. in Electrical and Computer Engineering - UFRN (11) 9595-30-900 desnesn@br.ibm.com