Re: [edk2] [PATCH 3/6] MdeModulePkg/Tpl: Fix negative value left shift

2017-09-20 Thread Wu, Hao A
ong, Eric; Zeng, Star > Subject: RE: [edk2] [PATCH 3/6] MdeModulePkg/Tpl: Fix negative value left > shift > > There is a case must be considered that gEventPending is 0, HighBitSet64 will > return -1, then the code will be wrong. > The code maybe: > > while (gEventPe

Re: [edk2] [PATCH 3/6] MdeModulePkg/Tpl: Fix negative value left shift

2017-09-20 Thread Zeng, Star
l.com>; Zeng, Star <star.z...@intel.com> Subject: Re: [edk2] [PATCH 3/6] MdeModulePkg/Tpl: Fix negative value left shift On 19/09/2017 13:43, Hao Wu wrote: > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=695 > > Within function CoreRestoreTpl(), left shift a negative value -2 i

Re: [edk2] [PATCH 3/6] MdeModulePkg/Tpl: Fix negative value left shift

2017-09-19 Thread Paolo Bonzini
On 19/09/2017 13:43, Hao Wu wrote: > 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

[edk2] [PATCH 3/6] MdeModulePkg/Tpl: Fix negative value left shift

2017-09-19 Thread Hao Wu
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