On Mar 1, 2020, at 3:41 PM, Michael D Kinney <michael.d.kinney@intel.com> wrote:Andrew,
Thanks. I did not realize this was a struct with
a single flexible array member. I agree that does
not make sense.
The top level struct here is a HOB that must be in
contiguous memory. The HOB can vary in size based on
MicrocodeCount and StorageType. We are trying to make
it easy to write the C code that produces and consumes
this HOB. Using flexible array members helps improve
the readability when structures have this attribute.
For the storage type defined, the StorageContext is a
single UINT64 value. Other storage type GUIDs may have
more complex StorageContext structures. This array
of structures is guaranteed to start on an 8-byte
boundary, so the use case is to cast the start of
the StorageContext to the defined type and access
the array if structures and their fields.
Do you have any suggestions on how to make this
better?
Mike-----Original Message-----
From: afish@apple.com <afish@apple.com>
Sent: Thursday, February 27, 2020 7:43 AM
To: devel@edk2.groups.io; Kinney, Michael D
<michael.d.kinney@intel.com>
Cc: Gao, Liming <liming.gao@intel.com>; Fu, Siyuan
<siyuan.fu@intel.com>; Ni, Ray <ray.ni@intel.com>;
Chaganty, Rangasai V <rangasai.v.chaganty@intel.com>
Subject: Re: [edk2-devel] [Patch]
IntelSiliconPkg/ShadowMicrocodePei: Fix GCC build
error.
Mike,
Flexible array members must be the last element of a
struct but they can not be the only element.
This is non standard behavior from the compilers that
are not throwing the error.
Why not just use a pointer?On Feb 26, 2020, at 10:03 PM, Michael D Kinney<michael.d.kinney@intel.com> wrote:5.5
Liming,
This does not make sense. Those compilers
should support C99 flexible array members.
Structured PCDs also require use of flexible
array members.
We need to make sure the compiler flags for
those tool chain are correct to support flexible
array members.
Mike-----Original Message-----
From: Gao, Liming <liming.gao@intel.com>
Sent: Wednesday, February 26, 2020 9:58 PM
To: devel@edk2.groups.io; Kinney, Michael D
<michael.d.kinney@intel.com>; Fu, Siyuan
<siyuan.fu@intel.com>
Cc: Ni, Ray <ray.ni@intel.com>; Chaganty, Rangasai V
<rangasai.v.chaganty@intel.com>
Subject: RE: [edk2-devel] [Patch]
IntelSiliconPkg/ShadowMicrocodePei: Fix GCC build
error.
Mike:
I find this issue on GCC5 tool chain tag with GCCOnand CLANGPDB tool chain tag with CLANG 9.0.0
Thanks
Liming-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io><siyuan.fu@intel.com>;Behalf Of Michael D KinneySent: Thursday, February 27, 2020 1:54 PMdevel@edk2.groups.io; Fu, Siyuan
To: Gao, Liming <liming.gao@intel.com>;VKinney, Michael D<michael.d.kinney@intel.com>
Cc: Ni, Ray <ray.ni@intel.com>; Chaganty, Rangasai<michael.d.kinney@intel.com>;<rangasai.v.chaganty@intel.com>Subject: Re: [edk2-devel] [Patch]IntelSiliconPkg/ShadowMicrocodePei: Fix GCC build
error.
Which GCC and CLANG tool chain tags?
Flexible array member is a standard C feature
documented in C99.
Mike-----Original Message-----
From: Gao, Liming <liming.gao@intel.com>
Sent: Wednesday, February 26, 2020 9:38 PM
To: Kinney, Michael Dplatforms\Silicon\Intel\IntelSiliconPkg\Include\Guid/Mi<siyuan.fu@intel.com>devel@edk2.groups.io; Fu, SiyuanVCc: Ni, Ray <ray.ni@intel.com>; Chaganty, Rangasaithe<rangasai.v.chaganty@intel.com>
Subject: RE: [edk2-devel] [Patch]
IntelSiliconPkg/ShadowMicrocodePei: Fix GCC build
error.
Mike:
I find GCC and CLANG will report the error forempty struct.
d:\allpkg\edk2-arraycrocodeShadowInfoHob.h:61:11: error: flexiblehttps://tianocore.acgmultimedia.com/show_bug.cgi?id=244<michael.d.kinney@intel.com>member 'MicrocodeAddressInFlash' not allowed in
otherwise empty struct
UINT64 MicrocodeAddressInFlash[];
^
1 error generated.
Thanks
Liming-----Original Message-----
From: Kinney, Michael DRangasai VSent: Thursday, February 27, 2020 1:25 PM<siyuan.fu@intel.com>; Kinney, Michael D
To: devel@edk2.groups.io; Fu, Siyuan
<michael.d.kinney@intel.com>Cc: Ni, Ray <ray.ni@intel.com>; Chaganty,<devel@edk2.groups.io><rangasai.v.chaganty@intel.com>; Gao, Liming
<liming.gao@intel.com>Subject: RE: [edk2-devel] [Patch]IntelSiliconPkg/ShadowMicrocodePei: Fix GCC build
error.
What compiler does not like the flexible array
member syntax [].
Mike-----Original Message-----
From: devel@edk2.groups.ioRangasaiOnBehalf Of Siyuan, Fu
Sent: Wednesday, February 26, 2020 5:58 PM
To: devel@edk2.groups.io
Cc: Ni, Ray <ray.ni@intel.com>; Chaganty,buildV<rangasai.v.chaganty@intel.com>; Gao, Liming
<liming.gao@intel.com>
Subject: [edk2-devel] [Patch]
IntelSiliconPkg/ShadowMicrocodePei: Fix GCCcommiterror.
This patch fixes compiler error introduced byb0099a39bd.
BZ:.../Intel/IntelSiliconPkg/Include/Guid/MicrocodeShadowI.../Feature/ShadowMicrocode/ShadowMicrocodePei.c<rangasai.v.chaganty@intel.com>9
Cc: Ray Ni <ray.ni@intel.com>
Cc: Rangasai V ChagantyCc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Siyuan Fu <siyuan.fu@intel.com>
---| 2 +-a/Silicon/Intel/IntelSiliconPkg/Feature/ShadowMicrocodedeletions(-)nfoHob.h | 2 +-
2 files changed, 2 insertions(+), 2
diff --gitb/Silicon/Intel/IntelSiliconPkg/Feature/ShadowMicrocode/ShadowMicrocodePei.ca/Silicon/Intel/IntelSiliconPkg/Feature/ShadowMicrocode/ShadowMicrocodePei.c
index 7e4084247e..8d6574f667 100644
---b/Silicon/Intel/IntelSiliconPkg/Feature/ShadowMicrocode/ShadowMicrocodePei.c
+++a/Silicon/Intel/IntelSiliconPkg/Include/Guid/MicrocodeS(/ShadowMicrocodePei.c
@@ -247,7 +247,7 @@ ShadowMicrocodePatchWorkerMicrocodeAddressInFlash[Index]Walker;(VOID *) Patches[Index].Address,
Patches[Index].Size
);
- MicrocodeAddressInMemory[Index] = (UINT64)(UINTN)+ MicrocodeAddressInMemory[Index] = (UINT64)Walker;
Flashcontext-=(UINT64) Patches[Index].Address;
Walker += Patches[Index].Size;
}
diff --gitb/Silicon/Intel/IntelSiliconPkg/Include/Guid/MicrocodeShadowInfoHob.ha/Silicon/Intel/IntelSiliconPkg/Include/Guid/MicrocodeShadowInfoHob.h
index d887b39123..1daae1234a 100644
---b/Silicon/Intel/IntelSiliconPkg/Include/Guid/MicrocodeShadowInfoHob.h
+++addresshadowInfoHob.h
@@ -58,7 +58,7 @@ typedef struct {
// microcode patch address on flash. Theisplaced in same
// order as the microcode patches in
MicrocodeAddrInMemory.
//
- UINT64 MicrocodeAddressInFlash[];
+ UINT64 MicrocodeAddressInFlash[0];
} EFI_MICROCODE_STORAGE_TYPE_FLASH_CONTEXT;
#endif
--
2.19.1.windows.1