Discussion:
[edk2] CorebootModulePkg: gcc reports conflicting types for 'CbParseAcpiTable'
Laszlo Ersek
2015-05-26 08:48:17 UTC
Permalink
Hi,

CorebootModulePkg fails to build with gcc. See error msg below.

Thanks
Laszlo

CorebootModulePkg/Library/CbParseLib/CbParseLib.c:363:1: error: conflicting types for 'CbParseAcpiTable'
CbParseAcpiTable (
^
In file included from CorebootModulePkg/Library/CbParseLib/CbParseLib.c:21:0:
CorebootModulePkg/Include/Library/CbParseLib.h:65:1: note: previous declaration of 'CbParseAcpiTable' was here
CbParseAcpiTable (
^
CorebootModulePkg/Library/CbParseLib/CbParseLib.c: In function 'CbParseFadtInfo':
CorebootModulePkg/Library/CbParseLib/CbParseLib.c:425:3: error: passing argument 1 of 'CbParseAcpiTable' from incompatible pointer type [-Werror]
Status = CbParseAcpiTable (&Rsdp, NULL);
^
CorebootModulePkg/Library/CbParseLib/CbParseLib.c:363:1: note: expected 'void **' but argument is of type 'struct EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER **'
CbParseAcpiTable (
^
cc1: all warnings being treated as errors
Dong, Guo
2015-05-27 01:32:31 UTC
Permalink
Hi Laszlo,

Thanks to point out this issue.
The fix has been sent out to edk2-devel list for code review now.

Thanks,
Guo

-----Original Message-----
From: Laszlo Ersek [mailto:***@redhat.com]
Sent: Tuesday, May 26, 2015 4:48 PM
To: edk2-devel list
Cc: Gerd Hoffmann; Ma, Maurice; Dong, Guo; Scott Duplichan
Subject: CorebootModulePkg: gcc reports conflicting types for 'CbParseAcpiTable'

Hi,

CorebootModulePkg fails to build with gcc. See error msg below.

Thanks
Laszlo

CorebootModulePkg/Library/CbParseLib/CbParseLib.c:363:1: error: conflicting types for 'CbParseAcpiTable'
CbParseAcpiTable (
^
In file included from CorebootModulePkg/Library/CbParseLib/CbParseLib.c:21:0:
CorebootModulePkg/Include/Library/CbParseLib.h:65:1: note: previous declaration of 'CbParseAcpiTable' was here CbParseAcpiTable ( ^
CorebootModulePkg/Library/CbParseLib/CbParseLib.c: In function 'CbParseFadtInfo':
CorebootModulePkg/Library/CbParseLib/CbParseLib.c:425:3: error: passing argument 1 of 'CbParseAcpiTable' from incompatible pointer type [-Werror]
Status = CbParseAcpiTable (&Rsdp, NULL);
^
CorebootModulePkg/Library/CbParseLib/CbParseLib.c:363:1: note: expected 'void **' but argument is of type 'struct EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER **'
CbParseAcpiTable (
^
cc1: all warnings being treated as errors

------------------------------------------------------------------------------
Scott Duplichan
2015-05-27 16:36:01 UTC
Permalink
Laszlo Ersek [mailto:***@redhat.com] wrote:

]Sent: Tuesday, May 26, 2015 03:48 AM
]To: edk2-devel list
]Cc: Gerd Hoffmann; 'Maurice Ma'; Dong Guo; Scott Duplichan
]Subject: CorebootModulePkg: gcc reports conflicting types for 'CbParseAcpiTable'
]
]Hi,
]
]CorebootModulePkg fails to build with gcc. See error msg below.
]
]Thanks
]Laszlo
]
]CorebootModulePkg/Library/CbParseLib/CbParseLib.c:363:1: error: conflicting types for 'CbParseAcpiTable'
] CbParseAcpiTable (
] ^
]In file included from CorebootModulePkg/Library/CbParseLib/CbParseLib.c:21:0:
]CorebootModulePkg/Include/Library/CbParseLib.h:65:1: note: previous declaration of 'CbParseAcpiTable' was ]here
] CbParseAcpiTable (
] ^
]CorebootModulePkg/Library/CbParseLib/CbParseLib.c: In function 'CbParseFadtInfo':
]CorebootModulePkg/Library/CbParseLib/CbParseLib.c:425:3: error: passing argument 1 of 'CbParseAcpiTable' ]from incompatible pointer type [-Werror]
] Status = CbParseAcpiTable (&Rsdp, NULL);
] ^
]CorebootModulePkg/Library/CbParseLib/CbParseLib.c:363:1: note: expected 'void **' but argument is of type ]'struct EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER **'
] CbParseAcpiTable (
] ^
]cc1: all warnings being treated as errors

This gcc build fail is caused by SVN rev 17486:
http://permalink.gmane.org/gmane.comp.bios.tianocore.scm/3924

It accidentally reverts the very change that was added to fix
the gcc build fail:
http://sourceforge.net/p/tianocore/edk2/ci/3b17ae9e51998a7002d7e00cb25243969c570215/
Reverting SVN rev 17486 solves the problem.

With the large number of tool chains supported by EDK2, it is not surprising
to see these kinds of problems. While the EDK2 project really needs a build server,
contributors building from Windows can easily test gcc builds. Windows hosted
gcc tool chains are here:
http://sourceforge.net/projects/edk2developertoolsforwindows/
These tool chain downloads are small and require no installation. Just decompress
and set environment variables to identify their location. Building with these
tool chains does not involve running any bash shell. It works exactly the same
as building with Microsoft tool chains, so there is no learning curve for
Windows users.

The reverse situation of running Microsoft tool chains from Linux is impossible
or impractical. Linux users need to test Microsoft tool chain builds using a
private or public build server.

I ran a few builds just to see what to expect from a build server run. I used
SVN rev 17512 with change 17486 reverted. I added openssl so that ovmf could
be tested using SECURE_BOOT_ENABLE.

The builds use combinations of:
Ovmf App IntelFsp Duet Shell BeagleBoard ArmPlatform ArmJuno Emulator CorebootPayload
DDK3790 VS2005 VS2008 VS2010 VS2012 VS2013 GCC44 GCC45 GCC46 GCC47 GCC48 GCC49
DEBUG RELEASE
X64 IA32 IA32X64 ARM AARCH64

NOOPT build was not tested, though it sometimes finds problems not seen with
DEBUG or RELEASE builds.

IPF was not tested due to lack of new development for that platform.

VS2003 was not tested because it is old and causes unwanted warnings that
are not consistent with newer Microsoft tool chains. VS2003 also lacks
X64 support.

AppPkg builds for ARM or AARCH64 were not attempted. These failed in the
past and probably fail today. If I remember correctly, the failure is due
to missing library functions needed to satisfy calls generated by gcc.
ArmJunoPkg builds for ARM were not attempted for the same reason. ArmJunoPkg
for AARCH64 is OK.

Of the 348 combinations remaining, 314 pass and 34 fail:

build.exe -p D:\edk2build\edk2\OvmfPkg\OvmfPkgX64.dsc -b DEBUG -t DDK3790 -n 16 -a X64 -DSECURE_BOOT_ENABLE -DFD_SIZE_2MB
OvmfPkg\Library\XenHypercallLib\X86XenHypercall.c(38) : warning C4244: 'return' : conversion from 'int' to 'BOOLEAN', possible loss of data
This fail occurs only for DDK3790 and VS2005. Maybe time to retire these
especially old tool chains.


build.exe -p D:\edk2build\edk2\AppPkg\AppPkg.dsc -b DEBUG -t DDK3790 -n 16 -a X64
d:\edk2build\edk2\StdLib\LibC\Uefi\Devices\Console\daConsole.c(305) : warning C4244: '=' : conversion from 'int' to 'wchar_t', possible loss of data
This fails only with Microsoft DDK3790, an old tool chain.


build.exe -p D:\edk2build\edk2\AppPkg\AppPkg.dsc -b DEBUG -t VS2013x86 -n 16 -a IA32
LibGdtoa.lib(strtod.obj) : error LNK2001: unresolved external symbol __dtoui3
This fail happens with VS2013 or newer Microsoft tool chains. This problem was
discussed on the mailing list in 2014.


build.exe -p D:\edk2build\edk2\OvmfPkg\OvmfPkgX64.dsc -b DEBUG -t DDK3790 -n 16 -a X64 -DSECURE_BOOT_ENABLE -DFD_SIZE_2MB
d:\edk2build\edk2\MdePkg\Include\Library\DebugLib.h(264) : error C2010: '.' : unexpected in macro formal parameter list
This fail is caused because the logic that checks for missing Microsoft
compiler support for variadic macros uses compiler predefined macro
_MSC_VER. The logic is correct, but fails because OpensslLib.inf undefines
_MSC_VER. Removing all occurrences of -U_MSC_VER from OpensslLib.inf solves
the build problem. If it is essential to undefined _MSC_VER for some not so
obvious reason, the DebugLib.h logic will have to change.

Thanks,
Scott




------------------------------------------------------------------------------
Brian J. Johnson
2015-05-27 18:01:05 UTC
Permalink
Post by Scott Duplichan
The reverse situation of running Microsoft tool chains from Linux is impossible
or impractical. Linux users need to test Microsoft tool chain builds using a
private or public build server.
Microsoft's tools run well enough under wine, so it's possible to use
the (ancient) DDK3790 compilers on Linux without running Windows or
purchasing Visual Studio. We do this all the time. But it takes a lot
of one-time setup, and is kind of clunky.
Post by Scott Duplichan
...
build.exe -p D:\edk2build\edk2\OvmfPkg\OvmfPkgX64.dsc -b DEBUG -t DDK3790 -n 16 -a X64 -DSECURE_BOOT_ENABLE -DFD_SIZE_2MB
OvmfPkg\Library\XenHypercallLib\X86XenHypercall.c(38) : warning C4244: 'return' : conversion from 'int' to 'BOOLEAN', possible loss of data
This fail occurs only for DDK3790 and VS2005. Maybe time to retire these
especially old tool chains.
If that's done, we should add official support for the newer Windows 7
DDK: http://www.microsoft.com/en-us/download/details.aspx?id=11800

See the discussion on the list last September:
http://thread.gmane.org/gmane.comp.bios.tianocore.devel/9846/focus=9892
--
Brian J. Johnson

--------------------------------------------------------------------

My statements are my own, are not authorized by SGI, and do not
necessarily represent SGI’s positions.

------------------------------------------------------------------------------
Scott Duplichan
2015-05-28 12:37:26 UTC
Permalink
Brian J. Johnson [mailto:***@sgi.com] wrote:

]Sent: Wednesday, May 27, 2015 01:01 PM
]To: edk2-***@lists.sourceforge.net; 'Laszlo Ersek'
]Subject: Re: [edk2] CorebootModulePkg: gcc reports conflicting types for 'CbParseAcpiTable'
]
]On 05/27/2015 11:36 AM, Scott Duplichan wrote:
]> The reverse situation of running Microsoft tool chains from Linux is impossible
]> or impractical. Linux users need to test Microsoft tool chain builds using a
]> private or public build server.
]
]Microsoft's tools run well enough under wine, so it's possible to use
]the (ancient) DDK3790 compilers on Linux without running Windows or
]purchasing Visual Studio. We do this all the time. But it takes a lot
]of one-time setup, and is kind of clunky.

Hello Brian,

Thanks for pointing out the Linux option of wine + free Microsoft DDK for
building. I imagine some will use this approach to prevent patch rejections
once a build server is in place to check patches before acceptance. I didn't
suggest it because Windows is my primary OS, and I have never actually run
an EDK2 build using Linux + wine + DDK.


]> build.exe -p D:\edk2build\edk2\OvmfPkg\OvmfPkgX64.dsc -b DEBUG -t DDK3790 -n 16 -a X64 -]DSECURE_BOOT_ENABLE -DFD_SIZE_2MB
]> OvmfPkg\Library\XenHypercallLib\X86XenHypercall.c(38) : warning C4244: 'return' : conversion from 'int' ]to 'BOOLEAN', possible loss of data
]> This fail occurs only for DDK3790 and VS2005. Maybe time to retire these
]> especially old tool chains.
]
]If that's done, we should add official support for the newer Windows 7
]DDK: http://www.microsoft.com/en-us/download/details.aspx?id=11800

Most definitely. DDK3790 should be dropped and replaced by DDK7600. When
you pointed out the possibility of using DDK7600 a while back, I tried it
and it worked perfectly. The DDK7600 compiler is 5 years newer than the
DDK3790 compiler. I could submit a patch, though I have an outstanding
GCC5 patch that I would like to see go through first.

]See the discussion on the list last September:
]http://thread.gmane.org/gmane.comp.bios.tianocore.devel/9846/focus=9892
]--
]
] Brian J. Johnson
]
]--------------------------------------------------------------------
]
] My statements are my own, are not authorized by SGI, and do not
] necessarily represent SGI’s positions.
]
]------------------------------------------------------------------------------



------------------------------------------------------------------------------
Laszlo Ersek
2015-05-27 18:42:44 UTC
Permalink
Post by Scott Duplichan
]Sent: Tuesday, May 26, 2015 03:48 AM
]To: edk2-devel list
]Cc: Gerd Hoffmann; 'Maurice Ma'; Dong Guo; Scott Duplichan
]Subject: CorebootModulePkg: gcc reports conflicting types for 'CbParseAcpiTable'
]
]Hi,
]
]CorebootModulePkg fails to build with gcc. See error msg below.
]
]Thanks
]Laszlo
]
]CorebootModulePkg/Library/CbParseLib/CbParseLib.c:363:1: error: conflicting types for 'CbParseAcpiTable'
] CbParseAcpiTable (
] ^
]CorebootModulePkg/Include/Library/CbParseLib.h:65:1: note: previous declaration of 'CbParseAcpiTable' was ]here
] CbParseAcpiTable (
] ^
]CorebootModulePkg/Library/CbParseLib/CbParseLib.c:425:3: error: passing argument 1 of 'CbParseAcpiTable' ]from incompatible pointer type [-Werror]
] Status = CbParseAcpiTable (&Rsdp, NULL);
] ^
]CorebootModulePkg/Library/CbParseLib/CbParseLib.c:363:1: note: expected 'void **' but argument is of type ]'struct EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER **'
] CbParseAcpiTable (
] ^
]cc1: all warnings being treated as errors
http://permalink.gmane.org/gmane.comp.bios.tianocore.scm/3924
It accidentally reverts the very change that was added to fix
http://sourceforge.net/p/tianocore/edk2/ci/3b17ae9e51998a7002d7e00cb25243969c570215/
Reverting SVN rev 17486 solves the problem.
Something seems fishy. I haven't tried to understand the code until now,
but I guess I can't avoid looking at it after all:

SVN r17144: Changes pMemTable of CbParseAcpiTable() from VOID** to
VOID*. Callers are not updated. In order to compensate for
that, CbParseAcpiTable() is updated internally.

SVN r17486: Practically reverts the above. Triggers the gcc build
failure that SVN r17144 was supposed to fix.

SVN r17519: Current fix. Leaves CbParseAcpiTable() intact and adapts
the caller instead.

I think we can live with r17519 now. It matches the edk2 coding style.

Strictly speaking (in ISO C standardese), the pattern visible in r17519
(and everywhere else in edk2) is not correct, because "pointer to
structure" and "pointer to pointer" can have different representations.
(This is precisely why gcc complains without a forceful cast.)
Post by Scott Duplichan
diff --git a/CorebootModulePkg/Library/CbParseLib/CbParseLib.c b/CorebootModulePkg/Library/CbParseLib/CbParseLib.c
index 66374b5..acb796a 100644
--- a/CorebootModulePkg/Library/CbParseLib/CbParseLib.c
+++ b/CorebootModulePkg/Library/CbParseLib/CbParseLib.c
@@ -408,6 +408,7 @@ CbParseFadtInfo (
OUT UINTN *pResetValue
)
{
+ VOID *Tmp;
EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp;
EFI_ACPI_DESCRIPTION_HEADER *Rsdt;
UINT32 *Entry32;
@@ -422,10 +423,11 @@ CbParseFadtInfo (
Rsdp = NULL;
Status = RETURN_SUCCESS;
- Status = CbParseAcpiTable ((VOID **)&Rsdp, NULL);
+ Status = CbParseAcpiTable (&Tmp, NULL);
if (RETURN_ERROR(Status)) {
return Status;
}
+ Rsdp = Tmp;
if (Rsdp == NULL) {
return RETURN_NOT_FOUND;
This would involve a pointer conversion (in the Rsdp=Tmp assignment)
which could update the representation, in theory.

In practice the representation is identical; hence the edk2 pattern (and
the -fno-strict-aliasing flag as well).
Post by Scott Duplichan
With the large number of tool chains supported by EDK2, it is not surprising
to see these kinds of problems. While the EDK2 project really needs a build server,
contributors building from Windows can easily test gcc builds. Windows hosted
http://sourceforge.net/projects/edk2developertoolsforwindows/
Cool :)
Post by Scott Duplichan
These tool chain downloads are small and require no installation. Just decompress
and set environment variables to identify their location. Building with these
tool chains does not involve running any bash shell. It works exactly the same
as building with Microsoft tool chains, so there is no learning curve for
Windows users.
The reverse situation of running Microsoft tool chains from Linux is impossible
or impractical. Linux users need to test Microsoft tool chain builds using a
private or public build server.
I ran a few builds just to see what to expect from a build server run. I used
SVN rev 17512 with change 17486 reverted. I added openssl so that ovmf could
be tested using SECURE_BOOT_ENABLE.
Ovmf App IntelFsp Duet Shell BeagleBoard ArmPlatform ArmJuno Emulator CorebootPayload
DDK3790 VS2005 VS2008 VS2010 VS2012 VS2013 GCC44 GCC45 GCC46 GCC47 GCC48 GCC49
DEBUG RELEASE
X64 IA32 IA32X64 ARM AARCH64
NOOPT build was not tested, though it sometimes finds problems not seen with
DEBUG or RELEASE builds.
IPF was not tested due to lack of new development for that platform.
VS2003 was not tested because it is old and causes unwanted warnings that
are not consistent with newer Microsoft tool chains. VS2003 also lacks
X64 support.
AppPkg builds for ARM or AARCH64 were not attempted. These failed in the
past and probably fail today. If I remember correctly, the failure is due
to missing library functions needed to satisfy calls generated by gcc.
ArmJunoPkg builds for ARM were not attempted for the same reason. ArmJunoPkg
for AARCH64 is OK.
build.exe -p D:\edk2build\edk2\OvmfPkg\OvmfPkgX64.dsc -b DEBUG -t DDK3790 -n 16 -a X64 -DSECURE_BOOT_ENABLE -DFD_SIZE_2MB
OvmfPkg\Library\XenHypercallLib\X86XenHypercall.c(38) : warning C4244: 'return' : conversion from 'int' to 'BOOLEAN', possible loss of data
This fail occurs only for DDK3790 and VS2005. Maybe time to retire these
especially old tool chains.
I guess we'll fix this when the build server complains about it, or
someone runs into it in the wild ;)

Thanks!
Laszlo
Post by Scott Duplichan
build.exe -p D:\edk2build\edk2\AppPkg\AppPkg.dsc -b DEBUG -t DDK3790 -n 16 -a X64
d:\edk2build\edk2\StdLib\LibC\Uefi\Devices\Console\daConsole.c(305) : warning C4244: '=' : conversion from 'int' to 'wchar_t', possible loss of data
This fails only with Microsoft DDK3790, an old tool chain.
build.exe -p D:\edk2build\edk2\AppPkg\AppPkg.dsc -b DEBUG -t VS2013x86 -n 16 -a IA32
LibGdtoa.lib(strtod.obj) : error LNK2001: unresolved external symbol __dtoui3
This fail happens with VS2013 or newer Microsoft tool chains. This problem was
discussed on the mailing list in 2014.
build.exe -p D:\edk2build\edk2\OvmfPkg\OvmfPkgX64.dsc -b DEBUG -t DDK3790 -n 16 -a X64 -DSECURE_BOOT_ENABLE -DFD_SIZE_2MB
d:\edk2build\edk2\MdePkg\Include\Library\DebugLib.h(264) : error C2010: '.' : unexpected in macro formal parameter list
This fail is caused because the logic that checks for missing Microsoft
compiler support for variadic macros uses compiler predefined macro
_MSC_VER. The logic is correct, but fails because OpensslLib.inf undefines
_MSC_VER. Removing all occurrences of -U_MSC_VER from OpensslLib.inf solves
the build problem. If it is essential to undefined _MSC_VER for some not so
obvious reason, the DebugLib.h logic will have to change.
Thanks,
Scott
------------------------------------------------------------------------------
Scott Duplichan
2015-05-28 14:52:07 UTC
Permalink
Laszlo Ersek [mailto:***@redhat.com] wrote:

]Sent: Wednesday, May 27, 2015 01:43 PM
]To: Scott Duplichan
]Cc: 'edk2-devel list'; 'Gerd Hoffmann'; 'Maurice Ma'; 'Dong Guo'
]Subject: Re: CorebootModulePkg: gcc reports conflicting types for 'CbParseAcpiTable'
]
]On 05/27/15 18:36, Scott Duplichan wrote:
]> Laszlo Ersek [mailto:***@redhat.com] wrote:
]>
]> ]Sent: Tuesday, May 26, 2015 03:48 AM
]> ]To: edk2-devel list
]> ]Cc: Gerd Hoffmann; 'Maurice Ma'; Dong Guo; Scott Duplichan
]> ]Subject: CorebootModulePkg: gcc reports conflicting types for 'CbParseAcpiTable'
]> ]
]> ]Hi,
]> ]
]> ]CorebootModulePkg fails to build with gcc. See error msg below.
]> ]
]> ]Thanks
]> ]Laszlo
]> ]
]> ]CorebootModulePkg/Library/CbParseLib/CbParseLib.c:363:1: error: conflicting types for 'CbParseAcpiTable'
]> ] CbParseAcpiTable (
]> ] ^
]> ]In file included from CorebootModulePkg/Library/CbParseLib/CbParseLib.c:21:0:
]> ]CorebootModulePkg/Include/Library/CbParseLib.h:65:1: note: previous declaration of 'CbParseAcpiTable' ]was ]here
]> ] CbParseAcpiTable (
]> ] ^
]> ]CorebootModulePkg/Library/CbParseLib/CbParseLib.c: In function 'CbParseFadtInfo':
]> ]CorebootModulePkg/Library/CbParseLib/CbParseLib.c:425:3: error: passing argument 1 of 'CbParseAcpiTable' ]]from incompatible pointer type [-Werror]
]> ] Status = CbParseAcpiTable (&Rsdp, NULL);
]> ] ^
]> ]CorebootModulePkg/Library/CbParseLib/CbParseLib.c:363:1: note: expected 'void **' but argument is of ]type ]'struct EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER **'
]> ] CbParseAcpiTable (
]> ] ^
]> ]cc1: all warnings being treated as errors
]>
]> This gcc build fail is caused by SVN rev 17486:
]> http://permalink.gmane.org/gmane.comp.bios.tianocore.scm/3924
]>
]> It accidentally reverts the very change that was added to fix
]> the gcc build fail:
]> http://sourceforge.net/p/tianocore/edk2/ci/3b17ae9e51998a7002d7e00cb25243969c570215/
]> Reverting SVN rev 17486 solves the problem.
]
]Something seems fishy. I haven't tried to understand the code until now,
]but I guess I can't avoid looking at it after all:
]
]SVN r17144: Changes pMemTable of CbParseAcpiTable() from VOID** to
] VOID*. Callers are not updated. In order to compensate for
] that, CbParseAcpiTable() is updated internally.
]
]SVN r17486: Practically reverts the above. Triggers the gcc build
] failure that SVN r17144 was supposed to fix.
]
]SVN r17519: Current fix. Leaves CbParseAcpiTable() intact and adapts
] the caller instead.
]
]I think we can live with r17519 now. It matches the edk2 coding style.
]
]Strictly speaking (in ISO C standardese), the pattern visible in r17519
](and everywhere else in edk2) is not correct, because "pointer to
]structure" and "pointer to pointer" can have different representations.
](This is precisely why gcc complains without a forceful cast.)
]
]The correct way would be:
]
]> diff --git a/CorebootModulePkg/Library/CbParseLib/CbParseLib.c ]b/CorebootModulePkg/Library/CbParseLib/CbParseLib.c
]> index 66374b5..acb796a 100644
]> --- a/CorebootModulePkg/Library/CbParseLib/CbParseLib.c
]> +++ b/CorebootModulePkg/Library/CbParseLib/CbParseLib.c
]> @@ -408,6 +408,7 @@ CbParseFadtInfo (
]> OUT UINTN *pResetValue
]> )
]> {
]> + VOID *Tmp;
]> EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp;
]> EFI_ACPI_DESCRIPTION_HEADER *Rsdt;
]> UINT32 *Entry32;
]> @@ -422,10 +423,11 @@ CbParseFadtInfo (
]> Rsdp = NULL;
]> Status = RETURN_SUCCESS;
]>
]> - Status = CbParseAcpiTable ((VOID **)&Rsdp, NULL);
]> + Status = CbParseAcpiTable (&Tmp, NULL);
]> if (RETURN_ERROR(Status)) {
]> return Status;
]> }
]> + Rsdp = Tmp;
]>
]> if (Rsdp == NULL) {
]> return RETURN_NOT_FOUND;
]
]This would involve a pointer conversion (in the Rsdp=Tmp assignment)
]which could update the representation, in theory.
]
]In practice the representation is identical; hence the edk2 pattern (and
]the -fno-strict-aliasing flag as well).

