From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753449AbdKNK3j convert rfc822-to-8bit (ORCPT ); Tue, 14 Nov 2017 05:29:39 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:35756 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753924AbdKNK3b (ORCPT ); Tue, 14 Nov 2017 05:29:31 -0500 Date: Tue, 14 Nov 2017 15:59:21 +0530 From: "Naveen N. Rao" Subject: Re: [PATCH v4 2/3] powerpc/modules: Don't try to restore r2 after a sibling call To: Kamalesh Babulal , Michael Ellerman Cc: Balbir Singh , Josh Poimboeuf , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, live-patching@vger.kernel.org References: <20171114092910.20399-1-kamalesh@linux.vnet.ibm.com> <20171114092910.20399-3-kamalesh@linux.vnet.ibm.com> In-Reply-To: <20171114092910.20399-3-kamalesh@linux.vnet.ibm.com> User-Agent: astroid/0.10.2 (https://github.com/astroidmail/astroid) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8BIT X-TM-AS-GCONF: 00 x-cbid: 17111410-0020-0000-0000-000003CC0E89 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17111410-0021-0000-0000-000042613DC9 Message-Id: <1510654928.8xrjtkjm8m.naveen@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-11-14_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=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1711140143 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Kamalesh Babulal wrote: > From: Josh Poimboeuf > > When attempting to load a livepatch module, I got the following error: > > module_64: patch_module: Expect noop after relocate, got 3c820000 > > The error was triggered by the following code in > unregister_netdevice_queue(): > > 14c: 00 00 00 48 b 14c > 14c: R_PPC64_REL24 net_set_todo > 150: 00 00 82 3c addis r4,r2,0 > > GCC didn't insert a nop after the branch to net_set_todo() because it's > a sibling call, so it never returns. The nop isn't needed after the > branch in that case. > > Signed-off-by: Josh Poimboeuf > Signed-off-by: Kamalesh Babulal > --- > arch/powerpc/kernel/module_64.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c > index 39b01fd..9e5391f 100644 > --- a/arch/powerpc/kernel/module_64.c > +++ b/arch/powerpc/kernel/module_64.c > @@ -489,6 +489,10 @@ static int restore_r2(u32 *instruction, struct module *me) > if (is_early_mcount_callsite(instruction - 1)) > return 1; > > + /* Sibling calls don't return, so they don't need to restore r2 */ > + if (instruction[-1] == PPC_INST_BRANCH) > + return 1; > + This looks quite fragile, unless we know for sure that gcc will _always_ emit this instruction form for sibling calls with relocations. As an alternative, does it make sense to do the following check instead? if ((instr_is_branch_iform(insn) || instr_is_branch_bform(insn)) && !(insn & 0x1)) - Naveen