lkml.org 
[lkml]   [2021]   [Dec]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH 13/19] kvm: x86: Disable WRMSR interception for IA32_XFD on demand
Date

On 12/8/2021 8:03 AM, Yang Zhong wrote:
> From: Jing Liu <jing2.liu@intel.com>
>
> Always intercepting IA32_XFD causes non-negligible overhead when this
> register is updated frequently in the guest.
>
> Disable WRMSR interception to IA32_XFD after fpstate reallocation is
> completed. There are three options for when to disable the
> interception:
>
> 1) When emulating the 1st WRMSR which requires reallocation,
> disable interception before exiting to userapce with the
> assumption that the userspace VMM should not bounch back to
> the kernel if reallocation fails. However it's not good to
> design kernel based on application behavior. If due to bug
> the vCPU thread comes back to the kernel after reallocation
> fails, XFD passthrough may lead to host memory corruption
> when doing XSAVES for guest fpstate which has a smaller size
> than what guest XFD allows.
>
> 2) Disable interception when coming back from the userspace VMM
> (for the 1st WRMSR which triggers reallocation). Re-check
> whether fpstate size can serve the new guest XFD value. Disable
> interception only when the check succeeds. This requires KVM
> to store guest XFD value in some place and then compare it
> to guest_fpu::user_xfeatures in the completion handler.

For option 2), we are considering that fpstate->size can be used to indicate
if reallocation is successful. Because once one of the XFD features (today,
it's AMX) is enabled, kernel need reallocate full size, otherwise, KVM has no
chance to reallocate for other XFD features later since it's non-trapped (to
avoid WRMSR VM EXITs due to guest toggling XFD).

Then KVM doesn't need to store guest XFD value in some place. And kernel
fpu core may need an API to tell guest permitted size for KVM.

Thanks,
Jing

>
> 3) Disable interception at the 2nd WRMSR which enables dynamic
> XSTATE features. If guest_fpu::user_xfeatures already includes
> bits for dynamic features set in guest XFD value, disable
> interception.
>

\
 
 \ /
  Last update: 2021-12-08 08:24    [W:1.049 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site