[PATCH 2/4] KVM: arm64: Allocate a protected vCPU's SVE state at EL2

Oliver Upton oupton at kernel.org
Fri Nov 6 10:59:05 PST 2026


On Fri, Nov 06, 2026 at 05:51:44PM +0000, Vincent Donnefort wrote:
> > @@ -1243,6 +1253,9 @@ int pkvm_reset_vcpu(struct pkvm_hyp_vcpu *hyp_vcpu)
> >  			    PSCI_0_2_AFFINITY_LEVEL_ON) != PSCI_0_2_AFFINITY_LEVEL_ON_PENDING)
> >  		return -ECANCELED;
> >  
> > +	if (vcpu_has_sve(&hyp_vcpu->vcpu))
> > +		memset(hyp_vcpu->vcpu.arch.sve_state, 0, vcpu_sve_state_size(&hyp_vcpu->vcpu));
> > +
> 
> Why wasn't this line around before?

Prior to this series SVE was only supported in non-protected guests, so
the host was responsible for resetting SVE state.

Now that we have pVM support we need to reset state for protected
vCPUs.

Thanks,
Oliver

> >  	kvm_reset_vcpu_core(&hyp_vcpu->vcpu);
> >  	kvm_reset_pvm_sys_regs(&hyp_vcpu->vcpu);
> >  
> > diff --git a/arch/arm64/kvm/hyp/nvhe/sys_regs.c b/arch/arm64/kvm/hyp/nvhe/sys_regs.c
> > index 32e82653ebf7e..06ea91415ad8b 100644
> > --- a/arch/arm64/kvm/hyp/nvhe/sys_regs.c
> > +++ b/arch/arm64/kvm/hyp/nvhe/sys_regs.c
> > @@ -570,6 +570,7 @@ static const struct sys_reg_desc_reset pvm_sys_reg_reset_vals[] = {
> >  	RESET_UNKNOWN(MAIR_EL1),
> >  	RESET_ZERO(AMAIR_EL1),
> >  	RESET_ZERO(MDSCR_EL1),
> > +	RESET_ZERO(ZCR_EL1),
> >  	RESET_ZERO(CNTV_CTL_EL0),
> >  	RESET_UNKNOWN(TTBR0_EL1),
> >  	RESET_UNKNOWN(TTBR1_EL1),
> > diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c
> > index 10eb7249aa9e8..aaaa1b8634ba4 100644
> > --- a/arch/arm64/kvm/reset.c
> > +++ b/arch/arm64/kvm/reset.c
> > @@ -52,6 +52,8 @@ int __init kvm_arm_init_sve(void)
> >  		if (WARN_ON(kvm_sve_max_vl > VL_ARCH_MAX))
> >  			kvm_sve_max_vl = VL_ARCH_MAX;
> >  
> > +		kvm_nvhe_sym(kvm_sve_max_vl) = kvm_sve_max_vl;
> > +
> >  		/*
> >  		 * Don't even try to make use of vector lengths that
> >  		 * aren't available on all CPUs, for now:
> > -- 
> > 2.47.3
> > 
> 
> -- 
> Vincent



More information about the linux-arm-kernel mailing list