lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240228193238.2102157-3-cristian.marussi@arm.com>
Date: Wed, 28 Feb 2024 19:32:36 +0000
From: Cristian Marussi <cristian.marussi@....com>
To: linux-kernel@...r.kernel.org,
	linux-arm-kernel@...ts.infradead.org
Cc: sudeep.holla@....com,
	james.quinlan@...adcom.com,
	f.fainelli@...il.com,
	vincent.guittot@...aro.org,
	peng.fan@....nxp.com,
	michal.simek@....com,
	quic_sibis@...cinc.com,
	quic_nkela@...cinc.com,
	Cristian Marussi <cristian.marussi@....com>
Subject: [PATCH 2/4] firmware: arm_scmi: Add message dump traces for bad and unexpected replies

Use trace_scmi_msg_dump also to account for late-timed-out, out-of-order
and unexpected replies.

Signed-off-by: Cristian Marussi <cristian.marussi@....com>
---
 drivers/firmware/arm_scmi/driver.c | 36 +++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index 34d77802c990..a3182199f123 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -822,6 +822,13 @@ scmi_xfer_command_acquire(struct scmi_chan_info *cinfo, u32 msg_hdr)
 			"Message for %d type %d is not expected!\n",
 			xfer_id, msg_type);
 		spin_unlock_irqrestore(&minfo->xfer_lock, flags);
+
+		trace_scmi_msg_dump(info->id, cinfo->id,
+				    MSG_XTRACT_PROT_ID(msg_hdr),
+				    MSG_XTRACT_ID(msg_hdr),
+				    !msg_type ? "_!RESP" : "_!DLYD",
+				    xfer_id, 0, NULL, 0);
+
 		return xfer;
 	}
 	refcount_inc(&xfer->users);
@@ -846,6 +853,13 @@ scmi_xfer_command_acquire(struct scmi_chan_info *cinfo, u32 msg_hdr)
 		dev_err(cinfo->dev,
 			"Invalid message type:%d for %d - HDR:0x%X  state:%d\n",
 			msg_type, xfer_id, msg_hdr, xfer->state);
+
+		trace_scmi_msg_dump(info->id, cinfo->id,
+				    MSG_XTRACT_PROT_ID(msg_hdr),
+				    MSG_XTRACT_ID(msg_hdr),
+				    !msg_type ? "_!RESP" : "_!DLYD",
+				    xfer_id, 0, NULL, 0);
+
 		/* On error the refcount incremented above has to be dropped */
 		__scmi_xfer_put(minfo, xfer);
 		xfer = ERR_PTR(-EINVAL);
@@ -882,6 +896,12 @@ static void scmi_handle_notification(struct scmi_chan_info *cinfo,
 	if (IS_ERR(xfer)) {
 		dev_err(dev, "failed to get free message slot (%ld)\n",
 			PTR_ERR(xfer));
+
+		trace_scmi_msg_dump(info->id, cinfo->id,
+				    MSG_XTRACT_PROT_ID(msg_hdr),
+				    MSG_XTRACT_ID(msg_hdr), "_!NOTI",
+				    MSG_XTRACT_TOKEN(msg_hdr), 0, NULL, 0);
+
 		scmi_clear_channel(info, cinfo);
 		return;
 	}
@@ -923,10 +943,18 @@ static void scmi_handle_response(struct scmi_chan_info *cinfo,
 
 	xfer = scmi_xfer_command_acquire(cinfo, msg_hdr);
 	if (IS_ERR(xfer)) {
+		u8 msg_type = MSG_XTRACT_TYPE(msg_hdr);
+
+		trace_scmi_msg_dump(info->id, cinfo->id,
+				    MSG_XTRACT_PROT_ID(msg_hdr),
+				    MSG_XTRACT_ID(msg_hdr),
+				    !msg_type ? "_!RESP" : "_!DLYD",
+				    MSG_XTRACT_TOKEN(msg_hdr), 0, NULL, 0);
+
 		if (IS_ENABLED(CONFIG_ARM_SCMI_RAW_MODE_SUPPORT))
 			scmi_raw_error_report(info->raw, cinfo, msg_hdr, priv);
 
-		if (MSG_XTRACT_TYPE(msg_hdr) == MSG_TYPE_DELAYED_RESP)
+		if (msg_type == MSG_TYPE_DELAYED_RESP)
 			scmi_clear_channel(info, cinfo);
 		return;
 	}
@@ -990,6 +1018,7 @@ static void scmi_handle_response(struct scmi_chan_info *cinfo,
 void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr, void *priv)
 {
 	u8 msg_type = MSG_XTRACT_TYPE(msg_hdr);
+	struct scmi_info *info = handle_to_scmi_info(cinfo->handle);
 
 	switch (msg_type) {
 	case MSG_TYPE_NOTIFICATION:
@@ -1001,6 +1030,11 @@ void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr, void *priv)
 		break;
 	default:
 		WARN_ONCE(1, "received unknown msg_type:%d\n", msg_type);
+		trace_scmi_msg_dump(info->id, cinfo->id,
+				    MSG_XTRACT_PROT_ID(msg_hdr),
+				    MSG_XTRACT_ID(msg_hdr), "_!UNKN",
+				    MSG_XTRACT_TOKEN(msg_hdr), 0, NULL, 0);
+
 		break;
 	}
 }
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