public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ruiyu Ni <ruiyu.ni@intel.com>
To: edk2-devel@lists.01.org
Cc: Eric Dong <eric.dong@intel.com>, Star Zeng <star.zeng@intel.com>
Subject: [PATCH 3/4] UefiCpuPkg/MtrrLib: Handle one setting request covering all memory
Date: Tue,  9 Jan 2018 11:35:51 +0800	[thread overview]
Message-ID: <20180109033552.378192-4-ruiyu.ni@intel.com> (raw)
In-Reply-To: <20180109033552.378192-1-ruiyu.ni@intel.com>

*SetMemoryAttribute*() API cannot handle the setting request that
looks like <0, MAX_ADDRESS, Type>. The buggy parameter checking
logic returns Unsupported for this case.
The patch fixes the checking logic to handle such case.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
---
 UefiCpuPkg/Library/MtrrLib/MtrrLib.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
index 566a4cb67b..54f703606b 100644
--- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
+++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
@@ -2270,8 +2270,13 @@ MtrrSetMemoryAttributesInMtrrSettings (
       goto Exit;
     }
     if (((Ranges[Index].BaseAddress & ~MtrrValidAddressMask) != 0) ||
-        ((Ranges[Index].Length & ~MtrrValidAddressMask) != 0)
+        ((((Ranges[Index].BaseAddress + Ranges[Index].Length) & ~MtrrValidAddressMask) != 0) &&
+          (Ranges[Index].BaseAddress + Ranges[Index].Length) != MtrrValidBitsMask + 1)
         ) {
+      //
+      // Either the BaseAddress or the Limit doesn't follow the alignment requirement.
+      // Note: It's still valid if Limit doesn't follow the alignment requirement but equals to MAX Address.
+      //
       Status = RETURN_UNSUPPORTED;
       goto Exit;
     }
-- 
2.15.1.windows.2



  parent reply	other threads:[~2018-01-09  3:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-09  3:35 [PATCH 0/4] Quality improvement of MtrrLib Ruiyu Ni
2018-01-09  3:35 ` [PATCH 1/4] UefiCpuPkg/MtrrLib: Refine the debug messages Ruiyu Ni
2018-01-09  3:35 ` [PATCH 2/4] UefiCpuPkg/MtrrLib: Fix bug that may calculate wrong MTRR result Ruiyu Ni
2018-01-09  3:35 ` Ruiyu Ni [this message]
2018-01-09  3:35 ` [PATCH 4/4] UefiCpuPkg/MtrrLib: Correct typo to change vector to vertex Ruiyu Ni
2018-01-10  2:25 ` [PATCH 0/4] Quality improvement of MtrrLib Dong, Eric

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=20180109033552.378192-4-ruiyu.ni@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