From mboxrd@z Thu Jan 1 00:00:00 1970 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 13C3B3A1B6; Mon, 14 Oct 2024 15:03:36 +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=1728918216; cv=none; b=gLbCi7zroKhTwsIghOsrYp1f0ZE/0xTT9D0jTPJqC+2C+yZWN/YTLQvWmpmqQQJ76uLeU6UEMLCB98VXhkP9lS8R7rpFvuLjdSO2E44PC+dNhxS5Pxko0A/mtUzzZm1jlPWhFGAEqKMHUwBcezf+biKYWG+MuxhPoK4F7uOQUFQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728918216; c=relaxed/simple; bh=6zAlPWA18SLAY8vjJU7JmWdYCxmGsttZ39xjXV9O8YI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=I5oy9Jb4bWk7lx7Df2D8M9uGI4sx/e5tWkjENLi4wBlqkuty+r1o4R0JNAfAUafDr+pS7njTshBmBv37snGwJNKdQrtMdAIk9dU0tNGgJoGSRIA+vRRODj7sz9S1hrW0asfJtzfd2IaKLDZnOmkSSwZr2VGtiP8bjUMlrRuG8Zs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=smHMaN2N; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="smHMaN2N" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76C38C4CEC3; Mon, 14 Oct 2024 15:03:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728918216; bh=6zAlPWA18SLAY8vjJU7JmWdYCxmGsttZ39xjXV9O8YI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=smHMaN2NAhh8xAdyLIIByJco1nM6Bnm9CX53B0iael/93TmH23ndtJBbWbwFK6NSw 56RF7LfSbYeZiWGVECry4KdfymL1EG9qOrv/8DqaCOovHTwVXC1FG2EfGmhDpFYRzv WdMNTZfPIt4R19FRSpDAOtAUDErOeUi96XWFs49Q= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jinjie Ruan , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Palmer Dabbelt , Sasha Levin Subject: [PATCH 6.1 226/798] riscv: Fix fp alignment bug in perf_callchain_user() Date: Mon, 14 Oct 2024 16:13:00 +0200 Message-ID: <20241014141226.803215942@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241014141217.941104064@linuxfoundation.org> References: <20241014141217.941104064@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jinjie Ruan [ Upstream commit 22ab08955ea13be04a8efd20cc30890e0afaa49c ] The standard RISC-V calling convention said: "The stack grows downward and the stack pointer is always kept 16-byte aligned". So perf_callchain_user() should check whether 16-byte aligned for fp. Link: https://riscv.org/wp-content/uploads/2015/01/riscv-calling.pdf Fixes: dbeb90b0c1eb ("riscv: Add perf callchain support") Signed-off-by: Jinjie Ruan Cc: Björn Töpel Link: https://lore.kernel.org/r/20240708032847.2998158-2-ruanjinjie@huawei.com Signed-off-by: Palmer Dabbelt Signed-off-by: Sasha Levin --- arch/riscv/kernel/perf_callchain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/riscv/kernel/perf_callchain.c b/arch/riscv/kernel/perf_callchain.c index 3348a61de7d99..2932791e93882 100644 --- a/arch/riscv/kernel/perf_callchain.c +++ b/arch/riscv/kernel/perf_callchain.c @@ -62,7 +62,7 @@ void perf_callchain_user(struct perf_callchain_entry_ctx *entry, perf_callchain_store(entry, regs->epc); fp = user_backtrace(entry, fp, regs->ra); - while (fp && !(fp & 0x3) && entry->nr < entry->max_stack) + while (fp && !(fp & 0x7) && entry->nr < entry->max_stack) fp = user_backtrace(entry, fp, 0); } -- 2.43.0