Skip to contentSkip to conversation

vmx-copy_from_guest.patch

PATCH New Leendert van Doorn 1 participant 1 message Sep 6, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vmx-copy_from_guest.patch

Reducing LOC (always a good thing) by eliminating duplicated functionality. vmx_platform.c/inst_copy_from_guest() now uses vmx_copy. Also shored up vmx_copy to handle copies when paging is enabled and improved its error handling.

xen/arch/x86/vmx.c +9 -3
diff -r 23d8580d56b0 xen/arch/x86/vmx.c
@@ -729,7 +735,7 @@
 int
 vmx_copy(void *buf, unsigned long laddr, int size, int dir)
 {
-    unsigned long mfn;
+    unsigned long gpa, mfn;
     char *addr;
     int count;
 
@@ -738,8 +744,14 @@
 	if (count > size)
 	    count = size;
 
-	mfn = get_mfn_from_pfn(laddr >> PAGE_SHIFT);
-	/* XXX check whether laddr is valid */
+	if (vmx_paging_enabled(current)) {
+		gpa = gva_to_gpa(laddr);
+		mfn = get_mfn_from_pfn(gpa >> PAGE_SHIFT);
+	} else
+		mfn = get_mfn_from_pfn(laddr >> PAGE_SHIFT);
+	if (mfn == INVALID_MFN)
+		return 0;
+
 	addr = (char *)map_domain_page(mfn) + (laddr & ~PAGE_MASK);
 
 	if (dir == VMX_COPY_IN)
xen/arch/x86/vmx_platform.c +4 -40

53 lines not on this page · raw message