From patchwork Tue Jul 25 08:41:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haibo Xu X-Patchwork-Id: 125429 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2329462vqg; Tue, 25 Jul 2023 01:51:01 -0700 (PDT) X-Google-Smtp-Source: APBJJlG1b+s5Nm/zxg0IpZ+aYtQgoRUpyAmNsSrEHKSlf3s46jCAlSe5ZezLUZZtPSuxnRBKH2kR X-Received: by 2002:a05:6512:234a:b0:4fb:7da3:de4 with SMTP id p10-20020a056512234a00b004fb7da30de4mr8643208lfu.13.1690275061261; Tue, 25 Jul 2023 01:51:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690275061; cv=none; d=google.com; s=arc-20160816; b=ot2tlFj/iQbDs4DH7kAW8CSMfneBVrU9BpfSgRFZUMQoLUWLsGIWr31edgqVOSfvww hedt1mjtwurjSH/t0u4jrpY3JLbdsvHS6qfrdJbtBUcOrwyYiThC5peA5shabMVGby8V kTiLOWtGdcvlBkqKOr6mrRviaTgpg9Hwjj/XkP1IT2gdwI2xHYCwOTOHj+vybPIIpKsT 4PG2FP0SZOOOh0b7lY/EpQMVLj8PFePT1FGd1Ni5Uw3sYzevz3RXYKZ4HKo1c7JMt77h dvaSG8F+56tePDvwA53DsdqFL9oJztGOx37s9Z6CTKGSu+J8n616w56kpFFWsZCKq4zZ wZEg== 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=Gk3+Nir/6GfCTYIrzioVPP6s55tC153ODmoJmxAhIkY=; fh=nbojmHnpHDWtjn+3N85SqC0aroe0kvPS40CgGs51wb8=; b=chpYI6T42n7O/r/hiFl7yYL3CAjTyLMJPUG/tVVRerPmCIzm1uPqkg7npa6LtvxLoq wsmkqs90DxBYbCoP7t63yS7pQm2JmcnndnbL9XTj9TLOrJXXTfYeC3qd0SQwBep4bRN9 JC2xAjK1snKVWmp4TbUkFpuc+VeM02uzjLWhjPIwAzj4dUqBZN26iMen2l7v02yqhadh 743Phg/0eZiqGWlCajWqwEwCKNc/+NpS4YT1vAxeRJSb5RzZZ3j2VbsqSDuZqrJzB+jh IaIf6aGr6F9ocLUxghIl4UA4JFWmG2c40i4LEI7P2dhCtLMrOuvwynNyv2HbfxTXq6H+ xbhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@intel.com header.s=Intel header.b=Kc+74Atw; 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 i19-20020a50fc13000000b005224c6046a6si778112edr.508.2023.07.25.01.50.38; Tue, 25 Jul 2023 01:51:01 -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=Kc+74Atw; 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 S232986AbjGYIii (ORCPT + 99 others); Tue, 25 Jul 2023 04:38:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233052AbjGYIiO (ORCPT ); Tue, 25 Jul 2023 04:38:14 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A64851992; Tue, 25 Jul 2023 01:38:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690274281; x=1721810281; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uf8Gsbg7FBNNbpgmLmy40kRrM0Q7yFPMJTNAbZ3eMQo=; b=Kc+74AtwGpQAqlKIXr9+KxRPGr87cOGdZVF2Vpq6RMKZhUPCLzHbsDtt L0Jciu+eHCbQzbWX2B+fd8ECJ7nyf2mJeTnS4Z4Z5VeZTzWYffonS2qxe sDJutIe0ar8UbxCuH/QvNRMzycEhiQoqOSL3Wdrnp/YIMqtw82BQsygrA 6qZ+fAOAZvTCJjEgP82SqA9ZqkKiddZWj32CZ/t3sKpoOMVWuZ9jpzbjt fLUBV/x4TgqhKUEYwJ+So0LSUQ+roq6K0j7txGyIgKSIXYrf+Qro29j/c y+hK5BgDpL5jubRc8dkqohIo2DP26UU4J2zKj7oELnCG3wa591HsPLzbj g==; X-IronPort-AV: E=McAfee;i="6600,9927,10781"; a="371264791" X-IronPort-AV: E=Sophos;i="6.01,230,1684825200"; d="scan'208";a="371264791" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2023 01:38:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10781"; a="761130712" X-IronPort-AV: E=Sophos;i="6.01,230,1684825200"; d="scan'208";a="761130712" Received: from haibo-optiplex-7090.sh.intel.com ([10.239.159.132]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2023 01:37:54 -0700 From: Haibo Xu Cc: xiaobo55x@gmail.com, haibo1.xu@intel.com, ajones@ventanamicro.com, maz@kernel.org, oliver.upton@linux.dev, seanjc@google.com, Paolo Bonzini , Jonathan Corbet , Anup Patel , Atish Patra , Paul Walmsley , Palmer Dabbelt , Albert Ou , Shuah Khan , James Morse , Suzuki K Poulose , Zenghui Yu , Ricardo Koller , Vishal Annapurve , David Matlack , Vipin Sharma , Colton Lewis , 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 v6 08/13] KVM: arm64: selftests: Move reject_set check logic to a function Date: Tue, 25 Jul 2023 16:41:34 +0800 Message-Id: <33097ed1a8e87beb6871cb6fa967dc9e0fae7adc.1690273969.git.haibo1.xu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772381862573683316 X-GMAIL-MSGID: 1772381862573683316 No functional changes. Just move the reject_set check logic to a function so we can check for a specific errno. This is a preparation for support reject_set in riscv. Suggested-by: Andrew Jones Signed-off-by: Haibo Xu Reviewed-by: Andrew Jones --- 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 f72f1a522ff4..f8ebc058b191 100644 --- a/tools/testing/selftests/kvm/aarch64/get-reg-list.c +++ b/tools/testing/selftests/kvm/aarch64/get-reg-list.c @@ -79,6 +79,11 @@ bool check_supported_reg(struct kvm_vcpu *vcpu, __u64 reg) return check_supported_feat_reg(vcpu, reg); } +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 853cbf470da2..1df94e8e9ed5 100644 --- a/tools/testing/selftests/kvm/get-reg-list.c +++ b/tools/testing/selftests/kvm/get-reg-list.c @@ -104,6 +104,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) { @@ -222,7 +227,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');