From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sean Christopherson Date: Thu, 3 Nov 2022 15:29:58 +0000 Subject: [PATCH 17/44] KVM: arm64: Do arm/arch initialiation without bouncing through kvm_init() In-Reply-To: References: <20221102231911.3107438-1-seanjc@google.com> <20221102231911.3107438-18-seanjc@google.com> Message-ID: List-Id: To: kvm-riscv@lists.infradead.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Thu, Nov 03, 2022, Philippe Mathieu-Daud? wrote: > Hi Sean, > > On 3/11/22 00:18, Sean Christopherson wrote: > > Move 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(), i.e. this is a glorified nop. > > > > Making kvm_arch_init() a nop will allow dropping it entirely once all > > other architectures follow suit. > > > > No functional change intended. > > > > Signed-off-by: Sean Christopherson > > --- > > arch/arm64/kvm/arm.c | 25 ++++++++++++++++--------- > > 1 file changed, 16 insertions(+), 9 deletions(-) > > > /* NOP: Compiling as a module not supported */ > > void kvm_arch_exit(void) > > { > > - kvm_unregister_perf_callbacks(); > > Doesn't this belong to the previous patch? No, but the above changelog is a lie, there is very much a functional change here. The goal of the previous patch is to fix the error paths in kvm_arch_init(), a.k.a. kvm_arm_init(). After fixing kvm_arch_init(), there are still bugs in the sequence as a whole because kvm_arch_exit() doesn't unwind other state, e.g. kvm_arch_exit() should really look something like: void kvm_arch_exit(void) { teardown_subsystems(); if (!is_kernel_in_hyp_mode()) teardown_hyp_mode(); kvm_arm_vmid_alloc_free(); if (is_protected_kvm_enabled()) ??? } Becuase although the comment "NOP: Compiling as a module not supported" is correct about KVM ARM always having to be built into the kernel, kvm_arch_exit() can still be called if a later stage of kvm_init() fails. But rather than add a patch to fix kvm_arch_exit(), I chose to fix the bug by moving code out of kvm_arch_init() so that the unwind sequence established in the previous patch could be reused. Except I managed to forget those details when writing the changelog. The changelog should instead be: KVM: arm64: Do arm/arch initialization without bouncing through kvm_init() 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. From mboxrd@z Thu Jan 1 00:00:00 1970 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 mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97C81C43219 for ; Thu, 3 Nov 2022 15:30:07 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id EAFCD4B5F4; Thu, 3 Nov 2022 11:30:06 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@google.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Fqqrl+Z42J4y; Thu, 3 Nov 2022 11:30:05 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id C18E34B62D; Thu, 3 Nov 2022 11:30:05 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 5C7B84B269 for ; Thu, 3 Nov 2022 11:30:04 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RZUd7YNdRVi6 for ; Thu, 3 Nov 2022 11:30:03 -0400 (EDT) Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 38AE84B210 for ; Thu, 3 Nov 2022 11:30:03 -0400 (EDT) Received: by mail-pf1-f179.google.com with SMTP id b29so1907548pfp.13 for ; Thu, 03 Nov 2022 08:30:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=UyUe+HbRzSrTdJquQCMiaXWC2coZG28I37xguDaJaYg=; b=JxP3em5mMEo8M/seyYjwqQClKWueZhrkefM7iopEbtJ9U0ARhXsBBlBaHvB0YZ+mCq 7I2lDIbzgsTnUJXXFFd+Mf2MRkvMQ3d/mi120+0k+co+feliF2fGnlDGLipP3oo4jHIs yhCQnzB0LNdLsoCiyP2ThdGCDug/wevVBzx4ZCIoRVJzM62ULFanZrMyKnrfoLhgGw7L LE3NJVvLI80qGdb5QUdNBUYtcEfD6sTxNonp/rLGuh5no7R8ACiBwreWQkoFJnyoE1Nq joZ/uzznkWHqO7mwwbSR52gm1kYa+vf+hliw2Y9f1o05+cN6N5swUWJ7vJszMr5BEKoW HTcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UyUe+HbRzSrTdJquQCMiaXWC2coZG28I37xguDaJaYg=; b=WDrfsjs9muI1VY9sqiEag9Nj4uRF3UZy83DXSocnfA6E6H0dnEsljabidOI7FqkgZr bVhSYVB/7husId6rKtNnKS2vG+NmkYF66F7B0JHFCpM3UNpgbdasOFg170R7iFADLmu0 gsbbVeHYxctrBIYq2u4ZcH7ZA2LqH1/YnAbQZQKhPxkt8BaLXCSwAbRS9eT+m5oMgV4/ O1620m4YL5gXrl+um3oT8szb134bK2+gJM8F9tVBf08iO9cenZNvEE5gWjyC1Z4zSw4A sOSZFWDA0eowNGO+WlfvfSwtfe67KuoEbJTofhUBEIr7RdWlnkGRTu45lc4u0juFyirF el+A== X-Gm-Message-State: ACrzQf3eprpGtKAxG4IF9PqDbnsZhGJWW7+A04JSV3oGErqIIHiqB0lQ 7zOqF1pOGB8SEVzTupAI8j4HbQ== X-Google-Smtp-Source: AMsMyM6by5WQXi0G4lBZGaavWsGrxKC8DeWyAUbAtvZsM8BboB9ucyemIyMYLKoI4FadI1MlyxYOPw== X-Received: by 2002:a05:6a00:1996:b0:56d:a845:5789 with SMTP id d22-20020a056a00199600b0056da8455789mr17697890pfl.59.1667489402026; Thu, 03 Nov 2022 08:30:02 -0700 (PDT) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id f3-20020a170902f38300b0017a018221e2sm835452ple.70.2022.11.03.08.30.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 08:30:01 -0700 (PDT) Date: Thu, 3 Nov 2022 15:29:58 +0000 From: Sean Christopherson To: Philippe =?iso-8859-1?Q?Mathieu-Daud=E9?= Subject: Re: [PATCH 17/44] KVM: arm64: Do arm/arch initialiation without bouncing through kvm_init() Message-ID: References: <20221102231911.3107438-1-seanjc@google.com> <20221102231911.3107438-18-seanjc@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Cc: Matthew Rosato , David Hildenbrand , Yuan Yao , Paul Walmsley , linux-kernel@vger.kernel.org, Michael Ellerman , linux-riscv@lists.infradead.org, Claudio Imbrenda , kvmarm@lists.cs.columbia.edu, linux-s390@vger.kernel.org, Janosch Frank , Marc Zyngier , Huacai Chen , Aleksandar Markovic , Christian Borntraeger , Chao Gao , Eric Farman , Albert Ou , kvm@vger.kernel.org, Atish Patra , kvmarm@lists.linux.dev, Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Isaku Yamahata , Fabiano Rosas , linux-mips@vger.kernel.org, Palmer Dabbelt , kvm-riscv@lists.infradead.org, Paolo Bonzini , Vitaly Kuznetsov , linuxppc-dev@lists.ozlabs.org X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On Thu, Nov 03, 2022, Philippe Mathieu-Daud=E9 wrote: > Hi Sean, > = > On 3/11/22 00:18, Sean Christopherson wrote: > > Move 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 acti= on > > performed by kvm_init(), i.e. this is a glorified nop. > > = > > Making kvm_arch_init() a nop will allow dropping it entirely once all > > other architectures follow suit. > > = > > No functional change intended. > > = > > Signed-off-by: Sean Christopherson > > --- > > arch/arm64/kvm/arm.c | 25 ++++++++++++++++--------- > > 1 file changed, 16 insertions(+), 9 deletions(-) > = > > /* NOP: Compiling as a module not supported */ > > void kvm_arch_exit(void) > > { > > - kvm_unregister_perf_callbacks(); > = > Doesn't this belong to the previous patch? No, but the above changelog is a lie, there is very much a functional chang= e here. The goal of the previous patch is to fix the error paths in kvm_arch_init()= , a.k.a. kvm_arm_init(). After fixing kvm_arch_init(), there are still bugs in the = sequence as a whole because kvm_arch_exit() doesn't unwind other state, e.g. kvm_arc= h_exit() should really look something like: void kvm_arch_exit(void) { teardown_subsystems(); if (!is_kernel_in_hyp_mode()) teardown_hyp_mode(); kvm_arm_vmid_alloc_free(); if (is_protected_kvm_enabled()) ??? = } Becuase although the comment "NOP: Compiling as a module not supported" is = correct about KVM ARM always having to be built into the kernel, kvm_arch_exit() ca= n still be called if a later stage of kvm_init() fails. But rather than add a patch to fix kvm_arch_exit(), I chose to fix the bug = by moving code out of kvm_arch_init() so that the unwind sequence established = in the previous patch could be reused. Except I managed to forget those details when writing the changelog. The c= hangelog should instead be: KVM: arm64: Do arm/arch initialization without bouncing through kvm_init() = 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. _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CDB167492 for ; Thu, 3 Nov 2022 15:30:02 +0000 (UTC) Received: by mail-pf1-f177.google.com with SMTP id g62so1920012pfb.10 for ; Thu, 03 Nov 2022 08:30:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=UyUe+HbRzSrTdJquQCMiaXWC2coZG28I37xguDaJaYg=; b=JxP3em5mMEo8M/seyYjwqQClKWueZhrkefM7iopEbtJ9U0ARhXsBBlBaHvB0YZ+mCq 7I2lDIbzgsTnUJXXFFd+Mf2MRkvMQ3d/mi120+0k+co+feliF2fGnlDGLipP3oo4jHIs yhCQnzB0LNdLsoCiyP2ThdGCDug/wevVBzx4ZCIoRVJzM62ULFanZrMyKnrfoLhgGw7L LE3NJVvLI80qGdb5QUdNBUYtcEfD6sTxNonp/rLGuh5no7R8ACiBwreWQkoFJnyoE1Nq joZ/uzznkWHqO7mwwbSR52gm1kYa+vf+hliw2Y9f1o05+cN6N5swUWJ7vJszMr5BEKoW HTcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UyUe+HbRzSrTdJquQCMiaXWC2coZG28I37xguDaJaYg=; b=6YGJTGgoCOOjV0D2ckyjUzZnwBF0nJJFhEn9QzTuIr2XXXTmtng8uUk3uWenc4OFiW QsUNJf0G8Q/uH4PxiY6FLmFs65lyCsFS4wQHHrOmJqDvTtRcnFZonJRND8GNVtpBSfgP b1KDdedgq0QrAHZO1iQcmMW43qmAA4NAWStrbOVLSuog5L+khqiEYCZlyW6l85jwe0i+ hl/R44U6CYY7sGOazRrFoKFfzgYS4QiT5zvtmCYkTPGsSFyTzNF58NoR6px5IfMP6AHM 81VCwmRpnRd+7oSw13OlrYpPm32tNFfIj87TWR9ZS/iDLQAvlzTz/xCV+7RCO+hWcrVP 2qVA== X-Gm-Message-State: ACrzQf0o755SMKWs4RysAnK4d4KqxNsO16fpJ1eGdvnb+93UBL1VqnsI 6Rs9i55eEajnK313bq8ho0hndw== X-Google-Smtp-Source: AMsMyM6by5WQXi0G4lBZGaavWsGrxKC8DeWyAUbAtvZsM8BboB9ucyemIyMYLKoI4FadI1MlyxYOPw== X-Received: by 2002:a05:6a00:1996:b0:56d:a845:5789 with SMTP id d22-20020a056a00199600b0056da8455789mr17697890pfl.59.1667489402026; Thu, 03 Nov 2022 08:30:02 -0700 (PDT) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id f3-20020a170902f38300b0017a018221e2sm835452ple.70.2022.11.03.08.30.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 08:30:01 -0700 (PDT) Date: Thu, 3 Nov 2022 15:29:58 +0000 From: Sean Christopherson To: Philippe =?iso-8859-1?Q?Mathieu-Daud=E9?= Cc: 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 , Vitaly Kuznetsov , 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, Isaku Yamahata , Fabiano Rosas , Michael Ellerman , Chao Gao , Thomas Gleixner , Yuan Yao Subject: Re: [PATCH 17/44] KVM: arm64: Do arm/arch initialiation without bouncing through kvm_init() Message-ID: References: <20221102231911.3107438-1-seanjc@google.com> <20221102231911.3107438-18-seanjc@google.com> Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Message-ID: <20221103152958.9np9OIStbdfycz1h6R7xJOXl4fY-AZRDpXckMpIPDnE@z> On Thu, Nov 03, 2022, Philippe Mathieu-Daudé wrote: > Hi Sean, > > On 3/11/22 00:18, Sean Christopherson wrote: > > Move 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(), i.e. this is a glorified nop. > > > > Making kvm_arch_init() a nop will allow dropping it entirely once all > > other architectures follow suit. > > > > No functional change intended. > > > > Signed-off-by: Sean Christopherson > > --- > > arch/arm64/kvm/arm.c | 25 ++++++++++++++++--------- > > 1 file changed, 16 insertions(+), 9 deletions(-) > > > /* NOP: Compiling as a module not supported */ > > void kvm_arch_exit(void) > > { > > - kvm_unregister_perf_callbacks(); > > Doesn't this belong to the previous patch? No, but the above changelog is a lie, there is very much a functional change here. The goal of the previous patch is to fix the error paths in kvm_arch_init(), a.k.a. kvm_arm_init(). After fixing kvm_arch_init(), there are still bugs in the sequence as a whole because kvm_arch_exit() doesn't unwind other state, e.g. kvm_arch_exit() should really look something like: void kvm_arch_exit(void) { teardown_subsystems(); if (!is_kernel_in_hyp_mode()) teardown_hyp_mode(); kvm_arm_vmid_alloc_free(); if (is_protected_kvm_enabled()) ??? } Becuase although the comment "NOP: Compiling as a module not supported" is correct about KVM ARM always having to be built into the kernel, kvm_arch_exit() can still be called if a later stage of kvm_init() fails. But rather than add a patch to fix kvm_arch_exit(), I chose to fix the bug by moving code out of kvm_arch_init() so that the unwind sequence established in the previous patch could be reused. Except I managed to forget those details when writing the changelog. The changelog should instead be: KVM: arm64: Do arm/arch initialization without bouncing through kvm_init() 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. From mboxrd@z Thu Jan 1 00:00:00 1970 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 3346EC433FE for ; Thu, 3 Nov 2022 15:44:24 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hfHRyQxepdwIzZJceU4IQfEeGl4NnLKEFhAy93g9M4U=; b=WLOvqs4pJB8ygw vCI0B+UT2BEtzWexBVerpo/Rsd51kh9wzrA6YIY99Au1PgBMvONOEIFrynR0w6Yp2MvhvZwzM9CzI C00gk2zHfTMFP8p82xtYa7TIWyWNTBcx49s5PK8Sll2MF3kKNWu3YnLkgl1Km/QP8tc+IXYsCIcD+ 33nHYhOvlEhfnmuA4znrx5j0fEeGV/Lw57pMn/upIDyM5T/cIKQFy0XPeWY59pVZIEXSBQwLR7FGu br2Xzn0oH7DianFsiLuj9lxuDDNjHrXF/sJeV5MgzPCcrok3VEd+Mo4kn8zwxm0F0fhVVjxAZVwgO vjQ0exwI35guRvA3lUdg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqcO5-000TxC-Bu; Thu, 03 Nov 2022 15:44:13 +0000 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqcAR-000Nsy-Sh for linux-riscv@lists.infradead.org; Thu, 03 Nov 2022 15:30:09 +0000 Received: by mail-pg1-x532.google.com with SMTP id s196so1972592pgs.3 for ; Thu, 03 Nov 2022 08:30:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=UyUe+HbRzSrTdJquQCMiaXWC2coZG28I37xguDaJaYg=; b=JxP3em5mMEo8M/seyYjwqQClKWueZhrkefM7iopEbtJ9U0ARhXsBBlBaHvB0YZ+mCq 7I2lDIbzgsTnUJXXFFd+Mf2MRkvMQ3d/mi120+0k+co+feliF2fGnlDGLipP3oo4jHIs yhCQnzB0LNdLsoCiyP2ThdGCDug/wevVBzx4ZCIoRVJzM62ULFanZrMyKnrfoLhgGw7L LE3NJVvLI80qGdb5QUdNBUYtcEfD6sTxNonp/rLGuh5no7R8ACiBwreWQkoFJnyoE1Nq joZ/uzznkWHqO7mwwbSR52gm1kYa+vf+hliw2Y9f1o05+cN6N5swUWJ7vJszMr5BEKoW HTcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UyUe+HbRzSrTdJquQCMiaXWC2coZG28I37xguDaJaYg=; b=OzXihcHC1xl6wBycmRCV9aObJi5G0xoXVnW7prn1OWrv2KTxVqq5vkYXFMCR2Ra76i b/ccfLuWj3wbo/CyBgLO/+9T4+sn4Y06SnC0sO14AvIptSZ8miseKtdqjPdetEaSejtC q77PzRQ8FRjKsX/11Vvp1Q22ypKQ4rtZxSbBHr9HK7SdV9ijrwr5M8mXrYof6UbFnSg0 lED9pgDIG181Qsyh9JNTy0r/6e2ADxHSAtpU9M/mXrZZzgEkJXZxzH706IJcH0HLMPg/ 63eHve4u7V3JS5RaC2QxyY24i1y7ecaSeZbmb18OPlCqYHk8owghzbt7lk0IVrfqdJiB EXbQ== X-Gm-Message-State: ACrzQf2hOYDkIiHSH2jxN4vS2wIckMBwhFxv1tow3pnRKXftO0xmNn9D VGShRyiWYgGn/rMjoKWdSiANgQ== X-Google-Smtp-Source: AMsMyM6by5WQXi0G4lBZGaavWsGrxKC8DeWyAUbAtvZsM8BboB9ucyemIyMYLKoI4FadI1MlyxYOPw== X-Received: by 2002:a05:6a00:1996:b0:56d:a845:5789 with SMTP id d22-20020a056a00199600b0056da8455789mr17697890pfl.59.1667489402026; Thu, 03 Nov 2022 08:30:02 -0700 (PDT) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id f3-20020a170902f38300b0017a018221e2sm835452ple.70.2022.11.03.08.30.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 08:30:01 -0700 (PDT) Date: Thu, 3 Nov 2022 15:29:58 +0000 From: Sean Christopherson To: Philippe =?iso-8859-1?Q?Mathieu-Daud=E9?= Cc: 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 , Vitaly Kuznetsov , 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, Isaku Yamahata , Fabiano Rosas , Michael Ellerman , Chao Gao , Thomas Gleixner , Yuan Yao Subject: Re: [PATCH 17/44] KVM: arm64: Do arm/arch initialiation without bouncing through kvm_init() Message-ID: References: <20221102231911.3107438-1-seanjc@google.com> <20221102231911.3107438-18-seanjc@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221103_083007_981255_7A176D7D X-CRM114-Status: GOOD ( 21.37 ) 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: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Thu, Nov 03, 2022, Philippe Mathieu-Daud=E9 wrote: > Hi Sean, > = > On 3/11/22 00:18, Sean Christopherson wrote: > > Move 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 acti= on > > performed by kvm_init(), i.e. this is a glorified nop. > > = > > Making kvm_arch_init() a nop will allow dropping it entirely once all > > other architectures follow suit. > > = > > No functional change intended. > > = > > Signed-off-by: Sean Christopherson > > --- > > arch/arm64/kvm/arm.c | 25 ++++++++++++++++--------- > > 1 file changed, 16 insertions(+), 9 deletions(-) > = > > /* NOP: Compiling as a module not supported */ > > void kvm_arch_exit(void) > > { > > - kvm_unregister_perf_callbacks(); > = > Doesn't this belong to the previous patch? No, but the above changelog is a lie, there is very much a functional chang= e here. The goal of the previous patch is to fix the error paths in kvm_arch_init()= , a.k.a. kvm_arm_init(). After fixing kvm_arch_init(), there are still bugs in the = sequence as a whole because kvm_arch_exit() doesn't unwind other state, e.g. kvm_arc= h_exit() should really look something like: void kvm_arch_exit(void) { teardown_subsystems(); if (!is_kernel_in_hyp_mode()) teardown_hyp_mode(); kvm_arm_vmid_alloc_free(); if (is_protected_kvm_enabled()) ??? = } Becuase although the comment "NOP: Compiling as a module not supported" is = correct about KVM ARM always having to be built into the kernel, kvm_arch_exit() ca= n still be called if a later stage of kvm_init() fails. But rather than add a patch to fix kvm_arch_exit(), I chose to fix the bug = by moving code out of kvm_arch_init() so that the unwind sequence established = in the previous patch could be reused. Except I managed to forget those details when writing the changelog. The c= hangelog should instead be: KVM: arm64: Do arm/arch initialization without bouncing through kvm_init() = 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. _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 B5116C4332F for ; Thu, 3 Nov 2022 15:30:59 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4N374y1jlrz3cR7 for ; Fri, 4 Nov 2022 02:30:58 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=JxP3em5m; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=google.com (client-ip=2607:f8b0:4864:20::529; helo=mail-pg1-x529.google.com; envelope-from=seanjc@google.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=JxP3em5m; dkim-atps=neutral Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4N373x3y1qz2x9v for ; Fri, 4 Nov 2022 02:30:05 +1100 (AEDT) Received: by mail-pg1-x529.google.com with SMTP id b62so2003572pgc.0 for ; Thu, 03 Nov 2022 08:30:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=UyUe+HbRzSrTdJquQCMiaXWC2coZG28I37xguDaJaYg=; b=JxP3em5mMEo8M/seyYjwqQClKWueZhrkefM7iopEbtJ9U0ARhXsBBlBaHvB0YZ+mCq 7I2lDIbzgsTnUJXXFFd+Mf2MRkvMQ3d/mi120+0k+co+feliF2fGnlDGLipP3oo4jHIs yhCQnzB0LNdLsoCiyP2ThdGCDug/wevVBzx4ZCIoRVJzM62ULFanZrMyKnrfoLhgGw7L LE3NJVvLI80qGdb5QUdNBUYtcEfD6sTxNonp/rLGuh5no7R8ACiBwreWQkoFJnyoE1Nq joZ/uzznkWHqO7mwwbSR52gm1kYa+vf+hliw2Y9f1o05+cN6N5swUWJ7vJszMr5BEKoW HTcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UyUe+HbRzSrTdJquQCMiaXWC2coZG28I37xguDaJaYg=; b=ytsWfWJVQiLq0mUEP57vqFWSncXVilHQWDFfJtRGuZwnZ7YFwOjlhXkr5f8+tJFWlv VhrY5kmMxDh++wbI07XYvTpFB8c8CGpeEcVKIxHV38XXB+wnbfjA4PCp2p4HKsMpy7x1 iIpgr3LebaUiMzkzYYkB2YOUqe35wnS6ClNu0QBxDwuONECaEWiDRO4KunsAYnYCd/3p cPu7X1FqQAeq+gzgGuZFf4E5eaYTO4/7XLZlIw2uYIs9wghgrG90ovE05vIWK2AaFZHm cyRkWwvb1qN8w5r5cP0DpHrsG6XDyc7luKyx9b8+tSdIFIzxFUGppOzStBWLTdHmB95d XJEQ== X-Gm-Message-State: ACrzQf20A0/O+WJABQUBCbTJuJW2SQaMwanyR8zIO6kPO+GFs5z+bghn Q+EQCJJZKXpu2vsAE1MUS6/2bQ== X-Google-Smtp-Source: AMsMyM6by5WQXi0G4lBZGaavWsGrxKC8DeWyAUbAtvZsM8BboB9ucyemIyMYLKoI4FadI1MlyxYOPw== X-Received: by 2002:a05:6a00:1996:b0:56d:a845:5789 with SMTP id d22-20020a056a00199600b0056da8455789mr17697890pfl.59.1667489402026; Thu, 03 Nov 2022 08:30:02 -0700 (PDT) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id f3-20020a170902f38300b0017a018221e2sm835452ple.70.2022.11.03.08.30.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 08:30:01 -0700 (PDT) Date: Thu, 3 Nov 2022 15:29:58 +0000 From: Sean Christopherson To: Philippe =?iso-8859-1?Q?Mathieu-Daud=E9?= Subject: Re: [PATCH 17/44] KVM: arm64: Do arm/arch initialiation without bouncing through kvm_init() Message-ID: References: <20221102231911.3107438-1-seanjc@google.com> <20221102231911.3107438-18-seanjc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Matthew Rosato , David Hildenbrand , Yuan Yao , Paul Walmsley , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Claudio Imbrenda , kvmarm@lists.cs.columbia.edu, linux-s390@vger.kernel.org, Janosch Frank , Marc Zyngier , Huacai Chen , Aleksandar Markovic , James Morse , Christian Borntraeger , Chao Gao , Eric Farman , Albert Ou , Suzuki K Poulose , kvm@vger.kernel.org, Atish Patra , kvmarm@lists.linux.dev, Thomas Gleixner , Alexandru Elisei , linux-arm-kernel@lists.infradead.org, Isaku Yamahata , Fabiano Rosas , linux-mips@vger.kernel.org, Oliver Upton , Palmer Dabbelt , kvm-riscv@lists.infradead.org, Anup Patel , Paolo Bonzini , Vitaly Kuznetsov , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Thu, Nov 03, 2022, Philippe Mathieu-Daudé wrote: > Hi Sean, > > On 3/11/22 00:18, Sean Christopherson wrote: > > Move 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(), i.e. this is a glorified nop. > > > > Making kvm_arch_init() a nop will allow dropping it entirely once all > > other architectures follow suit. > > > > No functional change intended. > > > > Signed-off-by: Sean Christopherson > > --- > > arch/arm64/kvm/arm.c | 25 ++++++++++++++++--------- > > 1 file changed, 16 insertions(+), 9 deletions(-) > > > /* NOP: Compiling as a module not supported */ > > void kvm_arch_exit(void) > > { > > - kvm_unregister_perf_callbacks(); > > Doesn't this belong to the previous patch? No, but the above changelog is a lie, there is very much a functional change here. The goal of the previous patch is to fix the error paths in kvm_arch_init(), a.k.a. kvm_arm_init(). After fixing kvm_arch_init(), there are still bugs in the sequence as a whole because kvm_arch_exit() doesn't unwind other state, e.g. kvm_arch_exit() should really look something like: void kvm_arch_exit(void) { teardown_subsystems(); if (!is_kernel_in_hyp_mode()) teardown_hyp_mode(); kvm_arm_vmid_alloc_free(); if (is_protected_kvm_enabled()) ??? } Becuase although the comment "NOP: Compiling as a module not supported" is correct about KVM ARM always having to be built into the kernel, kvm_arch_exit() can still be called if a later stage of kvm_init() fails. But rather than add a patch to fix kvm_arch_exit(), I chose to fix the bug by moving code out of kvm_arch_init() so that the unwind sequence established in the previous patch could be reused. Except I managed to forget those details when writing the changelog. The changelog should instead be: KVM: arm64: Do arm/arch initialization without bouncing through kvm_init() 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. From mboxrd@z Thu Jan 1 00:00:00 1970 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 D572FC433FE for ; Thu, 3 Nov 2022 15:45:50 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6RHExxohc63reHes7jemfwjXeUA1MBoOSrRI8mpzMis=; b=3AZkD6FzGdoYnQ 5VIuyI4na1URUwcWKGuiRLE/ph40QoXXbZL2DA662t6mAo6TpseL8iTNuMBlwalFeBYFw5MMX4dbn orijCDAoTyI9s88eo83NKlsVcJUWl+Qbl8CXZEG0ln869rHYig3qJrLmi0w2me2cUukqG1t/5uebk zcXivUbWfjD5+YgCpI9Z+xYJYHlnaIZsRd/jd+7nw8s1fV2GapjrzKK2ytqE36IryXRcNWVv9Edj0 Vaq3iXgK2Qqa6ZYxnes2FCOSB2YMg4LnpVtbJejppGveCgn5Qckw/S9j4dPdoPXR4M5KmCbQARaAg fsEqF/W5EaUxTJT1GnJw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqcOG-000U1l-Oy; Thu, 03 Nov 2022 15:44:25 +0000 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqcAT-000Nsv-L3 for linux-arm-kernel@lists.infradead.org; Thu, 03 Nov 2022 15:30:11 +0000 Received: by mail-pg1-x529.google.com with SMTP id q71so1956932pgq.8 for ; Thu, 03 Nov 2022 08:30:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=UyUe+HbRzSrTdJquQCMiaXWC2coZG28I37xguDaJaYg=; b=JxP3em5mMEo8M/seyYjwqQClKWueZhrkefM7iopEbtJ9U0ARhXsBBlBaHvB0YZ+mCq 7I2lDIbzgsTnUJXXFFd+Mf2MRkvMQ3d/mi120+0k+co+feliF2fGnlDGLipP3oo4jHIs yhCQnzB0LNdLsoCiyP2ThdGCDug/wevVBzx4ZCIoRVJzM62ULFanZrMyKnrfoLhgGw7L LE3NJVvLI80qGdb5QUdNBUYtcEfD6sTxNonp/rLGuh5no7R8ACiBwreWQkoFJnyoE1Nq joZ/uzznkWHqO7mwwbSR52gm1kYa+vf+hliw2Y9f1o05+cN6N5swUWJ7vJszMr5BEKoW HTcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UyUe+HbRzSrTdJquQCMiaXWC2coZG28I37xguDaJaYg=; b=Kl/dxngkWoQODDH2jsQtgnBfW7hOlj+XZe6/LXDM62+n1VGjsAEzJ7aEQ1QK1L0YVr WLy+etKT2EFDOAdORkq0l1Il4fHS9i22C2RASl4rnQQDKByGD6q786mEwQA0FYz+QNAp 8rZSctnUa1z28QskGKSvvPPfpeN/VzEvM1dqSNj+juJqM8TIJp/Yim/ApbZsK/c4kzb4 rafcaLQTKjNFNjOl066Rbi3lSYbcy5rdk+yowwLXyXB6Y1lQ0DFRjI5nIMhC1FJ919Ja ZqYwblOSuPmOP8g3HtawhZHWbxWwyqEA9rQZ9FRiHYkBY0pF6Zqbfx9rLAP8pf/HOcGL sRVA== X-Gm-Message-State: ACrzQf2lo6Nb8YGN0ps9aqEGWUFEgBQ1tskyyqMM5ggPYAChLvITX5J3 gZEzAz/b4EGSAdY7snbH9GSDqQ== X-Google-Smtp-Source: AMsMyM6by5WQXi0G4lBZGaavWsGrxKC8DeWyAUbAtvZsM8BboB9ucyemIyMYLKoI4FadI1MlyxYOPw== X-Received: by 2002:a05:6a00:1996:b0:56d:a845:5789 with SMTP id d22-20020a056a00199600b0056da8455789mr17697890pfl.59.1667489402026; Thu, 03 Nov 2022 08:30:02 -0700 (PDT) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id f3-20020a170902f38300b0017a018221e2sm835452ple.70.2022.11.03.08.30.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 08:30:01 -0700 (PDT) Date: Thu, 3 Nov 2022 15:29:58 +0000 From: Sean Christopherson To: Philippe =?iso-8859-1?Q?Mathieu-Daud=E9?= Cc: 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 , Vitaly Kuznetsov , 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, Isaku Yamahata , Fabiano Rosas , Michael Ellerman , Chao Gao , Thomas Gleixner , Yuan Yao Subject: Re: [PATCH 17/44] KVM: arm64: Do arm/arch initialiation without bouncing through kvm_init() Message-ID: References: <20221102231911.3107438-1-seanjc@google.com> <20221102231911.3107438-18-seanjc@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221103_083009_771386_FE782BE9 X-CRM114-Status: GOOD ( 22.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Nov 03, 2022, Philippe Mathieu-Daud=E9 wrote: > Hi Sean, > = > On 3/11/22 00:18, Sean Christopherson wrote: > > Move 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 acti= on > > performed by kvm_init(), i.e. this is a glorified nop. > > = > > Making kvm_arch_init() a nop will allow dropping it entirely once all > > other architectures follow suit. > > = > > No functional change intended. > > = > > Signed-off-by: Sean Christopherson > > --- > > arch/arm64/kvm/arm.c | 25 ++++++++++++++++--------- > > 1 file changed, 16 insertions(+), 9 deletions(-) > = > > /* NOP: Compiling as a module not supported */ > > void kvm_arch_exit(void) > > { > > - kvm_unregister_perf_callbacks(); > = > Doesn't this belong to the previous patch? No, but the above changelog is a lie, there is very much a functional chang= e here. The goal of the previous patch is to fix the error paths in kvm_arch_init()= , a.k.a. kvm_arm_init(). After fixing kvm_arch_init(), there are still bugs in the = sequence as a whole because kvm_arch_exit() doesn't unwind other state, e.g. kvm_arc= h_exit() should really look something like: void kvm_arch_exit(void) { teardown_subsystems(); if (!is_kernel_in_hyp_mode()) teardown_hyp_mode(); kvm_arm_vmid_alloc_free(); if (is_protected_kvm_enabled()) ??? = } Becuase although the comment "NOP: Compiling as a module not supported" is = correct about KVM ARM always having to be built into the kernel, kvm_arch_exit() ca= n still be called if a later stage of kvm_init() fails. But rather than add a patch to fix kvm_arch_exit(), I chose to fix the bug = by moving code out of kvm_arch_init() so that the unwind sequence established = in the previous patch could be reused. Except I managed to forget those details when writing the changelog. The c= hangelog should instead be: KVM: arm64: Do arm/arch initialization without bouncing through kvm_init() = 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. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel