public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch 1/1] OvmfPkg/Xen: Fix VS2019 build issues
@ 2021-11-08 16:22 Michael D Kinney
  2021-11-09  7:01 ` Gerd Hoffmann
  2021-11-11 10:24 ` [edk2-devel] " Philippe Mathieu-Daudé
  0 siblings, 2 replies; 5+ messages in thread
From: Michael D Kinney @ 2021-11-08 16:22 UTC (permalink / raw)
  To: devel
  Cc: Anthony Perard, Julien Grall, Ard Biesheuvel, Jiewen Yao,
	Jordan Justen, Gerd Hoffmann

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

Fix VS2019 NOOPT build issues related to converting
a larger integer value to a smaller integer value.

Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Julien Grall <julien@xen.org>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
---
 .../Library/XenRealTimeClockLib/XenRealTimeClockLib.c  | 10 +++++-----
 OvmfPkg/XenPlatformPei/MemDetect.c                     |  2 +-
 OvmfPkg/XenTimerDxe/XenTimerDxe.c                      |  4 ++--
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.c b/OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.c
index e113bc89bd75..72e0aaa8798c 100644
--- a/OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.c
+++ b/OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.c
@@ -53,9 +53,9 @@ EpochToEfiTime (
   m  = (((da * 5) + 308) / 153) - 2;
   d  = da - (((m + 4) * 153) / 5) + 122;
 
-  Time->Year  = y - 4800 + ((m + 2) / 12);
+  Time->Year  = (UINT16)(y - 4800 + ((m + 2) / 12));
   Time->Month = ((m + 2) % 12) + 1;
-  Time->Day   = d + 1;
+  Time->Day   = (UINT8)(d + 1);
 
   ss = EpochSeconds % 60;
   a  = (EpochSeconds - ss) / 60;
@@ -63,9 +63,9 @@ EpochToEfiTime (
   b = (a - mm) / 60;
   hh = b % 24;
 
-  Time->Hour        = hh;
-  Time->Minute      = mm;
-  Time->Second      = ss;
+  Time->Hour        = (UINT8)hh;
+  Time->Minute      = (UINT8)mm;
+  Time->Second      = (UINT8)ss;
   Time->Nanosecond  = 0;
 
 }
diff --git a/OvmfPkg/XenPlatformPei/MemDetect.c b/OvmfPkg/XenPlatformPei/MemDetect.c
index 1970b631c94d..fa1be888d6ba 100644
--- a/OvmfPkg/XenPlatformPei/MemDetect.c
+++ b/OvmfPkg/XenPlatformPei/MemDetect.c
@@ -154,7 +154,7 @@ GetSystemMemorySizeBelow4gb (
     HighestAddress = GetHighestSystemMemoryAddress (TRUE);
     ASSERT (HighestAddress > 0 && HighestAddress <= BASE_4GB);
 
-    return HighestAddress;
+    return (UINT32)HighestAddress;
   }
 
   //
diff --git a/OvmfPkg/XenTimerDxe/XenTimerDxe.c b/OvmfPkg/XenTimerDxe/XenTimerDxe.c
index 0bec59382b0a..19fa17a29fb4 100644
--- a/OvmfPkg/XenTimerDxe/XenTimerDxe.c
+++ b/OvmfPkg/XenTimerDxe/XenTimerDxe.c
@@ -165,7 +165,7 @@ TimerDriverSetTimerPeriod (
 {
   UINT64  TimerCount;
   UINT32  TimerFrequency;
-  UINTN   DivideValue = 1;
+  UINT32  DivideValue = 1;
 
   if (TimerPeriod == 0) {
     //
@@ -193,7 +193,7 @@ TimerDriverSetTimerPeriod (
     //
     // Program the timer with the new count value
     //
-    InitializeApicTimer(DivideValue, TimerCount, TRUE, LOCAL_APIC_TIMER_VECTOR);
+    InitializeApicTimer(DivideValue, (UINT32)TimerCount, TRUE, LOCAL_APIC_TIMER_VECTOR);
 
     //
     // Enable timer interrupt
-- 
2.32.0.windows.1


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

* Re: [Patch 1/1] OvmfPkg/Xen: Fix VS2019 build issues
  2021-11-08 16:22 [Patch 1/1] OvmfPkg/Xen: Fix VS2019 build issues Michael D Kinney
@ 2021-11-09  7:01 ` Gerd Hoffmann
  2021-11-11  4:02   ` Yao, Jiewen
  2021-11-11 10:24 ` [edk2-devel] " Philippe Mathieu-Daudé
  1 sibling, 1 reply; 5+ messages in thread
From: Gerd Hoffmann @ 2021-11-09  7:01 UTC (permalink / raw)
  To: Michael D Kinney
  Cc: devel, Anthony Perard, Julien Grall, Ard Biesheuvel, Jiewen Yao,
	Jordan Justen

On Mon, Nov 08, 2021 at 08:22:08AM -0800, Michael D Kinney wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3722
> 
> Fix VS2019 NOOPT build issues related to converting
> a larger integer value to a smaller integer value.
> 
> Cc: Anthony Perard <anthony.perard@citrix.com>
> Cc: Julien Grall <julien@xen.org>
> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>

Acked-by: Gerd Hoffmann <kraxel@redhat.com>


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

* Re: [Patch 1/1] OvmfPkg/Xen: Fix VS2019 build issues
  2021-11-09  7:01 ` Gerd Hoffmann
@ 2021-11-11  4:02   ` Yao, Jiewen
  0 siblings, 0 replies; 5+ messages in thread
From: Yao, Jiewen @ 2021-11-11  4:02 UTC (permalink / raw)
  To: Gerd Hoffmann, Kinney, Michael D
  Cc: devel@edk2.groups.io, Anthony Perard, Julien Grall,
	Ard Biesheuvel, Justen, Jordan L

Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>

> -----Original Message-----
> From: Gerd Hoffmann <kraxel@redhat.com>
> Sent: Tuesday, November 9, 2021 3:01 PM
> To: Kinney, Michael D <michael.d.kinney@intel.com>
> Cc: devel@edk2.groups.io; Anthony Perard <anthony.perard@citrix.com>; Julien
> Grall <julien@xen.org>; Ard Biesheuvel <ardb+tianocore@kernel.org>; Yao,
> Jiewen <jiewen.yao@intel.com>; Justen, Jordan L <jordan.l.justen@intel.com>
> Subject: Re: [Patch 1/1] OvmfPkg/Xen: Fix VS2019 build issues
> 
> On Mon, Nov 08, 2021 at 08:22:08AM -0800, Michael D Kinney wrote:
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3722
> >
> > Fix VS2019 NOOPT build issues related to converting
> > a larger integer value to a smaller integer value.
> >
> > Cc: Anthony Perard <anthony.perard@citrix.com>
> > Cc: Julien Grall <julien@xen.org>
> > Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> > Cc: Jiewen Yao <jiewen.yao@intel.com>
> > Cc: Jordan Justen <jordan.l.justen@intel.com>
> > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
> 
> Acked-by: Gerd Hoffmann <kraxel@redhat.com>


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

* Re: [edk2-devel] [Patch 1/1] OvmfPkg/Xen: Fix VS2019 build issues
  2021-11-08 16:22 [Patch 1/1] OvmfPkg/Xen: Fix VS2019 build issues Michael D Kinney
  2021-11-09  7:01 ` Gerd Hoffmann
@ 2021-11-11 10:24 ` Philippe Mathieu-Daudé
  2021-11-11 19:45   ` Michael D Kinney
  1 sibling, 1 reply; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-11-11 10:24 UTC (permalink / raw)
  To: devel, michael.d.kinney
  Cc: Anthony Perard, Julien Grall, Ard Biesheuvel, Jiewen Yao,
	Jordan Justen, Gerd Hoffmann

Hi Michael,

On 11/8/21 17:22, Michael D Kinney wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3722
> 
> Fix VS2019 NOOPT build issues related to converting
> a larger integer value to a smaller integer value.
> 
> Cc: Anthony Perard <anthony.perard@citrix.com>
> Cc: Julien Grall <julien@xen.org>
> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
> ---
>  .../Library/XenRealTimeClockLib/XenRealTimeClockLib.c  | 10 +++++-----
>  OvmfPkg/XenPlatformPei/MemDetect.c                     |  2 +-
>  OvmfPkg/XenTimerDxe/XenTimerDxe.c                      |  4 ++--
>  3 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.c b/OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.c
> index e113bc89bd75..72e0aaa8798c 100644
> --- a/OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.c
> +++ b/OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.c
> @@ -53,9 +53,9 @@ EpochToEfiTime (
>    m  = (((da * 5) + 308) / 153) - 2;
>    d  = da - (((m + 4) * 153) / 5) + 122;
>  
> -  Time->Year  = y - 4800 + ((m + 2) / 12);
> +  Time->Year  = (UINT16)(y - 4800 + ((m + 2) / 12));
>    Time->Month = ((m + 2) % 12) + 1;
> -  Time->Day   = d + 1;
> +  Time->Day   = (UINT8)(d + 1);
>  
>    ss = EpochSeconds % 60;
>    a  = (EpochSeconds - ss) / 60;
> @@ -63,9 +63,9 @@ EpochToEfiTime (
>    b = (a - mm) / 60;
>    hh = b % 24;
>  
> -  Time->Hour        = hh;
> -  Time->Minute      = mm;
> -  Time->Second      = ss;
> +  Time->Hour        = (UINT8)hh;
> +  Time->Minute      = (UINT8)mm;
> +  Time->Second      = (UINT8)ss;
>    Time->Nanosecond  = 0;
>  
>  }

I see this matches EmbeddedPkg::TimeBaseLib.c, but shouldn't both
implementations be safer using MdePkg::SafeIntLib.h?


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

* Re: [edk2-devel] [Patch 1/1] OvmfPkg/Xen: Fix VS2019 build issues
  2021-11-11 10:24 ` [edk2-devel] " Philippe Mathieu-Daudé
@ 2021-11-11 19:45   ` Michael D Kinney
  0 siblings, 0 replies; 5+ messages in thread
From: Michael D Kinney @ 2021-11-11 19:45 UTC (permalink / raw)
  To: devel@edk2.groups.io, philmd@redhat.com, Kinney, Michael D
  Cc: Anthony Perard, Julien Grall, Ard Biesheuvel, Yao, Jiewen,
	Justen, Jordan L, Gerd Hoffmann



> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Philippe Mathieu-Daudé
> Sent: Thursday, November 11, 2021 2:24 AM
> To: devel@edk2.groups.io; Kinney, Michael D <michael.d.kinney@intel.com>
> Cc: Anthony Perard <anthony.perard@citrix.com>; Julien Grall <julien@xen.org>; Ard Biesheuvel <ardb+tianocore@kernel.org>;
> Yao, Jiewen <jiewen.yao@intel.com>; Justen, Jordan L <jordan.l.justen@intel.com>; Gerd Hoffmann <kraxel@redhat.com>
> Subject: Re: [edk2-devel] [Patch 1/1] OvmfPkg/Xen: Fix VS2019 build issues
> 
> Hi Michael,
> 
> On 11/8/21 17:22, Michael D Kinney wrote:
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3722
> >
> > Fix VS2019 NOOPT build issues related to converting
> > a larger integer value to a smaller integer value.
> >
> > Cc: Anthony Perard <anthony.perard@citrix.com>
> > Cc: Julien Grall <julien@xen.org>
> > Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> > Cc: Jiewen Yao <jiewen.yao@intel.com>
> > Cc: Jordan Justen <jordan.l.justen@intel.com>
> > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
> > ---
> >  .../Library/XenRealTimeClockLib/XenRealTimeClockLib.c  | 10 +++++-----
> >  OvmfPkg/XenPlatformPei/MemDetect.c                     |  2 +-
> >  OvmfPkg/XenTimerDxe/XenTimerDxe.c                      |  4 ++--
> >  3 files changed, 8 insertions(+), 8 deletions(-)
> >
> > diff --git a/OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.c
> b/OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.c
> > index e113bc89bd75..72e0aaa8798c 100644
> > --- a/OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.c
> > +++ b/OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.c
> > @@ -53,9 +53,9 @@ EpochToEfiTime (
> >    m  = (((da * 5) + 308) / 153) - 2;
> >    d  = da - (((m + 4) * 153) / 5) + 122;
> >
> > -  Time->Year  = y - 4800 + ((m + 2) / 12);
> > +  Time->Year  = (UINT16)(y - 4800 + ((m + 2) / 12));
> >    Time->Month = ((m + 2) % 12) + 1;
> > -  Time->Day   = d + 1;
> > +  Time->Day   = (UINT8)(d + 1);
> >
> >    ss = EpochSeconds % 60;
> >    a  = (EpochSeconds - ss) / 60;
> > @@ -63,9 +63,9 @@ EpochToEfiTime (
> >    b = (a - mm) / 60;
> >    hh = b % 24;
> >
> > -  Time->Hour        = hh;
> > -  Time->Minute      = mm;
> > -  Time->Second      = ss;
> > +  Time->Hour        = (UINT8)hh;
> > +  Time->Minute      = (UINT8)mm;
> > +  Time->Second      = (UINT8)ss;
> >    Time->Nanosecond  = 0;
> >
> >  }
> 
> I see this matches EmbeddedPkg::TimeBaseLib.c, but shouldn't both
> implementations be safer using MdePkg::SafeIntLib.h?

I agree.  Do you want to enter a BZ for this task with pointers to
the source files that should update their math ops to use SafeIntLib?

> 
> 
> 
> 
> 


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

end of thread, other threads:[~2021-11-11 19:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-08 16:22 [Patch 1/1] OvmfPkg/Xen: Fix VS2019 build issues Michael D Kinney
2021-11-09  7:01 ` Gerd Hoffmann
2021-11-11  4:02   ` Yao, Jiewen
2021-11-11 10:24 ` [edk2-devel] " Philippe Mathieu-Daudé
2021-11-11 19:45   ` Michael D Kinney

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