From patchwork Thu May 25 07:38:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haibo Xu X-Patchwork-Id: 98827 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp180195vqr; Thu, 25 May 2023 00:38:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5CJPsjODwjdlgeXCA7lu6MgKCXp2nROnB7aOG6SxZme3HQONQGn5tSr/MzNW4jOlFzGEeF X-Received: by 2002:a05:6a20:3947:b0:10c:7916:f9f6 with SMTP id r7-20020a056a20394700b0010c7916f9f6mr9941407pzg.52.1685000304608; Thu, 25 May 2023 00:38:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685000304; cv=none; d=google.com; s=arc-20160816; b=RNbruky6Iu+XK6Zl5A3lZEX5z/G8JfNjIaxuUmbqhxtQPsxi4XGj2bbt3mmR8Kv9mJ qVanjKGVY73KCdCr2KAah7Dbbca3qEEaDkUdrFjPQIx8Z+3M3bkAXssrCukVo2pgMOUC Hz+NUFReis0jC05GnXV/yYtAEEWCxmAwKTdh0pJt6rT3VmUV2xUuJhy5f+RHmnL46RkZ uvz5kN+CGM5q8qmcm4sDgYyliUuQIDPIhHYpE6oX4C3Iptp4ntqhH4uTYZs5Ra12E2zA HmwxAwAtcl+cbDz5+HvSWnxfKCoey8Lr/WtjHySjT517RJ7BzOXAQR0UgJTEtcxPwpSD lEMQ== 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=M/sby4ROX18+dwEZBCD/LWwWjnRL2Hbm11kxJMA7y8c=; b=MkvPX+HRTcyiJGjzwiYhG9W09S4csxwNKVCGK/BffeBNl3+vIIcgZeP8oFHiPk+w17 1eGiD3ZCh3wAVRk6bFaGWAxPesCDfYhjSx7BBWuB+QhM80MH5hpRahfSxyE6tN8Lgbay 83i6LOAl8UmTp+FlNdZgyEbRANeSRPdjwDmgvt9i3BSihhmxoxHu+iF3JHxgx+rmdVS5 vyr7NzyfnaWGUHyIAm9ie5Mnhu/RfdVdWfaTE4p/Z3QTTYUcME5OgLRzVRIMEbNiqm0j 1xcWw6wtcPU/9gYcoh+c5LTjor+s/501bdpOQW+NWLD/Nxjl1V5UjbAqpNHXdz/A+lrv PPig== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@intel.com header.s=Intel header.b=VAXle2Gz; 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 131-20020a630289000000b0053b9bbd31aasi521281pgc.551.2023.05.25.00.38.09; Thu, 25 May 2023 00:38:24 -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=VAXle2Gz; 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 S237059AbjEYHfq (ORCPT + 99 others); Thu, 25 May 2023 03:35:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239368AbjEYHf3 (ORCPT ); Thu, 25 May 2023 03:35:29 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 759D1E47; Thu, 25 May 2023 00:35:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685000127; x=1716536127; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9Xe9xj57Aj6Y+zbwY0sxx3rxGo9ZCYdqxL/t27YiGTk=; b=VAXle2GzU3Sie8OZUVIp54L4i4zM6CDTuWtKymjakf8sljb8hlqC20MN BV6jG19oO+8gN0M5ATPr1rriJXKceGYhn6RSMbjaukTwBCSsiKO2byoJi MWN4KywfpnTfzjPRmeRbz/aYyhemptz07aMWka5szAuiU4IoKRctLkQqQ 6/IG4F72sVpzU3EcCQRVcGgKpXYMJYJpXCUJeJVpHi+d8Vah5gNeJsefe Ar/sS8dX/jPD6zHRRHNzN5vNQ6hTeGDr/XAxxoJx+xM0Hld50lIGWbTTD v9qT1D14aZb7Zjst52w8+21euPrDstkPVPJisRiOBy0bd9BB0DapPAEH8 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10720"; a="356164439" X-IronPort-AV: E=Sophos;i="6.00,190,1681196400"; d="scan'208";a="356164439" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 May 2023 00:34:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10720"; a="769775956" X-IronPort-AV: E=Sophos;i="6.00,190,1681196400"; d="scan'208";a="769775956" Received: from haibo-optiplex-7090.sh.intel.com ([10.239.159.132]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 May 2023 00:34:08 -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 , David Matlack , Ben Gardon , 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 v2 07/11] KVM: arm64: selftests: Finish generalizing get-reg-list Date: Thu, 25 May 2023 15:38:31 +0800 Message-Id: <87f433096a95d21bcefe440629e74cd2a2d44470.1684999824.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=-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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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?1766850879199307577?= X-GMAIL-MSGID: =?utf-8?q?1766850879199307577?= 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 --- 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);