1 // SPDX-License-Identifier: GPL-2.0
3 #include <linux/entry-kvm.h>
4 #include <linux/kvm_host.h>
6 static int xfer_to_guest_mode_work(struct kvm_vcpu *vcpu, unsigned long ti_work)
11 if (ti_work & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL)) {
12 clear_notify_signal();
13 if (task_work_pending(current))
17 if (ti_work & _TIF_SIGPENDING) {
18 kvm_handle_signal_exit(vcpu);
22 if (ti_work & _TIF_NEED_RESCHED)
25 if (ti_work & _TIF_NOTIFY_RESUME)
26 resume_user_mode_work(NULL);
28 ret = arch_xfer_to_guest_mode_handle_work(vcpu, ti_work);
32 ti_work = read_thread_flags();
33 } while (ti_work & XFER_TO_GUEST_MODE_WORK || need_resched());
37 int xfer_to_guest_mode_handle_work(struct kvm_vcpu *vcpu)
39 unsigned long ti_work;
42 * This is invoked from the outer guest loop with interrupts and
45 * KVM invokes xfer_to_guest_mode_work_pending() with interrupts
46 * disabled in the inner loop before going into guest mode. No need
47 * to disable interrupts here.
49 ti_work = read_thread_flags();
50 if (!(ti_work & XFER_TO_GUEST_MODE_WORK))
53 return xfer_to_guest_mode_work(vcpu, ti_work);
55 EXPORT_SYMBOL_GPL(xfer_to_guest_mode_handle_work);