Message ID | 450cb59db52ebeaa68f3d77f1bd995618f3612b8.1686275310.git.haibo1.xu@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp667180vqr; Thu, 8 Jun 2023 19:25:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5PQp9AyP9IflnVuXiBlhi3l87b8UJf2irHzcwRTbb0jQ9ok0HvFPPnlmcg9YV5VYKrb6Gp X-Received: by 2002:a05:6359:a8a:b0:129:bed5:f63f with SMTP id em10-20020a0563590a8a00b00129bed5f63fmr144849rwb.12.1686277519836; Thu, 08 Jun 2023 19:25:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686277519; cv=none; d=google.com; s=arc-20160816; b=Pr0oM4SrR8TkqWVNGt9L08zQWuFNKioeVH/1bxLl/GCS6Xo0azC7mWnc6HL65jigg/ 9Z218+68qhNqHGyO1FGHTGyVtQRxwv+pmIZDU0JBc8mmn+Es/sIIwtLqvOSqUjMdQ9XZ 8l2Ii9J6+0/JBprkoLQDjZuSvWmYBQb9zYKHlI3NV2BHxBRaWV9LEEHh3Vj6f+0Od83+ UJpM2t/qMTltipBAjJ+8I7cvoa8nXDap2tpZS5gy57I8zH1g+mt1pYLSV7i/x2QrVXiO /azSSkt24dScRDz78k7QkZBp3BqsjQBnNtYG5qGHnG2pItvnHEGstp88dNIRPv1wqt3M Z7NA== 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=JXTnNuk2PC+j5sSg/JnbyqSPw9xMwQItvHPSr9/mpUY=; b=gmw5FEl/LID8E9KuPTEHcxkxSqR8yUfMaU40nRl4hp3rwJppKZhvQfxbHXHzfo5KE5 w32G+YXBlyz7xKX0Q9k8o+v2G36ul/RPj2FlOGhqtBCadfNl09iBPgAq/+6FR5hhUhfB xOABAoNbWvMlY5I2hJLkvFL4e9GfWiOjruLR2ZWz0+9+HsdM+nkejGrSC3SqeiYR1IZY 0nJMRIEh6Z5jRfy/8773IwnYh+rkFOqAFmBsIbb/K4c/Egd1FIbj2Gcu9d3q4Su4ZRi5 /18Vz/J9CX5n9cFQB8kqy5WNNqhh6PI0ECCo9WH+p6pHnt/+2mp8Z9BW22y5b/HTjibk a+2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@intel.com header.s=Intel header.b=ahl9fMj8; 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 s17-20020a63af51000000b0053fbb186dbasi1827198pgo.244.2023.06.08.19.25.05; Thu, 08 Jun 2023 19:25:19 -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=ahl9fMj8; 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 S238161AbjFICIN (ORCPT <rfc822;literming00@gmail.com> + 99 others); Thu, 8 Jun 2023 22:08:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238254AbjFICIG (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 8 Jun 2023 22:08:06 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5851F3A94; Thu, 8 Jun 2023 19:07:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686276472; x=1717812472; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UlIRkUVulcSCFIf9TRzhX1R3LH6Ql1M5u49CXYdVOfk=; b=ahl9fMj8adqoAV6EEYwQeZIr/OSqWzMgmIHhiVXsfiq/iuIzTWJQ9Cam jiH7o2pbz10GH+88w1SlAt2aufWyDJ58OA7nNDtX55BxOsm0pKusu4IlZ Xdi0+QPnvzbDRqW7gVeJ24yNQe/70m8G8wGPZyUIgOKfj0eZLB8kmX/Jj U3+3M6hpsTmjlRfGQcd3LAFPXOi++SM/O6TjULdLsNgKArij5EepLK+4/ pRSLS9nwKm+UgtnUQmBB3xkubPJRs3Vh8/1E9RrfEFRT/mIjRT3FU5oqn AOGufU7Nf/mkd9G9RaPI8BiEmuoh09cpTgo69NjqIAt58NQyv/jiQ6l4v Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10735"; a="359975619" X-IronPort-AV: E=Sophos;i="6.00,228,1681196400"; d="scan'208";a="359975619" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jun 2023 19:07:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10735"; a="713334823" X-IronPort-AV: E=Sophos;i="6.00,228,1681196400"; d="scan'208";a="713334823" Received: from haibo-optiplex-7090.sh.intel.com ([10.239.159.132]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jun 2023 19:07:43 -0700 From: Haibo Xu <haibo1.xu@intel.com> Cc: xiaobo55x@gmail.com, haibo1.xu@intel.com, ajones@ventanamicro.com, maz@kernel.org, oliver.upton@linux.dev, seanjc@google.com, Paolo Bonzini <pbonzini@redhat.com>, Jonathan Corbet <corbet@lwn.net>, Anup Patel <anup@brainfault.org>, Atish Patra <atishp@atishpatra.org>, Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, Shuah Khan <shuah@kernel.org>, James Morse <james.morse@arm.com>, Suzuki K Poulose <suzuki.poulose@arm.com>, Zenghui Yu <yuzenghui@huawei.com>, David Matlack <dmatlack@google.com>, Ben Gardon <bgardon@google.com>, Vipin Sharma <vipinsh@google.com>, Colton Lewis <coltonlewis@google.com>, 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 v3 07/10] KVM: arm64: selftests: Finish generalizing get-reg-list Date: Fri, 9 Jun 2023 10:12:15 +0800 Message-Id: <450cb59db52ebeaa68f3d77f1bd995618f3612b8.1686275310.git.haibo1.xu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <cover.1686275310.git.haibo1.xu@intel.com> References: <cover.1686275310.git.haibo1.xu@intel.com> 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, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768190136167157997?= X-GMAIL-MSGID: =?utf-8?q?1768190136167157997?= |
Series |
RISCV: Add KVM_GET_REG_LIST API
|
|
Commit Message
Haibo Xu
June 9, 2023, 2:12 a.m. UTC
From: Andrew Jones <ajones@ventanamicro.com> 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 <ajones@ventanamicro.com> Signed-off-by: Haibo Xu <haibo1.xu@intel.com> --- tools/testing/selftests/kvm/get-reg-list.c | 24 ++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)
Comments
On Fri, Jun 09, 2023 at 10:12:15AM +0800, Haibo Xu wrote: > From: Andrew Jones <ajones@ventanamicro.com> > > 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 <ajones@ventanamicro.com> > Signed-off-by: Haibo Xu <haibo1.xu@intel.com> > --- > tools/testing/selftests/kvm/get-reg-list.c | 24 ++++++++++++++++++---- > 1 file changed, 20 insertions(+), 4 deletions(-) > > diff --git a/tools/testing/selftests/kvm/get-reg-list.c b/tools/testing/selftests/kvm/get-reg-list.c > index 69bb91087081..c4bd5a5259da 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,24 @@ 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); > + > + 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 +158,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,9 +167,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); > + vcpu = vcpu_config_get_vcpu(c, vm); > finalize_vcpu(vcpu, c); I just noticed that this has been modified from what I posted to leave the finalize_vcpu() call here, despite it now being inside the #ifdef __aarch64__. That breaks the purpose of the patch. Please make sure this file compiles for other architectures without requiring additional patches, which would keep the commit message honest. You can either revert this to what I posted, and then readd the finalize_vcpu() call in another patch, or you can add a finalize_vcpu() stub to the #else part of the ifdef in this patch. Also please don't modify patches authored by others without calling out the modifications somewhere, either the commit message or under the --- of the patch or in the cover letter. Thanks, drew
On Fri, Jun 9, 2023 at 8:30 PM Andrew Jones <ajones@ventanamicro.com> wrote: > > On Fri, Jun 09, 2023 at 10:12:15AM +0800, Haibo Xu wrote: > > From: Andrew Jones <ajones@ventanamicro.com> > > > > 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 <ajones@ventanamicro.com> > > Signed-off-by: Haibo Xu <haibo1.xu@intel.com> > > --- > > tools/testing/selftests/kvm/get-reg-list.c | 24 ++++++++++++++++++---- > > 1 file changed, 20 insertions(+), 4 deletions(-) > > > > diff --git a/tools/testing/selftests/kvm/get-reg-list.c b/tools/testing/selftests/kvm/get-reg-list.c > > index 69bb91087081..c4bd5a5259da 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,24 @@ 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); > > + > > + 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 +158,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,9 +167,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); > > + vcpu = vcpu_config_get_vcpu(c, vm); > > finalize_vcpu(vcpu, c); > > I just noticed that this has been modified from what I posted to leave > the finalize_vcpu() call here, despite it now being inside the #ifdef > __aarch64__. That breaks the purpose of the patch. Please make sure this > file compiles for other architectures without requiring additional > patches, which would keep the commit message honest. You can either > revert this to what I posted, and then readd the finalize_vcpu() call in > another patch, or you can add a finalize_vcpu() stub to the #else part > of the ifdef in this patch. > > Also please don't modify patches authored by others without calling out > the modifications somewhere, either the commit message or under the --- > of the patch or in the cover letter. > Thanks for pointing it out! I will have a check about it. > Thanks, > drew
diff --git a/tools/testing/selftests/kvm/get-reg-list.c b/tools/testing/selftests/kvm/get-reg-list.c index 69bb91087081..c4bd5a5259da 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,24 @@ 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); + + 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 +158,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,9 +167,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); + vcpu = vcpu_config_get_vcpu(c, vm); finalize_vcpu(vcpu, c); reg_list = vcpu_get_reg_list(vcpu);