public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Zeng, Star" <star.zeng@intel.com>
To: "Wang, Jian J" <jian.j.wang@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Dong, Eric" <eric.dong@intel.com>,
	"Bi, Dandan" <dandan.bi@intel.com>,
	"Zeng, Star" <star.zeng@intel.com>
Subject: Re: [PATCH] MdeModulePkg/Core: Fix build error with old Visual Studio
Date: Mon, 20 Nov 2017 05:04:27 +0000	[thread overview]
Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B9B8306@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <20171120034343.10764-1-jian.j.wang@intel.com>

How about to use bit instead of decimal, for example BIT0 for 001, BIT2 for 100 and BIT0+BIT2 for 101, etc.

And please add detailed comments for return value of GetGuardedMemoryBits(), it has only VOID currently.

  @return VOID.


Thanks,
Star
-----Original Message-----
From: Wang, Jian J 
Sent: Monday, November 20, 2017 11:44 AM
To: edk2-devel@lists.01.org
Cc: Zeng, Star <star.zeng@intel.com>; Dong, Eric <eric.dong@intel.com>; Bi, Dandan <dandan.bi@intel.com>
Subject: [PATCH] MdeModulePkg/Core: Fix build error with old Visual Studio

The build error is introduced by following check in:
  2930ef9809976ce693d1d377851344c3b06bd926
  235a4490c8ce8b6dbac49e6ae3559cb73d6bf620

The Visual Studio older than 2015 doesn't support constant integer
in binary format (0bxxx). This patch change them to decimal to fix
it.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Bi Dandan <dandan.bi@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
---
 MdeModulePkg/Core/Dxe/Mem/HeapGuard.c   | 11 ++++++++---
 MdeModulePkg/Core/PiSmmCore/HeapGuard.c | 11 ++++++++---
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c b/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c
index 98d597b180..259aa6c500 100644
--- a/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c
+++ b/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c
@@ -501,8 +501,13 @@ IsGuardPage (
 {
   UINTN       BitMap;
 
+  //
+  // There must be at least one guarded page before and/or after given
+  // address if it's a Guard page. The bitmap pattern should be one of
+  // 001, 100 and 101
+  //
   BitMap = GetGuardedMemoryBits (Address - EFI_PAGE_SIZE, 3);
-  return ((BitMap == 0b001) || (BitMap == 0b100) || (BitMap == 0b101));
+  return ((BitMap == 1) || (BitMap == 4) || (BitMap == 5));
 }
 
 /**
@@ -519,7 +524,7 @@ IsHeadGuard (
   IN EFI_PHYSICAL_ADDRESS    Address
   )
 {
-  return (GetGuardedMemoryBits (Address, 2) == 0b10);
+  return (GetGuardedMemoryBits (Address, 2) == 2);
 }
 
 /**
@@ -536,7 +541,7 @@ IsTailGuard (
   IN EFI_PHYSICAL_ADDRESS    Address
   )
 {
-  return (GetGuardedMemoryBits (Address - EFI_PAGE_SIZE, 2) == 0b01);
+  return (GetGuardedMemoryBits (Address - EFI_PAGE_SIZE, 2) == 1);
 }
 
 /**
diff --git a/MdeModulePkg/Core/PiSmmCore/HeapGuard.c b/MdeModulePkg/Core/PiSmmCore/HeapGuard.c
index 6fda9ba430..676521c489 100644
--- a/MdeModulePkg/Core/PiSmmCore/HeapGuard.c
+++ b/MdeModulePkg/Core/PiSmmCore/HeapGuard.c
@@ -513,8 +513,13 @@ IsGuardPage (
 {
   UINTN       BitMap;
 
+  //
+  // There must be at least one guarded page before and/or after given
+  // address if it's a Guard page. The bitmap pattern should be one of
+  // 001, 100 and 101
+  //
   BitMap = GetGuardedMemoryBits (Address - EFI_PAGE_SIZE, 3);
-  return ((BitMap == 0b001) || (BitMap == 0b100) || (BitMap == 0b101));
+  return ((BitMap == 1) || (BitMap == 4) || (BitMap == 5));
 }
 
 /**
@@ -531,7 +536,7 @@ IsHeadGuard (
   IN EFI_PHYSICAL_ADDRESS    Address
   )
 {
-  return (GetGuardedMemoryBits (Address, 2) == 0b10);
+  return (GetGuardedMemoryBits (Address, 2) == 2);
 }
 
 /**
@@ -548,7 +553,7 @@ IsTailGuard (
   IN EFI_PHYSICAL_ADDRESS    Address
   )
 {
-  return (GetGuardedMemoryBits (Address - EFI_PAGE_SIZE, 2) == 0b01);
+  return (GetGuardedMemoryBits (Address - EFI_PAGE_SIZE, 2) == 1);
 }
 
 /**
-- 
2.14.1.windows.1



  reply	other threads:[~2017-11-20  5:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-20  3:43 [PATCH] MdeModulePkg/Core: Fix build error with old Visual Studio Jian J Wang
2017-11-20  5:04 ` Zeng, Star [this message]
2017-11-20  5:42   ` Wang, Jian J

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=0C09AFA07DD0434D9E2A0C6AEB0483103B9B8306@shsmsx102.ccr.corp.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