ANDROID: vfio: Add vfio_file_get_device
Add a function to get struct device from a VFIO file, this is would be used from kvm-vfio bridge for protected device assignment. Bug: 357781595 Bug: 348382247 Change-Id: I60026744e2bd65b290cee8eb439a542946255755 Signed-off-by: Mostafa Saleh <smostafa@google.com>
This commit is contained in:
@@ -479,6 +479,19 @@ void vfio_device_put_kvm(struct vfio_device *device)
|
||||
clear:
|
||||
device->kvm = NULL;
|
||||
}
|
||||
|
||||
static struct vfio_device *vfio_device_from_file(struct file *file);
|
||||
/**
|
||||
* vfio_file_get_device - Return struct device from vfio device fd
|
||||
* @file: VFIO device file
|
||||
*/
|
||||
struct device *vfio_file_get_device(struct file *file)
|
||||
{
|
||||
struct vfio_device *device = vfio_device_from_file(file);
|
||||
|
||||
return device ? device->dev : NULL;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(vfio_file_get_device);
|
||||
#endif
|
||||
|
||||
/* true if the vfio_device has open_device() called but not close_device() */
|
||||
|
||||
@@ -316,6 +316,7 @@ static inline bool vfio_file_has_dev(struct file *file, struct vfio_device *devi
|
||||
bool vfio_file_is_valid(struct file *file);
|
||||
bool vfio_file_enforced_coherent(struct file *file);
|
||||
void vfio_file_set_kvm(struct file *file, struct kvm *kvm);
|
||||
struct device *vfio_file_get_device(struct file *file);
|
||||
|
||||
#define VFIO_PIN_PAGES_MAX_ENTRIES (PAGE_SIZE/sizeof(unsigned long))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user