* [PATCH kvm-unit-tests 0/4] x86: hyper-v: Add support for CONFIG_KVM_HYPERV
@ 2023-10-25 15:29 Vitaly Kuznetsov
2023-10-25 15:29 ` [PATCH kvm-unit-tests 1/4] x86: hyper-v: Use '-cpu host,hv_passhtrough' for Hyper-V tests Vitaly Kuznetsov
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Vitaly Kuznetsov @ 2023-10-25 15:29 UTC (permalink / raw)
To: kvm, Paolo Bonzini, Sean Christopherson, Maxim Levitsky
With the introduction of CONFIG_KVM_HYPERV:
https://lore.kernel.org/kvm/20231025152406.1879274-1-vkuznets@redhat.com/
it becomes possible to build KVM without Hyper-V emulation support. Make
Hyper-V tests in kvm-unit-tests handle such case with dignity.
Vitaly Kuznetsov (4):
x86: hyper-v: Use '-cpu host,hv_passhtrough' for Hyper-V tests
x86: hyper-v: Use report_skip() in hyperv_stimer when pre-requisites
are not met
x86: hyper-v: Use 'goto' instead of putting the whole test in an 'if'
branch in hyperv_synic
x86: hyper-v: Unify hyperv_clock with other Hyper-V tests
x86/hyperv_clock.c | 12 ++++-----
x86/hyperv_stimer.c | 6 ++---
x86/hyperv_synic.c | 61 +++++++++++++++++++++++----------------------
x86/unittests.cfg | 8 +++---
4 files changed, 43 insertions(+), 44 deletions(-)
--
2.41.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH kvm-unit-tests 1/4] x86: hyper-v: Use '-cpu host,hv_passhtrough' for Hyper-V tests
2023-10-25 15:29 [PATCH kvm-unit-tests 0/4] x86: hyper-v: Add support for CONFIG_KVM_HYPERV Vitaly Kuznetsov
@ 2023-10-25 15:29 ` Vitaly Kuznetsov
2023-10-25 15:29 ` [PATCH kvm-unit-tests 2/4] x86: hyper-v: Use report_skip() in hyperv_stimer when pre-requisites are not met Vitaly Kuznetsov
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Vitaly Kuznetsov @ 2023-10-25 15:29 UTC (permalink / raw)
To: kvm, Paolo Bonzini, Sean Christopherson, Maxim Levitsky
To make Hyper-V tests skip gracefully when Hyper-V emulation support is
missing in KVM run all tests with '-cpu host,hv_passhtrough' which is
supposed to enable all enlightenments. Tests can (and will) check CPUID
and report_skip() when the required features are missing.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
x86/unittests.cfg | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/x86/unittests.cfg b/x86/unittests.cfg
index 3fe59449b650..a5574b105efc 100644
--- a/x86/unittests.cfg
+++ b/x86/unittests.cfg
@@ -451,25 +451,25 @@ arch = x86_64
[hyperv_synic]
file = hyperv_synic.flat
smp = 2
-extra_params = -cpu kvm64,hv_vpindex,hv_synic -device hyperv-testdev
+extra_params = -cpu host,hv_passthrough -device hyperv-testdev
groups = hyperv
[hyperv_connections]
file = hyperv_connections.flat
smp = 2
-extra_params = -cpu kvm64,hv_vpindex,hv_synic -device hyperv-testdev
+extra_params = -cpu host,hv_passthrough -device hyperv-testdev
groups = hyperv
[hyperv_stimer]
file = hyperv_stimer.flat
smp = 2
-extra_params = -cpu kvm64,hv_vpindex,hv_time,hv_synic,hv_stimer -device hyperv-testdev
+extra_params = -cpu host,hv_passthrough -device hyperv-testdev
groups = hyperv
[hyperv_clock]
file = hyperv_clock.flat
smp = 2
-extra_params = -cpu kvm64,hv_time
+extra_params = -cpu host,hv_passthrough
arch = x86_64
groups = hyperv
check = /sys/devices/system/clocksource/clocksource0/current_clocksource=tsc
--
2.41.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH kvm-unit-tests 2/4] x86: hyper-v: Use report_skip() in hyperv_stimer when pre-requisites are not met
2023-10-25 15:29 [PATCH kvm-unit-tests 0/4] x86: hyper-v: Add support for CONFIG_KVM_HYPERV Vitaly Kuznetsov
2023-10-25 15:29 ` [PATCH kvm-unit-tests 1/4] x86: hyper-v: Use '-cpu host,hv_passhtrough' for Hyper-V tests Vitaly Kuznetsov
@ 2023-10-25 15:29 ` Vitaly Kuznetsov
2023-10-25 15:29 ` [PATCH kvm-unit-tests 3/4] x86: hyper-v: Use 'goto' instead of putting the whole test in an 'if' branch in hyperv_synic Vitaly Kuznetsov
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Vitaly Kuznetsov @ 2023-10-25 15:29 UTC (permalink / raw)
To: kvm, Paolo Bonzini, Sean Christopherson, Maxim Levitsky
'report_pass()' is supposed to be used when tests actually pass, use
'report_skip()' to match other tests.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
x86/hyperv_stimer.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/x86/hyperv_stimer.c b/x86/hyperv_stimer.c
index f7c679160bdf..bcf0fc9d8058 100644
--- a/x86/hyperv_stimer.c
+++ b/x86/hyperv_stimer.c
@@ -353,17 +353,17 @@ int main(int ac, char **av)
{
if (!synic_supported()) {
- report_pass("Hyper-V SynIC is not supported");
+ report_skip("Hyper-V SynIC is not supported");
goto done;
}
if (!stimer_supported()) {
- report_pass("Hyper-V SynIC timers are not supported");
+ report_skip("Hyper-V SynIC timers are not supported");
goto done;
}
if (!hv_time_ref_counter_supported()) {
- report_pass("Hyper-V time reference counter is not supported");
+ report_skip("Hyper-V time reference counter is not supported");
goto done;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH kvm-unit-tests 3/4] x86: hyper-v: Use 'goto' instead of putting the whole test in an 'if' branch in hyperv_synic
2023-10-25 15:29 [PATCH kvm-unit-tests 0/4] x86: hyper-v: Add support for CONFIG_KVM_HYPERV Vitaly Kuznetsov
2023-10-25 15:29 ` [PATCH kvm-unit-tests 1/4] x86: hyper-v: Use '-cpu host,hv_passhtrough' for Hyper-V tests Vitaly Kuznetsov
2023-10-25 15:29 ` [PATCH kvm-unit-tests 2/4] x86: hyper-v: Use report_skip() in hyperv_stimer when pre-requisites are not met Vitaly Kuznetsov
@ 2023-10-25 15:29 ` Vitaly Kuznetsov
2023-10-25 15:29 ` [PATCH kvm-unit-tests 4/4] x86: hyper-v: Unify hyperv_clock with other Hyper-V tests Vitaly Kuznetsov
2024-01-24 12:11 ` [PATCH kvm-unit-tests 0/4] x86: hyper-v: Add support for CONFIG_KVM_HYPERV Vitaly Kuznetsov
4 siblings, 0 replies; 6+ messages in thread
From: Vitaly Kuznetsov @ 2023-10-25 15:29 UTC (permalink / raw)
To: kvm, Paolo Bonzini, Sean Christopherson, Maxim Levitsky
Unify 'hyperv_synic' test with other Hyper-V tests by using the:
if (required-features-missing) {
report_skip();
goto done;
}
...
done:
return report_summary();
pattern.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
x86/hyperv_synic.c | 61 +++++++++++++++++++++++-----------------------
1 file changed, 31 insertions(+), 30 deletions(-)
diff --git a/x86/hyperv_synic.c b/x86/hyperv_synic.c
index 9d61d8362ebd..ae57f1c5faac 100644
--- a/x86/hyperv_synic.c
+++ b/x86/hyperv_synic.c
@@ -141,45 +141,46 @@ static void synic_test_cleanup(void *ctx)
int main(int ac, char **av)
{
+ int ncpus, i;
+ bool ok;
- if (synic_supported()) {
- int ncpus, i;
- bool ok;
-
- setup_vm();
- enable_apic();
+ if (!synic_supported()) {
+ report_skip("Hyper-V SynIC is not supported");
+ goto done;
+ }
- ncpus = cpu_count();
- if (ncpus > MAX_CPUS)
- report_abort("number cpus exceeds %d", MAX_CPUS);
- printf("ncpus = %d\n", ncpus);
+ setup_vm();
+ enable_apic();
- synic_prepare_sint_vecs();
+ ncpus = cpu_count();
+ if (ncpus > MAX_CPUS)
+ report_abort("number cpus exceeds %d", MAX_CPUS);
+ printf("ncpus = %d\n", ncpus);
- printf("prepare\n");
- on_cpus(synic_test_prepare, (void *)read_cr3());
+ synic_prepare_sint_vecs();
- for (i = 0; i < ncpus; i++) {
- printf("test %d -> %d\n", i, ncpus - 1 - i);
- on_cpu_async(i, synic_test, (void *)(ulong)(ncpus - 1 - i));
- }
- while (cpus_active() > 1)
- pause();
+ printf("prepare\n");
+ on_cpus(synic_test_prepare, (void *)read_cr3());
- printf("cleanup\n");
- on_cpus(synic_test_cleanup, NULL);
+ for (i = 0; i < ncpus; i++) {
+ printf("test %d -> %d\n", i, ncpus - 1 - i);
+ on_cpu_async(i, synic_test, (void *)(ulong)(ncpus - 1 - i));
+ }
+ while (cpus_active() > 1)
+ pause();
- ok = true;
- for (i = 0; i < ncpus; ++i) {
- printf("isr_enter_count[%d] = %d\n",
- i, atomic_read(&isr_enter_count[i]));
- ok &= atomic_read(&isr_enter_count[i]) == 16;
- }
+ printf("cleanup\n");
+ on_cpus(synic_test_cleanup, NULL);
- report(ok, "Hyper-V SynIC test");
- } else {
- printf("Hyper-V SynIC is not supported");
+ ok = true;
+ for (i = 0; i < ncpus; ++i) {
+ printf("isr_enter_count[%d] = %d\n",
+ i, atomic_read(&isr_enter_count[i]));
+ ok &= atomic_read(&isr_enter_count[i]) == 16;
}
+ report(ok, "Hyper-V SynIC test");
+
+done:
return report_summary();
}
--
2.41.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH kvm-unit-tests 4/4] x86: hyper-v: Unify hyperv_clock with other Hyper-V tests
2023-10-25 15:29 [PATCH kvm-unit-tests 0/4] x86: hyper-v: Add support for CONFIG_KVM_HYPERV Vitaly Kuznetsov
` (2 preceding siblings ...)
2023-10-25 15:29 ` [PATCH kvm-unit-tests 3/4] x86: hyper-v: Use 'goto' instead of putting the whole test in an 'if' branch in hyperv_synic Vitaly Kuznetsov
@ 2023-10-25 15:29 ` Vitaly Kuznetsov
2024-01-24 12:11 ` [PATCH kvm-unit-tests 0/4] x86: hyper-v: Add support for CONFIG_KVM_HYPERV Vitaly Kuznetsov
4 siblings, 0 replies; 6+ messages in thread
From: Vitaly Kuznetsov @ 2023-10-25 15:29 UTC (permalink / raw)
To: kvm, Paolo Bonzini, Sean Christopherson, Maxim Levitsky
Always do 'return report_summary()' at the end, use report_abort() when an
abnormality is detected.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
x86/hyperv_clock.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/x86/hyperv_clock.c b/x86/hyperv_clock.c
index f1e7204a8ea9..7eb4f734ee5b 100644
--- a/x86/hyperv_clock.c
+++ b/x86/hyperv_clock.c
@@ -144,7 +144,6 @@ static void perf_test(int ncpus)
int main(int ac, char **av)
{
- int nerr = 0;
int ncpus;
struct hv_reference_tsc_page shadow;
uint64_t tsc1, t1, tsc2, t2;
@@ -152,7 +151,7 @@ int main(int ac, char **av)
if (!hv_time_ref_counter_supported()) {
report_skip("time reference counter is unsupported");
- return report_summary();
+ goto done;
}
setup_vm();
@@ -167,10 +166,8 @@ int main(int ac, char **av)
"MSR value after enabling");
hvclock_get_time_values(&shadow, hv_clock);
- if (shadow.tsc_sequence == 0 || shadow.tsc_sequence == 0xFFFFFFFF) {
- printf("Reference TSC page not available\n");
- exit(1);
- }
+ if (shadow.tsc_sequence == 0 || shadow.tsc_sequence == 0xFFFFFFFF)
+ report_abort("Reference TSC page not available\n");
printf("scale: %" PRIx64" offset: %" PRId64"\n", shadow.tsc_scale, shadow.tsc_offset);
ref1 = rdmsr(HV_X64_MSR_TIME_REF_COUNT);
@@ -196,5 +193,6 @@ int main(int ac, char **av)
report(rdmsr(HV_X64_MSR_REFERENCE_TSC) == 0,
"MSR value after disabling");
- return nerr > 0 ? 1 : 0;
+done:
+ return report_summary();
}
--
2.41.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH kvm-unit-tests 0/4] x86: hyper-v: Add support for CONFIG_KVM_HYPERV
2023-10-25 15:29 [PATCH kvm-unit-tests 0/4] x86: hyper-v: Add support for CONFIG_KVM_HYPERV Vitaly Kuznetsov
` (3 preceding siblings ...)
2023-10-25 15:29 ` [PATCH kvm-unit-tests 4/4] x86: hyper-v: Unify hyperv_clock with other Hyper-V tests Vitaly Kuznetsov
@ 2024-01-24 12:11 ` Vitaly Kuznetsov
4 siblings, 0 replies; 6+ messages in thread
From: Vitaly Kuznetsov @ 2024-01-24 12:11 UTC (permalink / raw)
To: kvm, Paolo Bonzini, Sean Christopherson; +Cc: Maxim Levitsky
Vitaly Kuznetsov <vkuznets@redhat.com> writes:
> With the introduction of CONFIG_KVM_HYPERV:
> https://lore.kernel.org/kvm/20231025152406.1879274-1-vkuznets@redhat.com/
>
> it becomes possible to build KVM without Hyper-V emulation support. Make
> Hyper-V tests in kvm-unit-tests handle such case with dignity.
>
Ping) CONFIG_KVM_HYPERV is merged in 6.8 and kvm-unit-tests fail
miserably when !CONFIG_KVM_HYPERV without these changes. Patches still
apply cleanly.
--
Vitaly
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-01-24 12:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-25 15:29 [PATCH kvm-unit-tests 0/4] x86: hyper-v: Add support for CONFIG_KVM_HYPERV Vitaly Kuznetsov
2023-10-25 15:29 ` [PATCH kvm-unit-tests 1/4] x86: hyper-v: Use '-cpu host,hv_passhtrough' for Hyper-V tests Vitaly Kuznetsov
2023-10-25 15:29 ` [PATCH kvm-unit-tests 2/4] x86: hyper-v: Use report_skip() in hyperv_stimer when pre-requisites are not met Vitaly Kuznetsov
2023-10-25 15:29 ` [PATCH kvm-unit-tests 3/4] x86: hyper-v: Use 'goto' instead of putting the whole test in an 'if' branch in hyperv_synic Vitaly Kuznetsov
2023-10-25 15:29 ` [PATCH kvm-unit-tests 4/4] x86: hyper-v: Unify hyperv_clock with other Hyper-V tests Vitaly Kuznetsov
2024-01-24 12:11 ` [PATCH kvm-unit-tests 0/4] x86: hyper-v: Add support for CONFIG_KVM_HYPERV Vitaly Kuznetsov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox