From patchwork Wed Nov 30 23:09:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13060794 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F327CC4321E for ; Thu, 1 Dec 2022 00:04:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KDc2gddykjpXPZxBKZ9e3VB4e1tODVwlk7MtOymNfcA=; b=xTiYlT6RVdBsrm xqH48oyIGIeQW21i72/OTXXXrrI8UoPO4uIsE9fIEwCEJySQ1dJqURtxvym7eu+Ly3b+/GVAL41Xz szJ43FR2fXw8HMn0Ckz3gf2kkJHFnZimMdTiK69GSYt0e9wGi5a1UmcO9rJdMxwIDd0nQGEU6q+Zy rc8HPLNFp23jkxK72C01fBxAj1WcDzaQNIdQGt5ym2ztqjFssYwpyDsaGTUVLU8WLYm7DoAGbSoPi Q4qIBKO5osuW0VLR1d57tnbouCl65aL/2WIuk+G3Lg84BvBQmNR697WTx7GyBD9j5Fuw+BVbIz6ra ANtijZBdjhsElMEoLYUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0X3i-003TNx-Ev; Thu, 01 Dec 2022 00:04:10 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0Wbb-003Gqn-4z for linux-riscv@bombadil.infradead.org; Wed, 30 Nov 2022 23:35:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:Cc:To:From:Subject: Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To:Sender: Content-Transfer-Encoding:Content-ID:Content-Description; bh=eiSwfPmu4ewAiGcYbvYY+86df6I0KPgxP3gGecAMxPE=; b=JKAFSzurmpr29J5CtGIr1SR/Na BXuHQrDotzQGrYAmLpU0j5PS89vUqN/adeLMe1NpijtNTg9T596mluin1ZPxpJkMoqpnY9fDQSeLC Psc2a3uVx4muj0r8og1gtIWgyp9PMNCdRtrNzLCUQXb4n/EbMbnvOPf0vWJEhm+RowhffSFlSQDpY AT2Hfx9sEtXPlUoZuziFWqBwjL6TI35d15O/b8kXoYPtnKsSnZrsSxvoYTzUFAr5O6ZPxn91WqUxZ H3g35QH4OZHVPq5evuzqiPAhPV27aBGbWSYrjvbof03uOuEGB1mqctWzQNNqYQoFyMYe1KapSwu2D m+RaACnA==; Received: from mail-pj1-x104a.google.com ([2607:f8b0:4864:20::104a]) by casper.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0WDX-00FPt8-Kf for linux-riscv@lists.infradead.org; Wed, 30 Nov 2022 23:10:17 +0000 Received: by mail-pj1-x104a.google.com with SMTP id w2-20020a17090a8a0200b002119ea856edso3787311pjn.5 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=eiSwfPmu4ewAiGcYbvYY+86df6I0KPgxP3gGecAMxPE=; b=iL8L003XqB+GKgCwHArr5kcxs4MyewOQ/xo1XysK8lk71q/4iO5w3SKvia9KqD7amd nXu1/r0fblzdTNOJpq/EYl9gFk0lysyFVV/7oFccNNQgU1JhwDr1/0HsYHMNLSclslmA UAtezhSD+JCAni39XkYX4QGkvZksvWY0lR4tjm/jCfiuQLeieGvg5A3LN33ihkcJ66/D QbO+O4mX6xEZLgdpufHO4gE+50I1GNIH2gNitP+ZjnsiKLl2r5s0LRLVS15/Koi+mQZn TJODgWK9oIR1COz+tFiDAPrhXmMt5j7wHvbTN67IWmBvfAG9+GHxtj6LR7jSg7tvIMuj 4E5A== 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=eiSwfPmu4ewAiGcYbvYY+86df6I0KPgxP3gGecAMxPE=; b=b8m6ZB/ef7uh9blwf1433f3eSfV4TAlJCl0BnrUyacPgYQeB0YAs7/UeHg678GovzU IGUfkcBymLUZCKbIv0qAVxulh21qgULm3u/8leoOg4TOcoNQdqMD3yhst5/Odsp+A7OH WThBSl0dKMC8/QagfYbHETDw+B0hr0f/Uye7If0FpWHE3xaQKVpPx4L/CALPf3zBP+c3 BiraViz8RMFsM2j3Fl1Yqvr2JqI9HQZ+CtYUNVjPT0QFttUywhmjDpyRqvvc6Ray8jg8 kTc6Ll2QndDyOrePitYbNkQzqSNjHvfLtprHXV5E6DDEnX7C3z7OvLGMnODdyaAzyPaD EYcQ== X-Gm-Message-State: ANoB5pnUx7kxhZMQrQVRX33HgP4jY71lE0A2td4pKwU9IoakNEehr6ZD 5FXSi6jFGxMCF2qGwXi6IZqpv1m/IOs= X-Google-Smtp-Source: AA0mqf6KEmE4iPJ9U98BX162/oz5Lzb4cw+ziaGyrlJEvv/WGc/WSrrcrRcdtUijxIw8BMhf6X3VggubLl4= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:90a:ce05:b0:219:23ea:b314 with SMTP id f5-20020a17090ace0500b0021923eab314mr23130247pju.230.1669849806254; Wed, 30 Nov 2022 15:10:06 -0800 (PST) Date: Wed, 30 Nov 2022 23:09:01 +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-18-seanjc@google.com> Subject: [PATCH v2 17/50] KVM: arm64: Free hypervisor allocations if vector slot init 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_Mathieu-Da?= =?utf-8?q?ud=C3=A9?= " , Fabiano Rosas , Michael Ellerman , Kai Huang , Chao Gao , Thomas Gleixner X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221130_231015_705930_2D5C5ABA X-CRM114-Status: GOOD ( 10.15 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Teardown hypervisor mode if vector slot setup fails in order to avoid leaking any allocations done by init_hyp_mode(). Fixes: b881cdce77b4 ("KVM: arm64: Allocate hyp vectors statically") Signed-off-by: Sean Christopherson --- arch/arm64/kvm/arm.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 07f5cef5c33b..fa986ebb4793 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -2237,18 +2237,18 @@ int kvm_arch_init(void *opaque) err = kvm_init_vector_slots(); if (err) { kvm_err("Cannot initialise vector slots\n"); - goto out_err; - } - - err = init_subsystems(); - if (err) goto out_hyp; + } + + err = init_subsystems(); + if (err) + goto out_subs; if (!in_hyp_mode) { err = finalize_hyp_mode(); if (err) { kvm_err("Failed to finalize Hyp protection\n"); - goto out_hyp; + goto out_subs; } } @@ -2262,8 +2262,9 @@ int kvm_arch_init(void *opaque) return 0; -out_hyp: +out_subs: hyp_cpu_pm_exit(); +out_hyp: if (!in_hyp_mode) teardown_hyp_mode(); out_err: