[PATCH v2 2/7] Drivers: hv: Disentangle VTL return cancellation from SIGPENDING

Wei Liu wei.liu at kernel.org
Fri Aug 29 11:38:16 PDT 2025


On Wed, Aug 27, 2025 at 05:01:51PM -0700, Sean Christopherson wrote:
> Check for return to a lower VTL being cancelled separately from handling
> pending TIF-based work, as there is no need to immediately process pending
> work; the kernel will immediately exit to userspace (ignoring preemption)
> and handle the pending work at that time.
> 
> Disentangling cancellation from the TIF-based work will allow switching to
> common virtualization APIs for detecting and processing pending work.
> 
> Signed-off-by: Sean Christopherson <seanjc at google.com>

Thanks for this patch, Sean.

My current plan is to drop this driver from my tree (hence it will
disappear from linux-next soon) because Peter has an objection to the
ABI it introduces. I just have not gotten around to it yet.

I won't apply this patch, the next one and the last one. I have CC'ed
the owner of that driver to this patch here so that your suggestion can
be incorporated in future submissions.

CC Saurabh and Naman.

Thanks,
Wei

> ---
>  drivers/hv/mshv_vtl_main.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/hv/mshv_vtl_main.c b/drivers/hv/mshv_vtl_main.c
> index 12f5e77b7095..aa09a76f0eff 100644
> --- a/drivers/hv/mshv_vtl_main.c
> +++ b/drivers/hv/mshv_vtl_main.c
> @@ -731,19 +731,21 @@ static int mshv_vtl_ioctl_return_to_lower_vtl(void)
>  						_TIF_NOTIFY_RESUME | _TIF_NOTIFY_SIGNAL |
>  						_TIF_NEED_RESCHED_LAZY;
>  		unsigned long ti_work;
> -		u32 cancel;
>  		unsigned long irq_flags;
>  		struct hv_vp_assist_page *hvp;
>  		int ret;
>  
>  		local_irq_save(irq_flags);
> +		if (READ_ONCE(mshv_vtl_this_run()->cancel)) {
> +			local_irq_restore(irq_flags);
> +			preempt_enable();
> +			return -EINTR;
> +		}
> +
>  		ti_work = READ_ONCE(current_thread_info()->flags);
> -		cancel = READ_ONCE(mshv_vtl_this_run()->cancel);
> -		if (unlikely((ti_work & VTL0_WORK) || cancel)) {
> +		if (unlikely(ti_work & VTL0_WORK)) {
>  			local_irq_restore(irq_flags);
>  			preempt_enable();
> -			if (cancel)
> -				ti_work |= _TIF_SIGPENDING;
>  			ret = mshv_do_pre_guest_mode_work(ti_work);
>  			if (ret)
>  				return ret;
> -- 
> 2.51.0.268.g9569e192d0-goog
> 
> 



More information about the linux-riscv mailing list