xref: /OK3568_Linux_fs/kernel/Documentation/virt/kvm/devices/vfio.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun
3*4882a593Smuzhiyun===================
4*4882a593SmuzhiyunVFIO virtual device
5*4882a593Smuzhiyun===================
6*4882a593Smuzhiyun
7*4882a593SmuzhiyunDevice types supported:
8*4882a593Smuzhiyun
9*4882a593Smuzhiyun  - KVM_DEV_TYPE_VFIO
10*4882a593Smuzhiyun
11*4882a593SmuzhiyunOnly one VFIO instance may be created per VM.  The created device
12*4882a593Smuzhiyuntracks VFIO groups in use by the VM and features of those groups
13*4882a593Smuzhiyunimportant to the correctness and acceleration of the VM.  As groups
14*4882a593Smuzhiyunare enabled and disabled for use by the VM, KVM should be updated
15*4882a593Smuzhiyunabout their presence.  When registered with KVM, a reference to the
16*4882a593SmuzhiyunVFIO-group is held by KVM.
17*4882a593Smuzhiyun
18*4882a593SmuzhiyunGroups:
19*4882a593Smuzhiyun  KVM_DEV_VFIO_GROUP
20*4882a593Smuzhiyun
21*4882a593SmuzhiyunKVM_DEV_VFIO_GROUP attributes:
22*4882a593Smuzhiyun  KVM_DEV_VFIO_GROUP_ADD: Add a VFIO group to VFIO-KVM device tracking
23*4882a593Smuzhiyun	kvm_device_attr.addr points to an int32_t file descriptor
24*4882a593Smuzhiyun	for the VFIO group.
25*4882a593Smuzhiyun  KVM_DEV_VFIO_GROUP_DEL: Remove a VFIO group from VFIO-KVM device tracking
26*4882a593Smuzhiyun	kvm_device_attr.addr points to an int32_t file descriptor
27*4882a593Smuzhiyun	for the VFIO group.
28*4882a593Smuzhiyun  KVM_DEV_VFIO_GROUP_SET_SPAPR_TCE: attaches a guest visible TCE table
29*4882a593Smuzhiyun	allocated by sPAPR KVM.
30*4882a593Smuzhiyun	kvm_device_attr.addr points to a struct::
31*4882a593Smuzhiyun
32*4882a593Smuzhiyun		struct kvm_vfio_spapr_tce {
33*4882a593Smuzhiyun			__s32	groupfd;
34*4882a593Smuzhiyun			__s32	tablefd;
35*4882a593Smuzhiyun		};
36*4882a593Smuzhiyun
37*4882a593Smuzhiyun	where:
38*4882a593Smuzhiyun
39*4882a593Smuzhiyun	- @groupfd is a file descriptor for a VFIO group;
40*4882a593Smuzhiyun	- @tablefd is a file descriptor for a TCE table allocated via
41*4882a593Smuzhiyun	  KVM_CREATE_SPAPR_TCE.
42