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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c1a5ab1d-1601-46db-83da-b26422a2aabd@linux.microsoft.com>
Date: Thu, 28 Aug 2025 17:03:28 -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 6/7] Drivers: hv: Use common "entry virt" APIs to do
 work in root before running guest

On 8/27/2025 5:01 PM, Sean Christopherson wrote:
> Use the kernel's common "entry virt" APIs to handle pending work prior to
> (re)entering guest mode, now that the virt APIs don't have a superfluous
> dependency on KVM.
> 
> No functional change intended.
> 
> Signed-off-by: Sean Christopherson <seanjc@...gle.com>
> ---
>  drivers/hv/Kconfig          |  1 +
>  drivers/hv/mshv_root_main.c | 32 ++++++--------------------------
>  2 files changed, 7 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
> index 2e8df09db599..894037afcbf9 100644
> --- a/drivers/hv/Kconfig
> +++ b/drivers/hv/Kconfig
> @@ -66,6 +66,7 @@ config MSHV_ROOT
>  	# no particular order, making it impossible to reassemble larger pages
>  	depends on PAGE_SIZE_4KB
>  	select EVENTFD
> +	select VIRT_XFER_TO_GUEST_WORK
>  	default n
>  	help
>  	  Select this option to enable support for booting and running as root
> diff --git a/drivers/hv/mshv_root_main.c b/drivers/hv/mshv_root_main.c
> index 0d849f09160a..7c83f656e071 100644
> --- a/drivers/hv/mshv_root_main.c
> +++ b/drivers/hv/mshv_root_main.c
> @@ -8,6 +8,7 @@
>   * Authors: Microsoft Linux virtualization team
>   */
>  
> +#include <linux/entry-virt.h>
>  #include <linux/kernel.h>
>  #include <linux/module.h>
>  #include <linux/fs.h>
> @@ -481,29 +482,6 @@ mshv_vp_wait_for_hv_kick(struct mshv_vp *vp)
>  	return 0;
>  }
>  
> -static int mshv_pre_guest_mode_work(struct mshv_vp *vp)
> -{
> -	const ulong work_flags = _TIF_NOTIFY_SIGNAL | _TIF_SIGPENDING |
> -				 _TIF_NEED_RESCHED  | _TIF_NEED_RESCHED_LAZY |
> -				 _TIF_NOTIFY_RESUME;
> -	ulong th_flags;
> -
> -	th_flags = read_thread_flags();
> -	while (th_flags & work_flags) {
> -		int ret;
> -
> -		/* nb: following will call schedule */
> -		ret = mshv_do_pre_guest_mode_work(th_flags);
> -
> -		if (ret)
> -			return ret;
> -
> -		th_flags = read_thread_flags();
> -	}
> -
> -	return 0;
> -}
> -
>  /* Must be called with interrupts enabled */
>  static long mshv_run_vp_with_root_scheduler(struct mshv_vp *vp)
>  {
> @@ -524,9 +502,11 @@ static long mshv_run_vp_with_root_scheduler(struct mshv_vp *vp)
>  		u32 flags = 0;
>  		struct hv_output_dispatch_vp output;
>  
> -		ret = mshv_pre_guest_mode_work(vp);
> -		if (ret)
> -			break;
> +		if (__xfer_to_guest_mode_work_pending()) {
> +			ret = xfer_to_guest_mode_handle_work();
> +			if (ret)
> +				break;
> +		}
>  
>  		if (vp->run.flags.intercept_suspend)
>  			flags |= HV_DISPATCH_VP_FLAG_CLEAR_INTERCEPT_SUSPEND;

Also tested mshv_root with 1-6 applied, looks good to me. Possibly Naman,
Saurabh, or Roman can test the mshv_vtl patches, I can't do it
unfortunately.

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