Re: [PATCH RFC 3/7] kvm: x86: XSAVE state and XFD MSRs context switch

2021-02-22 Thread Liu, Jing2
On 2/9/2021 2:55 AM, Konrad Rzeszutek Wilk wrote: On Mon, Feb 08, 2021 at 07:12:22PM +0100, Paolo Bonzini wrote: [...] However, running the host with _more_ bits set than necessary in XFD should not be a problem as long as the host doesn't use the AMX instructions. So perhaps Jing can

Re: [PATCH RFC 3/7] kvm: x86: XSAVE state and XFD MSRs context switch

2021-02-22 Thread Liu, Jing2
On 2/9/2021 2:12 AM, Paolo Bonzini wrote: On 08/02/21 19:04, Sean Christopherson wrote: That said, the case where we saw MSR autoload as faster involved EFER, and we decided that it was due to TLB flushes (commit f6577a5fa15d, "x86, kvm, vmx: Always use LOAD_IA32_EFER if available",

Re: [PATCH RFC 3/7] kvm: x86: XSAVE state and XFD MSRs context switch

2021-02-08 Thread Konrad Rzeszutek Wilk
On Mon, Feb 08, 2021 at 07:12:22PM +0100, Paolo Bonzini wrote: > On 08/02/21 19:04, Sean Christopherson wrote: > > > That said, the case where we saw MSR autoload as faster involved EFER, and > > > we decided that it was due to TLB flushes (commit f6577a5fa15d, "x86, kvm, > > > vmx: Always use

Re: [PATCH RFC 3/7] kvm: x86: XSAVE state and XFD MSRs context switch

2021-02-08 Thread Paolo Bonzini
On 08/02/21 19:04, Sean Christopherson wrote: That said, the case where we saw MSR autoload as faster involved EFER, and we decided that it was due to TLB flushes (commit f6577a5fa15d, "x86, kvm, vmx: Always use LOAD_IA32_EFER if available", 2014-11-12). Do you know if RDMSR/WRMSR is always

Re: [PATCH RFC 3/7] kvm: x86: XSAVE state and XFD MSRs context switch

2021-02-08 Thread Sean Christopherson
On Mon, Feb 08, 2021, Paolo Bonzini wrote: > On 08/02/21 18:31, Sean Christopherson wrote: > > On Mon, Feb 08, 2021, Paolo Bonzini wrote: > > > On 07/02/21 16:42, Jing Liu wrote: > > > > In KVM, "guest_fpu" serves for any guest task working on this vcpu > > > > during vmexit and vmenter. We

Re: [PATCH RFC 3/7] kvm: x86: XSAVE state and XFD MSRs context switch

2021-02-08 Thread Paolo Bonzini
On 08/02/21 18:31, Sean Christopherson wrote: On Mon, Feb 08, 2021, Paolo Bonzini wrote: On 07/02/21 16:42, Jing Liu wrote: In KVM, "guest_fpu" serves for any guest task working on this vcpu during vmexit and vmenter. We provide a pre-allocated guest_fpu space and entire "guest_fpu.state_mask"

Re: [PATCH RFC 3/7] kvm: x86: XSAVE state and XFD MSRs context switch

2021-02-08 Thread Sean Christopherson
On Mon, Feb 08, 2021, Paolo Bonzini wrote: > On 07/02/21 16:42, Jing Liu wrote: > > |In KVM, "guest_fpu" serves for any guest task working on this vcpu > > during vmexit and vmenter. We provide a pre-allocated guest_fpu space > > and entire "guest_fpu.state_mask" to avoid each dynamic features > >

Re: [PATCH RFC 3/7] kvm: x86: XSAVE state and XFD MSRs context switch

2021-02-08 Thread Paolo Bonzini
On 07/02/21 16:42, Jing Liu wrote: |In KVM, "guest_fpu" serves for any guest task working on this vcpu during vmexit and vmenter. We provide a pre-allocated guest_fpu space and entire "guest_fpu.state_mask" to avoid each dynamic features detection on each vcpu task. Meanwhile, to ensure

Re: [PATCH RFC 3/7] kvm: x86: XSAVE state and XFD MSRs context switch

2021-02-07 Thread Liu, Jing2
On 2/7/2021 7:49 PM, Borislav Petkov wrote: On Sun, Feb 07, 2021 at 10:42:52AM -0500, Jing Liu wrote: diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c index 7e0c68043ce3..fbb761fc13ec 100644 --- a/arch/x86/kernel/fpu/init.c +++ b/arch/x86/kernel/fpu/init.c @@ -145,6

Re: [PATCH RFC 3/7] kvm: x86: XSAVE state and XFD MSRs context switch

2021-02-07 Thread Borislav Petkov
On Sun, Feb 07, 2021 at 10:42:52AM -0500, Jing Liu wrote: > diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c > index 7e0c68043ce3..fbb761fc13ec 100644 > --- a/arch/x86/kernel/fpu/init.c > +++ b/arch/x86/kernel/fpu/init.c > @@ -145,6 +145,7 @@

[PATCH RFC 3/7] kvm: x86: XSAVE state and XFD MSRs context switch

2021-02-06 Thread Jing Liu
XFD allows the kernel to enable a feature state in XCR0 and to receive a #NM trap when a task uses instructions accessing that state. Kernel defines "struct fpu.state_mask" to indicate the saved xstate and interact with the XFD hardware when needed via a simple conversion. Once a dynamic feature