From patchwork Sat Jul 1 13:42:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haibo Xu X-Patchwork-Id: 115045 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp11078773vqr; Sat, 1 Jul 2023 07:40:30 -0700 (PDT) X-Google-Smtp-Source: APBJJlHo/foJyR+mOXzC0DxOxVbPlIXnTj9WlrrvTsyklf+fGSF9WBQqI+1OMsLHj5Dj8u9vgTRz X-Received: by 2002:a17:903:40c6:b0:1b6:6812:4ede with SMTP id t6-20020a17090340c600b001b668124edemr5094697pld.26.1688222430461; Sat, 01 Jul 2023 07:40:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688222430; cv=none; d=google.com; s=arc-20160816; b=YKcOc/KRaH/mKCOv6j4hY8lPrzQ4VCwzoUL2ffPT6ELMD9rdA575wdi5MpUbfm5VlF +zVUILAnCApeT/1qTRv8ooemgKAKLr+9CQc3+RFBxgCR6A8SJ4tfByGnw8zOonhns3JV Ytx+uLw4FU7hpTpH6Fmi8Vo1VrLgnfMOuMTw+xMgoA7kUjnkgPhlcE2pmc2qdr06A+sr HRtztRz0epJxxWYwuobkWdRGFNSk+YPqkJQnKy6w6A7cniby/wEzUbnX0fhcSFvSgWXj 0Hr1tQ4WPuhsy1XvTBUck8lsVP115CZFgwiRqmiIQuCOOY8tHo9iIKjDMSJGKKmaEiG+ S8mQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y23-20020a17090264d700b001b87df35cccsi1723181pli.363.2023.07.01.07.40.15; Sat, 01 Jul 2023 07:40:30 -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 S230480AbjGANkB (ORCPT + 99 others); Sat, 1 Jul 2023 09:40:01 -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 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?1770229523389811311?= X-GMAIL-MSGID: =?utf-8?q?1770229523389811311?= 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;