Re: [PATCH] Support for in-kernel mmio handlers

Dor Laor
2007-04-05T07:29:55Z

>> Signed-off-by: Gregory Haskins <ghaskins-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org>
>>
>> ---
>> drivers/kvm/kvm.h | 50
>+++++++++++++++++++++++++++++++++++++++++++++
>> drivers/kvm/kvm_main.c | 53
+++++++++++++++++++++++++++++++++++++++---
>-----
>> 2 files changed, 94 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
>> index fceeb84..3334730 100644
>> --- a/drivers/kvm/kvm.h
>> +++ b/drivers/kvm/kvm.h
>> @@ -236,6 +236,54 @@ struct kvm_pio_request {
>> int rep;
>> };
>>
>> +struct kvm_io_device {
>> + unsigned long (*read)(struct kvm_io_device *this,
>> + gpa_t addr,
>> + unsigned long length);
>> + void (*write)(struct kvm_io_device *this,
>> + gpa_t addr,
>> + unsigned long length,
>> + unsigned long val);
>>
>
>length could be just an int.
>
>> + int (*in_range)(struct kvm_io_device *this, gpa_t addr);
>>
>
>Do you see any reason to have this as a callback and not a pair of
gpas?

This way a device can register for a range that contains holes, this
would allow partial implementation in the kernel and part in user space.
Might be usefull for some VT optimization support (haven't though of a
specific one yet, but there's a good chance to be used.)

>
>> +
>> + void *private;
>> + struct list_head link;
>>
>
>Having these in an array would be much more efficient. A fixed size
>array of moderate size should suffice.

You can take it from my old apic code.