Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3610748rdb; Wed, 13 Sep 2023 18:31:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEbM5eTEwNh5bMIW/B3bXBDpKvuP3nIDEgQLZNza56qmKDKC7xIQZ5uH6qQI6G+l1mzpZ6j X-Received: by 2002:a17:90a:64ca:b0:271:b6a0:319e with SMTP id i10-20020a17090a64ca00b00271b6a0319emr3778721pjm.19.1694655101969; Wed, 13 Sep 2023 18:31:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694655101; cv=none; d=google.com; s=arc-20160816; b=hvq7nzjOcK/fBcBeUguEx1fAZN99LOT2O6KBgdN6Fzn688bW+x/HtMIxd+c7DBXirT NMVgKfXYRSavkgGxnwEFsnLQRHJsTugWb43LtwF9hOFFbSS3yWZhbgZTzqUzcY4Qwk3Q uThMcGgpCIdNMttuGSHA/XjWbBAOFKTsyliTbHDA0jLOhQgyIfEwGHkFg41dFYnhqXMK qYBqzNmOfsHDQTlI7r7XSJMy+GmKqqlA4vyDq64c610tdCKSDJoipFn+2qbw5aOjgQbY esFIT9Ens0PIQOxDxF9Mmf9DXwxZrsQrp+/wPM5NOS0zbXm8gaFvFIIQrK7PrYE9If+j dmmQ== 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=R63HxU+jdT+MHX52ndgphH+bk7fL8N8rSJgGLXA2GKM=; fh=VNybS12FIGx3OhkJP4loa51tbfdXGqrrDnb3kRCPqo8=; b=K3aB39C/pVpIjmGqM6EISXgaSlity8kY34xpGNgoVq2v4vi46vcNE+EnzXTr0kyOQu 40/F8Ygzh1ZErziTR8hW8PdcS/ftrKjIDLjzC12Sksiyk95eEDcwO9/kLWAG89xyggAm nskoMBqAJM/Py/OqjPkzNN0H+T7yW5shfcuU6Af7eFiLFgxpaqn7MBRsN8Wbuf0wQxMf RHkfnXXEx35sslEuQFbaOvdXUBrE8T+LI8jVv9pgsl/ODoMzkYyjDKl8hi02qxt7+Pik e2XY8SZO9ta0CoKRV4P0E9aZ2k/mDcfw+PykIgurweRelAJ0sFt7kWlR4g9IGPYUJCvz oXEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@intel.com header.s=Intel header.b=J4jGbeHr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id h5-20020a170902680500b001bbbbb61c67si526496plk.542.2023.09.13.18.31.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 18:31:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=fail header.i=@intel.com header.s=Intel header.b=J4jGbeHr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id E468881E0FE0; Wed, 13 Sep 2023 18:30:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233628AbjINBaB (ORCPT + 99 others); Wed, 13 Sep 2023 21:30:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233553AbjINB37 (ORCPT ); Wed, 13 Sep 2023 21:29:59 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F1331BD5; Wed, 13 Sep 2023 18:29:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694654995; x=1726190995; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kszkck1bItOmesIM2X4z8f1oz4GhWjlcbd0j7Gr185w=; b=J4jGbeHrrkCh6XtJrj1EnXl4iYsSNOU7uYepInvyBkHthN4g1HYg2VJX 9z7ccx0zhChzXqGrqPPkUUqkr22xeQRCm1qccCrpiBus5kYV3AWzZL3fA YAobGC+xzhxMffDBeFpRNOc5diVp8VXNDCapd84D5/DlpnBi9zJvAFAJp Kur8VA7s5JuzK6GhENYQKyVtdur38tUDSQUAWbE9kNW0Qb0ATAwKfG7eJ Tlqoqp8DM3AnZWZ8g5AxlYixiWnYlKK/IjkPo8949ZDSrl1nfdibEm9qE OjYt4cISBOwZHC6NBOIJ0ni1vIegRz6yrtY19e/e4vtm/09eog+rHM5X/ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="377734275" X-IronPort-AV: E=Sophos;i="6.02,144,1688454000"; d="scan'208";a="377734275" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2023 18:29:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="694049579" X-IronPort-AV: E=Sophos;i="6.02,144,1688454000"; d="scan'208";a="694049579" Received: from haibo-optiplex-7090.sh.intel.com ([10.239.159.132]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2023 18:29:47 -0700 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 , Sean Christopherson , Ricardo Koller , Vishal Annapurve , Vitaly Kuznetsov , Vipin Sharma , David Matlack , Thomas Huth , Colton Lewis , Aaron Lewis , 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 v3 8/9] KVM: riscv: selftests: Change vcpu_has_ext to a common function Date: Thu, 14 Sep 2023 09:37:02 +0800 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 (lipwig.vger.email [0.0.0.0]); Wed, 13 Sep 2023 18:30:02 -0700 (PDT) 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 --- .../selftests/kvm/include/riscv/processor.h | 2 ++ .../testing/selftests/kvm/lib/riscv/processor.c | 9 +++++++++ tools/testing/selftests/kvm/riscv/get-reg-list.c | 16 +--------------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/tools/testing/selftests/kvm/include/riscv/processor.h b/tools/testing/selftests/kvm/include/riscv/processor.h index 2c975d9cead2..7d5517648ea7 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..e527ad0abc30 100644 --- a/tools/testing/selftests/kvm/lib/riscv/processor.c +++ b/tools/testing/selftests/kvm/lib/riscv/processor.c @@ -15,6 +15,15 @@ static vm_vaddr_t exception_handlers; +bool __vcpu_has_ext(struct kvm_vcpu *vcpu, int ext) +{ + unsigned long value = 0; + + __vcpu_get_reg(vcpu, RISCV_ISA_EXT_REG(ext), &value); + + return !!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 d8ecacd03ecf..0dcff823f287 100644 --- a/tools/testing/selftests/kvm/riscv/get-reg-list.c +++ b/tools/testing/selftests/kvm/riscv/get-reg-list.c @@ -44,20 +44,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); - if (ret) { - printf("Failed to get ext %d", ext); - return false; - } - - return !!value; -} - void finalize_vcpu(struct kvm_vcpu *vcpu, struct vcpu_reg_list *c) { struct vcpu_reg_sublist *s; @@ -77,7 +63,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