From nobody Sun May 19 16:31:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+99486+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+99486+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1675348928; cv=none; d=zohomail.com; s=zohoarc; b=mbM7m9bgsouboaWg3kuns1hRl3OvyODMimBie2NxVh+t8Z6V2X82tGbBc5mOW4FCGVukTQBZTdNwGkYfgUaomw6YMv6+hMVuMn5yalfgESohDJNNPm+BERNj5o81Rr3PY7IKlFg7v00eZJhB2sEEy/ioUDuVjlfpaGIgpW7T6Qs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675348928; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=ij2sVKx+g8pocIsE6EgvpsitNrs2/JS2eZ6k0YtD13g=; b=mSVpOeB5KocoE9MYWkRSt8vr0gDsrSK8Hi69a9bxGwHm7YUHz5gqK20lYf0k/g0/QLG3elzdUwZS5bdAHeHfemwp5H2z3Q+a2dSzHTJdICD6kcXonV6ePaX/ZTlTGhFhVqIsvojE4ptjz8Zd2wf2aDDPVBmK5G5wunPitSJFs30= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+99486+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1675348928233841.3232210497135; Thu, 2 Feb 2023 06:42:08 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 42oNYY1788612xVDpPqR6PU3; Thu, 02 Feb 2023 06:42:07 -0800 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.15839.1675348243454307688 for ; Thu, 02 Feb 2023 06:30:43 -0800 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 85025C14; Thu, 2 Feb 2023 06:31:24 -0800 (PST) X-Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 44F583F64C; Thu, 2 Feb 2023 06:30:41 -0800 (PST) From: "Sudeep Holla" To: devel@edk2.groups.io Cc: Sudeep Holla , Leif Lindholm , Ard Biesheuvel , Pierre Gondois , Girish Pathak , Jeff Brasen , Sami Mujawar Subject: [edk2-devel] [PATCH] ArmPkg/ArmScmiDxe: Fix the calculation of RequiredArraySize in ClockDescribeRates() Date: Thu, 2 Feb 2023 14:30:15 +0000 Message-Id: <20230202143015.3066988-1-sudeep.holla@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sudeep.holla@arm.com X-Gm-Message-State: FP8s5ZMUJ9McP8VWdPtkEzpix1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1675348927; bh=CwbuecgxWklTB5RUegYbZE8PCGaUYo4zNifomPI4fRk=; h=Cc:Date:From:Reply-To:Subject:To; b=eDPJknDA0bViSU3flFaJPgRh869LHf/onH+8hEaHgTrrcAn5Wuik6tK8Cu1hO9wrwz4 Qoanbm/rNM6Z5CsIkG/4h9U4DtAeD3JKON9lkDUO1NTwlYLgahp6u2I0zwscbtQCjaLAt DE+egNHXftq5n0EtkzIRGvKDboux2vtK1Ck= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1675348928560100001 Content-Type: text/plain; charset="utf-8" As per the SCMI specification, section CLOCK_DESCRIBE_RATES mentions that the value of num_rates_flags[11:0] in the response must be 3 if the return format is the triplet. Due to the buggy firmware, this was not noticed for long time. The firmware is now fixed resulting in ClockDescribeRates() to fail with "Buffer Too Small" error as the RequiredArraySize gets miscalcula= ted as 72 instead of 24. Fix the issue by reusing the logic for both the return format which must work if num_rates_flags has correct value as expected from the specificatio= n. Cc: Pierre Gondois Cc: Girish Pathak Cc: Jeff Brasen Reported-by: Sami Mujawar Signed-off-by: Sudeep Holla Reviewed-by: Pierre Gondois Tested-by: Pierre Gondois --- ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) Hi All, Sorry for the resend, I hadn't subscribed before so resending after the subscription. Regards, Sudeep diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c b/ArmPkg/Drivers= /ArmScmiDxe/ScmiClockProtocol.c index 12a7e6df5d43..1412717bc227 100644 --- a/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c @@ -236,12 +236,7 @@ ClockDescribeRates ( *TotalRates =3D NUM_RATES (DescribeRates->NumRatesFlags) + NUM_REMAIN_RATES (DescribeRates->NumRatesFlags); =20 - if (*Format =3D=3D ScmiClockRateFormatDiscrete) { - RequiredArraySize =3D (*TotalRates) * sizeof (UINT64); - } else { - // We need to return triplet of 64 bit value for each rate - RequiredArraySize =3D (*TotalRates) * 3 * sizeof (UINT64); - } + RequiredArraySize =3D (*TotalRates) * sizeof (UINT64); =20 if (RequiredArraySize > (*RateArraySize)) { *RateArraySize =3D RequiredArraySize; --=20 2.39.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#99486): https://edk2.groups.io/g/devel/message/99486 Mute This Topic: https://groups.io/mt/96700745/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-