diff options
Diffstat (limited to 'arch/x86/kernel/kvm.c')
| -rw-r--r-- | arch/x86/kernel/kvm.c | 26 | 
1 files changed, 19 insertions, 7 deletions
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index 08b973f6403..cd6d9a5a42f 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -20,6 +20,7 @@   *   Authors: Anthony Liguori <aliguori@us.ibm.com>   */ +#include <linux/context_tracking.h>  #include <linux/module.h>  #include <linux/kernel.h>  #include <linux/kvm_para.h> @@ -121,6 +122,8 @@ void kvm_async_pf_task_wait(u32 token)  	struct kvm_task_sleep_node n, *e;  	DEFINE_WAIT(wait); +	rcu_irq_enter(); +  	spin_lock(&b->lock);  	e = _find_apf_task(b, token);  	if (e) { @@ -128,6 +131,8 @@ void kvm_async_pf_task_wait(u32 token)  		hlist_del(&e->link);  		kfree(e);  		spin_unlock(&b->lock); + +		rcu_irq_exit();  		return;  	} @@ -152,13 +157,16 @@ void kvm_async_pf_task_wait(u32 token)  			/*  			 * We cannot reschedule. So halt.  			 */ +			rcu_irq_exit();  			native_safe_halt(); +			rcu_irq_enter();  			local_irq_disable();  		}  	}  	if (!n.halted)  		finish_wait(&n.wq, &wait); +	rcu_irq_exit();  	return;  }  EXPORT_SYMBOL_GPL(kvm_async_pf_task_wait); @@ -246,16 +254,18 @@ EXPORT_SYMBOL_GPL(kvm_read_and_reset_pf_reason);  dotraplinkage void __kprobes  do_async_page_fault(struct pt_regs *regs, unsigned long error_code)  { +	enum ctx_state prev_state; +  	switch (kvm_read_and_reset_pf_reason()) {  	default:  		do_page_fault(regs, error_code);  		break;  	case KVM_PV_REASON_PAGE_NOT_PRESENT:  		/* page is swapped out by the host. */ -		rcu_irq_enter(); +		prev_state = exception_enter();  		exit_idle();  		kvm_async_pf_task_wait((u32)read_cr2()); -		rcu_irq_exit(); +		exception_exit(prev_state);  		break;  	case KVM_PV_REASON_PAGE_READY:  		rcu_irq_enter(); @@ -289,9 +299,9 @@ static void kvm_register_steal_time(void)  	memset(st, 0, sizeof(*st)); -	wrmsrl(MSR_KVM_STEAL_TIME, (__pa(st) | KVM_MSR_ENABLED)); -	printk(KERN_INFO "kvm-stealtime: cpu %d, msr %lx\n", -		cpu, __pa(st)); +	wrmsrl(MSR_KVM_STEAL_TIME, (slow_virt_to_phys(st) | KVM_MSR_ENABLED)); +	pr_info("kvm-stealtime: cpu %d, msr %llx\n", +		cpu, (unsigned long long) slow_virt_to_phys(st));  }  static DEFINE_PER_CPU(unsigned long, kvm_apic_eoi) = KVM_PV_EOI_DISABLED; @@ -316,7 +326,7 @@ void __cpuinit kvm_guest_cpu_init(void)  		return;  	if (kvm_para_has_feature(KVM_FEATURE_ASYNC_PF) && kvmapf) { -		u64 pa = __pa(&__get_cpu_var(apf_reason)); +		u64 pa = slow_virt_to_phys(&__get_cpu_var(apf_reason));  #ifdef CONFIG_PREEMPT  		pa |= KVM_ASYNC_PF_SEND_ALWAYS; @@ -332,7 +342,8 @@ void __cpuinit kvm_guest_cpu_init(void)  		/* Size alignment is implied but just to make it explicit. */  		BUILD_BUG_ON(__alignof__(kvm_apic_eoi) < 4);  		__get_cpu_var(kvm_apic_eoi) = 0; -		pa = __pa(&__get_cpu_var(kvm_apic_eoi)) | KVM_MSR_ENABLED; +		pa = slow_virt_to_phys(&__get_cpu_var(kvm_apic_eoi)) +			| KVM_MSR_ENABLED;  		wrmsrl(MSR_KVM_PV_EOI_EN, pa);  	} @@ -497,6 +508,7 @@ static bool __init kvm_detect(void)  const struct hypervisor_x86 x86_hyper_kvm __refconst = {  	.name			= "KVM",  	.detect			= kvm_detect, +	.x2apic_available	= kvm_para_available,  };  EXPORT_SYMBOL_GPL(x86_hyper_kvm);  |