Message ID | f5ef26e862260efdf1c809d0eee46ee1c8b457f2.1688010022.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 k13csp11076061vqr; Sat, 1 Jul 2023 07:34:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlEw3a9xXN9nKev3j7EsX5oE7E+IJ+czYElDBntHow64RUipcxnK6cMHusjZFQPmNz5U19dC X-Received: by 2002:a17:90a:5147:b0:25e:886b:c6b with SMTP id k7-20020a17090a514700b0025e886b0c6bmr4750738pjm.48.1688222080325; Sat, 01 Jul 2023 07:34:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688222080; cv=none; d=google.com; s=arc-20160816; b=CnVOiB92OKrabr6MWi0G0IsBTiVlw2ye3Y2/MnbAY+j7XWKxpCNy15NDT2rvUWyXwv 1p/esBybMv1Bqptglbkl+IehMgNugg69f1nvvy/2iIIzd0bfSRA2tCx2Ztbn+5xN3xYw O5+9bQa6SG0kGT84Cj72rF3Nm9KnxDiHGCYeNvrTiNYgxCa1yDmbuxnNgJBsYJnFtX+W OEtBZxj9hSkUpDH2GL+c/wR39mnioh3LVdDhSNKg6ff+pFr7edtnKQk/wxkwWm/4V+A0 rBsNP2fsUaFJ0X7sKpsbmxlI67FMY4o1gR8AHObloiaqlhvCkTbOhewBpdn2JgmvXmr3 Xkew== 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=Wb/MGjWqkXyJATI/TrpjAVnedE+FTJ5VpA83NYdC/A0=; fh=7EPU0yFgKq6DK54DdRhAOTNBSTrU9EP8Vi5A8HZNYZw=; b=uhjjByzIeL1hwl6qNLgLpNt2D+rtJwZj322brmOt2rr5CGsYBNNe+tY7+87StjZd5G YdDkeZvhQi0EAQ+8uhJMCpwVmxdWod+14VsRDT3UOJBDoygl2TaKUnkLO8dZx6GiI44g 8aEXQKFcJtRk9PS91rza9flixZKsxgg2yPD+BcioIboU8NfaraOKQq01uVmhuDajCdaE ah4si9IyKNBJoPzeEYHgMV094iNypItCpKa3phBhhWM1e0s7L3VarFbyBRJOQfiU2hlK Rlx2F2hZgl/5fc5krDyC5f5+Wa2/bCLUvlI+U/odAVSq1NAIC7CIopTBW/M07zBZY1jw +bAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@intel.com header.s=Intel header.b=CoS17CGH; 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 d7-20020a656207000000b00524ecfa05d8si15437355pgv.15.2023.07.01.07.34.27; Sat, 01 Jul 2023 07:34:40 -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=CoS17CGH; 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 S230374AbjGANjc (ORCPT <rfc822;nicolai.engesland@gmail.com> + 99 others); Sat, 1 Jul 2023 09:39:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230337AbjGANja (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 1 Jul 2023 09:39:30 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E06E9423A; Sat, 1 Jul 2023 06:39:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688218744; x=1719754744; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=r/aRBwjLRDnUy2X8CTuWO0qSvTCCqephwitvcdu1Lbs=; b=CoS17CGHC7qzxuwg0waelF1ohOi1HiGYiqwueka05LPzghEALKeokQeY qanGVrgw1u0EXPkjgVY5MNn0gnQg+U+OAJM0x7Wh/dzAjom/6Qyv6LrrH jLlJ2ZJ8v6KI1T93/CPIYTRrWvKnL6iVkLvKPHTrKsBbFjzx25WfHkEpk 7jh/elU24H+f6hofYYN4whcffhy85XI7IJ9qB+G+mdUqxVvy3M0SrvcP5 mUncEL+G9BU41ddkfBtEirt11tqUoEmqV1dLi2Gl9TIctOgBp7kW5VNzw 5gtUWDGCiPSxKHgZVeWlLa5dZdJyRv3JE7dxQ8/y9Kc0Csm2kbvKdaC8c Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10758"; a="342926235" X-IronPort-AV: E=Sophos;i="6.01,173,1684825200"; d="scan'208";a="342926235" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2023 06:38:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10758"; a="747694085" X-IronPort-AV: E=Sophos;i="6.01,173,1684825200"; d="scan'208";a="747694085" Received: from haibo-optiplex-7090.sh.intel.com ([10.239.159.132]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2023 06:38:51 -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>, Ricardo Koller <ricarkol@google.com>, Vishal Annapurve <vannapurve@google.com>, David Matlack <dmatlack@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 v5 08/13] KVM: arm64: selftests: Move reject_set check logic to a function Date: Sat, 1 Jul 2023 21:42:56 +0800 Message-Id: <f5ef26e862260efdf1c809d0eee46ee1c8b457f2.1688010022.git.haibo1.xu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <cover.1688010022.git.haibo1.xu@intel.com> References: <cover.1688010022.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, 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?1770229156171294018?= X-GMAIL-MSGID: =?utf-8?q?1770229156171294018?= |
Series |
RISCV: Add KVM_GET_REG_LIST API
|
|
Commit Message
Haibo Xu
July 1, 2023, 1:42 p.m. UTC
No functional changes. Just move the reject_set check logic to a
function so we can check for specific errno for specific register.
This is a preparation for support reject_set in riscv.
Suggested-by: Andrew Jones <ajones@ventanamicro.com>
Signed-off-by: Haibo Xu <haibo1.xu@intel.com>
---
tools/testing/selftests/kvm/aarch64/get-reg-list.c | 5 +++++
tools/testing/selftests/kvm/get-reg-list.c | 7 ++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
Comments
On Sat, Jul 01, 2023 at 09:42:56PM +0800, Haibo Xu wrote: > No functional changes. Just move the reject_set check logic to a > function so we can check for specific errno for specific register. 'for specific register' part isn't true anymore. > This is a preparation for support reject_set in riscv. > > Suggested-by: Andrew Jones <ajones@ventanamicro.com> > Signed-off-by: Haibo Xu <haibo1.xu@intel.com> > --- > tools/testing/selftests/kvm/aarch64/get-reg-list.c | 5 +++++ > tools/testing/selftests/kvm/get-reg-list.c | 7 ++++++- > 2 files changed, 11 insertions(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/kvm/aarch64/get-reg-list.c b/tools/testing/selftests/kvm/aarch64/get-reg-list.c > index aaf035c969ec..4aa58f1aebe3 100644 > --- a/tools/testing/selftests/kvm/aarch64/get-reg-list.c > +++ b/tools/testing/selftests/kvm/aarch64/get-reg-list.c > @@ -27,6 +27,11 @@ bool filter_reg(__u64 reg) > return false; > } > > +bool check_reject_set(int err) > +{ > + return err == EPERM; > +} > + > #define REG_MASK (KVM_REG_ARCH_MASK | KVM_REG_SIZE_MASK | KVM_REG_ARM_COPROC_MASK) > > #define CORE_REGS_XX_NR_WORDS 2 > diff --git a/tools/testing/selftests/kvm/get-reg-list.c b/tools/testing/selftests/kvm/get-reg-list.c > index f6ad7991a812..79e198968860 100644 > --- a/tools/testing/selftests/kvm/get-reg-list.c > +++ b/tools/testing/selftests/kvm/get-reg-list.c > @@ -98,6 +98,11 @@ void __weak print_reg(const char *prefix, __u64 id) > printf("\t0x%llx,\n", id); > } > > +bool __weak check_reject_set(int err) > +{ > + return true; > +} > + > #ifdef __aarch64__ > static void prepare_vcpu_init(struct vcpu_reg_list *c, struct kvm_vcpu_init *init) > { > @@ -216,7 +221,7 @@ static void run_test(struct vcpu_reg_list *c) > 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) { > + if (ret != -1 || !check_reject_set(errno)) { > printf("%s: Failed to reject (ret=%d, errno=%d) ", config_name(c), ret, errno); > print_reg(config_name(c), reg.id); > putchar('\n'); > -- > 2.34.1 > Otherwise, Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
On Sat, Jul 1, 2023 at 10:21 PM Andrew Jones <ajones@ventanamicro.com> wrote: > > On Sat, Jul 01, 2023 at 09:42:56PM +0800, Haibo Xu wrote: > > No functional changes. Just move the reject_set check logic to a > > function so we can check for specific errno for specific register. > > 'for specific register' part isn't true anymore. > > > This is a preparation for support reject_set in riscv. > > > > Suggested-by: Andrew Jones <ajones@ventanamicro.com> > > Signed-off-by: Haibo Xu <haibo1.xu@intel.com> > > --- > > tools/testing/selftests/kvm/aarch64/get-reg-list.c | 5 +++++ > > tools/testing/selftests/kvm/get-reg-list.c | 7 ++++++- > > 2 files changed, 11 insertions(+), 1 deletion(-) > > > > diff --git a/tools/testing/selftests/kvm/aarch64/get-reg-list.c b/tools/testing/selftests/kvm/aarch64/get-reg-list.c > > index aaf035c969ec..4aa58f1aebe3 100644 > > --- a/tools/testing/selftests/kvm/aarch64/get-reg-list.c > > +++ b/tools/testing/selftests/kvm/aarch64/get-reg-list.c > > @@ -27,6 +27,11 @@ bool filter_reg(__u64 reg) > > return false; > > } > > > > +bool check_reject_set(int err) > > +{ > > + return err == EPERM; > > +} > > + > > #define REG_MASK (KVM_REG_ARCH_MASK | KVM_REG_SIZE_MASK | KVM_REG_ARM_COPROC_MASK) > > > > #define CORE_REGS_XX_NR_WORDS 2 > > diff --git a/tools/testing/selftests/kvm/get-reg-list.c b/tools/testing/selftests/kvm/get-reg-list.c > > index f6ad7991a812..79e198968860 100644 > > --- a/tools/testing/selftests/kvm/get-reg-list.c > > +++ b/tools/testing/selftests/kvm/get-reg-list.c > > @@ -98,6 +98,11 @@ void __weak print_reg(const char *prefix, __u64 id) > > printf("\t0x%llx,\n", id); > > } > > > > +bool __weak check_reject_set(int err) > > +{ > > + return true; > > +} > > + > > #ifdef __aarch64__ > > static void prepare_vcpu_init(struct vcpu_reg_list *c, struct kvm_vcpu_init *init) > > { > > @@ -216,7 +221,7 @@ static void run_test(struct vcpu_reg_list *c) > > 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) { > > + if (ret != -1 || !check_reject_set(errno)) { > > printf("%s: Failed to reject (ret=%d, errno=%d) ", config_name(c), ret, errno); > > print_reg(config_name(c), reg.id); > > putchar('\n'); > > -- > > 2.34.1 > > > > Otherwise, > > Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Thanks for the review! Will fix it in the next version.
diff --git a/tools/testing/selftests/kvm/aarch64/get-reg-list.c b/tools/testing/selftests/kvm/aarch64/get-reg-list.c index aaf035c969ec..4aa58f1aebe3 100644 --- a/tools/testing/selftests/kvm/aarch64/get-reg-list.c +++ b/tools/testing/selftests/kvm/aarch64/get-reg-list.c @@ -27,6 +27,11 @@ bool filter_reg(__u64 reg) return false; } +bool check_reject_set(int err) +{ + return err == EPERM; +} + #define REG_MASK (KVM_REG_ARCH_MASK | KVM_REG_SIZE_MASK | KVM_REG_ARM_COPROC_MASK) #define CORE_REGS_XX_NR_WORDS 2 diff --git a/tools/testing/selftests/kvm/get-reg-list.c b/tools/testing/selftests/kvm/get-reg-list.c index f6ad7991a812..79e198968860 100644 --- a/tools/testing/selftests/kvm/get-reg-list.c +++ b/tools/testing/selftests/kvm/get-reg-list.c @@ -98,6 +98,11 @@ void __weak print_reg(const char *prefix, __u64 id) printf("\t0x%llx,\n", id); } +bool __weak check_reject_set(int err) +{ + return true; +} + #ifdef __aarch64__ static void prepare_vcpu_init(struct vcpu_reg_list *c, struct kvm_vcpu_init *init) { @@ -216,7 +221,7 @@ static void run_test(struct vcpu_reg_list *c) 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) { + if (ret != -1 || !check_reject_set(errno)) { printf("%s: Failed to reject (ret=%d, errno=%d) ", config_name(c), ret, errno); print_reg(config_name(c), reg.id); putchar('\n');