Re: [PATCH RESEND v4 5/9] KVM: VMX: Add init/set/get functions for SPP

2019-08-20 Thread Yang Weijiang
On Mon, Aug 19, 2019 at 05:13:47PM +0200, Paolo Bonzini wrote: > On 14/08/19 09:03, Yang Weijiang wrote: > > static struct kvm_x86_ops vmx_x86_ops __ro_after_init = { > > .cpu_has_kvm_support = cpu_has_kvm_support, > > .disabled_by_bios = vmx_disabled_by_bios, > > @@ -7740,6 +7783,11 @@

Re: [PATCH RESEND v4 5/9] KVM: VMX: Add init/set/get functions for SPP

2019-08-20 Thread Yang Weijiang
On Mon, Aug 19, 2019 at 05:05:22PM +0200, Paolo Bonzini wrote: > On 14/08/19 09:03, Yang Weijiang wrote: > > + > > +int kvm_mmu_get_subpages(struct kvm *kvm, struct kvm_subpage *spp_info, > > +bool mmu_locked) > > +{ > > + u32 *access = spp_info->access_map; > > + gfn_t gfn

Re: [PATCH RESEND v4 5/9] KVM: VMX: Add init/set/get functions for SPP

2019-08-20 Thread Yang Weijiang
On Mon, Aug 19, 2019 at 05:15:01PM +0200, Paolo Bonzini wrote: > On 19/08/19 04:08, Yang Weijiang wrote: > >> KVM_GET_NESTED_STATE has the requested information. If > >> data.vmx.vmxon_pa is anything other than -1, then the vCPU is in VMX > >> operation. If (flags & KVM_STATE_NESTED_GUEST_MODE),

Re: [PATCH RESEND v4 5/9] KVM: VMX: Add init/set/get functions for SPP

2019-08-19 Thread Paolo Bonzini
On 19/08/19 04:08, Yang Weijiang wrote: >> KVM_GET_NESTED_STATE has the requested information. If >> data.vmx.vmxon_pa is anything other than -1, then the vCPU is in VMX >> operation. If (flags & KVM_STATE_NESTED_GUEST_MODE), then L2 is >> active. > Thanks Jim, I'll reference the code and make

Re: [PATCH RESEND v4 5/9] KVM: VMX: Add init/set/get functions for SPP

2019-08-19 Thread Paolo Bonzini
On 14/08/19 09:03, Yang Weijiang wrote: > init_spp() must be called before {get, set}_subpage > functions, it creates subpage access bitmaps for memory pages > and issues a KVM request to setup SPPT root pages. > > kvm_mmu_set_subpages() is to enable SPP bit in EPT leaf page > and setup

Re: [PATCH RESEND v4 5/9] KVM: VMX: Add init/set/get functions for SPP

2019-08-19 Thread Paolo Bonzini
On 14/08/19 09:03, Yang Weijiang wrote: > + > +int kvm_mmu_get_subpages(struct kvm *kvm, struct kvm_subpage *spp_info, > + bool mmu_locked) > +{ > + u32 *access = spp_info->access_map; > + gfn_t gfn = spp_info->base_gfn; > + int npages = spp_info->npages; > +

Re: [PATCH RESEND v4 5/9] KVM: VMX: Add init/set/get functions for SPP

2019-08-19 Thread Yang Weijiang
On Thu, Aug 15, 2019 at 04:03:31PM +0200, Vitaly Kuznetsov wrote: > Yang Weijiang writes: > > > After looked into the issue and others, I feel to make SPP co-existing > > with nested VM is not good, the major reason is, L1 pages protected by > > SPP are transparent to L1 VM, if it launches L2

Re: [PATCH RESEND v4 5/9] KVM: VMX: Add init/set/get functions for SPP

2019-08-18 Thread Yang Weijiang
On Fri, Aug 16, 2019 at 11:19:46AM -0700, Jim Mattson wrote: > On Fri, Aug 16, 2019 at 6:29 AM Yang Weijiang wrote: > > > Thanks Jim and Sean! Could we add a new flag in kvm to identify if nested > > VM is on > > or off? That would make things easier. When VMLAUNCH is trapped, > > set the flag,

Re: [PATCH RESEND v4 5/9] KVM: VMX: Add init/set/get functions for SPP

2019-08-16 Thread Jim Mattson
On Fri, Aug 16, 2019 at 6:29 AM Yang Weijiang wrote: > Thanks Jim and Sean! Could we add a new flag in kvm to identify if nested VM > is on > or off? That would make things easier. When VMLAUNCH is trapped, > set the flag, if VMXOFF is trapped, clear the flag. KVM_GET_NESTED_STATE has the

Re: [PATCH RESEND v4 5/9] KVM: VMX: Add init/set/get functions for SPP

2019-08-16 Thread Yang Weijiang
On Thu, Aug 15, 2019 at 09:38:44AM -0700, Sean Christopherson wrote: > On Thu, Aug 15, 2019 at 09:25:41AM -0700, Jim Mattson wrote: > > On Thu, Aug 15, 2019 at 6:41 AM Yang Weijiang > > wrote: > > > > > Hi, Vitaly, > > > After looked into the issue and others, I feel to make SPP co-existing > >

Re: [PATCH RESEND v4 5/9] KVM: VMX: Add init/set/get functions for SPP

2019-08-15 Thread Sean Christopherson
On Thu, Aug 15, 2019 at 09:25:41AM -0700, Jim Mattson wrote: > On Thu, Aug 15, 2019 at 6:41 AM Yang Weijiang wrote: > > > Hi, Vitaly, > > After looked into the issue and others, I feel to make SPP co-existing > > with nested VM is not good, the major reason is, L1 pages protected by > > SPP are

Re: [PATCH RESEND v4 5/9] KVM: VMX: Add init/set/get functions for SPP

2019-08-15 Thread Jim Mattson
On Thu, Aug 15, 2019 at 6:41 AM Yang Weijiang wrote: > Hi, Vitaly, > After looked into the issue and others, I feel to make SPP co-existing > with nested VM is not good, the major reason is, L1 pages protected by > SPP are transparent to L1 VM, if it launches L2 VM, probably the > pages would be

Re: [PATCH RESEND v4 5/9] KVM: VMX: Add init/set/get functions for SPP

2019-08-15 Thread Vitaly Kuznetsov
Yang Weijiang writes: > After looked into the issue and others, I feel to make SPP co-existing > with nested VM is not good, the major reason is, L1 pages protected by > SPP are transparent to L1 VM, if it launches L2 VM, probably the > pages would be allocated to L2 VM, and that will bother to

Re: [PATCH RESEND v4 5/9] KVM: VMX: Add init/set/get functions for SPP

2019-08-15 Thread Yang Weijiang
On Wed, Aug 14, 2019 at 02:43:39PM +0200, Vitaly Kuznetsov wrote: > Yang Weijiang writes: > > > init_spp() must be called before {get, set}_subpage > > functions, it creates subpage access bitmaps for memory pages > > and issues a KVM request to setup SPPT root pages. > > > >

Re: [PATCH RESEND v4 5/9] KVM: VMX: Add init/set/get functions for SPP

2019-08-14 Thread Yang Weijiang
On Wed, Aug 14, 2019 at 02:43:39PM +0200, Vitaly Kuznetsov wrote: > Yang Weijiang writes: > > > init_spp() must be called before {get, set}_subpage > > functions, it creates subpage access bitmaps for memory pages > > and issues a KVM request to setup SPPT root pages. > > > >

Re: [PATCH RESEND v4 5/9] KVM: VMX: Add init/set/get functions for SPP

2019-08-14 Thread Vitaly Kuznetsov
Yang Weijiang writes: > init_spp() must be called before {get, set}_subpage > functions, it creates subpage access bitmaps for memory pages > and issues a KVM request to setup SPPT root pages. > > kvm_mmu_set_subpages() is to enable SPP bit in EPT leaf page > and setup corresponding SPPT

[PATCH RESEND v4 5/9] KVM: VMX: Add init/set/get functions for SPP

2019-08-14 Thread Yang Weijiang
init_spp() must be called before {get, set}_subpage functions, it creates subpage access bitmaps for memory pages and issues a KVM request to setup SPPT root pages. kvm_mmu_set_subpages() is to enable SPP bit in EPT leaf page and setup corresponding SPPT entries. The mmu_lock is held before above