Re: [PATCH v5 4/7] kvm, mem-hotplug: Reload L1' apic access page on migration in vcpu_enter_guest().

2014-09-11 Thread tangchen
Hi Paolo, On 09/11/2014 10:24 PM, Paolo Bonzini wrote: Il 11/09/2014 16:21, Gleb Natapov ha scritto: As far as I can tell the if that is needed there is: if (!is_guest_mode() || !(vmcs12->secondary_vm_exec_control & ECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES)) write(PIC_ACCESS_ADDR) In othe

Re: [PATCH v5 4/7] kvm, mem-hotplug: Reload L1' apic access page on migration in vcpu_enter_guest().

2014-09-11 Thread tangchen
Hi Gleb, Paolo, On 09/11/2014 10:47 PM, Gleb Natapov wrote: On Thu, Sep 11, 2014 at 04:37:39PM +0200, Paolo Bonzini wrote: Il 11/09/2014 16:31, Gleb Natapov ha scritto: What if the page being swapped out is L1's APIC access page? We don't run prepare_vmcs12 in that case because it's an L2->L0

Re: [PATCH v5 4/7] kvm, mem-hotplug: Reload L1' apic access page on migration in vcpu_enter_guest().

2014-09-11 Thread Gleb Natapov
On Thu, Sep 11, 2014 at 04:37:39PM +0200, Paolo Bonzini wrote: > Il 11/09/2014 16:31, Gleb Natapov ha scritto: > >> > What if the page being swapped out is L1's APIC access page? We don't > >> > run prepare_vmcs12 in that case because it's an L2->L0->L2 entry, so we > >> > need to "do something".

Re: [PATCH v5 4/7] kvm, mem-hotplug: Reload L1' apic access page on migration in vcpu_enter_guest().

2014-09-11 Thread Paolo Bonzini
Il 11/09/2014 16:31, Gleb Natapov ha scritto: >> > What if the page being swapped out is L1's APIC access page? We don't >> > run prepare_vmcs12 in that case because it's an L2->L0->L2 entry, so we >> > need to "do something". > We will do something on L2->L1 exit. We will call > kvm_reload_apic_

Re: [PATCH v5 4/7] kvm, mem-hotplug: Reload L1' apic access page on migration in vcpu_enter_guest().

