[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+CK2bChDqMKGAG8_rEigWcXRaBN=rnuV_WLnU=1TPjJRtpc5A@mail.gmail.com>
Date: Tue, 1 Jun 2021 21:33:52 -0400
From: Pavel Tatashin <pasha.tatashin@...een.com>
To: Marc Zyngier <maz@...nel.org>
Cc: James Morris <jmorris@...ei.org>, Sasha Levin <sashal@...nel.org>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
kexec mailing list <kexec@...ts.infradead.org>,
LKML <linux-kernel@...r.kernel.org>,
Jonathan Corbet <corbet@....net>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will@...nel.org>,
Linux ARM <linux-arm-kernel@...ts.infradead.org>,
James Morse <james.morse@....com>,
Vladimir Murzin <vladimir.murzin@....com>,
Matthias Brugger <matthias.bgg@...il.com>,
linux-mm <linux-mm@...ck.org>,
Mark Rutland <mark.rutland@....com>, steve.capper@....com,
rfontana@...hat.com, Thomas Gleixner <tglx@...utronix.de>,
Selin Dag <selindag@...il.com>,
Tyler Hicks <tyhicks@...ux.microsoft.com>,
Pingfan Liu <kernelfans@...il.com>,
Andrew Morton <akpm@...ux-foundation.org>,
madvenka@...ux.microsoft.com
Subject: Re: [PATCH 04/18] arm64: kernel: add helper for booted at EL2 and not VHE
On Tue, Jun 1, 2021 at 8:38 AM Marc Zyngier <maz@...nel.org> wrote:
>
> On Thu, 27 May 2021 16:05:12 +0100,
> Pavel Tatashin <pasha.tatashin@...een.com> wrote:
> >
> > Replace places that contain logic like this:
> > is_hyp_mode_available() && !is_kernel_in_hyp_mode()
> >
> > With a dedicated boolean function is_hyp_callable(). This will be needed
> > later in kexec in order to sooner switch back to EL2.
>
> This looks like the very definition of "run in nVHE mode", so I'd
> rather you call it like this, rather than "callable", which is
> extremely ambiguous (if running at EL2, I call it any time I want, for
> free).
Hi Marc,
Naming is hard. Are you proposing s/is_hyp_callable/run_in_nvhe_mode/
? This is also not a very good name because it does not sound like a
boolean, but instead that we know that there is nvhe mode available
and we can switch to it.
>
> >
> > Suggested-by: James Morse <james.morse@....com>
> >
> > [Fixed merging issues]
> >
> > Signed-off-by: Pavel Tatashin <pasha.tatashin@...een.com>
> > ---
> > arch/arm64/include/asm/virt.h | 5 +++++
> > arch/arm64/kernel/cpu-reset.h | 3 +--
> > arch/arm64/kernel/hibernate.c | 9 +++------
> > arch/arm64/kernel/sdei.c | 2 +-
> > 4 files changed, 10 insertions(+), 9 deletions(-)
> >
> > diff --git a/arch/arm64/include/asm/virt.h b/arch/arm64/include/asm/virt.h
> > index 7379f35ae2c6..4216c8623538 100644
> > --- a/arch/arm64/include/asm/virt.h
> > +++ b/arch/arm64/include/asm/virt.h
> > @@ -128,6 +128,11 @@ static __always_inline bool is_protected_kvm_enabled(void)
> > return cpus_have_final_cap(ARM64_KVM_PROTECTED_MODE);
> > }
> >
> > +static inline bool is_hyp_callable(void)
> > +{
> > + return is_hyp_mode_available() && !is_kernel_in_hyp_mode();
> > +}
>
> nit: consider switching the two members of the expression so that you
> don't have extra memory accesses when running at EL2.
Sure, I will do that.
> > -/* Do we need to reset el2? */
> > -#define el2_reset_needed() (is_hyp_mode_available() && !is_kernel_in_hyp_mode())
> > -
>
> Please keep the macro, as it explains *why* we're doing things (we
> need to reset EL2), and replacing it with a generic macro drops the
> documentation aspect.
OK, I will keep the macro, and redefine it to use the common macro.
Thank you,
Pasha
Powered by blists - more mailing lists