Re: [PATCH v2 09/11] KVM: MMU: simplify mmu_need_write_protect

2015-12-24 Thread Kai Huang
On 12/23/2015 07:25 PM, Xiao Guangrong wrote: Now, all non-leaf shadow page are page tracked, if gfn is not tracked there is no non-leaf shadow page of gfn is existed, we can directly make the shadow page of gfn to unsync Signed-off-by: Xiao Guangrong ---

Re: [PATCH v2 09/11] KVM: MMU: simplify mmu_need_write_protect

2015-12-24 Thread Kai Huang
On 12/24/2015 05:11 PM, Xiao Guangrong wrote: On 12/24/2015 04:36 PM, Kai Huang wrote: On 12/23/2015 07:25 PM, Xiao Guangrong wrote: Now, all non-leaf shadow page are page tracked, if gfn is not tracked there is no non-leaf shadow page of gfn is existed, we can directly make the shadow

Re: [PATCH 08/11] KVM: MMU: use page track for non-leaf shadow pages

2015-12-16 Thread Kai Huang
On 12/16/2015 04:39 PM, Xiao Guangrong wrote: On 12/16/2015 03:51 PM, Kai Huang wrote: On 12/15/2015 05:10 PM, Xiao Guangrong wrote: On 12/15/2015 03:52 PM, Kai Huang wrote: static bool __mmu_gfn_lpage_is_disallowed(gfn_t gfn, int level, @@ -2140,12 +2150,18 @@ static struct

Re: [PATCH 09/11] KVM: MMU: simplify mmu_need_write_protect

2015-12-16 Thread Kai Huang
On 12/16/2015 04:48 PM, Xiao Guangrong wrote: On 12/16/2015 04:05 PM, Kai Huang wrote: On 12/15/2015 05:25 PM, Xiao Guangrong wrote: On 12/15/2015 04:43 PM, Kai Huang wrote: On 12/01/2015 02:26 AM, Xiao Guangrong wrote: Now, all non-leaf shadow page are page tracked, if gfn

Re: [PATCH 09/11] KVM: MMU: simplify mmu_need_write_protect

2015-12-16 Thread Kai Huang
On 12/15/2015 05:25 PM, Xiao Guangrong wrote: On 12/15/2015 04:43 PM, Kai Huang wrote: On 12/01/2015 02:26 AM, Xiao Guangrong wrote: Now, all non-leaf shadow page are page tracked, if gfn is not tracked there is no non-leaf shadow page of gfn is existed, we can directly make the shadow

Re: [PATCH 06/11] KVM: MMU: let page fault handler be aware tracked page

2015-12-15 Thread Kai Huang
On 12/01/2015 02:26 AM, Xiao Guangrong wrote: The page fault caused by write access on the write tracked page can not be fixed, it always need to be emulated. page_fault_handle_page_track() is the fast path we introduce here to skip holding mmu-lock and shadow page table walking Why can it be

Re: [PATCH 09/11] KVM: MMU: simplify mmu_need_write_protect

2015-12-15 Thread Kai Huang
On 12/15/2015 04:43 PM, Kai Huang wrote: On 12/01/2015 02:26 AM, Xiao Guangrong wrote: Now, all non-leaf shadow page are page tracked, if gfn is not tracked there is no non-leaf shadow page of gfn is existed, we can directly make the shadow page of gfn to unsync Signed-off-by: Xiao

Re: [PATCH 08/11] KVM: MMU: use page track for non-leaf shadow pages

2015-12-15 Thread Kai Huang
On 12/15/2015 03:52 PM, Kai Huang wrote: On 12/01/2015 02:26 AM, Xiao Guangrong wrote: non-leaf shadow pages are always write protected, it can be the user of page track Signed-off-by: Xiao Guangrong <guangrong.x...@linux.intel.com> --- arch/x86/include/asm/kvm_page_track.

Re: [PATCH 09/11] KVM: MMU: simplify mmu_need_write_protect

2015-12-15 Thread Kai Huang
On 12/01/2015 02:26 AM, Xiao Guangrong wrote: Now, all non-leaf shadow page are page tracked, if gfn is not tracked there is no non-leaf shadow page of gfn is existed, we can directly make the shadow page of gfn to unsync Signed-off-by: Xiao Guangrong ---

Re: [PATCH 05/11] KVM: page track: introduce kvm_page_track_{add,remove}_page

2015-12-15 Thread Kai Huang
On 12/15/2015 03:15 PM, Kai Huang wrote: On 12/01/2015 02:26 AM, Xiao Guangrong wrote: These two functions are the user APIs: - kvm_page_track_add_page(): add the page to the tracking pool after that later specified access on that page will be tracked - kvm_page_track_remove_page

Re: [PATCH 04/11] KVM: page track: add the framework of guest page tracking

2015-12-15 Thread Kai Huang
On 12/15/2015 04:46 PM, Xiao Guangrong wrote: On 12/15/2015 03:06 PM, Kai Huang wrote: Hi Guangrong, I am starting to review this series, and should have some comments or questions, you can determine whether they are valuable :) Thank you very much for your review and breaking

