google / safeside

Understand and mitigate software-observable side-channels
BSD 3-Clause "New" or "Revised" License
494 stars 54 forks source link

Refactor architecture-specific code #119

Closed mmdriley closed 4 years ago

mmdriley commented 4 years ago

Move comments about implementing memory and speculation barriers into its own Markdown file and expand it a bit.

Put code specific to each architecture in its own header file.

Use mfence; lfence for a total barrier on x86 instead of cpuid. This is partly for the reasons in docs/fencing.md but also so we have one canonical instruction sequence everywhere we're using it.

Rename CLFlush to FlushDataCacheLine to avoid the x86-specific name. Add FlushFromDataCacheLineNoBarrier for places where we flush in a loop, since we can just have one serialization barrier at the end.