Message ID | 68856b86a93a4188558e5d0ebac0dd6aac8e404c.1705916069.git.haibo1.xu@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-32664-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp2466680dyb; Mon, 22 Jan 2024 01:50:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IFpPxgasjQm9Ts18lmWnymNMJq9YvjWir0VsAK73R+JBf9jQlQ16xaUvlxD9bGXt3U4rHtl X-Received: by 2002:ac2:5b0f:0:b0:50f:131c:1d19 with SMTP id v15-20020ac25b0f000000b0050f131c1d19mr780098lfn.59.1705917037115; Mon, 22 Jan 2024 01:50:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705917037; cv=pass; d=google.com; s=arc-20160816; b=leuWmcOfYOG/TsSFHIvC5TkEwPYBLKEBkyp7YRFPWOwTgnDnGkAYHYIGLMCOrgjRn+ GVQ/tutoXND+KEWCqsr6XCXJUtCex8RNdU7sbwf51GZd5Eape8EF5gc00JHs02HKS3Fo VW5IfUi/IOjd80seWMyU7M3WNnLomkPulfGyRFkQG1V5x+1KcAzxEz7w20sOxJZVkxlH 3ndr678Wh+ljEcDl84bz6e3wnwO56tsd2xLJRLiD9n6xHMJl14OAhTO+XsDDDMsKBWkF l2kGqlXU2MTQa8h+ykno2nzeHyl8dFoO/uIfqC5zhjM/mweHyw4XKHE6oGF12xeRRG0D 1r5w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=QvxNXW9Wvw902HG6JUEU8mAh06M7KG53GavXCgIFCiM=; fh=tZI69+l7f1SMD/Lnvo3rJAelKal9VmxkeHVGuH9HHgg=; b=rRouhM1oWpm5mVHzkmsB84LOasbJUFCeXxyeMcUESUOl78tyxlZPttNwRpnowaJ/Vw iQkYEWjcWcDDv6DrUeB/yje5MVxYjSlAa7nmZKnFdd5tImA9yhjaLVE5VcMk6vna/9hW 0rVpeXHCQoaaRvkyTbpiTmgQXLQH6CZvcrVdlXX91mZPrtqgD64ak2eZCpOj9QHUcU0k uUpZIPK40lTi4ghrE85ZSG0y36oGhKH99nDXTgxABHMiTLwwSTY7/hJdBsmxVp4vHlcM RvuDSla7orOnbz+/9esjm2uuHd7AxiyR57fFyT4gqtTehm/h81ZLaBnMyg53YcB/Rmak lCBQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=b8bypusW; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-32664-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32664-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id d37-20020a056402402500b0055c4c163a75si542772eda.668.2024.01.22.01.50.36 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 01:50:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32664-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=b8bypusW; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-32664-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32664-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B46F41F21E07 for <ouuuleilei@gmail.com>; Mon, 22 Jan 2024 09:50:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6CCE43BB28; Mon, 22 Jan 2024 09:48:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="b8bypusW" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 304AA3B790; Mon, 22 Jan 2024 09:48:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705916892; cv=none; b=RXIKjsHNCN/f4Be8cIScPwF/eC/Qxq7K2kEGCWROt/BZFQkLInnoKpKp/u6HwQqsEatB1oevicZcFrmIETEk9b/fKijyKcnQjQigss6JayVa6r6KGIrb2Zv4e684DVCUrjsOXy/mLKfG8980v8HH4ijRVP8KXW6ZWrzhrHOnU7Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705916892; c=relaxed/simple; bh=2adDNSs11ffydm0AYsw6Seh3zPpXT0ndS2F8Q7hAt1Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=p+Ni6hQ2Mt7ZKAiQ4lRIgX7BU5Nrb5fmZSIv1FF8uMvcExrn9KTYcG6XKHWVfH8YxU7bUw35P4pMlFDER3xmNMcXYJjMponKC4HAyY8rCn3JAfBIObxgsZs2qiI3737TFQ7earpl/b/HpbjcgarbAgHxBYncJlDru14Nid+n66A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=b8bypusW; arc=none smtp.client-ip=192.198.163.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705916891; x=1737452891; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2adDNSs11ffydm0AYsw6Seh3zPpXT0ndS2F8Q7hAt1Q=; b=b8bypusWCG2CK21aj+ju8IMswbpLzD4qa+5Zrx8JiAB+f2ZQ9BHzW4zn te3Fe8zkieUrIRaa4P0Uka1xlEw2R24bgRAabk+7IUVuPBEb4xwDv90PZ 51e472tJS+rG/ZmEYS2dT7e1b0jJ1Y8uS2dZ+/+fFNNJIsnlg7xluHnHz fv0t16yXVLzNL5VkrH5vGvb2UsSLC6G4ttj89OVyZ3/gtPPx2Qgg7cMX3 a7+5VStGmgoFH3KS+rAAugUfyHX4uuBVTt6o2SteAINIPof7iK8mohMef yf2ji6Q9wBIiXI6iN9uFc8Y1xmmedBwPfyrGsBz0EP8tX3er1pbspMhz1 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10960"; a="22642040" X-IronPort-AV: E=Sophos;i="6.05,211,1701158400"; d="scan'208";a="22642040" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2024 01:48:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10960"; a="778535584" X-IronPort-AV: E=Sophos;i="6.05,211,1701158400"; d="scan'208";a="778535584" Received: from haibo-optiplex-7090.sh.intel.com ([10.239.159.132]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2024 01:48:00 -0800 From: Haibo Xu <haibo1.xu@intel.com> To: Cc: xiaobo55x@gmail.com, ajones@ventanamicro.com, Haibo Xu <haibo1.xu@intel.com>, Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, Paolo Bonzini <pbonzini@redhat.com>, Shuah Khan <shuah@kernel.org>, Marc Zyngier <maz@kernel.org>, Oliver Upton <oliver.upton@linux.dev>, James Morse <james.morse@arm.com>, Suzuki K Poulose <suzuki.poulose@arm.com>, Zenghui Yu <yuzenghui@huawei.com>, Anup Patel <anup@brainfault.org>, Atish Patra <atishp@atishpatra.org>, Guo Ren <guoren@kernel.org>, Mayuresh Chitale <mchitale@ventanamicro.com>, Daniel Henrique Barboza <dbarboza@ventanamicro.com>, Conor Dooley <conor.dooley@microchip.com>, Samuel Holland <samuel@sholland.org>, Minda Chen <minda.chen@starfivetech.com>, Jisheng Zhang <jszhang@kernel.org>, Sean Christopherson <seanjc@google.com>, Peter Xu <peterx@redhat.com>, Like Xu <likexu@tencent.com>, Vipin Sharma <vipinsh@google.com>, Thomas Huth <thuth@redhat.com>, Aaron Lewis <aaronlewis@google.com>, Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>, 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 v5 11/12] KVM: riscv: selftests: Change vcpu_has_ext to a common function Date: Mon, 22 Jan 2024 17:58:41 +0800 Message-Id: <68856b86a93a4188558e5d0ebac0dd6aac8e404c.1705916069.git.haibo1.xu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <cover.1705916069.git.haibo1.xu@intel.com> References: <cover.1705916069.git.haibo1.xu@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788783663294300161 X-GMAIL-MSGID: 1788783663294300161 |
Series |
RISCV: Add kvm Sstc timer selftests
|
|
Commit Message
Haibo Xu
Jan. 22, 2024, 9:58 a.m. UTC
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 <haibo1.xu@intel.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> --- 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(-)
Comments
On Mon, Jan 22, 2024 at 1:48 AM Haibo Xu <haibo1.xu@intel.com> wrote: > > 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 <haibo1.xu@intel.com> > Reviewed-by: Andrew Jones <ajones@ventanamicro.com> > --- > 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; > +} > + Not sure what was the base patch on which this was rebased. The actual commit in the queue branch looks different. https://github.com/kvm-riscv/linux/commit/5563517cc2012e3326411b360c9924d3f2706c8d Both seem to have the same bug though the tests fail now and require the following fix. The ext id should be uint64_t and we need to pass ext directly so that SBI extension tests can also pass. --- a/tools/testing/selftests/kvm/include/riscv/processor.h +++ b/tools/testing/selftests/kvm/include/riscv/processor.h @@ -48,7 +48,7 @@ static inline uint64_t __kvm_reg_id(uint64_t type, uint64_t subtype, KVM_REG_RISCV_SBI_SINGLE, \ idx, KVM_REG_SIZE_ULONG) -bool __vcpu_has_ext(struct kvm_vcpu *vcpu, int ext); +bool __vcpu_has_ext(struct kvm_vcpu *vcpu, uint64_t ext); struct ex_regs { unsigned long ra; diff --git a/tools/testing/selftests/kvm/lib/riscv/processor.c b/tools/testing/selftests/kvm/lib/riscv/processor.c index 282587cd4bbc..ec66d331a127 100644 --- a/tools/testing/selftests/kvm/lib/riscv/processor.c +++ b/tools/testing/selftests/kvm/lib/riscv/processor.c @@ -15,12 +15,12 @@ static vm_vaddr_t exception_handlers; -bool __vcpu_has_ext(struct kvm_vcpu *vcpu, int ext) +bool __vcpu_has_ext(struct kvm_vcpu *vcpu, uint64_t ext) { unsigned long value = 0; int ret; - ret = __vcpu_get_reg(vcpu, RISCV_ISA_EXT_REG(ext), &value); + ret = __vcpu_get_reg(vcpu, ext, &value); return !ret && !!value; } With the above the fix, Both SBI/ISA extension tests pass. # ./get-reg-list sbi-base: PASS sbi-sta: PASS sbi-pmu: PASS sbi-dbcn: PASS aia: PASS fp_f: PASS fp_d: PASS 1..0 # SKIP - h not available, skipping tests smstateen: PASS sscofpmf: PASS sstc: PASS 1..0 # SKIP - svinval not available, skipping tests 1..0 # SKIP - svnapot not available, skipping tests 1..0 # SKIP - svpbmt not available, skipping tests zba: PASS zbb: PASS zbc: PASS 1..0 # SKIP - zbkb not available, skipping tests 1..0 # SKIP - zbkc not available, skipping tests 1..0 # SKIP - zbkx not available, skipping tests zbs: PASS zfa: PASS 1..0 # SKIP - zfh not available, skipping tests 1..0 # SKIP - zfhmin not available, skipping tests zicbom: PASS zicboz: PASS zicntr: PASS 1..0 # SKIP - zicond not available, skipping tests zicsr: PASS zifencei: PASS zihintntl: PASS zihintpause: PASS zihpm: PASS > 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 25de4b8bc347..ed29ba45588c 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 >
On Wed, Feb 21, 2024 at 7:03 AM Atish Patra <atishp@atishpatra.org> wrote: > > On Mon, Jan 22, 2024 at 1:48 AM Haibo Xu <haibo1.xu@intel.com> wrote: > > > > 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 <haibo1.xu@intel.com> > > Reviewed-by: Andrew Jones <ajones@ventanamicro.com> > > --- > > 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; > > +} > > + > > Not sure what was the base patch on which this was rebased. The actual > commit in the queue branch looks different. > This patch set was based on 6.7-rc8. > https://github.com/kvm-riscv/linux/commit/5563517cc2012e3326411b360c9924d3f2706c8d > > Both seem to have the same bug though the tests fail now and require > the following fix. > The ext id should be uint64_t and we need to pass ext directly so that > SBI extension tests can also pass. > It's weird that 6.7-rc8 has already included Andrew's change on the ISA ext reg, but this patch was not generated against his change. commit bdf6aa328f137e184b0fce607fd585354c3742f1 Author: Andrew Jones <ajones@ventanamicro.com> Date: Wed Dec 13 18:09:58 2023 +0100 RISC-V: KVM: selftests: Treat SBI ext regs like ISA ext regs Anyway, your changes were right. Please go ahead to include them when merging. Thanks, Haibo > > --- a/tools/testing/selftests/kvm/include/riscv/processor.h > +++ b/tools/testing/selftests/kvm/include/riscv/processor.h > @@ -48,7 +48,7 @@ static inline uint64_t __kvm_reg_id(uint64_t type, > uint64_t subtype, > KVM_REG_RISCV_SBI_SINGLE, \ > idx, KVM_REG_SIZE_ULONG) > > -bool __vcpu_has_ext(struct kvm_vcpu *vcpu, int ext); > +bool __vcpu_has_ext(struct kvm_vcpu *vcpu, uint64_t ext); > > struct ex_regs { > unsigned long ra; > diff --git a/tools/testing/selftests/kvm/lib/riscv/processor.c > b/tools/testing/selftests/kvm/lib/riscv/processor.c > index 282587cd4bbc..ec66d331a127 100644 > --- a/tools/testing/selftests/kvm/lib/riscv/processor.c > +++ b/tools/testing/selftests/kvm/lib/riscv/processor.c > @@ -15,12 +15,12 @@ > > static vm_vaddr_t exception_handlers; > > -bool __vcpu_has_ext(struct kvm_vcpu *vcpu, int ext) > +bool __vcpu_has_ext(struct kvm_vcpu *vcpu, uint64_t ext) > { > unsigned long value = 0; > int ret; > > - ret = __vcpu_get_reg(vcpu, RISCV_ISA_EXT_REG(ext), &value); > + ret = __vcpu_get_reg(vcpu, ext, &value); > > return !ret && !!value; > } > > With the above the fix, Both SBI/ISA extension tests pass. > # ./get-reg-list > sbi-base: PASS > sbi-sta: PASS > sbi-pmu: PASS > sbi-dbcn: PASS > aia: PASS > fp_f: PASS > fp_d: PASS > 1..0 # SKIP - h not available, skipping tests > smstateen: PASS > sscofpmf: PASS > sstc: PASS > 1..0 # SKIP - svinval not available, skipping tests > 1..0 # SKIP - svnapot not available, skipping tests > 1..0 # SKIP - svpbmt not available, skipping tests > zba: PASS > zbb: PASS > zbc: PASS > 1..0 # SKIP - zbkb not available, skipping tests > 1..0 # SKIP - zbkc not available, skipping tests > 1..0 # SKIP - zbkx not available, skipping tests > zbs: PASS > zfa: PASS > 1..0 # SKIP - zfh not available, skipping tests > 1..0 # SKIP - zfhmin not available, skipping tests > zicbom: PASS > zicboz: PASS > zicntr: PASS > 1..0 # SKIP - zicond not available, skipping tests > zicsr: PASS > zifencei: PASS > zihintntl: PASS > zihintpause: PASS > zihpm: PASS > > > > 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 25de4b8bc347..ed29ba45588c 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 > > > > > -- > Regards, > Atish
On 2/20/24 18:13, Haibo Xu wrote: > On Wed, Feb 21, 2024 at 7:03 AM Atish Patra <atishp@atishpatra.org> wrote: >> >> On Mon, Jan 22, 2024 at 1:48 AM Haibo Xu <haibo1.xu@intel.com> wrote: >>> >>> 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 <haibo1.xu@intel.com> >>> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> >>> --- >>> 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; >>> +} >>> + >> >> Not sure what was the base patch on which this was rebased. The actual >> commit in the queue branch looks different. >> > > This patch set was based on 6.7-rc8. > >> https://github.com/kvm-riscv/linux/commit/5563517cc2012e3326411b360c9924d3f2706c8d >> >> Both seem to have the same bug though the tests fail now and require >> the following fix. >> The ext id should be uint64_t and we need to pass ext directly so that >> SBI extension tests can also pass. >> > > It's weird that 6.7-rc8 has already included Andrew's change on the ISA ext reg, > but this patch was not generated against his change. > > commit bdf6aa328f137e184b0fce607fd585354c3742f1 > Author: Andrew Jones <ajones@ventanamicro.com> > Date: Wed Dec 13 18:09:58 2023 +0100 > > RISC-V: KVM: selftests: Treat SBI ext regs like ISA ext regs > > Anyway, your changes were right. Please go ahead to include them when merging. > I am not sure what happened. Probably, a merge conflict issue. I just realized I forgot to copy paste another fix in arch timer +++ b/tools/testing/selftests/kvm/riscv/arch_timer.c @@ -85,7 +85,7 @@ struct kvm_vm *test_vm_create(void) int nr_vcpus = test_args.nr_vcpus; vm = vm_create_with_vcpus(nr_vcpus, guest_code, vcpus); - __TEST_REQUIRE(__vcpu_has_ext(vcpus[0], KVM_RISCV_ISA_EXT_SSTC), + __TEST_REQUIRE(__vcpu_has_ext(vcpus[0], RISCV_ISA_EXT_REG(KVM_RISCV_ISA_EXT_SSTC)), > Thanks, > Haibo > >> >> --- a/tools/testing/selftests/kvm/include/riscv/processor.h >> +++ b/tools/testing/selftests/kvm/include/riscv/processor.h >> @@ -48,7 +48,7 @@ static inline uint64_t __kvm_reg_id(uint64_t type, >> uint64_t subtype, >> KVM_REG_RISCV_SBI_SINGLE, \ >> idx, KVM_REG_SIZE_ULONG) >> >> -bool __vcpu_has_ext(struct kvm_vcpu *vcpu, int ext); >> +bool __vcpu_has_ext(struct kvm_vcpu *vcpu, uint64_t ext); >> >> struct ex_regs { >> unsigned long ra; >> diff --git a/tools/testing/selftests/kvm/lib/riscv/processor.c >> b/tools/testing/selftests/kvm/lib/riscv/processor.c >> index 282587cd4bbc..ec66d331a127 100644 >> --- a/tools/testing/selftests/kvm/lib/riscv/processor.c >> +++ b/tools/testing/selftests/kvm/lib/riscv/processor.c >> @@ -15,12 +15,12 @@ >> >> static vm_vaddr_t exception_handlers; >> >> -bool __vcpu_has_ext(struct kvm_vcpu *vcpu, int ext) >> +bool __vcpu_has_ext(struct kvm_vcpu *vcpu, uint64_t ext) >> { >> unsigned long value = 0; >> int ret; >> >> - ret = __vcpu_get_reg(vcpu, RISCV_ISA_EXT_REG(ext), &value); >> + ret = __vcpu_get_reg(vcpu, ext, &value); >> >> return !ret && !!value; >> } >> >> With the above the fix, Both SBI/ISA extension tests pass. >> # ./get-reg-list >> sbi-base: PASS >> sbi-sta: PASS >> sbi-pmu: PASS >> sbi-dbcn: PASS >> aia: PASS >> fp_f: PASS >> fp_d: PASS >> 1..0 # SKIP - h not available, skipping tests >> smstateen: PASS >> sscofpmf: PASS >> sstc: PASS >> 1..0 # SKIP - svinval not available, skipping tests >> 1..0 # SKIP - svnapot not available, skipping tests >> 1..0 # SKIP - svpbmt not available, skipping tests >> zba: PASS >> zbb: PASS >> zbc: PASS >> 1..0 # SKIP - zbkb not available, skipping tests >> 1..0 # SKIP - zbkc not available, skipping tests >> 1..0 # SKIP - zbkx not available, skipping tests >> zbs: PASS >> zfa: PASS >> 1..0 # SKIP - zfh not available, skipping tests >> 1..0 # SKIP - zfhmin not available, skipping tests >> zicbom: PASS >> zicboz: PASS >> zicntr: PASS >> 1..0 # SKIP - zicond not available, skipping tests >> zicsr: PASS >> zifencei: PASS >> zihintntl: PASS >> zihintpause: PASS >> zihpm: PASS >> >> >>> 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 25de4b8bc347..ed29ba45588c 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 >>> >> >> >> -- >> Regards, >> Atish
On Wed, Feb 21, 2024 at 4:37 PM Atish Patra <atishp@rivosinc.com> wrote: > > On 2/20/24 18:13, Haibo Xu wrote: > > On Wed, Feb 21, 2024 at 7:03 AM Atish Patra <atishp@atishpatra.org> wrote: > >> > >> On Mon, Jan 22, 2024 at 1:48 AM Haibo Xu <haibo1.xu@intel.com> wrote: > >>> > >>> 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 <haibo1.xu@intel.com> > >>> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> > >>> --- > >>> 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; > >>> +} > >>> + > >> > >> Not sure what was the base patch on which this was rebased. The actual > >> commit in the queue branch looks different. > >> > > > > This patch set was based on 6.7-rc8. > > > >> https://github.com/kvm-riscv/linux/commit/5563517cc2012e3326411b360c9924d3f2706c8d > >> > >> Both seem to have the same bug though the tests fail now and require > >> the following fix. > >> The ext id should be uint64_t and we need to pass ext directly so that > >> SBI extension tests can also pass. > >> > > > > It's weird that 6.7-rc8 has already included Andrew's change on the ISA ext reg, > > but this patch was not generated against his change. > > > > commit bdf6aa328f137e184b0fce607fd585354c3742f1 > > Author: Andrew Jones <ajones@ventanamicro.com> > > Date: Wed Dec 13 18:09:58 2023 +0100 > > > > RISC-V: KVM: selftests: Treat SBI ext regs like ISA ext regs > > > > Anyway, your changes were right. Please go ahead to include them when merging. > > > > I am not sure what happened. Probably, a merge conflict issue. > > I just realized I forgot to copy paste another fix in arch timer > > +++ b/tools/testing/selftests/kvm/riscv/arch_timer.c > @@ -85,7 +85,7 @@ struct kvm_vm *test_vm_create(void) > int nr_vcpus = test_args.nr_vcpus; > > vm = vm_create_with_vcpus(nr_vcpus, guest_code, vcpus); > - __TEST_REQUIRE(__vcpu_has_ext(vcpus[0], KVM_RISCV_ISA_EXT_SSTC), > + __TEST_REQUIRE(__vcpu_has_ext(vcpus[0], > RISCV_ISA_EXT_REG(KVM_RISCV_ISA_EXT_SSTC)), > Right Fix! Please let me know if I need to rebase this patch series on your tree and resent it. Thanks, Haibo
On 2/21/24 05:08, Haibo Xu wrote: > On Wed, Feb 21, 2024 at 4:37 PM Atish Patra <atishp@rivosinc.com> wrote: >> >> On 2/20/24 18:13, Haibo Xu wrote: >>> On Wed, Feb 21, 2024 at 7:03 AM Atish Patra <atishp@atishpatra.org> wrote: >>>> >>>> On Mon, Jan 22, 2024 at 1:48 AM Haibo Xu <haibo1.xu@intel.com> wrote: >>>>> >>>>> 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 <haibo1.xu@intel.com> >>>>> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> >>>>> --- >>>>> 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; >>>>> +} >>>>> + >>>> >>>> Not sure what was the base patch on which this was rebased. The actual >>>> commit in the queue branch looks different. >>>> >>> >>> This patch set was based on 6.7-rc8. >>> >>>> https://github.com/kvm-riscv/linux/commit/5563517cc2012e3326411b360c9924d3f2706c8d >>>> >>>> Both seem to have the same bug though the tests fail now and require >>>> the following fix. >>>> The ext id should be uint64_t and we need to pass ext directly so that >>>> SBI extension tests can also pass. >>>> >>> >>> It's weird that 6.7-rc8 has already included Andrew's change on the ISA ext reg, >>> but this patch was not generated against his change. >>> >>> commit bdf6aa328f137e184b0fce607fd585354c3742f1 >>> Author: Andrew Jones <ajones@ventanamicro.com> >>> Date: Wed Dec 13 18:09:58 2023 +0100 >>> >>> RISC-V: KVM: selftests: Treat SBI ext regs like ISA ext regs >>> >>> Anyway, your changes were right. Please go ahead to include them when merging. >>> >> >> I am not sure what happened. Probably, a merge conflict issue. >> >> I just realized I forgot to copy paste another fix in arch timer >> >> +++ b/tools/testing/selftests/kvm/riscv/arch_timer.c >> @@ -85,7 +85,7 @@ struct kvm_vm *test_vm_create(void) >> int nr_vcpus = test_args.nr_vcpus; >> >> vm = vm_create_with_vcpus(nr_vcpus, guest_code, vcpus); >> - __TEST_REQUIRE(__vcpu_has_ext(vcpus[0], KVM_RISCV_ISA_EXT_SSTC), >> + __TEST_REQUIRE(__vcpu_has_ext(vcpus[0], >> RISCV_ISA_EXT_REG(KVM_RISCV_ISA_EXT_SSTC)), >> > > Right Fix! > Please let me know if I need to rebase this patch series on your tree > and resent it. > That's Anup's call. > Thanks, > Haibo > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv
On Wed, Feb 21, 2024 at 2:07 PM Atish Patra <atishp@rivosinc.com> wrote: > > On 2/20/24 18:13, Haibo Xu wrote: > > On Wed, Feb 21, 2024 at 7:03 AM Atish Patra <atishp@atishpatra.org> wrote: > >> > >> On Mon, Jan 22, 2024 at 1:48 AM Haibo Xu <haibo1.xu@intel.com> wrote: > >>> > >>> 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 <haibo1.xu@intel.com> > >>> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> > >>> --- > >>> 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; > >>> +} > >>> + > >> > >> Not sure what was the base patch on which this was rebased. The actual > >> commit in the queue branch looks different. > >> > > > > This patch set was based on 6.7-rc8. > > > >> https://github.com/kvm-riscv/linux/commit/5563517cc2012e3326411b360c9924d3f2706c8d > >> > >> Both seem to have the same bug though the tests fail now and require > >> the following fix. > >> The ext id should be uint64_t and we need to pass ext directly so that > >> SBI extension tests can also pass. > >> > > > > It's weird that 6.7-rc8 has already included Andrew's change on the ISA ext reg, > > but this patch was not generated against his change. > > > > commit bdf6aa328f137e184b0fce607fd585354c3742f1 > > Author: Andrew Jones <ajones@ventanamicro.com> > > Date: Wed Dec 13 18:09:58 2023 +0100 > > > > RISC-V: KVM: selftests: Treat SBI ext regs like ISA ext regs > > > > Anyway, your changes were right. Please go ahead to include them when merging. > > > > I am not sure what happened. Probably, a merge conflict issue. > > I just realized I forgot to copy paste another fix in arch timer > > +++ b/tools/testing/selftests/kvm/riscv/arch_timer.c > @@ -85,7 +85,7 @@ struct kvm_vm *test_vm_create(void) > int nr_vcpus = test_args.nr_vcpus; > > vm = vm_create_with_vcpus(nr_vcpus, guest_code, vcpus); > - __TEST_REQUIRE(__vcpu_has_ext(vcpus[0], KVM_RISCV_ISA_EXT_SSTC), > + __TEST_REQUIRE(__vcpu_has_ext(vcpus[0], > RISCV_ISA_EXT_REG(KVM_RISCV_ISA_EXT_SSTC)), I have squashed this change into an existing commit in riscv_kvm_queue. Thanks, Anup > > > > Thanks, > > Haibo > > > >> > >> --- a/tools/testing/selftests/kvm/include/riscv/processor.h > >> +++ b/tools/testing/selftests/kvm/include/riscv/processor.h > >> @@ -48,7 +48,7 @@ static inline uint64_t __kvm_reg_id(uint64_t type, > >> uint64_t subtype, > >> KVM_REG_RISCV_SBI_SINGLE, \ > >> idx, KVM_REG_SIZE_ULONG) > >> > >> -bool __vcpu_has_ext(struct kvm_vcpu *vcpu, int ext); > >> +bool __vcpu_has_ext(struct kvm_vcpu *vcpu, uint64_t ext); > >> > >> struct ex_regs { > >> unsigned long ra; > >> diff --git a/tools/testing/selftests/kvm/lib/riscv/processor.c > >> b/tools/testing/selftests/kvm/lib/riscv/processor.c > >> index 282587cd4bbc..ec66d331a127 100644 > >> --- a/tools/testing/selftests/kvm/lib/riscv/processor.c > >> +++ b/tools/testing/selftests/kvm/lib/riscv/processor.c > >> @@ -15,12 +15,12 @@ > >> > >> static vm_vaddr_t exception_handlers; > >> > >> -bool __vcpu_has_ext(struct kvm_vcpu *vcpu, int ext) > >> +bool __vcpu_has_ext(struct kvm_vcpu *vcpu, uint64_t ext) > >> { > >> unsigned long value = 0; > >> int ret; > >> > >> - ret = __vcpu_get_reg(vcpu, RISCV_ISA_EXT_REG(ext), &value); > >> + ret = __vcpu_get_reg(vcpu, ext, &value); > >> > >> return !ret && !!value; > >> } > >> > >> With the above the fix, Both SBI/ISA extension tests pass. > >> # ./get-reg-list > >> sbi-base: PASS > >> sbi-sta: PASS > >> sbi-pmu: PASS > >> sbi-dbcn: PASS > >> aia: PASS > >> fp_f: PASS > >> fp_d: PASS > >> 1..0 # SKIP - h not available, skipping tests > >> smstateen: PASS > >> sscofpmf: PASS > >> sstc: PASS > >> 1..0 # SKIP - svinval not available, skipping tests > >> 1..0 # SKIP - svnapot not available, skipping tests > >> 1..0 # SKIP - svpbmt not available, skipping tests > >> zba: PASS > >> zbb: PASS > >> zbc: PASS > >> 1..0 # SKIP - zbkb not available, skipping tests > >> 1..0 # SKIP - zbkc not available, skipping tests > >> 1..0 # SKIP - zbkx not available, skipping tests > >> zbs: PASS > >> zfa: PASS > >> 1..0 # SKIP - zfh not available, skipping tests > >> 1..0 # SKIP - zfhmin not available, skipping tests > >> zicbom: PASS > >> zicboz: PASS > >> zicntr: PASS > >> 1..0 # SKIP - zicond not available, skipping tests > >> zicsr: PASS > >> zifencei: PASS > >> zihintntl: PASS > >> zihintpause: PASS > >> zihpm: PASS > >> > >> > >>> 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 25de4b8bc347..ed29ba45588c 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 > >>> > >> > >> > >> -- > >> Regards, > >> Atish >
On Mon, Feb 26, 2024 at 1:20 PM Anup Patel <anup@brainfault.org> wrote: > > On Wed, Feb 21, 2024 at 2:07 PM Atish Patra <atishp@rivosinc.com> wrote: > > > > On 2/20/24 18:13, Haibo Xu wrote: > > > On Wed, Feb 21, 2024 at 7:03 AM Atish Patra <atishp@atishpatra.org> wrote: > > >> > > >> On Mon, Jan 22, 2024 at 1:48 AM Haibo Xu <haibo1.xu@intel.com> wrote: > > >>> > > >>> 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 <haibo1.xu@intel.com> > > >>> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> > > >>> --- > > >>> 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; > > >>> +} > > >>> + > > >> > > >> Not sure what was the base patch on which this was rebased. The actual > > >> commit in the queue branch looks different. > > >> > > > > > > This patch set was based on 6.7-rc8. > > > > > >> https://github.com/kvm-riscv/linux/commit/5563517cc2012e3326411b360c9924d3f2706c8d > > >> > > >> Both seem to have the same bug though the tests fail now and require > > >> the following fix. > > >> The ext id should be uint64_t and we need to pass ext directly so that > > >> SBI extension tests can also pass. > > >> > > > > > > It's weird that 6.7-rc8 has already included Andrew's change on the ISA ext reg, > > > but this patch was not generated against his change. > > > > > > commit bdf6aa328f137e184b0fce607fd585354c3742f1 > > > Author: Andrew Jones <ajones@ventanamicro.com> > > > Date: Wed Dec 13 18:09:58 2023 +0100 > > > > > > RISC-V: KVM: selftests: Treat SBI ext regs like ISA ext regs > > > > > > Anyway, your changes were right. Please go ahead to include them when merging. > > > > > > > I am not sure what happened. Probably, a merge conflict issue. > > > > I just realized I forgot to copy paste another fix in arch timer > > > > +++ b/tools/testing/selftests/kvm/riscv/arch_timer.c > > @@ -85,7 +85,7 @@ struct kvm_vm *test_vm_create(void) > > int nr_vcpus = test_args.nr_vcpus; > > > > vm = vm_create_with_vcpus(nr_vcpus, guest_code, vcpus); > > - __TEST_REQUIRE(__vcpu_has_ext(vcpus[0], KVM_RISCV_ISA_EXT_SSTC), > > + __TEST_REQUIRE(__vcpu_has_ext(vcpus[0], > > RISCV_ISA_EXT_REG(KVM_RISCV_ISA_EXT_SSTC)), > > I have squashed this change into an existing commit in riscv_kvm_queue. > > Thanks, > Anup > Thanks a lot, Anup! > > > > > > > Thanks, > > > Haibo > > > > > >> > > >> --- a/tools/testing/selftests/kvm/include/riscv/processor.h > > >> +++ b/tools/testing/selftests/kvm/include/riscv/processor.h > > >> @@ -48,7 +48,7 @@ static inline uint64_t __kvm_reg_id(uint64_t type, > > >> uint64_t subtype, > > >> KVM_REG_RISCV_SBI_SINGLE, \ > > >> idx, KVM_REG_SIZE_ULONG) > > >> > > >> -bool __vcpu_has_ext(struct kvm_vcpu *vcpu, int ext); > > >> +bool __vcpu_has_ext(struct kvm_vcpu *vcpu, uint64_t ext); > > >> > > >> struct ex_regs { > > >> unsigned long ra; > > >> diff --git a/tools/testing/selftests/kvm/lib/riscv/processor.c > > >> b/tools/testing/selftests/kvm/lib/riscv/processor.c > > >> index 282587cd4bbc..ec66d331a127 100644 > > >> --- a/tools/testing/selftests/kvm/lib/riscv/processor.c > > >> +++ b/tools/testing/selftests/kvm/lib/riscv/processor.c > > >> @@ -15,12 +15,12 @@ > > >> > > >> static vm_vaddr_t exception_handlers; > > >> > > >> -bool __vcpu_has_ext(struct kvm_vcpu *vcpu, int ext) > > >> +bool __vcpu_has_ext(struct kvm_vcpu *vcpu, uint64_t ext) > > >> { > > >> unsigned long value = 0; > > >> int ret; > > >> > > >> - ret = __vcpu_get_reg(vcpu, RISCV_ISA_EXT_REG(ext), &value); > > >> + ret = __vcpu_get_reg(vcpu, ext, &value); > > >> > > >> return !ret && !!value; > > >> } > > >> > > >> With the above the fix, Both SBI/ISA extension tests pass. > > >> # ./get-reg-list > > >> sbi-base: PASS > > >> sbi-sta: PASS > > >> sbi-pmu: PASS > > >> sbi-dbcn: PASS > > >> aia: PASS > > >> fp_f: PASS > > >> fp_d: PASS > > >> 1..0 # SKIP - h not available, skipping tests > > >> smstateen: PASS > > >> sscofpmf: PASS > > >> sstc: PASS > > >> 1..0 # SKIP - svinval not available, skipping tests > > >> 1..0 # SKIP - svnapot not available, skipping tests > > >> 1..0 # SKIP - svpbmt not available, skipping tests > > >> zba: PASS > > >> zbb: PASS > > >> zbc: PASS > > >> 1..0 # SKIP - zbkb not available, skipping tests > > >> 1..0 # SKIP - zbkc not available, skipping tests > > >> 1..0 # SKIP - zbkx not available, skipping tests > > >> zbs: PASS > > >> zfa: PASS > > >> 1..0 # SKIP - zfh not available, skipping tests > > >> 1..0 # SKIP - zfhmin not available, skipping tests > > >> zicbom: PASS > > >> zicboz: PASS > > >> zicntr: PASS > > >> 1..0 # SKIP - zicond not available, skipping tests > > >> zicsr: PASS > > >> zifencei: PASS > > >> zihintntl: PASS > > >> zihintpause: PASS > > >> zihpm: PASS > > >> > > >> > > >>> 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 25de4b8bc347..ed29ba45588c 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 > > >>> > > >> > > >> > > >> -- > > >> Regards, > > >> Atish > >
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 25de4b8bc347..ed29ba45588c 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); } }