# HG changeset patch # User Steven Smith # Date 1232617992 0 # Node ID ea4b9c439ac347003fce1f2d12095dced7c1d48b # Parent 9fc1576f207b72752b92509467b693c22dd5acb7 Allow GNTABOP_copy to be used from HVM domains. diff -r 9fc1576f207b -r ea4b9c439ac3 xen/arch/x86/hvm/hvm.c --- a/xen/arch/x86/hvm/hvm.c Wed Jan 21 17:43:23 2009 +0000 +++ b/xen/arch/x86/hvm/hvm.c Thu Jan 22 09:53:12 2009 +0000 @@ -1876,12 +1876,25 @@ return hvm_intblk_none; } +static int grant_table_op_is_allowed(unsigned int cmd) +{ + switch (cmd) { + case GNTTABOP_query_size: + case GNTTABOP_setup_table: + case GNTTABOP_set_version: + case GNTTABOP_copy: + return 1; + default: + /* all other commands need auditing */ + return 0; + } +} + static long hvm_grant_table_op( unsigned int cmd, XEN_GUEST_HANDLE(void) uop, unsigned int count) { - if ( (cmd != GNTTABOP_query_size) && (cmd != GNTTABOP_setup_table) && - (cmd != GNTTABOP_set_version) ) - return -ENOSYS; /* all other commands need auditing */ + if ( !grant_table_op_is_allowed(cmd) ) + return -ENOSYS; return do_grant_table_op(cmd, uop, count); } @@ -1932,6 +1945,15 @@ #else /* defined(__x86_64__) */ +static long hvm_grant_table_op_compat32(unsigned int cmd, + XEN_GUEST_HANDLE(void) uop, + unsigned int count) +{ + if ( !grant_table_op_is_allowed(cmd) ) + return -ENOSYS; + return compat_grant_table_op(cmd, uop, count); +} + static long hvm_memory_op_compat32(int cmd, XEN_GUEST_HANDLE(void) arg) { long rc = compat_memory_op(cmd, arg); @@ -1971,7 +1993,7 @@ static hvm_hypercall_t *hvm_hypercall32_table[NR_hypercalls] = { [ __HYPERVISOR_memory_op ] = (hvm_hypercall_t *)hvm_memory_op_compat32, - [ __HYPERVISOR_grant_table_op ] = (hvm_hypercall_t *)hvm_grant_table_op, + [ __HYPERVISOR_grant_table_op ] = (hvm_hypercall_t *)hvm_grant_table_op_compat32, [ __HYPERVISOR_vcpu_op ] = (hvm_hypercall_t *)hvm_vcpu_op_compat32, HYPERCALL(xen_version), HYPERCALL(event_channel_op), diff -r 9fc1576f207b -r ea4b9c439ac3 xen/include/xen/hypercall.h --- a/xen/include/xen/hypercall.h Wed Jan 21 17:43:23 2009 +0000 +++ b/xen/include/xen/hypercall.h Thu Jan 22 09:53:12 2009 +0000 @@ -130,6 +130,12 @@ int vcpuid, XEN_GUEST_HANDLE(void) arg); +extern long +compat_grant_table_op( + unsigned int cmd, + XEN_GUEST_HANDLE(void) uop, + unsigned int count); + #endif #endif /* __XEN_HYPERCALL_H__ */