Re: [PATCH v2 1/2] KVM: selftests: Have perf_test_util signal when to stop vCPUs

2022-11-22 Thread Gavin Shan
les changed, 8 insertions(+), 12 deletions(-) Reviewed-by: Gavin Shan diff --git a/tools/testing/selftests/kvm/access_tracking_perf_test.c b/tools/testing/selftests/kvm/access_tracking_perf_test.c index 76c583a07ea2..942370d57392 100644 --- a/tools/testing/selftests/

Re: [PATCH 2/2] KVM: selftests: Build access_tracking_perf_test for arm64

2022-11-12 Thread Gavin Shan
On 11/12/22 7:19 AM, Oliver Upton wrote: Does exactly what it says on the tin. Signed-off-by: Oliver Upton --- tools/testing/selftests/kvm/Makefile | 1 + 1 file changed, 1 insertion(+) Reviewed-by: Gavin Shan diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing

Re: [PATCH 1/2] KVM: selftests: Allow >1 guest mode in access_tracking_perf_test

2022-11-12 Thread Gavin Shan
changed, 3 insertions(+) Reviewed-by: Gavin Shan diff --git a/tools/testing/selftests/kvm/access_tracking_perf_test.c b/tools/testing/selftests/kvm/access_tracking_perf_test.c index 76c583a07ea2..4da066479e0a 100644 --- a/tools/testing/selftests/kvm/access_tracking_perf_test.c +++ b/tools

Re: [PATCH v10 3/7] KVM: Support dirty ring in conjunction with bitmap

2022-11-12 Thread Gavin Shan
Hi Sean, On 11/12/22 8:18 AM, Sean Christopherson wrote: On Sat, Nov 12, 2022, Gavin Shan wrote: On 11/12/22 7:00 AM, Sean Christopherson wrote: On Sat, Nov 12, 2022, Gavin Shan wrote: On 11/11/22 11:19 PM, Marc Zyngier wrote: On Thu, 10 Nov 2022 23:47:41 +, Gavin Shan wrote

[PATCH for-next] KVM: Push dirty information unconditionally to backup bitmap

2022-11-12 Thread Gavin Shan
cpu context, kvm_arch_allow_write_without_running_vcpu() returns 'true', and the backup bitmap (KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP) isn't enabled yet. Suggested-by: Sean Christopherson Signed-off-by: Gavin Shan --- virt/kvm/kvm_main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --

Re: [PATCH v10 3/7] KVM: Support dirty ring in conjunction with bitmap

2022-11-11 Thread Gavin Shan
Hi Sean, On 11/12/22 7:00 AM, Sean Christopherson wrote: On Sat, Nov 12, 2022, Gavin Shan wrote: On 11/11/22 11:19 PM, Marc Zyngier wrote: On Thu, 10 Nov 2022 23:47:41 +, Gavin Shan wrote: But that I don't get. Or rather, I don't get the commit message that matches this hunk. Do we want

Re: [PATCH v10 3/7] KVM: Support dirty ring in conjunction with bitmap

2022-11-11 Thread Gavin Shan
Hi Marc, On 11/11/22 11:19 PM, Marc Zyngier wrote: On Thu, 10 Nov 2022 23:47:41 +, Gavin Shan wrote: commit b05377ecbe003f12c8b79846fa3a300401dcab68 (HEAD -> kvm/arm64_dirtyring) Author: Gavin Shan Date: Fri Nov 11 07:13:12 2022 +0800 KVM: Push dirty information unconditiona

Re: [PATCH v10 3/7] KVM: Support dirty ring in conjunction with bitmap

