public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 0/4] Improve performance of boundary validation in MakeTable()
@ 2019-02-25  6:08 Shenglei Zhang
  2019-02-25  6:08 ` [PATCH 1/4] BaseTools/TianoCompress: Improve performance of boundary validation Shenglei Zhang
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Shenglei Zhang @ 2019-02-25  6:08 UTC (permalink / raw)
  To: edk2-devel; +Cc: Bob Feng, Liming Gao, Yonghong Zhu, Michael D Kinney

The boundary validation checking in MakeTable() performs on
every loop iteration. This could be improved by checking
just once before the loop.
https://bugzilla.tianocore.org/show_bug.cgi?id=1329

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Shenglei Zhang (4):
  BaseTools/TianoCompress: Improve performance of boundary validation
  BaseTools/C/Common: Improve performance of boundary validation
  IntelFrameworkModulePkg: Improve performance of boundary validation
  MdePkg/BaseUefiDecompressLib: Improve performance of boundary
    validation

 BaseTools/Source/C/Common/Decompress.c              | 13 +++++++------
 BaseTools/Source/C/TianoCompress/TianoCompress.c    |  9 +++++----
 .../BaseUefiTianoCustomDecompressLib.c              | 12 ++++++------
 .../BaseUefiDecompressLib/BaseUefiDecompressLib.c   |  8 ++++----
 4 files changed, 22 insertions(+), 20 deletions(-)

-- 
2.18.0.windows.1



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/4] BaseTools/TianoCompress: Improve performance of boundary validation
  2019-02-25  6:08 [PATCH 0/4] Improve performance of boundary validation in MakeTable() Shenglei Zhang
@ 2019-02-25  6:08 ` Shenglei Zhang
  2019-02-25  6:08 ` [PATCH 2/4] BaseTools/C/Common: " Shenglei Zhang
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Shenglei Zhang @ 2019-02-25  6:08 UTC (permalink / raw)
  To: edk2-devel; +Cc: Bob Feng, Liming Gao, Yonghong Zhu

The boundary validation checking in MakeTable() performs on
every loop iteration. This could be improved by checking
just once before the loop.
https://bugzilla.tianocore.org/show_bug.cgi?id=1329

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
---
 BaseTools/Source/C/TianoCompress/TianoCompress.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/BaseTools/Source/C/TianoCompress/TianoCompress.c b/BaseTools/Source/C/TianoCompress/TianoCompress.c
index 29b11c597f..e79b287ea4 100644
--- a/BaseTools/Source/C/TianoCompress/TianoCompress.c
+++ b/BaseTools/Source/C/TianoCompress/TianoCompress.c
@@ -2281,13 +2281,14 @@ Returns:
 
     if (Len <= TableBits) {
 
-      for (Index = Start[Len]; Index < NextCode; Index++) {
-        if (Index >= MaxTableLength) {
-          return (UINT16) BAD_TABLE;
-        }
+      if (Start[Len] + NextCode > MaxTableLength) {
+        return (UINT16) BAD_TABLE;
+      }
+	  for (Index = Start[Len]; Index < NextCode; Index++) {
         Table[Index] = Char;
       }
 
+
     } else {
 
       Index3  = Start[Len];
-- 
2.18.0.windows.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/4] BaseTools/C/Common: Improve performance of boundary validation
  2019-02-25  6:08 [PATCH 0/4] Improve performance of boundary validation in MakeTable() Shenglei Zhang
  2019-02-25  6:08 ` [PATCH 1/4] BaseTools/TianoCompress: Improve performance of boundary validation Shenglei Zhang
