From patchwork Tue Jul 25 08:41:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haibo Xu X-Patchwork-Id: 125431 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2330280vqg; Tue, 25 Jul 2023 01:53:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlGauZex3lGjatDvrV3+9xuymWINqRbX0LU0HT76O9fBFAJkazTI1qDqzBCEhFIOSBuK0h8y X-Received: by 2002:a17:906:3085:b0:974:183a:54b6 with SMTP id 5-20020a170906308500b00974183a54b6mr10844010ejv.33.1690275211773; Tue, 25 Jul 2023 01:53:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690275211; cv=none; d=google.com; s=arc-20160816; b=tl6HM1U2y3hknRpxStbSDw2a6zYsLp3JtLKRE61kTVYWfYmR4p0VfoIo17HGIXEAA+ Z8zTL2aztG1vs2LqD4EOLT8YN8JfzPA2u2b7bA5s8mBbM8AuAyJ3EQ42YapbqFwGYz3G jdbLlOIvn/0xj0glupHhMNx7zVLkGZbEBGKaupAa5ssiSc6mM14AIm03JOW+qdNkMT0z E0/gQMFij4I4OZt4z7GyDQt9+UuULaz0tt7X6DVoG4IOxCht78vvCBMgdcGd9U30LF+J E/RzOcGncls8g6IwGrfRyGz/XMhb5rhy/yz9CYy00IuaeIPsvuNa1xoQdg/Cfe0ulOuM nb7A== 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=cChTheCQQZLmTrFX3JJjMMmjBlPw3t2aJIwjiibGiec=; fh=nbojmHnpHDWtjn+3N85SqC0aroe0kvPS40CgGs51wb8=; b=s44vd1HpFZB5y/RqPZTldm7GCFlWTDWXgEdwSGoWjkLvEATc3VkCJkhVPIMoAeWe2z wyg657DPDvF9wCXu+Y4giqYwXS5g3IU8jumXSNX3dMKTkYF3DQJkyv8kAFNkLQIvu3tC 3hfw1RHG+o4styAYWVHoD36FvmL7aSaNbmXb1MrNp8Y6CFR6Jsm+56fFmDdQjbuyyuA4 goUOw1P7J52cU53NOh52urq6IVjofqrNCuZ7B+5+c9QDI0LpKxMLAbcc9yVGUH5jc504 gVgUEPTYr7J6ep45loICRkZnYJbj225Oz3i/Tp9CLbkvRWx4XdChmhFQ5eTCJ4p2P4IW A8Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@intel.com header.s=Intel header.b=LoZUiGhm; 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 r25-20020a1709067fd900b0098638efc275si7020159ejs.688.2023.07.25.01.53.08; Tue, 25 Jul 2023 01:53:31 -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=LoZUiGhm; 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 S232233AbjGYIiv (ORCPT + 99 others); Tue, 25 Jul 2023 04:38:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232101AbjGYIi1 (ORCPT ); Tue, 25 Jul 2023 04:38:27 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A810172A; Tue, 25 Jul 2023 01:38:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690274298; x=1721810298; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tweL8MC1Z4PsW8REKGjDOZBcdwCj7tnWBl0dpmE8j5k=; b=LoZUiGhmGhwIUvvQWWoKutFIou/2vGmQiDbmaFuWbAtwIV3CE5syrpl7 GdquQWM5zmGm/xPdM/0pWpY6S2c1qOC18GthuqXWgX3ZRO3xqAgXb2mtD AOR1ODiBbejD3DK/oRAppLWfTzUH2zxvPPCabnbZd1WS1sZ7AvPiZvg6v wHqj8zzgoibMt1zpjfNkuzUnPxJiacRmHNbKojsVR8ObX0m6ycbFzIb8G l9+dpVPX5MnqpbvP9hHenm0d5Gb5d19nhLmGKn6gXRbHr8pzcPePD276O cKkGFE7PHP/SrLKL6kI7+t0XZs37MNPIGl3Oa0fSNFaCYSA1oN6CDgyMR g==; X-IronPort-AV: E=McAfee;i="6600,9927,10781"; a="371264870" X-IronPort-AV: E=Sophos;i="6.01,230,1684825200"; d="scan'208";a="371264870" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2023 01:38:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10781"; a="761130932" X-IronPort-AV: E=Sophos;i="6.01,230,1684825200"; d="scan'208";a="761130932" Received: from haibo-optiplex-7090.sh.intel.com ([10.239.159.132]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2023 01:38:09 -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 v6 09/13] KVM: arm64: selftests: Move finalize_vcpu back to run_test Date: Tue, 25 Jul 2023 16:41:35 +0800 Message-Id: <753d160e49e193f2800fdf45ad6d9af8c6828067.1690273969.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=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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: INBOX X-GMAIL-THRID: 1772382020290857591 X-GMAIL-MSGID: 1772382020290857591 No functional changes. Just move the finalize_vcpu call back to run_test and do weak function trick to prepare for the opration in riscv. Suggested-by: Andrew Jones Signed-off-by: Haibo Xu Reviewed-by: Andrew Jones --- .../selftests/kvm/aarch64/get-reg-list.c | 13 +++++++++++ tools/testing/selftests/kvm/get-reg-list.c | 22 +++++-------------- .../selftests/kvm/include/kvm_util_base.h | 3 +++ 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/tools/testing/selftests/kvm/aarch64/get-reg-list.c b/tools/testing/selftests/kvm/aarch64/get-reg-list.c index f8ebc058b191..709d7d721760 100644 --- a/tools/testing/selftests/kvm/aarch64/get-reg-list.c +++ b/tools/testing/selftests/kvm/aarch64/get-reg-list.c @@ -84,6 +84,19 @@ bool check_reject_set(int err) return err == EPERM; } +void finalize_vcpu(struct kvm_vcpu *vcpu, struct vcpu_reg_list *c) +{ + struct vcpu_reg_sublist *s; + int feature; + + for_each_sublist(c, s) { + if (s->finalize) { + feature = s->feature; + vcpu_ioctl(vcpu, KVM_ARM_VCPU_FINALIZE, &feature); + } + } +} + #define REG_MASK (KVM_REG_ARCH_MASK | KVM_REG_SIZE_MASK | KVM_REG_ARM_COPROC_MASK) #define CORE_REGS_XX_NR_WORDS 2 diff --git a/tools/testing/selftests/kvm/get-reg-list.c b/tools/testing/selftests/kvm/get-reg-list.c index 1df94e8e9ed5..43a919f2208f 100644 --- a/tools/testing/selftests/kvm/get-reg-list.c +++ b/tools/testing/selftests/kvm/get-reg-list.c @@ -34,9 +34,6 @@ static __u64 *blessed_reg, blessed_n; extern struct vcpu_reg_list *vcpu_configs[]; extern int vcpu_configs_n; -#define for_each_sublist(c, s) \ - for ((s) = &(c)->sublists[0]; (s)->regs; ++(s)) - #define for_each_reg(i) \ for ((i) = 0; (i) < reg_list->n; ++(i)) @@ -109,6 +106,10 @@ bool __weak check_reject_set(int err) return true; } +void __weak finalize_vcpu(struct kvm_vcpu *vcpu, struct vcpu_reg_list *c) +{ +} + #ifdef __aarch64__ static void prepare_vcpu_init(struct vcpu_reg_list *c, struct kvm_vcpu_init *init) { @@ -119,19 +120,6 @@ static void prepare_vcpu_init(struct vcpu_reg_list *c, struct kvm_vcpu_init *ini init->features[s->feature / 32] |= 1 << (s->feature % 32); } -static void finalize_vcpu(struct kvm_vcpu *vcpu, struct vcpu_reg_list *c) -{ - struct vcpu_reg_sublist *s; - int feature; - - for_each_sublist(c, s) { - if (s->finalize) { - feature = s->feature; - vcpu_ioctl(vcpu, KVM_ARM_VCPU_FINALIZE, &feature); - } - } -} - static struct kvm_vcpu *vcpu_config_get_vcpu(struct vcpu_reg_list *c, struct kvm_vm *vm) { struct kvm_vcpu_init init = { .target = -1, }; @@ -140,7 +128,6 @@ static struct kvm_vcpu *vcpu_config_get_vcpu(struct vcpu_reg_list *c, struct kvm prepare_vcpu_init(c, &init); vcpu = __vm_vcpu_add(vm, 0); aarch64_vcpu_setup(vcpu, &init); - finalize_vcpu(vcpu, c); return vcpu; } @@ -180,6 +167,7 @@ static void run_test(struct vcpu_reg_list *c) vm = vm_create_barebones(); vcpu = vcpu_config_get_vcpu(c, vm); + finalize_vcpu(vcpu, c); reg_list = vcpu_get_reg_list(vcpu); diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/testing/selftests/kvm/include/kvm_util_base.h index 1a455511503e..ec65c292b5fd 100644 --- a/tools/testing/selftests/kvm/include/kvm_util_base.h +++ b/tools/testing/selftests/kvm/include/kvm_util_base.h @@ -141,6 +141,9 @@ struct vcpu_reg_list { struct vcpu_reg_sublist sublists[]; }; +#define for_each_sublist(c, s) \ + for ((s) = &(c)->sublists[0]; (s)->regs; ++(s)) + #define kvm_for_each_vcpu(vm, i, vcpu) \ for ((i) = 0; (i) <= (vm)->last_vcpu_id; (i)++) \ if (!((vcpu) = vm->vcpus[i])) \