From patchwork Wed Oct 25 15:29:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vitaly Kuznetsov X-Patchwork-Id: 13436447 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E04DC0032E for ; Wed, 25 Oct 2023 15:39:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233942AbjJYPj2 (ORCPT ); Wed, 25 Oct 2023 11:39:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232621AbjJYPj1 (ORCPT ); Wed, 25 Oct 2023 11:39:27 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C733C1BC for ; Wed, 25 Oct 2023 08:29:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698247761; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kHpgRL5EddUTto5/Vaxzfx33SlksxOrFntoVOzzsuPM=; b=KwYldo98snPB5lOGLCbHcwssj2qzXD9rLxugj+WPSRUv8u6I9pKqA5nj+dTBC3grFpyuUS Zz4d1KKLFQNHlxXc2wqEOOWIcszg/OZcjDR+4PCPAm74eM2DNwn/dBXvmZjYdwecCgve53 mFIg6UOiACBdNkl1YMi+l8mkR+jkDzo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-625-jiBywVHKMhqVasCnkGb6IA-1; Wed, 25 Oct 2023 11:29:19 -0400 X-MC-Unique: jiBywVHKMhqVasCnkGb6IA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 296A88870E7; Wed, 25 Oct 2023 15:29:19 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.226.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id 57C172166B26; Wed, 25 Oct 2023 15:29:18 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org, Paolo Bonzini , Sean Christopherson , Maxim Levitsky Subject: [PATCH kvm-unit-tests 1/4] x86: hyper-v: Use '-cpu host,hv_passhtrough' for Hyper-V tests Date: Wed, 25 Oct 2023 17:29:12 +0200 Message-ID: <20231025152915.1879661-2-vkuznets@redhat.com> In-Reply-To: <20231025152915.1879661-1-vkuznets@redhat.com> References: <20231025152915.1879661-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 --- 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 From patchwork Wed Oct 25 15:29:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vitaly Kuznetsov X-Patchwork-Id: 13436448 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24794C07545 for ; Wed, 25 Oct 2023 15:39:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234524AbjJYPjh (ORCPT ); Wed, 25 Oct 2023 11:39:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232621AbjJYPjg (ORCPT ); Wed, 25 Oct 2023 11:39:36 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61BFBD56 for ; Wed, 25 Oct 2023 08:29:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698247773; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=28vU8AtFcmowR+oJB1xtmcOuRYh4PysKXZ77Wa0Z6bY=; b=YG6xJfgR9NXr9rFalG3Fq5xDb1iRJfCYg8zinA39wOjL75cTV8zTJduTNtAl4B/9gsYVZv 3JzhDdZmw7A7M0zvRO4SP6c9Rbr/pjTzLZNiqTMyf8cq/Lq+jVEUsTq6aJRbOFJRZZCDAy G2bFBOLnQ3IMrFKkNj9VIMfEyoHAlnc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-602-vLRRCnpbODu3xQdVo3h0hA-1; Wed, 25 Oct 2023 11:29:20 -0400 X-MC-Unique: vLRRCnpbODu3xQdVo3h0hA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 317B385C6F2; Wed, 25 Oct 2023 15:29:20 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.226.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5ECFC2166B26; Wed, 25 Oct 2023 15:29:19 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org, Paolo Bonzini , Sean Christopherson , Maxim Levitsky Subject: [PATCH kvm-unit-tests 2/4] x86: hyper-v: Use report_skip() in hyperv_stimer when pre-requisites are not met Date: Wed, 25 Oct 2023 17:29:13 +0200 Message-ID: <20231025152915.1879661-3-vkuznets@redhat.com> In-Reply-To: <20231025152915.1879661-1-vkuznets@redhat.com> References: <20231025152915.1879661-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 'report_pass()' is supposed to be used when tests actually pass, use 'report_skip()' to match other tests. Signed-off-by: Vitaly Kuznetsov --- 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; } From patchwork Wed Oct 25 15:29:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vitaly Kuznetsov X-Patchwork-Id: 13436446 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31C0CC0032E for ; Wed, 25 Oct 2023 15:32:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235100AbjJYPcc (ORCPT ); Wed, 25 Oct 2023 11:32:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235048AbjJYPca (ORCPT ); Wed, 25 Oct 2023 11:32:30 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1860A196 for ; Wed, 25 Oct 2023 08:31:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698247897; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MtoXj1GYNMFSHttaFfxD/jjrlz6bvckSpFZTkJXcl/4=; b=deWhkqSWEWiljA48IAWLX09BgvM8mGX432dQf66d0x0QDU1QLaFtaf7mdGCWYfPTM5MyUO lHxVYG5D0CoTl7lSSfUcdRZ95hQsPG8WjxSTAHx7tkqJqbitQXH8TyxDFfd+PoAWNjJFAD ZFAW+sGF321XDejY6iR349KfUlsDqd8= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-37-q9cDIzN4Ni-QF5cC8qpvKQ-1; Wed, 25 Oct 2023 11:30:17 -0400 X-MC-Unique: q9cDIzN4Ni-QF5cC8qpvKQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3981C1C0783D; Wed, 25 Oct 2023 15:29:21 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.226.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id 666E32166B27; Wed, 25 Oct 2023 15:29:20 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org, Paolo Bonzini , Sean Christopherson , Maxim Levitsky Subject: [PATCH kvm-unit-tests 3/4] x86: hyper-v: Use 'goto' instead of putting the whole test in an 'if' branch in hyperv_synic Date: Wed, 25 Oct 2023 17:29:14 +0200 Message-ID: <20231025152915.1879661-4-vkuznets@redhat.com> In-Reply-To: <20231025152915.1879661-1-vkuznets@redhat.com> References: <20231025152915.1879661-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 --- 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(); } From patchwork Wed Oct 25 15:29:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vitaly Kuznetsov X-Patchwork-Id: 13436449 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51C9CC0032E for ; Wed, 25 Oct 2023 15:39:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235035AbjJYPjn (ORCPT ); Wed, 25 Oct 2023 11:39:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232621AbjJYPjm (ORCPT ); Wed, 25 Oct 2023 11:39:42 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F11EB10CE for ; Wed, 25 Oct 2023 08:29:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698247766; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MiLrHcm1jHxIj86P0YZpTBI2aY7ofRBfJwnJst86kZs=; b=g9Dh2beT/XsdYTcp8GS1/HlndgfjKTzW34yiQBVV/nQq586qbr9J8pHtQqAyCadDbT6I5S 4gaOfm4SJKiD3jSh7aK+RUdtmDPAHSHOEN2mrNWY+Alx3y97JLfSkkr1jTOHH3+frcxYJH VPiCYKYXtULI1NoKNCbEwIJadHRyEyw= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-557-br9Zkg-dMF2GxD5U1p93qQ-1; Wed, 25 Oct 2023 11:29:22 -0400 X-MC-Unique: br9Zkg-dMF2GxD5U1p93qQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3F53D3C1E9DD; Wed, 25 Oct 2023 15:29:22 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.226.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E1FD2166B26; Wed, 25 Oct 2023 15:29:21 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org, Paolo Bonzini , Sean Christopherson , Maxim Levitsky Subject: [PATCH kvm-unit-tests 4/4] x86: hyper-v: Unify hyperv_clock with other Hyper-V tests Date: Wed, 25 Oct 2023 17:29:15 +0200 Message-ID: <20231025152915.1879661-5-vkuznets@redhat.com> In-Reply-To: <20231025152915.1879661-1-vkuznets@redhat.com> References: <20231025152915.1879661-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Always do 'return report_summary()' at the end, use report_abort() when an abnormality is detected. Signed-off-by: Vitaly Kuznetsov --- 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(); }