do_grant_table_op()'s input array size limitation
Am I right in understanding that the restriction on 512 entries to be passed in is solely to cap the time that's being spent in the hypervisor without being able to service softirq requests as well as while the domain lock is being held? If that's the case, eliminating that restriction could be fairly strait forward by putting the majority of the function body in a loop or, perhaps even better, calling hypercall_preempt_check() every so many entries and using the continuation mechanism.
Thanks, Jan
Quoted 10 lines · Jan Beulich
Am I right in understanding that the restriction on 512 entries to be passed in is solely to cap the time that's being spent in the hypervisor without being
able to service softirq requests as well as while the domain lock is being held?
If that's the case, eliminating that restriction could be fairly strait forward by
putting the majority of the function body in a loop or, perhaps even better, callinghypercall_preempt_check()every so many entries and using the continuation mechanism.
Yes, true.
-- Keir
Quoted 14 lines
Quoted 1 line
Quoted 1 line
Keir Fraser <[email protected]> 02.07.09 09:37 >>>
Quoted 10 lines · Jan Beulich
Am I right in understanding that the restriction on 512 entries to be passed in is solely to cap the time that's being spent in the hypervisor without being
able to service softirq requests as well as while the domain lock is being held?
If that's the case, eliminating that restriction could be fairly strait forward by
putting the majority of the function body in a loop or, perhaps even better, callinghypercall_preempt_check()every so many entries and using the continuation mechanism.
Quoted 1 line
Yes, true.
Would you have time to look over this (so far only compile tested) patch, to see if there's anything obviously wrong (I admit I feel uncertain whenever it comes to touching the grant table code)?
Thanks, Jan
xen/common/compat/grant_table.c +28 -3
@@ -35,7 +35,9 @@ int compat_grant_table_op(unsigned int c {int rc =0 ;unsigned int i; +XEN_GUEST_HANDLE (void ) cnt_uop; +set_xen_guest_handle (cnt_uop,NULL );switch ( cmd ) {#define CASE (name) \
@@ -79,7 +81,7 @@ int compat_grant_table_op(unsigned int creturn do_grant_table_op (cmd, cmp_uop, count); } -if ( count >512 ) +if ( (int )count <0 ) rc = -EINVAL ;for ( i =0 ; i < count && rc ==0 ; )
@@ -128,6 +130,7 @@ int compat_grant_table_op(unsigned int c rc =gnttab_setup_table (guest_handle_cast (nat.uop, gnttab_setup_table_t),1 ); } } +ASSERT (rc <=0 );if ( rc ==0 ) {#define XLAT_gnttab_setup_table_HNDL_frame_list (_d_, _s_) \
@@ -163,12 +166,19 @@ int compat_grant_table_op(unsigned int c }if ( rc ==0 ) rc =gnttab_transfer (guest_handle_cast (nat.uop, gnttab_transfer_t), n); -if ( rc ==0 ) +if ( rc >0 ) + { +ASSERT (rc < n); + i -= n - rc; + n = rc; + } +if ( rc >=0 ) {XEN_GUEST_HANDLE (gnttab_transfer_compat_t) xfer; xfer =guest_handle_cast (cmp_uop, gnttab_transfer_compat_t);guest_handle_add_offset (xfer, i); + cnt_uop =guest_handle_cast (xfer, void);while ( n-- ) {guest_handle_add_offset (xfer,-1 );
@@ -201,12 +211,19 @@ int compat_grant_table_op(unsigned int c }if ( rc ==0 ) rc =gnttab_copy (guest_handle_cast (nat.uop, gnttab_copy_t), n); -if ( rc ==0 ) +if ( rc >0 ) + { +ASSERT (rc < n); + i -= n - rc; + n = rc; + } +if ( rc >=0 ) {XEN_GUEST_HANDLE (gnttab_copy_compat_t) copy; copy =guest_handle_cast (cmp_uop, gnttab_copy_compat_t);guest_handle_add_offset (copy, i); + cnt_uop =guest_handle_cast (copy, void);while ( n-- ) {guest_handle_add_offset (copy,-1 );
@@ -222,6 +239,14 @@ int compat_grant_table_op(unsigned int c } } +if ( rc >0 ) + { +ASSERT (i < count); +ASSERT (!guest_handle_is_null (cnt_uop)); + rc =hypercall_create_continuation (__HYPERVISOR_grant_table_op, +"ihi" , cmd, cnt_uop, count - i); + } +return rc; }
xen/common/grant_table.c +49 -1
140 lines not on this page · raw message
Quoted 5 lines · Jan Beulich
Quoted 1 line
Yes, true.
Would you have time to look over this (so far only compile tested) patch, to see if there's anything obviously wrong (I admit I feel uncertain whenever it comes to touching the grant table code)?
I feel the same looking at the compat code shims. ;-) The grant_table.c changes look about right to me.
-- Keir