Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp23814690rwd; Sat, 1 Jul 2023 07:43:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlH1Y5C05e9DgzvUq7E7SJxsmRT+jPLkjKCiHQq6P4zg8uxQ9xFmw175ClLMLTdki2R7QYTy X-Received: by 2002:a05:6a00:99c:b0:681:eddd:51fb with SMTP id u28-20020a056a00099c00b00681eddd51fbmr8141626pfg.18.1688222619339; Sat, 01 Jul 2023 07:43:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688222619; cv=none; d=google.com; s=arc-20160816; b=ieJi6uFMN8NSV+pwol7U4xZVPxOKpfo13Yk9TPBZNtgr7Gs+Krdyi4TeV3qWZhQhft KZllu3/uBPsMjUcHLp+l8r3M1E8hfCnYbnUfHVD+fNBUx3oM7etmLpYWzOmEijLrKawg ZbgtfX6a8wCeV/3/W0Y4Nt5Fd/C2lZIKeukuQAMCi/sgi1cK43EDd/LuN07CUz4ERAWk eJNMv7M0PeOgxamvOImnx6Y7rd76i//92rsyMaLxj5Nbd54mG0bheP2E1KI6qS3I8OAi ud4hIXTXzbveHiZ6CjP4Rkw9Q3pQ0sIl2XQOrmFYUVIRFWkSjuPNgbE4P8C4aw14QhNR kAHA== 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=eE836Fm4w+ggTLR70hkszVLixutbeZQ5Ewp4AFb4C3A=; fh=t5Ra4m2YxRKhU4WbIwyb+raTVIOmXdZcxHU0Z8Y+pgE=; b=wpBNMkoWFNh4S+Bl7YqKIJApAlk7bG++otv2G82oadgJlGZkjT32EX17tFXDedJz8h e6nhmgorxlWVbT3IphnKddEI69bkxMSY4ZLeG+c6LyMrjhGNOzZesOLBamvnL0eaAudW sWcWSBSqIL4CVPFxkFPNabAqDIHD5ImTL92Pim7bvThckUrHiaJjUuwLErfBDyMN80ON qc77GIYwpiqFKqhT1oPmcQlGEQx+lb+s1UUEcAHbR0KFl2jFZBY04bwblkFHDa2rPVzI uWcg+QULMgMhhL0Cd0vnf1ck+6Vijn+pecg8SKmrHWnc6rzChrvGBwzX1/KuPczslqoO b0+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@intel.com header.s=Intel header.b=NIoHOX+D; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fi30-20020a056a00399e00b0064d533abfd4si15009281pfb.189.2023.07.01.07.43.25; Sat, 01 Jul 2023 07:43:39 -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=NIoHOX+D; 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 S230476AbjGANkA (ORCPT + 99 others); Sat, 1 Jul 2023 09:40:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230337AbjGANj7 (ORCPT ); Sat, 1 Jul 2023 09:39:59 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 580424207; Sat, 1 Jul 2023 06:39: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=1688218770; x=1719754770; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=I+7CmZbE8smFi2s/kidYxguksFY8+4Lb0ZPsMAWD3Cc=; b=NIoHOX+D2vpVQpMVNncDGkxHq703DmUo1o/QrzbXs38AIY6KbmKqnOaj M1WUNRkPQoGt0NjFvX0qNC6GiULv+R3/WS4kCAvel89KgE0RV18AOs3RA Sj1M+yRy9KjURDvWFYdP4o3DrZXxGIRbb58dKLJOFMaYE92Emj8C9B7c8 jkQ96fQukQ1s9GcayviKPJOMQ+kTCmDxfcxerw/dT5ay51I+pjG6EvHQ5 Ez2aWw1f58oML8AwfymRHCiKUnI9uT16CNGhoSltx5n8c9HFSEnWIKp2c E3nN+MGyOYaRXUJcUVrJm3J05p2wigJ9iCVt/8MIz1MJL3CViDLBTCK4j A==; X-IronPort-AV: E=McAfee;i="6600,9927,10758"; a="342926281" X-IronPort-AV: E=Sophos;i="6.01,173,1684825200"; d="scan'208";a="342926281" 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:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10758"; a="747694214" X-IronPort-AV: E=Sophos;i="6.01,173,1684825200"; d="scan'208";a="747694214" 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:20 -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 10/13] KVM: selftests: Only do get/set tests on present blessed list Date: Sat, 1 Jul 2023 21:42:58 +0800 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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: X-Mailing-List: linux-kernel@vger.kernel.org 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 c61090806007..74fb6f6fdd09 100644 --- a/tools/testing/selftests/kvm/get-reg-list.c +++ b/tools/testing/selftests/kvm/get-reg-list.c @@ -49,6 +49,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 ((i) = 0; (i) < blessed_n; ++(i)) \ + if (find_reg(reg_list->reg, reg_list->n, blessed_reg[i])) + static const char *config_name(struct vcpu_reg_list *c) { struct vcpu_reg_sublist *s; @@ -177,6 +181,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 @@ -186,8 +200,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], @@ -230,16 +247,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; -- 2.34.1