# HG changeset patch # User gcosta@redhat.com # Date 1164380458 18000 # Node ID da7aa8896ab07932160406c8b19a6ad4a61b3af7 # Parent 47fcd5f768fef50cba2fc6dbadc7b75de55e88a5 [XEN] Implement the memory_map hypercall It's needed to provide guests with an idea of a physical mapping that may differ from simply what's needed to fit tot_pages. Signed-off-by: Glauber de Oliveira Costa diff -r 47fcd5f768fe -r da7aa8896ab0 xen/arch/x86/mm.c --- a/xen/arch/x86/mm.c Fri Nov 17 08:30:43 2006 -0500 +++ b/xen/arch/x86/mm.c Fri Nov 24 10:00:58 2006 -0500 @@ -2976,7 +2976,45 @@ long arch_memory_op(int op, XEN_GUEST_HA case XENMEM_memory_map: { - return -ENOSYS; + struct xen_memory_map memmap; + struct domain *d; + XEN_GUEST_HANDLE(e820entry_t) buffer; + struct e820entry map; + + if ( IS_PRIV(current->domain) ) + return -ENOSYS; + + d = current->domain; + + if ( copy_from_guest(&memmap, arg, 1) ) + return -EFAULT; + + buffer = guest_handle_cast(memmap.buffer, e820entry_t); + if ( unlikely(guest_handle_is_null(buffer)) ) + return -EFAULT; + + memmap.nr_entries = 1; + + /* if we were not supplied with proper information, the best we can + * do is rely on the current max_pages information as a sane bound */ + if (d->memory_map_limit) + map.size = d->memory_map_limit; + else + map.size = d->max_pages << PAGE_SHIFT; + + /* 8MB slack (to balance backend allocations). */ + map.size += 8 << 20; + map.addr = 0ULL; + map.type = E820_RAM; + + if ( copy_to_guest(arg, &memmap, 1) ) + return -EFAULT; + + if ( copy_to_guest(buffer, &map, 1) < 0 ) + return -EFAULT; + + return 0; + } case XENMEM_machine_memory_map: