Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp12301764rwd; Fri, 23 Jun 2023 04:25:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5zwqyhmxXVl+YzGjXE3Ex0UNLoKJdazkiemPkLQa7yIT5XevD7eQCZRuoRszbAyna3MVC8 X-Received: by 2002:a17:902:aa97:b0:1b2:28ca:d16 with SMTP id d23-20020a170902aa9700b001b228ca0d16mr17995829plr.44.1687519516903; Fri, 23 Jun 2023 04:25:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687519516; cv=none; d=google.com; s=arc-20160816; b=cAu5y1y/NPHEXCGgQdVZfP3udij+QPn4aXshCH6Un/Nsl9Lld8FWrthxxh8SsAO8XO iD0N47p4vIoBvd9JkKstKZVlm/c+bJo+xNn0UJ0pTAJpxVJ2tbMDwXbT8MN6P9pjGIGE Rj7hFj/rtaPpiPmtiCPgdg6MMm7S99yQMpx3av7u4NdjIA+RfntmRPn9fNqv9dIwSTE8 Q1kOY8PY00+1g65PtFsgEaeDPdsZJj8py2fbrxGIvGEJOlRCHRX9oDZMk6SGBSA0NNxv 2eYFxzg2ras+VH4ZR7AGYavj9fIU6uACgkTSgqZq9NIAjkZqrsPkK/0HUEgIignPaVpK Pn7g== 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=; b=0TZQGlh4PHZ7NEvyoRICsdUJyII9am4VfLBjmJonyJmxu/V7uXQV9iNXE+dw7elSw8 PNWRMoOW7KkTkozgu+E08CCKV0M/XmXJAbCiWU1YWSuP3u85PdL7hmKE8WLxsHFzaBCz yMyEJhYgFdhLx4t9+q1xvq6SkSHs/xtxE5/w0JylhA3yL9v2/I40DXjksGgkKMtPs+4q /zXWk0H7t/jeVTYMWQSOoieWIjsNKuLbbrr2RcDsoP+8jvcJtHBvHWApaTMXVNlL1Sbi xFB/B1TsmvMSpd8nhUWPnOInl69ln7pWUKtRqv+EMNJrtyp2c9GyUhw3gjKmQhJPPCM3 AZZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@intel.com header.s=Intel header.b="HLd5/BS+"; 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 n7-20020a170903110700b001b22c8d0dc5si2010609plh.437.2023.06.23.04.25.03; Fri, 23 Jun 2023 04:25:16 -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="HLd5/BS+"; 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 S231571AbjFWKgx (ORCPT + 99 others); Fri, 23 Jun 2023 06:36:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232344AbjFWKgf (ORCPT ); Fri, 23 Jun 2023 06:36:35 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDCBC2979; Fri, 23 Jun 2023 03:36:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687516572; x=1719052572; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EXZQIePHrnC+4oyrdo52RNlpn5u8QhJ9eHGJ6BBZ17s=; b=HLd5/BS+VbXTlxtvwlI0s+LnW1doeukLCio8yOlqHfaXr6JxDsnSUbjv yEFf3P7dFGlPrQwih6qz/Cy/TRZSk+YYGoHI3L8uE5Fu3pykymQIy/TW5 GfpC4iQrNkwa4x+5EEKxnDd8qO9oAYG+f4EbdCFwNz+ZwjeWXNmbs1MGN GFERhl4UQ+yHSNy/w1OhhYjDQYtzV772FwDsx7EMshQF6SkcIsVbWMaVn nStigDtJA5kFDiSFTo6aplNHIf0WxXy49qtJT1tiWwhw9uu/Otcfj5XC0 JQybXoSxIBotxp8q4xPHIVc9raPC496rucPWNbIsKqh2bnmltfMA5zBrl g==; X-IronPort-AV: E=McAfee;i="6600,9927,10749"; a="447112583" X-IronPort-AV: E=Sophos;i="6.01,151,1684825200"; d="scan'208";a="447112583" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2023 03:36:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10749"; a="715276101" X-IronPort-AV: E=Sophos;i="6.01,151,1684825200"; d="scan'208";a="715276101" Received: from haibo-optiplex-7090.sh.intel.com ([10.239.159.132]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2023 03:36:04 -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 , Ben Gardon , David Matlack , Ricardo Koller , Vishal Annapurve , 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 v4 07/12] KVM: arm64: selftests: Finish generalizing get-reg-list Date: Fri, 23 Jun 2023 18:40:09 +0800 Message-Id: <0d81728cf8b4fd931b495ac4c86d6a74e55a5230.1687515463.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