From patchwork Sat Jul 1 13:42:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haibo Xu X-Patchwork-Id: 115046 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp11093695vqr; Sat, 1 Jul 2023 08:09:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7AInY6wNKvjX7n59lOmkiTFNRaQMTG9y0z/dUyjEJTE0nYfHtoOKYajlpSz8uteJnPSnJY X-Received: by 2002:a05:6a20:1443:b0:12b:e9a0:f04a with SMTP id a3-20020a056a20144300b0012be9a0f04amr4676897pzi.22.1688224151399; Sat, 01 Jul 2023 08:09:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688224151; cv=none; d=google.com; s=arc-20160816; b=F0fzvDqFZAMm2MwRuV+KImgLAmsYf1l+vYzOQ+YzyPpU3ogKD5GY/38PuSXaJ5a4RO KLDOinuUZd3AE4VJwTX2thSwV03wOOFECzUN9SK9SoV5k1njbLaUhyqERj5rsYzi6/cd eGi4LAQF3JSw8p4dvweZNBXXZWbHj5EKbS4G5FGh010KUk5+PP/J8mnpqQG+EaNPcB9T g1n+h3kMO5uFgQmhL35UN0290r9yrO9cnoLsHnI83ZFfQZc8hPg/GeQxQdnkE0cTBn95 +40y3CUkSaQELH3r7EPOYDqdMgfW/pulcKgp7OMB4ttEZ0YcVhn0PID6g6o1e0D6nYui hHnw== 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=GL/dEoq06rwFfHdn3uK/sDGoFyuzTW14xp2Aqi64P1w=; fh=t5Ra4m2YxRKhU4WbIwyb+raTVIOmXdZcxHU0Z8Y+pgE=; b=AH/L50cVYkyAqZCzBYWe+NU95XC/ag4RZCTeArWsxKw17LegNv7t7HzfkvYPLx7YVW CPnVh3gygg6C7WspEfKQ5ODhXbl1d32V80t5maeq2IDTYnjtgzZirJGPxopd3hJX+uf/ +imO7BNWEzEL9XTSSDwL7S5KhDW5aDptVSISUSUfteAH9Cm0uQe7yyUkbQev8Mfnkk3M /cDvf4L50ZnY5b7JV3j5kNnE72aoauqi+UWw+4NaumDeWaidUBIYEtUX7bVy9yz7vboT WNXlQ9wWg47MdUfQB2EGgqrOQAE2Du8pvXxK47i5P3PfTPBw48QD55fLKduElGtTddRo OJwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@intel.com header.s=Intel header.b=FWBmVC60; 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 a11-20020a170902eccb00b001b69fe9a45asi5933952plh.575.2023.07.01.08.08.59; Sat, 01 Jul 2023 08:09:11 -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=FWBmVC60; 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 S230494AbjGANkO (ORCPT + 99 others); Sat, 1 Jul 2023 09:40:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230499AbjGANkM (ORCPT ); Sat, 1 Jul 2023 09:40:12 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ADFE44B0; Sat, 1 Jul 2023 06:39:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688218782; x=1719754782; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tib4u7zV9bvH0+hgUwQFMOHqdNc+6PnMdDY7xbrMXoM=; b=FWBmVC60w/si5dyPOXZ2/9A4mMSKz9L8aV8NgFZ9Wgj0ZP0IeesLQWWS ZPq9uCInRJT1+xmGFSusD4NnsSdZ+jUPHigfiKdlT3RqeDdL4ZJYLYD0U ZVbR6Rc8PvlN8YC7/KXmj7FjdmaDoXcRGhFzL0Yeur9zH5c2aH2KrTZHc HppscNOunMGlxQLJE1KMrbTcWoxh2Za1uiTtMg5hlh/f7WvGikv5x4ccp 45PI2H2iQvJl/swpATmSQa8U6/HPzqsoyfQu26don5lQta/WNpxnB5mfP m64mCj+BQPFDsHLeUojOBZxJcqrleD96InVAfjK6TPLvfxmYgogFXR0Df Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10758"; a="342926300" X-IronPort-AV: E=Sophos;i="6.01,173,1684825200"; d="scan'208";a="342926300" 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:39:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10758"; a="747694279" X-IronPort-AV: E=Sophos;i="6.01,173,1684825200"; d="scan'208";a="747694279" 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:39:34 -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 , Vipin Sharma , David Matlack , 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 v5 11/13] KVM: selftests: Add skip_set facility to get_reg_list test Date: Sat, 1 Jul 2023 21:42:59 +0800 Message-Id: <0a418f26388e744b6ae2f17639bea08a05643549.1688010022.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=-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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770229431617755350?= X-GMAIL-MSGID: =?utf-8?q?1770231327678330811?= Add new skips_set members to vcpu_reg_sublist so as to skip set operation on some registers. Suggested-by: Andrew Jones Signed-off-by: Haibo Xu --- tools/testing/selftests/kvm/get-reg-list.c | 20 +++++++++++++------ .../selftests/kvm/include/kvm_util_base.h | 2 ++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/kvm/get-reg-list.c b/tools/testing/selftests/kvm/get-reg-list.c index 74fb6f6fdd09..1a32a900aeea 100644 --- a/tools/testing/selftests/kvm/get-reg-list.c +++ b/tools/testing/selftests/kvm/get-reg-list.c @@ -157,6 +157,7 @@ static void run_test(struct vcpu_reg_list *c) { int new_regs = 0, missing_regs = 0, i, n; int failed_get = 0, failed_set = 0, failed_reject = 0; + int skipped_set = 0; struct kvm_vcpu *vcpu; struct kvm_vm *vm; struct vcpu_reg_sublist *s; @@ -210,7 +211,7 @@ static void run_test(struct vcpu_reg_list *c) .id = reg_list->reg[i], .addr = (__u64)&addr, }; - bool reject_reg = false; + bool reject_reg = false, skip_reg = false; int ret; ret = __vcpu_get_reg(vcpu, reg_list->reg[i], &addr); @@ -221,8 +222,8 @@ static void run_test(struct vcpu_reg_list *c) ++failed_get; } - /* rejects_set registers are rejected after KVM_ARM_VCPU_FINALIZE */ for_each_sublist(c, s) { + /* rejects_set registers are rejected for set operation */ 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, ®); @@ -234,9 +235,16 @@ static void run_test(struct vcpu_reg_list *c) } break; } + + /* skips_set registers are skipped for set operation */ + if (s->skips_set && find_reg(s->skips_set, s->skips_set_n, reg.id)) { + skip_reg = true; + ++skipped_set; + break; + } } - if (!reject_reg) { + if (!reject_reg && !skip_reg) { ret = __vcpu_ioctl(vcpu, KVM_SET_ONE_REG, ®); if (ret) { printf("%s: Failed to set ", config_name(c)); @@ -281,9 +289,9 @@ static void run_test(struct vcpu_reg_list *c) } TEST_ASSERT(!missing_regs && !failed_get && !failed_set && !failed_reject, - "%s: There are %d missing registers; " - "%d registers failed get; %d registers failed set; %d registers failed reject", - config_name(c), missing_regs, failed_get, failed_set, failed_reject); + "%s: There are %d missing registers; %d registers failed get; " + "%d registers failed set; %d registers failed reject; %d registers skipped set", + config_name(c), missing_regs, failed_get, failed_set, failed_reject, skipped_set); pr_info("%s: PASS\n", config_name(c)); blessed_n = 0; diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/testing/selftests/kvm/include/kvm_util_base.h index e4480049000d..67c031fe89a1 100644 --- a/tools/testing/selftests/kvm/include/kvm_util_base.h +++ b/tools/testing/selftests/kvm/include/kvm_util_base.h @@ -134,6 +134,8 @@ struct vcpu_reg_sublist { __u64 regs_n; __u64 *rejects_set; __u64 rejects_set_n; + __u64 *skips_set; + __u64 skips_set_n; }; struct vcpu_reg_list {