BlackToppStudios / Mezz_StaticFoundation

All of the parts of the Mezzanine that need to be handled prior to the real build, like compiler options and platform detection.
GNU General Public License v3.0
2 stars 0 forks source link

Add Spectre code correction suppression. #44

Open Sqeaky opened 6 years ago

Sqeaky commented 6 years ago

Spectre is new class of security vulnerability that can cause data to be read from Cache when it shouldn't be able to be read. Most compilers are automatically correcting code vulnerable to this. These corrections do slow down the code with the fixes.

Video games are generally not privacy sensitive, but some may deal with credit card numbers, passwords and potentially other unforeseen sensitive information. It seems that using these mitigations by default is a good idea. Video games also tend to have performance sensitive loops or other things that might require Spectre mitigation on the hot path.

Some compilers produce warnings when inserting these mitigations. Currently the game developer can suppress Spectre warnings in non-performance critical code with something like the following:

SAVE_WARNING_STATE
SUPPRESS_VC_WARNING(5045)
// Code that needs spectre fixes
RESTORE_WARNING_STATE

The game developer also needs a macro that actually suppresses Spectre mitigations. On platforms and compilers this macro should be empty so the code the game developer's code does need to change and automatically inserts spectre mitigation where required.

https://blogs.msdn.microsoft.com/vcblog/2018/01/15/spectre-mitigations-in-msvc/