I do like this approach because it reduces the use of type casts.
Another possibility is to make the function work like malloc() and
return a void pointer. If return status information beyond pass/fail
is needed, the caller could pass the address of an error status
variable and the function could update it. Otherwise the function can
return NULL for fail status. This is not a completely general solution
though, because it does not work in cases where a function needs to
return two or more pointers.


]> With the large number of tool chains supported by EDK2, it is not surprising
]> to see these kinds of problems. While the EDK2 project really needs a build server,
]> contributors building from Windows can easily test gcc builds. Windows hosted
]> gcc tool chains are here:
]> http://sourceforge.net/projects/edk2developertoolsforwindows/
]
]Cool :)
]
]> These tool chain downloads are small and require no installation. Just decompress
]> and set environment variables to identify their location. Building with these
]> tool chains does not involve running any bash shell. It works exactly the same
]> as building with Microsoft tool chains, so there is no learning curve for
]> Windows users.
]>
]> The reverse situation of running Microsoft tool chains from Linux is impossible
]> or impractical. Linux users need to test Microsoft tool chain builds using a
]> private or public build server.
]>
]> I ran a few builds just to see what to expect from a build server run. I used
]> SVN rev 17512 with change 17486 reverted. I added openssl so that ovmf could
]> be tested using SECURE_BOOT_ENABLE.
]>
]> The builds use combinations of:
]> Ovmf App IntelFsp Duet Shell BeagleBoard ArmPlatform ArmJuno Emulator CorebootPayload
]> DDK3790 VS2005 VS2008 VS2010 VS2012 VS2013 GCC44 GCC45 GCC46 GCC47 GCC48 GCC49
]> DEBUG RELEASE
]> X64 IA32 IA32X64 ARM AARCH64
]>
]> NOOPT build was not tested, though it sometimes finds problems not seen with
]> DEBUG or RELEASE builds.
]>
]> IPF was not tested due to lack of new development for that platform.
]>
]> VS2003 was not tested because it is old and causes unwanted warnings that
]> are not consistent with newer Microsoft tool chains. VS2003 also lacks
]> X64 support.
]>
]> AppPkg builds for ARM or AARCH64 were not attempted. These failed in the
]> past and probably fail today. If I remember correctly, the failure is due
]> to missing library functions needed to satisfy calls generated by gcc.
]> ArmJunoPkg builds for ARM were not attempted for the same reason. ArmJunoPkg
]> for AARCH64 is OK.
]>
]> Of the 348 combinations remaining, 314 pass and 34 fail:
]>
]> build.exe -p D:\edk2build\edk2\OvmfPkg\OvmfPkgX64.dsc -b DEBUG -t DDK3790 -n 16 -a X64 -]DSECURE_BOOT_ENABLE -DFD_SIZE_2MB
]> OvmfPkg\Library\XenHypercallLib\X86XenHypercall.c(38) : warning C4244: 'return' : conversion from 'int' ]to 'BOOLEAN', possible loss of data
]> This fail occurs only for DDK3790 and VS2005. Maybe time to retire these
]> especially old tool chains.
]
]I guess we'll fix this when the build server complains about it, or
]someone runs into it in the wild ;)
]
]Thanks!
]Laszlo
]
]>
]>
]> build.exe -p D:\edk2build\edk2\AppPkg\AppPkg.dsc -b DEBUG -t DDK3790 -n 16 -a X64
]> d:\edk2build\edk2\StdLib\LibC\Uefi\Devices\Console\daConsole.c(305) : warning C4244: '=' : conversion ]from 'int' to 'wchar_t', possible loss of data
]> This fails only with Microsoft DDK3790, an old tool chain.
]>
]>
]> build.exe -p D:\edk2build\edk2\AppPkg\AppPkg.dsc -b DEBUG -t VS2013x86 -n 16 -a IA32
]> LibGdtoa.lib(strtod.obj) : error LNK2001: unresolved external symbol __dtoui3
]> This fail happens with VS2013 or newer Microsoft tool chains. This problem was
]> discussed on the mailing list in 2014.
]>
]>
]> build.exe -p D:\edk2build\edk2\OvmfPkg\OvmfPkgX64.dsc -b DEBUG -t DDK3790 -n 16 -a X64 -]DSECURE_BOOT_ENABLE -DFD_SIZE_2MB
]> d:\edk2build\edk2\MdePkg\Include\Library\DebugLib.h(264) : error C2010: '.' : unexpected in macro formal ]parameter list
]> This fail is caused because the logic that checks for missing Microsoft
]> compiler support for variadic macros uses compiler predefined macro
]> _MSC_VER. The logic is correct, but fails because OpensslLib.inf undefines
]> _MSC_VER. Removing all occurrences of -U_MSC_VER from OpensslLib.inf solves
]> the build problem. If it is essential to undefined _MSC_VER for some not so
]> obvious reason, the DebugLib.h logic will have to change.
]>
]> Thanks,
]> Scott



