printf: Remove unused 'bprintf'
[drm/drm-misc.git] / include / linux / entry-kvm.h
blob16149f6625e48a3ff3f32aa4fabac3aba374c103
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __LINUX_ENTRYKVM_H
3 #define __LINUX_ENTRYKVM_H
5 #include <linux/static_call_types.h>
6 #include <linux/resume_user_mode.h>
7 #include <linux/syscalls.h>
8 #include <linux/seccomp.h>
9 #include <linux/sched.h>
10 #include <linux/tick.h>
12 /* Transfer to guest mode work */
13 #ifdef CONFIG_KVM_XFER_TO_GUEST_WORK
15 #ifndef ARCH_XFER_TO_GUEST_MODE_WORK
16 # define ARCH_XFER_TO_GUEST_MODE_WORK (0)
17 #endif
19 #define XFER_TO_GUEST_MODE_WORK \
20 (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY | _TIF_SIGPENDING | \
21 _TIF_NOTIFY_SIGNAL | _TIF_NOTIFY_RESUME | \
22 ARCH_XFER_TO_GUEST_MODE_WORK)
24 struct kvm_vcpu;
26 /**
27 * arch_xfer_to_guest_mode_handle_work - Architecture specific xfer to guest
28 * mode work handling function.
29 * @vcpu: Pointer to current's VCPU data
30 * @ti_work: Cached TIF flags gathered in xfer_to_guest_mode_handle_work()
32 * Invoked from xfer_to_guest_mode_handle_work(). Defaults to NOOP. Can be
33 * replaced by architecture specific code.
35 static inline int arch_xfer_to_guest_mode_handle_work(struct kvm_vcpu *vcpu,
36 unsigned long ti_work);
38 #ifndef arch_xfer_to_guest_mode_work
39 static inline int arch_xfer_to_guest_mode_handle_work(struct kvm_vcpu *vcpu,
40 unsigned long ti_work)
42 return 0;
44 #endif
46 /**
47 * xfer_to_guest_mode_handle_work - Check and handle pending work which needs
48 * to be handled before going to guest mode
49 * @vcpu: Pointer to current's VCPU data
51 * Returns: 0 or an error code
53 int xfer_to_guest_mode_handle_work(struct kvm_vcpu *vcpu);
55 /**
56 * xfer_to_guest_mode_prepare - Perform last minute preparation work that
57 * need to be handled while IRQs are disabled
58 * upon entering to guest.
60 * Has to be invoked with interrupts disabled before the last call
61 * to xfer_to_guest_mode_work_pending().
63 static inline void xfer_to_guest_mode_prepare(void)
65 lockdep_assert_irqs_disabled();
66 tick_nohz_user_enter_prepare();
69 /**
70 * __xfer_to_guest_mode_work_pending - Check if work is pending
72 * Returns: True if work pending, False otherwise.
74 * Bare variant of xfer_to_guest_mode_work_pending(). Can be called from
75 * interrupt enabled code for racy quick checks with care.
77 static inline bool __xfer_to_guest_mode_work_pending(void)
79 unsigned long ti_work = read_thread_flags();
81 return !!(ti_work & XFER_TO_GUEST_MODE_WORK);
84 /**
85 * xfer_to_guest_mode_work_pending - Check if work is pending which needs to be
86 * handled before returning to guest mode
88 * Returns: True if work pending, False otherwise.
90 * Has to be invoked with interrupts disabled before the transition to
91 * guest mode.
93 static inline bool xfer_to_guest_mode_work_pending(void)
95 lockdep_assert_irqs_disabled();
96 return __xfer_to_guest_mode_work_pending();
98 #endif /* CONFIG_KVM_XFER_TO_GUEST_WORK */
100 #endif