lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 01 Jun 2021 13:22:57 +0100
From:   Marc Zyngier <maz@...nel.org>
To:     Pavel Tatashin <pasha.tatashin@...een.com>
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 03/18] arm64: hyp-stub: Move elx_sync into the vectors

On Thu, 27 May 2021 22:23:22 +0100,
Pavel Tatashin <pasha.tatashin@...een.com> wrote:
> 
> On Thu, May 27, 2021 at 11:54 AM Marc Zyngier <maz@...nel.org> wrote:
> >
> > On Thu, 27 May 2021 16:05:11 +0100,
> > Pavel Tatashin <pasha.tatashin@...een.com> 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 <james.morse@....com>
> > > Signed-off-by: Pavel Tatashin <pasha.tatashin@...een.com>
> > > ---
> > >  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.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