Re: [PATCH v4] KVM: x86: fix access memslots w/o hold srcu read lock

2014-11-13 Thread Tang Chen
Thanks for the sharing. Will do more tests. :) On 11/14/2014 07:39 AM, Wanpeng Li wrote: Hi Tang, On Tue, Nov 11, 2014 at 01:35:29PM +0800, Tang Chen wrote: Hi Wanpeng, Sorry for the late. I think I have totally missed this thread. I opened lockdep and RCU debug, and tried on 3.18-rc1

Re: [PATCH v4] KVM: x86: fix access memslots w/o hold srcu read lock

2014-11-10 Thread Tang Chen
Hi Wanpeng, I think I have totally missed this thread. I opened lockdep and RCU debug, and tried on 3.18-rc1. But I didn't get the warning. My steps are: 1. Use numactl to bind a qemu process to node1. 2. Offline all node1 memory. And the qemu process is still running. Would you please tell m

Re: [PATCH v8 0/8] kvm, mem-hotplug: Do not pin ept identity pagetable and apic access page.

2014-09-25 Thread Tang Chen
On 09/25/2014 09:43 PM, Paolo Bonzini wrote: Il 25/09/2014 10:19, Tang Chen ha scritto: Hi Paolo, I'd like to help to test the patches. Would you please tell me what is the best way to test this patch-set ? How did _you_ test the patches?... I just added "-cpu xxx,-x2apic"

Re: [PATCH v8 0/8] kvm, mem-hotplug: Do not pin ept identity pagetable and apic access page.

2014-09-25 Thread Tang Chen
04:20 PM, Paolo Bonzini wrote: Il 24/09/2014 09:57, Tang Chen ha scritto: ept identity pagetable and apic access page in kvm are pinned in memory. As a result, they cannot be migrated/hot-removed. But actually they don't need to be pinned in memory. [For ept identity page] Just do not pin it.

Re: [PATCH v8 0/8] kvm, mem-hotplug: Do not pin ept identity pagetable and apic access page.

2014-09-24 Thread Tang Chen
On 09/24/2014 04:20 PM, Paolo Bonzini wrote: Il 24/09/2014 09:57, Tang Chen ha scritto: ept identity pagetable and apic access page in kvm are pinned in memory. As a result, they cannot be migrated/hot-removed. But actually they don't need to be pinned in memory. [For ept identity page]

[PATCH v8 3/8] kvm: Make init_rmode_identity_map() return 0 on success.

2014-09-24 Thread Tang Chen
success, -errno on failure. Signed-off-by: Tang Chen --- arch/x86/kvm/vmx.c | 31 +++ 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 4fb84ad..72a0470 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c

[PATCH v8 1/8] kvm: Use APIC_DEFAULT_PHYS_BASE macro as the apic access page address.

2014-09-24 Thread Tang Chen
We have APIC_DEFAULT_PHYS_BASE defined as 0xfee0, which is also the address of apic access page. So use this macro. Signed-off-by: Tang Chen Reviewed-by: Gleb Natapov --- arch/x86/kvm/svm.c | 3 ++- arch/x86/kvm/vmx.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff

[PATCH v8 5/8] kvm: Rename make_all_cpus_request() to kvm_make_all_cpus_request() and make it non-static.

2014-09-24 Thread Tang Chen
Since different architectures need different handling, we will add some arch specific code later. The code may need to make cpu requests outside kvm_main.c, so make it non-static and rename it to kvm_make_all_cpus_request(). Reviewed-by: Paolo Bonzini Signed-off-by: Tang Chen --- include

[PATCH v8 2/8] kvm: Remove ept_identity_pagetable from struct kvm_arch.

2014-09-24 Thread Tang Chen
m_arch->ept_identity_pagetable is removed, ept identity pagetable page is no longer pinned in memory. And it can be migrated/hot-removed. Signed-off-by: Tang Chen Reviewed-by: Gleb Natapov --- arch/x86/include/asm/kvm_host.h | 1 - arch/x86/kvm/vmx.c

[PATCH v8 4/8] kvm, mem-hotplug: Reload L1's apic access page in vcpu_enter_guest().

2014-09-24 Thread Tang Chen
to check if we are in L2 and if L1 prepares an non-shared apic access page for L2. We do this in vmx_set_apic_access_page_addr() when trying to set new apic access page's hpa like this: if (!is_guest_mode(vcpu) || !(vmx->nested.current_vmcs12->secondary_vm_exec_control &a

[PATCH v8 7/8] kvm, mem-hotplug: Add arch specific mmu notifier to handle apic access migration.

2014-09-24 Thread Tang Chen
s in the next L2->L1 exit. This patch force a L1->L0 exit or L2->L0 exit when shared apic access page is migrated using mmu notifier. Since apic access page is only used on intel x86, this is arch specific code. Signed-off-by: Tang Chen --- arch/arm/include/asm/kvm_host.h | 5 +

[PATCH v8 8/8] kvm, mem-hotplug: Unpin and remove kvm_arch->apic_access_page.

2014-09-24 Thread Tang Chen
v Signed-off-by: Tang Chen --- arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/vmx.c | 17 ++--- arch/x86/kvm/x86.c | 16 ++-- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/in

