On Thu, Aug 30, Jan Beulich wrote:

> approach): One is Paul's idea of making null_handler actually retrieve
> RAM contents when (part of) the access touches RAM. Another might

This works for me:

static int null_read(const struct hvm_io_handler *io_handler,
                     uint64_t addr,
                     uint32_t size,
                     uint64_t *data)
{
    struct vcpu *curr = current;
    struct domain *currd = curr->domain;
    p2m_type_t p2mt = p2m_invalid;
    unsigned long gmfn = paddr_to_pfn(addr);
    struct page_info *page;
    char *p;

    get_gfn_query_unlocked(currd, gmfn, &p2mt);
    if ( p2mt != p2m_ram_rw )
    {   
        *data = ~0ul;
    }
    else
    {   
        page = get_page_from_gfn(currd, gmfn, NULL, P2M_UNSHARE);
        if ( ! page )
        {
            memset(data, 0xee, size);
        }
        else
        {
            p = (char *)__map_domain_page(page) + (addr & ~PAGE_MASK);
            memcpy(data, p, size);
            unmap_domain_page(p);
            put_page(page);
        }
    }
    return X86EMUL_OKAY;
}

Olaf

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reply via email to