Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp192851rwb; Mon, 26 Sep 2022 17:08:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6HFt58YV8Oa6x85wm8bJtFEaSq6wu6NtjRtZkGuDmMOSWqCX2eR6Dglz+5Z5IgeIDB1LjC X-Received: by 2002:a05:6a00:84d:b0:542:4254:17ef with SMTP id q13-20020a056a00084d00b00542425417efmr26037249pfk.31.1664237293013; Mon, 26 Sep 2022 17:08:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664237293; cv=none; d=google.com; s=arc-20160816; b=tPBS3lFt6VqUTXoTcfZJGikL7onUAjMEkfpeQvkhlhGfIxJBHl8kcoJMPy6x2iGWrJ re3c25E8ICPbHU1TnvZ/RXgvkj9h0AUGP3wifo6LeReCKVKgfSXbk3Wc1cQMYGb/qORQ vhaB15vGCb3Ra1nR6Y0jbe5VgG6VILV9is2nTx3vQAEcSXYRyyzA4a+LR6T4FaONacf3 130VFKCedqNtvaGQVl4jEHiwUkAA+ckQYxEHv+9OmwUncqX9JYTnsi1F+ju9z16kss6C jjBqxje0QASxLnvICqMzcPwocVDrIOLG1+ggHV5C6GXfo+0AqOVWavoo5hOtK+m6Y4t0 ZXDA== 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=Jo63jB5aNkOmZDxGlU8EM0gFxXH2llzd7sTVLu1lWkc=; b=hhu8KdX1XXFa/zTr8QKBqDJresK/CGVBQMKMoJ4khTX9Qkj2ECqgWkS6q3kIICDgrc zmA2BE+ZxI16EyDGpB2Us+LhHqlNMCZqF+JLz31vGz9Kb8AB8HIlhFH/A5J8g57eHmpY nArhtS/PWh5zVO2x2a26b0+BkmKyme19ew3KvkHDpy5yh5rkubuqqjey/hSEKwwifDBc bDfssypxBkr8p1yObMcCrycx4UsNEyEACF7VRPsCEx7oaWxvrwTuyl9ebZzAZ5HCTnSw JjG41JaDEIlhrO/i8eWtulUdu0+ZM/ZNwDOmKpDwjQhxxujNR7J7Sqtf70X35lJk/NP3 gyvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=MIMLv+fn; 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 x27-20020a056a00189b00b00540d97d4509si345687pfh.58.2022.09.26.17.07.56; Mon, 26 Sep 2022 17:08:13 -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=MIMLv+fn; 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 S231222AbiIZXUS (ORCPT + 99 others); Mon, 26 Sep 2022 19:20:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231205AbiIZXTI (ORCPT ); Mon, 26 Sep 2022 19:19:08 -0400 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3290D98D0 for ; Mon, 26 Sep 2022 16:18:56 -0700 (PDT) Received: by mail-pg1-x531.google.com with SMTP id r62so4051387pgr.12 for ; Mon, 26 Sep 2022 16:18:56 -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=Jo63jB5aNkOmZDxGlU8EM0gFxXH2llzd7sTVLu1lWkc=; b=MIMLv+fnxX3/NujgpjMsljKROeTEsehckMHu/VtUXTQ6lmxDM+4W56RtENRiIpoOcD T9yxqUa9KXPczd7Glb4rMT7AAWsa9huqQDk9pGaDIv4O7F1nDuM2FrxOlFx72i2r3b+4 AmI8YMthUGJkG+GKj3Kmtzyk/N+UoybrcC69BgcOfIfoLmrftAxhdEHoFAs/v/E4/oed 9yhHs663VNYfrkHDAOWT8Gz8xgkaC0BI76niXWQasZXP07OtqPIgll/tqiyIcCoZW3Af APBufVCyll4LqSP4RQm2XfsaKfwf2afNIMBIvMZhrNISLDgwLBzSsdXJDulcyis1TsCc Y28g== 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=Jo63jB5aNkOmZDxGlU8EM0gFxXH2llzd7sTVLu1lWkc=; b=B/WUPTMFgMRzvojIl/v7ssS9GiwpTkekdRCuBwizxhB/xBf57dLzUnXMxEgHqRMCjV r9dijiK/zDnvB2lSsJNxtRmosQ2mq10clxzKl571nOVcfIMt5kXCcY/k1b3KrdOX0jcm e7UD3CdxpE6bpJu2eM8Qu8esdbJVKoRiQtyl5MVSTf1rT4mxWNrScOEM172EP+4g5wX1 n0M0gYsloDobrKPxaIMFr+Zzk55M6A2/MJWrP4sYS6QzX+wsowUcWj4edb8rAYbeti5n 7a2gjCSmyxqSSCrcl/EW2OcCrCwhXRQZ4XNed6k9PAObakMFYIb1kOyf3yIcarRAq/lV u6FQ== X-Gm-Message-State: ACrzQf2xwjZ01pDBEl9QKTGoQBrKw+wkh1KsiL9YqcK+UgYq05mOV2EE Yl3yV/heFFQNcM974jTndCgld7sYkpq1LI4bU13DtQ== X-Received: by 2002:a63:b4f:0:b0:439:cc64:50e6 with SMTP id a15-20020a630b4f000000b00439cc6450e6mr21426874pgl.483.1664234336144; Mon, 26 Sep 2022 16:18:56 -0700 (PDT) MIME-Version: 1.0 References: <20220915000448.1674802-1-vannapurve@google.com> <20220915000448.1674802-3-vannapurve@google.com> In-Reply-To: From: Vishal Annapurve Date: Mon, 26 Sep 2022 16:18:45 -0700 Message-ID: Subject: Re: [V2 PATCH 2/8] KVM: selftests: Add arch specific initialization To: David Matlack Cc: x86 , kvm list , LKML , linux-kselftest@vger.kernel.org, Paolo Bonzini , shuah , Ben Gardon , Sean Christopherson , Oliver Upton , peterx@redhat.com, Vitaly Kuznetsov 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 Wed, Sep 21, 2022 at 1:51 PM David Matlack 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. > > nit: s/before executing selftest logic/before main()/ > Ack, will fix this in the next series. > ("selftest logic" is vague) > > > + */ > > +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. > > + */ > > +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(); > > } > > Suggest defining a default no-op implementation of > kvm_selftest_arch_init() using __weak since most architectures do not > actually need an implementation. > Ack, will update this in the next series. > > ... > >