* [PATCH v1 0/2] ArmPkg/ArmScmiDxe: Fix a bug uncovered with the new SCP firmware @ 2018-06-15 14:10 Girish Pathak 2018-06-15 14:10 ` [PATCH v1 1/2] ArmPkg/ArmScmiDxe: Fix ASSERT error in SCMI DXE Girish Pathak 2018-06-15 14:10 ` [PATCH v1 2/2] ArmPkg/ArmScmiDxe: Dynamically allocate buffer for protocol ids Girish Pathak 0 siblings, 2 replies; 6+ messages in thread From: Girish Pathak @ 2018-06-15 14:10 UTC (permalink / raw) To: edk2-devel Cc: ard.biesheuvel, leif.lindholm, Matteo.Carlini, Stephanie.Hughes-Fitt, nd This series fixes a bug in the ArmScmiDxe which was revealed while testing with the new SCP firmware. The changes can be seen at https://github.com/girishpathak/edk2/tree/281_scmi_fix_v1 Girish Pathak (2): ArmPkg/ArmScmiDxe: Fix ASSERT error in SCMI DXE ArmPkg/ArmScmiDxe: Dynamically allocate buffer for protocol ids ArmPkg/Drivers/ArmScmiDxe/Scmi.c | 5 -- ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c | 62 ++++++++++++-------- ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h | 9 +-- 3 files changed, 43 insertions(+), 33 deletions(-) -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v1 1/2] ArmPkg/ArmScmiDxe: Fix ASSERT error in SCMI DXE 2018-06-15 14:10 [PATCH v1 0/2] ArmPkg/ArmScmiDxe: Fix a bug uncovered with the new SCP firmware Girish Pathak @ 2018-06-15 14:10 ` Girish Pathak 2018-06-18 17:01 ` Ard Biesheuvel 2018-06-15 14:10 ` [PATCH v1 2/2] ArmPkg/ArmScmiDxe: Dynamically allocate buffer for protocol ids Girish Pathak 1 sibling, 1 reply; 6+ messages in thread From: Girish Pathak @ 2018-06-15 14:10 UTC (permalink / raw) To: edk2-devel Cc: ard.biesheuvel, leif.lindholm, Matteo.Carlini, Stephanie.Hughes-Fitt, nd This change fixes a bug in the SCMI DXE which is observed with the upcoming release of the SCP firmware. The PROTOCOL_ID_MASK (0xF) which is used to generate an index in the ProtocolInitFxns is wrong because protocol ids can be anywhere in 0x10 - 15 or 0x80 - FF range. This mask generates the same index for two different protocols e.g. for protocol ids 0x10 and 0x90, which causes duplicate initialization of a protocol resulting in a failure. This change removes the use of PROTOCOL_ID_MASK and instead uses a list of protocol ids and their initialization functions to identify a supported protocol and initialize it. Change-Id: Ib004294d2bec853045ed6e811d123832fba555cd Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Girish Pathak <girish.pathak@arm.com> --- ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c | 35 ++++++++++---------- ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h | 8 +++-- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c index 2920c6f6f33c5bb8ac00c903a0b199ba5f06f4de..cc68cbc922fcc06bff8f7e0aa8b6bf64a9932874 100644 --- a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c @@ -29,13 +29,10 @@ #include "ScmiDxe.h" #include "ScmiPrivate.h" -STATIC CONST SCMI_PROTOCOL_INIT_TABLE ProtocolInitFxns[MAX_PROTOCOLS] = { - { ScmiBaseProtocolInit }, - { NULL }, - { NULL }, - { ScmiPerformanceProtocolInit }, - { ScmiClockProtocolInit }, - { NULL } +STATIC CONST SCMI_PROTOCOL_ENTRY Protocols[] = { + { SCMI_PROTOCOL_ID_BASE, ScmiBaseProtocolInit }, + { SCMI_PROTOCOL_ID_PERFORMANCE, ScmiPerformanceProtocolInit }, + { SCMI_PROTOCOL_ID_CLOCK, ScmiClockProtocolInit } }; /** ARM SCMI driver entry point function. @@ -65,14 +62,14 @@ ArmScmiDxeEntryPoint ( UINT32 Version; UINT32 Index; UINT32 NumProtocols; - UINT32 ProtocolNo; + UINT32 ProtocolIndex = 0; UINT8 SupportedList[MAX_PROTOCOLS]; UINT32 SupportedListSize = sizeof (SupportedList); - ProtocolNo = SCMI_PROTOCOL_ID_BASE & PROTOCOL_ID_MASK; - // Every SCMI implementation must implement the base protocol. - Status = ProtocolInitFxns[ProtocolNo].Init (&ImageHandle); + ASSERT (Protocols[ProtocolIndex].Id == SCMI_PROTOCOL_ID_BASE); + + Status = Protocols[ProtocolIndex].InitFxn (&ImageHandle); if (EFI_ERROR (Status)) { ASSERT (FALSE); return Status; @@ -123,13 +120,15 @@ ArmScmiDxeEntryPoint ( } // Install supported protocol on ImageHandle. - for (Index = 0; Index < NumProtocols; Index++) { - ProtocolNo = SupportedList[Index] & PROTOCOL_ID_MASK; - if (ProtocolInitFxns[ProtocolNo].Init != NULL) { - Status = ProtocolInitFxns[ProtocolNo].Init (&ImageHandle); - if (EFI_ERROR (Status)) { - ASSERT (FALSE); - return Status; + while (++ProtocolIndex < ARRAY_SIZE (Protocols)) { + for (Index = 0; Index < NumProtocols; Index++) { + if (Protocols[ProtocolIndex].Id == SupportedList[Index]) { + Status = Protocols[ProtocolIndex].InitFxn (&ImageHandle); + if (EFI_ERROR (Status)) { + ASSERT (FALSE); + return Status; + } + break; } } } diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h index 29cdde173659c701116b021a3c437a92b473e4e5..5815e1e78074067760b6f618e248526ee25e59c8 100644 --- a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h @@ -17,8 +17,9 @@ #ifndef SCMI_DXE_H_ #define SCMI_DXE_H_ +#include "ScmiPrivate.h" + #define MAX_PROTOCOLS 6 -#define PROTOCOL_ID_MASK 0xF #define MAX_VENDOR_LEN SCMI_MAX_STR_LEN /** Pointer to protocol initialization function. @@ -35,7 +36,8 @@ EFI_STATUS ); typedef struct { - SCMI_PROTOCOL_INIT_FXN Init; -} SCMI_PROTOCOL_INIT_TABLE; + SCMI_PROTOCOL_ID Id; // Protocol Id. + SCMI_PROTOCOL_INIT_FXN InitFxn; // Protocol init function. +} SCMI_PROTOCOL_ENTRY; #endif /* SCMI_DXE_H_ */ -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/2] ArmPkg/ArmScmiDxe: Fix ASSERT error in SCMI DXE 2018-06-15 14:10 ` [PATCH v1 1/2] ArmPkg/ArmScmiDxe: Fix ASSERT error in SCMI DXE Girish Pathak @ 2018-06-18 17:01 ` Ard Biesheuvel 0 siblings, 0 replies; 6+ messages in thread From: Ard Biesheuvel @ 2018-06-18 17:01 UTC (permalink / raw) To: Girish Pathak Cc: edk2-devel@lists.01.org, Leif Lindholm, Matteo Carlini, Stephanie Hughes-Fitt, nd Hello Girish, On 15 June 2018 at 16:10, Girish Pathak <girish.pathak@arm.com> wrote: > This change fixes a bug in the SCMI DXE which is observed with the > upcoming release of the SCP firmware. > > The PROTOCOL_ID_MASK (0xF) which is used to generate an index in > the ProtocolInitFxns is wrong because protocol ids can be > anywhere in 0x10 - 15 or 0x80 - FF range. This mask generates > the same index for two different protocols e.g. for protocol ids > 0x10 and 0x90, which causes duplicate initialization of a protocol > resulting in a failure. > > This change removes the use of PROTOCOL_ID_MASK and instead > uses a list of protocol ids and their initialization functions > to identify a supported protocol and initialize it. > > Change-Id: Ib004294d2bec853045ed6e811d123832fba555cd > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Girish Pathak <girish.pathak@arm.com> > --- > ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c | 35 ++++++++++---------- > ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h | 8 +++-- > 2 files changed, 22 insertions(+), 21 deletions(-) > > diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c > index 2920c6f6f33c5bb8ac00c903a0b199ba5f06f4de..cc68cbc922fcc06bff8f7e0aa8b6bf64a9932874 100644 > --- a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c > +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c > @@ -29,13 +29,10 @@ > #include "ScmiDxe.h" > #include "ScmiPrivate.h" > > -STATIC CONST SCMI_PROTOCOL_INIT_TABLE ProtocolInitFxns[MAX_PROTOCOLS] = { > - { ScmiBaseProtocolInit }, > - { NULL }, > - { NULL }, > - { ScmiPerformanceProtocolInit }, > - { ScmiClockProtocolInit }, > - { NULL } > +STATIC CONST SCMI_PROTOCOL_ENTRY Protocols[] = { > + { SCMI_PROTOCOL_ID_BASE, ScmiBaseProtocolInit }, > + { SCMI_PROTOCOL_ID_PERFORMANCE, ScmiPerformanceProtocolInit }, > + { SCMI_PROTOCOL_ID_CLOCK, ScmiClockProtocolInit } > }; > > /** ARM SCMI driver entry point function. > @@ -65,14 +62,14 @@ ArmScmiDxeEntryPoint ( > UINT32 Version; > UINT32 Index; > UINT32 NumProtocols; > - UINT32 ProtocolNo; > + UINT32 ProtocolIndex = 0; We don't permit initialized automatic variables. > UINT8 SupportedList[MAX_PROTOCOLS]; > UINT32 SupportedListSize = sizeof (SupportedList); This applies here as well, but it slipped through the cracks last time. Care to fix this one as well? Thanks. > > - ProtocolNo = SCMI_PROTOCOL_ID_BASE & PROTOCOL_ID_MASK; > - > // Every SCMI implementation must implement the base protocol. > - Status = ProtocolInitFxns[ProtocolNo].Init (&ImageHandle); > + ASSERT (Protocols[ProtocolIndex].Id == SCMI_PROTOCOL_ID_BASE); > + Just use Protocols[0].Id here instead of obfuscating the code with a var reference known to be == 0 > + Status = Protocols[ProtocolIndex].InitFxn (&ImageHandle); Same here. In fact, why not just call ScmiBaseProtocolInit() here? > if (EFI_ERROR (Status)) { > ASSERT (FALSE); > return Status; > @@ -123,13 +120,15 @@ ArmScmiDxeEntryPoint ( > } > > // Install supported protocol on ImageHandle. > - for (Index = 0; Index < NumProtocols; Index++) { > - ProtocolNo = SupportedList[Index] & PROTOCOL_ID_MASK; > - if (ProtocolInitFxns[ProtocolNo].Init != NULL) { > - Status = ProtocolInitFxns[ProtocolNo].Init (&ImageHandle); > - if (EFI_ERROR (Status)) { > - ASSERT (FALSE); > - return Status; > + while (++ProtocolIndex < ARRAY_SIZE (Protocols)) { Please use a for () loop here, including the 0 assignment that replaces the initializer above. > + for (Index = 0; Index < NumProtocols; Index++) { > + if (Protocols[ProtocolIndex].Id == SupportedList[Index]) { > + Status = Protocols[ProtocolIndex].InitFxn (&ImageHandle); > + if (EFI_ERROR (Status)) { > + ASSERT (FALSE); In general, ASSERT_EFI_ERROR () is really much more useful than ASSERT (FALSE), because the DEBUG output will tell you the actual value of Status. Just a tip. > + return Status; > + } > + break; > } > } > } > diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h > index 29cdde173659c701116b021a3c437a92b473e4e5..5815e1e78074067760b6f618e248526ee25e59c8 100644 > --- a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h > +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h > @@ -17,8 +17,9 @@ > #ifndef SCMI_DXE_H_ > #define SCMI_DXE_H_ > > +#include "ScmiPrivate.h" > + > #define MAX_PROTOCOLS 6 > -#define PROTOCOL_ID_MASK 0xF > #define MAX_VENDOR_LEN SCMI_MAX_STR_LEN > > /** Pointer to protocol initialization function. > @@ -35,7 +36,8 @@ EFI_STATUS > ); > > typedef struct { > - SCMI_PROTOCOL_INIT_FXN Init; > -} SCMI_PROTOCOL_INIT_TABLE; > + SCMI_PROTOCOL_ID Id; // Protocol Id. > + SCMI_PROTOCOL_INIT_FXN InitFxn; // Protocol init function. Could you replace this with InitFn please? Fxn as an abbreviation for function is not idiomatic in any of the projects I have ever been involved in, so let's not confuse people unnecessarily. > +} SCMI_PROTOCOL_ENTRY; > > #endif /* SCMI_DXE_H_ */ > -- > 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' > > ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v1 2/2] ArmPkg/ArmScmiDxe: Dynamically allocate buffer for protocol ids 2018-06-15 14:10 [PATCH v1 0/2] ArmPkg/ArmScmiDxe: Fix a bug uncovered with the new SCP firmware Girish Pathak 2018-06-15 14:10 ` [PATCH v1 1/2] ArmPkg/ArmScmiDxe: Fix ASSERT error in SCMI DXE Girish Pathak @ 2018-06-15 14:10 ` Girish Pathak 2018-06-18 16:40 ` [PATCH v1 0/2] ArmPkg/ArmScmiDxe: Fix a bug uncovered with the new SCP firmware Sudeep Holla 2018-06-18 17:05 ` [PATCH v1 2/2] ArmPkg/ArmScmiDxe: Dynamically allocate buffer for protocol ids Ard Biesheuvel 1 sibling, 2 replies; 6+ messages in thread From: Girish Pathak @ 2018-06-15 14:10 UTC (permalink / raw) To: edk2-devel Cc: ard.biesheuvel, leif.lindholm, Matteo.Carlini, Stephanie.Hughes-Fitt, nd Dynamically allocate the buffer to receive the SCMI protocol list. This makes MAX_PROTOCOLS redundant, so it is removed. It also fixes one minor code alignment issue and removes an unused macro PROTOCOL_MASK. Change-Id: Idc5880d4fb7b5c674f5fb7dce1198a7cad0303a7 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Girish Pathak <girish.pathak@arm.com> --- ArmPkg/Drivers/ArmScmiDxe/Scmi.c | 5 ---- ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c | 27 +++++++++++++++----- ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h | 1 - 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/ArmPkg/Drivers/ArmScmiDxe/Scmi.c b/ArmPkg/Drivers/ArmScmiDxe/Scmi.c index 1e279f69cf615428dbb6477b8ac7de3258628df3..d247d3a932fe9f197460a95e9afa88681742e4b4 100644 --- a/ArmPkg/Drivers/ArmScmiDxe/Scmi.c +++ b/ArmPkg/Drivers/ArmScmiDxe/Scmi.c @@ -22,11 +22,6 @@ #include "ScmiPrivate.h" -// SCMI Specification 1.0 -#define MAX_PROTOCOLS 6 - -#define PROTOCOL_MASK 0xF - // Arbitrary timeout value 20ms. #define RESPONSE_TIMEOUT 20000 diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c index cc68cbc922fcc06bff8f7e0aa8b6bf64a9932874..e7b9feca5e1b565fc031385bfe2f2dc0ca53aab0 100644 --- a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c @@ -63,8 +63,8 @@ ArmScmiDxeEntryPoint ( UINT32 Index; UINT32 NumProtocols; UINT32 ProtocolIndex = 0; - UINT8 SupportedList[MAX_PROTOCOLS]; - UINT32 SupportedListSize = sizeof (SupportedList); + UINT8 *SupportedList; + UINT32 SupportedListSize; // Every SCMI implementation must implement the base protocol. ASSERT (Protocols[ProtocolIndex].Id == SCMI_PROTOCOL_ID_BASE); @@ -108,13 +108,26 @@ ArmScmiDxeEntryPoint ( ASSERT (NumProtocols != 0); + SupportedListSize = (NumProtocols * sizeof (*SupportedList)); + + Status = gBS->AllocatePool ( + EfiBootServicesData, + SupportedListSize, + (VOID**)&SupportedList + ); + if (EFI_ERROR (Status)) { + ASSERT (FALSE); + return Status; + } + // Get the list of protocols supported by SCP firmware on the platform. Status = BaseProtocol->DiscoverListProtocols ( - BaseProtocol, - &SupportedListSize, - SupportedList - ); + BaseProtocol, + &SupportedListSize, + SupportedList + ); if (EFI_ERROR (Status)) { + gBS->FreePool (SupportedList); ASSERT (FALSE); return Status; } @@ -133,5 +146,7 @@ ArmScmiDxeEntryPoint ( } } + gBS->FreePool (SupportedList); + return EFI_SUCCESS; } diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h index 5815e1e78074067760b6f618e248526ee25e59c8..b50a52a01d47efbbccec8c97bf44041c47ff8b38 100644 --- a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h @@ -19,7 +19,6 @@ #include "ScmiPrivate.h" -#define MAX_PROTOCOLS 6 #define MAX_VENDOR_LEN SCMI_MAX_STR_LEN /** Pointer to protocol initialization function. -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v1 0/2] ArmPkg/ArmScmiDxe: Fix a bug uncovered with the new SCP firmware 2018-06-15 14:10 ` [PATCH v1 2/2] ArmPkg/ArmScmiDxe: Dynamically allocate buffer for protocol ids Girish Pathak @ 2018-06-18 16:40 ` Sudeep Holla 2018-06-18 17:05 ` [PATCH v1 2/2] ArmPkg/ArmScmiDxe: Dynamically allocate buffer for protocol ids Ard Biesheuvel 1 sibling, 0 replies; 6+ messages in thread From: Sudeep Holla @ 2018-06-18 16:40 UTC (permalink / raw) To: Girish Pathak, edk2-devel Cc: Stephanie Hughes-Fitt, Leif Lindholm, Ard Biesheuvel, Sudeep Holla Hi Girish, On Fri, Jun 15, 2018 at 03:10:52PM +0100, Girish Pathak wrote: > This series fixes a bug in the ArmScmiDxe which was revealed while testing > with the new SCP firmware. > > The changes can be seen at https://github.com/girishpathak/edk2/tree/281_scmi_fix_v1 > Thanks for the fix. This fixes the issue I originally reported. So, FWIW Tested-by: Sudeep Holla <sudeep.holla@arm.com> -- Regards, Sudeep ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 2/2] ArmPkg/ArmScmiDxe: Dynamically allocate buffer for protocol ids 2018-06-15 14:10 ` [PATCH v1 2/2] ArmPkg/ArmScmiDxe: Dynamically allocate buffer for protocol ids Girish Pathak 2018-06-18 16:40 ` [PATCH v1 0/2] ArmPkg/ArmScmiDxe: Fix a bug uncovered with the new SCP firmware Sudeep Holla @ 2018-06-18 17:05 ` Ard Biesheuvel 1 sibling, 0 replies; 6+ messages in thread From: Ard Biesheuvel @ 2018-06-18 17:05 UTC (permalink / raw) To: Girish Pathak Cc: edk2-devel@lists.01.org, Leif Lindholm, Matteo Carlini, Stephanie Hughes-Fitt, nd On 15 June 2018 at 16:10, Girish Pathak <girish.pathak@arm.com> wrote: > Dynamically allocate the buffer to receive the SCMI protocol list. > This makes MAX_PROTOCOLS redundant, so it is removed. > It also fixes one minor code alignment issue and removes an unused > macro PROTOCOL_MASK. > > Change-Id: Idc5880d4fb7b5c674f5fb7dce1198a7cad0303a7 Can you please get rid of these change IDs? They have no meaning in the context of the upstream repo. > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Girish Pathak <girish.pathak@arm.com> > --- > ArmPkg/Drivers/ArmScmiDxe/Scmi.c | 5 ---- > ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c | 27 +++++++++++++++----- > ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h | 1 - > 3 files changed, 21 insertions(+), 12 deletions(-) > > diff --git a/ArmPkg/Drivers/ArmScmiDxe/Scmi.c b/ArmPkg/Drivers/ArmScmiDxe/Scmi.c > index 1e279f69cf615428dbb6477b8ac7de3258628df3..d247d3a932fe9f197460a95e9afa88681742e4b4 100644 > --- a/ArmPkg/Drivers/ArmScmiDxe/Scmi.c > +++ b/ArmPkg/Drivers/ArmScmiDxe/Scmi.c > @@ -22,11 +22,6 @@ > > #include "ScmiPrivate.h" > > -// SCMI Specification 1.0 > -#define MAX_PROTOCOLS 6 > - > -#define PROTOCOL_MASK 0xF > - > // Arbitrary timeout value 20ms. > #define RESPONSE_TIMEOUT 20000 > > diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c > index cc68cbc922fcc06bff8f7e0aa8b6bf64a9932874..e7b9feca5e1b565fc031385bfe2f2dc0ca53aab0 100644 > --- a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c > +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c > @@ -63,8 +63,8 @@ ArmScmiDxeEntryPoint ( > UINT32 Index; > UINT32 NumProtocols; > UINT32 ProtocolIndex = 0; > - UINT8 SupportedList[MAX_PROTOCOLS]; > - UINT32 SupportedListSize = sizeof (SupportedList); Ah excellent. Forget what I said about this line in the previous message. > + UINT8 *SupportedList; > + UINT32 SupportedListSize; > > // Every SCMI implementation must implement the base protocol. > ASSERT (Protocols[ProtocolIndex].Id == SCMI_PROTOCOL_ID_BASE); > @@ -108,13 +108,26 @@ ArmScmiDxeEntryPoint ( > > ASSERT (NumProtocols != 0); > > + SupportedListSize = (NumProtocols * sizeof (*SupportedList)); > + > + Status = gBS->AllocatePool ( > + EfiBootServicesData, > + SupportedListSize, > + (VOID**)&SupportedList > + ); > + if (EFI_ERROR (Status)) { > + ASSERT (FALSE); > + return Status; > + } > + > // Get the list of protocols supported by SCP firmware on the platform. > Status = BaseProtocol->DiscoverListProtocols ( > - BaseProtocol, > - &SupportedListSize, > - SupportedList > - ); > + BaseProtocol, > + &SupportedListSize, > + SupportedList > + ); > if (EFI_ERROR (Status)) { > + gBS->FreePool (SupportedList); > ASSERT (FALSE); > return Status; > } > @@ -133,5 +146,7 @@ ArmScmiDxeEntryPoint ( > } > } > > + gBS->FreePool (SupportedList); > + > return EFI_SUCCESS; > } > diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h > index 5815e1e78074067760b6f618e248526ee25e59c8..b50a52a01d47efbbccec8c97bf44041c47ff8b38 100644 > --- a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h > +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h > @@ -19,7 +19,6 @@ > > #include "ScmiPrivate.h" > > -#define MAX_PROTOCOLS 6 > #define MAX_VENDOR_LEN SCMI_MAX_STR_LEN > > /** Pointer to protocol initialization function. > -- > 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' > > ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-06-18 17:05 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-06-15 14:10 [PATCH v1 0/2] ArmPkg/ArmScmiDxe: Fix a bug uncovered with the new SCP firmware Girish Pathak 2018-06-15 14:10 ` [PATCH v1 1/2] ArmPkg/ArmScmiDxe: Fix ASSERT error in SCMI DXE Girish Pathak 2018-06-18 17:01 ` Ard Biesheuvel 2018-06-15 14:10 ` [PATCH v1 2/2] ArmPkg/ArmScmiDxe: Dynamically allocate buffer for protocol ids Girish Pathak 2018-06-18 16:40 ` [PATCH v1 0/2] ArmPkg/ArmScmiDxe: Fix a bug uncovered with the new SCP firmware Sudeep Holla 2018-06-18 17:05 ` [PATCH v1 2/2] ArmPkg/ArmScmiDxe: Dynamically allocate buffer for protocol ids Ard Biesheuvel
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox