From patchwork Tue Jul 25 08:41:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haibo Xu X-Patchwork-Id: 125435 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2340346vqg; Tue, 25 Jul 2023 02:16:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlG2Yn0NihX9BdwBl5SeNjB6SaANzr/ZyRUYf5G5KoLQ2PSfQrwQgI7Zq7RWsB/Mph7c7oND X-Received: by 2002:aa7:d784:0:b0:522:3ea4:81a9 with SMTP id s4-20020aa7d784000000b005223ea481a9mr2507577edq.34.1690276619109; Tue, 25 Jul 2023 02:16:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690276619; cv=none; d=google.com; s=arc-20160816; b=qrkhGbIrFypeQeIY3qeY6u52t7YFFd/jMyddRpMcSVJ8WFjNXyk5ClBp+Sml8gcF2J wGVmjxEYv0t0Sa/V2RXJ5VDV2JDM3/KdU8ctOJludUESBxPIhyifoF99DxbT3HquUUKJ cSDBOwwv7ILWWGSUqCQtsvbM51liU8t52y/YLHC8ZX3R3qfk91/27T/Zd5quIpHl0jub t06dwwqtre2t5LceVMc/igcKgugP6GLwYA1xqgxh/U/p1CTZ5HuqVrgP+GA0yEwkMCef azdsPWEPf6L3dPxcGqbrRvqV42/+zrWAKJSNXYvvVWD9JEFmNlhwZ+HHxqie0moL1vnH c2QA== 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=805a0nJDyePWbuiw624Es4VxaUGx6Ga8Wxg737h+RTA=; fh=6eqX2bP6CyZ6CG3Q2z2Vj4o48A9VguseIgHQAmPXp0s=; b=hbM2XErEp6NmTKgzGoJlik57yRRrml3aHPzlDszUcYJH4/lcSYVREkO2BF0AC57qhK GrvIMo8jza0XySUUzMiLyWKklbkebzg60uNN9ACcBl6FrzQpUw3TY65as2ieE2v08Tj1 npsfeXYHishPADHa7FgeO212q7VdeLAHhicr/7S8RzksJbs9zd9uFkjN+Q32a0jH7aBN /mTOWNjF5AZsxQH8yTcWQNMctJyemF383kegQ0DtU7Kq+kKNRUxlAKdbY9Tq/i0H4N0T dhd1XQXkrM2kR4cy3LReiDPIiWtEs3+yZUouGcGamIXxJ3/0ttERt+U8yl1be0cqGRC2 U14Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@intel.com header.s=Intel header.b=l2saHmjK; 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 y5-20020a50eb05000000b005220ec7fdecsi4883668edp.567.2023.07.25.02.16.35; Tue, 25 Jul 2023 02:16:59 -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=l2saHmjK; 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 S232434AbjGYIj4 (ORCPT + 99 others); Tue, 25 Jul 2023 04:39:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232944AbjGYIjj (ORCPT ); Tue, 25 Jul 2023 04:39:39 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2E1B26AE; Tue, 25 Jul 2023 01:38: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=1690274323; x=1721810323; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qzwokNgafPuwqIA26TD1GKTMzvfggtQq7LKIFUe+PJ0=; b=l2saHmjKas08YzXYk+g/8wwI5bP1LH/J1HA5tP9UdautmLrnLDXzEREz lliMrBEMKHUgxFD97SEalxDceFolUDBL2DppyVD5yChTdFMPDzTJNK/O9 WxKON4CmAHocZXwXmjGhhklr3aF6HnPOXSp7px0XfLSD7Uh34PT66iBSH n0Z1sW014CXEkjUw6Pon+M4mhKBzsiMHJKmpGbjlGl63wiu/jajbv+6/q 6KClK3T8Wt90qIlbeFyhbJkVLbVDSsGE05mWmjzZWj1UkwiATjXR2k6zC REw1RhHZqKt4ztw9nR8HkPM35CuvTqs38n8tTrzfKgfPvfbjjUI6m9bzW Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10781"; a="371264968" X-IronPort-AV: E=Sophos;i="6.01,230,1684825200"; d="scan'208";a="371264968" 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:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10781"; a="761131098" X-IronPort-AV: E=Sophos;i="6.01,230,1684825200"; d="scan'208";a="761131098" 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:38:23 -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 , Peter Xu , 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 v6 10/13] KVM: selftests: Only do get/set tests on present blessed list Date: Tue, 25 Jul 2023 16:41:36 +0800 Message-Id: <859b1f9ec108ba897de2d5fd0c9c24a1aa32a8ef.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: 1772383496191574166 X-GMAIL-MSGID: 1772383496191574166 Only do the get/set tests on present and blessed registers since we don't know the capabilities of any new ones. Suggested-by: Andrew Jones Signed-off-by: Haibo Xu Reviewed-by: Andrew Jones --- tools/testing/selftests/kvm/get-reg-list.c | 29 ++++++++++++++-------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/tools/testing/selftests/kvm/get-reg-list.c b/tools/testing/selftests/kvm/get-reg-list.c index 43a919f2208f..2232620fb797 100644 --- a/tools/testing/selftests/kvm/get-reg-list.c +++ b/tools/testing/selftests/kvm/get-reg-list.c @@ -50,6 +50,10 @@ extern int vcpu_configs_n; for_each_reg_filtered(i) \ if (!find_reg(blessed_reg, blessed_n, reg_list->reg[i])) +#define for_each_present_blessed_reg(i) \ + for_each_reg(i) \ + if (find_reg(blessed_reg, blessed_n, reg_list->reg[i])) + static const char *config_name(struct vcpu_reg_list *c) { struct vcpu_reg_sublist *s; @@ -183,6 +187,16 @@ static void run_test(struct vcpu_reg_list *c) return; } + for_each_sublist(c, s) + blessed_n += s->regs_n; + blessed_reg = calloc(blessed_n, sizeof(__u64)); + + n = 0; + for_each_sublist(c, s) { + for (i = 0; i < s->regs_n; ++i) + blessed_reg[n++] = s->regs[i]; + } + /* * We only test that we can get the register and then write back the * same value. Some registers may allow other values to be written @@ -192,8 +206,11 @@ static void run_test(struct vcpu_reg_list *c) * be written need to have the other values tested, then we should * create a new set of tests for those in a new independent test * executable. + * + * Only do the get/set tests on present, blessed list registers, + * since we don't know the capabilities of any new registers. */ - for_each_reg(i) { + for_each_present_blessed_reg(i) { uint8_t addr[2048 / 8]; struct kvm_one_reg reg = { .id = reg_list->reg[i], @@ -236,16 +253,6 @@ static void run_test(struct vcpu_reg_list *c) } } - for_each_sublist(c, s) - blessed_n += s->regs_n; - blessed_reg = calloc(blessed_n, sizeof(__u64)); - - n = 0; - for_each_sublist(c, s) { - for (i = 0; i < s->regs_n; ++i) - blessed_reg[n++] = s->regs[i]; - } - for_each_new_reg(i) ++new_regs;