Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp207996rwb; Mon, 26 Sep 2022 17:24:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4u+aP8pMacKGodalfAIygtLOB0VC7aLaTIMq4kAnGMw/4335lTJAo5oamyhFmVySSTRpP9 X-Received: by 2002:a17:907:70a:b0:750:bf91:caa3 with SMTP id xb10-20020a170907070a00b00750bf91caa3mr20683850ejb.711.1664238276101; Mon, 26 Sep 2022 17:24:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664238276; cv=none; d=google.com; s=arc-20160816; b=1KvXhL3GwLSydipLVWUnARL5GBbGL0wUEwCJv39BYMZrHX/8Czh7qtzkmoDohzRe0j GrhebVJGtJ/JEzyw5kYxuyzPcbp3QoAUef3wgTIZbdJFQ1DQl2oNVDS4MU5riCaVasqX avMvxksNABMRbxJ63kosxifZ01++bEosCK+ILsI0tIkkGeWK8eHW+z2Z8Rjc0/9FyFlg QdVqVCgJ7+ZKEWyBxT+mAvu/uKv5xZKxoNRCX700gUbJM7lOlr4ND0W56UBKsEUbdVZ4 v7HcyYjimnomjm2A3OzAzbPEho2d/vEaSKnkATAtBFwyjnHlE47l2TiVHAFZMfjAPv/m mqJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=SIAPwLGrdF6de2sUvVzEsUXI67gCH9gi2KlqfGNRtvk=; b=EzSAlEgTb4VvS2e+157M+wtBUd/EDkDknLexXFdIkYA+RfwqvhVYlpSXuH/eGpbswD CT2oVfsma3mG+1625FwmdPobT1ZaSqIUMRI9f2uBDOcx4WtErYT9EsFZO1ok6+nUMuwm Dgn9PpLVY5n5X7nuCNlyrIx/JBHkP+Y1gvcJbI60R9NN4BI3eJDTm0y+a1K7Na14gkLW D5VIADylEsgCdBdh9MS/ZfoCME57OKOlcid7roO09wX3GljbdlqKUGBFzHpiXYv3h1dA oBznxEyeHFeoT9hHf6XHGjtgqVzKY87sy6zoH5YkBNDYceN7Ofy/IVobdbsrXbr1BhNK 5wQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=PiwXiRi6; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sb17-20020a1709076d9100b0078200e81b92si1584255ejc.758.2022.09.26.17.24.11; Mon, 26 Sep 2022 17:24:36 -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=pass header.i=@google.com header.s=20210112 header.b=PiwXiRi6; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231262AbiIZXTf (ORCPT + 99 others); Mon, 26 Sep 2022 19:19:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230393AbiIZXSw (ORCPT ); Mon, 26 Sep 2022 19:18:52 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA3F7B656C for ; Mon, 26 Sep 2022 16:18:50 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id d11so7578456pll.8 for ; Mon, 26 Sep 2022 16:18:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=SIAPwLGrdF6de2sUvVzEsUXI67gCH9gi2KlqfGNRtvk=; b=PiwXiRi6C5W9sHwMs6AfMS2o9JzPIAHf0vDUDJ4gQ4sXVlaTML3wMo++n6LPbexjxG yg+3HFqUSr7IIk+GDWu3bk261jQmKuSUpnrjAeXgsQ1fqp2oldn6BXZHs5IPKkBQdm4c jnBFOuGs7aTKI7SMJ6LBaNzvjg9tAMuWhXKOGN0ZdgF8r1WtCYP2z41AgLNbGUoZHtXh K32XsFj7suJJr0vWAZFCww+Umdo1J5TA0yuR8gTn5cPhzkJ0ycEMDffQ0ZLU+l7yh75b yK1F5yOF8lNeNKC0134uIKJ/DVxvCQ6kuXkK/aqJkCL6DGzU8g4G88Y2tXr1kimfhyEG jtRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=SIAPwLGrdF6de2sUvVzEsUXI67gCH9gi2KlqfGNRtvk=; b=yeG73gQXqlr8uPaODiiBpq+3bn35N0kDnsuZdav2GSnYFHszKBlfVIZuwu95dvGnRe MRIppMZ+3du5PsRP0y2H9BSQyurRdSwkmPZYtnGRgBZ+ZRRb6jP1SH8qM66y9bt2TS7O qVA4T0DGqHkRIyRfttyPZRge/O9kWLOJQVFDQG45pHiO1em7wN22lvewwanOSNb0Tb0y frJCkKsZBDkd4mhXNEQ9E6myHEYc1SlsrSCyX0TQ6a0WV+BpXW5BhYf6TZwBZ2mTwNzL u61k/tSzm8RNgrZiodFeb9gcxy2ugPU2B2gbSPwo9k3lNULX+CorDLX2Vti5K4KO+mGs vyXQ== X-Gm-Message-State: ACrzQf17zo+XjAjsQzezdkjuIMaM/zS0cro9cRUvHv5ozbwWp1N/TBWu fMadl7cV23vkrPmMa6RdtADyIsjCJNmeOabQ7+NXaQ== X-Received: by 2002:a17:902:d143:b0:178:456b:8444 with SMTP id t3-20020a170902d14300b00178456b8444mr24452996plt.137.1664234330087; Mon, 26 Sep 2022 16:18:50 -0700 (PDT) MIME-Version: 1.0 References: <20220915000448.1674802-1-vannapurve@google.com> <20220915000448.1674802-3-vannapurve@google.com> <20220915094442.45eldu4bes5alacm@kamzik> In-Reply-To: <20220915094442.45eldu4bes5alacm@kamzik> From: Vishal Annapurve Date: Mon, 26 Sep 2022 16:18:39 -0700 Message-ID: Subject: Re: [V2 PATCH 2/8] KVM: selftests: Add arch specific initialization To: Andrew Jones Cc: x86 , kvm list , LKML , linux-kselftest@vger.kernel.org, Paolo Bonzini , shuah , Ben Gardon , Sean Christopherson , Oliver Upton , peterx@redhat.com, Vitaly Kuznetsov , David Matlack Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 15, 2022 at 2:44 AM Andrew Jones wrote: > > On Thu, Sep 15, 2022 at 12:04:42AM +0000, Vishal Annapurve wrote: > > Introduce arch specific API: kvm_selftest_arch_init to allow each arch to > > handle initialization before running any selftest logic. > > > > Suggested-by: Sean Christopherson > > Signed-off-by: Vishal Annapurve > > --- > > .../selftests/kvm/include/kvm_util_base.h | 5 +++++ > > .../selftests/kvm/lib/aarch64/processor.c | 18 +++++++++--------- > > tools/testing/selftests/kvm/lib/kvm_util.c | 2 ++ > > .../selftests/kvm/lib/riscv/processor.c | 4 ++++ > > .../selftests/kvm/lib/s390x/processor.c | 4 ++++ > > .../selftests/kvm/lib/x86_64/processor.c | 4 ++++ > > 6 files changed, 28 insertions(+), 9 deletions(-) > > > > diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/testing/selftests/kvm/include/kvm_util_base.h > > index 24fde97f6121..98edbbda9f97 100644 > > --- a/tools/testing/selftests/kvm/include/kvm_util_base.h > > +++ b/tools/testing/selftests/kvm/include/kvm_util_base.h > > @@ -834,4 +834,9 @@ static inline int __vm_disable_nx_huge_pages(struct kvm_vm *vm) > > return __vm_enable_cap(vm, KVM_CAP_VM_DISABLE_NX_HUGE_PAGES, 0); > > } > > > > +/* > > + * API to execute architecture specific setup before executing selftest logic. > > + */ > > +void kvm_selftest_arch_init(void); > > + > > #endif /* SELFTEST_KVM_UTIL_BASE_H */ > > diff --git a/tools/testing/selftests/kvm/lib/aarch64/processor.c b/tools/testing/selftests/kvm/lib/aarch64/processor.c > > index 6f5551368944..2281d6c5d02f 100644 > > --- a/tools/testing/selftests/kvm/lib/aarch64/processor.c > > +++ b/tools/testing/selftests/kvm/lib/aarch64/processor.c > > @@ -495,15 +495,6 @@ void aarch64_get_supported_page_sizes(uint32_t ipa, > > close(kvm_fd); > > } > > > > -/* > > - * arm64 doesn't have a true default mode, so start by computing the > > - * available IPA space and page sizes early. > > - */ > > -void __attribute__((constructor)) init_guest_modes(void) > > -{ > > - guest_modes_append_default(); > > -} > > - > > void smccc_hvc(uint32_t function_id, uint64_t arg0, uint64_t arg1, > > uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5, > > uint64_t arg6, struct arm_smccc_res *res) > > @@ -528,3 +519,12 @@ void smccc_hvc(uint32_t function_id, uint64_t arg0, uint64_t arg1, > > [arg4] "r"(arg4), [arg5] "r"(arg5), [arg6] "r"(arg6) > > : "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"); > > } > > + > > +/* > > + * arm64 doesn't have a true default mode, so start by computing the > > + * available IPA space and page sizes early. > > + */ > > It'd be better to move this comment inside the function above the > guest_modes_append_default call. > Ack, will fix this in the next series. > > +void kvm_selftest_arch_init(void) > > +{ > > + guest_modes_append_default(); > > +} > > diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c > > index 3c83838999f5..dafe4471a6c7 100644 > > --- a/tools/testing/selftests/kvm/lib/kvm_util.c > > +++ b/tools/testing/selftests/kvm/lib/kvm_util.c > > @@ -1984,4 +1984,6 @@ void __attribute((constructor)) kvm_selftest_init(void) > > { > > /* Tell stdout not to buffer its content. */ > > setbuf(stdout, NULL); > > + > > + kvm_selftest_arch_init(); > > } > > diff --git a/tools/testing/selftests/kvm/lib/riscv/processor.c b/tools/testing/selftests/kvm/lib/riscv/processor.c > > index 604478151212..26660dd2ba78 100644 > > --- a/tools/testing/selftests/kvm/lib/riscv/processor.c > > +++ b/tools/testing/selftests/kvm/lib/riscv/processor.c > > @@ -362,3 +362,7 @@ void vcpu_args_set(struct kvm_vcpu *vcpu, unsigned int num, ...) > > void assert_on_unhandled_exception(struct kvm_vcpu *vcpu) > > { > > } > > + > > +void kvm_selftest_arch_init(void) > > +{ > > +} > > diff --git a/tools/testing/selftests/kvm/lib/s390x/processor.c b/tools/testing/selftests/kvm/lib/s390x/processor.c > > index 89d7340d9cbd..8654ec74009a 100644 > > --- a/tools/testing/selftests/kvm/lib/s390x/processor.c > > +++ b/tools/testing/selftests/kvm/lib/s390x/processor.c > > @@ -218,3 +218,7 @@ void vcpu_arch_dump(FILE *stream, struct kvm_vcpu *vcpu, uint8_t indent) > > void assert_on_unhandled_exception(struct kvm_vcpu *vcpu) > > { > > } > > + > > +void kvm_selftest_arch_init(void) > > +{ > > +} > > diff --git a/tools/testing/selftests/kvm/lib/x86_64/processor.c b/tools/testing/selftests/kvm/lib/x86_64/processor.c > > index 2e6e61bbe81b..20bf125f9363 100644 > > --- a/tools/testing/selftests/kvm/lib/x86_64/processor.c > > +++ b/tools/testing/selftests/kvm/lib/x86_64/processor.c > > @@ -1311,3 +1311,7 @@ bool vm_is_unrestricted_guest(struct kvm_vm *vm) > > > > return val == 'Y'; > > } > > + > > +void kvm_selftest_arch_init(void) > > +{ > > +} > > -- > > 2.37.2.789.g6183377224-goog > > > > Otherwise, > > Reviewed-by: Andrew Jones