[edk2-devel] [PATCH] ArmPkg/ArmScmiDxe: Fix the calculation of RequiredArraySize in ClockDescribeRates()

Sudeep Holla sudeep.holla at arm.com
Thu Feb 2 14:30:15 UTC 2023


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 miscalculated
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 specification.

Cc: Pierre Gondois <Pierre.Gondois at arm.com>
Cc: Girish Pathak <girish.pathak at arm.com>
Cc: Jeff Brasen <jbrasen at nvidia.com>
Reported-by: Sami Mujawar <sami.mujawar at arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla at arm.com>
---
 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 = NUM_RATES (DescribeRates->NumRatesFlags)
                     + NUM_REMAIN_RATES (DescribeRates->NumRatesFlags);
 
-      if (*Format == ScmiClockRateFormatDiscrete) {
-        RequiredArraySize = (*TotalRates) * sizeof (UINT64);
-      } else {
-        // We need to return triplet of 64 bit value for each rate
-        RequiredArraySize = (*TotalRates) * 3 * sizeof (UINT64);
-      }
+      RequiredArraySize = (*TotalRates) * sizeof (UINT64);
 
       if (RequiredArraySize > (*RateArraySize)) {
         *RateArraySize = RequiredArraySize;
-- 
2.39.1



-=-=-=-=-=-=-=-=-=-=-=-
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/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list