audk/MdeModulePkg/Core/Dxe
Hao Wu d9be0f66ff MdeModulePkg/Tpl: Fix negative value left shift
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=695

Within function CoreRestoreTpl(), left shift a negative value -2 is used
in:
"while (((-2 << NewTpl) & gEventPending) != 0) {"

which involves undefined behavior.

According to the C11 spec, Section 6.5.7:
> 4 The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated
>   bits are filled with zeros. If E1 has an unsigned type, the value
>   of the result is E1 * 2^E2 , reduced modulo one more than the
>   maximum value representable in the result type. If E1 has a signed
>   type and nonnegative value, and E1 * 2^E2 is representable in the
>   result type, then that is the resulting value; otherwise, the
>   behavior is undefined.

This commit refines the code logic to avoid left shifting the negative
value.

Cc: Steven Shi <steven.shi@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2017-09-29 16:14:17 +08:00
..
Dispatcher MdeModulePkg DxeCore: Fix issue to print GUID value %g without pointer 2017-04-14 10:58:31 +08:00
DxeMain MdeModulePkg/DxeCore: Add UEFI image protection. 2017-02-22 14:07:04 +08:00
Event MdeModulePkg/Tpl: Fix negative value left shift 2017-09-29 16:14:17 +08:00
FwVol MdeModulePkg Core: Support FFS_ATTRIB_DATA_ALIGNMENT_2 2017-09-26 18:01:03 +08:00
FwVolBlock MdeModulePkg DxeCore: Show error message on unaligned FvImage issue 2016-11-17 09:27:11 +08:00
Gcd MdeModulePkg/Core: Fix out-of-sync issue in GCD 2017-09-21 09:38:27 +08:00
Hand MdeModulePkg/DxeCore: Add check to ensure no possible NULL ptr deref 2017-09-26 09:38:46 +08:00
Image MdeModulePkg DxeCore: Fix double free pages on LoadImage failure path 2017-08-14 16:45:59 +08:00
Library Update the copyright notice format 2010-04-24 09:49:11 +00:00
Mem MdeModulePkg DxeCore: Enhance "ConvertPages: Incompatible memory types" 2017-08-14 16:46:03 +08:00
Misc MdeModulePkg: Fix use-after-free error in InstallConfigurationTable() 2017-06-20 16:55:10 +08:00
SectionExtraction MdeModulePkg DxeCore: Only free ScratchBuffer when it is not NULL 2017-06-26 13:17:16 +08:00
DxeCore.uni MdeModulePkg: Convert all .uni files to utf-8 2015-12-15 04:56:23 +00:00
DxeCoreExtra.uni MdeModulePkg: Convert all .uni files to utf-8 2015-12-15 04:56:23 +00:00
DxeMain.h MdeModulePkg/DxeCore: switch to MdePkg allocation granularity macros 2017-03-06 11:29:20 +01:00
DxeMain.inf MdeModulePkg/DxeCore: implement memory protection policy 2017-02-28 15:01:10 +00:00