Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5530135rwb; Tue, 22 Nov 2022 01:01:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf5aw3NgVWEfucY87EmRuqy6i0IM6yCTXnyqV8frZah8JDzHhmdnO7moqw0ioNKs56P80U9U X-Received: by 2002:a05:6402:298f:b0:468:f142:3040 with SMTP id eq15-20020a056402298f00b00468f1423040mr19536365edb.107.1669107697385; Tue, 22 Nov 2022 01:01:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669107697; cv=none; d=google.com; s=arc-20160816; b=blifePkd1qcORTiqiPVyEQ53GgilIWqyGo+9cZuNlH54goEDewKA4ovcWWM1JsqNS1 E1VwRVtx4VzvnsNNDPkLlyUXz1kDBiXk0AMe+bROE6lyonoJkoXY2i6Sxokq+9zrXYk3 7kL2nKhvEk/ubwrM4V0LfrbJX7SzqH1R0kuULN1hpMkpXnkpJZbxycaUi3fuEymWIPr5 UTYWAfa5/HiZubUDWz2GrKwQ0wXhL/21Q2q/Oggif+eZ3pDP+yEKRuIMLKXYmARpgU7I W9ceY69Na14SW9wtLt3JnvejINwAV6kLWjN2t+xsgRh0tkbgvNve0aOc9gy+WdgRwALy X/GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=+539B2TQQRZl1iRUz7vsHnC7jKGGaLE1TJcAkaJ+yc8=; b=M7CJu0c9WnJ+JNZmZVsplEbuWWgODbqrUQD4KRRaOQ2GfYPtHARfulnncdwBEZCxgq /k2lGAWZhd05WMIGFs3upO5dCGduOMntB8FTkL119MLdzwkOmudi3PhoWHG2QT/CWxVM LC6siwn/aXK0zPPxcLOZJ2EDsPSk+Rqj8gC8jlkslK1pHHccwfe7nikIF+eha4a5EDe0 VZHx+ECgzsM/Hppt44ALuHcqcu4HxXg1s3YRnElHzrK/Vgmdyi0MLKGr9wIvqHyUkh4w maYXL6T0GNH23OdzMgGHznoXs5sVxwRzVbSewLRmA98Wi20xdF6jaUX+6JTqYfBnNepi 5z5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=RtpgOb2x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dm15-20020a170907948f00b0077441079bfbsi12610478ejc.434.2022.11.22.01.01.09; Tue, 22 Nov 2022 01:01:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=RtpgOb2x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233043AbiKVI6c (ORCPT + 92 others); Tue, 22 Nov 2022 03:58:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233008AbiKVI5z (ORCPT ); Tue, 22 Nov 2022 03:57:55 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A132D13F8F for ; Tue, 22 Nov 2022 00:57:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1669107470; x=1700643470; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=+SSTtDJKH/DT1imwO1wWLGEs22th08LxjRQLt0jLVxY=; b=RtpgOb2xeVbybvEW1m7nJLFEnLCJoklOwzZL+ZzFeZky/w9XOreW/Itu cpMwMkIbCeZyTGpkS8jeMPyWgo54mBK6gW+sw2NmhepS4x55Mw2e/GnGC ol8VeIT6nGZJXolb5fifmO6IwCQ0VNAHY4wZNIBMA3+2T5NR1THjUsb7S mO0BG0KZxCCFlJR08Qb7ojM70zRRzM5Fh1SbPu6sYfUQowqxcrxjp+czW bhVjetK/Bb4tm72fk0ogtTY3HOib1esZg9Oh8ghiBiImgknzp+ptwP8SH pvtJHVXSXMlrJEKmTFw6Sqwz3G6tkyCOl9OW6y/YD4TTM+xkYooYeNQ+e w==; X-IronPort-AV: E=Sophos;i="5.96,183,1665471600"; d="scan'208";a="124555764" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 22 Nov 2022 01:57:49 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Tue, 22 Nov 2022 01:57:49 -0700 Received: from wendy (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12 via Frontend Transport; Tue, 22 Nov 2022 01:57:48 -0700 Date: Tue, 22 Nov 2022 08:57:30 +0000 From: Conor Dooley To: Song Shuai CC: , , , , , , , , Subject: Re: [PATCH] riscv/ftrace: fix ftrace_modify_call bug Message-ID: References: <20221122075440.1165172-1-suagrfillet@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20221122075440.1165172-1-suagrfillet@gmail.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,T_SPF_TEMPERROR autolearn=ham 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 Tue, Nov 22, 2022 at 03:54:40PM +0800, Song Shuai wrote: > With this commit (riscv: ftrace: Reduce the detour code size to half) AFAICT the above patch has not been applied & this patch here should be folded into the offending patch? I've marked this one as "Not Applicable" in patchwork as a result, but let me know if that is an incorrect assumption. Thanks, Conor. > patched, ftrace bug occurred When hosting kprobe and function tracer > at the same function. > > Obviously, the variable caller in ftrace_modify_call was assigned by > rec->ip with 4 offset failing the code replacing at function entry. > And the caller should be assigned by rec->ip directly to indicate > the function entry. > > The following is the ftrace bug log. > > ``` > [ 419.632855] 00000000f8776803: expected (ffe00297 1a4282e7) but got (1a8282e7 f0227179) > [ 419.633390] ------------[ ftrace bug ]------------ > [ 419.633553] ftrace failed to modify > [ 419.633569] [] kernel_read+0x0/0x52 > [ 419.633863] actual: 97:02:e0:ff:e7:82:82:1a > [ 419.634087] Updating ftrace call site to call a different ftrace function > [ 419.634279] ftrace record flags: e0000002 > [ 419.634487] (2) R > [ 419.634487] expected tramp: ffffffff800093cc > [ 419.634935] ------------[ cut here ]------------ > ``` > > Signed-off-by: Song Shuai > --- > arch/riscv/kernel/ftrace.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/riscv/kernel/ftrace.c b/arch/riscv/kernel/ftrace.c > index 8c77f236fc71..61b24d767e2e 100644 > --- a/arch/riscv/kernel/ftrace.c > +++ b/arch/riscv/kernel/ftrace.c > @@ -132,7 +132,7 @@ int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr, > unsigned long addr) > { > unsigned int call[2]; > - unsigned long caller = rec->ip + 4; > + unsigned long caller = rec->ip; > int ret; > > make_call_t0(caller, old_addr, call); > -- > 2.20.1 >