Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp970975lqp; Thu, 23 May 2024 05:49:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVXdIJKUw+6s63xDXYsFsU+BSDE2x2G4z9xuJjBvZuFFKarrJUFLuvs9lZpmuRIDVizXhq49/9B4TP7O1VHow5gEP65PkALQf9Jurrt4A== X-Google-Smtp-Source: AGHT+IGS0bBG0fuzrXGb3tU7/2pO6RXEceTxzg3/TpoxHSDNUYt+t0spCgQuX7YAE06OqF9i6svu X-Received: by 2002:a05:6a21:19a:b0:1a9:b2ee:5f72 with SMTP id adf61e73a8af0-1b1f884767fmr5332311637.36.1716468546017; Thu, 23 May 2024 05:49:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716468546; cv=pass; d=google.com; s=arc-20160816; b=XvpM9qI9WBYRZeN4zcaCr9vzcRiJNvmHBRqQ674N0vbEXBeHjrEfr/a+iK1ORIOlCu /s/v942OlQTqqoaz6ZtW2T7bU2yDiDfL0tuvxOryAi60lCEoAbXq+bhSS7sCvBrf9wm9 ITWECd3EOcmDBxNWcSOj7IbUqUNvWnx1QVUtBnX+dsLb8J2TgY5tkUgKaagjUXdHxZ/o D9QQeJVbx5TVPF+gFop2DQOAMq9qsZ7K4v21Ot5oyKfRDxVw+c53cGH4F1ckWHFdqcYF OwA/QC0iZc503HjCXMnH1oxaoA4Lyls4SZcl8VG1N+6EDJrC5QwOL/wc2xEhcEEOI5yn soCQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:references :in-reply-to:subject:to:from:dkim-signature; bh=0LnqLKPO3oHw4EJVIibzy2VTLh33HjinRBhfOHkwyqo=; fh=p4D7uQBzSl1MEIlXmSboOK0dPmM6lsEmwQTLPJ3x+vc=; b=EMQL1Sr9DYVMPdH1ZaCzfHcCuqVGphYUKPd7ua91N9jghjodk/uyAO7a4fj0O4NApx KsVj8/dLxAsyleb8/SEaAvRxxU2NbI8cz6Oy7gfHcOVe+k54MZMOgkhRghDndVp+Uc7t pMw9vkxOGjKLU81T6A+NAO8NxwQ/knjlr5YMvH0EfEkju9CupAsdiN9K63xJMv4ve7NS Hz6suis6tOBYXiugOndGh9jO3SD2mN7E0Hg/ExiwxqQ0nQMuD8qI19L9Y6iXTxN1wtLG KRzJznHqHz9smlMc1J4LPn2B3+InN3Wq8dxCVDjSbhPG37+b7B/HSqxu7sG7l3EfNFYI ldXA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gmIwD+NW; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-187496-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187496-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6672643e62dsi4964097a12.351.2024.05.23.05.49.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 05:49:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-187496-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gmIwD+NW; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-187496-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187496-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id EF75A283BDE for ; Thu, 23 May 2024 12:49:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5405214A4C1; Thu, 23 May 2024 12:49:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gmIwD+NW" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C5A513B5B0; Thu, 23 May 2024 12:48:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716468539; cv=none; b=aMCL7lLMccKSneskja0/KbFebVobYxFtsweDhJCbNHH/rOJ0+K5atREbQ3oPZhdqv3mqGIcRMUmuGl+4W5iTUK5kEv/1mM+GeK7867HOanmmr6umrpXudfR77bqTzLJ5XqHtjLCU3BtRfgcq7s7e443RDkCjDoFtiqBuhGW3Ofg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716468539; c=relaxed/simple; bh=0LnqLKPO3oHw4EJVIibzy2VTLh33HjinRBhfOHkwyqo=; h=From:To:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=orBmyz+xwM2SwqK00qtIhowRSE3jy+Qc0kKZDs84nu3aUu+DELh/6sVijGQS5y/4ywjNBYxPzdDAtyL3ym4WVo/ubWulRmfyhIaI74wEwnNl8nrOMlFOsDykdzQzYDCcSqbOC1GM9fT0AabZMPxNTvIvJlps2Y5unf/sad1U7UA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gmIwD+NW; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87B52C2BD10; Thu, 23 May 2024 12:48:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716468539; bh=0LnqLKPO3oHw4EJVIibzy2VTLh33HjinRBhfOHkwyqo=; h=From:To:Subject:In-Reply-To:References:Date:From; b=gmIwD+NWWG8uf8vz7oJxu92yCfnO5F7AHKAYts7hJ3i7MjyDadHiy9lzsJ6u8U4mI oYCcZSPKX1+Mx6oRo3u1ATvbTWd2gsQZxBuu1wYMeVa1//6i3BYkZJvjVAv8COnPfc UgGMD/d2ScHrcYNYsj02hBwhLrTrXjvfp1y+aI3yAhbktDkDf4MMCEdU1pnGsJ3pNL 6ODypG/qGkAdFHLyFRh826sp0Jy7qvGN+SoZNPcwGOYZw8I6JwcpVxJ/b2J/aaE4JC fEM/kpy8wItlOJWXQBUzcGyLb2xGZQcm3X6KlLvkvun89tmccNqmesex35PqRqk6ET Y9yV1AO9U188Q== From: =?utf-8?B?QmrDtnJuIFTDtnBlbA==?= To: Alexandre Ghiti , Paul Walmsley , Palmer Dabbelt , Albert Ou , Steven Rostedt , Masami Hiramatsu , Mark Rutland , Alexandre Ghiti , Andrea Parri , =?utf-8?B?QmrDtnJuIFTDtnBlbA==?= , Conor Dooley , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: Re: [PATCH] riscv: Fix early ftrace nop patching In-Reply-To: <20240523115134.70380-1-alexghiti@rivosinc.com> References: <20240523115134.70380-1-alexghiti@rivosinc.com> Date: Thu, 23 May 2024 14:48:55 +0200 Message-ID: <87y1803d8o.fsf@all.your.base.are.belong.to.us> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Alexandre Ghiti writes: > Commit c97bf629963e ("riscv: Fix text patching when IPI are used") > converted ftrace_make_nop() to use patch_insn_write() which does not > emit any icache flush relying entirely on __ftrace_modify_code() to do > that. > > But we missed that ftrace_make_nop() was called very early directly when > converting mcount calls into nops (actually on riscv it converts 2B nops > emitted by the compiler into 4B nops). > > This caused crashes on multiple HW as reported by Conor and Bj=C3=B6rn si= nce > the booting core could have half-patched instructions in its icache > which would trigger an illegal instruction trap: fix this by emitting a > local flush icache when early patching nops. > > Fixes: c97bf629963e ("riscv: Fix text patching when IPI are used") > Signed-off-by: Alexandre Ghiti Nice! I've manged to reproduce the crash on the VisionFive2 board (however only triggered when CONFIG_RELOCATABLE=3Dy), and can verify that this fix solves the issue. Reviewed-by: Bj=C3=B6rn T=C3=B6pel Tested-by: Bj=C3=B6rn T=C3=B6pel