[v2,19/50] KVM: arm64: Do arm/arch initialization without bouncing through kvm_init()
Message ID | 20221130230934.1014142-20-seanjc@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1199356wrr; Wed, 30 Nov 2022 15:13:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf6T7v9ySumHP5fjzx1NIgPlpefPeeWcyKx0KdmubfNYf0GgEkDJ63th5eP0j7ayWVFkCtIK X-Received: by 2002:a63:9d46:0:b0:477:d018:362e with SMTP id i67-20020a639d46000000b00477d018362emr27666153pgd.502.1669850016909; Wed, 30 Nov 2022 15:13:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669850016; cv=none; d=google.com; s=arc-20160816; b=wYOmoFRad0Asx1vX4gt9yqNe1eHwpAsLqIgZ9gwladB+OZpN0LpcwsPRqGRGBTnJyf l5UJe8tKXbrWzZQ981ffleOKBXU+L1Ly6+mK+2IH3hWKGRs0v7GDtimB9V6CJBLa/fft TWoBu57PickQNTnxDNuHyqWwCsJ4OHNYrx2JwI3Li+ZNnHUznE3ytUwF2o2CT+qD2cka OM6pGNXo+3NWCai6y3EDRSpDUjk+YRWVPjUdNzCf6N5Og2BV9QC5bhhzgoWJwpCVSn/+ /zAY5z2WLfezHOAVdcgL+BeDnQp6DT3vU6Vt6D8GbYjL0NY4fxf0aOJlBZTQPqsYm8ky mHwA== 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:reply-to:dkim-signature; bh=3q8g1I3CG/zN/S6yfEuz3UEYEnVKGNtIkvlUCCz4wMk=; b=JLejXxs3gvrp79jA4KyHbrNrZWUTaxo2XKaYrQOMaADhdahuJEBFNwndmpLNRtqRPS f/+RJgpDGZEvrbUTqiL+utAUBaJIxTd7lghOqWb3lC0lGN/nUAX/gvuFyGXxMfBw2Mqf 8XSSvUmDR/4ThextRBHKbs8WwKKxm9zPqSRFW01swoULnQcEwcCeU9e2Zrx2K7w8l36b ip/4vrkplB6IOFyHFZUE2ryLmnqMUTLhWUgZp2MtCKLT2VLfcWQpclRKcdZIs7fII+nT Ab9xG6gJnCRCsKlTUjLEzGD2CHz3NLbxtoll868elLpwsWV3/6qMZCGt+iiS2nU/6wzY TC1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=IzqZX1vp; 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 mr14-20020a17090b238e00b00218c111625csi5320949pjb.150.2022.11.30.15.13.24; Wed, 30 Nov 2022 15:13:36 -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=IzqZX1vp; 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 S229969AbiK3XNA (ORCPT <rfc822;heyuhang3455@gmail.com> + 99 others); Wed, 30 Nov 2022 18:13:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230009AbiK3XMD (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 30 Nov 2022 18:12:03 -0500 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B9629AE29 for <linux-kernel@vger.kernel.org>; Wed, 30 Nov 2022 15:10:28 -0800 (PST) Received: by mail-pj1-x1049.google.com with SMTP id m2-20020a17090aab0200b002188c801f92so169155pjq.4 for <linux-kernel@vger.kernel.org>; Wed, 30 Nov 2022 15:10:28 -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:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=3q8g1I3CG/zN/S6yfEuz3UEYEnVKGNtIkvlUCCz4wMk=; b=IzqZX1vpqBRD6eqp/m2lCIonVBr9d0e0dYh+rnORdsBouvRr/LJHoAVFCGYwduLpYW OTMMo4gprlzO/u6ojuhJyOc3wk8iW8vMqSUKMIfurZ/dESMUEks0XD0dELDo/XLaovGl EKo5NrbtnviyIeCdpV2+U1bLcQY9lYskXKPUNJWsxtd+ecYNZC7sEQkVg+anA/T0XgVe YvNoKh5i6BiC33HYuQOVTGAT9N1QTpRLVSSatOGlZCfv03s8ZzOwEte840f58eQcGUDe h1+xBUE24TMAZ61kNCycVQsK/JxxPJO1UMM34/IR0XeCfuqHb2uwlievzCRoo9MRdbjv 0jwg== 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:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=3q8g1I3CG/zN/S6yfEuz3UEYEnVKGNtIkvlUCCz4wMk=; b=hpeqr39wyJ3xo+HMCZDpF3exqi2aBpd2f++XWGseOlk/Ovz/0tV5vQvNQjvXxwYw/V MY4Io5rvnURn9e4MyiRymK//9x/SKEZRwk3O2JcqsZqW8i/TIjddWGEZh4zz0jtlzA22 dEnRMC2Ax+J6OOO+uvdIyR29N3WguZbHSlycy+OJ5nC3WHB/NvIpY5EmGiUDXSK8bNbV SVjMMfNF8KpkLATG49ent3ikexrOP6+83ZRZsNQIxj9XH3orP4FZElhjPlBfjJkH7M4z yV/70Xj92NGbEeHPdHBNuVGY12EMhSYq3ee9KmSzSK3htIZg+ws+WeHtI55uOkRxq2uC 9dzw== X-Gm-Message-State: ANoB5pnk1tQflqNgokz/UcEgyocTW4J0d6VVJEJPabBF/l5CsCRwrzzh srmZ+Qm+jOJEGQdATZbBXO/ziIOky2s= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:aa7:8bc1:0:b0:575:bfb9:b1fa with SMTP id s1-20020aa78bc1000000b00575bfb9b1famr7674415pfd.62.1669849810052; Wed, 30 Nov 2022 15:10:10 -0800 (PST) Reply-To: Sean Christopherson <seanjc@google.com> Date: Wed, 30 Nov 2022 23:09:03 +0000 In-Reply-To: <20221130230934.1014142-1-seanjc@google.com> Mime-Version: 1.0 References: <20221130230934.1014142-1-seanjc@google.com> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog Message-ID: <20221130230934.1014142-20-seanjc@google.com> Subject: [PATCH v2 19/50] KVM: arm64: Do arm/arch initialization without bouncing through kvm_init() From: Sean Christopherson <seanjc@google.com> To: Paolo Bonzini <pbonzini@redhat.com>, Marc Zyngier <maz@kernel.org>, Huacai Chen <chenhuacai@kernel.org>, Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>, Anup Patel <anup@brainfault.org>, Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, Christian Borntraeger <borntraeger@linux.ibm.com>, Janosch Frank <frankja@linux.ibm.com>, Claudio Imbrenda <imbrenda@linux.ibm.com>, Matthew Rosato <mjrosato@linux.ibm.com>, Eric Farman <farman@linux.ibm.com>, Sean Christopherson <seanjc@google.com>, Vitaly Kuznetsov <vkuznets@redhat.com>, David Woodhouse <dwmw2@infradead.org>, Paul Durrant <paul@xen.org> Cc: James Morse <james.morse@arm.com>, Alexandru Elisei <alexandru.elisei@arm.com>, Suzuki K Poulose <suzuki.poulose@arm.com>, Oliver Upton <oliver.upton@linux.dev>, Atish Patra <atishp@atishpatra.org>, David Hildenbrand <david@redhat.com>, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, Yuan Yao <yuan.yao@intel.com>, Cornelia Huck <cohuck@redhat.com>, Isaku Yamahata <isaku.yamahata@intel.com>, " =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= " <philmd@linaro.org>, Fabiano Rosas <farosas@linux.ibm.com>, Michael Ellerman <mpe@ellerman.id.au>, Kai Huang <kai.huang@intel.com>, Chao Gao <chao.gao@intel.com>, Thomas Gleixner <tglx@linutronix.de> 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,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: <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?1750964651658690934?= X-GMAIL-MSGID: =?utf-8?q?1750964651658690934?= |
Series |
KVM: Rework kvm_init() and hardware enabling
|
|
Commit Message
Sean Christopherson
Nov. 30, 2022, 11:09 p.m. UTC
Do arm/arch specific initialization directly in arm's module_init(), now
called kvm_arm_init(), instead of bouncing through kvm_init() to reach
kvm_arch_init(). Invoking kvm_arch_init() is the very first action
performed by kvm_init(), so from a initialization perspective this is a
glorified nop.
Avoiding kvm_arch_init() also fixes a mostly benign bug as kvm_arch_exit()
doesn't properly unwind if a later stage of kvm_init() fails. While the
soon-to-be-deleted comment about compiling as a module being unsupported
is correct, kvm_arch_exit() can still be called by kvm_init() if any step
after the call to kvm_arch_init() succeeds.
Add a FIXME to call out that pKVM initialization isn't unwound if
kvm_init() fails, which is a pre-existing problem inherited from
kvm_arch_exit().
Making kvm_arch_init() a nop will also allow dropping kvm_arch_init() and
kvm_arch_exit() entirely once all other architectures follow suit.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/arm64/kvm/arm.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index e6f6fcfe6bcc..d3a4db1abf32 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -2195,7 +2195,7 @@ void kvm_arch_irq_bypass_start(struct irq_bypass_consumer *cons) /** * Initialize Hyp-mode and memory mappings on all CPUs. */ -int kvm_arch_init(void *opaque) +int kvm_arm_init(void) { int err; bool in_hyp_mode; @@ -2269,6 +2269,14 @@ int kvm_arch_init(void *opaque) kvm_info("Hyp mode initialized successfully\n"); } + /* + * FIXME: Do something reasonable if kvm_init() fails after pKVM + * hypervisor protection is finalized. + */ + err = kvm_init(NULL, sizeof(struct kvm_vcpu), 0, THIS_MODULE); + if (err) + goto out_subs; + return 0; out_subs: @@ -2281,10 +2289,15 @@ int kvm_arch_init(void *opaque) return err; } +int kvm_arch_init(void *opaque) +{ + return 0; +} + /* NOP: Compiling as a module not supported */ void kvm_arch_exit(void) { - kvm_unregister_perf_callbacks(); + } static int __init early_kvm_mode_cfg(char *arg) @@ -2325,10 +2338,4 @@ enum kvm_mode kvm_get_mode(void) return kvm_mode; } -static int arm_init(void) -{ - int rc = kvm_init(NULL, sizeof(struct kvm_vcpu), 0, THIS_MODULE); - return rc; -} - -module_init(arm_init); +module_init(kvm_arm_init);