From: Leif Lindholm <leif.lindholm@linaro.org>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: edk2-devel@lists.01.org
Subject: Re: [PATCH 2/2] ArmPkg/ArmMmuLib ARM: fix thinko in second level page table handling
Date: Fri, 11 Jan 2019 18:07:32 +0000 [thread overview]
Message-ID: <20190111180732.ea3dl7mxw2z4hfgm@bivouac.eciton.net> (raw)
In-Reply-To: <20190104180432.24480-2-ard.biesheuvel@linaro.org>
On Fri, Jan 04, 2019 at 07:04:32PM +0100, Ard Biesheuvel wrote:
> PopulateLevel2PageTable () is invoked for [parts of] mappings that
> start or end on a non-1 MB aligned address (or both). The size of
> the mapping depends on both the start address modulo 1 MB and the
> length of the mapping, but the logic that calculates this size is
> flawed: subtracting 'start address modulo 1 MB' could result in a
> negative value for the remaining length, which is obviously wrong.
>
> So instead, take either RemainLength, or the rest of the 1 MB
> block, whichever is smaller.
>
> 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 | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c
> index b237321a8d8b..3b3b20aa9b78 100644
> --- a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c
> +++ b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c
> @@ -294,8 +294,8 @@ FillTranslationTable (
> PhysicalBase += TT_DESCRIPTOR_SECTION_SIZE;
> RemainLength -= TT_DESCRIPTOR_SECTION_SIZE;
> } else {
> - PageMapLength = MIN (RemainLength, TT_DESCRIPTOR_SECTION_SIZE) -
> - (PhysicalBase % TT_DESCRIPTOR_SECTION_SIZE);
> + PageMapLength = MIN (RemainLength, TT_DESCRIPTOR_SECTION_SIZE -
> + (PhysicalBase % TT_DESCRIPTOR_SECTION_SIZE));
>
> // Case: Physical address aligned on the Section Size (1MB) && the length
> // does not fill a section
> --
> 2.17.1
>
next prev parent reply other threads:[~2019-01-11 18:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-04 18:04 [PATCH 1/2] ArmPkg/ArmMmuLib ARM: add missing support for non-shareable cached mappings Ard Biesheuvel
2019-01-04 18:04 ` [PATCH 2/2] ArmPkg/ArmMmuLib ARM: fix thinko in second level page table handling Ard Biesheuvel
2019-01-11 18:07 ` Leif Lindholm [this message]
2019-01-13 16:36 ` Ard Biesheuvel
2019-01-11 18:04 ` [PATCH 1/2] ArmPkg/ArmMmuLib ARM: add missing support for non-shareable cached mappings Leif Lindholm
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190111180732.ea3dl7mxw2z4hfgm@bivouac.eciton.net \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox