x86/CPU/AMD: Fix the DIV(0) initial fix attempt
authorBorislav Petkov (AMD) <bp@alien8.de>
Fri, 11 Aug 2023 21:38:24 +0000 (23:38 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 26 Aug 2023 11:27:00 +0000 (13:27 +0200)
commite4679a0342e05a962639a6ec3781f257f417f0ff
treee2d500ab9ff1a7c15dfa9f85acc7cdd731773173
parentb41eb316c95c98d16dba2045c4890a3020f0a5bc
x86/CPU/AMD: Fix the DIV(0) initial fix attempt

commit f58d6fbcb7c848b7f2469be339bc571f2e9d245b upstream.

Initially, it was thought that doing an innocuous division in the #DE
handler would take care to prevent any leaking of old data from the
divider but by the time the fault is raised, the speculation has already
advanced too far and such data could already have been used by younger
operations.

Therefore, do the innocuous division on every exit to userspace so that
userspace doesn't see any potentially old data from integer divisions in
kernel space.

Do the same before VMRUN too, to protect host data from leaking into the
guest too.

Fixes: 77245f1c3c64 ("x86/CPU/AMD: Do not leak quotient data after a division by 0")
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Cc: <stable@kernel.org>
Link: https://lore.kernel.org/r/20230811213824.10025-1-bp@alien8.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/include/asm/entry-common.h
arch/x86/kernel/cpu/amd.c
arch/x86/kernel/traps.c
arch/x86/kvm/svm/svm.c