]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
x86/apic: Fix atomic update of offset in reserve_eilvt_offset()
authorUros Bizjak <ubizjak@gmail.com>
Mon, 27 Feb 2023 16:09:17 +0000 (17:09 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 May 2023 14:11:03 +0000 (23:11 +0900)
commit67ab0335b0675c9da8908489e66e4770f90299a6
treee55455987de63fc7e155f019536f1084da8e01fb
parent435c65af581a61ca249bd8f717c3a147dc119f11
x86/apic: Fix atomic update of offset in reserve_eilvt_offset()

[ Upstream commit f96fb2df3eb31ede1b34b0521560967310267750 ]

The detection of atomic update failure in reserve_eilvt_offset() is
not correct. The value returned by atomic_cmpxchg() should be compared
to the old value from the location to be updated.

If these two are the same, then atomic update succeeded and
"eilvt_offsets[offset]" location is updated to "new" in an atomic way.

Otherwise, the atomic update failed and it should be retried with the
value from "eilvt_offsets[offset]" - exactly what atomic_try_cmpxchg()
does in a correct and more optimal way.

Fixes: a68c439b1966c ("apic, x86: Check if EILVT APIC registers are available (AMD only)")
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20230227160917.107820-1-ubizjak@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/x86/kernel/apic/apic.c