[PATCH v8 6/8] kvm, mem-hotplug: Reload L1's apic access page on migration when L2 is running.

2014-09-24 Thread Tang Chen
s in the next L2->L1 exit. This patch handles 3). In L0->L2 entry, L2's vmcs will be updated in prepare_vmcs02() called by nested_vm_run(). So we need to do nothing. In L2->L1 exit, this patch requests apic access page reload in L2->L1 vmexit. Reviewed-by: Paolo Bonzini Sign

[PATCH v8 0/8] kvm, mem-hotplug: Do not pin ept identity pagetable and apic access page.

2014-09-24 Thread Tang Chen
ved useless set_apic_access_page_addr() hook for svm. Tang Chen (8): kvm: Use APIC_DEFAULT_PHYS_BASE macro as the apic access page address. kvm: Remove ept_identity_pagetable from struct kvm_arch. kvm: Make init_rmode_identity_map() return 0 on success. kvm, mem-hotplug: Reload L1's api

Re: [PATCH 1/1] kvm, mem-hotplug: Add arch specific mmu notifier to handle apic access migration.

2014-09-24 Thread Tang Chen
On 09/24/2014 03:08 PM, Jan Kiszka wrote: On 2014-09-24 04:09, Tang Chen wrote: Hi Paolo, I'm not sure if this patch is following your comment. Please review. And all the other comments are followed. If this patch is OK, I'll send v8 soon. Thanks. We are handling "L1 and L2

[PATCH 1/1] kvm, mem-hotplug: Add arch specific mmu notifier to handle apic access migration.

2014-09-23 Thread Tang Chen
Hi Paolo, I'm not sure if this patch is following your comment. Please review. And all the other comments are followed. If this patch is OK, I'll send v8 soon. Thanks. We are handling "L1 and L2 share one apic access page" situation when migrating apic access page. We should do some handling w

[PATCH v7 1/9] kvm: Use APIC_DEFAULT_PHYS_BASE macro as the apic access page address.

2014-09-20 Thread Tang Chen
We have APIC_DEFAULT_PHYS_BASE defined as 0xfee0, which is also the address of apic access page. So use this macro. Signed-off-by: Tang Chen Reviewed-by: Gleb Natapov --- arch/x86/kvm/svm.c | 3 ++- arch/x86/kvm/vmx.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff

[PATCH v7 3/9] kvm: Make init_rmode_identity_map() return 0 on success.

2014-09-20 Thread Tang Chen
success, -errno on failure. Signed-off-by: Tang Chen --- arch/x86/kvm/vmx.c | 31 +++ 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 4fb84ad..72a0470 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c

[PATCH v7 0/9] kvm, mem-hotplug: Do not pin ept identity pagetable and apic access page.

2014-09-20 Thread Tang Chen
t in mmu notifier. Tang Chen (9): kvm: Use APIC_DEFAULT_PHYS_BASE macro as the apic access page address. kvm: Remove ept_identity_pagetable from struct kvm_arch. kvm: Make init_rmode_identity_map() return 0 on success. kvm: Add interface to check if secondary exec virtualzed apic accesse

[PATCH v7 4/9] kvm: Add interface to check if secondary exec virtualzed apic accesses is enabled.

2014-09-20 Thread Tang Chen
condary exec virtualzed apic accesses is enabled. This patch adds an interface to check if L2's secondary exec virtualzed apic accesses is enabled, because vmx cannot be accessed outside vmx.c. Signed-off-by: Tang Chen --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/svm.c

[PATCH v7 5/9] kvm, mem-hotplug: Reload L1's apic access page in vcpu_enter_guest().

2014-09-20 Thread Tang Chen
are in L2 and if L2's secondary exec virtualzed apic accesses is enabled. Signed-off-by: Tang Chen --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/svm.c | 6 ++ arch/x86/kvm/vmx.c | 6 ++ arch/x86/kvm/x86.c | 23 +++ in

[PATCH v7 6/9] kvm: Rename make_all_cpus_request() to kvm_make_all_cpus_request() and make it non-static.

2014-09-20 Thread Tang Chen
Since different architectures need different handling, we will add some arch specific code later. The code may need to make cpu requests outside kvm_main.c, so make it non-static and rename it to kvm_make_all_cpus_request(). Signed-off-by: Tang Chen --- include/linux/kvm_host.h | 1 + virt

[PATCH v7 9/9] kvm, mem-hotplug: Unpin and remove kvm_arch->apic_access_page.

2014-09-20 Thread Tang Chen
v Signed-off-by: Tang Chen --- arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/vmx.c | 15 +-- arch/x86/kvm/x86.c | 16 +++- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/in

[PATCH v7 8/9] kvm, mem-hotplug: Add arch specific mmu notifier to handle apic access migration.

2014-09-20 Thread Tang Chen
s in the next L2->L1 exit. This patch force a L1->L0 exit or L2->L0 exit when shared apic access page is migrated using mmu notifier. Since apic access page is only used on intel x86, this is arch specific code. Signed-off-by: Tang Chen --- arch/x86/kvm/x86.c | 11

[PATCH v7 7/9] kvm, mem-hotplug: Reload L1's apic access page on migration when L2 is running.

