Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F74EC54EAA for ; Fri, 27 Jan 2023 12:50:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234418AbjA0MuF (ORCPT ); Fri, 27 Jan 2023 07:50:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234505AbjA0MuB (ORCPT ); Fri, 27 Jan 2023 07:50:01 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03B8517CF1; Fri, 27 Jan 2023 04:50:01 -0800 (PST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 9D4551FEB5; Fri, 27 Jan 2023 12:49:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1674823799; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=GP9NL13Rf97tWq7NcnHFZorJIck1tg1rt/ecYqO31yg=; b=2QkeNLS7Zk4oROO1gOmTHIaKEMK7D3878W7X32mvkTyGiwd7e7Rqbr3n3jDLSko7BUUY84 1D/sEKora7JvGBck/MvcMMtw4oXmIsxmR2p10SLAxMY8r1zz2c/3olGZDI2c1PU4b5tQn4 aP5GSTgka34VlNvZsarsGNXivPRJ/DE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1674823799; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=GP9NL13Rf97tWq7NcnHFZorJIck1tg1rt/ecYqO31yg=; b=LIj/sjeZush1mKcK9oMcWvz7H3//fYRQHsjvI+rhVVpRpyJTgqvcWN8hbFj2GL5ZKn/hwz doSM4u1zOF40BGDA== Received: from pobox.suse.cz (pobox.suse.cz [10.100.2.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 70BFF2C141; Fri, 27 Jan 2023 12:49:59 +0000 (UTC) Date: Fri, 27 Jan 2023 13:50:04 +0100 (CET) From: Miroslav Benes To: Josh Poimboeuf cc: Michael Ellerman , live-patching@vger.kernel.org, Nicholas Piggin , Christophe Leroy , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Song Liu Subject: Re: [PATCH 2/2] powerpc/module_64: Fix "expected nop" error on module re-patching In-Reply-To: <2f6329ffd9674df6ff57e03edeb2ca54414770ab.1674617130.git.jpoimboe@kernel.org> Message-ID: References: <2f6329ffd9674df6ff57e03edeb2ca54414770ab.1674617130.git.jpoimboe@kernel.org> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 24 Jan 2023, Josh Poimboeuf wrote: > When a module with a livepatched function is unloaded and then reloaded, > klp attempts to dynamically re-patch it. On ppc64, that fails with the > following error: > > module_64: livepatch_nfsd: Expected nop after call, got e8410018 at e_show+0x60/0x548 [livepatch_nfsd] > livepatch: failed to initialize patch 'livepatch_nfsd' for module 'nfsd' (-8) > livepatch: patch 'livepatch_nfsd' failed for module 'nfsd', refusing to load module 'nfsd' > > The error happens because the restore r2 instruction had already > previously been written into the klp module's replacement function when > the original function was patched the first time. So the instruction > wasn't a nop as expected. > > When the restore r2 instruction has already been patched in, detect that > and skip the warning and the instruction write. > > Signed-off-by: Josh Poimboeuf Reviewed-by: Miroslav Benes M