Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 02EA86112 for ; Tue, 11 Oct 2022 20:59:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA530C433C1; Tue, 11 Oct 2022 20:59:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665521955; bh=WDo7TGKL3wdUVXktG1Ud6ocgH2ZnNiVxM3UyUdlDECc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Ke+sNRqK7PE3/xFvxADXu/qe+KbCTRkR0BxLz1btUnknJZgyM4ekS9tob+pkCvhs2 Icg12WveyWOwGN6iuyt/biq+f6iXDYHU3QwLNFGXx5ImYf6JoUvs1OsFNZPd/rGthL PJDvQiyIKwPRUuuiD8IEFi5V9oSncigd5LLu709bJD63+oIYT4EbwALvsb/tHfLzFI 0zuVX09Ss7iN7GkS86KOZv/52ANIBsjqfeArwhB3tGd1cQwY1QU8i5Kv8/lhb+nSMc OPQDzn72FDLOqeTpMYdZFoQkldEK9ihPTGEJ3+CLaxDRVrFrbp18sJw3ci8VMftclB IygljItW34ovA== Received: from sofa.misterjones.org ([185.219.108.64] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1oiMLJ-00FuhW-Bb; Tue, 11 Oct 2022 21:59:13 +0100 Date: Tue, 11 Oct 2022 21:58:22 +0100 Message-ID: <87pmeygjrl.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: kvmarm@lists.cs.columbia.edu, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, James Morse , Suzuki K Poulose , Alexandru Elisei , Quentin Perret , Will Deacon , Vincent Donnefort Subject: Re: [PATCH] KVM: arm64: pkvm: Fixup boot mode to reflect that the kernel resumes from EL1 In-Reply-To: References: <20221011165400.1241729-1-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: oliver.upton@linux.dev, kvmarm@lists.cs.columbia.edu, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, suzuki.poulose@arm.com, alexandru.elisei@arm.com, qperret@google.com, will@kernel.org, vdonnefort@google.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Message-ID: <20221011205822.gG6TjN8DxrSPSsNzbiqS56sH-3yWKikPMl85fgMkPZk@z> On Tue, 11 Oct 2022 19:48:39 +0100, Oliver Upton wrote: > > On Tue, Oct 11, 2022 at 05:54:00PM +0100, Marc Zyngier wrote: > > The kernel has an awfully complicated boot sequence in order to cope > > with the various EL2 configurations, including those that "enhanced" > > the architecture. We go from EL2 to EL1, then back to EL2, staying > > at EL2 if VHE capable and otherwise go back to EL1. > > > > Here's a paracetamol tablet for you. > > Heh, still have a bit of a headache from this :) > > I'm having a hard time following where we skip the EL2 promotion based > on __boot_cpu_mode. > > On the cpu_resume() path it looks like we take the return of > init_kernel_el() and pass that along to finalise_el2(). As we are in EL1 > at this point, it seems like we'd go init_kernel_el() -> init_el1(). > > What am I missing? That I'm an idiot. This is only necessary on pre-6.0, before 005e12676af0 ("arm64: head: record CPU boot mode after enabling the MMU"), as this code-path *used* to reload the boot mode from memory. Now, this is directly passed as a parameter, making this patch useless. The joys of looking at too many code bases at the same time... I'll see how we can add it to 5.19. Thanks, M. -- Without deviation from the norm, progress is not possible.