Skip to contentSkip to conversation

vmx-copy_from_guest.patch

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

lore
Share & tools
lore
#0 lore raw
# seems current vmx_copy can not deal with copy over page boundary?
# so remove inst_copy_from_guest will cause problem.

Are you looking at the correct tree? Both xen-vt-testing and xen-unstable have my newer vmx_copy that was introduced last Friday. It does handle multiple pages.

int
vmx_copy(void *buf, unsigned long laddr, int size, int dir)

{
    unsigned long gpa, mfn;
    char *addr;
    int count;

    while (size > 0) {
        count = PAGE_SIZE - (laddr & ~PAGE_MASK);
        if (count > size)
            count = size;

        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)
            memcpy(buf, addr, count);
        else
            memcpy(addr, buf, count);

        unmap_domain_page(addr);

        laddr += count;
        buf += count;
        size -= count;
    }

    return 1;
}

- Leendert

--
Leendert van Doorn <[email protected]>
IBM T.J. Watson Research Center (914) 784-7831
30 Saw Mill River Road, Hawthorne, NY 10532