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:
Mostafa Saleh
2023-11-16 11:03:05 +00:00
parent 68c58efb37
commit 69ea9011bd
2 changed files with 14 additions and 0 deletions
+13
View File
@@ -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() */
+1
View File
@@ -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))