Re: [PATCH 08/11] KVM: MMU: use page track for non-leaf shadow pages

2015-12-15 Thread Kai Huang
On 12/15/2015 05:10 PM, Xiao Guangrong wrote: On 12/15/2015 03:52 PM, Kai Huang wrote: static bool __mmu_gfn_lpage_is_disallowed(gfn_t gfn, int level, @@ -2140,12 +2150,18 @@ static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu, hlist_add_head(>hash_link, &

Re: [PATCH 06/11] KVM: MMU: let page fault handler be aware tracked page

2015-12-15 Thread Kai Huang
On 12/15/2015 05:03 PM, Xiao Guangrong wrote: On 12/15/2015 04:11 PM, Kai Huang wrote: On 12/01/2015 02:26 AM, Xiao Guangrong wrote: The page fault caused by write access on the write tracked page can not be fixed, it always need to be emulated. page_fault_handle_page_track() is the fast

Re: [PATCH 08/11] KVM: MMU: use page track for non-leaf shadow pages

2015-12-14 Thread Kai Huang
On 12/01/2015 02:26 AM, Xiao Guangrong wrote: non-leaf shadow pages are always write protected, it can be the user of page track Signed-off-by: Xiao Guangrong --- arch/x86/include/asm/kvm_page_track.h | 8 + arch/x86/kvm/mmu.c| 26

Re: [PATCH 04/11] KVM: page track: add the framework of guest page tracking

2015-12-14 Thread Kai Huang
Hi Guangrong, I am starting to review this series, and should have some comments or questions, you can determine whether they are valuable :) See below. On 12/01/2015 02:26 AM, Xiao Guangrong wrote: The array, gfn_track[mode][gfn], is introduced in memory slot for every guest page, this is

Re: [PATCH 05/11] KVM: page track: introduce kvm_page_track_{add,remove}_page

2015-12-14 Thread Kai Huang
On 12/01/2015 02:26 AM, Xiao Guangrong wrote: These two functions are the user APIs: - kvm_page_track_add_page(): add the page to the tracking pool after that later specified access on that page will be tracked - kvm_page_track_remove_page(): remove the page from the tracking pool, the

Re: [v2] KVM: VMX: Fix commit which broke PML

2015-11-04 Thread Kai Huang
pml_pg); vmx->pml_pg = NULL; - - vmcs_clear_bits(SECONDARY_VM_EXEC_CONTROL, SECONDARY_EXEC_ENABLE_PML); } Thanks, -Kai On 11/04/2015 08:00 PM, Paolo Bonzini wrote: On 04/11/2015 06:46, Kai Huang wrote: I found PML was broken since below commit:

[v2] KVM: VMX: Fix commit which broke PML