@ 2019-02-25  6:08 ` Shenglei Zhang
  2019-02-25  6:08 ` [PATCH 3/4] IntelFrameworkModulePkg: " Shenglei Zhang
  2019-02-25  6:08 ` [PATCH 4/4] MdePkg/BaseUefiDecompressLib: " Shenglei Zhang
  3 siblings, 0 replies; 5+ messages in thread
From: Shenglei Zhang @ 2019-02-25  6:08 UTC (permalink / raw)
  To: edk2-devel; +Cc: Bob Feng, Liming Gao, Yonghong Zhu

The boundary validation checking in MakeTable() performs on
every loop iteration. This could be improved by checking
just once before the loop.
https://bugzilla.tianocore.org/show_bug.cgi?id=1329

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
---
 BaseTools/Source/C/Common/Decompress.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/BaseTools/Source/C/Common/Decompress.c b/BaseTools/Source/C/Common/Decompress.c
index 0e9ba0a982..adac66c5c2 100644
--- a/BaseTools/Source/C/Common/Decompress.c
+++ b/BaseTools/Source/C/Common/Decompress.c
@@ -254,12 +254,13 @@ Returns:
 
     if (Len <= TableBits) {
 
-      for (Index = Start[Len]; Index < NextCode; Index++) {
-        if (Index >= MaxTableLength) {
-          return (UINT16) BAD_TABLE;
-        }
-        Table[Index] = Char;
-      }
+	if (Start[Len] + NextCode > MaxTableLength) {
+	  return (UINT16) BAD_TABLE;
+	}
+	for (Index = Start[Len]; Index < NextCode; Index++) {
+	  Table[Index] = Char;
+	}
+
 
     } else {
 
-- 
2.18.0.windows.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] IntelFrameworkModulePkg: Improve performance of boundary validation
  2019-02-25  6:08 [PATCH 0/4] Improve performance of boundary validation in MakeTable() Shenglei Zhang
  2019-02-25  6:08 ` [PATCH 1/4] BaseTools/TianoCompress: Improve performance of boundary validation Shenglei Zhang
  2019-02-25  6:08 ` [PATCH 2/4] BaseTools/C/Common: " Shenglei Zhang
@ 2019-02-25  6:08 ` Shenglei Zhang
  2019-02-25  6:08 ` [PATCH 4/4] MdePkg/BaseUefiDecompressLib: " Shenglei Zhang
  3 siblings, 0 replies; 5+ messages in thread
From: Shenglei Zhang @ 2019-02-25  6:08 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao

The boundary validation checking in MakeTable() performs on
every loop iteration. This could be improved by checking
just once before the loop.
https://bugzilla.tianocore.org/show_bug.cgi?id=1329

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
---
 .../BaseUefiTianoCustomDecompressLib.c               | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c b/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c
index 970795b1da..a7ff94920e 100644
--- a/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c
+++ b/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c
@@ -213,12 +213,12 @@ MakeTable (
 
     if (Len <= TableBits) {
 
-      for (Index = Start[Len]; Index < NextCode; Index++) {
-        if (Index >= MaxTableLength) {
-          return (UINT16) BAD_TABLE;
-        }
-        Table[Index] = Char;
-      }
+	if (Start[Len] + NextCode > MaxTableLength) {
+	  return (UINT16) BAD_TABLE;
+	}
+	for (Index = Start[Len]; Index < NextCode; Index++) {
+	  Table[Index] = Char;
+	}
 
     } else {
 
-- 
2.18.0.windows.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/4] MdePkg/BaseUefiDecompressLib: Improve performance of boundary validation
  2019-02-25  6:08 [PATCH 0/4] Improve performance of boundary validation in MakeTable() Shenglei Zhang
                   ` (2 preceding siblings ...)
  2019-02-25  6:08 ` [PATCH 3/4] IntelFrameworkModulePkg: " Shenglei Zhang
@ 2019-02-25  6:08 ` Shenglei Zhang
  3 siblings, 0 replies; 5+ messages in thread
From: Shenglei Zhang @ 2019-02-25  6:08 UTC (permalink / raw)
  To: edk2-devel; +Cc: Michael D Kinney, Liming Gao

The boundary validation checking in MakeTable() performs on
every loop iteration. This could be improved by checking
just once before the loop.
https://bugzilla.tianocore.org/show_bug.cgi?id=1329

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
---
 .../Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c b/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c
index c1e8c5581a..e979b18f0f 100644
--- a/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c
+++ b/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c
@@ -222,10 +222,10 @@ MakeTable (
 
     if (Len <= TableBits) {
 
-      for (Index = Start[Len]; Index < NextCode; Index++) {
-        if (Index >= MaxTableLength) {
-          return (UINT16) BAD_TABLE;
-        }
+      if (Start[Len] + NextCode > MaxTableLength) {
+        return (UINT16) BAD_TABLE;
+      }
+	  for (Index = Start[Len]; Index < NextCode; Index++) {
         Table[Index] = Char;
       }
 
-- 
2.18.0.windows.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-02-25  6:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-25  6:08 [PATCH 0/4] Improve performance of boundary validation in MakeTable() Shenglei Zhang
2019-02-25  6:08 ` [PATCH 1/4] BaseTools/TianoCompress: Improve performance of boundary validation Shenglei Zhang
2019-02-25  6:08 ` [PATCH 2/4] BaseTools/C/Common: " Shenglei Zhang
2019-02-25  6:08 ` [PATCH 3/4] IntelFrameworkModulePkg: " Shenglei Zhang
2019-02-25  6:08 ` [PATCH 4/4] MdePkg/BaseUefiDecompressLib: " Shenglei Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox