mirror_edk2.git
3 years agoUefiCpuPkg PiSmmCpuDxeSmm: Remove redundant code to set IDT range to RO
Star Zeng [Fri, 12 Jan 2018 04:59:03 +0000 (12:59 +0800)]
UefiCpuPkg PiSmmCpuDxeSmm: Remove redundant code to set IDT range to RO

AllocateCodePages() is used to allocate buffer for IDT range,
the code pages will be set to RO in SetMemMapAttributes(),
then the code to set IDT range to RO in PatchGdtIdtMap() is
redundant and could be removed.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
3 years agoUefiCpuPkg PiSmmCpuDxeSmm: Fixed #double fault on #page fault for IA32
Star Zeng [Thu, 11 Jan 2018 10:27:12 +0000 (18:27 +0800)]
UefiCpuPkg PiSmmCpuDxeSmm: Fixed #double fault on #page fault for IA32

When StackGuard is enabled on IA32, the #double fault exception
is reported instead of #page fault.

This issue does not exist on X64, or IA32 without StackGuard.

The fix at e4435f710cea2d2f10cd7343d545920867780086 was incomplete.

It is because AllocateCodePages() is used to allocate buffer for
GDT and TSS, the code pages will be set to RO in SetMemMapAttributes().
But IA32 Stack Guard need use task switch to switch stack that need
write GDT and TSS, so AllocateCodePages() could not be used.

This patch uses AllocatePages() instead of AllocateCodePages() to
allocate buffer for GDT and TSS if StackGuard is enabled on IA32.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
3 years agoMdeModulePkg/Ip4Dxe: Add an independent timer for reconfig checking
Wang Fan [Thu, 11 Jan 2018 07:28:41 +0000 (15:28 +0800)]
MdeModulePkg/Ip4Dxe: Add an independent timer for reconfig checking

* Since wireless network can switch at very short time, the time interval
  of reconfig event checking is too long for this case. To achieve better
  performance and scalability, separate this task from Ip4 tick timer.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
3 years agoMdeModulePkg/DxeNetLib: Add array range check in NetIp6IsNetEqual().
Wang Fan [Thu, 11 Jan 2018 10:09:24 +0000 (18:09 +0800)]
MdeModulePkg/DxeNetLib: Add array range check in NetIp6IsNetEqual().

* The library API use array elements without any index range check, this
patch is to fix this issue to avoid null pointer reference.

V2
* Added an ASSERT check for the case PrefixLength equals to IP6_PREFIX_MAX.
* Synced some code descriptions to head file.

Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
3 years agoUefiCpuPkg/MpInitLib: fix 32-bit build error
Jian J Wang [Thu, 11 Jan 2018 01:00:28 +0000 (09:00 +0800)]
UefiCpuPkg/MpInitLib: fix 32-bit build error

Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Dandan Bi <dandan.bi@intel.com>
3 years agoNetworkPkg: Add more parameter or return status check in UDP6 driver
Wang Fan [Wed, 3 Jan 2018 10:11:04 +0000 (18:11 +0800)]
NetworkPkg: Add more parameter or return status check in UDP6 driver

In UDP6Dxe, there are several places that may be enhanced
to check input parameters and returned status. This patch
is to fix these issues.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
3 years agoNetworkPkg: Fix some coding style issues in UDP6 driver
Wang Fan [Wed, 3 Jan 2018 09:53:29 +0000 (17:53 +0800)]
NetworkPkg: Fix some coding style issues in UDP6 driver

In UDP6Dxe, there are some coding style issues, this patch
is to fix these issues.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
3 years agoNetworkPkg: Fix a memory leak issue in UDP6 driver
Wang Fan [Wed, 3 Jan 2018 09:35:53 +0000 (17:35 +0800)]
NetworkPkg: Fix a memory leak issue in UDP6 driver

In UDP6Dxe Udp6Groups(), the code return directly without free the
buffer allocated for McastIp when JoinFlag is TRUE. It is a memory
leak issue that needs to be fixed. This patch is to fix this issue.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
3 years agoNetworkPkg: Add ASSERT error handling for UDP6 driver
Wang Fan [Wed, 3 Jan 2018 09:30:54 +0000 (17:30 +0800)]
NetworkPkg: Add ASSERT error handling for UDP6 driver

In Udp6Dxe, there are several places use ASSERT to check returned
value. But these errors should be handled if they occur, this patch
is to fix this issue.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
3 years agoUefiCpuPkg/MtrrLib: Fix an assertion bug
Ruiyu Ni [Tue, 9 Jan 2018 10:25:20 +0000 (18:25 +0800)]
UefiCpuPkg/MtrrLib: Fix an assertion bug

0                     40          f0         100
+---WT--+--UC--+--WT--+-----WB----+----UC----+

When calculating the shortest path from 0 to 100, the
MtrrLibCalculateLeastMtrrs() is called to update the
Vertices.Previous.
When calculating the shortest path from 0 to 40,
MtrrLibCalculateLeastMtrrs() is called recursively to update the
Vertices.Previous.
The second call corrupt the Previous value that will be used
later.
The patch removes the code that corrupts Previous.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
3 years agoUefiCpuPkg/MtrrLib: Fix a MTRR calculation bug
Ruiyu Ni [Tue, 9 Jan 2018 08:46:40 +0000 (16:46 +0800)]
UefiCpuPkg/MtrrLib: Fix a MTRR calculation bug

80                   A8   B0   B8   C0
+----------WB--------+-UC-+-WT-+-WB-+

For above memory settings, current code caused the final MTRR
settings miss [A8, B0, UC] when default memory type is UC.

The root cause is the code only checks the mandatory weight
between A8 to B0, but skips to check the optional weight.
The patch fixes this issue.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
3 years agoMdeModulePkg/Dhcp4Dxe: Free NET_BUF data after sent out to avoid memory leak
Wang Fan [Wed, 10 Jan 2018 07:24:53 +0000 (15:24 +0800)]
MdeModulePkg/Dhcp4Dxe: Free NET_BUF data after sent out to avoid memory leak

* When build a DHCP message in function DhcpSendMessage() or DhcpRetransmit(),
a new NET_BUF is created by the library of NetbufFromExt, but it's not freed
after it is sent out. This patch is to fix this memory leak issue.

V2:
* Since packet has already been referred by DhcpSb->LastPacket, and will be
freed when sending another packet or clean up, there is no need to add an
extra free function in NetbufFromExt.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
3 years agoMdeModulePkg/VarCheckHii: Update data type for variable "ArrayIndex"
Bi, Dandan [Tue, 9 Jan 2018 07:24:44 +0000 (15:24 +0800)]
MdeModulePkg/VarCheckHii: Update data type for variable "ArrayIndex"

In some case the ArrayIndex with UINT16 may be not large enough to
hold the multiplication result of HiiQuestion->VarOffset * 8;
So this patch update the data type to fix this potential issue.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
3 years agoMdePkg/BaseLib: add attribute 'RETURNS_TWICE' to SetJump
M1cha [Sun, 7 Jan 2018 17:31:03 +0000 (01:31 +0800)]
MdePkg/BaseLib: add attribute 'RETURNS_TWICE' to SetJump

When compiling with any ARM toolchain and Os, registers can get
trashed when returning for the second time from SetJump because GCC
only handles this correctly when using standard names like 'setjmp' or
'getcontext'. When different names are used you have to use the
attribute 'returns_twice' to tell gcc to be extra careful.

example:
extern int  FN_NAME(void*);

void jmp_buf_set(void *jmpb, void (*f)(void))
{
  if (!FN_NAME(jmpb))
    f();
}

this code produces this wrong code with Os:
00000000 <jmp_buf_set>:
   0: e92d4010 push {r4, lr}
   4: e1a04001 mov r4, r1
   8: ebfffffe bl 0 <nonstandard_setjmp>
   c: e3500000 cmp r0, #0
  10: 01a03004 moveq r3, r4
  14: 08bd4010 popeq {r4, lr}
  18: 012fff13 bxeq r3
  1c: e8bd4010 pop {r4, lr}
  20: e12fff1e bx lr

The generated code pushes backups of r4 and lr to the stack and then
saves all registers using nonstandard_setjmp.
Then it pops the stack and jumps to the function in r3 which is the
main problem because now the function can overwrite our register
backups on the stack.
When we return a second time from the call to nonstandard_setjmp, the
stack pointer has it's original(pushed) position and when the code
pops r4 and lr from the stack the values are not guaranteed to be the
same.

When using a standard name like setjmp or getcontext or adding
'__attribute__((returns_twice))' to nonstandard_setjmp's declaration
the code looks different:

