Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp23812892rwd; Sat, 1 Jul 2023 07:41:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlG70fIyp0JK2UqmhZAKKwoG4MJPEAx3ZnEb/V59CoV/gXT6+bEGJNp2Pc+BzkVrpX3pfESW X-Received: by 2002:a05:6a20:841f:b0:127:7ea7:e039 with SMTP id c31-20020a056a20841f00b001277ea7e039mr4523504pzd.62.1688222500369; Sat, 01 Jul 2023 07:41:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688222500; cv=none; d=google.com; s=arc-20160816; b=s5zU14dWeVeIKdkHxjnRj4zaOwmgfKvnjCt/m2VOvuXw+NmhT4L8dpRd4Pp9GyzkWb tMuGXnKAAVMGNWujoRXCe2YwufStO0C+KUPsTSe2O3pwJ4IOGqxQ5Vg0rxU9mV8UX6WK snjkmLJUkhhSurE6gVM5W26h4mcIPZz34EzoV9qCPoMkcyv16p1w79CKkd8gqdnP/4ng BLAg+xnWs8+83ro8QsM3CwPi2mR4N8drODy0AUU8CYeylHLGXVQSRMpXuZ07C6mY+R+2 KLFMnhcScO2VoBbaAAjLqtv/DR5gN2qDEIj2njvNvKLOcz13m08fpcFTzo593HDiWzyE RNKw== 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=8iQCFUkdMVcDHUs3T92Z5mYKFBVT++z4+lSbnH0chs4=; fh=7EPU0yFgKq6DK54DdRhAOTNBSTrU9EP8Vi5A8HZNYZw=; b=0P8lQvfc3Ipxnth8OHM7HaoJjI/8KyOflCmBbT1PQGX/m4DDeGg+2scVHV6HL3OFON KiwesZe7oTctvwjTWNXrZQqWGN3fC7lWQfkVJT9iaD/MJhaIEb6dglOkZhkw5uDGzDlc JgWrpHtHMuuXihzjU9xYYulWd7rpGtVWhpGLF+EyabzjXGrhsQWUCUNPkxVgrE7wS/lB J0wjludVVKrYxCSMwzlVV7+dn6Bz8ogCR8Ct26EMenIv6m9zxfy2n1wjlwUdBDuDaS/j dGc2j7+6JqPtNg+DVN0Ib0erWJwIXQzgLkL0toyW7BIi3CWrkBtlu8CB4iNpot5BQnp1 4ZKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@intel.com header.s=Intel header.b=RCAR2Nkz; 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 p4-20020a056a000a0400b0067537349056si12939782pfh.342.2023.07.01.07.41.28; Sat, 01 Jul 2023 07:41:40 -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=RCAR2Nkz; 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 S229754AbjGANjK (ORCPT + 99 others); Sat, 1 Jul 2023 09:39:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229597AbjGANjI (ORCPT ); Sat, 1 Jul 2023 09:39:08 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9ECB244BF; Sat, 1 Jul 2023 06:38:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688218724; x=1719754724; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EXZQIePHrnC+4oyrdo52RNlpn5u8QhJ9eHGJ6BBZ17s=; b=RCAR2Nkz6gecoqoUoox0iT0DdMGgjZlaRr8oTBJELp1RO03MPmW7mFCZ /qjdqWcmdzsrwlEV7U6+6osEOn7am0DNOg2EC2822r1aq7MXR08FQmsM5 /AM0dgkUaercf4D3Bw2nznC+WyjRe01JBpjCJNQ8DKpmUrtPKbQuzG7Wi F9oLIcR9NPR3JOT99k9usufQQv8juv7icMboxwiNpgdShUEWtFVH6P32+ goKmDvV2QTaR+V+DPAPcQZXLvJxCygqnNZ2sMQOoSMS+pefdO6uyw8Qyv hwTtwI8Gs4c9tbaLEMYc5GPCG2s9+R8W0+teRR80pqetVyJcDEKiZyiAs w==; X-IronPort-AV: E=McAfee;i="6600,9927,10758"; a="342926202" X-IronPort-AV: E=Sophos;i="6.01,173,1684825200"; d="scan'208";a="342926202" 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:38:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10758"; a="747694018" X-IronPort-AV: E=Sophos;i="6.01,173,1684825200"; d="scan'208";a="747694018" 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:38:37 -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 v5 07/13] KVM: arm64: selftests: Finish generalizing get-reg-list Date: Sat, 1 Jul 2023 21:42:55 +0800 Message-Id: <0d81728cf8b4fd931b495ac4c86d6a74e55a5230.1688010022.git.haibo1.xu@intel.com> 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 From: Andrew Jones Add some unfortunate #ifdeffery to ensure the common get-reg-list.c can be compiled and run with other architectures. The next architecture to support get-reg-list should now only need to provide $(ARCH_DIR)/get-reg-list.c where arch-specific print_reg() and vcpu_configs[] get defined. Signed-off-by: Andrew Jones Signed-off-by: Haibo Xu --- tools/testing/selftests/kvm/get-reg-list.c | 26 +++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/kvm/get-reg-list.c b/tools/testing/selftests/kvm/get-reg-list.c index 69bb91087081..f6ad7991a812 100644 --- a/tools/testing/selftests/kvm/get-reg-list.c +++ b/tools/testing/selftests/kvm/get-reg-list.c @@ -98,6 +98,7 @@ void __weak print_reg(const char *prefix, __u64 id) printf("\t0x%llx,\n", id); } +#ifdef __aarch64__ static void prepare_vcpu_init(struct vcpu_reg_list *c, struct kvm_vcpu_init *init) { struct vcpu_reg_sublist *s; @@ -120,6 +121,25 @@ static void finalize_vcpu(struct kvm_vcpu *vcpu, struct vcpu_reg_list *c) } } +static struct kvm_vcpu *vcpu_config_get_vcpu(struct vcpu_reg_list *c, struct kvm_vm *vm) +{ + struct kvm_vcpu_init init = { .target = -1, }; + struct kvm_vcpu *vcpu; + + prepare_vcpu_init(c, &init); + vcpu = __vm_vcpu_add(vm, 0); + aarch64_vcpu_setup(vcpu, &init); + finalize_vcpu(vcpu, c); + + return vcpu; +} +#else +static struct kvm_vcpu *vcpu_config_get_vcpu(struct vcpu_reg_list *c, struct kvm_vm *vm) +{ + return __vm_vcpu_add(vm, 0); +} +#endif + static void check_supported(struct vcpu_reg_list *c) { struct vcpu_reg_sublist *s; @@ -139,7 +159,6 @@ static bool print_filtered; static void run_test(struct vcpu_reg_list *c) { - struct kvm_vcpu_init init = { .target = -1, }; int new_regs = 0, missing_regs = 0, i, n; int failed_get = 0, failed_set = 0, failed_reject = 0; struct kvm_vcpu *vcpu; @@ -149,10 +168,7 @@ static void run_test(struct vcpu_reg_list *c) check_supported(c); vm = vm_create_barebones(); - prepare_vcpu_init(c, &init); - vcpu = __vm_vcpu_add(vm, 0); - aarch64_vcpu_setup(vcpu, &init); - finalize_vcpu(vcpu, c); + vcpu = vcpu_config_get_vcpu(c, vm); reg_list = vcpu_get_reg_list(vcpu); -- 2.34.1