Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp844056pxb; Fri, 22 Apr 2022 12:24:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTVOHbPmDf3B7hvdkYbMFbYPfmI2GBmRl/78nGeSJHoOHgdhuZhX2QqgDiQzOoBUl4Z7SV X-Received: by 2002:a17:903:240c:b0:153:c8df:7207 with SMTP id e12-20020a170903240c00b00153c8df7207mr5972497plo.44.1650655447681; Fri, 22 Apr 2022 12:24:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650655447; cv=none; d=google.com; s=arc-20160816; b=MvRGIAYPNEvqwQmZtSSoa0/ShElLpkZvRRobMdfX6pjWYAFIXDtsQxk9DEeRocjkPU eytgy8rSzFhnFIJAm0ZRJA+zZtN/FokGanf3dcVZ4LSEDhFeYn18EKwJzZ0H8vg2TK79 /GS8L+YfcfiavyXc6mB095KplmfjktbW84qmoucqNYgQG/c/IdjYbCu8uh5EMkL+DZwH XYGABkyattZRobD3LKWQ1RYCLXf8saCHB0hYCqVxYJPgdSs3j6O+31IRFnRtH+mVGnAb xozVmt8judjnl4AoNJ/z8ZFMMDv8//GSO3uzTheR/gdHPiKJaTe8/KX3tB5RCcERi6Te e8Xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=oeftgxQ4FeokmFj2HfewW+u34cSg1nSvpjqfx2hKvUg=; b=CQrnL00zR4akvge/ZQXmGdhE1bPkLTZ437/yPzUq1eAjz3RiKw73ekAWySlaUTkLF/ VxYr0T7NAMsS9LWJS9Cbr1ViygXwi3OoDeGQ/9i4Cw2pFFwZRrE7os0lvOJ6TH661Ggn wXRJ1IGnJ5hox60Pdr/KG5N0GxwsY/5sG45ycEpznd+YPvn426gnQkFQ3HlwgEOVCkut knPR8ULtEOosS9l9s+Ej+L5oQw6u4wby4kjf2evC2VLpIlGYpZgb28eGg82hL9yIb2ZU VDJ9CSZKyIoI4W09rOxDBvOL2ys38VScggpfk0DVNg0lTtpW383w6AtxXEOQipK8Q32L DMvA== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id fy6-20020a17090b020600b001d762d20a5fsi3752293pjb.118.2022.04.22.12.24.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 12:24:07 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D38591C9CDF; Fri, 22 Apr 2022 11:36:26 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347767AbiDRTrD (ORCPT + 99 others); Mon, 18 Apr 2022 15:47:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347753AbiDRTrB (ORCPT ); Mon, 18 Apr 2022 15:47:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3966A24BDD for ; Mon, 18 Apr 2022 12:44:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C8DE060F6A for ; Mon, 18 Apr 2022 19:44:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 510EBC385A1; Mon, 18 Apr 2022 19:44:20 +0000 (UTC) Date: Mon, 18 Apr 2022 15:44:18 -0400 From: Steven Rostedt To: "Naveen N. Rao" Cc: Benjamin Herrenschmidt , Christophe Leroy , Ingo Molnar , Michael Ellerman , Paul Mackerras , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH v1 07/22] powerpc/ftrace: Use patch_instruction() return directly Message-ID: <20220418154418.72ccc00c@gandalf.local.home> In-Reply-To: <1650262058.altfknhzto.naveen@linux.ibm.com> References: <1650262058.altfknhzto.naveen@linux.ibm.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 18 Apr 2022 11:51:16 +0530 "Naveen N. Rao" wrote: > > --- a/arch/powerpc/kernel/trace/ftrace.c > > +++ b/arch/powerpc/kernel/trace/ftrace.c > > @@ -78,10 +78,7 @@ ftrace_modify_code(unsigned long ip, ppc_inst_t old, ppc_inst_t new) > > } > > > > /* replace the text with the new text */ > > - if (patch_instruction((u32 *)ip, new)) > > - return -EPERM; > > - > > - return 0; > > + return patch_instruction((u32 *)ip, new); > > I think the reason we were returning -EPERM is so that ftrace_bug() can That is correct. > throw the right error message. That will change due to this patch, > though I'm not sure how much it matters. -EFAULT and -EPERM seem to > print almost the same error message. In these cases it helps to know the type of failure, as the way to debug it is different. -EFAULT: It failed to read it the location. This means that the memory is likely not even mapped in, or the pointer is way off. -EINVAL: Means that what was read did not match what was expected (the code was already updated, pointing to the wrong location, or simply the calculation of what to expect is incorrect). -EPERM: Means the write failed. What was read was expected, but the permissions to write have not been updated properly. Differentiating the three is crucial to looking at where the issue lies when an ftrace_bug() triggers. -- Steve