From patchwork Sat Sep 2 12:59:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xu, Haibo1" X-Patchwork-Id: 13373100 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 96E0CC71153 for ; Sat, 2 Sep 2023 12:54:29 +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=HQCFNTmwzC7uEUKjkJbcR1dktApHJpNExJeDGS3lB1I=; b=gZWMW7WqiRkG5n v4MpB8nYShbPgHCD75DzZsImfviIm6zMZUiwXHgnqC0dneXNtDNniuhnfSA1plZPKyTY4xHAEifci JIITV6SJPxHS2d2nr9WGCvxw0vxL82MNhjtDa5htBK6RztR4Z6nWyelr477MSztrOMX5oBOrsjsU5 or68zYlJQBD11hr7onyyCdG3KUrljJjXaZXkTtiaz2RXwJlSF0iKoXDuLFfsXxCbDt4CEjYWaLenm erfx7hKKseZqGGwqvqqnFYMYsl5ZJOioz8m/0wv7r63r6rcpTvTki1QFmd8hAzjoT8r/WOOCuv1gm McA+6NzfWxPZBnkT4PEw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qcQ8t-001S8Y-1k; Sat, 02 Sep 2023 12:54:23 +0000 Received: from mgamail.intel.com ([134.134.136.20]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qcQ8q-001S6z-1M; Sat, 02 Sep 2023 12:54:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1693659260; x=1725195260; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9YJhysFvLd1mPdbyv9dkpgRLSMU/lWlm/UKAdUMSaGc=; b=A0KTalc6Rjs0y4pBO5V55S070f+Ie/iqaZLOXJZzEWVLLCxLDHBiTryG fQ4/Bw5I0LEBP0mYN0VqxDx+858Ki3WG1w3DDqN/SnUU/HC4IsHSJIFAh 950wYpZEVb+iDYO+jaLdRpaQD+MjycjW1U5VNNAQkLa2JqkMhAsKQmO+F ED3fiAe22GryxkumsG+NAGe5PhRI0hQL3efZVwsrWAk9CRDXcjgBFhrqj ITY1lX0cp5GcGcy4HrvebKl+d0AWeFdaDhz3gYmWiKqwKNL+x1l1bKzAU yZxS2sIfZNar3nRlfoxkiFT/BggJs92XRyc1yIM0w6Xgv4gE4FtNgVPNR Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10821"; a="366599428" X-IronPort-AV: E=Sophos;i="6.02,222,1688454000"; d="scan'208";a="366599428" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2023 05:54:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10821"; a="855022263" X-IronPort-AV: E=Sophos;i="6.02,222,1688454000"; d="scan'208";a="855022263" Received: from haibo-optiplex-7090.sh.intel.com ([10.239.159.132]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2023 05:54:10 -0700 From: Haibo Xu To: 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 , Daniel Henrique Barboza , wchen , Sean Christopherson , Ricardo Koller , Vishal Annapurve , David Matlack , Aaron Lewis , Vitaly Kuznetsov , Ackerley Tng , Mingwei Zhang , Jim Mattson , Lei Wang , Vipin Sharma , Maxim Levitsky , Like Xu , Peter Gonda , Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , David Woodhouse , Michal Luczaj , Paul Durrant , 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 v2 7/8] KVM: riscv: selftest: Change vcpu_has_ext to a common function Date: Sat, 2 Sep 2023 20:59:29 +0800 Message-Id: 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-20230902_055420_497716_20A94B55 X-CRM114-Status: GOOD ( 12.11 ) 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 Move vcpu_has_ext to the processor.c so that other test cases can use it for vCPU extension check. Signed-off-by: Haibo Xu --- .../selftests/kvm/include/riscv/processor.h | 2 ++ tools/testing/selftests/kvm/lib/riscv/processor.c | 9 +++++++++ tools/testing/selftests/kvm/riscv/get-reg-list.c | 14 -------------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests/kvm/include/riscv/processor.h b/tools/testing/selftests/kvm/include/riscv/processor.h index d1e5d9f7ad45..6087c8fc263a 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..5ececa566f24 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..c4028bf32e3f 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;