Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1113518rbb; Sun, 25 Feb 2024 21:20:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWn/WqECzqMw5HSHeyrQiPfOmXr9mMgEzxFWEDnDsvfjX0eHAmVcoonbnFvm2675sa0tp//1Avg40fTG7CDE+b+q5PH9scVEc9H5MZ0+A== X-Google-Smtp-Source: AGHT+IGxj4NLX5pQr1ZIVIE+W2ilqrzF/dv51t1WjRO49TUpb9uAynjEou4Iw5AgJS8h02K7LWHI X-Received: by 2002:a17:906:3590:b0:a43:4156:96d2 with SMTP id o16-20020a170906359000b00a43415696d2mr1290942ejb.27.1708924815373; Sun, 25 Feb 2024 21:20:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708924815; cv=pass; d=google.com; s=arc-20160816; b=M/QaqySP+wlO8+SlwVpbSXLXLWOFLQpx1GLA92NcKkch7YsmWJ7hnQw7RPGuG1GK7h ETtw/C7e9suwVusPdSEVESQSx5FbaaTy+c6ZVVTNzTqj/M92NnA4JxuoOhI+3AJ/H5SW NYE2PlXjA3V+6FrW07GAqTgVHL0hBGennY9/ywNwd0r/3GOFVtlHIOUQE170pcI0+qPJ do0HKZ0n0KNhsW9w6lPHgbQHAaJK6ofAzvY+fAFKnAHZf2bbbpTpfo+RMFg4XdKEcTzJ TtVJXLIX7I3mxxVy/M2/0EhJ/5+JgMx3seO48wotKSongLodZupNyMrLMuxruk+qYr/y iy8A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=fvD9c59bJDsB22IC2oo8c8Y8bED38e+VeFaxxSdJnPM=; fh=JLzMH5mNaIDT5NW5mmFLMdl3SKtW+QYY1GhziBktKzU=; b=ZIxltUHxGZxgvGo3xiMcu3uYk6ZYgLiFAxtqnaaxyG5gHpEZ5jX9H4NiTbEjXvKtGJ eqZZyAioOrhDCz2oww3WSpHmFp68aeYKuMstP0P1Pdy1vpB9k46xeFTOnTkPFzv6TYDI xCHk/IybPhoTau2FuDMLfz80YiCKbM2DeHiCHLv66tP7d+oZi9aDTfqUxJWI2/2h/zLT 1DLqCSsoHYCILHGVLX/o7OtU7ZZbOnGeNFBrVMtZzjlMG/qIS8FldWr2//jStBul94GE vtTQnFy8PYU3CibR7ey3bwkowqob5/n6t831OHBb/JP9R4zDVDib7AILsBoLPeb9d94p nc8g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@brainfault-org.20230601.gappssmtp.com header.s=20230601 header.b=QEJQDf37; arc=pass (i=1 dkim=pass dkdomain=brainfault-org.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-80563-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80563-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id u21-20020a170906c41500b00a42dfd7cda5si1817697ejz.568.2024.02.25.21.20.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 21:20:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80563-linux.lists.archive=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=@brainfault-org.20230601.gappssmtp.com header.s=20230601 header.b=QEJQDf37; arc=pass (i=1 dkim=pass dkdomain=brainfault-org.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-80563-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80563-linux.lists.archive=gmail.com@vger.kernel.org" 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 E50561F21C3D for ; Mon, 26 Feb 2024 05:20:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B55541B94E; Mon, 26 Feb 2024 05:20:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=brainfault-org.20230601.gappssmtp.com header.i=@brainfault-org.20230601.gappssmtp.com header.b="QEJQDf37" Received: from mail-io1-f50.google.com (mail-io1-f50.google.com [209.85.166.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 34E001B7E5 for ; Mon, 26 Feb 2024 05:20:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708924803; cv=none; b=pBG5f8zcweSTIxaVgtZgpEbl7wQVnxyYuo4iT/WckSHeaO2jlbxAcAFTGaOpyE0gSs24LIyRpSsvyFnS6FbMYjZ1ASzCmoG4HkVw67ictRS6289pTohioJUf4Z76r21oHskuCfGJ33o9hSK5OQqbCdO9E0Pg/ZaTJXIJUqn7XNI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708924803; c=relaxed/simple; bh=/PgP2P0hX/+bEV3aU0WEL7b5JNAP3+sF8FKj2czw6Ho=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Zd6RAwkEYvDuNoisf1GzYyiN0p+X3MQliTOmaU3G/xsTZGDfdtW3p4SyPsmsQaRknl33jBK6YEe5q8CzdAzwr+9GsGv1Asz210t6w32QqAVvQhX+8cxH8Ia+vSZiHXzhQchXlyN4sLJmpEXiq24cVlQSWoBlTBSjd8HzsvM1AbY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=brainfault.org; spf=none smtp.mailfrom=brainfault.org; dkim=pass (2048-bit key) header.d=brainfault-org.20230601.gappssmtp.com header.i=@brainfault-org.20230601.gappssmtp.com header.b=QEJQDf37; arc=none smtp.client-ip=209.85.166.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=brainfault.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=brainfault.org Received: by mail-io1-f50.google.com with SMTP id ca18e2360f4ac-7c788332976so88818539f.3 for ; Sun, 25 Feb 2024 21:20:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20230601.gappssmtp.com; s=20230601; t=1708924800; x=1709529600; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=fvD9c59bJDsB22IC2oo8c8Y8bED38e+VeFaxxSdJnPM=; b=QEJQDf37iHkMJROnf8Q+UJvZI2C6Gz2ji+uywr0fhIn0r5dSI+gmdu8ASiO/xjaUOL ofb8cf0m9VUhr1yydEqCgmV4C13HKUNBy462EOYNnfiW6+p8f482qYid3PxV6+L74NDb 7yfAX20A61KtkADDIpewZYTeZlxq1BuYAQLgNzHtS1CQRg6aXH7Lm6N6TM6pzNcELU4f quXzvcDiK7vhZsJ9/Jts6kux1AOJ+Vg2kpCKTAfUNJHcAOyg+13r8gGwGkHW1X0QjZTb Kk66QkPNl92PD0EL7lApa+SkD6QXRyuZ0G4KeKqJnnUX6gU44Weqk/HC3f6uCRdYJmi+ N8/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708924800; x=1709529600; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fvD9c59bJDsB22IC2oo8c8Y8bED38e+VeFaxxSdJnPM=; b=rXJbPTHnZ7HmSBLr9O+ybCN/wu4F6cjq6KA5RjunSqxKHp7u1lq9TzFUWfiquZCXwO lfJEjMpgCwWtV6a/l0SPo3MQVO143G2gI25cH56ewmR+IzpcB1dg2lJLXahgFIMqiqwr lc5Xst/B8t5j5mwBeykL7esGQEc4xc/TGN2IR0W9cAej90PHkImm4h1PSFrdr4YvqRcW jzZWajJUrEajpuKedPT6s2udDb3uymTaZ5UwVMakkSqa4UG30BRnB5IIGlKyRlMcScoR W8XzVPzY5z029vIu4eJF1UZePLDoQ7sSVXYz44x2pIDlJzZpnczxIAv2xrIs5604IyC8 6WvA== X-Forwarded-Encrypted: i=1; AJvYcCUEQMa87MxUN0KW1AxsfRztAEA3q014oB9etPJV59nthHEelhepYPresk0Uu2vwEViYQSunvXVLGkXwRvBgGoPCikQsKd502nDLQ+iJ X-Gm-Message-State: AOJu0Yz9CHdekPRFdQlf6Qwdu8/Y9qa9x6GB1fCXlD8s6LxDDVIuLWRL pdRPvE4E9JrUmdH6lQ1Sde5b1vUha2kPlhX8umyvNw5b/fKXok/KR12FPb0MMOeZxukpHxADKol A1hnMAgiYjm4MCJ4we8WfXeMFwcnM5J5HNfsI2w== X-Received: by 2002:a05:6e02:d0d:b0:364:216e:d1dc with SMTP id g13-20020a056e020d0d00b00364216ed1dcmr6656541ilj.22.1708924800237; Sun, 25 Feb 2024 21:20:00 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <68856b86a93a4188558e5d0ebac0dd6aac8e404c.1705916069.git.haibo1.xu@intel.com> <2c96c61a-2685-4cee-9cef-963ed833bf92@rivosinc.com> In-Reply-To: <2c96c61a-2685-4cee-9cef-963ed833bf92@rivosinc.com> From: Anup Patel Date: Mon, 26 Feb 2024 10:49:48 +0530 Message-ID: Subject: Re: [PATCH v5 11/12] KVM: riscv: selftests: Change vcpu_has_ext to a common function To: Atish Patra Cc: Haibo Xu , Atish Patra , Haibo Xu , ajones@ventanamicro.com, Paul Walmsley , Palmer Dabbelt , Albert Ou , Paolo Bonzini , Shuah Khan , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Guo Ren , Mayuresh Chitale , Daniel Henrique Barboza , Conor Dooley , Samuel Holland , Minda Chen , Jisheng Zhang , Sean Christopherson , Peter Xu , Like Xu , Vipin Sharma , Thomas Huth , Aaron Lewis , Maciej Wieczor-Retman , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Feb 21, 2024 at 2:07=E2=80=AFPM Atish Patra w= rote: > > On 2/20/24 18:13, Haibo Xu wrote: > > On Wed, Feb 21, 2024 at 7:03=E2=80=AFAM Atish Patra wrote: > >> > >> On Mon, Jan 22, 2024 at 1:48=E2=80=AFAM Haibo Xu = 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 > >>> 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/tool= s/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 =3D 0; > >>> + int ret; > >>> + > >>> + ret =3D __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/5563517cc2012e3326411b360c99= 24d3f2706c8d > >> > >> 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 > > 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 m= erging. > > > > 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 =3D test_args.nr_vcpus; > > vm =3D 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 =3D 0; > >> int ret; > >> > >> - ret =3D __vcpu_get_reg(vcpu, RISCV_ISA_EXT_REG(ext), &value); > >> + ret =3D __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 =3D=3D EINVAL; > >>> } > >>> > >>> -static inline bool vcpu_has_ext(struct kvm_vcpu *vcpu, int ext) > >>> -{ > >>> - int ret; > >>> - unsigned long value; > >>> - > >>> - ret =3D __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] =3D { 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 en= abled */ > >>> - __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 >