2022-11-10 Thread Gavin Shan
Hi Sean, On 11/11/22 12:46 AM, Sean Christopherson wrote: On Thu, Nov 10, 2022, Gavin Shan wrote: @@ -3305,7 +3305,10 @@ void mark_page_dirty_in_slot(struct kvm *kvm, struct kvm_vcpu *vcpu = kvm_get_running_vcpu(); #ifdef CONFIG_HAVE_KVM_DIRTY_RING - if (WARN_ON_ONCE(!vcpu

Re: [PATCH v9 3/7] KVM: Support dirty ring in conjunction with bitmap

2022-11-10 Thread Gavin Shan
Hi Marc, On 11/10/22 6:25 PM, Marc Zyngier wrote: On Wed, 09 Nov 2022 00:51:21 +, Gavin Shan wrote: On 11/9/22 8:32 AM, Sean Christopherson wrote: That said, there're no remaining issues that can't be sorted out on top, so don't hold up v10 if I don't look at it in a timely manner

Re: [PATCH v3 0/6] KVM: selftests: memslot_perf_test: aarch64 cleanup/fixes

2022-11-10 Thread Gavin Shan
Hi Marc, On 10/25/22 7:18 AM, Maciej S. Szmigiero wrote: On 20.10.2022 09:12, Gavin Shan wrote: kvm/selftests/memslots_perf_test doesn't work with 64KB-page-size-host and 4KB-page-size-guest on aarch64. In the implementation, the host and guest page size have been hardcoded to 4KB. It's

[PATCH v10 7/7] KVM: selftests: Automate choosing dirty ring size in dirty_log_test

2022-11-10 Thread Gavin Shan
vcpu exit due to full dirty ring state. The option '-c' becomes a hint to the dirty ring count, instead of the value of it. Signed-off-by: Gavin Shan --- tools/testing/selftests/kvm/dirty_log_test.c | 26 +--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/tools

[PATCH v10 6/7] KVM: selftests: Clear dirty ring states between two modes in dirty_log_test

2022-11-10 Thread Gavin Shan
' and the ring buffer index before next new mode is to be executed. Signed-off-by: Gavin Shan --- tools/testing/selftests/kvm/dirty_log_test.c | 27 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/kvm/dirty_log_test.c b/tools/testing

[PATCH v10 5/7] KVM: selftests: Use host page size to map ring buffer in dirty_log_test

2022-11-10 Thread Gavin Shan
0xb06ec86b: ?? ??:0 10 0x00401def: _start at ??:? Dirty ring mapped private Fix the issue by using host's page size to map the ring buffer. Signed-off-by: Gavin Shan --- tools/testing/selftests/kvm/lib/kvm_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff

[PATCH v10 4/7] KVM: arm64: Enable ring-based dirty memory tracking

2022-11-10 Thread Gavin Shan
() to keep the site of saving vgic/its tables out of the no-running-vcpu radar. Signed-off-by: Gavin Shan --- Documentation/virt/kvm/api.rst| 2 +- arch/arm64/include/uapi/asm/kvm.h | 1 + arch/arm64/kvm/Kconfig| 2 ++ arch/arm64/kvm/arm.c | 3 +++ arch

[PATCH v10 3/7] KVM: Support dirty ring in conjunction with bitmap

2022-11-10 Thread Gavin Shan
-off-by: Gavin Shan Acked-by: Peter Xu --- Documentation/virt/kvm/api.rst| 34 --- .../virt/kvm/devices/arm-vgic-its.rst | 5 +- include/linux/kvm_dirty_ring.h| 7 +++ include/linux/kvm_host.h | 1 + include/uapi/linux/kvm.h

[PATCH v10 2/7] KVM: Move declaration of kvm_cpu_dirty_log_size() to kvm_dirty_ring.h

2022-11-10 Thread Gavin Shan
for 'kvm_cpu_dirty_log_size' \ [-Wmissing-prototypes] \ int __weak kvm_cpu_dirty_log_size(void) Reported-by: kernel test robot Signed-off-by: Gavin Shan Reviewed-by: Peter Xu --- arch/x86/include/asm/kvm_host.h | 2 -- include/linux/kvm_dirty_ring.h | 1 + 2 files

[PATCH v10 1/7] KVM: x86: Introduce KVM_REQ_DIRTY_RING_SOFT_FULL

2022-11-10 Thread Gavin Shan
host.h is changed to tab character by the way. In order to avoid using 'container_of()', the argument @ring is replaced by @vcpu in kvm_dirty_ring_push(). Link: https://lore.kernel.org/kvmarm/87lerkwtm5.wl-...@kernel.org Suggested-by: Marc Zyngier Signed-off-by: Gavin Shan Reviewed-by: Pe

[PATCH v10 0/7] KVM: arm64: Enable ring-based dirty memory tracking

2022-11-10 Thread Gavin Shan
elog improvement (Marc) * Fix dirty_log_test without knowing host page size (Drew) Gavin Shan (7): KVM: x86: Introduce KVM_REQ_DIRTY_RING_SOFT_FULL KVM: Move declaration of kvm_cpu_dirty_log_size() to kvm_dirty_ring.h KVM: Support dirty ring in conjunction with bitmap KVM: arm64: E

Re: [PATCH v5 03/14] KVM: arm64: Pass mm_ops through the visitor context

2022-11-09 Thread Gavin Shan
| 3 +- arch/arm64/kvm/hyp/pgtable.c | 63 +++- 3 files changed, 26 insertions(+), 41 deletions(-) Reviewed-by: Gavin Shan diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h index 14d4b68a1e92..a752793482cb 100644

Re: [PATCH v5 04/14] KVM: arm64: Don't pass kvm_pgtable through kvm_pgtable_walk_data

2022-11-09 Thread Gavin Shan
/pgtable.c | 18 +- 1 file changed, 5 insertions(+), 13 deletions(-) Reviewed-by: Gavin Shan diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index db25e81a9890..93989b750a26 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c

Re: [PATCH v5 03/14] KVM: arm64: Pass mm_ops through the visitor context

2022-11-09 Thread Gavin Shan
Hi Oliver, On 11/8/22 5:56 AM, Oliver Upton wrote: As a prerequisite for getting visitors off of struct kvm_pgtable, pass mm_ops through the visitor context. No functional change intended. Signed-off-by: Oliver Upton --- arch/arm64/include/asm/kvm_pgtable.h | 1 +

Re: [PATCH v5 02/14] KVM: arm64: Stash observed pte value in visitor context

2022-11-09 Thread Gavin Shan
(+), 51 deletions(-) Reviewed-by: Gavin Shan A nit as below. diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h index 607f9bb8aab4..14d4b68a1e92 100644 --- a/arch/arm64/include/asm/kvm_pgtable.h +++ b/arch/arm64/include/asm/kvm_pgtable.h @@ -201,6 +201,7

Re: [PATCH v5 01/14] KVM: arm64: Combine visitor arguments into a context structure

2022-11-09 Thread Gavin Shan
Hi Oliver, On 11/10/22 8:42 AM, Oliver Upton wrote: On Thu, Nov 10, 2022 at 08:23:36AM +0800, Gavin Shan wrote: On 11/8/22 5:56 AM, Oliver Upton wrote: Passing new arguments by value to the visitor callbacks is extremely inflexible for stuffing new parameters used by only some of the visitors

Re: [PATCH v5 01/14] KVM: arm64: Combine visitor arguments into a context structure

2022-11-09 Thread Gavin Shan
/arm64/include/asm/kvm_pgtable.h | 15 +- arch/arm64/kvm/hyp/nvhe/mem_protect.c | 10 +- arch/arm64/kvm/hyp/nvhe/setup.c | 16 +- arch/arm64/kvm/hyp/pgtable.c | 269 +- 4 files changed, 154 insertions(+), 156 deletions(-) Reviewed-by: Gavin Shan One

Re: [PATCH v9 3/7] KVM: Support dirty ring in conjunction with bitmap

2022-11-08 Thread Gavin Shan
Hi Sean, On 11/9/22 8:32 AM, Sean Christopherson wrote: On Wed, Nov 09, 2022, Gavin Shan wrote: On 11/9/22 8:05 AM, Sean Christopherson wrote: On Wed, Nov 09, 2022, Gavin Shan wrote: On 11/9/22 12:25 AM, Sean Christopherson wrote: I have no objection to disallowing userspace from disabling

Re: [PATCH v9 3/7] KVM: Support dirty ring in conjunction with bitmap

2022-11-08 Thread Gavin Shan
Hi Sean, On 11/9/22 8:05 AM, Sean Christopherson wrote: On Wed, Nov 09, 2022, Gavin Shan wrote: On 11/9/22 12:25 AM, Sean Christopherson wrote: I have no objection to disallowing userspace from disabling the combo, but I think it's worth requiring cap->args[0] to be '0' just in case we cha

Re: [PATCH v9 3/7] KVM: Support dirty ring in conjunction with bitmap

2022-11-08 Thread Gavin Shan
Hi Sean, On 11/9/22 12:25 AM, Sean Christopherson wrote: On Tue, Nov 08, 2022, Gavin Shan wrote: diff --git a/virt/kvm/Kconfig b/virt/kvm/Kconfig index 800f9470e36b..228be1145cf3 100644 --- a/virt/kvm/Kconfig +++ b/virt/kvm/Kconfig @@ -33,6 +33,14 @@ config HAVE_KVM_DIRTY_RING_ACQ_REL

[PATCH v9 7/7] KVM: selftests: Automate choosing dirty ring size in dirty_log_test

2022-11-07 Thread Gavin Shan
vcpu exit due to full dirty ring state. The option '-c' becomes a hint to the dirty ring count, instead of the value of it. Signed-off-by: Gavin Shan --- tools/testing/selftests/kvm/dirty_log_test.c | 26 +--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/tools

[PATCH v9 6/7] KVM: selftests: Clear dirty ring states between two modes in dirty_log_test

2022-11-07 Thread Gavin Shan
' and the ring buffer index before next new mode is to be executed. Signed-off-by: Gavin Shan --- tools/testing/selftests/kvm/dirty_log_test.c | 27 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/kvm/dirty_log_test.c b/tools/testing

[PATCH v9 5/7] KVM: selftests: Use host page size to map ring buffer in dirty_log_test

2022-11-07 Thread Gavin Shan
0xb06ec86b: ?? ??:0 10 0x00401def: _start at ??:? Dirty ring mapped private Fix the issue by using host's page size to map the ring buffer. Signed-off-by: Gavin Shan --- tools/testing/selftests/kvm/lib/kvm_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff

[PATCH v9 4/7] KVM: arm64: Enable ring-based dirty memory tracking

2022-11-07 Thread Gavin Shan
the generic one, to keep the site of saving vgic/its tables out of the no-running-vcpu radar. Signed-off-by: Gavin Shan --- Documentation/virt/kvm/api.rst| 2 +- arch/arm64/include/uapi/asm/kvm.h | 1 + arch/arm64/kvm/Kconfig| 2 ++ arch/arm64/kvm/arm.c | 3 +++ arch/arm64

[PATCH v9 3/7] KVM: Support dirty ring in conjunction with bitmap

2022-11-07 Thread Gavin Shan
-off-by: Gavin Shan Acked-by: Peter Xu --- Documentation/virt/kvm/api.rst| 34 --- .../virt/kvm/devices/arm-vgic-its.rst | 5 +- include/linux/kvm_dirty_ring.h| 7 +++ include/linux/kvm_host.h | 1 + include/uapi/linux/kvm.h

[PATCH v9 2/7] KVM: Move declaration of kvm_cpu_dirty_log_size() to kvm_dirty_ring.h

2022-11-07 Thread Gavin Shan
for 'kvm_cpu_dirty_log_size' \ [-Wmissing-prototypes] \ int __weak kvm_cpu_dirty_log_size(void) Reported-by: kernel test robot Signed-off-by: Gavin Shan Reviewed-by: Peter Xu --- arch/x86/include/asm/kvm_host.h | 2 -- include/linux/kvm_dirty_ring.h | 1 + 2 files

[PATCH v9 1/7] KVM: x86: Introduce KVM_REQ_DIRTY_RING_SOFT_FULL

2022-11-07 Thread Gavin Shan
host.h is changed to tab character by the way. In order to avoid using 'container_of()', the argument @ring is replaced by @vcpu in kvm_dirty_ring_push(). Link: https://lore.kernel.org/kvmarm/87lerkwtm5.wl-...@kernel.org Suggested-by: Marc Zyngier Signed-off-by: Gavin Shan Reviewed-by: Pe

[PATCH v9 0/7] KVM: arm64: Enable ring-based dirty memory tracking

2022-11-07 Thread Gavin Shan
quest_pending() (Peter) * Move declaration of kvm_cpu_dirty_log_size() (test-robot) v2: * Introduce KVM_REQ_RING_SOFT_FULL (Marc) * Changelog improvement (Marc) * Fix dirty_log_test without knowing host page size

Re: [PATCH v8 3/7] KVM: Support dirty ring in conjunction with bitmap

2022-11-07 Thread Gavin Shan
Hi Oliver, On 11/8/22 9:13 AM, Oliver Upton wrote: On Tue, Nov 08, 2022 at 08:44:52AM +0800, Gavin Shan wrote: Frankly, I don't expect the capability to be disabled. Similar to KVM_CAP_DIRTY_LOG_RING or KVM_CAP_DIRTY_LOG_RING_ACQ_REL, it would a one-shot capability and only enablement

Re: [PATCH v8 3/7] KVM: Support dirty ring in conjunction with bitmap

2022-11-07 Thread Gavin Shan
Hi Sean, On 11/8/22 12:05 AM, Sean Christopherson wrote: On Sat, Nov 05, 2022, Gavin Shan wrote: diff --git a/virt/kvm/dirty_ring.c b/virt/kvm/dirty_ring.c index fecbb7d75ad2..758679724447 100644 --- a/virt/kvm/dirty_ring.c +++ b/virt/kvm/dirty_ring.c @@ -21,6 +21,16 @@ u32

Re: [PATCH v8 3/7] KVM: Support dirty ring in conjunction with bitmap

2022-11-07 Thread Gavin Shan
Hi Marc, On 11/7/22 7:33 PM, Marc Zyngier wrote: On Mon, 07 Nov 2022 10:45:34 +, Gavin Shan wrote: On 11/5/22 7:40 AM, Gavin Shan wrote: ARM64 needs to dirty memory outside of a VCPU context when VGIC/ITS is enabled. It's conflicting with that ring-based dirty page tracking always

Re: [PATCH v8 4/7] KVM: arm64: Enable ring-based dirty memory tracking

2022-11-07 Thread Gavin Shan
Hi Marc, On 11/7/22 5:47 PM, Marc Zyngier wrote: On Sun, 06 Nov 2022 21:46:19 +, Gavin Shan wrote: On 11/6/22 11:50 PM, Marc Zyngier wrote: On Fri, 04 Nov 2022 23:40:46 +, Gavin Shan wrote: Enable ring-based dirty memory tracking on arm64 by selecting CONFIG_HAVE_KVM_DIRTY_

Re: [PATCH v8 3/7] KVM: Support dirty ring in conjunction with bitmap

2022-11-07 Thread Gavin Shan
Hi Marc, Peter, Oliver and Sean, On 11/5/22 7:40 AM, Gavin Shan wrote: ARM64 needs to dirty memory outside of a VCPU context when VGIC/ITS is enabled. It's conflicting with that ring-based dirty page tracking always requires a running VCPU context. Introduce a new flavor of dirty ring

Re: [PATCH v8 0/7] KVM: arm64: Enable ring-based dirty memory tracking

2022-11-06 Thread Gavin Shan
Hi Marc, On 11/7/22 12:08 AM, Marc Zyngier wrote: On Fri, 04 Nov 2022 23:40:42 +, Gavin Shan wrote: This series enables the ring-based dirty memory tracking for ARM64. The feature has been available and enabled on x86 for a while. It is beneficial when the number of dirty pages is small

Re: [PATCH v8 4/7] KVM: arm64: Enable ring-based dirty memory tracking

2022-11-06 Thread Gavin Shan
Hi Marc, On 11/6/22 11:50 PM, Marc Zyngier wrote: On Fri, 04 Nov 2022 23:40:46 +, Gavin Shan wrote: Enable ring-based dirty memory tracking on arm64 by selecting CONFIG_HAVE_KVM_DIRTY_{RING_ACQ_REL, RING_WITH_BITMAP} and providing the ring buffer's physical page offset

Re: [PATCH v8 3/7] KVM: Support dirty ring in conjunction with bitmap

2022-11-06 Thread Gavin Shan
Hi Marc, On 11/6/22 11:43 PM, Marc Zyngier wrote: On Fri, 04 Nov 2022 23:40:45 +, Gavin Shan wrote: ARM64 needs to dirty memory outside of a VCPU context when VGIC/ITS is enabled. It's conflicting with that ring-based dirty page tracking always requires a running VCPU context. Introduce

Re: [PATCH v8 3/7] KVM: Support dirty ring in conjunction with bitmap

2022-11-06 Thread Gavin Shan
Hi Peter and Marc, On 11/7/22 5:06 AM, Peter Xu wrote: On Sun, Nov 06, 2022 at 08:12:22PM +, Marc Zyngier wrote: On Sun, 06 Nov 2022 16:22:29 +, Peter Xu wrote: On Sun, Nov 06, 2022 at 03:43:17PM +, Marc Zyngier wrote: +Note that the bitmap here is only a backup of the ring

Re: [PATCH v3 0/6] KVM: selftests: memslot_perf_test: aarch64 cleanup/fixes

2022-11-04 Thread Gavin Shan
On 10/25/22 7:18 AM, Maciej S. Szmigiero wrote: On 20.10.2022 09:12, Gavin Shan wrote: kvm/selftests/memslots_perf_test doesn't work with 64KB-page-size-host and 4KB-page-size-guest on aarch64. In the implementation, the host and guest page size have been hardcoded to 4KB. It's ovbiously

[PATCH v8 7/7] KVM: selftests: Automate choosing dirty ring size in dirty_log_test

2022-11-04 Thread Gavin Shan
vcpu exit due to full dirty ring state. The option '-c' becomes a hint to the dirty ring count, instead of the value of it. Signed-off-by: Gavin Shan --- tools/testing/selftests/kvm/dirty_log_test.c | 26 +--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/tools

[PATCH v8 6/7] KVM: selftests: Clear dirty ring states between two modes in dirty_log_test

2022-11-04 Thread Gavin Shan
' and the ring buffer index before next new mode is to be executed. Signed-off-by: Gavin Shan --- tools/testing/selftests/kvm/dirty_log_test.c | 27 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/kvm/dirty_log_test.c b/tools/testing

[PATCH v8 5/7] KVM: selftests: Use host page size to map ring buffer in dirty_log_test

2022-11-04 Thread Gavin Shan
0xb06ec86b: ?? ??:0 10 0x00401def: _start at ??:? Dirty ring mapped private Fix the issue by using host's page size to map the ring buffer. Signed-off-by: Gavin Shan --- tools/testing/selftests/kvm/lib/kvm_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff

[PATCH v8 4/7] KVM: arm64: Enable ring-based dirty memory tracking

2022-11-04 Thread Gavin Shan
are being saved or not. The helper is used in ARM64's kvm_arch_allow_write_without_running_vcpu() to keep the site of saving vgic/its tables out of no-running-vcpu radar. Signed-off-by: Gavin Shan --- Documentation/virt/kvm/api.rst | 2 +- arch/arm64/include/uapi/asm/kvm.h | 1 + arch/arm64

[PATCH v8 3/7] KVM: Support dirty ring in conjunction with bitmap

2022-11-04 Thread Gavin Shan
-off-by: Gavin Shan Acked-by: Peter Xu --- Documentation/virt/kvm/api.rst | 33 ++- include/linux/kvm_dirty_ring.h | 7 + include/linux/kvm_host.h | 1 + include/uapi/linux/kvm.h | 1 + virt/kvm/Kconfig | 8 ++ virt/kvm/dirty_ring.c

[PATCH v8 1/7] KVM: x86: Introduce KVM_REQ_DIRTY_RING_SOFT_FULL

2022-11-04 Thread Gavin Shan
host.h is changed to tab character by the way. In order to avoid using 'container_of()', the argument @ring is replaced by @vcpu in kvm_dirty_ring_push(). Link: https://lore.kernel.org/kvmarm/87lerkwtm5.wl-...@kernel.org Suggested-by: Marc Zyngier Signed-off-by: Gavin Shan Reviewed-by: Pe

[PATCH v8 2/7] KVM: Move declaration of kvm_cpu_dirty_log_size() to kvm_dirty_ring.h

2022-11-04 Thread Gavin Shan
for 'kvm_cpu_dirty_log_size' \ [-Wmissing-prototypes] \ int __weak kvm_cpu_dirty_log_size(void) Reported-by: kernel test robot Signed-off-by: Gavin Shan Reviewed-by: Peter Xu --- arch/x86/include/asm/kvm_host.h | 2 -- include/linux/kvm_dirty_ring.h | 1 + 2 files

[PATCH v8 0/7] KVM: arm64: Enable ring-based dirty memory tracking

2022-11-04 Thread Gavin Shan
(Marc) * Changelog improvement (Marc) * Fix dirty_log_test without knowing host page size (Drew) Gavin Shan (7): KVM: x86: Introduce KVM_REQ_DIRTY_RING_SOFT_FULL KVM: Move declaration of kvm_cpu_dirty_log_size() to kvm_dirty_ring.h KVM

Re: [PATCH v7 4/9] KVM: Support dirty ring in conjunction with bitmap

2022-11-04 Thread Gavin Shan
Hi Oliver, On 11/5/22 4:12 AM, Oliver Upton wrote: On Fri, Nov 04, 2022 at 02:57:15PM +0800, Gavin Shan wrote: On 11/4/22 9:06 AM, Oliver Upton wrote: [...] Just to make sure we're on the same page, there's two issues: (1) If DIRTY_LOG_RING is enabled before memslot creation

Re: [PATCH v7 4/9] KVM: Support dirty ring in conjunction with bitmap

2022-11-04 Thread Gavin Shan
Hi Oliver, On 11/4/22 9:06 AM, Oliver Upton wrote: On Fri, Nov 04, 2022 at 08:12:21AM +0800, Gavin Shan wrote: On 11/4/22 7:32 AM, Oliver Upton wrote: On Mon, Oct 31, 2022 at 08:36:16AM +0800, Gavin Shan wrote: ARM64 needs to dirty memory outside of a VCPU context when VGIC/ITS is enabled

Re: [PATCH v7 4/9] KVM: Support dirty ring in conjunction with bitmap

2022-11-03 Thread Gavin Shan
Hi Oliver, On 11/4/22 7:32 AM, Oliver Upton wrote: On Mon, Oct 31, 2022 at 08:36:16AM +0800, Gavin Shan wrote: ARM64 needs to dirty memory outside of a VCPU context when VGIC/ITS is enabled. It's conflicting with that ring-based dirty page tracking always requires a running VCPU context

Re: [PATCH v7 1/9] KVM: x86: Introduce KVM_REQ_DIRTY_RING_SOFT_FULL

2022-11-02 Thread Gavin Shan
On 11/3/22 12:44 AM, Marc Zyngier wrote: On Wed, 02 Nov 2022 16:11:07 +, Sean Christopherson wrote: On Wed, Nov 02, 2022, Marc Zyngier wrote: On Wed, 02 Nov 2022 14:29:26 +, Peter Xu wrote: However I don't see anything stops a simple "race" to trigger like below:

Re: [PATCH v7 5/9] KVM: arm64: Improve no-running-vcpu report for dirty ring

2022-10-31 Thread Gavin Shan
On 10/31/22 5:08 PM, Oliver Upton wrote: On Mon, Oct 31, 2022 at 08:36:17AM +0800, Gavin Shan wrote: KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP should be enabled only when KVM device "kvm-arm-vgic-its" is used by userspace. Currently, it's the only case where a running VCPU is missed for

Re: [PATCH v6 3/8] KVM: Add support for using dirty ring in conjunction with bitmap

2022-10-31 Thread Gavin Shan
On 10/31/22 5:08 PM, Marc Zyngier wrote: On 2022-10-28 17:51, Sean Christopherson wrote: On Fri, Oct 28, 2022, Gavin Shan wrote: On 10/28/22 2:30 AM, Marc Zyngier wrote: > On Thu, 27 Oct 2022 18:44:51 +0100, > > On Thu, Oct 27, 2022, Marc Zyngier wrote: > > > On Tue, 25 Oct 2

Re: [PATCH v6 3/8] KVM: Add support for using dirty ring in conjunction with bitmap

2022-10-30 Thread Gavin Shan
Hi Sean, On 10/29/22 12:51 AM, Sean Christopherson wrote: On Fri, Oct 28, 2022, Gavin Shan wrote: On 10/28/22 2:30 AM, Marc Zyngier wrote: On Thu, 27 Oct 2022 18:44:51 +0100, Sean Christopherson wrote: On Thu, Oct 27, 2022, Marc Zyngier wrote: On Tue, 25 Oct 2022 18:47:12 +0100, Sean

[PATCH v7 9/9] KVM: selftests: Automate choosing dirty ring size in dirty_log_test

2022-10-30 Thread Gavin Shan
vcpu exit due to full dirty ring state. The option '-c' becomes a hint to the dirty ring count, instead of the value of it. Signed-off-by: Gavin Shan --- tools/testing/selftests/kvm/dirty_log_test.c | 26 +--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/tools

[PATCH v7 8/9] KVM: selftests: Clear dirty ring states between two modes in dirty_log_test

2022-10-30 Thread Gavin Shan
' and the ring buffer index before next new mode is to be executed. Signed-off-by: Gavin Shan --- tools/testing/selftests/kvm/dirty_log_test.c | 27 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/kvm/dirty_log_test.c b/tools/testing

[PATCH v7 7/9] KVM: selftests: Use host page size to map ring buffer in dirty_log_test

2022-10-30 Thread Gavin Shan
0xb06ec86b: ?? ??:0 10 0x00401def: _start at ??:? Dirty ring mapped private Fix the issue by using host's page size to map the ring buffer. Signed-off-by: Gavin Shan --- tools/testing/selftests/kvm/lib/kvm_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff

[PATCH v7 6/9] KVM: arm64: Enable ring-based dirty memory tracking

2022-10-30 Thread Gavin Shan
Enable ring-based dirty memory tracking on arm64 by selecting CONFIG_HAVE_KVM_DIRTY_{RING_ACQ_REL, RING_WITH_BITMAP} and providing the ring buffer's physical page offset (KVM_DIRTY_LOG_PAGE_OFFSET). Signed-off-by: Gavin Shan --- Documentation/virt/kvm/api.rst| 2 +- arch/arm64/include/uapi

[PATCH v7 5/9] KVM: arm64: Improve no-running-vcpu report for dirty ring

2022-10-30 Thread Gavin Shan
google.com Suggested-by: Sean Christopherson Signed-off-by: Gavin Shan --- arch/arm64/kvm/mmu.c | 14 ++ arch/arm64/kvm/vgic/vgic-init.c| 4 ++-- arch/arm64/kvm/vgic/vgic-irqfd.c | 4 ++-- arch/arm64/kvm/vgic/vgic-its.c | 2 +- arch/arm64/kvm/vgic

[PATCH v7 4/9] KVM: Support dirty ring in conjunction with bitmap

2022-10-30 Thread Gavin Shan
-off-by: Gavin Shan --- Documentation/virt/kvm/api.rst | 31 --- include/linux/kvm_dirty_ring.h | 6 ++ include/linux/kvm_host.h | 1 + include/uapi/linux/kvm.h | 1 + virt/kvm/Kconfig | 8 virt/kvm/dirty_ring.c | 5

[PATCH v7 3/9] KVM: Check KVM_CAP_DIRTY_LOG_{RING, RING_ACQ_REL} prior to enabling them

2022-10-30 Thread Gavin Shan
: Add KVM_CAP_DIRTY_LOG_RING_ACQ_REL capability and config option") Reported-by: Sean Christopherson Suggested-by: Sean Christopherson Signed-off-by: Gavin Shan --- virt/kvm/kvm_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 30

[PATCH v7 2/9] KVM: Move declaration of kvm_cpu_dirty_log_size() to kvm_dirty_ring.h

2022-10-30 Thread Gavin Shan
for 'kvm_cpu_dirty_log_size' \ [-Wmissing-prototypes] \ int __weak kvm_cpu_dirty_log_size(void) Reported-by: kernel test robot Signed-off-by: Gavin Shan Reviewed-by: Peter Xu --- arch/x86/include/asm/kvm_host.h | 2 -- include/linux/kvm_dirty_ring.h | 1 + 2 files

[PATCH v7 1/9] KVM: x86: Introduce KVM_REQ_DIRTY_RING_SOFT_FULL

2022-10-30 Thread Gavin Shan
rieved from the VCPU. Link: https://lore.kernel.org/kvmarm/87lerkwtm5.wl-...@kernel.org Suggested-by: Marc Zyngier Signed-off-by: Gavin Shan Reviewed-by: Peter Xu --- arch/x86/kvm/x86.c | 15 ++- include/linux/kvm_dirty_ring.h | 17 ++--- include/linux/kvm_

[PATCH v7 0/9] KVM: arm64: Enable ring-based dirty memory tracking

2022-10-30 Thread Gavin Shan
_SOFT_FULL (Marc) * Changelog improvement (Marc) * Fix dirty_log_test without knowing host page size (Drew) Gavin Shan (9): KVM: x86: Introduce KVM_REQ_DIRTY_RING_SOFT_FULL KVM: Move declaration of kvm_cpu_dirty_log_size() to kvm_dirty_ri

Re: [PATCH v6 3/8] KVM: Add support for using dirty ring in conjunction with bitmap

2022-10-28 Thread Gavin Shan
Hi Sean and Marc, On 10/28/22 2:30 AM, Marc Zyngier wrote: On Thu, 27 Oct 2022 18:44:51 +0100, Sean Christopherson wrote: On Thu, Oct 27, 2022, Marc Zyngier wrote: On Tue, 25 Oct 2022 18:47:12 +0100, Sean Christopherson wrote: [...] And ideally such bugs would detected without

Re: [PATCH v6 3/8] KVM: Add support for using dirty ring in conjunction with bitmap

2022-10-22 Thread Gavin Shan
Hi Sean, On 10/22/22 12:05 AM, Sean Christopherson wrote: On Fri, Oct 21, 2022, Marc Zyngier wrote: On Fri, 21 Oct 2022 00:44:51 +0100, Sean Christopherson wrote: On Tue, Oct 11, 2022, Gavin Shan wrote: Some architectures (such as arm64) need to dirty memory outside of the context

Re: [PATCH v6 3/8] KVM: Add support for using dirty ring in conjunction with bitmap

2022-10-21 Thread Gavin Shan
Hi Sean, On 10/22/22 7:20 AM, Sean Christopherson wrote: On Fri, Oct 21, 2022, Gavin Shan wrote: What about inverting the naming to better capture that this is about the dirty bitmap, and less so about the dirty ring? It's not obvious what "exclusive" means, e.g. I saw this s

Re: [PATCH v6 1/8] KVM: x86: Introduce KVM_REQ_RING_SOFT_FULL

2022-10-21 Thread Gavin Shan
Hi Sean, On 10/22/22 7:48 AM, Sean Christopherson wrote: On Sat, Oct 22, 2022, Gavin Shan wrote: When dirty ring becomes full, the VCPU can't handle any operations, which will bring more dirty pages. Right, but there's a buffer of 64 entries on top of what the CPU can buffer (VMX's PML can

Re: [PATCH v6 1/8] KVM: x86: Introduce KVM_REQ_RING_SOFT_FULL

2022-10-21 Thread Gavin Shan
Hi Sean, On 10/21/22 11:25 PM, Sean Christopherson wrote: On Fri, Oct 21, 2022, Gavin Shan wrote: I think Marc want to make the check more generalized with a new event [1]. Generalized code can be achieved with a helper though. The motivation is indeed to avoid overhead on every run

Re: [PATCH v6 3/8] KVM: Add support for using dirty ring in conjunction with bitmap

2022-10-21 Thread Gavin Shan
Hi Sean, On 10/21/22 7:44 AM, Sean Christopherson wrote: On Tue, Oct 11, 2022, Gavin Shan wrote: Some architectures (such as arm64) need to dirty memory outside of the context of a vCPU. Of course, this simply doesn't fit with the UAPI of KVM's per-vCPU dirty ring. What is the point of using

Re: [PATCH v6 1/8] KVM: x86: Introduce KVM_REQ_RING_SOFT_FULL

2022-10-20 Thread Gavin Shan
Hi Sean, On 10/21/22 6:42 AM, Sean Christopherson wrote: On Tue, Oct 11, 2022, Gavin Shan wrote: This adds KVM_REQ_RING_SOFT_FULL, which is raised when the dirty "This" is basically "This patch", which is generally frowned upon. Just state what changes are being

Re: [PATCH 4/6] KVM: selftests: memslot_perf_test: Support variable guest page size

2022-10-20 Thread Gavin Shan
On 10/20/22 4:18 AM, Maciej S. Szmigiero wrote: On 19.10.2022 02:26, Gavin Shan wrote: On 10/18/22 11:56 PM, Maciej S. Szmigiero wrote: On 18.10.2022 02:51, Gavin Shan wrote: On 10/18/22 8:46 AM, Gavin Shan wrote: On 10/18/22 5:31 AM, Maciej S. Szmigiero wrote: On 14.10.2022 09:19, Gavin

[PATCH v3 6/6] KVM: selftests: memslot_perf_test: Report optimal memory slots

2022-10-20 Thread Gavin Shan
igh for this test, decrease the cap (max is 514) Signed-off-by: Gavin Shan --- .../testing/selftests/kvm/memslot_perf_test.c | 45 +-- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/kvm/memslot_perf_test.c b/tools/testing/selftests/

[PATCH v3 5/6] KVM: selftests: memslot_perf_test: Consolidate memory

2022-10-20 Thread Gavin Shan
also add checks to ensure that none of host/guest page size exceeds 64KB. MEM_TEST_MOVE_SIZE is fixed up to 192KB either. With this, the following command works fine on 64KB-page-size-host and 4KB-page-size-guest. # ./memslot_perf_test -v -s 512 Signed-off-by: Gavin Shan --- .../testing

[PATCH v3 4/6] KVM: selftests: memslot_perf_test: Support variable guest page size

2022-10-20 Thread Gavin Shan
in this patch are almost mechanical replacing '4096' with 'guest_page_size'. Signed-off-by: Gavin Shan --- .../testing/selftests/kvm/memslot_perf_test.c | 210 +++--- 1 file changed, 129 insertions(+), 81 deletions(-) diff --git a/tools/testing/selftests/kvm/memslot_perf_test.c b/tools

[PATCH v3 3/6] KVM: selftests: memslot_perf_test: Probe memory slots for once

2022-10-20 Thread Gavin Shan
intended. Signed-off-by: Gavin Shan --- .../testing/selftests/kvm/memslot_perf_test.c | 32 +++ 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/tools/testing/selftests/kvm/memslot_perf_test.c b/tools/testing/selftests/kvm/memslot_perf_test.c index dcb492b3f27b

[PATCH v3 2/6] KVM: selftests: memslot_perf_test: Consolidate loop conditions in prepare_vm()

2022-10-20 Thread Gavin Shan
it as the memory slot index either. No functional change intended. Signed-off-by: Gavin Shan --- tools/testing/selftests/kvm/memslot_perf_test.c | 11 +-- 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/kvm/memslot_perf_test.c b/tools/testing/selftests

[PATCH v3 1/6] KVM: selftests: memslot_perf_test: Use data->nslots in prepare_vm()

2022-10-20 Thread Gavin Shan
atches. No functional change intended. Signed-off-by: Gavin Shan --- tools/testing/selftests/kvm/memslot_perf_test.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/kvm/memslot_perf_test.c b/tools/testing/selftests/kvm/memslot_perf_test.c index 449954

[PATCH v3 0/6] KVM: selftests: memslot_perf_test: aarch64 cleanup/fixes

2022-10-20 Thread Gavin Shan
size in kvm_util_base.h in PATCH[v2 5/6] (Sean) * Add checks on host/guest page size in check_memory_size() and fail early if any of them exceeds 64KB in PATCH[v2 5/6] (Maciej) Gavin Shan (6): KVM: selftests: memslot_perf_test: Use data

Re: [PATCH 4/6] KVM: selftests: memslot_perf_test: Support variable guest page size

2022-10-18 Thread Gavin Shan
On 10/18/22 11:56 PM, Maciej S. Szmigiero wrote: On 18.10.2022 02:51, Gavin Shan wrote: On 10/18/22 8:46 AM, Gavin Shan wrote: On 10/18/22 5:31 AM, Maciej S. Szmigiero wrote: On 14.10.2022 09:19, Gavin Shan wrote: The test case is obviously broken on aarch64 because non-4KB guest page size

Re: [PATCH v6 3/8] KVM: Add support for using dirty ring in conjunction with bitmap

2022-10-18 Thread Gavin Shan
Hi Peter, On 10/19/22 12:07 AM, Peter Xu wrote: On Tue, Oct 11, 2022 at 02:14:42PM +0800, Gavin Shan wrote: Some architectures (such as arm64) need to dirty memory outside of the context of a vCPU. Of course, this simply doesn't fit with the UAPI of KVM's per-vCPU dirty ring. Introduce a new

Re: [PATCH 5/6] KVM: selftests: memslot_perf_test: Consolidate memory sizes

2022-10-18 Thread Gavin Shan
On 10/18/22 3:47 PM, Oliver Upton wrote: On Mon, Oct 17, 2022 at 10:08:48PM +, Sean Christopherson wrote: On Mon, Oct 17, 2022, Maciej S. Szmigiero wrote: +#define MEM_EXTRA_SIZE 0x1 Also, an expression like "(64 << 10)" is more readable than a "1" with a tail of zeroes (it's

[PATCH v2 6/6] KVM: selftests: memslot_perf_test: Report optimal memory slots

2022-10-17 Thread Gavin Shan
igh for this test, decrease the cap (max is 514) Signed-off-by: Gavin Shan --- .../testing/selftests/kvm/memslot_perf_test.c | 45 +-- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/kvm/memslot_perf_test.c b/tools/testing/selftests/

[PATCH v2 4/6] KVM: selftests: memslot_perf_test: Support variable guest page size

2022-10-17 Thread Gavin Shan
to host page, the size of page chunk is automatically selected, other than one page. - All other changes included in this patch are almost mechanical replacing '4096' with 'guest_page_size'. Signed-off-by: Gavin Shan --- .../testing/selftests/kvm/memslot_perf_test.c | 201

[PATCH v2 5/6] KVM: selftests: memslot_perf_test: Consolidate memory sizes

2022-10-17 Thread Gavin Shan
also add checks to ensure that none of host/guest page size exceeds 64KB. After it's applied, the following command works fine on 64KB-page-size-host and 4KB-page-size-guest. # ./memslot_perf_test -v -s 512 Signed-off-by: Gavin Shan --- .../selftests/kvm/include/kvm_util_base.h | 15

[PATCH v2 3/6] KVM: selftests: memslot_perf_test: Probe memory slots for once

2022-10-17 Thread Gavin Shan
intended. Signed-off-by: Gavin Shan --- .../testing/selftests/kvm/memslot_perf_test.c | 32 +++ 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/tools/testing/selftests/kvm/memslot_perf_test.c b/tools/testing/selftests/kvm/memslot_perf_test.c index dcb492b3f27b

[PATCH v2 1/6] KVM: selftests: memslot_perf_test: Use data->nslots in prepare_vm()

2022-10-17 Thread Gavin Shan
atches. No functional change intended. Signed-off-by: Gavin Shan --- tools/testing/selftests/kvm/memslot_perf_test.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/kvm/memslot_perf_test.c b/tools/testing/selftests/kvm/memslot_perf_test.c index 449954

[PATCH v2 2/6] KVM: selftests: memslot_perf_test: Consolidate loop conditions in prepare_vm()

2022-10-17 Thread Gavin Shan
it as the memory slot index either. No functional change intended. Signed-off-by: Gavin Shan --- tools/testing/selftests/kvm/memslot_perf_test.c | 11 +-- 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/kvm/memslot_perf_test.c b/tools/testing/selftests

[PATCH v2 0/6] KVM: selftests: memslot_perf_test: aarch64 cleanup/fixes

2022-10-17 Thread Gavin Shan
) Gavin Shan (6): KVM: selftests: memslot_perf_test: Use data->nslots in prepare_vm() KVM: selftests: memslot_perf_test: Consolidate loop conditions in prepare_vm() KVM: selftests: memslot_perf_test: Probe memory slots for once KVM: selftests: memslot_perf_test: Support variable guest p

Re: [PATCH 5/6] KVM: selftests: memslot_perf_test: Consolidate memory sizes

2022-10-17 Thread Gavin Shan
On 10/18/22 5:36 AM, Maciej S. Szmigiero wrote: On 14.10.2022 09:19, Gavin Shan wrote: The addresses and sizes passed to madvise() and vm_userspace_mem_region_add() should be aligned to host page size, which can be 64KB on aarch64. So it's wrong by passing additional fixed 4KB memory area

Re: [PATCH 4/6] KVM: selftests: memslot_perf_test: Support variable guest page size

2022-10-17 Thread Gavin Shan
On 10/18/22 8:46 AM, Gavin Shan wrote: On 10/18/22 5:31 AM, Maciej S. Szmigiero wrote: On 14.10.2022 09:19, Gavin Shan wrote: The test case is obviously broken on aarch64 because non-4KB guest page size is supported. The guest page size on aarch64 could be 4KB, 16KB or 64KB. This supports

Re: [PATCH 4/6] KVM: selftests: memslot_perf_test: Support variable guest page size

2022-10-17 Thread Gavin Shan
On 10/18/22 5:31 AM, Maciej S. Szmigiero wrote: On 14.10.2022 09:19, Gavin Shan wrote: The test case is obviously broken on aarch64 because non-4KB guest page size is supported. The guest page size on aarch64 could be 4KB, 16KB or 64KB. This supports variable guest page size, mostly

Re: [PATCH 5/6] KVM: selftests: memslot_perf_test: Consolidate memory sizes

2022-10-17 Thread Gavin Shan
On 10/18/22 7:32 AM, Sean Christopherson wrote: On Tue, Oct 18, 2022, Gavin Shan wrote: On 10/18/22 6:56 AM, Maciej S. Szmigiero wrote: On 18.10.2022 00:51, Gavin Shan wrote: On 10/18/22 6:08 AM, Sean Christopherson wrote: On Mon, Oct 17, 2022, Maciej S. Szmigiero wrote: +#define

Re: [PATCH 5/6] KVM: selftests: memslot_perf_test: Consolidate memory sizes

2022-10-17 Thread Gavin Shan
On 10/18/22 6:56 AM, Maciej S. Szmigiero wrote: On 18.10.2022 00:51, Gavin Shan wrote: On 10/18/22 6:08 AM, Sean Christopherson wrote: On Mon, Oct 17, 2022, Maciej S. Szmigiero wrote: +#define MEM_EXTRA_SIZE    0x1 Also, an expression like "(64 << 10)" is more re

  1   2   3   4   5   6   7   >