aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/vmx.c
diff options
context:
space:
mode:
authorIzik Eidus <izike@qumranet.com>2007-10-01 16:14:18 -0400
committerAvi Kivity <avi@qumranet.com>2008-01-30 10:52:50 -0500
commit195aefde9cc2cee38dd54ef92a866721fba4413e (patch)
treee9d7f47e8a462ee193a53cc4c21e5b3c7254956c /drivers/kvm/vmx.c
parent290fc38da8187b53b78dd4d5ab27a20b88ef8b61 (diff)
KVM: Add general accessors to read and write guest memory
Signed-off-by: Izik Eidus <izike@qumranet.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/vmx.c')
-rw-r--r--drivers/kvm/vmx.c43
1 files changed, 19 insertions, 24 deletions
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index 439873a25cca..894fd45ecc98 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -1387,33 +1387,28 @@ static void vmx_set_gdt(struct kvm_vcpu *vcpu, struct descriptor_table *dt)
1387 1387
1388static int init_rmode_tss(struct kvm* kvm) 1388static int init_rmode_tss(struct kvm* kvm)
1389{ 1389{
1390 struct page *p1, *p2, *p3;
1391 gfn_t fn = rmode_tss_base(kvm) >> PAGE_SHIFT; 1390 gfn_t fn = rmode_tss_base(kvm) >> PAGE_SHIFT;
1392 char *page; 1391 u16 data = 0;
1393 1392 int r;
1394 p1 = gfn_to_page(kvm, fn++);
1395 p2 = gfn_to_page(kvm, fn++);
1396 p3 = gfn_to_page(kvm, fn);
1397 1393
1398 if (!p1 || !p2 || !p3) { 1394 r = kvm_clear_guest_page(kvm, fn, 0, PAGE_SIZE);
1399 kvm_printf(kvm,"%s: gfn_to_page failed\n", __FUNCTION__); 1395 if (r < 0)
1396 return 0;
1397 data = TSS_BASE_SIZE + TSS_REDIRECTION_SIZE;
1398 r = kvm_write_guest_page(kvm, fn++, &data, 0x66, sizeof(u16));
1399 if (r < 0)
1400 return 0;
1401 r = kvm_clear_guest_page(kvm, fn++, 0, PAGE_SIZE);
1402 if (r < 0)
1403 return 0;
1404 r = kvm_clear_guest_page(kvm, fn, 0, PAGE_SIZE);
1405 if (r < 0)
1406 return 0;
1407 data = ~0;
1408 r = kvm_write_guest_page(kvm, fn, &data, RMODE_TSS_SIZE - 2 * PAGE_SIZE - 1,
1409 sizeof(u8));
1410 if (r < 0)
1400 return 0; 1411 return 0;
1401 }
1402
1403 page = kmap_atomic(p1, KM_USER0);
1404 clear_page(page);
1405 *(u16*)(page + 0x66) = TSS_BASE_SIZE + TSS_REDIRECTION_SIZE;
1406 kunmap_atomic(page, KM_USER0);
1407
1408 page = kmap_atomic(p2, KM_USER0);
1409 clear_page(page);
1410 kunmap_atomic(page, KM_USER0);
1411
1412 page = kmap_atomic(p3, KM_USER0);
1413 clear_page(page);
1414 *(page + RMODE_TSS_SIZE - 2 * PAGE_SIZE - 1) = ~0;
1415 kunmap_atomic(page, KM_USER0);
1416
1417 return 1; 1412 return 1;
1418} 1413}
1419 1414