------------------------------------------------------------------------------
Gerd Hoffmann
2015-05-28 05:54:19 UTC
Permalink
Post by Laszlo Ersek
Hi,
CorebootModulePkg fails to build with gcc. See error msg below.
Shamelessly hijacking the thread, as the coreboot people are nicely in
Cc: ...

What hardware is the CorebootPkg supposed to work on? Any hardware
coreboot boots on? Or specific hardware only? In case of the later:
What are the reasons?

A few weeks back I did a quick smoke test on qemu, which didn't work ...

What does CorebootPkg use as console? As debug output? Serial line?
Coreboot Framebuffer? Any hints for trouble shooting?

cheers,
Gerd



------------------------------------------------------------------------------
Ma, Maurice
2015-05-28 15:27:38 UTC
Permalink
Hi, Gerd,

The CorebootModulePkg/CorebootPayloadPkg can be built as a standard UEFI payload binary for coreboot.
It should be a generic payload and should run on most of the IA platforms as a coreboot payload.

To test it you need to have coreboot enabled on a platform first. Then you can configure the coreboot to use the UEFI payload binary.
With this payload, it should be able to boot to UEFI Shell as well as UEFI-aware OS.

We have tested it with many Intel platforms, including BayleyBay CRB, MinnowBoard Max, etc.
BTW the BayleyBay and MinnowBoardMax boards have been officially supported by the coreboot.

CorebootPayloadPkg can support both serial port (in/out) and Framebuffer (out) as console.
The debug output will be on serial port only at this point.

If you have any issue/question with this UEFI payload, please post it and we can try to help.

Thanks
Maurice

-----Original Message-----
From: Gerd Hoffmann [mailto:***@redhat.com]
Sent: Wednesday, May 27, 2015 10:54 PM
To: Laszlo Ersek
Cc: edk2-devel list; Ma, Maurice; Dong, Guo; Scott Duplichan
Subject: Re: CorebootModulePkg: gcc reports conflicting types for 'CbParseAcpiTable'
Post by Laszlo Ersek
Hi,
CorebootModulePkg fails to build with gcc. See error msg below.
Shamelessly hijacking the thread, as the coreboot people are nicely in
Cc: ...

What hardware is the CorebootPkg supposed to work on? Any hardware coreboot boots on? Or specific hardware only? In case of the later:
What are the reasons?

A few weeks back I did a quick smoke test on qemu, which didn't work ...

What does CorebootPkg use as console? As debug output? Serial line?
Coreboot Framebuffer? Any hints for trouble shooting?

cheers,
Gerd


------------------------------------------------------------------------------
Gerd Hoffmann
2015-05-28 15:45:38 UTC
Permalink
Hi,
Post by Ma, Maurice
CorebootPayloadPkg can support both serial port (in/out) and Framebuffer (out) as console.
The debug output will be on serial port only at this point.
Anything specific needed to enable it or is it on by default (in debug
builds)?

thanks,
Gerd




------------------------------------------------------------------------------
Ma, Maurice
2015-05-28 16:14:01 UTC
Permalink
Hi, Gerb,

The current UEFI payload can support 16550 UART compatible UART only.

The serial port I/O base and type (I/O or MMIO) are passed from coreboot to the UEFI payload.
In our test it is at I/O base 0x3F8 with baud rate set to 115200.

The debug will be on by default if you do a debug build for the UEFI payload.

Thanks
Maurice

-----Original Message-----
From: Gerd Hoffmann [mailto:***@redhat.com]
Sent: Thursday, May 28, 2015 8:46 AM
To: Ma, Maurice
Cc: Laszlo Ersek; edk2-devel list; Dong, Guo; Scott Duplichan
Subject: Re: CorebootModulePkg: gcc reports conflicting types for 'CbParseAcpiTable'