2015-11-03 Thread Kai Huang
rename vmx_enable{disable}_pml to vmx_create{destroy}_pml_buffer. Signed-off-by: Kai Huang <kai.hu...@linux.intel.com> --- v1->v2: Fix this by following Paolo's suggestion. It's better to not to clear SECONDARY_EXEC_ENABLE_PML in vmx_secondary_exec_control unconditionally but only clear i

Re: [PATCH] KVM: VMX: Fix commit which broke PML

2015-11-03 Thread Kai Huang
On 11/03/2015 05:59 PM, Paolo Bonzini wrote: On 03/11/2015 06:49, Kai Huang wrote: I found PML was broken since below commit: commit feda805fe7c4ed9cf78158e73b1218752e3b4314 Author: Xiao Guangrong <guangrong.x...@linux.intel.com> Date: Wed Sep 9 14:05:55 2015

[RESEND PATCH v2] KVM: VMX: Fix commit which broke PML

2015-11-03 Thread Kai Huang
rename vmx_enable{disable}_pml to vmx_create{destroy}_pml_buffer. Signed-off-by: Kai Huang <kai.hu...@linux.intel.com> --- Sorry previous patch missed PATCH subject prefix. Resend by fixing that. v1->v2: Fix this by following Paolo's suggestion. It's better to not to clea

[PATCH] KVM: VMX: Fix commit which broke PML

2015-11-02 Thread Kai Huang
C_CONTROL directly. Signed-off-by: Kai Huang <kai.hu...@linux.intel.com> --- arch/x86/kvm/vmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 4d0aa31..4525c0a7 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -

Re: [PATCH 6/6] KVM: VMX: Add PML support in VMX

2015-02-05 Thread Kai Huang
On 02/05/2015 11:04 PM, Radim Krčmář wrote: 2015-02-05 14:23+0800, Kai Huang: On 02/03/2015 11:18 PM, Radim Krčmář wrote: You have it protected by CONFIG_X86_64, but use it unconditionally. Thanks for catching. This has been fixed by another patch, and the fix has also been merged by Paolo

Re: [PATCH 6/6] KVM: VMX: Add PML support in VMX

2015-02-05 Thread Kai Huang
On 02/05/2015 11:04 PM, Radim Krčmář wrote: 2015-02-05 14:23+0800, Kai Huang: On 02/03/2015 11:18 PM, Radim Krčmář wrote: You have it protected by CONFIG_X86_64, but use it unconditionally. Thanks for catching. This has been fixed by another patch, and the fix has also been merged by Paolo

Re: [PATCH 2/6] KVM: MMU: Add mmu help functions to support PML

2015-02-04 Thread Kai Huang
On 02/04/2015 01:34 AM, Radim Krčmář wrote: 2015-01-28 10:54+0800, Kai Huang: This patch adds new mmu layer functions to clear/set D-bit for memory slot, and to write protect superpages for memory slot. In case of PML, CPU logs the dirty GPA automatically to PML buffer when CPU updates D-bit

Re: [PATCH 6/6] KVM: VMX: Add PML support in VMX

2015-02-04 Thread Kai Huang
On 02/03/2015 11:18 PM, Radim Krčmář wrote: 2015-01-28 10:54+0800, Kai Huang: This patch adds PML support in VMX. A new module parameter 'enable_pml' is added (+module_param_named(pml, enable_pml, bool, S_IRUGO);) to allow user to enable/disable it manually. Signed-off-by: Kai Huang kai.hu

Re: [PATCH 5/6] KVM: x86: Add new dirty logging kvm_x86_ops for PML

2015-02-04 Thread Kai Huang
On 02/03/2015 11:53 PM, Radim Krčmář wrote: 2015-01-28 10:54+0800, Kai Huang: This patch adds new kvm_x86_ops dirty logging hooks to enable/disable dirty logging for particular memory slot, and to flush potentially logged dirty GPAs before reporting slot-dirty_bitmap to userspace. kvm x86

[PATCH] KVM: trace: fix trace_kvm_pml_full build error on i386

