lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0b4eb0cc-657f-4cdb-8255-e3b8f6b14077@linux.microsoft.com>
Date: Thu, 28 Aug 2025 16:56:20 -0700
From: Nuno Das Neves <nunodasneves@...ux.microsoft.com>
To: Sean Christopherson <seanjc@...gle.com>, Marc Zyngier <maz@...nel.org>,
 Oliver Upton <oliver.upton@...ux.dev>,
 Catalin Marinas <catalin.marinas@....com>, Will Deacon <will@...nel.org>,
 Tianrui Zhao <zhaotianrui@...ngson.cn>, Bibo Mao <maobibo@...ngson.cn>,
 Huacai Chen <chenhuacai@...nel.org>, Anup Patel <anup@...infault.org>,
 Paul Walmsley <paul.walmsley@...ive.com>, Palmer Dabbelt
 <palmer@...belt.com>, Albert Ou <aou@...s.berkeley.edu>,
 Paolo Bonzini <pbonzini@...hat.com>, Thomas Gleixner <tglx@...utronix.de>,
 Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
 Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
 "K. Y. Srinivasan" <kys@...rosoft.com>,
 Haiyang Zhang <haiyangz@...rosoft.com>, Wei Liu <wei.liu@...nel.org>,
 Dexuan Cui <decui@...rosoft.com>, Peter Zijlstra <peterz@...radead.org>,
 Andy Lutomirski <luto@...nel.org>, "Paul E. McKenney" <paulmck@...nel.org>,
 Frederic Weisbecker <frederic@...nel.org>,
 Neeraj Upadhyay <neeraj.upadhyay@...nel.org>,
 Joel Fernandes <joelagnelf@...dia.com>, Josh Triplett
 <josh@...htriplett.org>, Boqun Feng <boqun.feng@...il.com>,
 Uladzislau Rezki <urezki@...il.com>
Cc: linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
 kvmarm@...ts.linux.dev, kvm@...r.kernel.org, loongarch@...ts.linux.dev,
 kvm-riscv@...ts.infradead.org, linux-riscv@...ts.infradead.org,
 linux-hyperv@...r.kernel.org, rcu@...r.kernel.org,
 Mukesh R <mrathor@...ux.microsoft.com>
Subject: Re: [PATCH v2 1/7] Drivers: hv: Handle NEED_RESCHED_LAZY before
 transferring to guest

On 8/27/2025 5:01 PM, Sean Christopherson wrote:
> Check for NEED_RESCHED_LAZY, not just NEED_RESCHED, prior to transferring
> control to a guest.  Failure to check for lazy resched can unnecessarily
> delay rescheduling until the next tick when using a lazy preemption model.
> 
> Note, ideally both the checking and processing of TIF bits would be handled
> in common code, to avoid having to keep three separate paths synchronized,
> but defer such cleanups to the future to keep the fix as standalone as
> possible.
> 
> Cc: Nuno Das Neves <nunodasneves@...ux.microsoft.com>
> Cc: Mukesh R <mrathor@...ux.microsoft.com>
> Fixes: 621191d709b1 ("Drivers: hv: Introduce mshv_root module to expose /dev/mshv to VMMs")
> Fixes: 64503b4f4468 ("Drivers: hv: Introduce mshv_vtl driver")
> Signed-off-by: Sean Christopherson <seanjc@...gle.com>
> ---
>  drivers/hv/mshv_common.c    | 2 +-
>  drivers/hv/mshv_root_main.c | 3 ++-
>  drivers/hv/mshv_vtl_main.c  | 3 ++-
>  3 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hv/mshv_common.c b/drivers/hv/mshv_common.c
> index 6f227a8a5af7..eb3df3e296bb 100644
> --- a/drivers/hv/mshv_common.c
> +++ b/drivers/hv/mshv_common.c
> @@ -151,7 +151,7 @@ int mshv_do_pre_guest_mode_work(ulong th_flags)
>  	if (th_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL))
>  		return -EINTR;
>  
> -	if (th_flags & _TIF_NEED_RESCHED)
> +	if (th_flags & (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY))
>  		schedule();
>  
>  	if (th_flags & _TIF_NOTIFY_RESUME)
> diff --git a/drivers/hv/mshv_root_main.c b/drivers/hv/mshv_root_main.c
> index 932932cb91ea..0d849f09160a 100644
> --- a/drivers/hv/mshv_root_main.c
> +++ b/drivers/hv/mshv_root_main.c
> @@ -484,7 +484,8 @@ mshv_vp_wait_for_hv_kick(struct mshv_vp *vp)
>  static int mshv_pre_guest_mode_work(struct mshv_vp *vp)
>  {
>  	const ulong work_flags = _TIF_NOTIFY_SIGNAL | _TIF_SIGPENDING |
> -				 _TIF_NEED_RESCHED  | _TIF_NOTIFY_RESUME;
> +				 _TIF_NEED_RESCHED  | _TIF_NEED_RESCHED_LAZY |
> +				 _TIF_NOTIFY_RESUME;
>  	ulong th_flags;
>  
>  	th_flags = read_thread_flags();
> diff --git a/drivers/hv/mshv_vtl_main.c b/drivers/hv/mshv_vtl_main.c
> index dc6594ae03ad..12f5e77b7095 100644
> --- a/drivers/hv/mshv_vtl_main.c
> +++ b/drivers/hv/mshv_vtl_main.c
> @@ -728,7 +728,8 @@ static int mshv_vtl_ioctl_return_to_lower_vtl(void)
>  	preempt_disable();
>  	for (;;) {
>  		const unsigned long VTL0_WORK = _TIF_SIGPENDING | _TIF_NEED_RESCHED |
> -						_TIF_NOTIFY_RESUME | _TIF_NOTIFY_SIGNAL;
> +						_TIF_NOTIFY_RESUME | _TIF_NOTIFY_SIGNAL |
> +						_TIF_NEED_RESCHED_LAZY;
>  		unsigned long ti_work;
>  		u32 cancel;
>  		unsigned long irq_flags;

Tested by compiling with CONFIG_PREEMPT_LAZY=y and booting a guest. For
the test I added a check to confirm _TIF_NEED_RESCHED_LAZY was set and
honored.

Looks good, thanks.

Tested-by: Nuno Das Neves <nunodasneves@...ux.microsoft.com>
Reviewed-by: Nuno Das Neves <nunodasneves@...ux.microsoft.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