>>> On Tue, May 15, 2007 at  3:45 AM, in message <[EMAIL PROTECTED]>,
Avi Kivity <[EMAIL PROTECTED]> wrote: 
> Gregory Haskins wrote:
>> Signed- off- by: Gregory Haskins <[EMAIL PROTECTED]>
>> ---
>>
>>  drivers/kvm/kvm.h      |    1 +
>>  drivers/kvm/kvm_main.c |   52 
>> ++++++++++++++++++++++++++++++++++++++++++------
>>  include/linux/kvm.h    |    1 +
>>  3 files changed, 48 insertions(+), 6 deletions(- )
>>
>> diff -- git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
>> index 7b5d5e6..f5731c4 100644
>> ---  a/drivers/kvm/kvm.h
>> +++ b/drivers/kvm/kvm.h
>> @@ - 333,6 +333,7 @@ struct kvm_vcpu_irq {
>>      int                  deferred;
>>      struct task_struct  *task;
>>      int                  guest_mode;
>> +    int                  eventfd;
>>   
> 
> Best to convert the fd to a filp when you install it.  This avoids the
> conversion during runtime and allows you to do error checking earlier.


That was my initial impression also, but then I realized there was a problem 
with that:  Eventfd doesnt appear to have any way to notify other entities when 
the fd is closed.  Therefore the filp could be left dangling in this case.  By 
using the fd instead, I can validate the pointer each time I need it.  Perhaps 
Davide will have a suggestion here.

Regardless, I do like the idea of checking the fd on assignment.  I will put an 
eventfd_fget() check into the ioctl too just to catch it early.  I might also 
add logic to invalidate irq.eventfd if the eventfd_fget() ever fails at runtime 
because userspace neglects to explicitly unregister (so we don't keep checking 
an invalid fd over and over).

-Greg

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel

Reply via email to