00000000 <jmp_buf_set>:
   0: e92d4007 push {r0, r1, r2, lr}
   4: e58d1004 str r1, [sp, #4]
   8: ebfffffe bl 0 <setjmp>
   c: e3500000 cmp r0, #0
  10: 059d3004 ldreq r3, [sp, #4]
  14: 01a0e00f moveq lr, pc
  18: 012fff13 bxeq r3
  1c: e28dd00c add sp, sp, #12
  20: e49de004 pop {lr} ; (ldr lr, [sp], #4)
  24: e12fff1e bx lr

Here the problem is being solved by restoring r3 from the stack
without popping it.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael Zimmermann <sigmaepsilon92@gmail.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoMdePkg: add RETURNS_TWICE attribute
M1cha [Wed, 27 Dec 2017 19:28:49 +0000 (03:28 +0800)]
MdePkg: add RETURNS_TWICE attribute

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael Zimmermann <sigmaepsilon92@gmail.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoBaseTools: Correct Target Path in CodaTargetList replace Path
Yunhua Feng [Wed, 3 Jan 2018 04:36:51 +0000 (12:36 +0800)]
BaseTools: Correct Target Path in CodaTargetList replace Path

Target Path in CodaTargetList is DebugDir path, correct replace
path with DebugDir

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
3 years agoMdeModulePkg/PciBus: Change switch-case to if-else to fix EBC build
Ruiyu Ni [Tue, 9 Jan 2018 05:52:47 +0000 (13:52 +0800)]
MdeModulePkg/PciBus: Change switch-case to if-else to fix EBC build

EBC compiler doesn't treat EFI_xxx as constant due to these macros
are UINT64 type in 64bit env and UINT32 type in 32bit env.
So it reports error when "case EFI_xxx" is used.
The patch changes to use if-else to fix EBC build failure.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
3 years agoUefiCpuPkg/MtrrLib: Correct typo to change vector to vertex
Ruiyu Ni [Tue, 9 Jan 2018 02:57:25 +0000 (10:57 +0800)]
UefiCpuPkg/MtrrLib: Correct typo to change vector to vertex

The patch only change the comments and variable name so
doesn't impact the functionality.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
3 years agoUefiCpuPkg/MtrrLib: Handle one setting request covering all memory
Ruiyu Ni [Tue, 9 Jan 2018 02:33:57 +0000 (10:33 +0800)]
UefiCpuPkg/MtrrLib: Handle one setting request covering all memory

*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>
Reviewed-by: Eric Dong <eric.dong@intel.com>
3 years agoUefiCpuPkg/MtrrLib: Fix bug that may calculate wrong MTRR result
Ruiyu Ni [Mon, 8 Jan 2018 10:11:39 +0000 (18:11 +0800)]
UefiCpuPkg/MtrrLib: Fix bug that may calculate wrong MTRR result

Code forgot to initialize the optional weight between adjacent
vertices. It caused wrong MTRR result was calculated for some
memory settings.

The logic was incorrectly removed when converting from POC
code. The patch adds back the initialization.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
3 years agoUefiCpuPkg/MtrrLib: Refine the debug messages
Ruiyu Ni [Mon, 8 Jan 2018 03:48:00 +0000 (11:48 +0800)]
UefiCpuPkg/MtrrLib: Refine the debug messages

MtrrSetMemoryAttributesInMtrrSettings() missed the debug messages
of memory attribute request and status. The patch moves all debug
messages from MtrrSetMemoryAttributeInMtrrSettings() to
MtrrSetMemoryAttributesInMtrrSettings() and refines the debug message
to carry more information.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
3 years agoMdeModulePkg/MdeModulePkg.uni: clarify Heap Guard usage
Jian J Wang [Mon, 8 Jan 2018 14:13:36 +0000 (22:13 +0800)]
MdeModulePkg/MdeModulePkg.uni: clarify Heap Guard usage

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
3 years agoMdeModulePkg/MdeModulePkg.dec: clarify Heap Guard usage
Jian J Wang [Fri, 29 Dec 2017 09:14:07 +0000 (17:14 +0800)]
MdeModulePkg/MdeModulePkg.dec: clarify Heap Guard usage

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
3 years agoNetworkPkg/IScsiDxe: Set ExitBootServiceEvent to NULL after close it.
Jiaxin Wu [Tue, 2 Jan 2018 05:30:44 +0000 (13:30 +0800)]
NetworkPkg/IScsiDxe: Set ExitBootServiceEvent to NULL after close it.

v2:
* Refine the commit log.

There are two place to close the ISCSI ExitBootServiceEvent:
#1.IScsiOnExitBootService(), which is the callback function of
   ExitBootServiceEvent.
#2.IScsiCleanDriverData(), which will be invoked by ISCSI driver
   binding stop().

So, the ExitBootServiceEvent will be closed and freed when exit boot
server is triggered. But it may be closed and freed again in ISCSI driver
binding stop(), which will result in the issue recorded at
https://bugzilla.tianocore.org/show_bug.cgi?id=742.

This patch is to resolve the issue.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
3 years agoMdeModulePkg/IScsiDxe: Set ExitBootServiceEvent to NULL after close it.
Jiaxin Wu [Tue, 2 Jan 2018 05:30:15 +0000 (13:30 +0800)]
MdeModulePkg/IScsiDxe: Set ExitBootServiceEvent to NULL after close it.

v2:
* Refine the commit log.

There are two place to close the ISCSI ExitBootServiceEvent:
#1.IScsiOnExitBootService(), which is the callback function of
   ExitBootServiceEvent.
#2.IScsiCleanDriverData(), which will be invoked by ISCSI driver
   binding stop().

So, the ExitBootServiceEvent will be closed and freed when exit boot
server is triggered. But it may be closed and freed again in ISCSI driver
binding stop(), which will result in the issue recorded at
https://bugzilla.tianocore.org/show_bug.cgi?id=742.

This patch is to resolve the issue.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
3 years agoNetworkPkg/HttpDxe: Fix build warning error if CHAR8 is unsigned.
Jiaxin Wu [Tue, 2 Jan 2018 03:29:03 +0000 (11:29 +0800)]
NetworkPkg/HttpDxe: Fix build warning error if CHAR8 is unsigned.

This patch is to fix the compiler warning error: C4245. The issue will happen
if the below build option is enabled:
  *_*_*_CC_FLAGS = -J.

That's because the value of ('A' - 'a') is a negative value, which will
be converted to an unsigned type if CHAR8 is treated as unsigned:
  Src -= ('A' - 'a');

The above issue is also recorded at:
https://bugzilla.tianocore.org/show_bug.cgi?id=815.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
3 years agoMdeModulePkg: Freed packet buffer when error occurs to avoid memory leak.
Wang Fan [Mon, 8 Jan 2018 05:18:26 +0000 (13:18 +0800)]
MdeModulePkg: Freed packet buffer when error occurs to avoid memory leak.

* In function Mtftp4WrqSendBlock(), when packet is not needed, function
  returns EFI_ABORTED but not freed the packet buffer. It results some
  memory leak and this patch is to fix this issue.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
3 years agoMdeModulePkg: Fixed two issues when error occurs in Mtftp4Start.
Wang Fan [Mon, 8 Jan 2018 05:14:43 +0000 (13:14 +0800)]
MdeModulePkg: Fixed two issues when error occurs in Mtftp4Start.

* This function sets returned status as token status and signal token
  when error occurs, and it results token status not compliance with
  spec definition. This patch fixed this issue.
* This function restore Tpl twice when Mtftp4WrqStart() returns an
  error, this patch fixed this issue.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
3 years agoUefiCpuPkg/MpInitLib: fix wrong address set as Stack Guard for APs
Jian J Wang [Mon, 8 Jan 2018 05:30:38 +0000 (13:30 +0800)]
UefiCpuPkg/MpInitLib: fix wrong address set as Stack Guard for APs

The reason is that DXE part initialization will reuse the stack allocated
at PEI phase, if MP was initialized before. Some code added to check this
situation and use stack base address saved in HOB passed from PEI.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
3 years agoUefiCpuPkg/MpInitLib: fix incorrect stack top init for cpu0
Jian J Wang [Thu, 4 Jan 2018 02:57:26 +0000 (10:57 +0800)]
UefiCpuPkg/MpInitLib: fix incorrect stack top init for cpu0

As the name suggests, CpuMpData->CpuInfoInHob[0].ApTopOfStack must be init
to the top of stack. But the MpInitLibInitialize() passed the base address
of stack to InitializeApData(), which is not correct. Although this stack
is not used for BSP, it's should be fixed in case of misunderstanding and
future possible code changes.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
3 years agoBaseTools: Add back the cc71d8 version's fix
Yonghong Zhu [Thu, 4 Jan 2018 07:44:37 +0000 (15:44 +0800)]
BaseTools: Add back the cc71d8 version's fix

The version cc71d8's fix was washed out by structure pcd report patch.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoBaseTools: Not print SKUID info for PCD when it is only Single SKUID
Yonghong Zhu [Thu, 4 Jan 2018 07:15:19 +0000 (15:15 +0800)]
BaseTools: Not print SKUID info for PCD when it is only Single SKUID

when it is only single SKUID, we don't need to print the SKUID info for
every PCD since in the Global section there already have this info.
For DefaultStore, we use same rule.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoUefiCpuPkg/MpInitLib: Fix a bug that AP enters timer INT handler
Ruiyu Ni [Fri, 5 Jan 2018 09:08:13 +0000 (17:08 +0800)]
UefiCpuPkg/MpInitLib: Fix a bug that AP enters timer INT handler

When SourceLevelDebug is enabled, AP randomly executes the DXECORE
timer handler logic. The root cause is the interrupts are not
masked in AP wake up procedure.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jeff Fan <vanjeff_919@hotmail.com>
3 years agoMdePkg/PciExpressLib.h: Add missing include of PciExpress21.h
Ruiyu Ni [Mon, 8 Jan 2018 10:02:52 +0000 (18:02 +0800)]
MdePkg/PciExpressLib.h: Add missing include of PciExpress21.h

PCI_ECAM_ADDRESS() macro is defined in PciExpress21.h so
always include PciExpress21.h in the library header file.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoMdeModulePkg/DxeUdpIoLib: Did some code enhancement for UdpIoLib
Wang Fan [Mon, 8 Jan 2018 05:39:50 +0000 (13:39 +0800)]
MdeModulePkg/DxeUdpIoLib: Did some code enhancement for UdpIoLib

* Added some ASSERT descriptions for library APIs.
* Added "Optional" option for Context parameter in UdpIoCancelDgrams().
* Added function return status check for UdpIoFreeIo().

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
3 years agoShellPkg/UefiShellLevel2CommandsLib: add missing EFIAPI call conv spec
Laszlo Ersek [Sat, 6 Jan 2018 19:24:11 +0000 (20:24 +0100)]
ShellPkg/UefiShellLevel2CommandsLib: add missing EFIAPI call conv spec

UefiShellLevel2CommandsLib (somewhat questionably) calls the
BaseLib-internal function InternalCharToUpper().

This function is declared in "MdePkg/Library/BaseLib/BaseLibInternals.h",
which is not a public library class header. UefiShellLevel2CommandsLib
therefore duplicates the function declaration, but a mistake was made: the
EFIAPI calling convention is not spelled out on the duplicated
declaration. Therefore calls made from UefiShellLevel2CommandsLib will not
match the actual function definition in "MdePkg/Library/BaseLib/String.c",
when GCC/X64 toolchains are used.

One consequence of this is that cross-filesystem copies don't work in the
UEFI shell (see the StrniCmp() function in
"UefiShellLevel2CommandsLib.c"). From the original report:

> FS0:\efi\ubuntu\> cp grubx64.efi fs1:\
>
> cp: The source and destination are the same.

Copy the declaration from "BaseLibInternals.h" to
"UefiShellLevel2CommandsLib.c" verbatim.

Reported-by: Rebecca Cran <rebecca@bluestop.org>
Analyzed-by: Thomas Palmer <thomas.palmer@hpe.com>
Analyzed-by: Liming Gao <liming.gao@intel.com>
Ref: http://mid.mail-archive.com/47cd17d8-f022-6ca5-2f52-06a8250f8d14@cran.org.uk
Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Rebecca Cran <rebecca@bluestop.org>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Thomas Palmer <thomas.palmer@hpe.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Thomas Palmer <thomas.palmer@hpe.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
3 years agoMdeModulePkg/PciBus: Reserve Bus number for non-root and root HPBs
Ruiyu Ni [Thu, 4 Jan 2018 05:39:11 +0000 (13:39 +0800)]
MdeModulePkg/PciBus: Reserve Bus number for non-root and root HPBs

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=656

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
3 years agoMdeModulePkg/PciBusDxe: cope with HPCs that request no bus nr padding
Ruiyu Ni [Mon, 8 Jan 2018 07:51:00 +0000 (15:51 +0800)]
MdeModulePkg/PciBusDxe: cope with HPCs that request no bus nr padding

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
3 years agoBaseTools: Fix Sku inherit issue.
BobCF [Wed, 27 Dec 2017 06:03:34 +0000 (14:03 +0800)]
BaseTools: Fix Sku inherit issue.

The final Pcd value should only be override by its parents.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Feng Bob C <bob.c.feng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoBaseTools: Fix Pcd value override issue caused by SKU inherit
Feng, Bob C [Tue, 26 Dec 2017 10:20:17 +0000 (18:20 +0800)]
BaseTools: Fix Pcd value override issue caused by SKU inherit

Pcd default value in DEC should only be assigned once.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
3 years agoBaseTools: Fix an issue in HiiPcd generation
BobCF [Tue, 2 Jan 2018 00:58:33 +0000 (08:58 +0800)]
BaseTools: Fix an issue in HiiPcd generation

DynamicHiiPcd may be used by PEIM or DXE driver.
All used DynamicHiiPcd value should be collected and placed into
the default setting PCD PcdNvStoreDefaultValueBuffer.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
3 years agoEmbeddedPkg/FdtLib: Update FdtLib to v1.4.5
Pankaj Bansal [Fri, 5 Jan 2018 11:17:37 +0000 (16:47 +0530)]
EmbeddedPkg/FdtLib: Update FdtLib to v1.4.5

Update the FdtLib so that new APIs provided by FdtLib like
fdt_address_cells, fdt_size_cells etc. can be used.

Reference code:
https://git.kernel.org/pub/scm/utils/dtc/dtc.git/tree/libfdt?h=v1.4.5

Cc: Leif Lindholm <leif.lindholm@linaro.org>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Pankaj Bansal <pankaj.bansal@nxp.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
3 years agoIntelSiliconPkg IntelVTdDxe: Support early SetAttributes()
Star Zeng [Wed, 3 Jan 2018 07:08:18 +0000 (15:08 +0800)]
IntelSiliconPkg IntelVTdDxe: Support early SetAttributes()

Support early SetAttributes() before DMAR table is installed.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
3 years agoIntelSiliconPkg IntelVTdDxe: Use TPL to protect list/engine operation
Star Zeng [Thu, 4 Jan 2018 02:33:42 +0000 (10:33 +0800)]
IntelSiliconPkg IntelVTdDxe: Use TPL to protect list/engine operation

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
3 years agoIntelSiliconPkg IntelVTdDxe: Signal AcpiNotificationFunc() initially
Star Zeng [Wed, 3 Jan 2018 06:00:03 +0000 (14:00 +0800)]
IntelSiliconPkg IntelVTdDxe: Signal AcpiNotificationFunc() initially

Signal AcpiNotificationFunc() initially for the case that
DMAR table has been installed when creating event.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
3 years agoMdeModulePkg/DxeNetLib: Fix an error in packet length counting.
Wang Fan [Wed, 3 Jan 2018 02:24:53 +0000 (10:24 +0800)]
MdeModulePkg/DxeNetLib: Fix an error in packet length counting.

* In old implementation, the operation len-- assumes AsciiSPrint()
  has counted NULL terminator, and it's not correct. This patch is
  to fix this issue.

Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
3 years agoMdeModulePkg/DxeNetLib: Add parameter check and ASSERT handling.
Wang Fan [Wed, 3 Jan 2018 02:18:29 +0000 (10:18 +0800)]
MdeModulePkg/DxeNetLib: Add parameter check and ASSERT handling.

* Library API should check the input parameters before use, or
  ASSERT to tell it has to meet some requirements. But in DxeNetLib,
  not all functions follows this rule.
* ASSERT shouldn't be used as error handling, add some handling code
  for errors.
* Add some ASSERT commence in function notes.

Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
3 years agoMdeModulePkg/DxeNetLib: Fix a potential issue in macro definition.
Wang Fan [Tue, 2 Jan 2018 02:56:44 +0000 (10:56 +0800)]
MdeModulePkg/DxeNetLib: Fix a potential issue in macro definition.

The NIC_ITEM_CONFIG_SIZE macro in DxeNetLib is defined as:
sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE) *
MAX_IP4_CONFIG_IN_VARIABLE. This macro should be surrounded
with parenthesis to avoid being incorrectly used.

Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
3 years agoNetworkPkg: Update PXE driver to check for NULL pointer before use it.
Fu Siyuan [Tue, 2 Jan 2018 05:25:59 +0000 (13:25 +0800)]
NetworkPkg: Update PXE driver to check for NULL pointer before use it.

This patch is to fix the issue that dereferencing of "This" (EFI_LOAD_FILE_PROTOCOL)
in EfiPxeLoadFile() is happening before the NULL check.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Sriram Subramanian <sriram-s@hpe.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
3 years agoNetworkPkg: Add assert for buffer pointer from DHCP driver.
Fu Siyuan [Tue, 2 Jan 2018 05:18:17 +0000 (13:18 +0800)]
NetworkPkg: Add assert for buffer pointer from DHCP driver.

The PxeBcDhcp4CallBack() is provided for DHCP driver to invoke packet check
during DHCP process, the DHCP driver should make sure Packet and NewPacket
has meaningful value. This patch adds assert for this.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Sriram Subramanian <sriram-s@hpe.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
3 years agoNetworkPkg: Fix memory leak problem in PXE driver.
Fu Siyuan [Tue, 2 Jan 2018 03:52:40 +0000 (11:52 +0800)]
NetworkPkg: Fix memory leak problem in PXE driver.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Sriram Subramanian <sriram-s@hpe.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
3 years agoNetworkPkg: Check allocated buffer pointer before use.
Fu Siyuan [Tue, 2 Jan 2018 03:44:21 +0000 (11:44 +0800)]
NetworkPkg: Check allocated buffer pointer before use.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Sriram Subramanian <sriram-s@hpe.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
3 years agoNetworkPkg: Abort the PXE process if DHCP has been started by other instance.
Fu Siyuan [Tue, 2 Jan 2018 03:41:24 +0000 (11:41 +0800)]
NetworkPkg: Abort the PXE process if DHCP has been started by other instance.

PXE need to use extended DHCP options and check received offers in callback
function, so there is no need to continue the PXE process if DHCP driver has
been started by other instance but not PXE driver itself.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Sriram Subramanian <sriram-s@hpe.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
3 years agoBaseTools: Fix compile error on VS2010
Yonghong Zhu [Wed, 3 Jan 2018 04:54:46 +0000 (12:54 +0800)]
BaseTools: Fix compile error on VS2010

VS2010 also defined RSIZE_MAX, so we undef it first.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoBaseTools/DevicePath: fix GCC build error in print_mem(), and clean it up
Laszlo Ersek [Tue, 2 Jan 2018 17:16:36 +0000 (01:16 +0800)]
BaseTools/DevicePath: fix GCC build error in print_mem(), and clean it up

Currently "BaseTools/Source/C/DevicePath/DevicePath.c" fails to build with
GCC48:

> DevicePath.c: In function 'print_mem':
> DevicePath.c:109:5: error: 'for' loop initial declarations are only
> allowed in C99 mode
>      for (size_t i=0; i<n; i++) {
>      ^
> DevicePath.c:109:5: note: use option -std=c99 or -std=gnu99 to compile
> your code

In addition, the print_mem() function does not conform to the edk2 coding
style:

- we use CamelCase and no underscores in identifiers,
- the types and type qualifiers should follow the edk2 style,
- initialization as part of definition is forbidden for local variables.

Clean these up.

While updating the print_mem()/PrintMem() call sites, also remove the
superfluous parentheses around the second argument.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Fixes: 7dbc50bd244d95fdc1741b9cfc561f0bfd724de1
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
3 years agoBaseTools CommonLib: Fix printf %llx issue on UINT64
Liming Gao [Tue, 2 Jan 2018 12:41:43 +0000 (20:41 +0800)]
BaseTools CommonLib: Fix printf %llx issue on UINT64

UINT64 is defined as the different type for the different ARCHs. To
let it work for all archs and compilers, add (unsigned long long) for
the input value together with %llx.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
3 years agoMdeModulePkg: Add error handling when IP address is Class E
Wang Fan [Wed, 3 Jan 2018 02:39:46 +0000 (10:39 +0800)]
MdeModulePkg: Add error handling when IP address is Class E

The Dhcp4.TransmitReceive() API should be able to use at any time according
to UEFI spec. While in classless addressing network, the netmask must be
explicitly provided together with the station address.
But if the DHCP instance haven't be configured with a valid netmask, we need
compute it according to the classful addressing rule. In such case, if the
user configures with class E IP address, ASSERT will happen, we need to handle
this case and return error status code.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
3 years agoBaseTools: Fix the regression bug of a74398 for SubFv Image
Yonghong Zhu [Tue, 2 Jan 2018 10:19:36 +0000 (18:19 +0800)]
BaseTools: Fix the regression bug of a74398 for SubFv Image

in version a74398 we use guid value and Fv name as ffs dir for FILE
statement, this patch apply this rule on subFv image.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoBaseTools: resolve initialization order errors in VfrFormPkg.h
zenith432 [Wed, 6 Dec 2017 16:46:37 +0000 (16:46 +0000)]
BaseTools: resolve initialization order errors in VfrFormPkg.h

clang generates many warnings
warning: field 'XXX' is uninitialized when used here [-Wuninitialized]
for VfrFormPkg.h.

VfrFormPkg.h defines many classes derived from CIfrObj (along with other
base classes.)
Each of these derived classes defines a non-static member field that serves
as a duplicate pointer to an original pointer defined in the CIfrObj base
class, but cast to a different pointer type.
The derived class constructor passes the duplicate pointer to base class
constructors:
1) Once passes the address of the duplicate pointer to the CIfrObj
   constructor to have it initialized.
2) Then passes the duplicate pointer to one or more subsequent base class
   constructors to be used.
Both 1) and 2) constitute undefined behavior in C++.  C++ prescribes that
base classes are initialized before non-static members when initializing a
derived class.  So when base class constructors are executing, it is not
permitted to assume any non-static members of the derived class exist (even
to the stage of having their storage allocated.)

clang does not issue warnings for 1), but issues warnings -Wuninitialized
for 2).

This coding methodology is resolved as follows:
a) The CIfrObj object accessor method for retrieving the original pointer
   is revised to a template member function that returns the original
   pointer cast to a desired target type.
b) The call to CIfrObj constructor is no longer used to initialize the
   duplicate pointer in the derived class.
c) Any subsequent calls to a base class constructor that need to use the
   pointer, retrieve it from the CIfrObj base class using the template
   accessor method.
d) If the derived class makes no further use of the pointer, then the
   duplicate pointer defined in it is eliminated.
e) If the derived class needs the duplicate pointer for other use, the
   duplicate pointer remains in the derived class and is initialized in
   proper order from the original pointer in CIfrObj.
f) Existing source code that previously used the CIfrObj pointer accessor
   method is revised to use the template method.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zenith432 <zenith432@users.sourceforge.net>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoBaseTools: silence parentheses-equality warning
zenith432 [Sat, 9 Dec 2017 10:41:48 +0000 (10:41 +0000)]
BaseTools: silence parentheses-equality warning

Some code generated by antlr causes clang to emit warning
warning: equality comparison with extraneous parentheses
  [-Wparentheses-equality]
The warning is suppressed specifically for clang without affecting other
compilers.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zenith432 <zenith432@users.sourceforge.net>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoBaseTools: eliminate unused expression result
zenith432 [Sat, 9 Dec 2017 10:14:41 +0000 (10:14 +0000)]
BaseTools: eliminate unused expression result

Remove some code generated by antlr that causes clang to emit warning
warning: expression result unused [-Wunused-value]

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zenith432 <zenith432@users.sourceforge.net>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoBaseTools: correct mal-typed CVfrDLGLexer::errstd
zenith432 [Sat, 9 Dec 2017 09:38:51 +0000 (09:38 +0000)]
BaseTools: correct mal-typed CVfrDLGLexer::errstd

The member function CVfrDLGLexer::errstd is intended as an override virtual
function of DLGLexerBase::errstd, but due to mismatched prototype, it
didn't override, and never got called.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zenith432 <zenith432@users.sourceforge.net>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoMdeModulePkg/DxePrintLibPrint2Protocol: Fix incomplete print output
Wang, Jian J [Tue, 2 Jan 2018 08:20:21 +0000 (16:20 +0800)]
MdeModulePkg/DxePrintLibPrint2Protocol: Fix incomplete print output

This is caused by a previous patch which tried to fix string over-read.
It's found that that patch for PrintLib in MdePkg will cause premature
terminating of loop used to traversing format string and cause incomplete
string output. Because this library uses similar code to do the same
job, it has the same issue too. So the fix is also the same.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
3 years agoMdePkg/BasePrintLib: Fix incomplete print output
Wang, Jian J [Tue, 2 Jan 2018 08:20:20 +0000 (16:20 +0800)]
MdePkg/BasePrintLib: Fix incomplete print output

