From patchwork Thu May 25 07:38:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haibo Xu X-Patchwork-Id: 13254852 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D38DBC77B7A for ; Thu, 25 May 2023 07:36:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6uT88BCr36i6t1OknYp8RKz1WvaOTsdertxPGeg6lwI=; b=dEKW+Wv0InJUqJ 44/7eYx87WJUUyoPab2yB5H3DsWCqqs7oRBBKW4zzFFNr7rWF5IVR3GVDx9Lstpdu2iW5/O9JofCL pTe7rHo8B4rMCAOl2XaWHwbJAeKplq5HLJ4GKVjTwP7SeOIQlecsXPbLYZJ3dA1fs+ZDGMSqkm8js 2z1Sod6TzGSq+EaEIVfiDhewVi19+VvBTM36QN5Y3Pflb/3vPbIYmIrnBMBCnUMHUFErJZUyiAK8t UHeHX+jXgD6lIPU9JGrBRyszO4YAQn6c0qHtemF4ltDDEKJ/6mfkULCKLs14zFckJ3ie6J1+xiNFh nfkZMG3bObmAfClRJFPA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q25WZ-00Fpdf-0y; Thu, 25 May 2023 07:36:39 +0000 Received: from mga02.intel.com ([134.134.136.20]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q25Vc-00Fon9-2J; Thu, 25 May 2023 07:35:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685000140; x=1716536140; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xygKw/lutXpoT+xBrrnIsigg+qVl1ffYhJioaYUxoVg=; b=eBpCxfCLdteSEdoe8PcbxPQ+Wt3x5QHNnTG2nTqFaIgk8KyjbU8VNQfj cZQjQLnbSGpXBH1nhkXGXkVMMOvIn+2mU3v6kDaZd/6pPAsXLOJ/jwOt0 qDQQExu88RR7eLnC66Vs5IfL4D5qia/6u0vdTZYwlnO63Gt0owEXAXON+ 9dLAn9fUv6+SDtu2BpWd5ff7jJKcBhV550NoubHI5QfsjOlxqZrLw5Gkw nYRmn+DJdwYEE9DLJkl0soXBc11ejwV/DVVkqUcrm59xbCnvUsm5eBpk9 1YFujfIApe2qxOFSYx4GxAmds4NTq+MCWBPeYBiUsq7nutzlpGWY1Ma79 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10720"; a="343285691" X-IronPort-AV: E=Sophos;i="6.00,190,1681196400"; d="scan'208";a="343285691" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 May 2023 00:34:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10720"; a="769776060" X-IronPort-AV: E=Sophos;i="6.00,190,1681196400"; d="scan'208";a="769776060" Received: from haibo-optiplex-7090.sh.intel.com ([10.239.159.132]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 May 2023 00:34:35 -0700 From: Haibo Xu To: Cc: xiaobo55x@gmail.com, haibo1.xu@intel.com, ajones@ventanamicro.com, maz@kernel.org, oliver.upton@linux.dev, seanjc@google.com, Paolo Bonzini , Jonathan Corbet , Anup Patel , Atish Patra , Paul Walmsley , Palmer Dabbelt , Albert Ou , Shuah Khan , James Morse , Suzuki K Poulose , Zenghui Yu , David Matlack , Ben Gardon , Vipin Sharma , Colton Lewis , kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kselftest@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Subject: [PATCH v2 09/11] KVM: riscv: selftests: Make check_supported arch specific Date: Thu, 25 May 2023 15:38:33 +0800 Message-Id: <26dea518fc5e8da51e61db279d175364bfecd009.1684999824.git.haibo1.xu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230525_003540_875586_3508006A X-CRM114-Status: GOOD ( 13.45 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org check_supported() was used to verify whether a feature/extension was supported in a guest in the get-reg-list test. Currently this info can be retrieved through the KVM_CAP_ARM_* API in aarch64, but in riscv, this info was only exposed through the KVM_GET_ONE_REG on KVM_REG_RISCV_ISA_EXT pseudo registers. Signed-off-by: Haibo Xu --- tools/testing/selftests/kvm/get-reg-list.c | 32 +++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tools/testing/selftests/kvm/get-reg-list.c b/tools/testing/selftests/kvm/get-reg-list.c index f6ad7991a812..f1fc113e9719 100644 --- a/tools/testing/selftests/kvm/get-reg-list.c +++ b/tools/testing/selftests/kvm/get-reg-list.c @@ -99,6 +99,20 @@ void __weak print_reg(const char *prefix, __u64 id) } #ifdef __aarch64__ +static void check_supported(struct vcpu_reg_list *c) +{ + struct vcpu_reg_sublist *s; + + for_each_sublist(c, s) { + if (!s->capability) + continue; + + __TEST_REQUIRE(kvm_has_cap(s->capability), + "%s: %s not available, skipping tests\n", + config_name(c), s->name); + } +} + static void prepare_vcpu_init(struct vcpu_reg_list *c, struct kvm_vcpu_init *init) { struct vcpu_reg_sublist *s; @@ -126,6 +140,8 @@ static struct kvm_vcpu *vcpu_config_get_vcpu(struct vcpu_reg_list *c, struct kvm struct kvm_vcpu_init init = { .target = -1, }; struct kvm_vcpu *vcpu; + check_supported(c); + prepare_vcpu_init(c, &init); vcpu = __vm_vcpu_add(vm, 0); aarch64_vcpu_setup(vcpu, &init); @@ -140,20 +156,6 @@ static struct kvm_vcpu *vcpu_config_get_vcpu(struct vcpu_reg_list *c, struct kvm } #endif -static void check_supported(struct vcpu_reg_list *c) -{ - struct vcpu_reg_sublist *s; - - for_each_sublist(c, s) { - if (!s->capability) - continue; - - __TEST_REQUIRE(kvm_has_cap(s->capability), - "%s: %s not available, skipping tests\n", - config_name(c), s->name); - } -} - static bool print_list; static bool print_filtered; @@ -165,8 +167,6 @@ static void run_test(struct vcpu_reg_list *c) struct kvm_vm *vm; struct vcpu_reg_sublist *s; - check_supported(c); - vm = vm_create_barebones(); vcpu = vcpu_config_get_vcpu(c, vm);