2014-09-20 Thread Tang Chen
s in the next L2->L1 exit. This patch handles 3). In L0->L2 entry, L2's vmcs will be updated in prepare_vmcs02() called by nested_vm_run(). So we need to do nothing. In L2->L1 exit, this patch requests apic access page reload in L2->L1 vmexit. Signed-off-by: Tang Chen -

[PATCH v7 2/9] kvm: Remove ept_identity_pagetable from struct kvm_arch.

2014-09-20 Thread Tang Chen
m_arch->ept_identity_pagetable is removed, ept identity pagetable page is no longer pinned in memory. And it can be migrated/hot-removed. Signed-off-by: Tang Chen Reviewed-by: Gleb Natapov --- arch/x86/include/asm/kvm_host.h | 1 - arch/x86/kvm/vmx.c

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

2014-09-17 Thread Tang Chen
On 09/16/2014 07:24 PM, Paolo Bonzini wrote: Il 16/09/2014 12:42, Tang Chen ha scritto: diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 33712fb..0df82c1 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -210,6 +210,11 @@ void kvm_make_scan_ioapic_request(struct kvm

[PATCH v6 1/6] kvm: Use APIC_DEFAULT_PHYS_BASE macro as the apic access page address.

2014-09-16 Thread Tang Chen
We have APIC_DEFAULT_PHYS_BASE defined as 0xfee0, which is also the address of apic access page. So use this macro. Signed-off-by: Tang Chen Reviewed-by: Gleb Natapov --- arch/x86/kvm/svm.c | 3 ++- arch/x86/kvm/vmx.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff

[PATCH v6 3/6] kvm: Make init_rmode_identity_map() return 0 on success.

2014-09-16 Thread Tang Chen
success, -errno on failure. Signed-off-by: Tang Chen --- arch/x86/kvm/vmx.c | 31 +++ 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 4fb84ad..72a0470 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c

[PATCH v6 0/6] kvm, mem-hotplug: Do not pin ept identity pagetable and apic access page.

2014-09-16 Thread Tang Chen
patch 7 since we are not able to handle the situation in nested vm. Tang Chen (6): kvm: Use APIC_DEFAULT_PHYS_BASE macro as the apic access page address. kvm: Remove ept_identity_pagetable from struct kvm_arch. kvm: Make init_rmode_identity_map() return 0 on success. kvm, mem-hotplug: R

[PATCH v6 2/6] kvm: Remove ept_identity_pagetable from struct kvm_arch.

2014-09-16 Thread Tang Chen
m_arch->ept_identity_pagetable is removed, ept identity pagetable page is no longer pinned in memory. And it can be migrated/hot-removed. Signed-off-by: Tang Chen Reviewed-by: Gleb Natapov --- arch/x86/include/asm/kvm_host.h | 1 - arch/x86/kvm/vmx.c

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

2014-09-16 Thread Tang Chen
->arch.apic_access_page to the new page. Signed-off-by: Tang Chen --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/svm.c | 6 ++ arch/x86/kvm/vmx.c | 6 ++ arch/x86/kvm/x86.c | 15 +++ include/linux/kvm_host.h|

[PATCH v6 5/6] kvm, mem-hotplug: Reload L1's apic access page on migration when L2 is running.

2014-09-16 Thread Tang Chen
address for all L2 vmcs. And this patch requests apic access page reload in L2->L1 vmexit. Signed-off-by: Tang Chen --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/vmx.c | 6 ++ arch/x86/kvm/x86.c | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-)

[PATCH v6 6/6] kvm, mem-hotplug: Unpin and remove kvm_arch->apic_access_page.

2014-09-16 Thread Tang Chen
v Signed-off-by: Tang Chen --- arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/vmx.c | 15 +-- arch/x86/kvm/x86.c | 15 +-- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/in

[PATCH v5 1/7] kvm: Use APIC_DEFAULT_PHYS_BASE macro as the apic access page address.

2014-09-10 Thread Tang Chen
We have APIC_DEFAULT_PHYS_BASE defined as 0xfee0, which is also the address of apic access page. So use this macro. Signed-off-by: Tang Chen Reviewed-by: Gleb Natapov --- arch/x86/kvm/svm.c | 3 ++- arch/x86/kvm/vmx.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff

[PATCH v5 2/7] kvm: Remove ept_identity_pagetable from struct kvm_arch.

2014-09-10 Thread Tang Chen
m_arch->ept_identity_pagetable is removed, ept identity pagetable page is no longer pinned in memory. And it can be migrated/hot-removed. Signed-off-by: Tang Chen Reviewed-by: Gleb Natapov --- arch/x86/include/asm/kvm_host.h | 1 - arch/x86/kvm/vmx.c

[PATCH v5 0/7] kvm, mem-hotplug: Do not pin ept identity pagetable and apic access page.

2014-09-10 Thread Tang Chen
. Patch 7/7: Remove nested_vmx->apic_access_page. Tang Chen (7): kvm: Use APIC_DEFAULT_PHYS_BASE macro as the apic access page address. kvm: Remove ept_identity_pagetable from struct kvm_arch. kvm: Make init_rmode_identity_map() return 0 on success. kvm, mem-hotplug: Reload L1'

[PATCH v5 3/7] kvm: Make init_rmode_identity_map() return 0 on success.

