Message ID | 73045958d9ab71d5266d012f1e13061afa8c5331.1686275310.git.haibo1.xu@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp667164vqr; Thu, 8 Jun 2023 19:25:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5XBRo5IqcTlZtxGSfUcxXqYxtqQXZFG2y4Se12V+tewyb9c2lMbXSVDRdN4steaKJUz9Tn X-Received: by 2002:a05:6808:1445:b0:39c:532b:fe43 with SMTP id x5-20020a056808144500b0039c532bfe43mr335688oiv.21.1686277517187; Thu, 08 Jun 2023 19:25:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686277517; cv=none; d=google.com; s=arc-20160816; b=nYSW4xVtaAiee4APR//YZ4hjxTwwaImAWuJVHawoWf3ae+0B8rvPq4tgz1ed78GG/R hBuNQsVrp9lKZGelXJSZrL/6DYBhNPZL79w44kd85xhBxue0D6EPaz7OJqrBmVGmWrvd 1Hd5NrWMtxK4OsTMFqWJZN78JsZgheb83/sm0BhcjYy39M9Rik/q/2W2d1vvnA/BoS/P H3tiFs6Fs9YdehrXGP7MFp7k1Tmo8WMkCJN4fop7zxf+9GYG+s4FCy2eyCjVym10pln6 aXqzuhhwgNDzRum7JjqgLkKuvEYLhf2kYergpqxmzsFq+ZldO2eKPW+ci7ATaXpGkRVZ 9Xkg== 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=8dM9xk2ca1HU6WT20mPAxWC8d0Jo9ynuPEQMKvO0WCU=; b=Ya78xJIoROC04gjpNAJSK0IBXGnX3eSIe76X9NO3lQdwgPyMeRWJCSpZZFvxoRCj/O 2ZBUBbBNyL8bnMO+PpRuFfKpVuxJLNuFmPzRB2St/kKKFHkkAM6+fox8OpJ9y/DqlXGq FTtFWvKzCLY/g7JoWqPfe/7sDO82p8pcErvGsjWf3KK9oMmkhEjN5KwQtKULoeqQhTDD iTKe2It2mfqQedHNWReNOLm/ARWQAYihncjcDtl6knEupCcJnM4iwO1Rei4El2qRJ0LZ 1eRHt4qvue0Z5d61kq0fZJBKkhva/30o+pRSHT1HxPBI90M1HtrDhJxZTYI7E6otfYfY 68Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@intel.com header.s=Intel header.b=hiXVagbN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w187-20020a627bc4000000b0065304909e29si1690526pfc.187.2023.06.08.19.25.02; Thu, 08 Jun 2023 19:25:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@intel.com header.s=Intel header.b=hiXVagbN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238271AbjFICJE (ORCPT <rfc822;literming00@gmail.com> + 99 others); Thu, 8 Jun 2023 22:09:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230126AbjFICJC (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 8 Jun 2023 22:09:02 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCE483A94; Thu, 8 Jun 2023 19:08:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686276510; x=1717812510; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EulOffrCSj4eOemj+Y35+bpErgFuZayXZ81lRq+53/o=; b=hiXVagbNeYBTi1wYoSc/+pT77N2Vj3UIESxBZVyqxgrEXMjXe9w23T5G amEyGTlP7t4qCGu5RGZgASK+cLgU+Y0ISUnlCr2yDMzb5MMNvyQmUilpZ SPz5YQK32tqrKuXvxGIJSDGwR/EJROF7YjjtXIB9EugohCQ9QFgI67pCD X6EvPmWrbgo4g91hTq74nD6i/mUjdWJapAi7IGiCiqWLBP5nOwcqGD16s aSNeCGrQk6BBfQ9eM4b+ypih/FQFdp0q5GRihny2hEP8JwNQXmjqTwdky RbkZ9i7o3J4tiTgJCEJVLhUscaweYshEIaXgVeqFn4JB7djPZJ6R0UVpJ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10735"; a="359975744" X-IronPort-AV: E=Sophos;i="6.00,228,1681196400"; d="scan'208";a="359975744" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jun 2023 19:08:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10735"; a="713334947" X-IronPort-AV: E=Sophos;i="6.00,228,1681196400"; d="scan'208";a="713334947" Received: from haibo-optiplex-7090.sh.intel.com ([10.239.159.132]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jun 2023 19:08:11 -0700 From: Haibo Xu <haibo1.xu@intel.com> Cc: xiaobo55x@gmail.com, haibo1.xu@intel.com, ajones@ventanamicro.com, maz@kernel.org, oliver.upton@linux.dev, seanjc@google.com, Paolo Bonzini <pbonzini@redhat.com>, Jonathan Corbet <corbet@lwn.net>, Anup Patel <anup@brainfault.org>, Atish Patra <atishp@atishpatra.org>, Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, Shuah Khan <shuah@kernel.org>, James Morse <james.morse@arm.com>, Suzuki K Poulose <suzuki.poulose@arm.com>, Zenghui Yu <yuzenghui@huawei.com>, David Matlack <dmatlack@google.com>, Ben Gardon <bgardon@google.com>, Vipin Sharma <vipinsh@google.com>, Colton Lewis <coltonlewis@google.com>, kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kselftest@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Subject: [PATCH v3 09/10] KVM: riscv: selftests: Skip some registers set operation Date: Fri, 9 Jun 2023 10:12:17 +0800 Message-Id: <73045958d9ab71d5266d012f1e13061afa8c5331.1686275310.git.haibo1.xu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <cover.1686275310.git.haibo1.xu@intel.com> References: <cover.1686275310.git.haibo1.xu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768190133848909988?= X-GMAIL-MSGID: =?utf-8?q?1768190133848909988?= |
Series |
RISCV: Add KVM_GET_REG_LIST API
|
|
Commit Message
Haibo Xu
June 9, 2023, 2:12 a.m. UTC
Set operation on some riscv registers(mostly pesudo ones) was not supported and should be skipped in the get-reg-list test. Just reuse the rejects_set utilities to handle it in riscv. Signed-off-by: Haibo Xu <haibo1.xu@intel.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> --- tools/testing/selftests/kvm/get-reg-list.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
Comments
On Fri, Jun 09, 2023 at 10:12:17AM +0800, Haibo Xu wrote: > Set operation on some riscv registers(mostly pesudo ones) was not > supported and should be skipped in the get-reg-list test. Just > reuse the rejects_set utilities to handle it in riscv. > > Signed-off-by: Haibo Xu <haibo1.xu@intel.com> > Reviewed-by: Andrew Jones <ajones@ventanamicro.com> > --- > tools/testing/selftests/kvm/get-reg-list.c | 20 +++++++++++++------- > 1 file changed, 13 insertions(+), 7 deletions(-) > > diff --git a/tools/testing/selftests/kvm/get-reg-list.c b/tools/testing/selftests/kvm/get-reg-list.c > index c4bd5a5259da..abacb95c21c6 100644 > --- a/tools/testing/selftests/kvm/get-reg-list.c > +++ b/tools/testing/selftests/kvm/get-reg-list.c > @@ -211,16 +211,22 @@ static void run_test(struct vcpu_reg_list *c) > ++failed_get; > } > > - /* rejects_set registers are rejected after KVM_ARM_VCPU_FINALIZE */ > + /* > + * rejects_set registers are rejected after KVM_ARM_VCPU_FINALIZE on aarch64, > + * or registers that should skip set operation on riscv. > + */ > for_each_sublist(c, s) { > if (s->rejects_set && find_reg(s->rejects_set, s->rejects_set_n, reg.id)) { > reject_reg = true; > - ret = __vcpu_ioctl(vcpu, KVM_SET_ONE_REG, ®); > - if (ret != -1 || errno != EPERM) { > - printf("%s: Failed to reject (ret=%d, errno=%d) ", config_name(c), ret, errno); > - print_reg(config_name(c), reg.id); > - putchar('\n'); > - ++failed_reject; > + if ((reg.id & KVM_REG_ARCH_MASK) == KVM_REG_ARM64) { > + ret = __vcpu_ioctl(vcpu, KVM_SET_ONE_REG, ®); > + if (ret != -1 || errno != EPERM) { > + printf("%s: Failed to reject (ret=%d, errno=%d) ", > + config_name(c), ret, errno); > + print_reg(config_name(c), reg.id); > + putchar('\n'); > + ++failed_reject; > + } Thinking about this some more, shouldn't we attempt the set ioctl for riscv reject registers as well, but look for different error numbers? Thanks, drew
On Fri, Jun 9, 2023 at 5:24 PM Andrew Jones <ajones@ventanamicro.com> wrote: > > On Fri, Jun 09, 2023 at 10:12:17AM +0800, Haibo Xu wrote: > > Set operation on some riscv registers(mostly pesudo ones) was not > > supported and should be skipped in the get-reg-list test. Just > > reuse the rejects_set utilities to handle it in riscv. > > > > Signed-off-by: Haibo Xu <haibo1.xu@intel.com> > > Reviewed-by: Andrew Jones <ajones@ventanamicro.com> > > --- > > tools/testing/selftests/kvm/get-reg-list.c | 20 +++++++++++++------- > > 1 file changed, 13 insertions(+), 7 deletions(-) > > > > diff --git a/tools/testing/selftests/kvm/get-reg-list.c b/tools/testing/selftests/kvm/get-reg-list.c > > index c4bd5a5259da..abacb95c21c6 100644 > > --- a/tools/testing/selftests/kvm/get-reg-list.c > > +++ b/tools/testing/selftests/kvm/get-reg-list.c > > @@ -211,16 +211,22 @@ static void run_test(struct vcpu_reg_list *c) > > ++failed_get; > > } > > > > - /* rejects_set registers are rejected after KVM_ARM_VCPU_FINALIZE */ > > + /* > > + * rejects_set registers are rejected after KVM_ARM_VCPU_FINALIZE on aarch64, > > + * or registers that should skip set operation on riscv. > > + */ > > for_each_sublist(c, s) { > > if (s->rejects_set && find_reg(s->rejects_set, s->rejects_set_n, reg.id)) { > > reject_reg = true; > > - ret = __vcpu_ioctl(vcpu, KVM_SET_ONE_REG, ®); > > - if (ret != -1 || errno != EPERM) { > > - printf("%s: Failed to reject (ret=%d, errno=%d) ", config_name(c), ret, errno); > > - print_reg(config_name(c), reg.id); > > - putchar('\n'); > > - ++failed_reject; > > + if ((reg.id & KVM_REG_ARCH_MASK) == KVM_REG_ARM64) { > > + ret = __vcpu_ioctl(vcpu, KVM_SET_ONE_REG, ®); > > + if (ret != -1 || errno != EPERM) { > > + printf("%s: Failed to reject (ret=%d, errno=%d) ", > > + config_name(c), ret, errno); > > + print_reg(config_name(c), reg.id); > > + putchar('\n'); > > + ++failed_reject; > > + } > > Thinking about this some more, shouldn't we attempt the set ioctl for > riscv reject registers as well, but look for different error numbers? > Yes, we can. Currently, 2 different errno(EOPNOTSUPP/EINVAL) would be reported for the rejected registers in risc-v. These 2 errnos can be handled specially like below: diff --git a/tools/testing/selftests/kvm/get-reg-list.c b/tools/testing/selftests/kvm/get-reg-list.c index 73f40e0842b8..f3f2c4519318 100644 --- a/tools/testing/selftests/kvm/get-reg-list.c +++ b/tools/testing/selftests/kvm/get-reg-list.c @@ -255,6 +255,15 @@ static void run_test(struct vcpu_reg_list *c) putchar('\n'); ++failed_reject; } + } else { + ret = __vcpu_ioctl(vcpu, KVM_SET_ONE_REG, ®); + if (ret != -1 || (errno != EINVAL && errno != EOPNOTSUPP)) { + printf("%s: Failed to reject (ret=%d, errno=%d) ", + config_name(c), ret, errno); + print_reg(config_name(c), reg.id); + putchar('\n'); + ++failed_reject; + } One possible issue for the above change is that when new registers that don't support sets were added, we need to add them to the reject registers list, or the test would fail. Initially, in the v1 patch, the design was to just skip the EOPNOTSUPP errno in set operations for all registers since it's a known errno for registers that don't support sets. This change cover all the registers even for future new ones. What's your opinion? Thanks, Haibo > Thanks, > drew
On Sat, Jun 10, 2023 at 10:35:24AM +0800, Haibo Xu wrote: > On Fri, Jun 9, 2023 at 5:24 PM Andrew Jones <ajones@ventanamicro.com> wrote: > > > > On Fri, Jun 09, 2023 at 10:12:17AM +0800, Haibo Xu wrote: > > > Set operation on some riscv registers(mostly pesudo ones) was not > > > supported and should be skipped in the get-reg-list test. Just > > > reuse the rejects_set utilities to handle it in riscv. > > > > > > Signed-off-by: Haibo Xu <haibo1.xu@intel.com> > > > Reviewed-by: Andrew Jones <ajones@ventanamicro.com> > > > --- > > > tools/testing/selftests/kvm/get-reg-list.c | 20 +++++++++++++------- > > > 1 file changed, 13 insertions(+), 7 deletions(-) > > > > > > diff --git a/tools/testing/selftests/kvm/get-reg-list.c b/tools/testing/selftests/kvm/get-reg-list.c > > > index c4bd5a5259da..abacb95c21c6 100644 > > > --- a/tools/testing/selftests/kvm/get-reg-list.c > > > +++ b/tools/testing/selftests/kvm/get-reg-list.c > > > @@ -211,16 +211,22 @@ static void run_test(struct vcpu_reg_list *c) > > > ++failed_get; > > > } > > > > > > - /* rejects_set registers are rejected after KVM_ARM_VCPU_FINALIZE */ > > > + /* > > > + * rejects_set registers are rejected after KVM_ARM_VCPU_FINALIZE on aarch64, > > > + * or registers that should skip set operation on riscv. > > > + */ > > > for_each_sublist(c, s) { > > > if (s->rejects_set && find_reg(s->rejects_set, s->rejects_set_n, reg.id)) { > > > reject_reg = true; > > > - ret = __vcpu_ioctl(vcpu, KVM_SET_ONE_REG, ®); > > > - if (ret != -1 || errno != EPERM) { > > > - printf("%s: Failed to reject (ret=%d, errno=%d) ", config_name(c), ret, errno); > > > - print_reg(config_name(c), reg.id); > > > - putchar('\n'); > > > - ++failed_reject; > > > + if ((reg.id & KVM_REG_ARCH_MASK) == KVM_REG_ARM64) { > > > + ret = __vcpu_ioctl(vcpu, KVM_SET_ONE_REG, ®); > > > + if (ret != -1 || errno != EPERM) { > > > + printf("%s: Failed to reject (ret=%d, errno=%d) ", > > > + config_name(c), ret, errno); > > > + print_reg(config_name(c), reg.id); > > > + putchar('\n'); > > > + ++failed_reject; > > > + } > > > > Thinking about this some more, shouldn't we attempt the set ioctl for > > riscv reject registers as well, but look for different error numbers? > > > > Yes, we can. Currently, 2 different errno(EOPNOTSUPP/EINVAL) would be > reported for the rejected registers in risc-v. > These 2 errnos can be handled specially like below: > > diff --git a/tools/testing/selftests/kvm/get-reg-list.c > b/tools/testing/selftests/kvm/get-reg-list.c > index 73f40e0842b8..f3f2c4519318 100644 > --- a/tools/testing/selftests/kvm/get-reg-list.c > +++ b/tools/testing/selftests/kvm/get-reg-list.c > @@ -255,6 +255,15 @@ static void run_test(struct vcpu_reg_list *c) > putchar('\n'); > ++failed_reject; > } > + } else { > + ret = __vcpu_ioctl(vcpu, > KVM_SET_ONE_REG, ®); > + if (ret != -1 || (errno != > EINVAL && errno != EOPNOTSUPP)) { > + printf("%s: Failed to > reject (ret=%d, errno=%d) ", > + > config_name(c), ret, errno); > + > print_reg(config_name(c), reg.id); > + putchar('\n'); > + ++failed_reject; > + } Instead of duplicating the code Arm uses, we just need an errno check function, preferably one that takes the register as an input, so we can check for specific errnos for specific registers. > > One possible issue for the above change is that when new registers > that don't support sets were added, we need > to add them to the reject registers list, or the test would fail. > > Initially, in the v1 patch, the design was to just skip the EOPNOTSUPP > errno in set operations for all registers > since it's a known errno for registers that don't support sets. This > change cover all the registers even for future > new ones. > > What's your opinion? I think we should only do the get/set tests on present, blessed list registers, since if it's a new register we don't know its capabilities. So, instead of for_each_reg(i) { /* get/set tests */ } we do for_each_present_blessed_reg(i) { /* get/set tests */ } where we have #define for_each_present_blessed_reg(i) \ for ((i) = 0; (i) < blessed_n; ++(i)) \ if (find_reg(reg_list->reg, reg_list->n, blessed_reg[i])) Changing run_test() to work this way should be a separate patch. Thanks, drew
On Mon, Jun 12, 2023 at 4:57 PM Andrew Jones <ajones@ventanamicro.com> wrote: > > On Sat, Jun 10, 2023 at 10:35:24AM +0800, Haibo Xu wrote: > > On Fri, Jun 9, 2023 at 5:24 PM Andrew Jones <ajones@ventanamicro.com> wrote: > > > > > > On Fri, Jun 09, 2023 at 10:12:17AM +0800, Haibo Xu wrote: > > > > Set operation on some riscv registers(mostly pesudo ones) was not > > > > supported and should be skipped in the get-reg-list test. Just > > > > reuse the rejects_set utilities to handle it in riscv. > > > > > > > > Signed-off-by: Haibo Xu <haibo1.xu@intel.com> > > > > Reviewed-by: Andrew Jones <ajones@ventanamicro.com> > > > > --- > > > > tools/testing/selftests/kvm/get-reg-list.c | 20 +++++++++++++------- > > > > 1 file changed, 13 insertions(+), 7 deletions(-) > > > > > > > > diff --git a/tools/testing/selftests/kvm/get-reg-list.c b/tools/testing/selftests/kvm/get-reg-list.c > > > > index c4bd5a5259da..abacb95c21c6 100644 > > > > --- a/tools/testing/selftests/kvm/get-reg-list.c > > > > +++ b/tools/testing/selftests/kvm/get-reg-list.c > > > > @@ -211,16 +211,22 @@ static void run_test(struct vcpu_reg_list *c) > > > > ++failed_get; > > > > } > > > > > > > > - /* rejects_set registers are rejected after KVM_ARM_VCPU_FINALIZE */ > > > > + /* > > > > + * rejects_set registers are rejected after KVM_ARM_VCPU_FINALIZE on aarch64, > > > > + * or registers that should skip set operation on riscv. > > > > + */ > > > > for_each_sublist(c, s) { > > > > if (s->rejects_set && find_reg(s->rejects_set, s->rejects_set_n, reg.id)) { > > > > reject_reg = true; > > > > - ret = __vcpu_ioctl(vcpu, KVM_SET_ONE_REG, ®); > > > > - if (ret != -1 || errno != EPERM) { > > > > - printf("%s: Failed to reject (ret=%d, errno=%d) ", config_name(c), ret, errno); > > > > - print_reg(config_name(c), reg.id); > > > > - putchar('\n'); > > > > - ++failed_reject; > > > > + if ((reg.id & KVM_REG_ARCH_MASK) == KVM_REG_ARM64) { > > > > + ret = __vcpu_ioctl(vcpu, KVM_SET_ONE_REG, ®); > > > > + if (ret != -1 || errno != EPERM) { > > > > + printf("%s: Failed to reject (ret=%d, errno=%d) ", > > > > + config_name(c), ret, errno); > > > > + print_reg(config_name(c), reg.id); > > > > + putchar('\n'); > > > > + ++failed_reject; > > > > + } > > > > > > Thinking about this some more, shouldn't we attempt the set ioctl for > > > riscv reject registers as well, but look for different error numbers? > > > > > > > Yes, we can. Currently, 2 different errno(EOPNOTSUPP/EINVAL) would be > > reported for the rejected registers in risc-v. > > These 2 errnos can be handled specially like below: > > > > diff --git a/tools/testing/selftests/kvm/get-reg-list.c > > b/tools/testing/selftests/kvm/get-reg-list.c > > index 73f40e0842b8..f3f2c4519318 100644 > > --- a/tools/testing/selftests/kvm/get-reg-list.c > > +++ b/tools/testing/selftests/kvm/get-reg-list.c > > @@ -255,6 +255,15 @@ static void run_test(struct vcpu_reg_list *c) > > putchar('\n'); > > ++failed_reject; > > } > > + } else { > > + ret = __vcpu_ioctl(vcpu, > > KVM_SET_ONE_REG, ®); > > + if (ret != -1 || (errno != > > EINVAL && errno != EOPNOTSUPP)) { > > + printf("%s: Failed to > > reject (ret=%d, errno=%d) ", > > + > > config_name(c), ret, errno); > > + > > print_reg(config_name(c), reg.id); > > + putchar('\n'); > > + ++failed_reject; > > + } > > Instead of duplicating the code Arm uses, we just need an errno check > function, preferably one that takes the register as an input, so we > can check for specific errnos for specific registers. > > > > > One possible issue for the above change is that when new registers > > that don't support sets were added, we need > > to add them to the reject registers list, or the test would fail. > > > > Initially, in the v1 patch, the design was to just skip the EOPNOTSUPP > > errno in set operations for all registers > > since it's a known errno for registers that don't support sets. This > > change cover all the registers even for future > > new ones. > > > > What's your opinion? > > I think we should only do the get/set tests on present, blessed list > registers, since if it's a new register we don't know its capabilities. > > So, instead of > > for_each_reg(i) { > /* get/set tests */ > } > > we do > > for_each_present_blessed_reg(i) { > /* get/set tests */ > } > > where we have > > #define for_each_present_blessed_reg(i) \ > for ((i) = 0; (i) < blessed_n; ++(i)) \ > if (find_reg(reg_list->reg, reg_list->n, blessed_reg[i])) > > > Changing run_test() to work this way should be a separate patch. > Good idea! let me have a try. Thanks, Haibo > Thanks, > drew
diff --git a/tools/testing/selftests/kvm/get-reg-list.c b/tools/testing/selftests/kvm/get-reg-list.c index c4bd5a5259da..abacb95c21c6 100644 --- a/tools/testing/selftests/kvm/get-reg-list.c +++ b/tools/testing/selftests/kvm/get-reg-list.c @@ -211,16 +211,22 @@ static void run_test(struct vcpu_reg_list *c) ++failed_get; } - /* rejects_set registers are rejected after KVM_ARM_VCPU_FINALIZE */ + /* + * rejects_set registers are rejected after KVM_ARM_VCPU_FINALIZE on aarch64, + * or registers that should skip set operation on riscv. + */ for_each_sublist(c, s) { if (s->rejects_set && find_reg(s->rejects_set, s->rejects_set_n, reg.id)) { reject_reg = true; - ret = __vcpu_ioctl(vcpu, KVM_SET_ONE_REG, ®); - if (ret != -1 || errno != EPERM) { - printf("%s: Failed to reject (ret=%d, errno=%d) ", config_name(c), ret, errno); - print_reg(config_name(c), reg.id); - putchar('\n'); - ++failed_reject; + if ((reg.id & KVM_REG_ARCH_MASK) == KVM_REG_ARM64) { + ret = __vcpu_ioctl(vcpu, KVM_SET_ONE_REG, ®); + if (ret != -1 || errno != EPERM) { + printf("%s: Failed to reject (ret=%d, errno=%d) ", + config_name(c), ret, errno); + print_reg(config_name(c), reg.id); + putchar('\n'); + ++failed_reject; + } } break; }