diff options
Diffstat (limited to 'Documentation/kvm/api.txt')
-rw-r--r-- | Documentation/kvm/api.txt | 208 |
1 files changed, 174 insertions, 34 deletions
diff --git a/Documentation/kvm/api.txt b/Documentation/kvm/api.txt index a237518e51b9..5f5b64982b1a 100644 --- a/Documentation/kvm/api.txt +++ b/Documentation/kvm/api.txt | |||
@@ -126,6 +126,10 @@ user fills in the size of the indices array in nmsrs, and in return | |||
126 | kvm adjusts nmsrs to reflect the actual number of msrs and fills in | 126 | kvm adjusts nmsrs to reflect the actual number of msrs and fills in |
127 | the indices array with their numbers. | 127 | the indices array with their numbers. |
128 | 128 | ||
129 | Note: if kvm indicates supports MCE (KVM_CAP_MCE), then the MCE bank MSRs are | ||
130 | not returned in the MSR list, as different vcpus can have a different number | ||
131 | of banks, as set via the KVM_X86_SETUP_MCE ioctl. | ||
132 | |||
129 | 4.4 KVM_CHECK_EXTENSION | 133 | 4.4 KVM_CHECK_EXTENSION |
130 | 134 | ||
131 | Capability: basic | 135 | Capability: basic |
@@ -160,29 +164,7 @@ Type: vm ioctl | |||
160 | Parameters: struct kvm_memory_region (in) | 164 | Parameters: struct kvm_memory_region (in) |
161 | Returns: 0 on success, -1 on error | 165 | Returns: 0 on success, -1 on error |
162 | 166 | ||
163 | struct kvm_memory_region { | 167 | This ioctl is obsolete and has been removed. |
164 | __u32 slot; | ||
165 | __u32 flags; | ||
166 | __u64 guest_phys_addr; | ||
167 | __u64 memory_size; /* bytes */ | ||
168 | }; | ||
169 | |||
170 | /* for kvm_memory_region::flags */ | ||
171 | #define KVM_MEM_LOG_DIRTY_PAGES 1UL | ||
172 | |||
173 | This ioctl allows the user to create or modify a guest physical memory | ||
174 | slot. When changing an existing slot, it may be moved in the guest | ||
175 | physical memory space, or its flags may be modified. It may not be | ||
176 | resized. Slots may not overlap. | ||
177 | |||
178 | The flags field supports just one flag, KVM_MEM_LOG_DIRTY_PAGES, which | ||
179 | instructs kvm to keep track of writes to memory within the slot. See | ||
180 | the KVM_GET_DIRTY_LOG ioctl. | ||
181 | |||
182 | It is recommended to use the KVM_SET_USER_MEMORY_REGION ioctl instead | ||
183 | of this API, if available. This newer API allows placing guest memory | ||
184 | at specified locations in the host address space, yielding better | ||
185 | control and easy access. | ||
186 | 168 | ||
187 | 4.6 KVM_CREATE_VCPU | 169 | 4.6 KVM_CREATE_VCPU |
188 | 170 | ||
@@ -226,17 +208,7 @@ Type: vm ioctl | |||
226 | Parameters: struct kvm_memory_alias (in) | 208 | Parameters: struct kvm_memory_alias (in) |
227 | Returns: 0 (success), -1 (error) | 209 | Returns: 0 (success), -1 (error) |
228 | 210 | ||
229 | struct kvm_memory_alias { | 211 | This ioctl is obsolete and has been removed. |
230 | __u32 slot; /* this has a different namespace than memory slots */ | ||
231 | __u32 flags; | ||
232 | __u64 guest_phys_addr; | ||
233 | __u64 memory_size; | ||
234 | __u64 target_phys_addr; | ||
235 | }; | ||
236 | |||
237 | Defines a guest physical address space region as an alias to another | ||
238 | region. Useful for aliased address, for example the VGA low memory | ||
239 | window. Should not be used with userspace memory. | ||
240 | 212 | ||
241 | 4.9 KVM_RUN | 213 | 4.9 KVM_RUN |
242 | 214 | ||
@@ -892,6 +864,174 @@ arguments. | |||
892 | This ioctl is only useful after KVM_CREATE_IRQCHIP. Without an in-kernel | 864 | This ioctl is only useful after KVM_CREATE_IRQCHIP. Without an in-kernel |
893 | irqchip, the multiprocessing state must be maintained by userspace. | 865 | irqchip, the multiprocessing state must be maintained by userspace. |
894 | 866 | ||
867 | 4.39 KVM_SET_IDENTITY_MAP_ADDR | ||
868 | |||
869 | Capability: KVM_CAP_SET_IDENTITY_MAP_ADDR | ||
870 | Architectures: x86 | ||
871 | Type: vm ioctl | ||
872 | Parameters: unsigned long identity (in) | ||
873 | Returns: 0 on success, -1 on error | ||
874 | |||
875 | This ioctl defines the physical address of a one-page region in the guest | ||
876 | physical address space. The region must be within the first 4GB of the | ||
877 | guest physical address space and must not conflict with any memory slot | ||
878 | or any mmio address. The guest may malfunction if it accesses this memory | ||
879 | region. | ||
880 | |||
881 | This ioctl is required on Intel-based hosts. This is needed on Intel hardware | ||
882 | because of a quirk in the virtualization implementation (see the internals | ||
883 | documentation when it pops into existence). | ||
884 | |||
885 | 4.40 KVM_SET_BOOT_CPU_ID | ||
886 | |||
887 | Capability: KVM_CAP_SET_BOOT_CPU_ID | ||
888 | Architectures: x86, ia64 | ||
889 | Type: vm ioctl | ||
890 | Parameters: unsigned long vcpu_id | ||
891 | Returns: 0 on success, -1 on error | ||
892 | |||
893 | Define which vcpu is the Bootstrap Processor (BSP). Values are the same | ||
894 | as the vcpu id in KVM_CREATE_VCPU. If this ioctl is not called, the default | ||
895 | is vcpu 0. | ||
896 | |||
897 | 4.41 KVM_GET_XSAVE | ||
898 | |||
899 | Capability: KVM_CAP_XSAVE | ||
900 | Architectures: x86 | ||
901 | Type: vcpu ioctl | ||
902 | Parameters: struct kvm_xsave (out) | ||
903 | Returns: 0 on success, -1 on error | ||
904 | |||
905 | struct kvm_xsave { | ||
906 | __u32 region[1024]; | ||
907 | }; | ||
908 | |||
909 | This ioctl would copy current vcpu's xsave struct to the userspace. | ||
910 | |||
911 | 4.42 KVM_SET_XSAVE | ||
912 | |||
913 | Capability: KVM_CAP_XSAVE | ||
914 | Architectures: x86 | ||
915 | Type: vcpu ioctl | ||
916 | Parameters: struct kvm_xsave (in) | ||
917 | Returns: 0 on success, -1 on error | ||
918 | |||
919 | struct kvm_xsave { | ||
920 | __u32 region[1024]; | ||
921 | }; | ||
922 | |||
923 | This ioctl would copy userspace's xsave struct to the kernel. | ||
924 | |||
925 | 4.43 KVM_GET_XCRS | ||
926 | |||
927 | Capability: KVM_CAP_XCRS | ||
928 | Architectures: x86 | ||
929 | Type: vcpu ioctl | ||
930 | Parameters: struct kvm_xcrs (out) | ||
931 | Returns: 0 on success, -1 on error | ||
932 | |||
933 | struct kvm_xcr { | ||
934 | __u32 xcr; | ||
935 | __u32 reserved; | ||
936 | __u64 value; | ||
937 | }; | ||
938 | |||
939 | struct kvm_xcrs { | ||
940 | __u32 nr_xcrs; | ||
941 | __u32 flags; | ||
942 | struct kvm_xcr xcrs[KVM_MAX_XCRS]; | ||
943 | __u64 padding[16]; | ||
944 | }; | ||
945 | |||
946 | This ioctl would copy current vcpu's xcrs to the userspace. | ||
947 | |||
948 | 4.44 KVM_SET_XCRS | ||
949 | |||
950 | Capability: KVM_CAP_XCRS | ||
951 | Architectures: x86 | ||
952 | Type: vcpu ioctl | ||
953 | Parameters: struct kvm_xcrs (in) | ||
954 | Returns: 0 on success, -1 on error | ||
955 | |||
956 | struct kvm_xcr { | ||
957 | __u32 xcr; | ||
958 | __u32 reserved; | ||
959 | __u64 value; | ||
960 | }; | ||
961 | |||
962 | struct kvm_xcrs { | ||
963 | __u32 nr_xcrs; | ||
964 | __u32 flags; | ||
965 | struct kvm_xcr xcrs[KVM_MAX_XCRS]; | ||
966 | __u64 padding[16]; | ||
967 | }; | ||
968 | |||
969 | This ioctl would set vcpu's xcr to the value userspace specified. | ||
970 | |||
971 | 4.45 KVM_GET_SUPPORTED_CPUID | ||
972 | |||
973 | Capability: KVM_CAP_EXT_CPUID | ||
974 | Architectures: x86 | ||
975 | Type: system ioctl | ||
976 | Parameters: struct kvm_cpuid2 (in/out) | ||
977 | Returns: 0 on success, -1 on error | ||
978 | |||
979 | struct kvm_cpuid2 { | ||
980 | __u32 nent; | ||
981 | __u32 padding; | ||
982 | struct kvm_cpuid_entry2 entries[0]; | ||
983 | }; | ||
984 | |||
985 | #define KVM_CPUID_FLAG_SIGNIFCANT_INDEX 1 | ||
986 | #define KVM_CPUID_FLAG_STATEFUL_FUNC 2 | ||
987 | #define KVM_CPUID_FLAG_STATE_READ_NEXT 4 | ||
988 | |||
989 | struct kvm_cpuid_entry2 { | ||
990 | __u32 function; | ||
991 | __u32 index; | ||
992 | __u32 flags; | ||
993 | __u32 eax; | ||
994 | __u32 ebx; | ||
995 | __u32 ecx; | ||
996 | __u32 edx; | ||
997 | __u32 padding[3]; | ||
998 | }; | ||
999 | |||
1000 | This ioctl returns x86 cpuid features which are supported by both the hardware | ||
1001 | and kvm. Userspace can use the information returned by this ioctl to | ||
1002 | construct cpuid information (for KVM_SET_CPUID2) that is consistent with | ||
1003 | hardware, kernel, and userspace capabilities, and with user requirements (for | ||
1004 | example, the user may wish to constrain cpuid to emulate older hardware, | ||
1005 | or for feature consistency across a cluster). | ||
1006 | |||
1007 | Userspace invokes KVM_GET_SUPPORTED_CPUID by passing a kvm_cpuid2 structure | ||
1008 | with the 'nent' field indicating the number of entries in the variable-size | ||
1009 | array 'entries'. If the number of entries is too low to describe the cpu | ||
1010 | capabilities, an error (E2BIG) is returned. If the number is too high, | ||
1011 | the 'nent' field is adjusted and an error (ENOMEM) is returned. If the | ||
1012 | number is just right, the 'nent' field is adjusted to the number of valid | ||
1013 | entries in the 'entries' array, which is then filled. | ||
1014 | |||
1015 | The entries returned are the host cpuid as returned by the cpuid instruction, | ||
1016 | with unknown or unsupported features masked out. The fields in each entry | ||
1017 | are defined as follows: | ||
1018 | |||
1019 | function: the eax value used to obtain the entry | ||
1020 | index: the ecx value used to obtain the entry (for entries that are | ||
1021 | affected by ecx) | ||
1022 | flags: an OR of zero or more of the following: | ||
1023 | KVM_CPUID_FLAG_SIGNIFCANT_INDEX: | ||
1024 | if the index field is valid | ||
1025 | KVM_CPUID_FLAG_STATEFUL_FUNC: | ||
1026 | if cpuid for this function returns different values for successive | ||
1027 | invocations; there will be several entries with the same function, | ||
1028 | all with this flag set | ||
1029 | KVM_CPUID_FLAG_STATE_READ_NEXT: | ||
1030 | for KVM_CPUID_FLAG_STATEFUL_FUNC entries, set if this entry is | ||
1031 | the first entry to be read by a cpu | ||
1032 | eax, ebx, ecx, edx: the values returned by the cpuid instruction for | ||
1033 | this function/index combination | ||
1034 | |||
895 | 5. The kvm_run structure | 1035 | 5. The kvm_run structure |
896 | 1036 | ||
897 | Application code obtains a pointer to the kvm_run structure by | 1037 | Application code obtains a pointer to the kvm_run structure by |