2014-09-10 Thread Tang Chen
success, -errno on failure. Signed-off-by: Tang Chen --- arch/x86/kvm/vmx.c | 25 +++-- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 953d529..63c4c3e 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c

[PATCH v5 7/7] kvm, mem-hotplug: Unpin and remove nested_vmx->apic_access_page.

2014-09-10 Thread Tang Chen
Just like we removed kvm_arch->apic_access_page, nested_vmx->apic_access_page becomes useless for the same reason. This patch removes nested_vmx->apic_access_page, and use gfn_to_page() to pin it in memory when we need it, and unpin it after then. Signed-off-by: Tang Chen --- arc

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

2014-09-10 Thread Tang Chen
->arch.apic_access_page to the new page. Signed-off-by: Tang Chen --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/svm.c | 6 ++ arch/x86/kvm/vmx.c | 6 ++ arch/x86/kvm/x86.c | 15 +++ include/linux/kvm_host.h|

[PATCH v5 6/7] kvm, mem-hotplug: Unpin and remove kvm_arch->apic_access_page.

2014-09-10 Thread Tang Chen
v Signed-off-by: Tang Chen --- arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/vmx.c | 32 +--- arch/x86/kvm/x86.c | 15 +-- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b

[PATCH v5 5/7] kvm, mem-hotplug: Reload L1's apic access page on migration when L2 is running.

2014-09-10 Thread Tang Chen
address for all L2 vmcs. And this patch requests apic access page reload in L2->L1 vmexit. Signed-off-by: Tang Chen --- arch/x86/kvm/vmx.c | 7 +++ virt/kvm/kvm_main.c | 1 + 2 files changed, 8 insertions(+) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index da6d55d..e7704b2 10

[PATCH v4 0/6] kvm, mem-hotplug: Do not pin ept identity pagetable and apic access page.

2014-08-27 Thread Tang Chen
other pages in memory, if user uses nested vm, memory hot-remove will not work. Change log v3 -> v4: 1. The original patch 6 is now patch 5. ( by Jan Kiszka ) 2. The original patch 1 is now patch 6 since we should unpin apic access page at the very last moment. Tang Chen (6):

[PATCH v4 2/6] kvm: Remove ept_identity_pagetable from struct kvm_arch.

2014-08-27 Thread Tang Chen
m_arch->ept_identity_pagetable is removed, ept identity pagetable page is no longer pinned in memory. And it can be migrated/hot-removed. Signed-off-by: Tang Chen --- arch/x86/include/asm/kvm_host.h | 1 - arch/x86/kvm/vmx.c | 50 -

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

2014-08-27 Thread Tang Chen
->arch.apic_access_page to the new page. Signed-off-by: Tang Chen --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/svm.c | 6 ++ arch/x86/kvm/vmx.c | 6 ++ arch/x86/kvm/x86.c | 15 +++ include/linux/kvm_host.h|

[PATCH v4 6/6] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-08-27 Thread Tang Chen
gfn_to_page() will finally call hva_to_pfn() to get the pfn, and pin the page in memory by calling GUP functions. This function unpins the page. After this patch, acpi access page is able to be migrated. Signed-off-by: Tang Chen --- arch/x86/kvm/vmx.c | 2 +- arch/x86/kvm/x86.c

[PATCH v4 5/6] kvm, mem-hotplug: Reload L1's apic access page on migration when L2 is running.

2014-08-27 Thread Tang Chen
address for all L2 vmcs. And this patch requests apic access page reload in L2->L1 vmexit. Signed-off-by: Tang Chen --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/svm.c | 6 ++ arch/x86/kvm/vmx.c | 32 arch/x86/kvm/

[PATCH v4 3/6] kvm: Make init_rmode_identity_map() return 0 on success.

2014-08-27 Thread Tang Chen
success, -errno on failure. Signed-off-by: Tang Chen --- arch/x86/kvm/vmx.c | 25 +++-- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 953d529..63c4c3e 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c

[PATCH v4 1/6] kvm: Use APIC_DEFAULT_PHYS_BASE macro as the apic access page address.

2014-08-27 Thread Tang Chen
We have APIC_DEFAULT_PHYS_BASE defined as 0xfee0, which is also the address of apic access page. So use this macro. Signed-off-by: Tang Chen --- arch/x86/kvm/svm.c | 3 ++- arch/x86/kvm/vmx.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/svm.c b

[PATCH v3 1/6] kvm: Add gfn_to_page_no_pin() to translate gfn to page without pinning.

2014-07-23 Thread Tang Chen
gfn_to_page() will finally call hva_to_pfn() to get the pfn, and pin the page in memory by calling GUP functions. This function unpins the page. Will be used by the followed patches. Signed-off-by: Tang Chen --- include/linux/kvm_host.h | 1 + virt/kvm/kvm_main.c | 17

[PATCH v3 6/6] kvm, mem-hotplug: Reload L1's apic access page if it is migrated when L2 is running.

2014-07-23 Thread Tang Chen
address for all L2 vmcs. And this patch requests apic access page reload in L2->L1 vmexit. Signed-off-by: Tang Chen --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/svm.c | 6 ++ arch/x86/kvm/vmx.c | 37 ++

