Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp586685rwd; Thu, 25 May 2023 00:37:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7VgjbZ8x2rizhlzMoThKFMlwi3/4YdLR6QeGteBdYBT8cmVxLut0RQoy9p3QyChHugpaft X-Received: by 2002:a05:6a20:12c1:b0:101:7ccd:e197 with SMTP id v1-20020a056a2012c100b001017ccde197mr25891771pzg.52.1685000254011; Thu, 25 May 2023 00:37:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685000253; cv=none; d=google.com; s=arc-20160816; b=JSmV09ICfXi2XqHXDbLply2OiHAPE+VG6M67VkdhKZ0VCdnuZG77XxsDR1+0l1/sC/ EF2ljNQQCj5t/TroqLv5C+oszJR8gmczoAorNHW+CXLlXwH5we8rrFESmjnU41otqzUV ypg3oXQZ7CPtGlhkzX1W2I8CP4qMI6z1Tb4EiLes4U09DouUjj1ed6VlpkHaudpA+6eP 24Yd93BMjHlB435RmOf+wqIlFiWjfSs1PZd7VDKwQcMVEjcRKvcUPsjjXeqMl4ZdSlkk kbynxi8m/vcURGXfP1HQdqMikUOHozeUtUNDi0rZJsPGW+POdOZfzHtjQG9yXCL0dJrp AxLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=yVCg8xE8umwzKCxufz4mzcNbszEN2M2B3gGEkUTq3V4=; b=GAqitPhXnHARGJK+9kNcPuK7mOlt1Kb0w1fEB0F4Yy5bOjjGaF70Ev/HAGoKLVNlk0 WjhEfKSEwZP9HsYBYZpYdNNISo1KImkdSDIKqPOsn4QxNo1vg1fGa+4VyMl5jwE/7n1l 6fu5pSjblwJmvcL6GtKxHGuexeaDlg4+gaoGiuV+aO5vV9ElVFmGWKQQ0vjZrHYxFUk5 LM3XhtH6zgYDNcirQntJyzwL5qq3KSSJhilkDOTVqVxYYMZqMstwCLXtOyYdEFEK6rlO 8yUw5CzhVootEEp1oOV6ds3GLviQUfoJDrcK9h064lk0sQvW3mZ6QVXXFGov15o7Wa+u cA3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@intel.com header.s=Intel header.b=lhj8PnLc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l65-20020a639144000000b0051fb9c77447si565281pge.477.2023.05.25.00.37.18; Thu, 25 May 2023 00:37:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@intel.com header.s=Intel header.b=lhj8PnLc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239806AbjEYHgS (ORCPT + 99 others); Thu, 25 May 2023 03:36:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239092AbjEYHfp (ORCPT ); Thu, 25 May 2023 03:35:45 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6665CE68; Thu, 25 May 2023 00:35:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685000134; x=1716536134; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xygKw/lutXpoT+xBrrnIsigg+qVl1ffYhJioaYUxoVg=; b=lhj8PnLcwwX1W2hwZqW48N3mNAdw1FI8QlTfb/YzgRVDodHt7E2NkzMR 4etOMqQeX3rcqSyQi8eNWA3UQeHmS6TyjtYAEKPTHZbiJ/kYSVUizM5W3 P7viPkrCU7/BmJbAUpnMEui6ia/SEvQ/wwh7MIhnZDqjlKanRW5MQA9/B V6FqNreFgWAEHGm4F/6sN1+Ry7lqq9kekJbPuD2Wje+1LtblXLFNnro1v N9rG63F56vM7BfM1BkavqEJoZYTFxLJCTPLPxl7YoBznhSXPofafvmhZe oFGAMBZ/14jEPyPmOSBwHyBn4MesxCQAQCiu09w9lda0kcaAkXmsmg5qL g==; X-IronPort-AV: E=McAfee;i="6600,9927,10720"; a="356164523" X-IronPort-AV: E=Sophos;i="6.00,190,1681196400"; d="scan'208";a="356164523" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.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 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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); -- 2.34.1