This is caused by previous patch which tried to fix string over-read,
which breaks UEFI menu rendering: the following

/------------------------------------------------------------------------------\
|                               Device Manager                                 |
\------------------------------------------------------------------------------/

is rendered as

/\
|                               Device Manager                                 |
\/.0                                                 2.00 GHz

(the spurious digits are SMBIOS data from the home screen)

The problem appears to be that the CHAR16 value of BOXDRAW_HORIZONTAL
equals 0x2500, which means that testing ArgumentString[] != '\0'
(which tests the low byte only) will yield FALSE and terminate the
loop prematurely.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoMdeModulePkg VarCheckPcd: Make sure the bin at required alignment
Star Zeng [Fri, 29 Dec 2017 10:12:36 +0000 (18:12 +0800)]
MdeModulePkg VarCheckPcd: Make sure the bin at required alignment

According to UEFI/PI spec, the AllocateXXXPool() interfaces should
return eight-byte aligned buffer that satisfies the required
HEADER_ALIGNMENT which is 4.

This patch adds ASSERT to make sure the bin at required alignment,
that can help catch the issue earlier about incorrect aligned buffer
returned from AllocateXXXPool().

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
3 years agoMdeModulePkg VarCheckHii: Make sure the bin at required alignment
Star Zeng [Fri, 29 Dec 2017 10:10:36 +0000 (18:10 +0800)]
MdeModulePkg VarCheckHii: Make sure the bin at required alignment

According to UEFI/PI spec, the AllocateXXXPool() interfaces should
return eight-byte aligned buffer that satisfies the required
HEADER_ALIGNMENT which is 4.

This patch adds ASSERT to make sure the bin at required alignment,
that can help catch the issue earlier about incorrect aligned buffer
returned from AllocateXXXPool().

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
3 years agoUefiCpuPkg CpuExceptionHandlerLib: Enhance DumpModuleImageInfo()
Star Zeng [Wed, 27 Dec 2017 09:24:04 +0000 (17:24 +0800)]
UefiCpuPkg CpuExceptionHandlerLib: Enhance DumpModuleImageInfo()

Enhance DumpModuleImageInfo() for page fault with I/D set.

If it is page fault with I/D set, the (E/R)IP in SystemContext
could not be used for DumpModuleImageInfo(), instead of, the next
IP of the IP triggering this page fault could be found from stack
by (E/R)SP in SystemContext.

IA32 SDM:
— I/D flag (bit 4).
This flag is 1 if the access causing the page-fault exception was
an instruction fetch. This flag describes the access causing the
page-fault exception, not the access rights specified by paging.

The idea comes from SmiPFHandler () in
UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c and
UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
3 years agoBaseTools: Add DevicePath support for PCD values
Yonghong Zhu [Wed, 27 Dec 2017 06:12:29 +0000 (14:12 +0800)]
BaseTools: Add DevicePath support for PCD values

Use C code parse device path to output hex string, and Python
run command when PCD Value need device path parse.

https://bugzilla.tianocore.org/show_bug.cgi?id=541

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoBaseTools: Fix the bug for QuarkPlatformPkg build failure
Zhu, Yonghong [Fri, 29 Dec 2017 00:28:17 +0000 (08:28 +0800)]
BaseTools: Fix the bug for QuarkPlatformPkg build failure

The issue is that the string 'LPC' starts with the 'L' character and
this is being confused with L" or L' for a Unicode string or Unicode
character.

Fixes:https://bugzilla.tianocore.org/show_bug.cgi?id=831
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoBaseTools: Fix a bug for different FV use same FILE statement Guid
Yonghong Zhu [Thu, 28 Dec 2017 17:40:54 +0000 (01:40 +0800)]
BaseTools: Fix a bug for different FV use same FILE statement Guid

We meet a case that different FV use same FILE statement Guid, but the
FILE content is different. current we use the Guid value as Ffs file
dir which cause the ffs file will be override. This patch use Guid
value and Fv name as ffs dir for FILE statement.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoMdeModulePkg/DxePrintLibPrint2Protocol: fix GCC5 build break
Wang, Jian J [Fri, 29 Dec 2017 01:40:28 +0000 (09:40 +0800)]
MdeModulePkg/DxePrintLibPrint2Protocol: fix GCC5 build break

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoUefiCpuPkg: Fix comment typo for MtrrLibApplyFixedMtrrs function
Song, BinX [Wed, 27 Dec 2017 07:53:44 +0000 (15:53 +0800)]
UefiCpuPkg: Fix comment typo for MtrrLibApplyFixedMtrrs function

