Subject: Re: [PATCH 4/4] KVM: arm64: Add SMC hook for SME dvmsync erratum

From: Catalin Marinas <[email-masked]>
Date: Fri, 6 Mar 2026 12:52:39 +0000

On Thu, Mar 05, 2026 at 02:32:54PM +0000, Will Deacon wrote:
> On Mon, Mar 02, 2026 at 04:57:57PM +0000, Catalin Marinas wrote:
> > @@ -28,6 +30,15 @@ static struct hyp_pool host_s2_pool;
> >  static DEFINE_PER_CPU(struct pkvm_hyp_vm *, __current_vm);
> >  #define current_vm (*this_cpu_ptr(&__current_vm))
> >  
> > +static void pkvm_sme_dvmsync_fw_call(void)
> > +{
> > +	if (cpus_have_final_cap(ARM64_WORKAROUND_SME_DVMSYNC)) {
> > +		struct arm_smccc_res res;
> > +
> > +		arm_smccc_1_1_smc(ARM_SMCCC_CPU_SME_DVMSYNC_WORKAROUND, &res);
> > +	}
> > +}
> > +
> >  static void guest_lock_component(struct pkvm_hyp_vm *vm)
> >  {
> >  	hyp_spin_lock(&vm->lock);
> > @@ -553,6 +564,12 @@ int host_stage2_set_owner_locked(phys_addr_t addr, u64 size, u8 owner_id)
> >  	if (ret)
> >  		return ret;
> >  
> > +	/*
> > +	 * After stage2 maintenance has happened, but before the page owner has
> > +	 * changed.
> > +	 */
> > +	pkvm_sme_dvmsync_fw_call();
> 
> Please note that this will conflict with my patch series adding support
> for protected memory with pkvm. I _think_ the right answer is to
> move this call into host_stage2_set_owner_metadata_locked().

Yes, it needs to be after host_stage2_try(), so it makes sense to move
it to host_stage2_set_owner_metadata_locked(). Let's see which order the
patches go in or we may have to fix the conflict during merge.

We can also leave the pKVM workaround for later once your rework goes
in.

-- 
Catalin