Hi,
Post by Ma, Maurice
CorebootPayloadPkg can support both serial port (in/out) and Framebuffer (out) as console.
The debug output will be on serial port only at this point.
Anything specific needed to enable it or is it on by default (in debug builds)?

thanks,
Gerd



------------------------------------------------------------------------------
Gerd Hoffmann
2015-05-29 07:03:07 UTC
Permalink
Post by Ma, Maurice
Hi, Gerb,
The current UEFI payload can support 16550 UART compatible UART only.
The serial port I/O base and type (I/O or MMIO) are passed from coreboot to the UEFI payload.
So I probably need serial console support in coreboot to get this going.

Ah, yes. Now I at least get some output:

$ qemu-system-x86_64 \
-bios /usr/share/coreboot.git/coreboot-i440fx-tianocore.rom \
-serial stdio
[ ... ]
Loading driver at 0x0000774A000 EntryPoint=0x0000774A2AF CpuDxe.efi
InstallProtocolInterface: BC62157E-3E33-4FEC-9920-2D3B36D750DF 7788B18
PROGRESS CODE: V03040002 I0
InstallProtocolInterface: 26BACCB1-6F42-11D4-BCE7-0080C73C8881 77593A0
!!!! X64 Exception Type - 0000000000000000 CPU Apic ID -
00000000 !!!!
RIP - 000000000774FD1C, CS - 0000000000000028, RFLAGS -
0000000000000202
RAX - 000000000774FD16, RCX - 00000000077593A0, RDX - 00000000077593A0
RBX - 0000000007F5A260, RSP - 0000000007F59618, RBP - 0000000007F59640
RSI - 0000000000000007, RDI - 0000000000000001
R8 - 0000000000000000, R9 - 00000000077889D8, R10 - 00000000000000C7
R11 - 000000000000003C, R12 - 0000000000000000, R13 - 0000000000000000
R14 - 0000000000000000, R15 - 0000000000000000
DS - 0000000000000008, ES - 0000000000000008, FS - 0000000000000008
GS - 0000000000000008, SS - 0000000000000008
CR0 - 0000000080000011, CR2 - 0000000000000000, CR3 - 0000000007B37000
CR4 - 0000000000000228, CR8 - 0000000000000000
DR0 - 0000000000000000, DR1 - 0000000000000000, DR2 - 0000000000000000
DR3 - 0000000000000000, DR6 - 00000000FFFF0FF0, DR7 - 0000000000000400
GDTR - 0000000007B24DD8 000000000000003F, LDTR - 0000000000000000
IDTR - 000000000778B018 0000000000000FFF, TR - 0000000000000000
FXSAVE_STATE - 0000000007F59270
!!!! Find PE
image /var/lib/jenkins/jobs/edk2/workspace/rpmbuild/rpm/BUILD/edk2.git/Build/CorebootPayloadPkgX64/DEBUG_GCC48/X64/UefiCpuPkg/CpuDxe/CpuDxe/DEBUG/CpuDxe.dll (ImageBase=000000000774A000, EntryPoint=000000000774A2AF) !!!!
[ ... hangs here ... ]

Any idea what this could be?

Note that on qemu the coreboot hardware initialization is alot simpler
than on real hardware, so it could simply be that CorebootPkg expects
some information from coreboot which simply isn't there in the qemu
case.

Given that CorebootPkg seems to crash in cpu initialization you might
want to have a look at the very simple coreboot cpu driver for qemu, in
src/cpu/qemu-x86/

cheers,
Gerd



------------------------------------------------------------------------------
Laszlo Ersek
2015-05-29 11:51:44 UTC
Permalink
Post by Gerd Hoffmann
Post by Ma, Maurice
Hi, Gerb,
The current UEFI payload can support 16550 UART compatible UART only.
The serial port I/O base and type (I/O or MMIO) are passed from coreboot to the UEFI payload.
So I probably need serial console support in coreboot to get this going.
$ qemu-system-x86_64 \
-bios /usr/share/coreboot.git/coreboot-i440fx-tianocore.rom \
-serial stdio
[ ... ]
Loading driver at 0x0000774A000 EntryPoint=0x0000774A2AF CpuDxe.efi
InstallProtocolInterface: BC62157E-3E33-4FEC-9920-2D3B36D750DF 7788B18
PROGRESS CODE: V03040002 I0
InstallProtocolInterface: 26BACCB1-6F42-11D4-BCE7-0080C73C8881 77593A0
!!!! X64 Exception Type - 0000000000000000 CPU Apic ID -
00000000 !!!!
RIP - 000000000774FD1C, CS - 0000000000000028, RFLAGS -
0000000000000202
RAX - 000000000774FD16, RCX - 00000000077593A0, RDX - 00000000077593A0
RBX - 0000000007F5A260, RSP - 0000000007F59618, RBP - 0000000007F59640
RSI - 0000000000000007, RDI - 0000000000000001
R8 - 0000000000000000, R9 - 00000000077889D8, R10 - 00000000000000C7
R11 - 000000000000003C, R12 - 0000000000000000, R13 - 0000000000000000
R14 - 0000000000000000, R15 - 0000000000000000
DS - 0000000000000008, ES - 0000000000000008, FS - 0000000000000008
GS - 0000000000000008, SS - 0000000000000008
CR0 - 0000000080000011, CR2 - 0000000000000000, CR3 - 0000000007B37000
CR4 - 0000000000000228, CR8 - 0000000000000000
DR0 - 0000000000000000, DR1 - 0000000000000000, DR2 - 0000000000000000
DR3 - 0000000000000000, DR6 - 00000000FFFF0FF0, DR7 - 0000000000000400
GDTR - 0000000007B24DD8 000000000000003F, LDTR - 0000000000000000
IDTR - 000000000778B018 0000000000000FFF, TR - 0000000000000000
FXSAVE_STATE - 0000000007F59270
!!!! Find PE
image /var/lib/jenkins/jobs/edk2/workspace/rpmbuild/rpm/BUILD/edk2.git/Build/CorebootPayloadPkgX64/DEBUG_GCC48/X64/UefiCpuPkg/CpuDxe/CpuDxe/DEBUG/CpuDxe.dll (ImageBase=000000000774A000, EntryPoint=000000000774A2AF) !!!!
[ ... hangs here ... ]
Any idea what this could be?
Yes, you can track this down. Just locate the .dll file referenced in
the above register dump (well, in fact, the same pathname with the
.debug suffix might be even better), and then with the help of
"objdump", you can tie the crash site to the source code:

