From patchwork Thu Oct 5 14:38:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 148791 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp354984vqb; Thu, 5 Oct 2023 07:58:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEJQ1eFUoSSrpyztc31PABt8TP2/PVqE123/1/J/EzTY7rjChCBHPdNOyXYrQRE3pTlYBmj X-Received: by 2002:a17:902:e5c7:b0:1c6:ec8:4c67 with SMTP id u7-20020a170902e5c700b001c60ec84c67mr5735416plf.18.1696517903521; Thu, 05 Oct 2023 07:58:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696517903; cv=none; d=google.com; s=arc-20160816; b=J14FbNASv6EJYDSALUXqMwNssXOYvNSygN/Ttab1IoQ/MiNj2IVoWydMrvXri2sPE9 uGe+azwvzYhWyOna7/anv67tMZeP0ruzFwz1vNdTE6a2HD5Y+yOMXHdk3wXyXPa18Ils y4dbUqwjrZG9lC4GgJQSqp0dJqgZcJjWbyNovFRXlt1psk/ByfJ0Yt2cSJTzNXoON30t Kj1yglE6XOD5Y8/EuDC3yKvMmcVD3vHQzzJocpvW9slIRLMQw92JTtomUF6h9Q0wN4tE tF1lBRyeradPd/cYxHPQCcT8FHbbsMQzwpEI7oN4z3VlpHLIMHpEdiuba6oqz/5d/QHu YdBg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0ftZTUSszjDaBYMwepJocwkUW/juZNz/Q5LGCufgOFs=; fh=WOoc99rHeo9qxHvnIaWffALNRebT/42m1dldSuRpBY0=; b=u6f5L5dmodxxJYDO/O6Dart+iiUhrxgzfAquGJWabdi5S/a4bh+F133AcNZML8XLyF qjcwtYt84njxc80z7uv7kJDj2jrpxGZq3LXK3OkCsUCnPCU2hFabFpFZ7Fs3gkLwgtGE PmR7/hZFtFNrtkNPr3x11zkgJ4bwxgupUM25Jn78nT7BIMOxfLsgWiOMf2TA9OkvK8IZ KwRTv/HhOhxVJfNPTyU2cMAw20sj9VgYmVAnVnu7EiOdIYMEPs4ERxawuoedkpet1Lgr i+c65Hj7xqix1iRCZ2IgpXfRAghkyVxt8hH82Cb7+A9FHonaOYnCms4UyMlnwNHe5+px E9vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SnBYr1fN; 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 z13-20020a170903018d00b001c746b986e8si1632864plg.461.2023.10.05.07.58.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 07:58:23 -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=SnBYr1fN; 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 E6F75867FEB8; Thu, 5 Oct 2023 07:58:22 -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 S234336AbjJEO5D (ORCPT + 19 others); Thu, 5 Oct 2023 10:57:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237666AbjJEOzg (ORCPT ); Thu, 5 Oct 2023 10:55:36 -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 79D7826A74 for ; Thu, 5 Oct 2023 07:38:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696516732; 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: in-reply-to:in-reply-to:references:references; bh=0ftZTUSszjDaBYMwepJocwkUW/juZNz/Q5LGCufgOFs=; b=SnBYr1fN+gmtbBOEPqNRfvkw3U87jMSZTS60h1T55lDcILw9Fux3LQr4RX//jyrSEcBHuH f0LsqWuPKhtfcOdr1viKUgGmOY43ahestB3E7ezzrgIu6NIihydrnVdhD/X58VWSB2eSXF iWh/LBLhd/J8lh0PVlGPFIfVq1dQq/Q= 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-627-HpW_D5Y1Peequ5SsnYIDUA-1; Thu, 05 Oct 2023 10:38:50 -0400 X-MC-Unique: HpW_D5Y1Peequ5SsnYIDUA-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 C216981D795; Thu, 5 Oct 2023 14:38:49 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.39.192.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DC9340C6EA8; Thu, 5 Oct 2023 14:38:48 +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 5/7] KVM: selftests: x86: Use TAP interface in the fix_hypercall test Date: Thu, 5 Oct 2023 16:38:37 +0200 Message-ID: <20231005143839.365297-6-thuth@redhat.com> In-Reply-To: <20231005143839.365297-1-thuth@redhat.com> References: <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 07:58:23 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778927957338053285 X-GMAIL-MSGID: 1778927957338053285 Use the kvm_test_harness.h interface in this test to get TAP output, so that it is easier for the user to see what the test is doing. Signed-off-by: Thomas Huth --- .../selftests/kvm/x86_64/fix_hypercall_test.c | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/kvm/x86_64/fix_hypercall_test.c b/tools/testing/selftests/kvm/x86_64/fix_hypercall_test.c index 0f728f05ea82f..59c389aff3961 100644 --- a/tools/testing/selftests/kvm/x86_64/fix_hypercall_test.c +++ b/tools/testing/selftests/kvm/x86_64/fix_hypercall_test.c @@ -9,6 +9,7 @@ #include #include +#include "kvm_test_harness.h" #include "apic.h" #include "test_util.h" #include "kvm_util.h" @@ -83,6 +84,8 @@ static void guest_main(void) GUEST_DONE(); } +KVM_ONE_VCPU_TEST_SUITE(fix_hypercall, guest_main); + static void enter_guest(struct kvm_vcpu *vcpu) { struct kvm_run *run = vcpu->run; @@ -103,14 +106,11 @@ static void enter_guest(struct kvm_vcpu *vcpu) } } -static void test_fix_hypercall(bool disable_quirk) +static void test_fix_hypercall(struct kvm_vcpu *vcpu, bool disable_quirk) { - struct kvm_vcpu *vcpu; - struct kvm_vm *vm; - - vm = vm_create_with_one_vcpu(&vcpu, guest_main); + struct kvm_vm *vm = vcpu->vm; - vm_init_descriptor_tables(vcpu->vm); + vm_init_descriptor_tables(vm); vcpu_init_descriptor_tables(vcpu); vm_install_exception_handler(vcpu->vm, UD_VECTOR, guest_ud_handler); @@ -126,10 +126,19 @@ static void test_fix_hypercall(bool disable_quirk) enter_guest(vcpu); } -int main(void) +KVM_ONE_VCPU_TEST(fix_hypercall, enable_quirk) +{ + test_fix_hypercall(vcpu, false); +} + +KVM_ONE_VCPU_TEST(fix_hypercall, disable_quirk) +{ + test_fix_hypercall(vcpu, true); +} + +int main(int argc, char *argv[]) { TEST_REQUIRE(kvm_check_cap(KVM_CAP_DISABLE_QUIRKS2) & KVM_X86_QUIRK_FIX_HYPERCALL_INSN); - test_fix_hypercall(false); - test_fix_hypercall(true); + return test_harness_run(argc, argv); }