public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] ArmPkg ArmVirtPkg: fix the GIC base address variables as 64-bit
@ 2016-10-17  5:03 Dennis Chen
  2016-10-17  7:28 ` Ard Biesheuvel
  0 siblings, 1 reply; 6+ messages in thread
From: Dennis Chen @ 2016-10-17  5:03 UTC (permalink / raw)
  To: edk2-devel; +Cc: nd, Dennis Chen, Ard Biesheuvel, Leif Lindholm

Since ACPI spec defines the GIC base addresses (CPU interface,
Distributor and Redistributor*GICv3 only*) as 64-bit, so we
should define these corresponding base address variables as 64-bit
instead of 32-bit. This patch redefines them according to the
ACPI spec.

Contributed-under: TianoCore Contribution Agreement 1.0
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Signed-off-by: Dennis Chen <dennis.chen@arm.com>
---
 ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c                | 4 ++--
 ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c
index b9ecd55..a4ba5cf 100644
--- a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c
+++ b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c
@@ -30,8 +30,8 @@ Abstract:
 
 extern EFI_HARDWARE_INTERRUPT_PROTOCOL gHardwareInterruptV2Protocol;
 
-STATIC UINT32 mGicInterruptInterfaceBase;
-STATIC UINT32 mGicDistributorBase;
+STATIC UINTN mGicInterruptInterfaceBase;
+STATIC UINTN mGicDistributorBase;
 
 /**
   Enable interrupt source Source.
diff --git a/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c b/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c
index 64afc4d..16683ef 100644
--- a/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c
+++ b/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c
@@ -79,11 +79,11 @@ ArmVirtGicArchLibConstructor (
 
     // RegProp[0..1] == { GICD base, GICD size }
     DistBase = SwapBytes64 (Reg[0]);
-    ASSERT (DistBase < MAX_UINT32);
+    ASSERT (DistBase < MAX_UINT64);
 
     // RegProp[2..3] == { GICR base, GICR size }
     RedistBase = SwapBytes64 (Reg[2]);
-    ASSERT (RedistBase < MAX_UINT32);
+    ASSERT (RedistBase < MAX_UINT64);
 
     PcdSet64 (PcdGicDistributorBase, DistBase);
     PcdSet64 (PcdGicRedistributorsBase, RedistBase);
@@ -117,8 +117,8 @@ ArmVirtGicArchLibConstructor (
 
     DistBase = SwapBytes64 (Reg[0]);
     CpuBase  = SwapBytes64 (Reg[2]);
-    ASSERT (DistBase < MAX_UINT32);
-    ASSERT (CpuBase < MAX_UINT32);
+    ASSERT (DistBase < MAX_UINT64);
+    ASSERT (CpuBase < MAX_UINT64);
 
     PcdSet64 (PcdGicDistributorBase, DistBase);
     PcdSet64 (PcdGicInterruptInterfaceBase, CpuBase);
-- 
2.7.4



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

* Re: [PATCH] ArmPkg ArmVirtPkg: fix the GIC base address variables as 64-bit
  2016-10-17  5:03 [PATCH] ArmPkg ArmVirtPkg: fix the GIC base address variables as 64-bit Dennis Chen
@ 2016-10-17  7:28 ` Ard Biesheuvel
  2016-10-17  7:44   ` Dennis Chen
  2016-10-17  8:33   ` Leif Lindholm
  0 siblings, 2 replies; 6+ messages in thread
From: Ard Biesheuvel @ 2016-10-17  7:28 UTC (permalink / raw)
  To: Dennis Chen; +Cc: edk2-devel-01, nd, Leif Lindholm

Hi Dennis,

On 17 October 2016 at 06:03, Dennis Chen <dennis.chen@arm.com> wrote:
> Since ACPI spec defines the GIC base addresses (CPU interface,
> Distributor and Redistributor*GICv3 only*) as 64-bit, so we
> should define these corresponding base address variables as 64-bit
> instead of 32-bit. This patch redefines them according to the
> ACPI spec.
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Leif Lindholm <leif.lindholm@linaro.org>
> Signed-off-by: Dennis Chen <dennis.chen@arm.com>
> ---
>  ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c                | 4 ++--
>  ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c | 8 ++++----

Could you split this patch in 2 please, and put Laszlo Ersek on cc for
the ArmVirtPkg patch?


