[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <24BD0906-C6FE-499C-9A4A-00C56E6EE84A@gmail.com>
Date: Sat, 4 Nov 2023 11:25:31 +0200
From: Nadav Amit <nadav.amit@...il.com>
To: Richard Weinberger <richard@....at>, linux-um@...ts.infradead.org
Cc: Thomas Gleixner <tglx@...utronix.de>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Peter Zijlstra <peterz@...radead.org>
Subject: Missing clobber on alternative use on Linux UM 32-bit
I was reading (again) the x86 C macro of “alternative()” and I was a bit
surprised it does clobber the flags (“cc”) as a precaution.
#define alternative(oldinstr, newinstr, ft_flags) \
asm_inline volatile (ALTERNATIVE(oldinstr, newinstr, ft_flags) : : : "memory")
Actually there seems to be only one instance of problematic cases - in um/32-bit:
#define mb() alternative("lock; addl $0,0(%%esp)", "mfence", X86_FEATURE_XMM2)
#define rmb() alternative("lock; addl $0,0(%%esp)", "lfence", X86_FEATURE_XMM2)
#define wmb() alternative("lock; addl $0,0(%%esp)", "sfence", X86_FEATURE_XMM)
Presumably, if XMM or XMM2 are not supported, there would be instances where addl
would be able to change eflags arithmetic flags without the compiler being aware
of it.
As it only affects 32-bit Linux UM - I don’t easily have an environment to test
the fix. An alternative (word-pun unintended) is to add “cc” as a precaution
to the alternative macro.
Powered by blists - more mailing lists