Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4514565rdb; Tue, 12 Dec 2023 01:22:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IF1BfLpHO9zms696tWWzP83eamDZcUvXKs0KYiVfYsDjJhwdoheQVPl5af3P7FqceVW+/aJ X-Received: by 2002:a05:6e02:1c8b:b0:35d:a1b9:9c0f with SMTP id w11-20020a056e021c8b00b0035da1b99c0fmr4545298ill.116.1702372928065; Tue, 12 Dec 2023 01:22:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702372928; cv=none; d=google.com; s=arc-20160816; b=TKKLPR9Uea9svAMt77ovRUkZnRguarwVYOAOHZ3JJ14Dk7KNlutWnTGiR2raSej4If U+eYgPoQ3WSYf4cFt25udGdcb2rZMZwfCt5TL45JJP6bA7BI7WM//4sK+UdAAUEsf+IJ f7WtBJA2lNc5TOAawFW+nQtTz+S9SDKtQVS5qmhE49t5Ae6w82SYZ7gQldm3tMglmof4 9FbCLiZ4aaec593KsG8zBU9qBhmeEoAUCzxz11XBA9nBnz+6AEwxq/TrwIs4QK0KKtrv xgXA7u4uXEBt/svVVG9wi1JUwzpPMLtF6b1fcgWwLR9T71kwUy8c7NBH9kzuXJpQMFWA bE4A== 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=y9i7oC4TVEmIPpy8QJuZITQ+lUCKP6nmenZBaz9PeFk=; fh=TZrTOSqp+WKl0B8xsF8vu8VOFwsDM2rMDEKmivwBf7U=; b=qLUpwcTDcv2UXjyUzFU/33D6E3p2Oxn4LLK5W5fzB8CqPIjaG15hfV2rVrbCRFmKRY o9g+X1tWAHv2sKD9RpQoblfThVjAWewRUUr42CEoehMbpvunuYXN6TUEfnsV0gXTcwa5 r40y6gSK928G44Dfb2f05T0Y6cYCcAGja2n8PNDjdwn/bpqyZSL8Fpt/FkyS62A55d4U vVtpoNob8D/+fVRZhYp/eGg2HZyBhmMVWeK368TVrtDdYnpYq3kdNKHHs5hJ2P0cDt9G BHbppggayhPk4YiyjPZFB2guyGb8783Na8cVi9aZsWWXFQ+vDcy/g1CTJWI3D5TB/pCd sLxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@intel.com header.s=Intel header.b=E2G3CUkr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id s24-20020a63f058000000b005c65ee483edsi7606767pgj.655.2023.12.12.01.22.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 01:22:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=fail header.i=@intel.com header.s=Intel header.b=E2G3CUkr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 255018056C66; Tue, 12 Dec 2023 01:22:05 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235214AbjLLJVs (ORCPT + 99 others); Tue, 12 Dec 2023 04:21:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235189AbjLLJV3 (ORCPT ); Tue, 12 Dec 2023 04:21:29 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2363AD5; Tue, 12 Dec 2023 01:21:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702372892; x=1733908892; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QhUq9FlvTvIr7jwQydmT4vM1c+dwWoHc5WAb4PAhk+o=; b=E2G3CUkrKXIsSRPCPQVv2cRaitQpnW42sYFbY4DWnL+cvM5L2VOYm1m6 RzAWhSp9sUm/hmgxoXzaMbsbCO/8i3tyNiegtln0blaX0U+vXNYFHQcKp uuzIvV8g3F+tPFdBGS8O3+rcJEe2t/siE55nK7c/0FMCr86tTnv8FQYcq wneP0ZPq2MH2BLoWkxTUlrGxYb9YFKRi0JxdpE8QjYkPAvyrlfOwGmvU3 URiqMi02ZgMrJc8eXl4lC1EvNGMAUt3XVSTsxKdNIm0lQoy7NQANQdTNY nbusEiM/5b8cTZzIiM57LGaf/wLZl4nUzfgiH/du0hEY1lTBrZELzZQ01 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10921"; a="480974446" X-IronPort-AV: E=Sophos;i="6.04,269,1695711600"; d="scan'208";a="480974446" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Dec 2023 01:21:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10921"; a="917213519" X-IronPort-AV: E=Sophos;i="6.04,269,1695711600"; d="scan'208";a="917213519" Received: from haibo-optiplex-7090.sh.intel.com ([10.239.159.132]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Dec 2023 01:21:23 -0800 From: Haibo Xu Cc: xiaobo55x@gmail.com, haibo1.xu@intel.com, ajones@ventanamicro.com, Paul Walmsley , Palmer Dabbelt , Albert Ou , Paolo Bonzini , Shuah Khan , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Anup Patel , Atish Patra , Guo Ren , Mayuresh Chitale , Greentime Hu , Conor Dooley , Heiko Stuebner , Minda Chen , Samuel Holland , Jisheng Zhang , Sean Christopherson , Peter Xu , Like Xu , Vipin Sharma , Maciej Wieczor-Retman , Aaron Lewis , Thomas Huth , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm-riscv@lists.infradead.org Subject: [PATCH v4 09/11] KVM: riscv: selftests: Change vcpu_has_ext to a common function Date: Tue, 12 Dec 2023 17:31:18 +0800 Message-Id: <3972ba512474a0a3c492877db82d19e988d7095e.1702371136.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=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email To: unlisted-recipients:; (no To-header on input) 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 (groat.vger.email [0.0.0.0]); Tue, 12 Dec 2023 01:22:05 -0800 (PST) Move vcpu_has_ext to the processor.c and rename it to __vcpu_has_ext so that other test cases can use it for vCPU extension check. Signed-off-by: Haibo Xu Reviewed-by: Andrew Jones --- tools/testing/selftests/kvm/include/riscv/processor.h | 2 ++ tools/testing/selftests/kvm/lib/riscv/processor.c | 10 ++++++++++ tools/testing/selftests/kvm/riscv/get-reg-list.c | 11 +---------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/kvm/include/riscv/processor.h b/tools/testing/selftests/kvm/include/riscv/processor.h index b68b1b731a34..bd27e1c67579 100644 --- a/tools/testing/selftests/kvm/include/riscv/processor.h +++ b/tools/testing/selftests/kvm/include/riscv/processor.h @@ -42,6 +42,8 @@ static inline uint64_t __kvm_reg_id(uint64_t type, uint64_t idx, #define RISCV_ISA_EXT_REG(idx) __kvm_reg_id(KVM_REG_RISCV_ISA_EXT, \ idx, KVM_REG_SIZE_ULONG) +bool __vcpu_has_ext(struct kvm_vcpu *vcpu, int ext); + struct ex_regs { unsigned long ra; unsigned long sp; diff --git a/tools/testing/selftests/kvm/lib/riscv/processor.c b/tools/testing/selftests/kvm/lib/riscv/processor.c index 39a1e9902dec..dad73ce18164 100644 --- a/tools/testing/selftests/kvm/lib/riscv/processor.c +++ b/tools/testing/selftests/kvm/lib/riscv/processor.c @@ -15,6 +15,16 @@ static vm_vaddr_t exception_handlers; +bool __vcpu_has_ext(struct kvm_vcpu *vcpu, int ext) +{ + unsigned long value = 0; + int ret; + + ret = __vcpu_get_reg(vcpu, RISCV_ISA_EXT_REG(ext), &value); + + return !ret && !!value; +} + static uint64_t page_align(struct kvm_vm *vm, uint64_t v) { return (v + vm->page_size) & ~(vm->page_size - 1); diff --git a/tools/testing/selftests/kvm/riscv/get-reg-list.c b/tools/testing/selftests/kvm/riscv/get-reg-list.c index 6bedaea95395..5da230e86728 100644 --- a/tools/testing/selftests/kvm/riscv/get-reg-list.c +++ b/tools/testing/selftests/kvm/riscv/get-reg-list.c @@ -75,15 +75,6 @@ bool check_reject_set(int err) return err == EINVAL; } -static inline bool vcpu_has_ext(struct kvm_vcpu *vcpu, int ext) -{ - int ret; - unsigned long value; - - ret = __vcpu_get_reg(vcpu, RISCV_ISA_EXT_REG(ext), &value); - return (ret) ? false : !!value; -} - void finalize_vcpu(struct kvm_vcpu *vcpu, struct vcpu_reg_list *c) { unsigned long isa_ext_state[KVM_RISCV_ISA_EXT_MAX] = { 0 }; @@ -111,7 +102,7 @@ void finalize_vcpu(struct kvm_vcpu *vcpu, struct vcpu_reg_list *c) __vcpu_set_reg(vcpu, RISCV_ISA_EXT_REG(s->feature), 1); /* Double check whether the desired extension was enabled */ - __TEST_REQUIRE(vcpu_has_ext(vcpu, s->feature), + __TEST_REQUIRE(__vcpu_has_ext(vcpu, s->feature), "%s not available, skipping tests\n", s->name); } } -- 2.34.1