public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ni, Ruiyu" <ruiyu.ni@Intel.com>
To: Jian J Wang <jian.j.wang@intel.com>, edk2-devel@lists.01.org
Cc: Eric Dong <eric.dong@intel.com>, Laszlo Ersek <lersek@redhat.com>
Subject: Re: [PATCH] UefiCpuPkg/CpuDxe: fix SetMemoryAttributes issue in 32-bit mode
Date: Tue, 16 Jan 2018 12:58:19 +0800	[thread overview]
Message-ID: <a922059b-5f76-832b-8c08-7b6ab00ee121@Intel.com> (raw)
In-Reply-To: <20180116024726.12892-1-jian.j.wang@intel.com>

On 1/16/2018 10:47 AM, Jian J Wang wrote:
> In 32-bit mode, the BIOS will not create page table for memory beyond
> 4GB and therefore it cannot handle the attributes change request for
> those memory. But current CpuDxe doesn't check this situation and still
> try to complete the request, which will cause attributes of incorrect
> memory address to be changed due to type cast from 64-bit to 32-bit.
> 
> This patch fixes this issue by checking the end address of input
> memory block and returning EFI_UNSUPPORTED if it's out of range.
> 
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
> ---
>   UefiCpuPkg/CpuDxe/CpuPageTable.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/UefiCpuPkg/CpuDxe/CpuPageTable.c b/UefiCpuPkg/CpuDxe/CpuPageTable.c
> index a9c9bc9d5e..3ad55f65c5 100644
> --- a/UefiCpuPkg/CpuDxe/CpuPageTable.c
> +++ b/UefiCpuPkg/CpuDxe/CpuPageTable.c
> @@ -699,6 +699,10 @@ ConvertMemoryPageAttributes (
>         DEBUG ((DEBUG_ERROR, "Non-PAE Paging!\n"));
>         return EFI_UNSUPPORTED;
>       }
> +    if ((BaseAddress + Length) > BASE_4GB) {
> +      DEBUG ((DEBUG_ERROR, "Beyond 4GB memory in 32-bit mode!\n"));
> +      return EFI_UNSUPPORTED;
> +    }
>       break;
>     case IMAGE_FILE_MACHINE_X64:
>       ASSERT (CurrentPagingContext.ContextData.X64.PageTableBase != 0);
> 

Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
-- 
Thanks,
Ray


      reply	other threads:[~2018-01-16  4:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-16  2:47 [PATCH] UefiCpuPkg/CpuDxe: fix SetMemoryAttributes issue in 32-bit mode Jian J Wang
2018-01-16  4:58 ` Ni, Ruiyu [this message]

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=a922059b-5f76-832b-8c08-7b6ab00ee121@Intel.com \
    --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