Re: [PATCH 1/1] x86: In x86-64 barrier_nospec can always be lfence

"H. Peter Anvin" <[email protected]> Sun, 09 Feb 2025 18:15:35 -0800
Newsgroups com.openwall.lists.kernel-hardening,org.kernel.vger.linux-arch,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On February 9, 2025 5:09:51 PM PST, Rik van Riel <riel@surriel=2Ecom> wrote=
:
>On Sun, 2025-02-09 at 13:57 -0800, Linus Torvalds wrote:
>>=20
>> So on x86, both read and write barriers are complete no-ops, because
>> all reads are ordered, and all writes are ordered=2E
>
>Given that this thread started with a reference
>to rdtsc, it may be worth keeping in mind that
>rdtsc reads themselves do not always appear to
>be ordered=2E
>
>Paul and I spotted some occasionaly "backwards
>TSC values" from the CSD lock instrumentation code,=C2=A0
>which went away when using ordered TSC reads:
>
>https://lkml=2Eiu=2Eedu/hypermail/linux/kernel/2410=2E1/03202=2Ehtml
>
>I guess maybe a TSC read does not follow all the same
>rules as a memory read, sometimes?
>

It probably doesn't, at least on uarches=2E