2014-09-11 Thread Gleb Natapov
On Thu, Sep 11, 2014 at 04:24:04PM +0200, Paolo Bonzini wrote: > Il 11/09/2014 16:21, Gleb Natapov ha scritto: > > As far as I can tell the if that is needed there is: > > > > if (!is_guest_mode() || !(vmcs12->secondary_vm_exec_control & > > ECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES)) > > write(

Re: [PATCH v5 4/7] kvm, mem-hotplug: Reload L1' apic access page on migration in vcpu_enter_guest().

2014-09-11 Thread Paolo Bonzini
Il 11/09/2014 16:21, Gleb Natapov ha scritto: > As far as I can tell the if that is needed there is: > > if (!is_guest_mode() || !(vmcs12->secondary_vm_exec_control & > ECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES)) > write(PIC_ACCESS_ADDR) > > In other words if L2 shares L1 apic access page then

Re: [PATCH v5 4/7] kvm, mem-hotplug: Reload L1' apic access page on migration in vcpu_enter_guest().

2014-09-11 Thread Gleb Natapov
On Thu, Sep 11, 2014 at 04:06:58PM +0200, Paolo Bonzini wrote: > Il 11/09/2014 15:59, Gleb Natapov ha scritto: > > > > Suppose vmcs01->APIC_ACCESS_ADDR = 0xf000. During L2 entry > > vmcs02->APIC_ACCESS_ADDR is set to 0xf000 too (by prepare_vmcs02). Now > > 0xf000 is migrated to 0x8000, mmu notifie

Re: [PATCH v5 4/7] kvm, mem-hotplug: Reload L1' apic access page on migration in vcpu_enter_guest().

2014-09-11 Thread Paolo Bonzini
Il 11/09/2014 15:59, Gleb Natapov ha scritto: > > Suppose vmcs01->APIC_ACCESS_ADDR = 0xf000. During L2 entry > vmcs02->APIC_ACCESS_ADDR is set to 0xf000 too (by prepare_vmcs02). Now > 0xf000 is migrated to 0x8000, mmu notifier is called, it forces vmexit, > but vcpu is in a guest mode so vmcs02->A

Re: [PATCH v5 4/7] kvm, mem-hotplug: Reload L1' apic access page on migration in vcpu_enter_guest().

2014-09-11 Thread Gleb Natapov
On Thu, Sep 11, 2014 at 03:05:05PM +0200, Paolo Bonzini wrote: > Il 11/09/2014 13:30, Gleb Natapov ha scritto: > >> > +vmcs_write64(APIC_ACCESS_ADDR, > >> > page_to_phys(page)); > >> > +/* > >> > + * Do not pin apic access pag

Re: [PATCH v5 4/7] kvm, mem-hotplug: Reload L1' apic access page on migration in vcpu_enter_guest().

2014-09-11 Thread Paolo Bonzini
Il 11/09/2014 13:30, Gleb Natapov ha scritto: >> > + vmcs_write64(APIC_ACCESS_ADDR, page_to_phys(page)); >> > + /* >> > + * Do not pin apic access page in memory so that memory >> > + * hotplug process is able to migrate it. >> >

Re: [PATCH v5 4/7] kvm, mem-hotplug: Reload L1' apic access page on migration in vcpu_enter_guest().

2014-09-11 Thread Gleb Natapov
On Thu, Sep 11, 2014 at 12:47:16PM +0200, Paolo Bonzini wrote: > Il 11/09/2014 12:12, Gleb Natapov ha scritto: > > On Thu, Sep 11, 2014 at 11:21:49AM +0200, Paolo Bonzini wrote: > >> Il 11/09/2014 07:38, Tang Chen ha scritto: > >>> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > >>> index 63

Re: [PATCH v5 4/7] kvm, mem-hotplug: Reload L1' apic access page on migration in vcpu_enter_guest().

2014-09-11 Thread Paolo Bonzini
Il 11/09/2014 12:12, Gleb Natapov ha scritto: > On Thu, Sep 11, 2014 at 11:21:49AM +0200, Paolo Bonzini wrote: >> Il 11/09/2014 07:38, Tang Chen ha scritto: >>> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c >>> index 63c4c3e..da6d55d 100644 >>> --- a/arch/x86/kvm/vmx.c >>> +++ b/arch/x86/kvm

Re: [PATCH v5 4/7] kvm, mem-hotplug: Reload L1' apic access page on migration in vcpu_enter_guest().

2014-09-11 Thread Paolo Bonzini
Il 11/09/2014 12:20, tangchen ha scritto: >>> >>> +vmcs_write64(APIC_ACCESS_ADDR, hpa); >> This has to be guarded by "if (!is_guest_mode(vcpu))". > > Since we cannot get vcpu through kvm, I'd like to move this check to > vcpu_reload_apic_access_page() when > kvm_x86_ops->set_apic_access_page_a

Re: [PATCH v5 4/7] kvm, mem-hotplug: Reload L1' apic access page on migration in vcpu_enter_guest().

2014-09-11 Thread tangchen
On 09/11/2014 05:21 PM, Paolo Bonzini wrote: Il 11/09/2014 07:38, Tang Chen ha scritto: apic access page is pinned in memory. As a result, it cannot be migrated/hot-removed. Actually, it is not necessary to be pinned. The hpa of apic access page is stored in VMCS APIC_ACCESS_ADDR pointer. Whe

Re: [PATCH v5 4/7] kvm, mem-hotplug: Reload L1' apic access page on migration in vcpu_enter_guest().

2014-09-11 Thread Gleb Natapov
On Thu, Sep 11, 2014 at 11:21:49AM +0200, Paolo Bonzini wrote: > Il 11/09/2014 07:38, Tang Chen ha scritto: > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > > index 63c4c3e..da6d55d 100644 > > --- a/arch/x86/kvm/vmx.c > > +++ b/arch/x86/kvm/vmx.c > > @@ -7093,6 +7093,11 @@ static void vmx

Re: [PATCH v5 4/7] kvm, mem-hotplug: Reload L1' apic access page on migration in vcpu_enter_guest().

2014-09-11 Thread Paolo Bonzini
Il 11/09/2014 07:38, Tang Chen ha scritto: > apic access page is pinned in memory. As a result, it cannot be > migrated/hot-removed. > Actually, it is not necessary to be pinned. > > The hpa of apic access page is stored in VMCS APIC_ACCESS_ADDR pointer. When > the page is migrated, kvm_mmu_notif

[PATCH v5 4/7] kvm, mem-hotplug: Reload L1' apic access page on migration in vcpu_enter_guest().

2014-09-10 Thread Tang Chen
apic access page is pinned in memory. As a result, it cannot be migrated/hot-removed. Actually, it is not necessary to be pinned. The hpa of apic access page is stored in VMCS APIC_ACCESS_ADDR pointer. When the page is migrated, kvm_mmu_notifier_invalidate_page() will invalidate the corresponding