aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/kvm.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/kernel/kvm.c')
-rw-r--r--arch/x86/kernel/kvm.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index aa60a08b65b1..8bb9594d0761 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -117,7 +117,11 @@ static struct kvm_task_sleep_node *_find_apf_task(struct kvm_task_sleep_head *b,
117 return NULL; 117 return NULL;
118} 118}
119 119
120void kvm_async_pf_task_wait(u32 token) 120/*
121 * @interrupt_kernel: Is this called from a routine which interrupts the kernel
122 * (other than user space)?
123 */
124void kvm_async_pf_task_wait(u32 token, int interrupt_kernel)
121{ 125{
122 u32 key = hash_32(token, KVM_TASK_SLEEP_HASHBITS); 126 u32 key = hash_32(token, KVM_TASK_SLEEP_HASHBITS);
123 struct kvm_task_sleep_head *b = &async_pf_sleepers[key]; 127 struct kvm_task_sleep_head *b = &async_pf_sleepers[key];
@@ -140,7 +144,10 @@ void kvm_async_pf_task_wait(u32 token)
140 144
141 n.token = token; 145 n.token = token;
142 n.cpu = smp_processor_id(); 146 n.cpu = smp_processor_id();
143 n.halted = is_idle_task(current) || preempt_count() > 1; 147 n.halted = is_idle_task(current) ||
148 (IS_ENABLED(CONFIG_PREEMPT_COUNT)
149 ? preempt_count() > 1 || rcu_preempt_depth()
150 : interrupt_kernel);
144 init_swait_queue_head(&n.wq); 151 init_swait_queue_head(&n.wq);
145 hlist_add_head(&n.link, &b->list); 152 hlist_add_head(&n.link, &b->list);
146 raw_spin_unlock(&b->lock); 153 raw_spin_unlock(&b->lock);
@@ -268,7 +275,7 @@ do_async_page_fault(struct pt_regs *regs, unsigned long error_code)
268 case KVM_PV_REASON_PAGE_NOT_PRESENT: 275 case KVM_PV_REASON_PAGE_NOT_PRESENT:
269 /* page is swapped out by the host. */ 276 /* page is swapped out by the host. */
270 prev_state = exception_enter(); 277 prev_state = exception_enter();
271 kvm_async_pf_task_wait((u32)read_cr2()); 278 kvm_async_pf_task_wait((u32)read_cr2(), !user_mode(regs));
272 exception_exit(prev_state); 279 exception_exit(prev_state);
273 break; 280 break;
274 case KVM_PV_REASON_PAGE_READY: 281 case KVM_PV_REASON_PAGE_READY: