[PATCH 0/1] x86/fpu: Follow up on the init_fpstate fix
From: Chang S. Bae
Date: Tue Oct 18 2022 - 18:24:14 EST
In short, the init_fpstate fix currently at tip's x86/urgent [6] is
incomplete for KVM. This patch follows up on that.
---
While these patches [1][2] attempt to fix the init fpstate, it results in a
fallout with KVM [3]:
The VCPU's XSAVE buffer is expanded at the time of VCPU setup [4] when any
dynamic feature is determined to be exposed via KVM_SET_CPUID.
Then, when the VCPU thread is executed [5], the xstate is copied to the
userspace via KVM_GET_XSAVE*. At the moment, the entire guest fpstate is in
init state.
But, init_fpstate has been incorrectly indicating the inclusion of
dynamic states. Subsequently, in the xstate copy loop, memory beyond the
init_fpstate looks to be referenced for the init states of dynamic
features.
The tip-merged series [1] fixes init_fpstate only. The xstate copy loop
remains to retrieve init_fpstate. Then, it will explode when a
dynamic-featured VCPU is about executed.
The included patch is to fix the copy function. It is based on the
x86/urgent branch [6].
Thanks,
Chang
[1] https://lore.kernel.org/lkml/20220824191223.1248-1-chang.seok.bae@xxxxxxxxx/
[2] https://lore.kernel.org/lkml/20221011222425.866137-1-dave.hansen@xxxxxxxxxxxxxxx/
[3] https://lore.kernel.org/lkml/BYAPR11MB3717EDEF2351C958F2C86EED95259@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/
[4] https://gitlab.com/qemu-project/qemu/-/blob/master/accel/kvm/kvm-accel-ops.c#L42
[5] https://gitlab.com/qemu-project/qemu/-/blob/master/accel/kvm/kvm-accel-ops.c#L51
[6] https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/log/?h=x86/urgent
Chang S. Bae (1):
x86/fpu: Fix copy_xstate_to_uabi() to copy init states correctly
arch/x86/kernel/fpu/xstate.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
base-commit: 67bf6493449b09590f9f71d7df29efb392b12d25
--
2.17.1