2015-01-29 Thread Kai Huang
of CONFIG_X86_64. Tested with Fengguang's .config, and also did sanity test on x86_64. Signed-off-by: Kai Huang kai.hu...@linux.intel.com --- arch/x86/kvm/trace.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h index a139977..7c7bc8b 100644

[PATCH 3/6] KVM: MMU: Explicitly set D-bit for writable spte.

2015-01-27 Thread Kai Huang
of PML. For the hva - pa change case, the spte is updated to either read-only (host pte is read-only) or be dropped (host pte is writeable), and both cases will be handled by above changes, therefore no change is necessary. Signed-off-by: Kai Huang kai.hu...@linux.intel.com --- arch/x86/kvm/mmu.c

[PATCH 1/6] KVM: Rename kvm_arch_mmu_write_protect_pt_masked to be more generic for log dirty

2015-01-27 Thread Kai Huang
We don't have to write protect guest memory for dirty logging if architecture supports hardware dirty logging, such as PML on VMX, so rename it to be more generic. Signed-off-by: Kai Huang kai.hu...@linux.intel.com --- arch/arm/kvm/mmu.c | 18 -- arch/x86/kvm/mmu.c

[PATCH 5/6] KVM: x86: Add new dirty logging kvm_x86_ops for PML

2015-01-27 Thread Kai Huang
to VMX specific. Other ARCHs won't be impacted as these hooks are NULL for them. Signed-off-by: Kai Huang kai.hu...@linux.intel.com --- arch/x86/include/asm/kvm_host.h | 25 +++ arch/x86/kvm/mmu.c | 6 +++- arch/x86/kvm/x86.c | 71

[PATCH 2/6] KVM: MMU: Add mmu help functions to support PML

2015-01-27 Thread Kai Huang
-bit manually for the slot with dirty logging disabled. Signed-off-by: Kai Huang kai.hu...@linux.intel.com --- arch/x86/include/asm/kvm_host.h | 9 ++ arch/x86/kvm/mmu.c | 195 2 files changed, 204 insertions(+) diff --git a/arch/x86/include

[PATCH 4/6] KVM: x86: Change parameter of kvm_mmu_slot_remove_write_access

2015-01-27 Thread Kai Huang
kvm_userspace_memory_region *' to 'struct kvm_memory_slot * new', but it requires changes on other non-x86 ARCH too, so avoid it now. Signed-off-by: Kai Huang kai.hu...@linux.intel.com --- arch/x86/include/asm/kvm_host.h | 3 ++- arch/x86/kvm/mmu.c | 5 ++--- arch/x86/kvm/x86.c

[PATCH 6/6] KVM: VMX: Add PML support in VMX

2015-01-27 Thread Kai Huang
This patch adds PML support in VMX. A new module parameter 'enable_pml' is added to allow user to enable/disable it manually. Signed-off-by: Kai Huang kai.hu...@linux.intel.com --- arch/x86/include/asm/vmx.h | 4 + arch/x86/include/uapi/asm/vmx.h | 1 + arch/x86/kvm/trace.h

[PATCH 0/6] KVM: VMX: Page Modification Logging (PML) support

2015-01-27 Thread Kai Huang
Protection. Kai Huang (6): KVM: Rename kvm_arch_mmu_write_protect_pt_masked to be more generic for log dirty KVM: MMU: Add mmu help functions to support PML KVM: MMU: Explicitly set D-bit for writable spte. KVM: x86: Change parameter of kvm_mmu_slot_remove_write_access KVM: x86: Add

[PATCH] Optimize TLB flush in kvm_mmu_slot_remove_write_access.

2015-01-11 Thread Kai Huang
Apparently no TLB flush is needed when there's no valid rmap in memory slot. Signed-off-by: Kai Huang kai.hu...@linux.intel.com --- arch/x86/kvm/mmu.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index f83fc6c..d43bf50 100644

[PATCH] Flush TLB when D bit is manually changed.

