Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3124566rwb; Wed, 30 Nov 2022 15:58:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf7iX89E9yGqmprOnSeG3vhocS6rEwvR83LJEGGDmMB+2uX5NLwl73y8nupXyl4b9DIQTxX8 X-Received: by 2002:a17:906:12c2:b0:7bd:1606:2da1 with SMTP id l2-20020a17090612c200b007bd16062da1mr22967186ejb.33.1669852686833; Wed, 30 Nov 2022 15:58:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669852686; cv=none; d=google.com; s=arc-20160816; b=f6P0MWsIqq7EGt8JaEAx1NY6LDm2gUVDzbwXqLOoinq7q16B04x2MgXTWQzIb3KH4B OnsIF/vDP2xevYJMCQ6Lc893Cyfe39LlHMtLf6LRjbiRmr84pxM4YvDSZEcO6t2qwTFG yNB0bIxVCdSUOAZ3zR3O0r4UlCjTX/7I6wgUeHpKfq9g87c4DbznpIJ3x8cphwhpZI2a QdVwweZ61dWKrDT0E9IupXBlv+OJPJZIHERMqU2lyUigcUZDq6uNg1yG4Iv65oY2CbJR j9LVoCTx5fzdivy3SCGPhL+VV66SiEAleXDzDvdw35UOcE0lYW6J5vzMMpOo/ANPWpxX Nk6A== 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=ELQ4r/TqKHaBJHvAWCVxPtXKZjhdmN2xYeWWLtdN78s=; b=KRzsP652ZRtoLnmH2RLQ3iT8aUrVfQrFiEiWL/+aU5Uda+8X0geXhLQnFbJFTb+mZZ IDyXf0Sa4jN+uTlRwJ56xJN1uDwdcf06bIe61vPkTzwOcT7n2LyU1fi89Gl0aLb6I8Xw oy9n72GrbbsnoizzHg8NkXb5y8UQLN8GE/yqi3WicMtNJnaVX3yfP+eN/SWWZmiGQfL3 6IFdgupNdW8iloSyMi64gUaGl+REexNnk5xzlVt1HB3wLBRu90yPnNeT7yguPOtWPebn XN8Xe0TK4bpfZmp97cI0ThzrAgXwyNz8Cpam+vtn3pKa7yourHjQPC9mElFoypNMrwrC hvog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=rV6sXkwW; 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 dt5-20020a170907728500b007bf9de4fe93si2546502ejc.154.2022.11.30.15.57.47; Wed, 30 Nov 2022 15:58:06 -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=rV6sXkwW; 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 S229979AbiK3XLv (ORCPT + 83 others); Wed, 30 Nov 2022 18:11:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229841AbiK3XK7 (ORCPT ); Wed, 30 Nov 2022 18:10:59 -0500 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD75399F25 for ; Wed, 30 Nov 2022 15:10:08 -0800 (PST) Received: by mail-pf1-x44a.google.com with SMTP id bq9-20020a056a000e0900b00571802a2eaaso149099pfb.22 for ; Wed, 30 Nov 2022 15:10:08 -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=ELQ4r/TqKHaBJHvAWCVxPtXKZjhdmN2xYeWWLtdN78s=; b=rV6sXkwW0NobTm3rjPA4K5oJXg7Chbj9zLHGkDIEdGJ4GDvAf1gR/xdVUzmRVjaVxZ Lpv4mXcdPvHfacU07BhEHSV/clf7T6Wt4K9p7HTpl3MuGOSlPJopPlIOdMhwNJq55wJQ C2XphKPH8RVseXHYjMsaGq/j2Utscd+e1YQpyMJwrt0VKjAxdKimwtuQPugYzzhiHh00 1sder2j0DzOfxhA6vqd3HzFSqamEahbTJmdvrPEKWeFh0CbO4l9ispHgKo3f6y1MgB15 Il0zG/AUJb/AsRXvsLsQjRJk0smNChBO607PrkbuzuuP3tG+dumldlOL4wJ4R/wyXPyf wKBw== 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=ELQ4r/TqKHaBJHvAWCVxPtXKZjhdmN2xYeWWLtdN78s=; b=Y0wV1mQrfhbvWez3CaUuHJkDMGgaTodB1oSR8fWaCAtk6zfkdlM1Sv21yDXqqAaVBB utHganaAP8+fENCxdl3T8mngM6eqMQ51rzOaATdK+TD+8U+TP0f6E1gDRn8Ljfrhsjbb D0zna3dxTlpibW6m+NttMNns0HT31MXEdGiiSHvkK2Pxq0M3OyxOQQMpTz0HZGWi5vKz 0fibP/yMp4mGS0+QxKpJEzK84+yHaa1ZBstN2UbVy1c9BuP02M4z1k5PdoVy/gzMwIIP tOa5GtwY19VWdVTNm/W7G9DKwgAwqzNvFSPI83zb4LqzVoaLl7dtmnIKkwcG0sjrO7J6 G7bg== X-Gm-Message-State: ANoB5pnMl6mTb7fOY6ZzD6IyYZNlCMxEw5Z8Nu/O3Aeptx3WEnqHxPJO 64w3R7/vPNsU7vew+cwbnQw9af2eOp8= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:90b:f89:b0:219:5b3b:2b9f with SMTP id ft9-20020a17090b0f8900b002195b3b2b9fmr848420pjb.2.1669849807964; Wed, 30 Nov 2022 15:10:07 -0800 (PST) Reply-To: Sean Christopherson Date: Wed, 30 Nov 2022 23:09:02 +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-19-seanjc@google.com> Subject: [PATCH v2 18/50] KVM: arm64: Unregister perf callbacks if hypervisor finalization fails From: Sean Christopherson To: Paolo Bonzini , Marc Zyngier , Huacai Chen , Aleksandar Markovic , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Matthew Rosato , Eric Farman , Sean Christopherson , Vitaly Kuznetsov , David Woodhouse , Paul Durrant Cc: James Morse , Alexandru Elisei , Suzuki K Poulose , Oliver Upton , Atish Patra , David Hildenbrand , 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 , Cornelia Huck , Isaku Yamahata , "=?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?=" , Fabiano Rosas , Michael Ellerman , Kai Huang , Chao Gao , Thomas Gleixner 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=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 Undo everything done by init_subsystems() if a later initialization step fails, i.e. unregister perf callbacks in addition to unregistering the power management notifier. Fixes: bfa79a805454 ("KVM: arm64: Elevate hypervisor mappings creation at EL2") Signed-off-by: Sean Christopherson --- arch/arm64/kvm/arm.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index fa986ebb4793..e6f6fcfe6bcc 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -1839,12 +1839,21 @@ static int init_subsystems(void) kvm_register_perf_callbacks(NULL); out: + if (err) + hyp_cpu_pm_exit(); + if (err || !is_protected_kvm_enabled()) on_each_cpu(_kvm_arch_hardware_disable, NULL, 1); return err; } +static void teardown_subsystems(void) +{ + kvm_unregister_perf_callbacks(); + hyp_cpu_pm_exit(); +} + static void teardown_hyp_mode(void) { int cpu; @@ -2242,7 +2251,7 @@ int kvm_arch_init(void *opaque) err = init_subsystems(); if (err) - goto out_subs; + goto out_hyp; if (!in_hyp_mode) { err = finalize_hyp_mode(); @@ -2263,7 +2272,7 @@ int kvm_arch_init(void *opaque) return 0; out_subs: - hyp_cpu_pm_exit(); + teardown_subsystems(); out_hyp: if (!in_hyp_mode) teardown_hyp_mode(); -- 2.38.1.584.g0f3c55d4c2-goog