Swap the order of checking for TIF-based work and cancellation, and disable
IRQs only after checking and processing TIF-based work; checking TIF with
IRQs enabled is a-ok, e.g. IRQs and preemption _must_ be enabled before
handling the pending work.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
drivers/hv/mshv_vtl_main.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/hv/mshv_vtl_main.c b/drivers/hv/mshv_vtl_main.c
index aa09a76f0eff..4ca13c54c0a0 100644
--- a/drivers/hv/mshv_vtl_main.c
+++ b/drivers/hv/mshv_vtl_main.c
@@ -735,16 +735,8 @@ static int mshv_vtl_ioctl_return_to_lower_vtl(void)
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);
if (unlikely(ti_work & VTL0_WORK)) {
- local_irq_restore(irq_flags);
preempt_enable();
ret = mshv_do_pre_guest_mode_work(ti_work);
if (ret)
@@ -753,6 +745,13 @@ static int mshv_vtl_ioctl_return_to_lower_vtl(void)
continue;
}
+ local_irq_save(irq_flags);
+ if (READ_ONCE(mshv_vtl_this_run()->cancel)) {
+ local_irq_restore(irq_flags);
+ preempt_enable();
+ return -EINTR;
+ }
+
mshv_vtl_return(&mshv_vtl_this_run()->cpu_context);
local_irq_restore(irq_flags);
--
2.51.0.268.g9569e192d0-goog