Messages in this thread | | | Date | Tue, 20 Jun 2023 09:58:30 +0200 | From | Peter Zijlstra <> | Subject | Re: [PATCH v11 18/20] x86: Handle TDX erratum to reset TDX private memory during kexec() and reboot |
| |
On Mon, Jun 19, 2023 at 06:06:30PM -0700, Dave Hansen wrote: > On 6/19/23 17:56, Huang, Kai wrote: > > Any comments to below? > > Nothing that I haven't already said in this thread: > > > Just use a normal old atomic_t or set_bit()/test_bit(). They have > > built-in memory barriers are are less likely to get botched. > > I kinda made a point of literally suggesting "atomic_t or > set_bit()/test_bit()". I even told you why: "built-in memory barriers". > > Guess what READ/WRITE_ONCE() *don't* have. Memory barriers.
x86 has built-in memory barriers for being TSO :-) Specifically all barriers provided by spinlock (acquire/release) are no-ops on x86.
(strictly speaking locks imply stronger order than they have to because TSO atomic ops imply stronger ordering than required)
There is one (and only the one) re-ordering possible on TSO and that is the store-buffer, later loads can fail to observe prior stores.
If that is a concern, you need explicit barriers.
This is #MC, much care and explicit open-coded crap is expected. Also, this is #MC, much broken is also expected :-( As in, the current #MC handler is a know pile of shit.
Basically the whole of #MC should be noinstr -- it isn't and that's a significant problem.
Also we still very much suffer the NMI <- #MC problem and the #MC latch is known broken garbage.
Whatever you do, do it very carefully, double check and be more careful.
| |