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 X-Spam-Level: X-Spam-Status: No, score=-14.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A714BC4708F for ; Tue, 1 Jun 2021 12:23:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7CEE4613C5 for ; Tue, 1 Jun 2021 12:23:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233823AbhFAMYr (ORCPT ); Tue, 1 Jun 2021 08:24:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:43582 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233797AbhFAMYm (ORCPT ); Tue, 1 Jun 2021 08:24:42 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E9693613AD; Tue, 1 Jun 2021 12:23:00 +0000 (UTC) Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1lo3QA-004oP5-RK; Tue, 01 Jun 2021 13:22:58 +0100 Date: Tue, 01 Jun 2021 13:22:57 +0100 Message-ID: <87r1hl22qm.wl-maz@kernel.org> From: Marc Zyngier To: Pavel Tatashin Cc: James Morris , Sasha Levin , "Eric W. Biederman" , kexec mailing list , LKML , Jonathan Corbet , Catalin Marinas , Will Deacon , Linux ARM , James Morse , Vladimir Murzin , Matthias Brugger , linux-mm , Mark Rutland , steve.capper@arm.com, rfontana@redhat.com, Thomas Gleixner , Selin Dag , Tyler Hicks , Pingfan Liu , Andrew Morton , madvenka@linux.microsoft.com Subject: Re: [PATCH 03/18] arm64: hyp-stub: Move elx_sync into the vectors In-Reply-To: References: <20210527150526.271941-1-pasha.tatashin@soleen.com> <20210527150526.271941-4-pasha.tatashin@soleen.com> <87sg28rx3c.wl-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) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: pasha.tatashin@soleen.com, jmorris@namei.org, sashal@kernel.org, ebiederm@xmission.com, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, corbet@lwn.net, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, vladimir.murzin@arm.com, matthias.bgg@gmail.com, linux-mm@kvack.org, mark.rutland@arm.com, steve.capper@arm.com, rfontana@redhat.com, tglx@linutronix.de, selindag@gmail.com, tyhicks@linux.microsoft.com, kernelfans@gmail.com, akpm@linux-foundation.org, madvenka@linux.microsoft.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 27 May 2021 22:23:22 +0100, Pavel Tatashin wrote: > > On Thu, May 27, 2021 at 11:54 AM Marc Zyngier wrote: > > > > On Thu, 27 May 2021 16:05:11 +0100, > > Pavel Tatashin wrote: > > > > > > The hyp-stub's elx_sync code fits in the vector. > > > > > > With this, all of the hyp-stubs behaviour is contained in its vectors. > > > This lets kexec and hibernate copy the hyp-stub when they need its > > > behaviour, instead of re-implementing it. > > > > > > Co-developed-by: James Morse > > > Signed-off-by: Pavel Tatashin > > > --- > > > arch/arm64/kernel/hyp-stub.S | 64 +++++++++++++++++++----------------- > > > 1 file changed, 33 insertions(+), 31 deletions(-) > > > > > > diff --git a/arch/arm64/kernel/hyp-stub.S b/arch/arm64/kernel/hyp-stub.S > > > index 18a97bee3779..86af6c4e52b9 100644 > > > --- a/arch/arm64/kernel/hyp-stub.S > > > +++ b/arch/arm64/kernel/hyp-stub.S > > > @@ -21,6 +21,37 @@ SYM_CODE_START_LOCAL(\label) > > > .align 7 > > > b \label > > > SYM_CODE_END(\label) > > > +.endm > > > + > > > +.macro elx_sync_vector label > > > +SYM_CODE_START_LOCAL(\label) > > > + .align 7 > > > + cmp x0, #HVC_SET_VECTORS > > > + b.ne 1f > > > + msr vbar_el2, x1 > > > + b 9f > > > + > > > +1: cmp x0, #HVC_VHE_RESTART > > > + b.eq mutate_to_vhe > > > > Now that this has turned into a macro, what are the guarantees that > > mutate_to_vhe will be within reach of the site where this macro is > > expanded? It does work here, but what about the other expansion sites > > that will show up later in the series? > > > > What was wrong with directly branching to the original call site? > > Nothing in the commit message explains it. > > Hi Marc, > > I need to explain this better in the commit log. Later in the series > we create our own vector copy that is outside of the old and new > kernel so it does not get overwritten during kexec relocation. When > VHE is enabled, the vector is passed so we can switch to el2 before > jumping to the new kernel. > > arm64_relocate_new_kernel() which performs the relocation runs with > MMU being enabled until relocation is done, after that disables MMU > and if vectors are passed performs: > > mov x0, #HVC_SOFT_RESTART > hvc #0 /* Jumps from el2 */ > > It cannot call mutate_to_vhe because #HVC_VHE_RESTART is not used > here. But, if it had to it would not work as we cannot return to the > old kernel text after relocation. OK, so you are happy with having a dangling branch pointing to nowhere? Something in me screams that it isn't a good idea, in general. If HVC_SOFT_RESTART is all you need, I'd rather you have a small stub that implements exactly that and nothing else. Feel free to extract it as a reusable macro if you want. Thanks, M. -- Without deviation from the norm, progress is not possible. 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 X-Spam-Level: X-Spam-Status: No, score=-14.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53119C47080 for ; Tue, 1 Jun 2021 12:24:34 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 1688F60FF0 for ; Tue, 1 Jun 2021 12:24:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1688F60FF0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JluX1gSigmswgwZyR+JGl+otrNydScPYklNdIQQ2nUs=; b=wkwsSAiQvXEVEs UgC1DZQ++DxS1LsRF/glgB6rUtJXCUks+hVt5i77xGr+mfLg3aTufoMvG6dFqS/b+YAVh6VQAhPdC SOX0kYWiYQ/oATXky3QZs1MkjAjyI2Lx5eIOVtxTJjGxcTNHy7voYtv1hTVix/XB7ek9190teIAnn LDMKpMFXkDigm0XIVIO1tp6Q9pJViVWcSVxyZcwwmYLQ3Mscr4I+GmPncl1GLfAR3goVLReZUgnm6 Kul8+dVY3FoRsRCFrHlFpayVjYaWg4cwach6cIlKGqHjbpZztAk57aCv6JCXm6xqXQ8Ye+e3kLpBM 8mN3rlpf8w7M4s2KyN7w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lo3QI-00GVck-TL; Tue, 01 Jun 2021 12:23:07 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lo3QD-00GVaq-AV; Tue, 01 Jun 2021 12:23:02 +0000 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E9693613AD; Tue, 1 Jun 2021 12:23:00 +0000 (UTC) Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1lo3QA-004oP5-RK; Tue, 01 Jun 2021 13:22:58 +0100 Date: Tue, 01 Jun 2021 13:22:57 +0100 Message-ID: <87r1hl22qm.wl-maz@kernel.org> From: Marc Zyngier To: Pavel Tatashin Cc: James Morris , Sasha Levin , "Eric W. Biederman" , kexec mailing list , LKML , Jonathan Corbet , Catalin Marinas , Will Deacon , Linux ARM , James Morse , Vladimir Murzin , Matthias Brugger , linux-mm , Mark Rutland , steve.capper@arm.com, rfontana@redhat.com, Thomas Gleixner , Selin Dag , Tyler Hicks , Pingfan Liu , Andrew Morton , madvenka@linux.microsoft.com Subject: Re: [PATCH 03/18] arm64: hyp-stub: Move elx_sync into the vectors In-Reply-To: References: <20210527150526.271941-1-pasha.tatashin@soleen.com> <20210527150526.271941-4-pasha.tatashin@soleen.com> <87sg28rx3c.wl-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) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: pasha.tatashin@soleen.com, jmorris@namei.org, sashal@kernel.org, ebiederm@xmission.com, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, corbet@lwn.net, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, vladimir.murzin@arm.com, matthias.bgg@gmail.com, linux-mm@kvack.org, mark.rutland@arm.com, steve.capper@arm.com, rfontana@redhat.com, tglx@linutronix.de, selindag@gmail.com, tyhicks@linux.microsoft.com, kernelfans@gmail.com, akpm@linux-foundation.org, madvenka@linux.microsoft.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210601_052301_440403_1DAD517B X-CRM114-Status: GOOD ( 38.53 ) 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="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 27 May 2021 22:23:22 +0100, Pavel Tatashin wrote: > > On Thu, May 27, 2021 at 11:54 AM Marc Zyngier wrote: > > > > On Thu, 27 May 2021 16:05:11 +0100, > > Pavel Tatashin wrote: > > > > > > The hyp-stub's elx_sync code fits in the vector. > > > > > > With this, all of the hyp-stubs behaviour is contained in its vectors. > > > This lets kexec and hibernate copy the hyp-stub when they need its > > > behaviour, instead of re-implementing it. > > > > > > Co-developed-by: James Morse > > > Signed-off-by: Pavel Tatashin > > > --- > > > arch/arm64/kernel/hyp-stub.S | 64 +++++++++++++++++++----------------- > > > 1 file changed, 33 insertions(+), 31 deletions(-) > > > > > > diff --git a/arch/arm64/kernel/hyp-stub.S b/arch/arm64/kernel/hyp-stub.S > > > index 18a97bee3779..86af6c4e52b9 100644 > > > --- a/arch/arm64/kernel/hyp-stub.S > > > +++ b/arch/arm64/kernel/hyp-stub.S > > > @@ -21,6 +21,37 @@ SYM_CODE_START_LOCAL(\label) > > > .align 7 > > > b \label > > > SYM_CODE_END(\label) > > > +.endm > > > + > > > +.macro elx_sync_vector label > > > +SYM_CODE_START_LOCAL(\label) > > > + .align 7 > > > + cmp x0, #HVC_SET_VECTORS > > > + b.ne 1f > > > + msr vbar_el2, x1 > > > + b 9f > > > + > > > +1: cmp x0, #HVC_VHE_RESTART > > > + b.eq mutate_to_vhe > > > > Now that this has turned into a macro, what are the guarantees that > > mutate_to_vhe will be within reach of the site where this macro is > > expanded? It does work here, but what about the other expansion sites > > that will show up later in the series? > > > > What was wrong with directly branching to the original call site? > > Nothing in the commit message explains it. > > Hi Marc, > > I need to explain this better in the commit log. Later in the series > we create our own vector copy that is outside of the old and new > kernel so it does not get overwritten during kexec relocation. When > VHE is enabled, the vector is passed so we can switch to el2 before > jumping to the new kernel. > > arm64_relocate_new_kernel() which performs the relocation runs with > MMU being enabled until relocation is done, after that disables MMU > and if vectors are passed performs: > > mov x0, #HVC_SOFT_RESTART > hvc #0 /* Jumps from el2 */ > > It cannot call mutate_to_vhe because #HVC_VHE_RESTART is not used > here. But, if it had to it would not work as we cannot return to the > old kernel text after relocation. OK, so you are happy with having a dangling branch pointing to nowhere? Something in me screams that it isn't a good idea, in general. If HVC_SOFT_RESTART is all you need, I'd rather you have a small stub that implements exactly that and nothing else. Feel free to extract it as a reusable macro if you want. Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Date: Tue, 01 Jun 2021 13:22:57 +0100 Message-ID: <87r1hl22qm.wl-maz@kernel.org> From: Marc Zyngier Subject: Re: [PATCH 03/18] arm64: hyp-stub: Move elx_sync into the vectors In-Reply-To: References: <20210527150526.271941-1-pasha.tatashin@soleen.com> <20210527150526.271941-4-pasha.tatashin@soleen.com> <87sg28rx3c.wl-maz@kernel.org> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "kexec" Errors-To: kexec-bounces+dwmw2=infradead.org@lists.infradead.org To: Pavel Tatashin Cc: James Morris , Sasha Levin , "Eric W. Biederman" , kexec mailing list , LKML , Jonathan Corbet , Catalin Marinas , Will Deacon , Linux ARM , James Morse , Vladimir Murzin , Matthias Brugger , linux-mm , Mark Rutland , steve.capper@arm.com, rfontana@redhat.com, Thomas Gleixner , Selin Dag , Tyler Hicks , Pingfan Liu , Andrew Morton , madvenka@linux.microsoft.com On Thu, 27 May 2021 22:23:22 +0100, Pavel Tatashin wrote: > > On Thu, May 27, 2021 at 11:54 AM Marc Zyngier wrote: > > > > On Thu, 27 May 2021 16:05:11 +0100, > > Pavel Tatashin wrote: > > > > > > The hyp-stub's elx_sync code fits in the vector. > > > > > > With this, all of the hyp-stubs behaviour is contained in its vectors. > > > This lets kexec and hibernate copy the hyp-stub when they need its > > > behaviour, instead of re-implementing it. > > > > > > Co-developed-by: James Morse > > > Signed-off-by: Pavel Tatashin > > > --- > > > arch/arm64/kernel/hyp-stub.S | 64 +++++++++++++++++++----------------- > > > 1 file changed, 33 insertions(+), 31 deletions(-) > > > > > > diff --git a/arch/arm64/kernel/hyp-stub.S b/arch/arm64/kernel/hyp-stub.S > > > index 18a97bee3779..86af6c4e52b9 100644 > > > --- a/arch/arm64/kernel/hyp-stub.S > > > +++ b/arch/arm64/kernel/hyp-stub.S > > > @@ -21,6 +21,37 @@ SYM_CODE_START_LOCAL(\label) > > > .align 7 > > > b \label > > > SYM_CODE_END(\label) > > > +.endm > > > + > > > +.macro elx_sync_vector label > > > +SYM_CODE_START_LOCAL(\label) > > > + .align 7 > > > + cmp x0, #HVC_SET_VECTORS > > > + b.ne 1f > > > + msr vbar_el2, x1 > > > + b 9f > > > + > > > +1: cmp x0, #HVC_VHE_RESTART > > > + b.eq mutate_to_vhe > > > > Now that this has turned into a macro, what are the guarantees that > > mutate_to_vhe will be within reach of the site where this macro is > > expanded? It does work here, but what about the other expansion sites > > that will show up later in the series? > > > > What was wrong with directly branching to the original call site? > > Nothing in the commit message explains it. > > Hi Marc, > > I need to explain this better in the commit log. Later in the series > we create our own vector copy that is outside of the old and new > kernel so it does not get overwritten during kexec relocation. When > VHE is enabled, the vector is passed so we can switch to el2 before > jumping to the new kernel. > > arm64_relocate_new_kernel() which performs the relocation runs with > MMU being enabled until relocation is done, after that disables MMU > and if vectors are passed performs: > > mov x0, #HVC_SOFT_RESTART > hvc #0 /* Jumps from el2 */ > > It cannot call mutate_to_vhe because #HVC_VHE_RESTART is not used > here. But, if it had to it would not work as we cannot return to the > old kernel text after relocation. OK, so you are happy with having a dangling branch pointing to nowhere? Something in me screams that it isn't a good idea, in general. If HVC_SOFT_RESTART is all you need, I'd rather you have a small stub that implements exactly that and nothing else. Feel free to extract it as a reusable macro if you want. Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec