From patchwork Tue Nov 15 21:38:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Annapurve X-Patchwork-Id: 20588 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2955315wru; Tue, 15 Nov 2022 13:47:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf5kgrAlsKJtDGZvtlLSL5dOGEkyOug+1Q4/gik+fYxlTSGpYm03yRPA9MsCH3vmMk+nCRGa X-Received: by 2002:a17:902:fe18:b0:187:1e83:2505 with SMTP id g24-20020a170902fe1800b001871e832505mr6031305plj.132.1668548833992; Tue, 15 Nov 2022 13:47:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668548833; cv=none; d=google.com; s=arc-20160816; b=UFqIW/NNFdBSoc1lGDU6tNGN0YknxYcziFwceuP/HQmK89oyCxAbEQA2a3TF/7EaN9 n6M8NBKtB4AA0rseSvnGI3oBxlA4SX8Ap7xzvdkApLdsEAImpfVnfSOOrcc1j4N78nCI xsX53CVDi/hSTw0E5KHe7oKaaVT1s15qBiyVMgkd0tEyzvan8eNjzzDOIKbsjkYhRL1X K3HawSxWF/v44nRX0/YYAgJZnOqrBuuwZ9omz2Qt+WOrXzTqKgMb7bsAGAHHOP0jbw4K k+1vWAdT6BclD4VaAiG+h4iFzDoT6WXOO4N5KWZFqxFdpAYlfyt51UKIpoYoMlE5rSEM 2McQ== 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=tuWVwJ16YEkS5FVgRWJyUapc80qRQY7AsPIqQryq7YE=; b=vl2m2jvbRJUG0kLFJUlNtR2iVerGEg0sTEX6qZsldoW4kJt+1pldLgbDxcVVG7Tgn5 4ZhVoGPazcxMYbFLYJ0FvBuIOcsKpo6pbnwFK/v+JaUsWOQ1CePFpbz7F19JCINYrbGA T3khoWo9913DQIOdTBkwxs37uOX6FOnHdy85njhDCJAJRDNeDh4Ns6X+RBwCerILf3n2 ThSLnHVGQO2qAZDXCWxjZ+eNnMELG0h0W0LxBJOgoQg8yZAp4xHLlwH3SeoZ8lNVVttr /nPdYTaY9qCb9JVPPOB02uz/75oKw17SUg4NuAItRil8Dgba7gHaNddeVEybrHRx7iUl TLlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Wpu8ji1M; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bk2-20020a056a02028200b00476e63cfd11si460075pgb.468.2022.11.15.13.46.28; Tue, 15 Nov 2022 13:47:13 -0800 (PST) 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=Wpu8ji1M; 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 S238789AbiKOVjH (ORCPT + 99 others); Tue, 15 Nov 2022 16:39:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238790AbiKOViz (ORCPT ); Tue, 15 Nov 2022 16:38:55 -0500 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 8FC6CFE0 for ; Tue, 15 Nov 2022 13:38:54 -0800 (PST) Received: by mail-pj1-x104a.google.com with SMTP id om10-20020a17090b3a8a00b002108b078ab1so61088pjb.9 for ; Tue, 15 Nov 2022 13:38:54 -0800 (PST) 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:message-id:reply-to; bh=tuWVwJ16YEkS5FVgRWJyUapc80qRQY7AsPIqQryq7YE=; b=Wpu8ji1MBWg33BnAZTlztobw9K3WTIOlK7sZASVsqXi3+vyDsQxwAhGAJAdjSmbLv2 Cd2v+DUyc4BduafbFeSbrEBZM8bTt4thoOJ0BvGXG8/UYUpM0zbDh+WY6PK33JuEMUhV +2VmVOacoW9hnUlbA20zdD/tg3YYkUBlFT9YSMeYCgbvkwx9OWEuw4M9j34VzSjLjiug wQPPi3RjOHtNH/E1p/1oSpAEax6UmhFunrzv0zsKtP5+RdwnIQW93r4ThqXuSyoIr21Z ha6zv+DzeEqQtpzRb8Is84rpxsX/kiAOXHtbviwNRC44C1UTxKasvlD7ej2HlWY20Kvg N3jA== 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:message-id:reply-to; bh=tuWVwJ16YEkS5FVgRWJyUapc80qRQY7AsPIqQryq7YE=; b=DkvFl6c0mKPqK+vTQjEdXbCBIwPLKXwkPn6HtNTfDDIBd60pL/7CPPruBfdhAoWosM cMgjcmpf3vvh5TujdNIcHEjsn/vt3nBV6CQ+7+p0Y3Eh1b9v9PWkHfefcSZ6z8CR8Ytl 1AJFUmYFB2bbwY9wudT6X9CwjI0UJCULGJlHNRA/n6SKEnJ6bmZd/Uvq+/58duaRYkn0 EBH9OpKvn8TxRLK+K0CfiG8kc4PV0uyt9Iid0aMgUaicn4ij5p9PJ2vFisvf6ta/ENsj yS2Tfo9BPCueI8VG7EFayxN4F9tVzIW4SQ2wK+uXqF2jI6fgDHgz3ZpeDlkSBKt7bmAe 3QPQ== X-Gm-Message-State: ANoB5pmkrAuhrs2sD2olPMQ9NyieISiUAs62rHNOtFbvtx8vTy516QpK tuaRre0Yu8nEolZplF8iIyLGfXwu5sC+P03h X-Received: from vannapurve2.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:41f8]) (user=vannapurve job=sendgmr) by 2002:a17:902:d64f:b0:188:beef:b68f with SMTP id y15-20020a170902d64f00b00188beefb68fmr5588393plh.172.1668548334142; Tue, 15 Nov 2022 13:38:54 -0800 (PST) Date: Tue, 15 Nov 2022 21:38:44 +0000 In-Reply-To: <20221115213845.3348210-1-vannapurve@google.com> Mime-Version: 1.0 References: <20221115213845.3348210-1-vannapurve@google.com> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog Message-ID: <20221115213845.3348210-3-vannapurve@google.com> Subject: [V4 PATCH 2/3] 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, pgonda@google.com, andrew.jones@linux.dev, Vishal Annapurve 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,USER_IN_DEF_DKIM_WL autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749600262372962633?= X-GMAIL-MSGID: =?utf-8?q?1749600262372962633?= Introduce arch specific API: kvm_selftest_arch_init to allow each arch to handle initialization before running any selftest logic. Suggested-by: Sean Christopherson Reviewed-by: Andrew Jones Reviewed-by: Peter Gonda 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 | 6 ++++++ 3 files changed, 20 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 e42a09cd24a0..eec0e4898efe 100644 --- a/tools/testing/selftests/kvm/include/kvm_util_base.h +++ b/tools/testing/selftests/kvm/include/kvm_util_base.h @@ -838,4 +838,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 main(). + */ +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..0de4aabc0c76 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"); } + +void kvm_selftest_arch_init(void) +{ + /* + * arm64 doesn't have a true default mode, so start by computing the + * available IPA space and page sizes early. + */ + 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 37d7d144c74e..deb4c731b9fa 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c @@ -2022,8 +2022,14 @@ void __vm_get_stat(struct kvm_vm *vm, const char *stat_name, uint64_t *data, } } +__weak void kvm_selftest_arch_init(void) +{ +} + void __attribute((constructor)) kvm_selftest_init(void) { /* Tell stdout not to buffer its content. */ setbuf(stdout, NULL); + + kvm_selftest_arch_init(); }