Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp146734rwn; Wed, 14 Sep 2022 17:47:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5TBNGJXnl8BC8E2IBNoQJ37Vi3e9SqH7aLfncMRxTkrPctgXJ0RAIjsI/TXTpMhZCDJRq1 X-Received: by 2002:a17:906:7313:b0:780:5b91:7722 with SMTP id di19-20020a170906731300b007805b917722mr681939ejc.338.1663202834951; Wed, 14 Sep 2022 17:47:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663202834; cv=none; d=google.com; s=arc-20160816; b=YhJDH7B9k8LDHXQjzVs55J3vWg16uaEB8qiTUFi7a8xyPsuw/9HOQQCpE33ASH1JNQ AEw9VjeOClouk+N9G2gCnln/rHYbPmXxDDroHQseUOMltJCmQeLM4v1+SyWHndItmllF cWTbPAvFPwMPi400muK6K1tw+qq10UTcbBq/b4MjjO6SFFglzzmUTcw8XgI4UTvaAo5T z211Gct2d6kyYB/wHClTvnt0d1yzXKm3FzMjdlHHJy+EyzKwvV0PMpjcaTLVdcNSi5WD cWluv83OjjnG4qa4bNeGxAKtpZ7SRQPDfSFpmwHSVS2fF/8iMINRsEHe42DVaFMvX+h7 VH9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=k7YNCe9q93GJKQLNbQn4DCcTE32W+gnc21Gk4wtYZRU=; b=icc9RaZe8v4A8ha07uCa2uuQPS8GkgnV/LvuimIDxTkSZiOSZH7xTkbMHghtk5gud0 +i3pyW+FMhIgJUzsreifT3NKDuMyGZ69U6+laZDu3iCeAvzhpsn5OQozUb03IPFUJcMF Hn8cTgz5Ny0dEBCx1axmKWqDNDA3vxRdZ+v3k9nRid83biu6NunH9ehDVjjNibRRX50a jVy8YPwVWa0Ps1ULR7auAEuDwjUE5qA4XZAQks+WC2iHMUHC226dqPeD9JKhar6w3UCT S3qCaXE4mVEFK0TMl75I0cgjQfLPL2VuubV4y+gOu5wWJCXen3pCvLjMhyBR8KDMcBT+ qo7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Dcke97I3; 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 nc4-20020a1709071c0400b007799cb3317csi14117770ejc.280.2022.09.14.17.46.45; Wed, 14 Sep 2022 17:47:14 -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=Dcke97I3; 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 S229849AbiIOAFC (ORCPT + 99 others); Wed, 14 Sep 2022 20:05:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229758AbiIOAE6 (ORCPT ); Wed, 14 Sep 2022 20:04:58 -0400 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83EECFD19 for ; Wed, 14 Sep 2022 17:04:56 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id oc9-20020a17090b1c0900b00202843f7057so3035676pjb.1 for ; Wed, 14 Sep 2022 17:04:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date; bh=k7YNCe9q93GJKQLNbQn4DCcTE32W+gnc21Gk4wtYZRU=; b=Dcke97I3Xf1R9wOrr0D7KOe97Lixb1Dngj32GCMPg6ofYp2vRngBYLjYH5f6Gax+5H 7z7JCGkCxwAZPCQy0VhUomyvulmWIzB964FDPzC2FPXvMo09SbDgwn6aW7KAgl2XZl7H IvRJ8Os9yQEc58xg1jUFFtXZoZfFs3xA+OvWphHXtKlY2k/T2JfQYpJw7DwJai1tRzEy Cnyc+dIpp9VUCtf1AqR2Em49BDLkyGeuh5AfNkHFN27dS5FsPXtSDvp+SIZMVCWpSpYR Y0vBDqVgOBEFMn10Au98lYjJtjNuGeNtSYILkPALZ9+6ZAV+CVh+5D+G7CRW50mgBYb0 84Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date; bh=k7YNCe9q93GJKQLNbQn4DCcTE32W+gnc21Gk4wtYZRU=; b=UaEmrpiUFm3XdSdSh1g9xhDlddy+aX7pK1DmGx8SnMp7dv62KCH4Ha/PwYHFVw0iP5 EAUi6EKu1Gzj/ji9rj5lctpOtpcP0e62CJshRvdp2HWg/jT/3wdAUBleybMCWUcEISy1 cRAF9B+1ztHqRKFrRQ6bjRKZIY8VY1Je7WpsEjW4Z0tSwAxLd6tjXVaf7m9ln8NIrVO0 uFgQKs8cUWccn3Te4R+aWe0BUzPNJ7GmXOi7V7FUj4sHybh7n1fYyghCQEoqhNK28iDj P6gK+SR1uZuIYSkDsgvuFWSXFd5GWz7MNoXysozuBzredGg+NKWaGkp+zwwL5450iyHq Z8Zg== X-Gm-Message-State: ACrzQf2dtNsI6lxlux3bn7rI2Ywr2Eq+Pn5al5fWBEuFFVVbhdxuwAEm s3Y11vFOS5aw+qculy55wRB1x+J3nKES1ud3 X-Received: from vannapurve2.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:41f8]) (user=vannapurve job=sendgmr) by 2002:a17:90a:a09:b0:202:ab93:2afb with SMTP id o9-20020a17090a0a0900b00202ab932afbmr7459241pjo.60.1663200295926; Wed, 14 Sep 2022 17:04:55 -0700 (PDT) Date: Thu, 15 Sep 2022 00:04:42 +0000 In-Reply-To: <20220915000448.1674802-1-vannapurve@google.com> Mime-Version: 1.0 References: <20220915000448.1674802-1-vannapurve@google.com> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog Message-ID: <20220915000448.1674802-3-vannapurve@google.com> Subject: [V2 PATCH 2/8] KVM: selftests: Add arch specific initialization From: Vishal Annapurve To: x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: pbonzini@redhat.com, shuah@kernel.org, bgardon@google.com, seanjc@google.com, oupton@google.com, peterx@redhat.com, vkuznets@redhat.com, dmatlack@google.com, Vishal Annapurve Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_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 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. + */ +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