On 05/22/20 16:14, Laszlo Ersek wrote: > INT64 Displacement;
> Displacement *= (1 << Ext->Sib.Scale); > (10c) Multiplying a negative INT64 by 1, 2, 4, or 8 is well-defined > (assuming again that the initial Displacement value is small enough, > which depends on the original instruction). > > If we wanted to be super-safe, we could replace this open-coded > INT64 multiplication with a call to SafeInt64Mult(), from > <Library/SafeIntLib.h>, and hang here, if the call fails. > > Up to you. Side comment: normally, even if we were 100% sure the result would be in range, we shouldn't use the "*" operator for INT64 multiplication -- because of intrinsics. BaseLib offers MultS64x64() for that problem. But, this is X64-only code. So using "*" for INT64 multiplication should be fine on all toolchains, regarded purely from an intrinsics perspective. So it's a choice between "*" (if we trust the instruction being decoded to be sane) or SafeInt64Mult() (if we don't). MultS64x64() sits in the middle, and doesn't buy us anything here. Thanks Laszlo -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#60146): https://edk2.groups.io/g/devel/message/60146 Mute This Topic: https://groups.io/mt/74336571/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-