>  2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c
> index b9ecd55..a4ba5cf 100644
> --- a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c
> +++ b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c
> @@ -30,8 +30,8 @@ Abstract:
>
>  extern EFI_HARDWARE_INTERRUPT_PROTOCOL gHardwareInterruptV2Protocol;
>
> -STATIC UINT32 mGicInterruptInterfaceBase;
> -STATIC UINT32 mGicDistributorBase;
> +STATIC UINTN mGicInterruptInterfaceBase;
> +STATIC UINTN mGicDistributorBase;
>

This should be UINT64 not UINTN

>  /**
>    Enable interrupt source Source.
> diff --git a/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c b/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c
> index 64afc4d..16683ef 100644
> --- a/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c
> +++ b/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c
> @@ -79,11 +79,11 @@ ArmVirtGicArchLibConstructor (
>
>      // RegProp[0..1] == { GICD base, GICD size }
>      DistBase = SwapBytes64 (Reg[0]);
> -    ASSERT (DistBase < MAX_UINT32);
> +    ASSERT (DistBase < MAX_UINT64);
>

This becomes equivalent to 'DistBase != MAX_UINT64' given that a
UINT64 cannot exceed MAX_UINT64. That is a nonsensical thing to
assert, so it is better to simply drop it

>      // RegProp[2..3] == { GICR base, GICR size }
>      RedistBase = SwapBytes64 (Reg[2]);
> -    ASSERT (RedistBase < MAX_UINT32);
> +    ASSERT (RedistBase < MAX_UINT64);
>

Likewise

>      PcdSet64 (PcdGicDistributorBase, DistBase);
>      PcdSet64 (PcdGicRedistributorsBase, RedistBase);
> @@ -117,8 +117,8 @@ ArmVirtGicArchLibConstructor (
>
>      DistBase = SwapBytes64 (Reg[0]);
>      CpuBase  = SwapBytes64 (Reg[2]);
> -    ASSERT (DistBase < MAX_UINT32);
> -    ASSERT (CpuBase < MAX_UINT32);
> +    ASSERT (DistBase < MAX_UINT64);
> +    ASSERT (CpuBase < MAX_UINT64);
>

Likewise

>      PcdSet64 (PcdGicDistributorBase, DistBase);
>      PcdSet64 (PcdGicInterruptInterfaceBase, CpuBase);
> --
> 2.7.4
>


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

* Re: [PATCH] ArmPkg ArmVirtPkg: fix the GIC base address variables as 64-bit
  2016-10-17  7:28 ` Ard Biesheuvel
@ 2016-10-17  7:44   ` Dennis Chen
  2016-10-17  8:33   ` Leif Lindholm
  1 sibling, 0 replies; 6+ messages in thread
From: Dennis Chen @ 2016-10-17  7:44 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: edk2-devel-01, nd, Leif Lindholm

Hello Ard,

Thanks for the comments! I will split this patch into 2 and for ArmVirtPkg patch,
we just need to simply drop the original ASSERT() since it's nonsensical any more.

Thanks,
Dennis

On Mon, Oct 17, 2016 at 08:28:50AM +0100, Ard Biesheuvel wrote:
> Hi Dennis,
> 
> On 17 October 2016 at 06:03, Dennis Chen <dennis.chen@arm.com> wrote:
> > Since ACPI spec defines the GIC base addresses (CPU interface,
> > Distributor and Redistributor*GICv3 only*) as 64-bit, so we
> > should define these corresponding base address variables as 64-bit
> > instead of 32-bit. This patch redefines them according to the
> > ACPI spec.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.0
> > Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> > Cc: Leif Lindholm <leif.lindholm@linaro.org>
> > Signed-off-by: Dennis Chen <dennis.chen@arm.com>
> > ---
> >  ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c                | 4 ++--
> >  ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c | 8 ++++----
> 
> Could you split this patch in 2 please, and put Laszlo Ersek on cc for
> the ArmVirtPkg patch?
> 
> 
> >  2 files changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c
> > index b9ecd55..a4ba5cf 100644
> > --- a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c
> > +++ b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c
> > @@ -30,8 +30,8 @@ Abstract:
> >
> >  extern EFI_HARDWARE_INTERRUPT_PROTOCOL gHardwareInterruptV2Protocol;
> >
> > -STATIC UINT32 mGicInterruptInterfaceBase;
> > -STATIC UINT32 mGicDistributorBase;
> > +STATIC UINTN mGicInterruptInterfaceBase;
> > +STATIC UINTN mGicDistributorBase;
> >
> 
> This should be UINT64 not UINTN
> 
> >  /**
> >    Enable interrupt source Source.
> > diff --git a/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c b/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c
> > index 64afc4d..16683ef 100644
> > --- a/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c
> > +++ b/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c
> > @@ -79,11 +79,11 @@ ArmVirtGicArchLibConstructor (
> >
> >      // RegProp[0..1] == { GICD base, GICD size }
> >      DistBase = SwapBytes64 (Reg[0]);
> > -    ASSERT (DistBase < MAX_UINT32);
> > +    ASSERT (DistBase < MAX_UINT64);
> >
> 
> This becomes equivalent to 'DistBase != MAX_UINT64' given that a
> UINT64 cannot exceed MAX_UINT64. That is a nonsensical thing to
> assert, so it is better to simply drop it
> 
> >      // RegProp[2..3] == { GICR base, GICR size }
> >      RedistBase = SwapBytes64 (Reg[2]);
> > -    ASSERT (RedistBase < MAX_UINT32);
> > +    ASSERT (RedistBase < MAX_UINT64);
> >
> 
> Likewise
> 
> >      PcdSet64 (PcdGicDistributorBase, DistBase);
> >      PcdSet64 (PcdGicRedistributorsBase, RedistBase);
> > @@ -117,8 +117,8 @@ ArmVirtGicArchLibConstructor (
> >
> >      DistBase = SwapBytes64 (Reg[0]);
> >      CpuBase  = SwapBytes64 (Reg[2]);
> > -    ASSERT (DistBase < MAX_UINT32);
> > -    ASSERT (CpuBase < MAX_UINT32);
> > +    ASSERT (DistBase < MAX_UINT64);
> > +    ASSERT (CpuBase < MAX_UINT64);
> >
> 
> Likewise
> 
> >      PcdSet64 (PcdGicDistributorBase, DistBase);
> >      PcdSet64 (PcdGicInterruptInterfaceBase, CpuBase);
> > --
> > 2.7.4
> >
> 



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

* Re: [PATCH] ArmPkg ArmVirtPkg: fix the GIC base address variables as 64-bit
  2016-10-17  7:28 ` Ard Biesheuvel
  2016-10-17  7:44   ` Dennis Chen
@ 2016-10-17  8:33   ` Leif Lindholm
  2016-10-17  9:20     ` Ard Biesheuvel
  1 sibling, 1 reply; 6+ messages in thread
From: Leif Lindholm @ 2016-10-17  8:33 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: Dennis Chen, edk2-devel-01

On Mon, Oct 17, 2016 at 08:28:50AM +0100, Ard Biesheuvel wrote:
> > diff --git a/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c b/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c
> > index 64afc4d..16683ef 100644
> > --- a/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c
> > +++ b/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c
> > @@ -79,11 +79,11 @@ ArmVirtGicArchLibConstructor (
> >
> >      // RegProp[0..1] == { GICD base, GICD size }
> >      DistBase = SwapBytes64 (Reg[0]);
> > -    ASSERT (DistBase < MAX_UINT32);
> > +    ASSERT (DistBase < MAX_UINT64);
> >
> 
> This becomes equivalent to 'DistBase != MAX_UINT64' given that a
> UINT64 cannot exceed MAX_UINT64. That is a nonsensical thing to
> assert, so it is better to simply drop it

Random thought:
Could we keep the assert(s) and change the test to MAX_UINTN, to have
a sanity test over whether a 32-bit plaform ends up with a duff
address?

/
    Leif

> >      // RegProp[2..3] == { GICR base, GICR size }
> >      RedistBase = SwapBytes64 (Reg[2]);
> > -    ASSERT (RedistBase < MAX_UINT32);
> > +    ASSERT (RedistBase < MAX_UINT64);
> >
> 
> Likewise
> 
> >      PcdSet64 (PcdGicDistributorBase, DistBase);
> >      PcdSet64 (PcdGicRedistributorsBase, RedistBase);
> > @@ -117,8 +117,8 @@ ArmVirtGicArchLibConstructor (
> >
> >      DistBase = SwapBytes64 (Reg[0]);
> >      CpuBase  = SwapBytes64 (Reg[2]);
> > -    ASSERT (DistBase < MAX_UINT32);
> > -    ASSERT (CpuBase < MAX_UINT32);
> > +    ASSERT (DistBase < MAX_UINT64);
> > +    ASSERT (CpuBase < MAX_UINT64);
> >
> 
> Likewise
> 
> >      PcdSet64 (PcdGicDistributorBase, DistBase);
> >      PcdSet64 (PcdGicInterruptInterfaceBase, CpuBase);
> > --
> > 2.7.4
> >


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

* Re: [PATCH] ArmPkg ArmVirtPkg: fix the GIC base address variables as 64-bit
  2016-10-17  8:33   ` Leif Lindholm
@ 2016-10-17  9:20     ` Ard Biesheuvel
  2016-10-17  9:27       ` Leif Lindholm
  0 siblings, 1 reply; 6+ messages in thread
From: Ard Biesheuvel @ 2016-10-17  9:20 UTC (permalink / raw)
  To: Leif Lindholm; +Cc: Dennis Chen, edk2-devel-01

On 17 October 2016 at 09:33, Leif Lindholm <leif.lindholm@linaro.org> wrote:
> On Mon, Oct 17, 2016 at 08:28:50AM +0100, Ard Biesheuvel wrote:
>> > diff --git a/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c b/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c
>> > index 64afc4d..16683ef 100644
>> > --- a/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c
>> > +++ b/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c
>> > @@ -79,11 +79,11 @@ ArmVirtGicArchLibConstructor (
>> >
>> >      // RegProp[0..1] == { GICD base, GICD size }
>> >      DistBase = SwapBytes64 (Reg[0]);
>> > -    ASSERT (DistBase < MAX_UINT32);
>> > +    ASSERT (DistBase < MAX_UINT64);
>> >
>>
>> This becomes equivalent to 'DistBase != MAX_UINT64' given that a
>> UINT64 cannot exceed MAX_UINT64. That is a nonsensical thing to
>> assert, so it is better to simply drop it
>
> Random thought:
> Could we keep the assert(s) and change the test to MAX_UINTN, to have
> a sanity test over whether a 32-bit plaform ends up with a duff
> address?
>

That seems like a useful thing in general, but given that we don't do
that anywhere else, I'd rather we just remove them.


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

* Re: [PATCH] ArmPkg ArmVirtPkg: fix the GIC base address variables as 64-bit
  2016-10-17  9:20     ` Ard Biesheuvel
@ 2016-10-17  9:27       ` Leif Lindholm
  0 siblings, 0 replies; 6+ messages in thread
From: Leif Lindholm @ 2016-10-17  9:27 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: Dennis Chen, edk2-devel-01

On Mon, Oct 17, 2016 at 10:20:30AM +0100, Ard Biesheuvel wrote:
> On 17 October 2016 at 09:33, Leif Lindholm <leif.lindholm@linaro.org> wrote:
> > On Mon, Oct 17, 2016 at 08:28:50AM +0100, Ard Biesheuvel wrote:
> >> > diff --git a/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c b/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c
> >> > index 64afc4d..16683ef 100644
> >> > --- a/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c
> >> > +++ b/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c
> >> > @@ -79,11 +79,11 @@ ArmVirtGicArchLibConstructor (
> >> >
> >> >      // RegProp[0..1] == { GICD base, GICD size }
> >> >      DistBase = SwapBytes64 (Reg[0]);
> >> > -    ASSERT (DistBase < MAX_UINT32);
> >> > +    ASSERT (DistBase < MAX_UINT64);
> >> >
> >>
> >> This becomes equivalent to 'DistBase != MAX_UINT64' given that a
> >> UINT64 cannot exceed MAX_UINT64. That is a nonsensical thing to
> >> assert, so it is better to simply drop it
> >
> > Random thought:
> > Could we keep the assert(s) and change the test to MAX_UINTN, to have
> > a sanity test over whether a 32-bit plaform ends up with a duff
> > address?
> 
> That seems like a useful thing in general, but given that we don't do
> that anywhere else, I'd rather we just remove them.

I won't argue with that.

/
    Leif


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

end of thread, other threads:[~2016-10-17  9:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-17  5:03 [PATCH] ArmPkg ArmVirtPkg: fix the GIC base address variables as 64-bit Dennis Chen
2016-10-17  7:28 ` Ard Biesheuvel
2016-10-17  7:44   ` Dennis Chen
2016-10-17  8:33   ` Leif Lindholm
2016-10-17  9:20     ` Ard Biesheuvel
2016-10-17  9:27       ` Leif Lindholm

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