[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] x86/hvm: Improve grant_table_op hypercall dispatching
commit a130a4128968b00d025b5d691b9a919498092d77 Author: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> AuthorDate: Mon Feb 13 11:49:29 2017 +0000 Commit: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> CommitDate: Tue Feb 14 14:34:26 2017 +0000 x86/hvm: Improve grant_table_op hypercall dispatching hvm_grant_table_op() and hvm_grant_table_op_compat32() are almost identical, but there is no need to have two functions instantiated at the end of different function pointers. Combine the two into a single hvm_grant_table_op() (folding grant_table_op_is_allowed() into is now-single caller) and dispatch to {do,compat}_grant_table_op() based on the hcall_64bit setting. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Reviewed-by: Wei Liu <wei.liu2@xxxxxxxxxx> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx> --- xen/arch/x86/hvm/hypercall.c | 40 +++++++++++++--------------------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hypercall.c index acb3714..85fa92d 100644 --- a/xen/arch/x86/hvm/hypercall.c +++ b/xen/arch/x86/hvm/hypercall.c @@ -46,9 +46,11 @@ static long hvm_memory_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) return rc; } -static int grant_table_op_is_allowed(unsigned int cmd) +static long hvm_grant_table_op( + unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) uop, unsigned int count) { - switch (cmd) { + switch ( cmd ) + { case GNTTABOP_query_size: case GNTTABOP_setup_table: case GNTTABOP_set_version: @@ -57,19 +59,16 @@ static int grant_table_op_is_allowed(unsigned int cmd) case GNTTABOP_map_grant_ref: case GNTTABOP_unmap_grant_ref: case GNTTABOP_swap_grant_ref: - return 1; - default: - /* all other commands need auditing */ - return 0; + break; + + default: /* All other commands need auditing. */ + return -ENOSYS; } -} -static long hvm_grant_table_op( - unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) uop, unsigned int count) -{ - if ( !grant_table_op_is_allowed(cmd) ) - return -ENOSYS; /* all other commands need auditing */ - return do_grant_table_op(cmd, uop, count); + if ( current->arch.hvm_vcpu.hcall_64bit ) + return do_grant_table_op(cmd, uop, count); + else + return compat_grant_table_op(cmd, uop, count); } static long hvm_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) @@ -89,15 +88,6 @@ static long hvm_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) } } -static long hvm_grant_table_op_compat32(unsigned int cmd, - XEN_GUEST_HANDLE_PARAM(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_physdev_op_compat32( int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) { @@ -130,13 +120,11 @@ static long hvm_physdev_op_compat32( #define do_physdev_op hvm_physdev_op #define compat_physdev_op hvm_physdev_op_compat32 -#define do_grant_table_op hvm_grant_table_op -#define compat_grant_table_op hvm_grant_table_op_compat32 #define do_arch_1 paging_domctl_continuation static const hypercall_table_t hvm_hypercall_table[] = { HVM_CALL(memory_op), - COMPAT_CALL(grant_table_op), + HVM_CALL(grant_table_op), COMPAT_CALL(vcpu_op), COMPAT_CALL(physdev_op), COMPAT_CALL(xen_version), @@ -160,8 +148,6 @@ static const hypercall_table_t hvm_hypercall_table[] = { #undef do_physdev_op #undef compat_physdev_op -#undef do_grant_table_op -#undef compat_grant_table_op #undef do_arch_1 #undef HYPERCALL -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |