Re: [PATCH 2/3] KVM: arm64: Generate final CTR_EL0 value when running in Protected mode

From: Quentin Perret
Date: Tue Mar 23 2021 - 05:47:54 EST


Hi Marc,

On Monday 22 Mar 2021 at 18:37:14 (+0000), Marc Zyngier wrote:
> Can't say I'm keen on the yucky bit, but here's an alternative (ha!)
> for you:
>
> diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h
> index 1a4cee7eb3c9..7582c3bd2f05 100644
> --- a/arch/arm64/include/asm/assembler.h
> +++ b/arch/arm64/include/asm/assembler.h
> @@ -278,6 +278,9 @@ alternative_else
> ldr_l \reg, arm64_ftr_reg_ctrel0 + ARM64_FTR_SYSVAL
> alternative_endif
> #else
> +alternative_if_not ARM64_KVM_PROTECTED_MODE
> + ASM_BUG()
> +alternative_else_nop_endif
> alternative_cb kvm_compute_final_ctr_el0
> movz \reg, #0
> movk \reg, #0, lsl #16
>
> Yes, it is one more instruction, but it is cleaner and allows us to
> from the first patch of the series.
>
> What do you think?

Yes, I think having the ASM_BUG() in this macro is bit nicer and I doubt
the additional nop will make any difference, so this is looking good to
me!

Thanks,
Quentin