[PATCH v3 10/12] KVM: arm64: nVHE: Support CONFIG_CFI_CLANG at EL2

Pierre-Clément Tosi ptosi at google.com
Wed May 29 05:30:15 PDT 2024


Hi Will,

On Mon, May 13, 2024 at 06:30:05PM +0100, Will Deacon wrote:
> On Fri, May 10, 2024 at 12:26:39PM +0100, Pierre-Clément Tosi wrote:
> > [...]
> > 
> > Use SYM_TYPED_FUNC_START() for __pkvm_init_switch_pgd, as nVHE can't
> > call it directly and must use a PA function pointer from C (because it
> > is part of the idmap page), which would trigger a kCFI failure if the
> > type ID wasn't present.
> > 
> > Signed-off-by: Pierre-Clément Tosi <ptosi at google.com>
> > ---
> >  arch/arm64/include/asm/esr.h       |  6 ++++++
> >  arch/arm64/kvm/handle_exit.c       | 11 +++++++++++
> >  arch/arm64/kvm/hyp/nvhe/Makefile   |  6 +++---
> >  arch/arm64/kvm/hyp/nvhe/hyp-init.S |  6 +++++-
> >  4 files changed, 25 insertions(+), 4 deletions(-)
> > 
> >  [...]
> > 
> > diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-init.S b/arch/arm64/kvm/hyp/nvhe/hyp-init.S
> > index 5a15737b4233..33fb5732ab83 100644
> > --- a/arch/arm64/kvm/hyp/nvhe/hyp-init.S
> > +++ b/arch/arm64/kvm/hyp/nvhe/hyp-init.S
> > @@ -5,6 +5,7 @@
> >   */
> >  
> >  #include <linux/arm-smccc.h>
> > +#include <linux/cfi_types.h>
> >  #include <linux/linkage.h>
> >  
> >  #include <asm/alternative.h>
> > @@ -268,8 +269,11 @@ SYM_CODE_END(__kvm_handle_stub_hvc)
> >  /*
> >   * void __pkvm_init_switch_pgd(struct kvm_nvhe_init_params *params,
> >   *                             void (*finalize_fn)(void));
> > + *
> > + * SYM_TYPED_FUNC_START() allows C to call this ID-mapped function indirectly
> > + * using a physical pointer without triggering a kCFI failure.
> >   */
> > -SYM_FUNC_START(__pkvm_init_switch_pgd)
> > +SYM_TYPED_FUNC_START(__pkvm_init_switch_pgd)
> >  	/* Load the inputs from the VA pointer before turning the MMU off */
> >  	ldr	x5, [x0, #NVHE_INIT_PGD_PA]
> >  	ldr	x0, [x0, #NVHE_INIT_STACK_HYP_VA]
> 
> Unrelated hunk?

No, this is needed to prevent a kCFI failure at EL2.

Please let me know if the comment and commit message aren't clear enough.

> 
> Will



More information about the linux-arm-kernel mailing list