2015-01-09 Thread Kai Huang
status to do specific things. Sanity test was done on my machine with Intel processor. Signed-off-by: Kai Huang kai.hu...@linux.intel.com --- arch/x86/kvm/mmu.c | 12 1 file changed, 12 insertions(+) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 978f402..1feac0c 100644

Re: Is there any consumer of virtio-balloon now?

2014-03-22 Thread Kai Huang
Thanks Paolo. What's the user space tool / command to trigger the virtio_balloon functionality? Basically I am looking for the whole code patch that triggers the virtio_balloon. Thanks, -Kai On 2014年03月21日 16:51, Paolo Bonzini wrote: Il 21/03/2014 05:22, Kai Huang ha scritto: Hi, I see

Re: Is there any consumer of virtio-balloon now?

2014-03-22 Thread Kai Huang
Just see the reply. Thanks a lot! Thanks, -Kai On 2014年03月21日 17:03, Kashyap Chamarthy wrote: On Fri, Mar 21, 2014 at 12:22:54PM +0800, Kai Huang wrote: Hi, I see the virtio-balloon is designed for memory auto balloon between KVM host and guest, but from latest linux kernel mainline code

Is there any consumer of virtio-balloon now?

2014-03-20 Thread Kai Huang
Hi, I see the virtio-balloon is designed for memory auto balloon between KVM host and guest, but from latest linux kernel mainline code, looks currently there's no consumer actually using it? Would you let me know who is the consumer if there's any? Thanks, -Kai -- To unsubscribe from this list:

Re: [PULL 7/7] vfio: fix mapping of MSIX bar

2014-01-19 Thread Kai Huang
On Sat, Jan 18, 2014 at 3:25 AM, Alex Williamson alex.william...@redhat.com wrote: From: Alexey Kardashevskiy a...@ozlabs.ru VFIO virtualizes MSIX table for the guest but not mapping the part of a BAR which contains an MSIX table. Since vfio_mmap_bar() mmaps chunks before and after the MSIX

Re: [PULL 7/7] vfio: fix mapping of MSIX bar

2014-01-19 Thread Kai Huang
On Sun, Jan 19, 2014 at 10:11 PM, Alex Williamson alex.william...@redhat.com wrote: On Sun, 2014-01-19 at 22:03 +0800, Kai Huang wrote: On Sat, Jan 18, 2014 at 3:25 AM, Alex Williamson alex.william...@redhat.com wrote: From: Alexey Kardashevskiy a...@ozlabs.ru VFIO virtualizes MSIX table

Re: [PATCH v4 2/7] iommu/core: split mapping to page sizes as supported by the hardware

2011-11-09 Thread Kai Huang
-int iommu_unmap(struct iommu_domain *domain, unsigned long iova, int gfp_order) +size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova, size_t size)  { -       size_t size, unmapped; +       size_t unmapped_page, unmapped = 0; +       unsigned int min_pagesz;        if

Re: What's the usage model (purpose) of interrupt remapping in IOMMU?

2011-11-03 Thread Kai Huang
Clear, thanks! -- Forwarded message -- From: Alex Williamson alex.william...@redhat.com Date: Wed, Nov 2, 2011 at 11:31 PM Subject: Re: What's the usage model (purpose) of interrupt remapping in IOMMU? To: Kai Huang mail.kai.hu...@gmail.com Cc: kvm@vger.kernel.org, linux

What's the usage model (purpose) of interrupt remapping in IOMMU?

2011-11-01 Thread Kai Huang
Hi, In case of direct io, without the interrupt remapping in IOMMU (intel VT-d or AMD IOMMU), hypervisor needs to inject interrupt for guest when the guest is scheduled to specific CPU. At the beginning I thought with IOMMU's interrupt remapping, the hardware can directly forward the interrupt to

Cache flush questions of Intel IOMMU

2011-08-23 Thread Kai Huang
Hi all, I am working on Intel iommu staff and I have two questions -- just send to kvm list as I am not sure which mail list should I send to, and it will be very appreciated if you could help to forward to related mail list. Thank you! 1) I see in Intel iommu's manual, caching behavior is