From patchwork Thu Feb 8 20:48:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 198567 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp444605dyd; Thu, 8 Feb 2024 12:52:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IEw68582M9vU8KI9kTiU8OsMHFfBjYPMyebias8ZkpOZZnrDl9t0eRgvAiZZ7Ttpi30Jzj2 X-Received: by 2002:aa7:c607:0:b0:560:10c:3cc with SMTP id h7-20020aa7c607000000b00560010c03ccmr270960edq.21.1707425541714; Thu, 08 Feb 2024 12:52:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707425541; cv=pass; d=google.com; s=arc-20160816; b=xlgA6sk/Hjdgnr2z6TDXJGfUXDSZgK2dZcD2tRek+2xzkm6Rj0FPXtCW7DsZvYuapx fQz/Ze7YB7ug8at6pFuSbcFNvtyItbmfLYQEl33cFnU2gygcZEd2I8Jj88AsqyZF+SHi nKr8XF4wzTD0uYKStGV2tJQCQh4awvQ7qSlxXCM8qgPC74+HF1xsigH3njsHPIzXg5IA jPrdkYxjX2bsbIOvmL739NL6dYn86PfHn/d6DXcMw6kv4C47zO0y5WCcLprXfe3obThi hT4/GZiu5V+mJKb5PI6luKIGOCEdR30VpMdQbF7nCC6nO3ZWOvfiu0snPZKelpvJ52hI p+Hg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=1FjsFqrrKXsl521gM/hDv0+tlQIs54sn7FNkgqZxeow=; fh=ZlxK1d0+E3fyvLJrr9wp51rdVK/yHMpgLCYpw60KupU=; b=ZNRiGpg+7yyqTOpZMhAWjuxi72R2phHRCKSsO54WGelkLFgb8IjQNEy3Rb8CYTJZbE 9Ysb5WMzQXhhTCjokTN3IJkTo9yKr41DhvHf6GTE0e7MPx8RbHSyQuPo0+Yngla9VPl8 nsUYUd4P7CkmsLboGIfSfo2UAOoN0jGB0F16EueZd3GNtV7G3zlhv731z83uobsHlg78 QcbZSim4zR4McYgg0yghXWIqDK5spHMXRm8l15sFVdtXFHnNdQm+zjd2MxxAThUEVCvm rAAhtM8Kaoyf7Zp5apZ7hL+cZB1xgaLUMvtqLulaSBJfzzkfStpTs412DQfndEVqeZpI fuDg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NQQSL2sK; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-58683-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58683-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=2; AJvYcCWNPFZequJ+Mk9rV5GlZZN8GupGngfRGYsKiuDydDDIAaEUA7vt75Ahq6Kzt1cjtxXIo2e6wV61D8bzfo6TuncLbctbWQ== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id cx24-20020a05640222b800b005612755663asi96069edb.113.2024.02.08.12.52.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 12:52:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58683-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NQQSL2sK; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-58683-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58683-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 5679B1F23BEB for ; Thu, 8 Feb 2024 20:52:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BFEE951C5D; Thu, 8 Feb 2024 20:49:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NQQSL2sK" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 283ED4F8A3 for ; Thu, 8 Feb 2024 20:49:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707425348; cv=none; b=c759/FIwl4j4rNQqc9CWEuUpJyvB8gNwbCxgOKilRI4zSNNecW5KYIpOp+mPshOkDsisEXDaqj+fF9+ComTXxqsqQeL62qCgfVV74Lh9ZI7Yin47+UXIrh/r390M+J7OCGqhlMIX39/AAgwpa4nFraXhkwyzFqOBExTgFe6EYq4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707425348; c=relaxed/simple; bh=W5to7iDa4oRE760XTEaEtgW3bD/CXiFOButwlNgLoZg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=An/6SpjFEwjVUs+QzzEHoyNisSQ9xm7cYz0G9IaDRiAoa5OCB/KevWuuGQmmLswDN4Tz3RK0/wYKz+JmDgtAWUqgjqRx7qZFEuSedK67e8k9S4faP2kUA+Cq4q+HGaD/CGbh4ZBeNCRord2CCz6Dl+oL8H5+fTxWNNAKbZM7qG0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=NQQSL2sK; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707425346; 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=1FjsFqrrKXsl521gM/hDv0+tlQIs54sn7FNkgqZxeow=; b=NQQSL2sKXY5WrsgmBmIy14nII5cq5uz9Cx89PCGFaXw4D/oKXmr9YZa4Fx7WbUGWIAlGuz uuGIekkWLkrKICZgg+Yf2C5iLKx0Up+Ujr0Dwwn0bNWMaTRA5ZNENd/fb5rWIyvF26D3/t lanXwIiwYZocHdArABzew21fkofOhTE= 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-528-Ckeg5F9OOzOY29lxHvM9Pg-1; Thu, 08 Feb 2024 15:49:01 -0500 X-MC-Unique: Ckeg5F9OOzOY29lxHvM9Pg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 75C5F29AA3AC; Thu, 8 Feb 2024 20:49:00 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.39.192.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6F46D1C10C0E; Thu, 8 Feb 2024 20:48:58 +0000 (UTC) From: Thomas Huth To: kvm@vger.kernel.org, Sean Christopherson Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Paolo Bonzini , Andrew Jones Subject: [PATCH v3 6/8] KVM: selftests: x86: Use TAP interface in the fix_hypercall test Date: Thu, 8 Feb 2024 21:48:42 +0100 Message-ID: <20240208204844.119326-7-thuth@redhat.com> In-Reply-To: <20240208204844.119326-1-thuth@redhat.com> References: <20240208204844.119326-1-thuth@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790365444859100759 X-GMAIL-MSGID: 1790365444859100759 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..f3c2239228b10 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); + 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, guest_main) +{ + test_fix_hypercall(vcpu, false); +} + +KVM_ONE_VCPU_TEST(fix_hypercall, disable_quirk, guest_main) +{ + 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); }