From patchwork Wed Nov 17 08:18:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 12692857 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23BE7C433F5 for ; Wed, 17 Nov 2021 08:20:31 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CBCBA61546 for ; Wed, 17 Nov 2021 08:20:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CBCBA61546 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=BE9VYd6H9XiMzfdLwB0M02zGAQE/DFgzywXxAmAtMlM=; b=pItuCNnTomBVMp Qq0/NLrRfSC6j7PX3ME5tEqmrbcBdOl6llN/RStD87oP2ocFIsL9850YBEROmV2iy1x/LiHon9QEP cUam8P0LL5XqvYfeiAeZp9HhGjjkGa3k4CnQgMXtOzG0+hZ8ZiAVLHsjAE6UfsErXuCWgZZC4zYZ7 S9K9eKfdXFZHWNmNdfrDqNisBt1zlVvKU0cfmh2mUhQTU0Je8X6VYF18isTZTT3BDZzzGcyn+3M5V Bc9l8OVKw0VZND7Ehc7DBqh4vyFxqpCfOBFZlEiqeP7498Plk+uHqz8nyI7nupxsc+HLmnVpRJo1y s/4UZc6OQiq8utjJmhBw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mnG9q-003vKv-Hr; Wed, 17 Nov 2021 08:19:06 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mnG9m-003vK8-Ty for linux-arm-kernel@lists.infradead.org; Wed, 17 Nov 2021 08:19:04 +0000 Received: by mail-wm1-x32e.google.com with SMTP id o29so1375358wms.2 for ; Wed, 17 Nov 2021 00:19:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=gJO+hq67wFWIADyKs7hg47r83klJFHiDVa9gUS5v9J8=; b=quTwTPHH+rAXIkc/+l5DE4z2+gAKWVNjg1OCK018bHrffz0C0nDb5GEJHXGrQ01CQL Ziea4IeXjSPgC8BvxMh+Dl6NvzqTr/9lACqC6GoNlstd5wQ9Vl4vphNvtu0+RUwR8U76 I9/NPr/qj95YZcchye9J5w73dHLUDH7EHmR8jIbU7uO2iODzcCVH2yWp6cFtHeYsNAFf 1sgh61pp0jHPxr7K52vXfLZqF/vAwL83NUQ7QsmuFhA+S7WohICY5uk4Lr5xv5P428Y7 XinfvJ4s33iuyUnAZlk/Rkb3rJhki6OM/VwTdDHsnddgVWrgxz8BGtzmiCz+HG9Ch+7o Ld4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=gJO+hq67wFWIADyKs7hg47r83klJFHiDVa9gUS5v9J8=; b=kjVqjxrDViGqkqrAfhJCjvzEBVCThUc+CVAt+gyFm0lDj7AXzuQsU6Q96iboOoHpQj 9LLbr6omyCjVliXHnUzMq6WNt0eP9r5Qvqh5dwgqn5TFhrfsA7qqGoccJA/V4MHo9aFO GfqJw8t8N5OFdvTfJpiR65Jgw0hH/HEoixxZn0uO3NsuPU9KzosC5viFGYHDgB8wft2N fWnT/KibgCYeWXi0rsiWRX/IU+uGtFNKprW863RsSEFJR3OdmPtbMmiNeFQPE+uDkka8 prjIbAg8cWBnMKq4DxbkmZ1KJNK3UVOtrKC1vJXTAquc1uXIU+HD7eVIxRBjAM86E5cT +kvw== X-Gm-Message-State: AOAM53364dU7NJGt7uP7RRzV0K8KTNGgwS7iL9a9xbC/FtbGo1ovkp2p iBn5h6/FuByinZpiFHo9ae5xxw== X-Google-Smtp-Source: ABdhPJxHRS+Yy3wpCUHh2hkl176fv28z9dLSXZaKn4MqGrtRjCVloK/qmx3sLpk46mOmJqUG7VEwBA== X-Received: by 2002:a05:600c:35cb:: with SMTP id r11mr77914397wmq.190.1637137140659; Wed, 17 Nov 2021 00:19:00 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:f:6020:24f0:d30b:4818:6b7]) by smtp.gmail.com with ESMTPSA id s8sm14598254wro.19.2021.11.17.00.18.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Nov 2021 00:18:59 -0800 (PST) From: Vincent Guittot To: sudeep.holla@arm.com, cristian.marussi@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Vincent Guittot Subject: [PATCH v2] arm/scmi: fix base agent discover response Date: Wed, 17 Nov 2021 09:18:56 +0100 Message-Id: <20211117081856.9932-1-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211117_001902_988793_BFFF7385 X-CRM114-Status: GOOD ( 13.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org According to scmi specification, the response of the discover agent request is made of: - int32 status - uint32 agent_id - uint8 name[16] but the current implementation doesn't take into account the agent_id field and only allocates a rx buffer of SCMI_MAX_STR_SIZE length Allocate the correct length for rx buffer and copy the name from the correct offset in the response. While no error were returned until v5.15, v5.16-rc1 fails with virtio_scmi transport channel: [ 1.093253] arm-scmi firmware:scmi0: SCMI Notifications - Core Enabled. [ 1.114776] arm-scmi firmware:scmi0: SCMI Protocol v2.0 'Linaro:PMWG' Firmware version 0x2090000 [ 1.117544] scmi-virtio virtio0: tx:used len 28 is larger than in buflen 24 Fixes: b6f20ff8bd94 ("firmware: arm_scmi: add common infrastructure and support for base protocol") Signed-off-by: Vincent Guittot Reviewed-by: Cristian Marussi Tested-by: Cristian Marussi --- Change since v1: - Added Fixes tag - Added Tested and Review tag drivers/firmware/arm_scmi/base.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/arm_scmi/base.c b/drivers/firmware/arm_scmi/base.c index de416f9e7921..f5219334fd3a 100644 --- a/drivers/firmware/arm_scmi/base.c +++ b/drivers/firmware/arm_scmi/base.c @@ -34,6 +34,12 @@ struct scmi_msg_resp_base_attributes { __le16 reserved; }; +struct scmi_msg_resp_base_discover_agent { + __le32 agent_id; + u8 name[SCMI_MAX_STR_SIZE]; +}; + + struct scmi_msg_base_error_notify { __le32 event_control; #define BASE_TP_NOTIFY_ALL BIT(0) @@ -225,18 +231,21 @@ static int scmi_base_discover_agent_get(const struct scmi_protocol_handle *ph, int id, char *name) { int ret; + struct scmi_msg_resp_base_discover_agent *agent_info; struct scmi_xfer *t; ret = ph->xops->xfer_get_init(ph, BASE_DISCOVER_AGENT, - sizeof(__le32), SCMI_MAX_STR_SIZE, &t); + sizeof(__le32), sizeof(*agent_info), &t); if (ret) return ret; put_unaligned_le32(id, t->tx.buf); ret = ph->xops->do_xfer(ph, t); - if (!ret) - strlcpy(name, t->rx.buf, SCMI_MAX_STR_SIZE); + if (!ret) { + agent_info = t->rx.buf; + strlcpy(name, agent_info->name, SCMI_MAX_STR_SIZE); + } ph->xops->xfer_put(ph, t);