aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/kvm_main.c
diff options
context:
space:
mode:
authorShaohua Li <shaohua.li@intel.com>2007-07-23 02:51:39 -0400
committerAvi Kivity <avi@qumranet.com>2007-10-13 04:18:19 -0400
commitfe5518819463d57ed032bc12458ed681bc790609 (patch)
tree15d13f175f2b77970eb7d84d442689426cafd283 /drivers/kvm/kvm_main.c
parent9ae0448f53324b3c476f68bd134d97ac4ec27e0c (diff)
KVM: Move gfn_to_page out of kmap/unmap pairs
gfn_to_page might sleep with swap support. Move it out of the kmap calls. Signed-off-by: Shaohua Li <shaohua.li@intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/kvm_main.c')
-rw-r--r--drivers/kvm/kvm_main.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 093cea36194b..80ee427754d2 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -1076,7 +1076,6 @@ static int emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa,
1076{ 1076{
1077 struct page *page; 1077 struct page *page;
1078 void *virt; 1078 void *virt;
1079 unsigned offset = offset_in_page(gpa);
1080 1079
1081 if (((gpa + bytes - 1) >> PAGE_SHIFT) != (gpa >> PAGE_SHIFT)) 1080 if (((gpa + bytes - 1) >> PAGE_SHIFT) != (gpa >> PAGE_SHIFT))
1082 return 0; 1081 return 0;
@@ -1085,7 +1084,7 @@ static int emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa,
1085 return 0; 1084 return 0;
1086 mark_page_dirty(vcpu->kvm, gpa >> PAGE_SHIFT); 1085 mark_page_dirty(vcpu->kvm, gpa >> PAGE_SHIFT);
1087 virt = kmap_atomic(page, KM_USER0); 1086 virt = kmap_atomic(page, KM_USER0);
1088 kvm_mmu_pte_write(vcpu, gpa, virt + offset, val, bytes); 1087 kvm_mmu_pte_write(vcpu, gpa, val, bytes);
1089 memcpy(virt + offset_in_page(gpa), val, bytes); 1088 memcpy(virt + offset_in_page(gpa), val, bytes);
1090 kunmap_atomic(virt, KM_USER0); 1089 kunmap_atomic(virt, KM_USER0);
1091 return 1; 1090 return 1;
@@ -1455,7 +1454,7 @@ static int vcpu_register_para(struct kvm_vcpu *vcpu, gpa_t para_state_gpa)
1455 1454
1456 mark_page_dirty(vcpu->kvm, para_state_gpa >> PAGE_SHIFT); 1455 mark_page_dirty(vcpu->kvm, para_state_gpa >> PAGE_SHIFT);
1457 para_state_page = pfn_to_page(para_state_hpa >> PAGE_SHIFT); 1456 para_state_page = pfn_to_page(para_state_hpa >> PAGE_SHIFT);
1458 para_state = kmap_atomic(para_state_page, KM_USER0); 1457 para_state = kmap(para_state_page);
1459 1458
1460 printk(KERN_DEBUG ".... guest version: %d\n", para_state->guest_version); 1459 printk(KERN_DEBUG ".... guest version: %d\n", para_state->guest_version);
1461 printk(KERN_DEBUG ".... size: %d\n", para_state->size); 1460 printk(KERN_DEBUG ".... size: %d\n", para_state->size);
@@ -1491,7 +1490,7 @@ static int vcpu_register_para(struct kvm_vcpu *vcpu, gpa_t para_state_gpa)
1491 1490
1492 para_state->ret = 0; 1491 para_state->ret = 0;
1493err_kunmap_skip: 1492err_kunmap_skip:
1494 kunmap_atomic(para_state, KM_USER0); 1493 kunmap(para_state_page);
1495 return 0; 1494 return 0;
1496err_gp: 1495err_gp:
1497 return 1; 1496 return 1;