From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: sudeep.holla@arm.com) 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) 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: [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> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 retur= n format is the triplet. Due to the buggy firmware, this was not noticed fo= r long time. The firmware is now fixed resulting in ClockDescribeRates() to fail with "Buffer Too Small" error as the RequiredArraySize gets miscalcu= lated 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 specificat= ion. Cc: Pierre Gondois Cc: Girish Pathak Cc: Jeff Brasen Reported-by: Sami Mujawar Signed-off-by: Sudeep Holla --- 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/Drive= rs/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