From patchwork Sun Sep 8 10:49:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13795406 Received: from fhigh2-smtp.messagingengine.com (fhigh2-smtp.messagingengine.com [103.168.172.153]) (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 5BB284B5AE; Sun, 8 Sep 2024 10:49:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725792588; cv=none; b=Wi/gGHHy1/87RlgPEDPdGLdg/dxnFqoIrAhHxHwc4OLkrw7EGze9/3F9ijxvLRsPrO+lJiJcBoMNIpQknDkOiKeqMUT0Y2QoZbZ9+MvkmT4U5dISSmWEk8MhorpNc5NT5fRV9OvMB0qs404BI9OVRK3op+cIxBbUztwiSaX0xqk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725792588; c=relaxed/simple; bh=gPoxcCvMOPNbUND32tMngwCVFKGByJIbKWjHXDDvWUc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BlOXwfhJDDGS97Dwg8WxX4d4C6rtm5FLZkSfvXkk0ux5uHFpACw77YspKUl2LHbmbbZWuve/fx42WBinxiQo5JZG2TL7i7Ph9flzugzG4/l7o8SOFoYim9/Al0RbsmEvhT5zAFuCSEnBNA2SDrAb4+vVbQLCDmDwc5CDwfUOVmM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com; spf=pass smtp.mailfrom=flygoat.com; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b=KoteGGQY; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=iW2W4Wre; arc=none smtp.client-ip=103.168.172.153 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flygoat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="KoteGGQY"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="iW2W4Wre" Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfhigh.phl.internal (Postfix) with ESMTP id 839D211402A7; Sun, 8 Sep 2024 06:49:46 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Sun, 08 Sep 2024 06:49:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1725792586; x=1725878986; bh=zWA14y3ger96EU3TugDKaEXMdxCpll5lPR6pZSKqCjI=; b= KoteGGQYPOp43jqBiFsL43osRkxc6cFYe2XTHjkfGdMDlHxF7/tgCPrRaneSRohw gJ2CQuDxduYf9wUw88mIylVhCG7hDlMb+EADtAOWLph6YPE54IvfATD4eE1RNZ3E 6mjHbJeiN3ASZSC1mY6InbXx87MaeHdJuI+S8NPK0ZLzrjx1zreCBih9e0dR+XM3 eDGUTkcGCW8xAO323NS+V6v8tTuX/tDxh2ert/LYumBJ3xUxByH408mol8JbmfS7 Ws8tcdpXSxPHQzudl8JFMnHfhCjsXoSiHqQPzVfLSnqbhx0/gTCoBJCIcatOWZLK 3T4xYkSuoci0gukjx1skmA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1725792586; x= 1725878986; bh=zWA14y3ger96EU3TugDKaEXMdxCpll5lPR6pZSKqCjI=; b=i W2W4Wre6rglSz+Bf1NzjaQq4ux7mutuEhcX9j/+rvrVicvEyju1nmnw+1eJ9M2Id 84FTUkHNkIePcAcpM4PZE3n0/PiikQ74lS5BldMuv5rQNdbnhk6mpkm8X8c5UWag YbtfH3/EhlLphTgokMw12VNovFtRSTG77iUDBu3nXzu6TMpRz7swK+ToVdpxd94Y 2JH90NBYMq80VPXTv13ndVUMvhIqg2T3qQ35wbRwNCXK5LTA32FI5iyWhk5Rc5Qf rvwT/zu++gJIXFT04tCgnwjpT0YNZg68UXqzNmOLNwILqseMP1BipnqMfjAPxFop nHBiO78H/u7cARn5TjzUw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudeihedgfedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdej necuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhi hgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffek gedugefhtdduudeghfeuveegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdr tghomhdpnhgspghrtghpthhtohepgedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoh epjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomhdprhgtphhtthhopehlihhn uhigqdhmihhpshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuh igqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehtshgs ohhgvghnugesrghlphhhrgdrfhhrrghnkhgvnhdruggv X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 8 Sep 2024 06:49:45 -0400 (EDT) From: Jiaxun Yang Date: Sun, 08 Sep 2024 11:49:42 +0100 Subject: [PATCH 1/2] MIPS: ftrace: Mark ftrace_get_parent_ra_addr as static Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240908-mips-chore-v1-1-9239c783f233@flygoat.com> References: <20240908-mips-chore-v1-0-9239c783f233@flygoat.com> In-Reply-To: <20240908-mips-chore-v1-0-9239c783f233@flygoat.com> To: Thomas Bogendoerfer Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Jiaxun Yang X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=986; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=gPoxcCvMOPNbUND32tMngwCVFKGByJIbKWjHXDDvWUc=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrS7jR51XTVbPj+4drH3iJQgq05M7/7o5DInaccylWwDd tG1/oEdpSwMYlwMsmKKLCECSn0bGi8uuP4g6w/MHFYmkCEMXJwCMBHhnYwMPVbKxU0/o1c3fU/Y oskdcGV/UJhF0u47c73bN5pm1395xcgw7+z+4H+2yffuvz+8kutefxh3kvT0l58cwhfGqAmyv/f gAwA= X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 This function is only used in ftrace.c. Mark as static to avoid compiler warning. Signed-off-by: Jiaxun Yang --- arch/mips/kernel/ftrace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/mips/kernel/ftrace.c b/arch/mips/kernel/ftrace.c index 8c401e42301c..96016eb1c476 100644 --- a/arch/mips/kernel/ftrace.c +++ b/arch/mips/kernel/ftrace.c @@ -248,8 +248,8 @@ int ftrace_disable_ftrace_graph_caller(void) #define S_R_SP (0xafb0 << 16) /* s{d,w} R, offset(sp) */ #define OFFSET_MASK 0xffff /* stack offset range: 0 ~ PT_SIZE */ -unsigned long ftrace_get_parent_ra_addr(unsigned long self_ra, unsigned long - old_parent_ra, unsigned long parent_ra_addr, unsigned long fp) +static unsigned long ftrace_get_parent_ra_addr(unsigned long self_ra, unsigned long old_parent_ra, + unsigned long parent_ra_addr, unsigned long fp) { unsigned long sp, ip, tmp; unsigned int code; From patchwork Sun Sep 8 10:49:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13795407 Received: from fhigh2-smtp.messagingengine.com (fhigh2-smtp.messagingengine.com [103.168.172.153]) (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 49631152176; Sun, 8 Sep 2024 10:49:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725792589; cv=none; b=WpnUu3QV7sYwMO3GzdfslCN4wQk1GDH5BmLxaeHKvMLQSF7NvstJ4++q/Vy3FYi6a4JRu7ZJxpl5yOeIqSrY3bfA3PxuchUJPWnh8lQvK09GY0Z8Jsg/6+j3th3SuqlrOs1YKGdIJ5lNTWZaEHKFVJQsoPFdpxrLZx7CUGEzU9I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725792589; c=relaxed/simple; bh=3KRdXo0Yoblv1+C/nMOt0XvyZkKnvZsM6lAjdumm6SA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GUpb7Rm3jZY39I8zKDup5enu8vkIegesL5XxuzTbx2JVxAMG/fOwZ7rPpQMDKsoUmmSng9RFTjtoZGhUKyCATdv+JipbAvGGdRG1UYIy7wRfTILTRJyEh9daj9CTFMEFf6VuJQmYe4rmxQ/QILeAXCnp3fUyjxcreNkcH0y035E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com; spf=pass smtp.mailfrom=flygoat.com; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b=rxIxt1zv; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=sJ4LhjYM; arc=none smtp.client-ip=103.168.172.153 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flygoat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="rxIxt1zv"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="sJ4LhjYM" Received: from phl-compute-11.internal (phl-compute-11.phl.internal [10.202.2.51]) by mailfhigh.phl.internal (Postfix) with ESMTP id 7348211402A8; Sun, 8 Sep 2024 06:49:47 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-11.internal (MEProxy); Sun, 08 Sep 2024 06:49:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1725792587; x=1725878987; bh=d5f/16wXObtnjNXxokE78TTUnWRghhQQ15g6S3jFNwU=; b= rxIxt1zvSSOOu6sxP5kw0CjoA0TjgZtZ01dp6EyvcVCodxSzWmCncMwNPTtXiWyD K/iRQl8n4P1lffaByWpOKBAxAvsy9AIrSw4C6bd5u4CjiSJUzalJPO3d8kHSFq4o ObJs3l+BtLdIHcpxWgm4RkjHcWN9iyVaaHGMIxbkzK7QowMp4sd6ILYcI6GdfHXX fyhvcCX0OpvzsLZSIGntADh50w81XFrf9eqgxeuE9x7pEFU2F1VOopYl2BJrSGQK xuqq8u9PcVs5VXsBLvWMSdnz1KV7RdB+Y966fIaEZVv3l0Ro7Z+0QgcQeGDDvrGd eGmeyoJVG6aGbEYY5RHuZA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1725792587; x= 1725878987; bh=d5f/16wXObtnjNXxokE78TTUnWRghhQQ15g6S3jFNwU=; b=s J4LhjYM/7WKl2AAuOFRwAOBkAIVEKD5VkVQFJbV+9zQfaYBAW4eBAcFLYRFA39YC mPew7JHYs9O6BFrzOTNSBrqr3GeEj+G5R1HAjD3GyyGHVtBKAA0FYS9NEl6aHomq IIktQn9j2g+9RYKwEBAgathp3Y1C64+6jl0h8zsY8ZIVx8zpHhq7RegtwTjr7X2E LGOtrIqMvlzCYwK+M+Y4ZywvxllPD43VIbJr5qHsu11nyD6B8eYkfipm1IfDvC5r ltsalIWk1gFKNSTbF4mVFFaBUk/OrkTmseE3xoH6Ac594LfbzS315IXdvQ9nhPbs pKFOZpLJx+YHWy1q4ucJw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudeihedgfedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdej necuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhi hgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffek gedugefhtdduudeghfeuveegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdr tghomhdpnhgspghrtghpthhtohepgedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoh epjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomhdprhgtphhtthhopehlihhn uhigqdhmihhpshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuh igqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehtshgs ohhgvghnugesrghlphhhrgdrfhhrrghnkhgvnhdruggv X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 8 Sep 2024 06:49:46 -0400 (EDT) From: Jiaxun Yang Date: Sun, 08 Sep 2024 11:49:43 +0100 Subject: [PATCH 2/2] MIPS: kprobes: Massage previous delay slot detection Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240908-mips-chore-v1-2-9239c783f233@flygoat.com> References: <20240908-mips-chore-v1-0-9239c783f233@flygoat.com> In-Reply-To: <20240908-mips-chore-v1-0-9239c783f233@flygoat.com> To: Thomas Bogendoerfer Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Jiaxun Yang X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1141; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=3KRdXo0Yoblv1+C/nMOt0XvyZkKnvZsM6lAjdumm6SA=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrS7jR7pLwpZWTNTLPeyxh45Ur9Sr9l/cvSvnI0PnlX48 ecZr7rTUcrCIMbFICumyBIioNS3ofHigusPsv7AzGFlAhnCwMUpABPpUmT4X20jO3/5CRXxxCmV peVR3s6t++4sc6+TKfvyMLfptx1vG8NfqUmR5v7fbn1q9lzd+i7JI3Pn3Lg5eyJUD2f8z78pEmj MDAA= X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 Expand the if condition into cascaded ifs to make code readable. Also use sizeof(union mips_instruction) instead of sizeof(mips_instruction) to match the code context. Signed-off-by: Jiaxun Yang --- arch/mips/kernel/kprobes.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/mips/kernel/kprobes.c b/arch/mips/kernel/kprobes.c index dc39f5b3fb83..96139adefad2 100644 --- a/arch/mips/kernel/kprobes.c +++ b/arch/mips/kernel/kprobes.c @@ -89,12 +89,12 @@ int arch_prepare_kprobe(struct kprobe *p) goto out; } - if (copy_from_kernel_nofault(&prev_insn, p->addr - 1, - sizeof(mips_instruction)) == 0 && - insn_has_delayslot(prev_insn)) { - pr_notice("Kprobes for branch delayslot are not supported\n"); - ret = -EINVAL; - goto out; + if (!copy_from_kernel_nofault(&prev_insn, p->addr - 1, sizeof(union mips_instruction))) { + if (insn_has_delayslot(prev_insn)) { + pr_notice("Kprobes for branch delayslot are not supported\n"); + ret = -EINVAL; + goto out; + } } if (__insn_is_compact_branch(insn)) {