# HG changeset patch
# User Tim Deegan <Tim.Deegan@xxxxxxxxxxxxx>
# Node ID d9f2de16ae5ab52c813d3887001268ea7222c50a
# Parent 6d892ea6194db5af3c3bed814110194a6afbbc31
[HVM] Fix hvm_copy_[to|from]_guest_virt
which would fail if it crossed a page boundary where the guest physical
pages were not contiguous.
Signed-off-by: Tim Deegan <Tim.Deegan@xxxxxxxxxxxxx>
---
xen/arch/x86/hvm/hvm.c | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)
diff -r 6d892ea6194d -r d9f2de16ae5a xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c Thu Nov 23 18:01:40 2006 +0000
+++ b/xen/arch/x86/hvm/hvm.c Fri Nov 24 09:42:40 2006 +0000
@@ -330,12 +330,13 @@ void hvm_hlt(unsigned long rflags)
/*
* __hvm_copy():
* @buf = hypervisor buffer
- * @addr = guest physical address to copy to/from
+ * @addr = guest address to copy to/from
* @size = number of bytes to copy
* @dir = copy *to* guest (TRUE) or *from* guest (FALSE)?
+ * @virt = addr is *virtual* (TRUE) or *guest physical* (FALSE)?
* Returns number of bytes failed to copy (0 == complete success).
*/
-static int __hvm_copy(void *buf, paddr_t addr, int size, int dir)
+static int __hvm_copy(void *buf, paddr_t addr, int size, int dir, int virt)
{
unsigned long mfn;
char *p;
@@ -346,7 +347,11 @@ static int __hvm_copy(void *buf, paddr_t
{
count = min_t(int, PAGE_SIZE - (addr & ~PAGE_MASK), todo);
- mfn = get_mfn_from_gpfn(addr >> PAGE_SHIFT);
+ if ( virt )
+ mfn = get_mfn_from_gpfn(shadow_gva_to_gfn(current, addr));
+ else
+ mfn = get_mfn_from_gpfn(addr >> PAGE_SHIFT);
+
if ( mfn == INVALID_MFN )
return todo;
@@ -369,23 +374,24 @@ static int __hvm_copy(void *buf, paddr_t
int hvm_copy_to_guest_phys(paddr_t paddr, void *buf, int size)
{
- return __hvm_copy(buf, paddr, size, 1);
+ return __hvm_copy(buf, paddr, size, 1, 0);
}
int hvm_copy_from_guest_phys(void *buf, paddr_t paddr, int size)
{
- return __hvm_copy(buf, paddr, size, 0);
+ return __hvm_copy(buf, paddr, size, 0, 0);
}
int hvm_copy_to_guest_virt(unsigned long vaddr, void *buf, int size)
{
- return __hvm_copy(buf, shadow_gva_to_gpa(current, vaddr), size, 1);
+ return __hvm_copy(buf, vaddr, size, 1, 1);
}
int hvm_copy_from_guest_virt(void *buf, unsigned long vaddr, int size)
{
- return __hvm_copy(buf, shadow_gva_to_gpa(current, vaddr), size, 0);
-}
+ return __hvm_copy(buf, vaddr, size, 0, 1);
+}
+
/* HVM specific printbuf. Mostly used for hvmloader chit-chat. */
void hvm_print_line(struct vcpu *v, const char c)
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|