]> Gentwo Git Trees - linux/.git/commitdiff
mshv: Use common "entry virt" APIs to do work in root before running guest
authorSean Christopherson <seanjc@google.com>
Thu, 28 Aug 2025 00:01:55 +0000 (17:01 -0700)
committerWei Liu <wei.liu@kernel.org>
Tue, 30 Sep 2025 22:50:48 +0000 (22:50 +0000)
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@google.com>
Tested-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
Reviewed-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
Signed-off-by: Wei Liu <wei.liu@kernel.org>
drivers/hv/Kconfig
drivers/hv/mshv.h
drivers/hv/mshv_common.c
drivers/hv/mshv_root_main.c

index 57623ca7f350ae79193ce1fdd3face22ce062ae5..cdb210cd3710e9f351353fd8c9756150dcc42b31 100644 (file)
@@ -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
index 0340a67acd0a4dacd7dcf93535a788f5dfb81cc9..d4813df92b9cbddc1e591821438d1057c69197f9 100644 (file)
@@ -25,6 +25,4 @@ int hv_call_set_vp_registers(u32 vp_index, u64 partition_id, u16 count,
 int hv_call_get_partition_property(u64 partition_id, u64 property_code,
                                   u64 *property_value);
 
-int mshv_do_pre_guest_mode_work(ulong th_flags);
-
 #endif /* _MSHV_H */
index eb3df3e296bbeef73be3df3e5b8cfdcdd2c90c71..aa2be51979fd687f8a90f8c5bfb8fbb01171869a 100644 (file)
@@ -138,25 +138,3 @@ int hv_call_get_partition_property(u64 partition_id,
        return 0;
 }
 EXPORT_SYMBOL_GPL(hv_call_get_partition_property);
-
-/*
- * Handle any pre-processing before going into the guest mode on this cpu, most
- * notably call schedule(). Must be invoked with both preemption and
- * interrupts enabled.
- *
- * Returns: 0 on success, -errno on error.
- */
-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 | _TIF_NEED_RESCHED_LAZY))
-               schedule();
-
-       if (th_flags & _TIF_NOTIFY_RESUME)
-               resume_user_mode_work(NULL);
-
-       return 0;
-}
-EXPORT_SYMBOL_GPL(mshv_do_pre_guest_mode_work);
index 3d0d5af80d2ec6128b1aaaf8fe5782ffb705aabd..e3b2bd417c46405f27159080f7411035915697fc 100644 (file)
@@ -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;