* [PATCH] KVM: selftests: page_table_test: fix calculation of guest_test_phys_mem
@ 2021-11-26 15:28 Maciej S. Szmigiero
2021-11-26 16:11 ` Paolo Bonzini
0 siblings, 1 reply; 2+ messages in thread
From: Maciej S. Szmigiero @ 2021-11-26 15:28 UTC (permalink / raw)
To: Paolo Bonzini
Cc: Shuah Khan, Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li,
Jim Mattson, Joerg Roedel, Igor Mammedov, Yanan Wang,
Andrew Jones, kvm, linux-kselftest, linux-kernel
From: "Maciej S. Szmigiero" <maciej.szmigiero@oracle.com>
A kvm_page_table_test run with its default settings fails on VMX due to
memory region add failure:
> ==== Test Assertion Failure ====
> lib/kvm_util.c:952: ret == 0
> pid=10538 tid=10538 errno=17 - File exists
> 1 0x00000000004057d1: vm_userspace_mem_region_add at kvm_util.c:947
> 2 0x0000000000401ee9: pre_init_before_test at kvm_page_table_test.c:302
> 3 (inlined by) run_test at kvm_page_table_test.c:374
> 4 0x0000000000409754: for_each_guest_mode at guest_modes.c:53
> 5 0x0000000000401860: main at kvm_page_table_test.c:500
> 6 0x00007f82ae2d8554: ?? ??:0
> 7 0x0000000000401894: _start at ??:?
> KVM_SET_USER_MEMORY_REGION IOCTL failed,
> rc: -1 errno: 17
> slot: 1 flags: 0x0
> guest_phys_addr: 0xc0000000 size: 0x40000000
This is because the memory range that this test is trying to add
(0x0c0000000 - 0x100000000) conflicts with LAPIC mapping at 0x0fee00000.
Looking at the code it seems that guest_test_*phys*_mem variable gets
mistakenly overwritten with guest_test_*virt*_mem while trying to adjust
the former for alignment.
With the correct variable adjusted this test runs successfully.
Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
---
tools/testing/selftests/kvm/kvm_page_table_test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/kvm/kvm_page_table_test.c b/tools/testing/selftests/kvm/kvm_page_table_test.c
index 3836322add00..ba1fdc3dcf4a 100644
--- a/tools/testing/selftests/kvm/kvm_page_table_test.c
+++ b/tools/testing/selftests/kvm/kvm_page_table_test.c
@@ -280,7 +280,7 @@ static struct kvm_vm *pre_init_before_test(enum vm_guest_mode mode, void *arg)
#ifdef __s390x__
alignment = max(0x100000, alignment);
#endif
- guest_test_phys_mem = align_down(guest_test_virt_mem, alignment);
+ guest_test_phys_mem = align_down(guest_test_phys_mem, alignment);
/* Set up the shared data structure test_args */
test_args.vm = vm;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] KVM: selftests: page_table_test: fix calculation of guest_test_phys_mem
2021-11-26 15:28 [PATCH] KVM: selftests: page_table_test: fix calculation of guest_test_phys_mem Maciej S. Szmigiero
@ 2021-11-26 16:11 ` Paolo Bonzini
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2021-11-26 16:11 UTC (permalink / raw)
To: Maciej S. Szmigiero
Cc: Shuah Khan, Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li,
Jim Mattson, Joerg Roedel, Igor Mammedov, Yanan Wang,
Andrew Jones, kvm, linux-kselftest, linux-kernel
On 11/26/21 16:28, Maciej S. Szmigiero wrote:
> From: "Maciej S. Szmigiero" <maciej.szmigiero@oracle.com>
>
> A kvm_page_table_test run with its default settings fails on VMX due to
> memory region add failure:
>> ==== Test Assertion Failure ====
>> lib/kvm_util.c:952: ret == 0
>> pid=10538 tid=10538 errno=17 - File exists
>> 1 0x00000000004057d1: vm_userspace_mem_region_add at kvm_util.c:947
>> 2 0x0000000000401ee9: pre_init_before_test at kvm_page_table_test.c:302
>> 3 (inlined by) run_test at kvm_page_table_test.c:374
>> 4 0x0000000000409754: for_each_guest_mode at guest_modes.c:53
>> 5 0x0000000000401860: main at kvm_page_table_test.c:500
>> 6 0x00007f82ae2d8554: ?? ??:0
>> 7 0x0000000000401894: _start at ??:?
>> KVM_SET_USER_MEMORY_REGION IOCTL failed,
>> rc: -1 errno: 17
>> slot: 1 flags: 0x0
>> guest_phys_addr: 0xc0000000 size: 0x40000000
>
> This is because the memory range that this test is trying to add
> (0x0c0000000 - 0x100000000) conflicts with LAPIC mapping at 0x0fee00000.
>
> Looking at the code it seems that guest_test_*phys*_mem variable gets
> mistakenly overwritten with guest_test_*virt*_mem while trying to adjust
> the former for alignment.
> With the correct variable adjusted this test runs successfully.
>
> Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
> ---
> tools/testing/selftests/kvm/kvm_page_table_test.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/kvm/kvm_page_table_test.c b/tools/testing/selftests/kvm/kvm_page_table_test.c
> index 3836322add00..ba1fdc3dcf4a 100644
> --- a/tools/testing/selftests/kvm/kvm_page_table_test.c
> +++ b/tools/testing/selftests/kvm/kvm_page_table_test.c
> @@ -280,7 +280,7 @@ static struct kvm_vm *pre_init_before_test(enum vm_guest_mode mode, void *arg)
> #ifdef __s390x__
> alignment = max(0x100000, alignment);
> #endif
> - guest_test_phys_mem = align_down(guest_test_virt_mem, alignment);
> + guest_test_phys_mem = align_down(guest_test_phys_mem, alignment);
>
> /* Set up the shared data structure test_args */
> test_args.vm = vm;
>
Queued, thanks.
Paolo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-11-26 16:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-26 15:28 [PATCH] KVM: selftests: page_table_test: fix calculation of guest_test_phys_mem Maciej S. Szmigiero
2021-11-26 16:11 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).