http://thread.gmane.org/gmane.comp.bios.tianocore.devel/7300/focus=7305

Thanks
Laszlo
Post by Gerd Hoffmann
Note that on qemu the coreboot hardware initialization is alot simpler
than on real hardware, so it could simply be that CorebootPkg expects
some information from coreboot which simply isn't there in the qemu
case.
Given that CorebootPkg seems to crash in cpu initialization you might
want to have a look at the very simple coreboot cpu driver for qemu, in
src/cpu/qemu-x86/
cheers,
Gerd
------------------------------------------------------------------------------
Gerd Hoffmann
2015-05-29 12:20:56 UTC
Permalink
Hi,
Post by Laszlo Ersek
Post by Gerd Hoffmann
Any idea what this could be?
Yes, you can track this down. Just locate the .dll file referenced in
the above register dump (well, in fact, the same pathname with the
.debug suffix might be even better), and then with the help of
http://thread.gmane.org/gmane.comp.bios.tianocore.devel/7300/focus=7305
Thanks. It's the return instruction of the EnableInterrupts() function.
So a stack overflow in an interrupt handler, which overwrites the return
address? The EnableInterrupts() function itself does just 'sti',
that'll hardly corrupt anything ...

cheers,
Gerd



------------------------------------------------------------------------------
Laszlo Ersek
2015-05-29 12:58:10 UTC
Permalink
Post by Gerd Hoffmann
Hi,
Post by Laszlo Ersek
Post by Gerd Hoffmann
Any idea what this could be?
Yes, you can track this down. Just locate the .dll file referenced in
the above register dump (well, in fact, the same pathname with the
.debug suffix might be even better), and then with the help of
http://thread.gmane.org/gmane.comp.bios.tianocore.devel/7300/focus=7305
Thanks. It's the return instruction of the EnableInterrupts() function.
So a stack overflow in an interrupt handler, which overwrites the return
address? The EnableInterrupts() function itself does just 'sti',
that'll hardly corrupt anything ...
Hm, I don't know. The exception type in the register dump is 0, which
seems to mean "division by zero".

http://wiki.osdev.org/Exceptions

If that's right, maybe you can peek at the guest memory with the qemu
monitor, and see the "saved instruction pointer" on the stack that
"points to the DIV or IDIV instruction which caused the exception".

Just guessing... Adding a bunch of DEBUG()s to the CpuDxe source might help.

Thanks
Laszlo

------------------------------------------------------------------------------
Ma, Maurice
2015-05-29 19:54:43 UTC
Permalink
Hi, Gerd,

The current UEFI payload has an assumption that all interrupt sources will be masked off before transferring to the UEFI payload.
In your case I saw the 8259 interrupts were unmasked before the handoff.

I tried to add the following in the entry point of the CbSupportPei PEIM to mask off the 8259 interrupt sources, and then it booted to EFI shell on Qemu.
IoWrite8 (0x21, 0xFF);
IoWrite8 (0xA1, 0xFF);

Maybe we should add this in CorebootPayloadPkg and remove the assumption mentioned above.

Thanks
Maurice

-----Original Message-----
From: Laszlo Ersek [mailto:***@redhat.com]
Sent: Friday, May 29, 2015 5:58 AM
To: Gerd Hoffmann
Cc: Ma, Maurice; edk2-devel list; Dong, Guo; Scott Duplichan
Subject: Re: CorebootModulePkg: gcc reports conflicting types for 'CbParseAcpiTable'
Post by Gerd Hoffmann
Hi,
Post by Laszlo Ersek
Post by Gerd Hoffmann
Any idea what this could be?
Yes, you can track this down. Just locate the .dll file referenced in
the above register dump (well, in fact, the same pathname with the
.debug suffix might be even better), and then with the help of
http://thread.gmane.org/gmane.comp.bios.tianocore.devel/7300/focus=73
05
Thanks. It's the return instruction of the EnableInterrupts() function.
So a stack overflow in an interrupt handler, which overwrites the
return address? The EnableInterrupts() function itself does just
'sti', that'll hardly corrupt anything ...
Hm, I don't know. The exception type in the register dump is 0, which seems to mean "division by zero".

http://wiki.osdev.org/Exceptions

If that's right, maybe you can peek at the guest memory with the qemu monitor, and see the "saved instruction pointer" on the stack that "points to the DIV or IDIV instruction which caused the exception".

Just guessing... Adding a bunch of DEBUG()s to the CpuDxe source might help.

Thanks
Laszlo
------------------------------------------------------------------------------
Gerd Hoffmann
2015-06-01 06:59:38 UTC
Permalink
Post by Ma, Maurice
Hi, Gerd,
The current UEFI payload has an assumption that all interrupt sources will be masked off before transferring to the UEFI payload.
In your case I saw the 8259 interrupts were unmasked before the handoff.
I tried to add the following in the entry point of the CbSupportPei PEIM to mask off the 8259 interrupt sources, and then it booted to EFI shell on Qemu.
IoWrite8 (0x21, 0xFF);
IoWrite8 (0xA1, 0xFF);
Maybe we should add this in CorebootPayloadPkg and remove the assumption mentioned above.
Sounds like a good idea from a robustness point of view.

cheers,
Gerd



------------------------------------------------------------------------------
Loading...