Fix comment typo for MtrrLibApplyFixedMtrrs function

Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bell Song <binx.song@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
3 years agoMdeModulePkg PeiCore: Update debug message to print FV handle correctly
Liming Gao [Thu, 28 Dec 2017 06:34:14 +0000 (14:34 +0800)]
MdeModulePkg PeiCore: Update debug message to print FV handle correctly

BfvHeader->FvLength is UINT64. Now, it prints with %x. It will cause the
late FvHandle to be as zero. So, its type is converted to UINT32.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
3 years agoMdeModulePkg HiiDataBase: Fix the potential NULL pointer access
Liming Gao [Thu, 28 Dec 2017 02:55:04 +0000 (10:55 +0800)]
MdeModulePkg HiiDataBase: Fix the potential NULL pointer access

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
3 years agoSourceLevelDebugPkg: Convert source file to DOS format
Liming Gao [Wed, 27 Dec 2017 15:23:19 +0000 (23:23 +0800)]
SourceLevelDebugPkg: Convert source file to DOS format

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Wu Hao A <hao.a.wu@intel.com>
Reviewed-by: Wu Hao A <hao.a.wu@intel.com>
3 years agoNetworkPkg: Convert source file to DOS format
Liming Gao [Wed, 27 Dec 2017 15:23:18 +0000 (23:23 +0800)]
NetworkPkg: Convert source file to DOS format

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
3 years agoIntelFspWrapperPkg: Convert INF file to dos format
Liming Gao [Wed, 27 Dec 2017 15:23:17 +0000 (23:23 +0800)]
IntelFspWrapperPkg: Convert INF file to dos format

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
3 years agoSecurityPkg: Convert source file to DOS format
Liming Gao [Thu, 28 Dec 2017 01:09:47 +0000 (09:09 +0800)]
SecurityPkg: Convert source file to DOS format

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Qin Long <qin.long@intel.com>
Reviewed-by: Chao Zhang <chao.b.zhang@intel.com>
3 years agoMdeModulePkg/DxePrintLibPrint2Protocol: Fix error in Precision position calculation
Jian J Wang [Thu, 28 Dec 2017 02:22:39 +0000 (10:22 +0800)]
MdeModulePkg/DxePrintLibPrint2Protocol: Fix error in Precision position calculation

Due to a potential hole in the stop condition of loop, the two continuous
access to ArgumentString (index, index+1) inside the loop might cause the
string ending character ('\0') and the byte after it to be read.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
3 years agoMdePkg/BasePrintLib: Fix error in Precision position calculation
Jian J Wang [Mon, 25 Dec 2017 02:07:39 +0000 (10:07 +0800)]
MdePkg/BasePrintLib: Fix error in Precision position calculation

Due to a potential hole in the stop condition of loop, the two continuous
access to ArgumentString (index, index+1) inside the loop might cause the
string ending character ('\0') and the byte after it to be read.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoCryptoPkg/OpensslLib AARCH64: disable rather than demote format warning
Ard Biesheuvel [Wed, 27 Dec 2017 09:16:47 +0000 (09:16 +0000)]
CryptoPkg/OpensslLib AARCH64: disable rather than demote format warning

We recently added -Wno-error=format to the OpenSslLib build script to
work around an issue in the upstream OpenSSL code. This does not inhibit
the warning, but prevents it from breaking the build by not treating it
as a fatal error.

Unfortunately, this interacts poorly with the -Wno-unused-const-variable
option that we added to GCC49 and later. Those versions of GCC ignore
-Wno-xxxx options that they don't understand, unless warnings are emitted
for another reason, in which case the warning is emitted after all, and
in our case, this breaks the build when the non-fatal format warning is
emitted.

CryptoPkg/Library/OpensslLib/openssl/crypto/asn1/x_int64.c: In function 'uint64_print':
CryptoPkg/Library/OpensslLib/openssl/crypto/asn1/x_int64.c:105:32: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'int64_t {aka long long int}' [-Wformat=]
         return BIO_printf(out, "%"BIO_PRI64"d\n", **(int64_t **)pval);
                                ^
CryptoPkg/Library/OpensslLib/openssl/crypto/asn1/x_int64.c:106:28: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'uint64_t {aka long long unsigned int}' [-Wformat=]
     return BIO_printf(out, "%"BIO_PRI64"u\n", **(uint64_t **)pval);
                            ^
CryptoPkg/Library/OpensslLib/openssl/crypto/asn1/x_int64.c: At top level:
cc1: error: unrecognized command line option '-Wno-unused-const-variable' [-Werror]
cc1: all warnings being treated as errors

So replace -Wno-error=format with -Wno-format to suppress the warning
entirely.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Long Qin <qin.long@intel.com>
3 years agoUefiCpuPkg: Rollback field name changes
Jian J Wang [Wed, 27 Dec 2017 09:06:18 +0000 (17:06 +0800)]
UefiCpuPkg: Rollback field name changes

Roll back commit 56649f43013703e95f54c293d708152b765cc49b.
The original names follows the spec definition.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoMdePkg/BaseLib.h: Rollback field name changes
Jian J Wang [Wed, 27 Dec 2017 09:00:45 +0000 (17:00 +0800)]
MdePkg/BaseLib.h: Rollback field name changes

Rollback commit 47595ac0b96aaa18246ac1be4a238893dd0aa0fe
The original names follows the spec definition.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoMdePkg: Update PI spec version to 1.6 in MdePkg.dec
Liming Gao [Wed, 27 Dec 2017 08:56:00 +0000 (16:56 +0800)]
MdePkg: Update PI spec version to 1.6 in MdePkg.dec

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
3 years agoMdeModulePkg HiiDataBase: Fix the potential NULL pointer reference
Liming Gao [Wed, 27 Dec 2017 02:31:19 +0000 (10:31 +0800)]
MdeModulePkg HiiDataBase: Fix the potential NULL pointer reference

This change is the additional fix of commit
14b351e2ed8586f144dd3cd2e0a25082c1a32837.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
3 years agoMdeModulePkg Variable: Use boolean type value instead of expression
Liming Gao [Wed, 27 Dec 2017 03:39:21 +0000 (11:39 +0800)]
MdeModulePkg Variable: Use boolean type value instead of expression

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
3 years agoBaseTools: Remove 'COMMON' in PCD SkuInfoList
BobCF [Wed, 27 Dec 2017 06:03:35 +0000 (14:03 +0800)]
BaseTools: Remove 'COMMON' in PCD SkuInfoList

'COMMON' is an alias of 'DEFAULT' for internal code,
it should be removed before generating Pcd DataBase.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
3 years agoCryptoPkg/OpensslLib AARCH64: suppress format string warning
Ard Biesheuvel [Wed, 27 Dec 2017 07:52:39 +0000 (07:52 +0000)]
CryptoPkg/OpensslLib AARCH64: suppress format string warning

On GCC Build: openssl-1.1.0g introduced one additional build warning:
 ...\openssl\crypto\asn1\x_int64.c:105:32: error: format '%ld' expects
     argument of type 'long int', but argument 3 has type 'int64_t
     {aka long long int}' [-Werror=format=]
 return BIO_printf(out, "%"BIO_PRI64"d\n", **(int64_t **)pval);
                             ^
Add "-Wno-error=format" to GCC build flags to suppress this warning,
since we have no real printf usage in BaseCryptLib, and BIO_printf()
was already wrapped as a dummy implementation in CryptoPkg.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Long Qin <qin.long@intel.com>
3 years agoNetworkPkg/IScsiDxe: Correct the DnsMode value according the target info.
Jiaxin Wu [Fri, 22 Dec 2017 02:15:36 +0000 (10:15 +0800)]
NetworkPkg/IScsiDxe: Correct the DnsMode value according the target info.

When the platform gets the target info from DHCP (option 17) and the ISCSI
server is expressed as IP address, the value of DnsMode should be false,
otherwise, the failure will happen in certain case.

please refer to https://bugzilla.tianocore.org/show_bug.chi?id=823 for
the detailed steps.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Karunakar P <karunakarp@amiindia.co.in>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Tested-by: Karunakar P <karunakarp@amiindia.co.in>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
3 years agoNetworkPkg/HttpDxe: Remove the unnecessary ASSERT.
Jiaxin Wu [Tue, 26 Dec 2017 05:30:25 +0000 (13:30 +0800)]
NetworkPkg/HttpDxe: Remove the unnecessary ASSERT.

Cc: Wang Fan <fan.wang@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
3 years agoNetworkPkg/HttpDxe: Fix the memory leak issue in HttpRequest().
Jiaxin Wu [Tue, 26 Dec 2017 03:10:34 +0000 (11:10 +0800)]
NetworkPkg/HttpDxe: Fix the memory leak issue in HttpRequest().

Cc: Wang Fan <fan.wang@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
3 years agoMdeModulePkg/DxeHttpLib: Refine some coding style.
Jiaxin Wu [Tue, 26 Dec 2017 01:31:06 +0000 (09:31 +0800)]
MdeModulePkg/DxeHttpLib: Refine some coding style.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wang Fan <fan.wang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
3 years agoMdeModulePkg/DxeHttpLib: Correct some return Status.
Jiaxin Wu [Mon, 25 Dec 2017 08:57:28 +0000 (16:57 +0800)]
MdeModulePkg/DxeHttpLib: Correct some return Status.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wang Fan <fan.wang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
3 years agoMdeModulePkg/DxeHttpLib: Check the input parameters for some APIs.
Jiaxin Wu [Mon, 25 Dec 2017 08:43:37 +0000 (16:43 +0800)]
MdeModulePkg/DxeHttpLib: Check the input parameters for some APIs.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wang Fan <fan.wang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com
3 years agoMdeModulePkg/DxeHttpLib: Avoid the potential memory leak when error happen.
Jiaxin Wu [Thu, 21 Dec 2017 06:36:12 +0000 (14:36 +0800)]
MdeModulePkg/DxeHttpLib: Avoid the potential memory leak when error happen.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wang Fan <fan.wang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
3 years agoMdeModulePkg/DxeHttpLib: Add boundary condition check.
Jiaxin Wu [Mon, 25 Dec 2017 08:17:34 +0000 (16:17 +0800)]
MdeModulePkg/DxeHttpLib: Add boundary condition check.

v2:
* Fix GCC the build error.

This patch is to add the boundary condition check to make sure
the accessed buffer is valid.

Cc: Gary Lin <glin@suse.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wang Fan <fan.wang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Tested-by: Gary Lin <glin@suse.com>
3 years agoNetworkPkg/TcpDxe: Check TCP payload for release version.
Jiaxin Wu [Fri, 22 Dec 2017 06:53:03 +0000 (14:53 +0800)]
NetworkPkg/TcpDxe: Check TCP payload for release version.

TCP payload check is implemented by TcpVerifySegment(), but all the function
calls of TcpVerifySegment() are placed in ASSERT(), which is only valid for
debug version:
  ASSERT (TcpVerifySegment (Nbuf) != 0);

This patch is to enable the check for release version.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wang Fan <fan.wang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
3 years agoUefiCpuPkg: Update AESNI support checking logic
Song, BinX [Mon, 25 Dec 2017 03:11:21 +0000 (11:11 +0800)]
UefiCpuPkg: Update AESNI support checking logic

With correct model CPU, current checking logic will
always execute AsmReadMsr64 operation and then check
ECX.AESNI[bit 25] = 1. Update checking logic to check
ECX.AESNI[bit 25] = 1 first and then do AsmReadMsr64
operation.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bell Song <binx.song@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
3 years agoUefiCpuPkg: Delete redundant PcdGetSize PcdCpuFeaturesSupport
Song, BinX [Thu, 21 Dec 2017 12:01:18 +0000 (20:01 +0800)]
UefiCpuPkg: Delete redundant PcdGetSize PcdCpuFeaturesSupport

When CpuCommonFeaturesLib use RegisterCpuFeaturesLib to register
CPU features, the CpuFeaturesData->BitMaskSize has already been
initialized. So delete redundant PcdGetSize PcdCpuFeaturesSupport
in CpuInitDataInitialize.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bell Song <binx.song@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
3 years agoRevert "UefiCpuPkg: Check invalid RegisterCpuFeature parameter"
Eric Dong [Thu, 21 Dec 2017 11:46:51 +0000 (19:46 +0800)]
Revert "UefiCpuPkg: Check invalid RegisterCpuFeature parameter"

This reverts commit 5c59537c1092a1372913274636a8d766fdd97e61.

Current code already has function IsCpuFeatureSupported to do
the feature validation, not need this check logic anymore.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bell Song <binx.song@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>