[PATCH v3 5/6] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-23 Thread Tang Chen
->arch.apic_access_page to the new page. Signed-off-by: Tang Chen --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/svm.c | 6 ++ arch/x86/kvm/vmx.c | 8 +++- arch/x86/kvm/x86.c | 17 +++-- include/linux/kvm_host.h|

[PATCH v3 0/6] kvm, mem-hotplug: Do not pin ept identity pagetable and apic access page.

2014-07-23 Thread Tang Chen
IC_PAGE_RELOAD request. 3. In [PATCH 5/5], add set_apic_access_page_addr() for svm. Tang Chen (6): kvm: Add gfn_to_page_no_pin() to translate gfn to page without pinning. kvm: Use APIC_DEFAULT_PHYS_BASE macro as the apic access page address. kvm: Remove ept_identity_pagetable from

[PATCH v3 4/6] kvm: Make init_rmode_identity_map() return 0 on success.

2014-07-23 Thread Tang Chen
success, -errno on failure. Signed-off-by: Tang Chen --- arch/x86/kvm/vmx.c | 25 +++-- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index b8bf47d..6ab4f87 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c

[PATCH v3 3/6] kvm: Remove ept_identity_pagetable from struct kvm_arch.

2014-07-23 Thread Tang Chen
m_arch->ept_identity_pagetable is removed, ept identity pagetable page is no longer pinned in memory. And it can be migrated/hot-removed. Signed-off-by: Tang Chen --- arch/x86/include/asm/kvm_host.h | 1 - arch/x86/kvm/vmx.c | 50 -

[PATCH v3 2/6] kvm: Use APIC_DEFAULT_PHYS_BASE macro as the apic access page address.

2014-07-23 Thread Tang Chen
We have APIC_DEFAULT_PHYS_BASE defined as 0xfee0, which is also the address of apic access page. So use this macro. Signed-off-by: Tang Chen --- arch/x86/kvm/svm.c | 3 ++- arch/x86/kvm/vmx.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/svm.c b

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-18 Thread Tang Chen
Hi Gleb, On 07/17/2014 09:57 PM, Gleb Natapov wrote: On Thu, Jul 17, 2014 at 09:34:20PM +0800, Tang Chen wrote: Hi Gleb, On 07/15/2014 08:40 PM, Gleb Natapov wrote: .. And yes, we have the problem you said here. We can migrate the page while L2 vm is running. So I think we should

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-17 Thread Tang Chen
Hi Gleb, On 07/15/2014 08:40 PM, Gleb Natapov wrote: .. And yes, we have the problem you said here. We can migrate the page while L2 vm is running. So I think we should enforce L2 vm to exit to L1. Right ? We can request APIC_ACCESS_ADDR reload during L2->L1 vmexit emulation, so if APIC_A

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-17 Thread Tang Chen
Hi Gleb, Sorry for the delay. Please see below. On 07/15/2014 10:40 PM, Gleb Natapov wrote: .. We can request APIC_ACCESS_ADDR reload during L2->L1 vmexit emulation, so if APIC_ACCESS_ADDR changes while L2 is running it will be reloaded for L1 too. apic pages for L2 and L1 are not the

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-15 Thread Tang Chen
On 07/15/2014 08:40 PM, Gleb Natapov wrote: On Tue, Jul 15, 2014 at 08:28:22PM +0800, Tang Chen wrote: On 07/15/2014 08:09 PM, Gleb Natapov wrote: On Tue, Jul 15, 2014 at 01:52:40PM +0200, Jan Kiszka wrote: .. I cannot follow your concerns yet. Specifically, how should APIC_ACCESS_ADDR

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-15 Thread Tang Chen
On 07/15/2014 08:09 PM, Gleb Natapov wrote: On Tue, Jul 15, 2014 at 01:52:40PM +0200, Jan Kiszka wrote: .. I cannot follow your concerns yet. Specifically, how should APIC_ACCESS_ADDR (the VMCS field, right?) change while L2 is running? We currently pin/unpin on L1->L2/L2->L1, respectively

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-15 Thread Tang Chen
On 07/15/2014 07:52 PM, Jan Kiszka wrote: On 2014-07-14 16:58, Gleb Natapov wrote: .. + struct page *page = gfn_to_page_no_pin(vcpu->kvm, + APIC_DEFAULT_PHYS_BASE>> PAGE_SHIFT); If you do not use kvm->arch.apic_access_page to get current addres

Re: [RESEND PATCH v2 4/5] kvm: Remove ept_identity_pagetable from struct kvm_arch.

2014-07-15 Thread Tang Chen
On 07/14/2014 10:27 PM, Gleb Natapov wrote: .. if (likely(kvm->arch.ept_identity_pagetable_done)) return 1; - ret = 0; identity_map_pfn = kvm->arch.ept_identity_map_addr>> PAGE_SHIFT; + + mutex_lock(&kvm->slots_lock); Why move this out of alloc_i

Re: [RESEND PATCH v2 4/5] kvm: Remove ept_identity_pagetable from struct kvm_arch.

