public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] MdeModulePkg: Fix undefined reference to memcpy with XCODE5
@ 2020-12-01 18:26 Vitaly Cheptsov
  2020-12-01 20:38 ` [edk2-devel] " Laszlo Ersek
  0 siblings, 1 reply; 5+ messages in thread
From: Vitaly Cheptsov @ 2020-12-01 18:26 UTC (permalink / raw)
  To: devel
  Cc: Vitaly Cheptsov, Jian J Wang, Hao A Wu, Jordan Justen,
	Laszlo Ersek, Ard Biesheuvel

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3098

XCODE5 toolchain in NOOPT mode generates memcpy when trying
to copy PEI_CORE_FV_HANDLE structure. This breaks OVMF
compilation with XCODE5.

CC: Jian J Wang <jian.j.wang@intel.com>
CC: Hao A Wu <hao.a.wu@intel.com>
CC: Jordan Justen <jordan.l.justen@intel.com>
CC: Laszlo Ersek <lersek@redhat.com>
CC: Ard Biesheuvel <ard.biesheuvel@arm.com>
Signed-off-by: Vitaly Cheptsov <cheptsov@ispras.ru>
---
 MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c |  4 ++--
 MdeModulePkg/Core/Pei/PeiMain.h               |  2 +-
 MdeModulePkg/Core/Pei/Ppi/Ppi.c               | 10 +++++-----
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
index b9a279e..3369585 100644
--- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
+++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
@@ -1256,13 +1256,13 @@ EvacuateTempRam (
   }
   for (FvIndex = 0; FvIndex < Private->FvCount; FvIndex++) {
     if (Private->Fv[FvIndex].FvHandle == PeiCoreFvHandle.FvHandle) {
-      PeiCoreFvHandle = Private->Fv[FvIndex];
+      CopyMem (&PeiCoreFvHandle, &Private->Fv[FvIndex], sizeof (PEI_CORE_FV_HANDLE));
       break;
     }
   }
   Status = EFI_SUCCESS;
 
-  ConvertPeiCorePpiPointers (Private, PeiCoreFvHandle);
+  ConvertPeiCorePpiPointers (Private, &PeiCoreFvHandle);
 
   for (FvIndex = 0; FvIndex < Private->FvCount; FvIndex++) {
     FvHeader = Private->Fv[FvIndex].FvHeader;
diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMain.h
index c27e8fc..daa48b4 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.h
+++ b/MdeModulePkg/Core/Pei/PeiMain.h
@@ -542,7 +542,7 @@ ConvertPpiPointersFv (
 VOID
 ConvertPeiCorePpiPointers (
   IN  PEI_CORE_INSTANCE        *PrivateData,
-  PEI_CORE_FV_HANDLE           CoreFvHandle
+  IN  PEI_CORE_FV_HANDLE       *CoreFvHandle
   );
 
 /**
diff --git a/MdeModulePkg/Core/Pei/Ppi/Ppi.c b/MdeModulePkg/Core/Pei/Ppi/Ppi.c
index 541047d..0ad71d1 100644
--- a/MdeModulePkg/Core/Pei/Ppi/Ppi.c
+++ b/MdeModulePkg/Core/Pei/Ppi/Ppi.c
@@ -1062,7 +1062,7 @@ ProcessPpiListFromSec (
 VOID
 ConvertPeiCorePpiPointers (
   IN  PEI_CORE_INSTANCE        *PrivateData,
-  PEI_CORE_FV_HANDLE           CoreFvHandle
+  IN  PEI_CORE_FV_HANDLE       *CoreFvHandle
   )
 {
   EFI_FV_FILE_INFO      FileInfo;
@@ -1079,16 +1079,16 @@ ConvertPeiCorePpiPointers (
   //
   // Find the PEI Core in the BFV in temporary memory.
   //
-  Status =  CoreFvHandle.FvPpi->FindFileByType (
-                                  CoreFvHandle.FvPpi,
+  Status =  CoreFvHandle->FvPpi->FindFileByType (
+                                  CoreFvHandle->FvPpi,
                                   EFI_FV_FILETYPE_PEI_CORE,
-                                  CoreFvHandle.FvHandle,
+                                  CoreFvHandle->FvHandle,
                                   &PeiCoreFileHandle
                                   );
   ASSERT_EFI_ERROR (Status);
 
   if (!EFI_ERROR (Status)) {
-    Status = CoreFvHandle.FvPpi->GetFileInfo (CoreFvHandle.FvPpi, PeiCoreFileHandle, &FileInfo);
+    Status = CoreFvHandle->FvPpi->GetFileInfo (CoreFvHandle->FvPpi, PeiCoreFileHandle, &FileInfo);
     ASSERT_EFI_ERROR (Status);
 
     Status = PeiGetPe32Data (PeiCoreFileHandle, &PeiCoreImageBase);
-- 
2.24.3 (Apple Git-128)


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [edk2-devel] [PATCH] MdeModulePkg: Fix undefined reference to memcpy with XCODE5
  2020-12-01 18:26 [PATCH] MdeModulePkg: Fix undefined reference to memcpy with XCODE5 Vitaly Cheptsov
@ 2020-12-01 20:38 ` Laszlo Ersek
  2020-12-02  0:52   ` 回复: " gaoliming
  0 siblings, 1 reply; 5+ messages in thread
From: Laszlo Ersek @ 2020-12-01 20:38 UTC (permalink / raw)
  To: devel, cheptsov; +Cc: Jian J Wang, Hao A Wu, Jordan Justen, Ard Biesheuvel

On 12/01/20 19:26, Vitaly Cheptsov wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3098
> 
> XCODE5 toolchain in NOOPT mode generates memcpy when trying
> to copy PEI_CORE_FV_HANDLE structure. This breaks OVMF
> compilation with XCODE5.
> 
> CC: Jian J Wang <jian.j.wang@intel.com>
> CC: Hao A Wu <hao.a.wu@intel.com>
> CC: Jordan Justen <jordan.l.justen@intel.com>
> CC: Laszlo Ersek <lersek@redhat.com>
> CC: Ard Biesheuvel <ard.biesheuvel@arm.com>
> Signed-off-by: Vitaly Cheptsov <cheptsov@ispras.ru>
> ---
>  MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c |  4 ++--
>  MdeModulePkg/Core/Pei/PeiMain.h               |  2 +-
>  MdeModulePkg/Core/Pei/Ppi/Ppi.c               | 10 +++++-----
>  3 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> index b9a279e..3369585 100644
> --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> @@ -1256,13 +1256,13 @@ EvacuateTempRam (
>    }
>    for (FvIndex = 0; FvIndex < Private->FvCount; FvIndex++) {
>      if (Private->Fv[FvIndex].FvHandle == PeiCoreFvHandle.FvHandle) {
> -      PeiCoreFvHandle = Private->Fv[FvIndex];
> +      CopyMem (&PeiCoreFvHandle, &Private->Fv[FvIndex], sizeof (PEI_CORE_FV_HANDLE));
>        break;
>      }
>    }
>    Status = EFI_SUCCESS;

I'm too tired to review this patch now (hello MdeModulePkg reviewers),
but the idea is correct -- "PeiCoreFvHandle" has type
PEI_CORE_FV_HANDLE, from "MdeModulePkg/Core/Pei/PeiMain.h", and it is a
structure type. Structure assignment is indeed not allowed in edk2.

Thanks
Laszlo

>  
> -  ConvertPeiCorePpiPointers (Private, PeiCoreFvHandle);
> +  ConvertPeiCorePpiPointers (Private, &PeiCoreFvHandle);
>  
>    for (FvIndex = 0; FvIndex < Private->FvCount; FvIndex++) {
>      FvHeader = Private->Fv[FvIndex].FvHeader;
> diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMain.h
> index c27e8fc..daa48b4 100644
> --- a/MdeModulePkg/Core/Pei/PeiMain.h
> +++ b/MdeModulePkg/Core/Pei/PeiMain.h
> @@ -542,7 +542,7 @@ ConvertPpiPointersFv (
>  VOID
>  ConvertPeiCorePpiPointers (
>    IN  PEI_CORE_INSTANCE        *PrivateData,
> -  PEI_CORE_FV_HANDLE           CoreFvHandle
> +  IN  PEI_CORE_FV_HANDLE       *CoreFvHandle
>    );
>  
>  /**
> diff --git a/MdeModulePkg/Core/Pei/Ppi/Ppi.c b/MdeModulePkg/Core/Pei/Ppi/Ppi.c
> index 541047d..0ad71d1 100644
> --- a/MdeModulePkg/Core/Pei/Ppi/Ppi.c
> +++ b/MdeModulePkg/Core/Pei/Ppi/Ppi.c
> @@ -1062,7 +1062,7 @@ ProcessPpiListFromSec (
>  VOID
>  ConvertPeiCorePpiPointers (
>    IN  PEI_CORE_INSTANCE        *PrivateData,
> -  PEI_CORE_FV_HANDLE           CoreFvHandle
> +  IN  PEI_CORE_FV_HANDLE       *CoreFvHandle
>    )
>  {
>    EFI_FV_FILE_INFO      FileInfo;
> @@ -1079,16 +1079,16 @@ ConvertPeiCorePpiPointers (
>    //
>    // Find the PEI Core in the BFV in temporary memory.
>    //
> -  Status =  CoreFvHandle.FvPpi->FindFileByType (
> -                                  CoreFvHandle.FvPpi,
> +  Status =  CoreFvHandle->FvPpi->FindFileByType (
> +                                  CoreFvHandle->FvPpi,
>                                    EFI_FV_FILETYPE_PEI_CORE,
> -                                  CoreFvHandle.FvHandle,
> +                                  CoreFvHandle->FvHandle,
>                                    &PeiCoreFileHandle
>                                    );
>    ASSERT_EFI_ERROR (Status);
>  
>    if (!EFI_ERROR (Status)) {
> -    Status = CoreFvHandle.FvPpi->GetFileInfo (CoreFvHandle.FvPpi, PeiCoreFileHandle, &FileInfo);
> +    Status = CoreFvHandle->FvPpi->GetFileInfo (CoreFvHandle->FvPpi, PeiCoreFileHandle, &FileInfo);
>      ASSERT_EFI_ERROR (Status);
>  
>      Status = PeiGetPe32Data (PeiCoreFileHandle, &PeiCoreImageBase);
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* 回复: [edk2-devel] [PATCH] MdeModulePkg: Fix undefined reference to memcpy with XCODE5
  2020-12-01 20:38 ` [edk2-devel] " Laszlo Ersek
@ 2020-12-02  0:52   ` gaoliming
  2020-12-02  1:29     ` Michael D Kinney
  0 siblings, 1 reply; 5+ messages in thread
From: gaoliming @ 2020-12-02  0:52 UTC (permalink / raw)
  To: devel, lersek, cheptsov
  Cc: 'Jian J Wang', 'Hao A Wu',
	'Jordan Justen', 'Ard Biesheuvel'

I agree this fix. We should use the pointer to structure as the function parameter. 

Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>

Thanks
Liming
> -----邮件原件-----
> 发件人: bounce+27952+68148+4905953+8761045@groups.io
> <bounce+27952+68148+4905953+8761045@groups.io> 代表 Laszlo Ersek
> 发送时间: 2020年12月2日 4:39
> 收件人: devel@edk2.groups.io; cheptsov@ispras.ru
> 抄送: Jian J Wang <jian.j.wang@intel.com>; Hao A Wu
> <hao.a.wu@intel.com>; Jordan Justen <jordan.l.justen@intel.com>; Ard
> Biesheuvel <ard.biesheuvel@arm.com>
> 主题: Re: [edk2-devel] [PATCH] MdeModulePkg: Fix undefined reference to
> memcpy with XCODE5
> 
> On 12/01/20 19:26, Vitaly Cheptsov wrote:
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3098
> >
> > XCODE5 toolchain in NOOPT mode generates memcpy when trying
> > to copy PEI_CORE_FV_HANDLE structure. This breaks OVMF
> > compilation with XCODE5.
> >
> > CC: Jian J Wang <jian.j.wang@intel.com>
> > CC: Hao A Wu <hao.a.wu@intel.com>
> > CC: Jordan Justen <jordan.l.justen@intel.com>
> > CC: Laszlo Ersek <lersek@redhat.com>
> > CC: Ard Biesheuvel <ard.biesheuvel@arm.com>
> > Signed-off-by: Vitaly Cheptsov <cheptsov@ispras.ru>
> > ---
> >  MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c |  4 ++--
> >  MdeModulePkg/Core/Pei/PeiMain.h               |  2 +-
> >  MdeModulePkg/Core/Pei/Ppi/Ppi.c               | 10 +++++-----
> >  3 files changed, 8 insertions(+), 8 deletions(-)
> >
> > diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> > index b9a279e..3369585 100644
> > --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> > +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> > @@ -1256,13 +1256,13 @@ EvacuateTempRam (
> >    }
> >    for (FvIndex = 0; FvIndex < Private->FvCount; FvIndex++) {
> >      if (Private->Fv[FvIndex].FvHandle == PeiCoreFvHandle.FvHandle) {
> > -      PeiCoreFvHandle = Private->Fv[FvIndex];
> > +      CopyMem (&PeiCoreFvHandle, &Private->Fv[FvIndex], sizeof
> (PEI_CORE_FV_HANDLE));
> >        break;
> >      }
> >    }
> >    Status = EFI_SUCCESS;
> 
> I'm too tired to review this patch now (hello MdeModulePkg reviewers),
> but the idea is correct -- "PeiCoreFvHandle" has type
> PEI_CORE_FV_HANDLE, from "MdeModulePkg/Core/Pei/PeiMain.h", and it is
> a
> structure type. Structure assignment is indeed not allowed in edk2.
> 
> Thanks
> Laszlo
> 
> >
> > -  ConvertPeiCorePpiPointers (Private, PeiCoreFvHandle);
> > +  ConvertPeiCorePpiPointers (Private, &PeiCoreFvHandle);
> >
> >    for (FvIndex = 0; FvIndex < Private->FvCount; FvIndex++) {
> >      FvHeader = Private->Fv[FvIndex].FvHeader;
> > diff --git a/MdeModulePkg/Core/Pei/PeiMain.h
> b/MdeModulePkg/Core/Pei/PeiMain.h
> > index c27e8fc..daa48b4 100644
> > --- a/MdeModulePkg/Core/Pei/PeiMain.h
> > +++ b/MdeModulePkg/Core/Pei/PeiMain.h
> > @@ -542,7 +542,7 @@ ConvertPpiPointersFv (
> >  VOID
> >  ConvertPeiCorePpiPointers (
> >    IN  PEI_CORE_INSTANCE        *PrivateData,
> > -  PEI_CORE_FV_HANDLE           CoreFvHandle
> > +  IN  PEI_CORE_FV_HANDLE       *CoreFvHandle
> >    );
> >
> >  /**
> > diff --git a/MdeModulePkg/Core/Pei/Ppi/Ppi.c
> b/MdeModulePkg/Core/Pei/Ppi/Ppi.c
> > index 541047d..0ad71d1 100644
> > --- a/MdeModulePkg/Core/Pei/Ppi/Ppi.c
> > +++ b/MdeModulePkg/Core/Pei/Ppi/Ppi.c
> > @@ -1062,7 +1062,7 @@ ProcessPpiListFromSec (
> >  VOID
> >  ConvertPeiCorePpiPointers (
> >    IN  PEI_CORE_INSTANCE        *PrivateData,
> > -  PEI_CORE_FV_HANDLE           CoreFvHandle
> > +  IN  PEI_CORE_FV_HANDLE       *CoreFvHandle
> >    )
> >  {
> >    EFI_FV_FILE_INFO      FileInfo;
> > @@ -1079,16 +1079,16 @@ ConvertPeiCorePpiPointers (
> >    //
> >    // Find the PEI Core in the BFV in temporary memory.
> >    //
> > -  Status =  CoreFvHandle.FvPpi->FindFileByType (
> > -                                  CoreFvHandle.FvPpi,
> > +  Status =  CoreFvHandle->FvPpi->FindFileByType (
> > +                                  CoreFvHandle->FvPpi,
> >                                    EFI_FV_FILETYPE_PEI_CORE,
> > -                                  CoreFvHandle.FvHandle,
> > +                                  CoreFvHandle->FvHandle,
> >                                    &PeiCoreFileHandle
> >                                    );
> >    ASSERT_EFI_ERROR (Status);
> >
> >    if (!EFI_ERROR (Status)) {
> > -    Status = CoreFvHandle.FvPpi->GetFileInfo (CoreFvHandle.FvPpi,
> PeiCoreFileHandle, &FileInfo);
> > +    Status = CoreFvHandle->FvPpi->GetFileInfo (CoreFvHandle->FvPpi,
> PeiCoreFileHandle, &FileInfo);
> >      ASSERT_EFI_ERROR (Status);
> >
> >      Status = PeiGetPe32Data (PeiCoreFileHandle, &PeiCoreImageBase);
> >
> 
> 
> 
> 
> 




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [edk2-devel] [PATCH] MdeModulePkg: Fix undefined reference to memcpy with XCODE5
  2020-12-02  0:52   ` 回复: " gaoliming
@ 2020-12-02  1:29     ` Michael D Kinney
  2020-12-04  1:32       ` 回复: " gaoliming
  0 siblings, 1 reply; 5+ messages in thread
From: Michael D Kinney @ 2020-12-02  1:29 UTC (permalink / raw)
  To: devel@edk2.groups.io, gaoliming@byosoft.com.cn, lersek@redhat.com,
	cheptsov@ispras.ru, Kinney, Michael D
  Cc: Wang, Jian J, Wu, Hao A, Justen, Jordan L,
	'Ard Biesheuvel'

I agree.  There were 2 issues here:

1) Passing a structure a function parameter
2) Structure assignment

Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>


Mike

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of gaoliming
> Sent: Tuesday, December 1, 2020 4:53 PM
> To: devel@edk2.groups.io; lersek@redhat.com; cheptsov@ispras.ru
> Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Justen, Jordan L <jordan.l.justen@intel.com>;
> 'Ard Biesheuvel' <ard.biesheuvel@arm.com>
> Subject: 回复: [edk2-devel] [PATCH] MdeModulePkg: Fix undefined reference to memcpy with XCODE5
> 
> I agree this fix. We should use the pointer to structure as the function parameter.
> 
> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
> 
> Thanks
> Liming
> > -----邮件原件-----
> > 发件人: bounce+27952+68148+4905953+8761045@groups.io
> > <bounce+27952+68148+4905953+8761045@groups.io> 代表 Laszlo Ersek
> > 发送时间: 2020年12月2日 4:39
> > 收件人: devel@edk2.groups.io; cheptsov@ispras.ru
> > 抄送: Jian J Wang <jian.j.wang@intel.com>; Hao A Wu
> > <hao.a.wu@intel.com>; Jordan Justen <jordan.l.justen@intel.com>; Ard
> > Biesheuvel <ard.biesheuvel@arm.com>
> > 主题: Re: [edk2-devel] [PATCH] MdeModulePkg: Fix undefined reference to
> > memcpy with XCODE5
> >
> > On 12/01/20 19:26, Vitaly Cheptsov wrote:
> > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3098
> > >
> > > XCODE5 toolchain in NOOPT mode generates memcpy when trying
> > > to copy PEI_CORE_FV_HANDLE structure. This breaks OVMF
> > > compilation with XCODE5.
> > >
> > > CC: Jian J Wang <jian.j.wang@intel.com>
> > > CC: Hao A Wu <hao.a.wu@intel.com>
> > > CC: Jordan Justen <jordan.l.justen@intel.com>
> > > CC: Laszlo Ersek <lersek@redhat.com>
> > > CC: Ard Biesheuvel <ard.biesheuvel@arm.com>
> > > Signed-off-by: Vitaly Cheptsov <cheptsov@ispras.ru>
> > > ---
> > >  MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c |  4 ++--
> > >  MdeModulePkg/Core/Pei/PeiMain.h               |  2 +-
> > >  MdeModulePkg/Core/Pei/Ppi/Ppi.c               | 10 +++++-----
> > >  3 files changed, 8 insertions(+), 8 deletions(-)
> > >
> > > diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> > b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> > > index b9a279e..3369585 100644
> > > --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> > > +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> > > @@ -1256,13 +1256,13 @@ EvacuateTempRam (
> > >    }
> > >    for (FvIndex = 0; FvIndex < Private->FvCount; FvIndex++) {
> > >      if (Private->Fv[FvIndex].FvHandle == PeiCoreFvHandle.FvHandle) {
> > > -      PeiCoreFvHandle = Private->Fv[FvIndex];
> > > +      CopyMem (&PeiCoreFvHandle, &Private->Fv[FvIndex], sizeof
> > (PEI_CORE_FV_HANDLE));
> > >        break;
> > >      }
> > >    }
> > >    Status = EFI_SUCCESS;
> >
> > I'm too tired to review this patch now (hello MdeModulePkg reviewers),
> > but the idea is correct -- "PeiCoreFvHandle" has type
> > PEI_CORE_FV_HANDLE, from "MdeModulePkg/Core/Pei/PeiMain.h", and it is
> > a
> > structure type. Structure assignment is indeed not allowed in edk2.
> >
> > Thanks
> > Laszlo
> >
> > >
> > > -  ConvertPeiCorePpiPointers (Private, PeiCoreFvHandle);
> > > +  ConvertPeiCorePpiPointers (Private, &PeiCoreFvHandle);
> > >
> > >    for (FvIndex = 0; FvIndex < Private->FvCount; FvIndex++) {
> > >      FvHeader = Private->Fv[FvIndex].FvHeader;
> > > diff --git a/MdeModulePkg/Core/Pei/PeiMain.h
> > b/MdeModulePkg/Core/Pei/PeiMain.h
> > > index c27e8fc..daa48b4 100644
> > > --- a/MdeModulePkg/Core/Pei/PeiMain.h
> > > +++ b/MdeModulePkg/Core/Pei/PeiMain.h
> > > @@ -542,7 +542,7 @@ ConvertPpiPointersFv (
> > >  VOID
> > >  ConvertPeiCorePpiPointers (
> > >    IN  PEI_CORE_INSTANCE        *PrivateData,
> > > -  PEI_CORE_FV_HANDLE           CoreFvHandle
> > > +  IN  PEI_CORE_FV_HANDLE       *CoreFvHandle
> > >    );
> > >
> > >  /**
> > > diff --git a/MdeModulePkg/Core/Pei/Ppi/Ppi.c
> > b/MdeModulePkg/Core/Pei/Ppi/Ppi.c
> > > index 541047d..0ad71d1 100644
> > > --- a/MdeModulePkg/Core/Pei/Ppi/Ppi.c
> > > +++ b/MdeModulePkg/Core/Pei/Ppi/Ppi.c
> > > @@ -1062,7 +1062,7 @@ ProcessPpiListFromSec (
> > >  VOID
> > >  ConvertPeiCorePpiPointers (
> > >    IN  PEI_CORE_INSTANCE        *PrivateData,
> > > -  PEI_CORE_FV_HANDLE           CoreFvHandle
> > > +  IN  PEI_CORE_FV_HANDLE       *CoreFvHandle
> > >    )
> > >  {
> > >    EFI_FV_FILE_INFO      FileInfo;
> > > @@ -1079,16 +1079,16 @@ ConvertPeiCorePpiPointers (
> > >    //
> > >    // Find the PEI Core in the BFV in temporary memory.
> > >    //
> > > -  Status =  CoreFvHandle.FvPpi->FindFileByType (
> > > -                                  CoreFvHandle.FvPpi,
> > > +  Status =  CoreFvHandle->FvPpi->FindFileByType (
> > > +                                  CoreFvHandle->FvPpi,
> > >                                    EFI_FV_FILETYPE_PEI_CORE,
> > > -                                  CoreFvHandle.FvHandle,
> > > +                                  CoreFvHandle->FvHandle,
> > >                                    &PeiCoreFileHandle
> > >                                    );
> > >    ASSERT_EFI_ERROR (Status);
> > >
> > >    if (!EFI_ERROR (Status)) {
> > > -    Status = CoreFvHandle.FvPpi->GetFileInfo (CoreFvHandle.FvPpi,
> > PeiCoreFileHandle, &FileInfo);
> > > +    Status = CoreFvHandle->FvPpi->GetFileInfo (CoreFvHandle->FvPpi,
> > PeiCoreFileHandle, &FileInfo);
> > >      ASSERT_EFI_ERROR (Status);
> > >
> > >      Status = PeiGetPe32Data (PeiCoreFileHandle, &PeiCoreImageBase);
> > >
> >
> >
> >
> >
> >
> 
> 
> 
> 
> 
> 
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* 回复: [edk2-devel] [PATCH] MdeModulePkg: Fix undefined reference to memcpy with XCODE5
  2020-12-02  1:29     ` Michael D Kinney
@ 2020-12-04  1:32       ` gaoliming
  0 siblings, 0 replies; 5+ messages in thread
From: gaoliming @ 2020-12-04  1:32 UTC (permalink / raw)
  To: devel, michael.d.kinney, lersek, cheptsov
  Cc: 'Wang, Jian J', 'Wu, Hao A',
	'Justen, Jordan L', 'Ard Biesheuvel'

Create PR for this patch https://github.com/tianocore/edk2/pull/1177

Thanks
Liming
> -----邮件原件-----
> 发件人: bounce+27952+68153+4905953+8761045@groups.io
> <bounce+27952+68153+4905953+8761045@groups.io> 代表 Michael D
> Kinney
> 发送时间: 2020年12月2日 9:30
> 收件人: devel@edk2.groups.io; gaoliming@byosoft.com.cn;
> lersek@redhat.com; cheptsov@ispras.ru; Kinney, Michael D
> <michael.d.kinney@intel.com>
> 抄送: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A
> <hao.a.wu@intel.com>; Justen, Jordan L <jordan.l.justen@intel.com>; 'Ard
> Biesheuvel' <ard.biesheuvel@arm.com>
> 主题: Re: [edk2-devel] [PATCH] MdeModulePkg: Fix undefined reference to
> memcpy with XCODE5
> 
> I agree.  There were 2 issues here:
> 
> 1) Passing a structure a function parameter
> 2) Structure assignment
> 
> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
> 
> 
> Mike
> 
> > -----Original Message-----
> > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of
> gaoliming
> > Sent: Tuesday, December 1, 2020 4:53 PM
> > To: devel@edk2.groups.io; lersek@redhat.com; cheptsov@ispras.ru
> > Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A
> <hao.a.wu@intel.com>; Justen, Jordan L <jordan.l.justen@intel.com>;
> > 'Ard Biesheuvel' <ard.biesheuvel@arm.com>
> > Subject: 回复: [edk2-devel] [PATCH] MdeModulePkg: Fix undefined
> reference to memcpy with XCODE5
> >
> > I agree this fix. We should use the pointer to structure as the function
> parameter.
> >
> > Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
> >
> > Thanks
> > Liming
> > > -----邮件原件-----
> > > 发件人: bounce+27952+68148+4905953+8761045@groups.io
> > > <bounce+27952+68148+4905953+8761045@groups.io> 代表 Laszlo
> Ersek
> > > 发送时间: 2020年12月2日 4:39
> > > 收件人: devel@edk2.groups.io; cheptsov@ispras.ru
> > > 抄送: Jian J Wang <jian.j.wang@intel.com>; Hao A Wu
> > > <hao.a.wu@intel.com>; Jordan Justen <jordan.l.justen@intel.com>; Ard
> > > Biesheuvel <ard.biesheuvel@arm.com>
> > > 主题: Re: [edk2-devel] [PATCH] MdeModulePkg: Fix undefined reference
> to
> > > memcpy with XCODE5
> > >
> > > On 12/01/20 19:26, Vitaly Cheptsov wrote:
> > > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3098
> > > >
> > > > XCODE5 toolchain in NOOPT mode generates memcpy when trying
> > > > to copy PEI_CORE_FV_HANDLE structure. This breaks OVMF
> > > > compilation with XCODE5.
> > > >
> > > > CC: Jian J Wang <jian.j.wang@intel.com>
> > > > CC: Hao A Wu <hao.a.wu@intel.com>
> > > > CC: Jordan Justen <jordan.l.justen@intel.com>
> > > > CC: Laszlo Ersek <lersek@redhat.com>
> > > > CC: Ard Biesheuvel <ard.biesheuvel@arm.com>
> > > > Signed-off-by: Vitaly Cheptsov <cheptsov@ispras.ru>
> > > > ---
> > > >  MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c |  4 ++--
> > > >  MdeModulePkg/Core/Pei/PeiMain.h               |  2 +-
> > > >  MdeModulePkg/Core/Pei/Ppi/Ppi.c               | 10 +++++-----
> > > >  3 files changed, 8 insertions(+), 8 deletions(-)
> > > >
> > > > diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> > > b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> > > > index b9a279e..3369585 100644
> > > > --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> > > > +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> > > > @@ -1256,13 +1256,13 @@ EvacuateTempRam (
> > > >    }
> > > >    for (FvIndex = 0; FvIndex < Private->FvCount; FvIndex++) {
> > > >      if (Private->Fv[FvIndex].FvHandle == PeiCoreFvHandle.FvHandle)
> {
> > > > -      PeiCoreFvHandle = Private->Fv[FvIndex];
> > > > +      CopyMem (&PeiCoreFvHandle, &Private->Fv[FvIndex], sizeof
> > > (PEI_CORE_FV_HANDLE));
> > > >        break;
> > > >      }
> > > >    }
> > > >    Status = EFI_SUCCESS;
> > >
> > > I'm too tired to review this patch now (hello MdeModulePkg reviewers),
> > > but the idea is correct -- "PeiCoreFvHandle" has type
> > > PEI_CORE_FV_HANDLE, from "MdeModulePkg/Core/Pei/PeiMain.h", and
> it is
> > > a
> > > structure type. Structure assignment is indeed not allowed in edk2.
> > >
> > > Thanks
> > > Laszlo
> > >
> > > >
> > > > -  ConvertPeiCorePpiPointers (Private, PeiCoreFvHandle);
> > > > +  ConvertPeiCorePpiPointers (Private, &PeiCoreFvHandle);
> > > >
> > > >    for (FvIndex = 0; FvIndex < Private->FvCount; FvIndex++) {
> > > >      FvHeader = Private->Fv[FvIndex].FvHeader;
> > > > diff --git a/MdeModulePkg/Core/Pei/PeiMain.h
> > > b/MdeModulePkg/Core/Pei/PeiMain.h
> > > > index c27e8fc..daa48b4 100644
> > > > --- a/MdeModulePkg/Core/Pei/PeiMain.h
> > > > +++ b/MdeModulePkg/Core/Pei/PeiMain.h
> > > > @@ -542,7 +542,7 @@ ConvertPpiPointersFv (
> > > >  VOID
> > > >  ConvertPeiCorePpiPointers (
> > > >    IN  PEI_CORE_INSTANCE        *PrivateData,
> > > > -  PEI_CORE_FV_HANDLE           CoreFvHandle
> > > > +  IN  PEI_CORE_FV_HANDLE       *CoreFvHandle
> > > >    );
> > > >
> > > >  /**
> > > > diff --git a/MdeModulePkg/Core/Pei/Ppi/Ppi.c
> > > b/MdeModulePkg/Core/Pei/Ppi/Ppi.c
> > > > index 541047d..0ad71d1 100644
> > > > --- a/MdeModulePkg/Core/Pei/Ppi/Ppi.c
> > > > +++ b/MdeModulePkg/Core/Pei/Ppi/Ppi.c
> > > > @@ -1062,7 +1062,7 @@ ProcessPpiListFromSec (
> > > >  VOID
> > > >  ConvertPeiCorePpiPointers (
> > > >    IN  PEI_CORE_INSTANCE        *PrivateData,
> > > > -  PEI_CORE_FV_HANDLE           CoreFvHandle
> > > > +  IN  PEI_CORE_FV_HANDLE       *CoreFvHandle
> > > >    )
> > > >  {
> > > >    EFI_FV_FILE_INFO      FileInfo;
> > > > @@ -1079,16 +1079,16 @@ ConvertPeiCorePpiPointers (
> > > >    //
> > > >    // Find the PEI Core in the BFV in temporary memory.
> > > >    //
> > > > -  Status =  CoreFvHandle.FvPpi->FindFileByType (
> > > > -                                  CoreFvHandle.FvPpi,
> > > > +  Status =  CoreFvHandle->FvPpi->FindFileByType (
> > > > +                                  CoreFvHandle->FvPpi,
> > > >
> EFI_FV_FILETYPE_PEI_CORE,
> > > > -                                  CoreFvHandle.FvHandle,
> > > > +                                  CoreFvHandle->FvHandle,
> > > >                                    &PeiCoreFileHandle
> > > >                                    );
> > > >    ASSERT_EFI_ERROR (Status);
> > > >
> > > >    if (!EFI_ERROR (Status)) {
> > > > -    Status = CoreFvHandle.FvPpi->GetFileInfo (CoreFvHandle.FvPpi,
> > > PeiCoreFileHandle, &FileInfo);
> > > > +    Status = CoreFvHandle->FvPpi->GetFileInfo (CoreFvHandle->FvPpi,
> > > PeiCoreFileHandle, &FileInfo);
> > > >      ASSERT_EFI_ERROR (Status);
> > > >
> > > >      Status = PeiGetPe32Data (PeiCoreFileHandle,
> &PeiCoreImageBase);
> > > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> >
> >
> >
> >
> >
> 
> 
> 
> 
> 




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-12-04  1:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-01 18:26 [PATCH] MdeModulePkg: Fix undefined reference to memcpy with XCODE5 Vitaly Cheptsov
2020-12-01 20:38 ` [edk2-devel] " Laszlo Ersek
2020-12-02  0:52   ` 回复: " gaoliming
2020-12-02  1:29     ` Michael D Kinney
2020-12-04  1:32       ` 回复: " gaoliming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox