* [PATCH] ArmPkg/ArmMmuLib ARM: trim high memory regions instead of rejecting them
@ 2019-01-28 16:23 Ard Biesheuvel
2019-01-28 18:11 ` Leif Lindholm
0 siblings, 1 reply; 3+ messages in thread
From: Ard Biesheuvel @ 2019-01-28 16:23 UTC (permalink / raw)
To: edk2-devel
ArmSetMemoryAttributes() still chokes in some cases, i.e., when the
length of the region exceeds 4 GB, the subtraction overflows, which
results in the region being misidentified as being 32-bit addressable.
Let's update the logic to trim the length to what we can address with
32 bits. This fixes the issue, and also deals with the issue where an
entire region is disregarded if part of it exceeds beyond what we can
map with 32 bits.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c
index bffab83d4fd0..baa085c3849a 100644
--- a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c
+++ b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c
@@ -744,10 +744,11 @@ ArmSetMemoryAttributes (
UINT64 ChunkLength;
BOOLEAN FlushTlbs;
- if (BaseAddress > (UINT64)MAX_ADDRESS - Length + 1) {
+ if (BaseAddress > (UINT64)MAX_ADDRESS) {
return EFI_UNSUPPORTED;
}
+ Length = MIN (Length, (UINT64)MAX_ADDRESS - BaseAddress + 1);
if (Length == 0) {
return EFI_SUCCESS;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ArmPkg/ArmMmuLib ARM: trim high memory regions instead of rejecting them
2019-01-28 16:23 [PATCH] ArmPkg/ArmMmuLib ARM: trim high memory regions instead of rejecting them Ard Biesheuvel
@ 2019-01-28 18:11 ` Leif Lindholm
2019-01-28 19:03 ` Ard Biesheuvel
0 siblings, 1 reply; 3+ messages in thread
From: Leif Lindholm @ 2019-01-28 18:11 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: edk2-devel
On Mon, Jan 28, 2019 at 05:23:32PM +0100, Ard Biesheuvel wrote:
> ArmSetMemoryAttributes() still chokes in some cases, i.e., when the
> length of the region exceeds 4 GB, the subtraction overflows, which
> results in the region being misidentified as being 32-bit addressable.
>
> Let's update the logic to trim the length to what we can address with
> 32 bits. This fixes the issue, and also deals with the issue where an
> entire region is disregarded if part of it exceeds beyond what we can
> map with 32 bits.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
> ---
> ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c
> index bffab83d4fd0..baa085c3849a 100644
> --- a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c
> +++ b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c
> @@ -744,10 +744,11 @@ ArmSetMemoryAttributes (
> UINT64 ChunkLength;
> BOOLEAN FlushTlbs;
>
> - if (BaseAddress > (UINT64)MAX_ADDRESS - Length + 1) {
> + if (BaseAddress > (UINT64)MAX_ADDRESS) {
> return EFI_UNSUPPORTED;
> }
>
> + Length = MIN (Length, (UINT64)MAX_ADDRESS - BaseAddress + 1);
> if (Length == 0) {
> return EFI_SUCCESS;
> }
> --
> 2.20.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ArmPkg/ArmMmuLib ARM: trim high memory regions instead of rejecting them
2019-01-28 18:11 ` Leif Lindholm
@ 2019-01-28 19:03 ` Ard Biesheuvel
0 siblings, 0 replies; 3+ messages in thread
From: Ard Biesheuvel @ 2019-01-28 19:03 UTC (permalink / raw)
To: Leif Lindholm; +Cc: edk2-devel@lists.01.org
On Mon, 28 Jan 2019 at 19:11, Leif Lindholm <leif.lindholm@linaro.org> wrote:
>
> On Mon, Jan 28, 2019 at 05:23:32PM +0100, Ard Biesheuvel wrote:
> > ArmSetMemoryAttributes() still chokes in some cases, i.e., when the
> > length of the region exceeds 4 GB, the subtraction overflows, which
> > results in the region being misidentified as being 32-bit addressable.
> >
> > Let's update the logic to trim the length to what we can address with
> > 32 bits. This fixes the issue, and also deals with the issue where an
> > entire region is disregarded if part of it exceeds beyond what we can
> > map with 32 bits.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>
> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
>
Thanks
Pushed as 9a00a7164a39..66509f90fc66
> > ---
> > ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c
> > index bffab83d4fd0..baa085c3849a 100644
> > --- a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c
> > +++ b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c
> > @@ -744,10 +744,11 @@ ArmSetMemoryAttributes (
> > UINT64 ChunkLength;
> > BOOLEAN FlushTlbs;
> >
> > - if (BaseAddress > (UINT64)MAX_ADDRESS - Length + 1) {
> > + if (BaseAddress > (UINT64)MAX_ADDRESS) {
> > return EFI_UNSUPPORTED;
> > }
> >
> > + Length = MIN (Length, (UINT64)MAX_ADDRESS - BaseAddress + 1);
> > if (Length == 0) {
> > return EFI_SUCCESS;
> > }
> > --
> > 2.20.1
> >
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-01-28 19:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-28 16:23 [PATCH] ArmPkg/ArmMmuLib ARM: trim high memory regions instead of rejecting them Ard Biesheuvel
2019-01-28 18:11 ` Leif Lindholm
2019-01-28 19:03 ` Ard Biesheuvel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox