Message ID | 20221102231911.3107438-6-seanjc@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp199097wru; Wed, 2 Nov 2022 16:20:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM77yp3Gg6iyiihmM5s04geFCfneKQpCn0eHTwqpL6h2DfrNfVycs9t/TZMPidENHw2BPV6O X-Received: by 2002:a63:ce02:0:b0:46f:38ad:e5b1 with SMTP id y2-20020a63ce02000000b0046f38ade5b1mr23993723pgf.75.1667431246308; Wed, 02 Nov 2022 16:20:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667431246; cv=none; d=google.com; s=arc-20160816; b=Skjcuo86B/QNqqJN8oBgG/wM9d1GawBlsdAHrmLmnhVkfEI3JaHUGXnp3ScUe4Bq/p 7JFZVnXLQf3kx1YUfUR53p6yXq0emB42FMm6t8E994Wuvcv13x+omMtDQrLWERLIJUsJ 6pWeKM99/yEN5WBrrNJDasfPOrh7yo7qCThKN6F6UT/hA//5ZS6etymIL7UMgTyFr5Bj RitIY07JOGIb7YDhrrlErOBrPVt2rBsddoJgQAmjUgE0pd6QJmBlYcjJi4nvXczWMmhy TOTIA9XRgHv5OJ2XLYlPhobiyWC2MQ4mn4RZQFZyv6yofN72y0iYzTsVBDBWpBiRyYh7 +y3w== 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=61+uc/Y9XgqKqIqJKklgZKwyXFi4EpAveqLf+gzND20=; b=dJX0MEJWmm36xvQ3AjZvIfsCQZno3MnJSmY9CSmRLGWz48Vet4zkFOQVUqI8L0fp9R NvnMia0RAtZz241PLPwqi+YCmf76Pco8/i1ptl8v48f2nn9p80otDeNubMeXCKh/oqLg Qds/rG2aW6WfrPL3PAhEc0JRlRF58I2CEyDv7pzyg9kJZePRVnw0OgX+TWGgpmLZA9it bJAJN65IoUFFDAVDq3fCsv3gr6ecWECsIlpHCEsIhY0xspOIMjpKmlVMVITWSaEy6eGN 451sazsdvLTJaMRbFHHq7dhk3KkC8mmq4T1dm1Yaj4WYQESZ5Y8+Nedf2y8vp6LowoMg HPsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Utw2bIoF; 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 oo11-20020a17090b1c8b00b0020d4dffd6e6si3730618pjb.99.2022.11.02.16.20.33; Wed, 02 Nov 2022 16:20:46 -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=Utw2bIoF; 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 S230336AbiKBXUN (ORCPT <rfc822;yves.mi.zy@gmail.com> + 99 others); Wed, 2 Nov 2022 19:20:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230320AbiKBXT2 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 2 Nov 2022 19:19:28 -0400 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 CEF5825F8 for <linux-kernel@vger.kernel.org>; Wed, 2 Nov 2022 16:19:23 -0700 (PDT) Received: by mail-pj1-x1049.google.com with SMTP id om10-20020a17090b3a8a00b002108b078ab1so2472083pjb.9 for <linux-kernel@vger.kernel.org>; Wed, 02 Nov 2022 16:19:23 -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:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=61+uc/Y9XgqKqIqJKklgZKwyXFi4EpAveqLf+gzND20=; b=Utw2bIoFpd0OsW8gcFI5XrC8r/opoeV6PzEujs3E4Mr9+St+h1iGz7I0t2dfS8UClh tAtUjqK55zt6/KkvBXOzqfYjfHXVvlGdNUDx6aXeRWpNBB/SzUU3M7O4hGxRvmfcP7Dv H7xUVWjzIm9fOWFawnQ+tUiBa9aTdqs3xjhRiHy7QmZH5iQmDFc0LC68bjVk8Tk76MUY okNb1d05tSvdlxWMqm8WJt1KJ94gRKBpU/aaJyEkAN3CmyDtunrNwjuXsVAB9MDK12T5 qP1tSiadBS2lzWdtmS7wbdVgSkTUTO1m/e38yDr5/ydciJMTwj/jwYNum8ez3aI14Ekv m1vw== 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=61+uc/Y9XgqKqIqJKklgZKwyXFi4EpAveqLf+gzND20=; b=tHImZWtoX3J9SPyXeGPegcRSBWytqBlYEzBGeZEJ+LlKXfqM06x8KHysvBonIKwgev tPYpt/Wa3Jc+LjihhKrxqbeRnDLYUKozYQHucKF3SvUhD7hNzzFxz+syHdFyIGf4t1as apVY47y5WmnS5y2p6qvLm8lZX+8H/zVjzX1AGGTHrG6RRh8gQMdeucxwUenaQ+1YS5Ri VU3rbh+qQy8/ThB2amL89wuMuhOJFZmm46R0EeL05nj/KDMz1xKRHKInQvwsC1nfRSBP fpVCRl3pykKqDkyzonWCYkmIvM67vHY+vOMIQ3QhufeL2Wj/j/6Bj98aANHkN4tSId8N 1xAg== X-Gm-Message-State: ACrzQf1Zd0THGbCbDatOv6rie1yliD9aAFVs7MA5r/1YX+yUV5G3ko3R xdasjJjqnyz2ODtYrrvV1M/6gK8Lf24= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:90b:38cd:b0:214:184f:4007 with SMTP id nn13-20020a17090b38cd00b00214184f4007mr9764899pjb.82.1667431162802; Wed, 02 Nov 2022 16:19:22 -0700 (PDT) Reply-To: Sean Christopherson <seanjc@google.com> Date: Wed, 2 Nov 2022 23:18:32 +0000 In-Reply-To: <20221102231911.3107438-1-seanjc@google.com> Mime-Version: 1.0 References: <20221102231911.3107438-1-seanjc@google.com> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog Message-ID: <20221102231911.3107438-6-seanjc@google.com> Subject: [PATCH 05/44] KVM: s390: Unwind kvm_arch_init() piece-by-piece() if a step fails 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> 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, Isaku Yamahata <isaku.yamahata@intel.com>, Fabiano Rosas <farosas@linux.ibm.com>, Michael Ellerman <mpe@ellerman.id.au>, Chao Gao <chao.gao@intel.com>, Thomas Gleixner <tglx@linutronix.de>, Yuan Yao <yuan.yao@intel.com> 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: <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?1748428386443887970?= X-GMAIL-MSGID: =?utf-8?q?1748428386443887970?= |
Series |
KVM: Rework kvm_init() and hardware enabling
|
|
Commit Message
Sean Christopherson
Nov. 2, 2022, 11:18 p.m. UTC
In preparation for folding kvm_arch_hardware_setup() into kvm_arch_init(),
unwind initialization one step at a time instead of simply calling
kvm_arch_exit(). Using kvm_arch_exit() regardless of which initialization
step failed relies on all affected state playing nice with being undone
even if said state wasn't first setup. That holds true for state that is
currently configured by kvm_arch_init(), but not for state that's handled
by kvm_arch_hardware_setup(), e.g. calling gmap_unregister_pte_notifier()
without first registering a notifier would result in list corruption due
to attempting to delete an entry that was never added to the list.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/s390/kvm/kvm-s390.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
Comments
On Wed, 2022-11-02 at 23:18 +0000, Sean Christopherson wrote: > In preparation for folding kvm_arch_hardware_setup() into > kvm_arch_init(), > unwind initialization one step at a time instead of simply calling > kvm_arch_exit(). Using kvm_arch_exit() regardless of which > initialization > step failed relies on all affected state playing nice with being > undone > even if said state wasn't first setup. That holds true for state > that is > currently configured by kvm_arch_init(), but not for state that's > handled > by kvm_arch_hardware_setup(), e.g. calling > gmap_unregister_pte_notifier() > without first registering a notifier would result in list corruption > due > to attempting to delete an entry that was never added to the list. > > Signed-off-by: Sean Christopherson <seanjc@google.com> > --- > arch/s390/kvm/kvm-s390.c | 21 ++++++++++++++------- > 1 file changed, 14 insertions(+), 7 deletions(-) Reviewed-by: Eric Farman <farman@linux.ibm.com>
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 45d4b8182b07..8395433a79b2 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -490,11 +490,11 @@ int kvm_arch_init(void *opaque) kvm_s390_dbf_uv = debug_register("kvm-uv", 32, 1, 7 * sizeof(long)); if (!kvm_s390_dbf_uv) - goto out; + goto err_kvm_uv; if (debug_register_view(kvm_s390_dbf, &debug_sprintf_view) || debug_register_view(kvm_s390_dbf_uv, &debug_sprintf_view)) - goto out; + goto err_debug_view; kvm_s390_cpu_feat_init(); @@ -502,25 +502,32 @@ int kvm_arch_init(void *opaque) rc = kvm_register_device_ops(&kvm_flic_ops, KVM_DEV_TYPE_FLIC); if (rc) { pr_err("A FLIC registration call failed with rc=%d\n", rc); - goto out; + goto err_flic; } if (IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM)) { rc = kvm_s390_pci_init(); if (rc) { pr_err("Unable to allocate AIFT for PCI\n"); - goto out; + goto err_pci; } } rc = kvm_s390_gib_init(GAL_ISC); if (rc) - goto out; + goto err_gib; return 0; -out: - kvm_arch_exit(); +err_gib: + if (IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM)) + kvm_s390_pci_exit(); +err_pci: +err_flic: +err_debug_view: + debug_unregister(kvm_s390_dbf_uv); +err_kvm_uv: + debug_unregister(kvm_s390_dbf); return rc; }