Re: [PATCH 03/18] arm64: hyp-stub: Move elx_sync into the vectors

From: Marc Zyngier
Date: Thu May 27 2021 - 11:54:42 EST


On Thu, 27 May 2021 16:05:11 +0100,
Pavel Tatashin <pasha.tatashin@xxxxxxxxxx> 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@xxxxxxx>
> Signed-off-by: Pavel Tatashin <pasha.tatashin@xxxxxxxxxx>
> ---
> 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.

Thanks,

M.

--
Without deviation from the norm, progress is not possible.