SpectrePoC icon indicating copy to clipboard operation
SpectrePoC copied to clipboard

Error comment on bit twiddling trick

Open Kingfish404 opened this issue 2 years ago • 1 comments

https://github.com/crozone/SpectrePoC/blob/2a01f8647c2966991dd50ef8b96ed25b85c25297/spectre.c#L193

should be

/* Set x=0xFFFFFFFFFFFFFFFF if x=0xFFFFFFFFFFFF0000, else x=0 */
// or
/* Set x=-1 if j%6=0, else x=0 */ 

It's clearly that the 2's complement of -1 is 0xFFFFFFFFFFFF0000 and there is no logic for j&6.

This Error has been copied or spread for so many repos.

Kingfish404 avatar Jan 28 '23 15:01 Kingfish404

Agreed, comment should be /* Set x=0xFFFFFFFFFFFFFFFF if x=0xFFFFFFFFFFFF0000, else x=0 */, although maybe something like:

/* Bitwise OR the upper bytes of x over the lower two bytes of x, such that if x was 0xFFFFFFFFFFFF0000, it becomes 0xFFFFFFFFFFFFFFFF. Otherwise, if x was 0, it remains as 0 */

crozone avatar Feb 01 '23 05:02 crozone