[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f37ecf01-3167-f12e-d9d0-b55c44b80c29@citrix.com>
Date: Thu, 4 Feb 2021 23:37:01 +0000
From: Andrew Cooper <andrew.cooper3@...rix.com>
To: Dave Hansen <dave.hansen@...ux.intel.com>,
<linux-kernel@...r.kernel.org>
CC: <jan.kiszka@...mens.com>, <x86@...nel.org>, <peterz@...radead.org>
Subject: Re: [RFC][PATCH 2/2] x86: add extra serialization for non-serializing
MSRs
On 05/03/2020 17:47, Dave Hansen wrote:
> Jan Kiszka reported that the x2apic_wrmsr_fence() function uses a
> plain "mfence" while the Intel SDM (10.12.3 MSR Access in x2APIC
> Mode) calls for "mfence;lfence".
>
> Short summary: we have special MSRs that have weaker ordering
> than all the rest. Add fencing consistent with current SDM
> recommendatrions.
>
> This is not known to cause any issues in practice, only in
> theory.
So, I accept that Intel have their own reasons for what is written in
the SDM, but "not ordered with stores" is at best misleading.
The x2APIC (and other) MSRs, aren't serialising. That's fine, as is the
fact that the WRMSR to trigger them doesn't have memory operands, and is
therefore not explicitly ordered with other loads and stores.
Consider:
xor %edi, %edi
movb (%rdi), %dl
wrmsr
It is fine for a non-serialising wrmsr here to execute speculative in
terms of internal calculations, but nothing it does can escape the local
core until the movb has fully retired, and is therefore globally visible.
Otherwise, I can send IPIs from non-architectural paths (in this case,
behind a page fault), and causality is broken.
IPIs are (at minimum) a write-like-thing leaving the core, even if they
don't interact with the regular memory path, and their effects cannot
become visible until the effects of older instructions are visible.
What the SDM is trying to say is that this potentially matters for
writes queued in the WC buffers.
If some code is using WC memory, and wants to send an IPI, and wants to
have the remote IPI handler read said data, then yes - there is a
problem - but the problem is the lack of SFENCE required to make the WC
buffer visible in the first place.
WC code is already responsible for its own memory ordering, and the
x2APIC IPIs can't execute early even in the absence of architectural
ordering guarantees.
~Andrew
Powered by blists - more mailing lists