2014-07-14 Thread Tang Chen
Hi Gleb, Please see below. On 07/12/2014 03:44 PM, Gleb Natapov wrote: On Wed, Jul 09, 2014 at 10:08:03AM +0800, Tang Chen wrote: kvm_arch->ept_identity_pagetable holds the ept identity pagetable page. But it is never used to refer to the page at all. In vcpu initialization, it indicates

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-14 Thread Tang Chen
Hi Gleb, Thanks for the reply. Please see below. On 07/12/2014 04:04 PM, Gleb Natapov wrote: On Tue, Jul 08, 2014 at 09:01:32PM +0800, Tang Chen wrote: 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

Re: [PATCH v2 0/5] kvm, mem-hotplug: Do not pin ept identity pagetable and apic access page.

2014-07-10 Thread Tang Chen
hi Gleb, Marcelo, Nadav, Would you please help to review these patches ? Thanks. :) On 07/08/2014 09:01 PM, Tang Chen wrote: ept identity pagetable and apic access page in kvm are pinned in memory. As a result, they cannot be migrated/hot-removed. But actually they don't need to be pinn

[RESEND PATCH v2 4/5] kvm: Remove ept_identity_pagetable from struct kvm_arch.

2014-07-08 Thread Tang Chen
rch->ept_identity_pagetable_done is enough to tell if the ept identity pagetable is initialized. So we can remove ept_identity_pagetable. Signed-off-by: Tang Chen --- arch/x86/include/asm/kvm_host.h | 1 - arch/x86/kvm/vmx.c | 25 +++-- 2 files changed, 11 inse

Re: [PATCH v2 4/5] kvm: Remove ept_identity_pagetable from struct kvm_arch.

2014-07-08 Thread Tang Chen
On 07/08/2014 09:01 PM, Tang Chen wrote: kvm_arch->ept_identity_pagetable holds the ept identity pagetable page. But it is never used to refer to the page at all. In vcpu initialization, it indicates two things: 1. indicates if ept page is allocated 2. indicates if a memory slot for ident

Re: [PATCH v2 0/5] kvm, mem-hotplug: Do not pin ept identity pagetable and apic access page.

2014-07-08 Thread Tang Chen
On 07/08/2014 09:01 PM, Tang Chen wrote: ept identity pagetable and apic access page in kvm are pinned in memory. As a result, they cannot be migrated/hot-removed. But actually they don't need to be pinned in memory. [For ept identity page] Just do not pin it. When it is migrated, guest

[PATCH v2 1/5] kvm: Add gfn_to_page_no_pin() to translate gfn to page without pinning.

2014-07-08 Thread Tang Chen
gfn_to_page() will finally call hva_to_pfn() to get the pfn, and pin the page in memory by calling GUP functions. This function unpins the page. Will be used by the followed patches. Signed-off-by: Tang Chen --- include/linux/kvm_host.h | 1 + virt/kvm/kvm_main.c | 17

[PATCH v2 4/5] kvm: Remove ept_identity_pagetable from struct kvm_arch.

2014-07-08 Thread Tang Chen
rch->ept_identity_pagetable_done is enough to tell if the ept identity pagetable is initialized. So we can remove ept_identity_pagetable. Signed-off-by: Tang Chen --- arch/x86/include/asm/kvm_host.h | 1 - arch/x86/kvm/vmx.c | 25 +++-- 2 files changed, 11 inse

[PATCH v2 2/5] kvm: Use APIC_DEFAULT_PHYS_BASE macro as the apic access page address.

2014-07-08 Thread Tang Chen
We have APIC_DEFAULT_PHYS_BASE defined as 0xfee0, which is also the address of apic access page. So use this macro. Signed-off-by: Tang Chen --- arch/x86/kvm/svm.c | 3 ++- arch/x86/kvm/vmx.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/svm.c b

[PATCH v2 3/5] kvm, mem-hotplug: Do not pin ept identity pagetable in memory.

2014-07-08 Thread Tang Chen
page. And in the next ept violation, the new page will be found by ept violation handler. This patch just unpin the ept identity page because it is not necessary. Signed-off-by: Tang Chen --- arch/x86/kvm/vmx.c | 3 ++- arch/x86/kvm/x86.c | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-)

[PATCH v2 0/5] kvm, mem-hotplug: Do not pin ept identity pagetable and apic access page.

2014-07-08 Thread Tang Chen
kvm_arch->ept_identity_pagetable. 2. In [PATCH 3/5], only introduce KVM_REQ_APIC_PAGE_RELOAD request. 3. In [PATCH 3/5], add set_apic_access_page_addr() for svm. Tang Chen (5): kvm: Add gfn_to_page_no_pin() to translate gfn to page without pinning. kvm: Use APIC_DEFAULT_PHYS_BASE macro as the apic

[PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-08 Thread Tang Chen
->arch.apic_access_page to the new page. Signed-off-by: Tang Chen --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/mmu.c | 11 +++ arch/x86/kvm/svm.c | 6 ++ arch/x86/kvm/vmx.c | 8 +++- arch/x86/kvm/x86.c |

Re: [PATCH 4/4] kvm, mem-hotplug: Update apic access page when it is migrated.

2014-07-08 Thread Tang Chen
Hi Wanpeng, On 07/07/2014 06:35 PM, Wanpeng Li wrote: On Wed, Jul 02, 2014 at 05:00:37PM +0800, Tang Chen wrote: apic access page is pinned in memory, and as a result it cannot be migrated/hot-removed. Actually it doesn't need to be pinned in memory. This patch introduces a new vcpu re

Re: [PATCH 4/4] kvm, mem-hotplug: Update apic access page when it is migrated.

2014-07-07 Thread Tang Chen
Hi Nadav, Thanks for the reply, please see below. On 07/07/2014 08:10 PM, Nadav Amit wrote: On 7/7/14, 2:54 PM, Gleb Natapov wrote: On Mon, Jul 07, 2014 at 02:42:27PM +0300, Nadav Amit wrote: Tang, Running some (unrelated) tests I see that KVM does not handle APIC base relocation correctly.

Re: [PATCH 4/4] kvm, mem-hotplug: Update apic access page when it is migrated.

2014-07-07 Thread Tang Chen
tomorrow. ;) Thanks. On 07/04/2014 06:13 PM, Gleb Natapov wrote: On Fri, Jul 04, 2014 at 10:18:25AM +0800, Tang Chen wrote: Hi Gleb, Thanks for the advices. Please see below. On 07/03/2014 09:55 PM, Gleb Natapov wrote: .. @@ -575,6 +575,7 @@ struct kvm_arch { unsigned int

Re: [PATCH 4/4] kvm, mem-hotplug: Update apic access page when it is migrated.

2014-07-06 Thread Tang Chen
Hi Gleb, Thanks for all the advices. Please see below. On 07/04/2014 06:13 PM, Gleb Natapov wrote: .. +static void vmx_set_apic_access_page_addr(struct kvm *kvm, hpa_t hpa) +{ + if (vm_need_virtualize_apic_accesses(kvm)) This shouldn't even been called if apic access page is not supp

Re: [PATCH 0/4] kvm, mem-hotplug: Do not pin ept identity pagetable and apic access page.

2014-07-03 Thread Tang Chen
Hi Gleb, On 07/03/2014 02:04 PM, Gleb Natapov wrote: On Thu, Jul 03, 2014 at 09:17:59AM +0800, Tang Chen wrote: Hi Gleb, On 07/02/2014 05:00 PM, Tang Chen wrote: Hi Gleb, Marcelo, Please help to review this patch-set. NOTE: This patch-set doesn't work properly. ept identity pagetabl

Re: [PATCH 3/4] kvm, memory-hotplug: Update ept identity pagetable when it is migrated.

2014-07-03 Thread Tang Chen
Hi Gleb, On 07/03/2014 12:34 AM, Gleb Natapov wrote: On Wed, Jul 02, 2014 at 05:00:36PM +0800, Tang Chen wrote: ept identity pagetable is pinned in memory, and as a result it cannot be migrated/hot-removed. But actually it doesn't need to be pinned in memory. This patch introduces a new

Re: [PATCH 4/4] kvm, mem-hotplug: Update apic access page when it is migrated.

2014-07-03 Thread Tang Chen
Hi Gleb, Thanks for the advices. Please see below. On 07/03/2014 09:55 PM, Gleb Natapov wrote: .. @@ -575,6 +575,7 @@ struct kvm_arch { unsigned int tss_addr; struct page *apic_access_page; + bool apic_access_page_migrated; Better have two requests KVM_REQ_APIC_PAGE_

Re: [PATCH 4/4] kvm, mem-hotplug: Update apic access page when it is migrated.

2014-07-03 Thread Tang Chen
Hi Gleb, Thanks for the advices. Please see below. On 07/03/2014 09:55 PM, Gleb Natapov wrote: .. @@ -575,6 +575,7 @@ struct kvm_arch { unsigned int tss_addr; struct page *apic_access_page; + bool apic_access_page_migrated; Better have two requests KVM_REQ_APIC_PAGE_

Re: [PATCH 3/4] kvm, memory-hotplug: Update ept identity pagetable when it is migrated.

2014-07-02 Thread Tang Chen
On 07/03/2014 12:34 AM, Gleb Natapov wrote: On Wed, Jul 02, 2014 at 05:00:36PM +0800, Tang Chen wrote: ept identity pagetable is pinned in memory, and as a result it cannot be migrated/hot-removed. But actually it doesn't need to be pinned in memory. This patch introduces a new vcpu re

Re: [PATCH 2/4] kvm: Add macro VMX_APIC_ACCESS_PAGE_ADDR

2014-07-02 Thread Tang Chen
On 07/03/2014 12:24 AM, Gleb Natapov wrote: On Wed, Jul 02, 2014 at 05:00:35PM +0800, Tang Chen wrote: Define guest phys_addr of apic access page. --- arch/x86/include/asm/vmx.h | 2 +- arch/x86/kvm/svm.c | 3 ++- arch/x86/kvm/vmx.c | 7 --- 3 files changed, 7

Re: [PATCH 0/4] kvm, mem-hotplug: Do not pin ept identity pagetable and apic access page.

2014-07-02 Thread Tang Chen
Hi Gleb, On 07/02/2014 05:00 PM, Tang Chen wrote: Hi Gleb, Marcelo, Please help to review this patch-set. NOTE: This patch-set doesn't work properly. ept identity pagetable and apic access page in kvm are pinned in memory. As a result, they cannot be migrated/hot-removed. But actually

[PATCH 3/4] kvm, memory-hotplug: Update ept identity pagetable when it is migrated.

2014-07-02 Thread Tang Chen
ept identity pagetable is pinned in memory, and as a result it cannot be migrated/hot-removed. But actually it doesn't need to be pinned in memory. This patch introduces a new vcpu request: KVM_REQ_MIGRATE_EPT to reset ept indetity pagetable related variable. This request will be made when kvm_mm

[PATCH 0/4] kvm, mem-hotplug: Do not pin ept identity pagetable and apic access page.

2014-07-02 Thread Tang Chen
age(). And reset it to new page's host physical address in tdp_page_fault(). But it seems that guest will access apic page directly by the host physical address. Tang Chen (4): kvm: Add gfn_to_page_no_pin() kvm: Add macro VMX_APIC_ACCESS_PAGE_ADDR kvm, memory-hotplug: Update ept identity

[PATCH 1/4] kvm: Add gfn_to_page_no_pin()

2014-07-02 Thread Tang Chen
Used by the followed patches. --- include/linux/kvm_host.h | 1 + virt/kvm/kvm_main.c | 17 - 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index ec4e3bd..7c58d9d 100644 --- a/include/linux/kvm_host.h +++ b/

[PATCH 0/4] kvm, mem-hotplug: Do not pin ept identity pagetable and apic access page.

2014-07-02 Thread Tang Chen
age(). And reset it to new page's host physical address in tdp_page_fault(). But it seems that guest will access apic page directly by the host physical address. Tang Chen (4): kvm: Add gfn_to_page_no_pin() kvm: Add macro VMX_APIC_ACCESS_PAGE_ADDR kvm, memory-hotplug: Update ept identity

[PATCH 2/4] kvm: Add macro VMX_APIC_ACCESS_PAGE_ADDR

2014-07-02 Thread Tang Chen
Define guest phys_addr of apic access page. --- arch/x86/include/asm/vmx.h | 2 +- arch/x86/kvm/svm.c | 3 ++- arch/x86/kvm/vmx.c | 7 --- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h index 7004d21..c4672

[PATCH 4/4] kvm, mem-hotplug: Update apic access page when it is migrated.

2014-07-02 Thread Tang Chen
apic access page is pinned in memory, and as a result it cannot be migrated/hot-removed. Actually it doesn't need to be pinned in memory. This patch introduces a new vcpu request: KVM_REQ_MIGRATE_EPT. This requet will be made when kvm_mmu_notifier_invalidate_page() is called when the page is unma

Re: [RFC PATCH 1/1] Move two pinned pages to non-movable node in kvm.

2014-06-30 Thread Tang Chen
Hi Gleb, On 06/30/2014 02:00 PM, Gleb Natapov wrote: On Mon, Jun 30, 2014 at 09:45:32AM +0800, Tang Chen wrote: On 06/21/2014 04:39 AM, Marcelo Tosatti wrote: On Fri, Jun 20, 2014 at 05:31:46PM -0300, Marcelo Tosatti wrote: IIRC your shadow page pinning patch series support flushing of ptes

Re: [RFC PATCH 1/1] Move two pinned pages to non-movable node in kvm.

2014-06-29 Thread Tang Chen
On 06/21/2014 04:39 AM, Marcelo Tosatti wrote: On Fri, Jun 20, 2014 at 05:31:46PM -0300, Marcelo Tosatti wrote: IIRC your shadow page pinning patch series support flushing of ptes by mmu notifier by forcing MMU reload and, as a result, faulting in of pinned pages during next entry. Your patch s

Re: [RFC PATCH 1/1] Move two pinned pages to non-movable node in kvm.

2014-06-22 Thread Tang Chen
Hi Marcelo, Gleb, Sorry for the delayed reply and thanks for the advices. On 06/21/2014 04:39 AM, Marcelo Tosatti wrote: On Fri, Jun 20, 2014 at 05:31:46PM -0300, Marcelo Tosatti wrote: IIRC your shadow page pinning patch series support flushing of ptes by mmu notifier by forcing MMU reload an

Re: [RFC PATCH 1/1] Move two pinned pages to non-movable node in kvm.

2014-06-19 Thread Tang Chen
Hi Marcelo, Thanks for your reply. Please see below. On 06/20/2014 03:00 AM, Marcelo Tosatti wrote: .. Remove pinning is preferable. In fact looks like for identity pagetable it should be trivial, just don't pin. APIC access page is a little bit more complicated since its physical address n

Re: [RFC PATCH 1/1] Move two pinned pages to non-movable node in kvm.

2014-06-17 Thread Tang Chen
Hi Gleb, Thanks for the quick reply. Please see below. On 06/18/2014 02:12 PM, Gleb Natapov wrote: On Wed, Jun 18, 2014 at 01:50:00PM +0800, Tang Chen wrote: [Questions] And by the way, would you guys please answer the following questions for me ? 1. What's the ept identity pagetabl

[RFC PATCH 1/1] Move two pinned pages to non-movable node in kvm.

2014-06-17 Thread Tang Chen
allocated in qemu userspace. Can we allocate it in kernel space ? 4. If I want to migrate these two pages, what do you think is the best way ? Thanks. Signed-off-by: Tang Chen --- arch/x86/include/asm/numa.h | 1 + arch/x86/kvm/vmx.c | 5 + arch/x86/kvm/x86.c