From patchwork Tue Nov 16 17:32:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 12692789 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 2F2EAC433F5 for ; Tue, 16 Nov 2021 17:34:33 +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 DAD8B615A4 for ; Tue, 16 Nov 2021 17:34:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DAD8B615A4 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=5+60ReWBPS+bx/kdweacaG33AccI6RK8cugThVjEniI=; b=hoNERjBf8Yuowa SAlbaUsPpeGUtsvpJYtWWcJOPjvxEy6BbYs/A7ZqH04XyvbXhgpfeAZHNx1aQqiT6siguocFRZ3St +mopXe3ffFADnxUktjOaxgxRc2hIhY+Dvujnkb/0d4A3zpjee/uZnwNrd8A8rjxlnUjXevpr4vXP8 Uluf+0l4871bO7GCQCOmW0UGA6pMTsyzQGVgvHzszpNLsPycGAA3ApT+jqTxvPnvSLJkgm6Ii+Ch6 QpZ+oO2IR5fxZeUOG60N3oDO2eq9XRCR49/2y7zR4SLg5K7GS8xQcF016xtb9VyGp/WtgEuSCkBgA 8xSLzo5Z+GKadfwNzFDQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mn2KP-002TF6-13; Tue, 16 Nov 2021 17:33:05 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mn2KM-002TEF-0h for linux-arm-kernel@lists.infradead.org; Tue, 16 Nov 2021 17:33:03 +0000 Received: by mail-wr1-x42d.google.com with SMTP id n29so39057489wra.11 for ; Tue, 16 Nov 2021 09:33: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=m8SDQz+S6LtrB733L7RhS3+k/Tfso/qpbqH21msDXEY=; b=AvC9s75MTA2zg+Q7yc/81fLq158JQaPc4nmq3koHSFBIdq6i8UgmjrT5RxxeiJxDNV Oo0rc53GtlokOfOLqWzT1GXYMHuy/2MpXfd+47sZA1kE+eRD+6sbYt0pSXjLog9DXDdm biGfRZFd4M+8kfs8R5v9jDpEoNNAX/uv+0Q+abYGOJ9wZGGZul6w2IZFhfNQrPD6JZjI z+b6/j+3xX0fRQsFjo5F8Y8c/QB8rkLlzuC/R72vZxSEEte+5gjvsl+cC87ijttzGKZv YCnnS87UFzqadmwg9EtQ96wcR217jyfdle9doDiyhkbIY8xMuyZWKD8Fvu7eoBaGdlxN PA6A== 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=m8SDQz+S6LtrB733L7RhS3+k/Tfso/qpbqH21msDXEY=; b=r3xt/+iT3TjGmR+Q9CelR1Q+rlnYZ9pZ8EWABq5nhBDAWFgBrRMBnR5JifuglaX7F3 e7skaPsjZX2UgltK7RdstiXidHb1H+qLKzIbcCVTySqA7nflI0X48a/qS2E7f+EYOlcC d+nKjL59IHfCCv+jTiXWoXC9WkuTxcoDkKOsb14pu2ID8LAjhYYam1VdacpjE0QUFO6S +oddUzAArst8U6AfFrREXx1y9OYm0jBJY0c65NremVuPz3eIybN1K1ggaVhiMA1NGEr9 DLRXvu6H+j0jKVm8elbdTLBFfMTSPdx7Jp+ReBo/8+Df/oZ6tzh/LK+sX5uPrpFKsOn2 U1Bg== X-Gm-Message-State: AOAM530Mz3nOuLYdKHuOd+Ng7yny6ytJflap4D1VeegJgtMgcA9KMrpG 2ZDyHAXWSpqxnPbFMmaII/8GVA== X-Google-Smtp-Source: ABdhPJzObjrDGoNnvV2TwwvPt9KDRI1wfpcJEpqZaMn03F/wwuaGKL4uWgbX0tKQQsjmRWDdtfAAyw== X-Received: by 2002:a5d:674c:: with SMTP id l12mr11148052wrw.439.1637083979982; Tue, 16 Nov 2021 09:32:59 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:f:6020:24f0:d30b:4818:6b7]) by smtp.gmail.com with ESMTPSA id q8sm17720577wrx.71.2021.11.16.09.32.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Nov 2021 09:32: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] arm/scmi: fix base agent discover response Date: Tue, 16 Nov 2021 18:32:55 +0100 Message-Id: <20211116173255.19936-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-20211116_093302_088784_3E7ECADE X-CRM114-Status: GOOD ( 12.53 ) 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 Signed-off-by: Vincent Guittot Reviewed-by: Cristian Marussi Tested-by: Cristian Marussi --- 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);