From patchwork Thu Oct 5 14:38:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 14953 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp360367vqb; Thu, 5 Oct 2023 08:04:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHtxZkEWS/y1ipRKUXNsyix9JPYFdFVf9ycN9zamvkRciHCtVQHkZQ5s+ACdUOfO+Y80p21 X-Received: by 2002:a05:6a21:7748:b0:154:c959:f157 with SMTP id bc8-20020a056a21774800b00154c959f157mr5229145pzc.30.1696518290258; Thu, 05 Oct 2023 08:04:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696518290; cv=none; d=google.com; s=arc-20160816; b=AMPw7Y2kfWq9PPtX34JCCyGqXPxn0i6RPb3yF/617++EekC+d4U0ljXSSd2JH7reaA HSjGqidoK+xEjkB4HHOpawOolb2h9g79JDi5l1JMsytSPM4klQmcQK8Vbaf8KmMbYE+n VAn5Zc8k60IwrfHLo0hi9WvrfBc1QOSMk47E29/9/knNaD6FZfzHH+LQEhwfDFibDBBq eF5unib33dtGbUKOcUaWNIO4bPxizq4T9/rBUTjyzkdjQ6/qti9RKPFcQ62NogFKlkkw BWUzTg79ZHjTNEqwyQs1xAvIKDSNEKEFNZveUEXJPpIbRDdrwCVj0i6yYJ31UrwzwXGO GAoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Dv/Tj9QdaUN/Br120dwAsxWiHl/rp7FzLwgEPtUXlX4=; fh=WOoc99rHeo9qxHvnIaWffALNRebT/42m1dldSuRpBY0=; b=XaGrl/p6/UbG1N+U4yMUNyt8rXQWMqQJ0ZdiybZk+6Ipsw2pR+p38a7L1lM+7PhZDz /JFndI6If1IA3pBhe1UAKCDLPsLpPgBqJLJaeRusEbMdoEGNvkzgX5Alf4zBVjsSFBnL RhaHZTbRBVTDIHS30T0BnEgtSbwcpznEvoU2DJG2PPE0ANQkpnDyYZIn62G9rU6R0ouA S3kNG2wHuLxVfBgkXQEetbAN0lyx0Me+n+a4CaIvSn6fZMO7157v0W5eav91QzcZnRtD t9caq7BDb+mLfw7YQgjqJT5CKHMBsW3EeJIC6CfzxCsVgA34iU+n4GsTXJACbac0bLji P1Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Xbafz0v0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id k62-20020a638441000000b0055b43079640si1670347pgd.707.2023.10.05.08.04.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 08:04:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Xbafz0v0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id DD89F87027BF; Thu, 5 Oct 2023 08:04:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230093AbjJEPDy (ORCPT + 19 others); Thu, 5 Oct 2023 11:03:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229567AbjJEPCu (ORCPT ); Thu, 5 Oct 2023 11:02:50 -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 6E4463C3B for ; Thu, 5 Oct 2023 07:38:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696516726; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Dv/Tj9QdaUN/Br120dwAsxWiHl/rp7FzLwgEPtUXlX4=; b=Xbafz0v0wTrf2GldfY8ciILeWNoOtZ35zZoo6/f1z2PCnpAaK5stPktlLRQDiRuaZ0GIfQ xS2qcJNSJZgJ/KMX0+094ew3FB21oS+8DrB/LqPrh01F/5hdEBrQmHPjx4Ar5tPXfPAj7Y FxSZAGTPXA7TRdz8EIb8/wRiNOv6lCo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-487-JabyE1AROsuedgPQHMod8A-1; Thu, 05 Oct 2023 10:38:42 -0400 X-MC-Unique: JabyE1AROsuedgPQHMod8A-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4DDC8803498; Thu, 5 Oct 2023 14:38:42 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.39.192.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C9F940C6EA8; Thu, 5 Oct 2023 14:38:40 +0000 (UTC) From: Thomas Huth To: Sean Christopherson , Paolo Bonzini , kvm@vger.kernel.org Cc: Shuah Khan , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v2 0/7] Use TAP in some more x86 KVM selftests Date: Thu, 5 Oct 2023 16:38:32 +0200 Message-ID: <20231005143839.365297-1-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 05 Oct 2023 08:04:48 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778928362857924192 X-GMAIL-MSGID: 1778928362857924192 Here's a follow-up from my RFC series last year: https://lore.kernel.org/lkml/20221004093131.40392-1-thuth@redhat.com/T/ and from v1 earlier this year: https://lore.kernel.org/kvm/20230712075910.22480-1-thuth@redhat.com/ Basic idea of this series is now to use the kselftest_harness.h framework to get TAP output in the tests, so that it is easier for the user to see what is going on, and e.g. to be able to detect whether a certain test is part of the test binary or not (which is useful when tests get extended in the course of time). v2: - Dropped the "Rename the ASSERT_EQ macro" patch (already merged) - Split the fixes in the sync_regs_test into separate patches (see the first two patches) - Introduce the KVM_ONE_VCPU_TEST_SUITE() macro as suggested by Sean (see third patch) and use it in the following patches - Add a new patch to convert vmx_pmu_caps_test.c, too Thomas Huth (7): KVM: selftests: x86: sync_regs_test: Use vcpu_run() where appropriate KVM: selftests: x86: sync_regs_test: Get regs structure before modifying it KVM: selftests: Add a macro to define a test with one vcpu KVM: selftests: x86: Use TAP interface in the sync_regs test KVM: selftests: x86: Use TAP interface in the fix_hypercall test KVM: selftests: x86: Use TAP interface in the vmx_pmu_caps test KVM: selftests: x86: Use TAP interface in the userspace_msr_exit test .../selftests/kvm/include/kvm_test_harness.h | 35 +++++ .../selftests/kvm/x86_64/fix_hypercall_test.c | 27 ++-- .../selftests/kvm/x86_64/sync_regs_test.c | 121 +++++++++++++----- .../kvm/x86_64/userspace_msr_exit_test.c | 19 +-- .../selftests/kvm/x86_64/vmx_pmu_caps_test.c | 50 ++------ 5 files changed, 160 insertions(+), 92 deletions(-) create mode 100644 tools/testing/selftests/kvm/include/kvm_test_harness.h