[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <MWHPR11MB1245DFEAEBDC57298ED4E073A96F9@MWHPR11MB1245.namprd11.prod.outlook.com>
Date: Wed, 8 Dec 2021 07:23:17 +0000
From: "Liu, Jing2" <jing2.liu@...el.com>
To: "Zhong, Yang" <yang.zhong@...el.com>,
"x86@...nel.org" <x86@...nel.org>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"tglx@...utronix.de" <tglx@...utronix.de>,
"mingo@...hat.com" <mingo@...hat.com>,
"bp@...en8.de" <bp@...en8.de>,
"dave.hansen@...ux.intel.com" <dave.hansen@...ux.intel.com>,
"pbonzini@...hat.com" <pbonzini@...hat.com>
CC: "seanjc@...gle.com" <seanjc@...gle.com>,
"Nakajima, Jun" <jun.nakajima@...el.com>,
"Tian, Kevin" <kevin.tian@...el.com>,
"jing2.liu@...ux.intel.com" <jing2.liu@...ux.intel.com>
Subject: RE: [PATCH 13/19] kvm: x86: Disable WRMSR interception for IA32_XFD
on demand
On 12/8/2021 8:03 AM, Yang Zhong wrote:
> From: Jing Liu <jing2.liu@...el.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.
>
Powered by blists - more mailing lists