api.txt 126 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942
  1. The Definitive KVM (Kernel-based Virtual Machine) API Documentation
  2. ===================================================================
  3. 1. General description
  4. ----------------------
  5. The kvm API is a set of ioctls that are issued to control various aspects
  6. of a virtual machine. The ioctls belong to three classes
  7. - System ioctls: These query and set global attributes which affect the
  8. whole kvm subsystem. In addition a system ioctl is used to create
  9. virtual machines
  10. - VM ioctls: These query and set attributes that affect an entire virtual
  11. machine, for example memory layout. In addition a VM ioctl is used to
  12. create virtual cpus (vcpus).
  13. Only run VM ioctls from the same process (address space) that was used
  14. to create the VM.
  15. - vcpu ioctls: These query and set attributes that control the operation
  16. of a single virtual cpu.
  17. Only run vcpu ioctls from the same thread that was used to create the
  18. vcpu.
  19. 2. File descriptors
  20. -------------------
  21. The kvm API is centered around file descriptors. An initial
  22. open("/dev/kvm") obtains a handle to the kvm subsystem; this handle
  23. can be used to issue system ioctls. A KVM_CREATE_VM ioctl on this
  24. handle will create a VM file descriptor which can be used to issue VM
  25. ioctls. A KVM_CREATE_VCPU ioctl on a VM fd will create a virtual cpu
  26. and return a file descriptor pointing to it. Finally, ioctls on a vcpu
  27. fd can be used to control the vcpu, including the important task of
  28. actually running guest code.
  29. In general file descriptors can be migrated among processes by means
  30. of fork() and the SCM_RIGHTS facility of unix domain socket. These
  31. kinds of tricks are explicitly not supported by kvm. While they will
  32. not cause harm to the host, their actual behavior is not guaranteed by
  33. the API. The only supported use is one virtual machine per process,
  34. and one vcpu per thread.
  35. 3. Extensions
  36. -------------
  37. As of Linux 2.6.22, the KVM ABI has been stabilized: no backward
  38. incompatible change are allowed. However, there is an extension
  39. facility that allows backward-compatible extensions to the API to be
  40. queried and used.
  41. The extension mechanism is not based on the Linux version number.
  42. Instead, kvm defines extension identifiers and a facility to query
  43. whether a particular extension identifier is available. If it is, a
  44. set of ioctls is available for application use.
  45. 4. API description
  46. ------------------
  47. This section describes ioctls that can be used to control kvm guests.
  48. For each ioctl, the following information is provided along with a
  49. description:
  50. Capability: which KVM extension provides this ioctl. Can be 'basic',
  51. which means that is will be provided by any kernel that supports
  52. API version 12 (see section 4.1), a KVM_CAP_xyz constant, which
  53. means availability needs to be checked with KVM_CHECK_EXTENSION
  54. (see section 4.4), or 'none' which means that while not all kernels
  55. support this ioctl, there's no capability bit to check its
  56. availability: for kernels that don't support the ioctl,
  57. the ioctl returns -ENOTTY.
  58. Architectures: which instruction set architectures provide this ioctl.
  59. x86 includes both i386 and x86_64.
  60. Type: system, vm, or vcpu.
  61. Parameters: what parameters are accepted by the ioctl.
  62. Returns: the return value. General error numbers (EBADF, ENOMEM, EINVAL)
  63. are not detailed, but errors with specific meanings are.
  64. 4.1 KVM_GET_API_VERSION
  65. Capability: basic
  66. Architectures: all
  67. Type: system ioctl
  68. Parameters: none
  69. Returns: the constant KVM_API_VERSION (=12)
  70. This identifies the API version as the stable kvm API. It is not
  71. expected that this number will change. However, Linux 2.6.20 and
  72. 2.6.21 report earlier versions; these are not documented and not
  73. supported. Applications should refuse to run if KVM_GET_API_VERSION
  74. returns a value other than 12. If this check passes, all ioctls
  75. described as 'basic' will be available.
  76. 4.2 KVM_CREATE_VM
  77. Capability: basic
  78. Architectures: all
  79. Type: system ioctl
  80. Parameters: machine type identifier (KVM_VM_*)
  81. Returns: a VM fd that can be used to control the new virtual machine.
  82. The new VM has no virtual cpus and no memory. An mmap() of a VM fd
  83. will access the virtual machine's physical address space; offset zero
  84. corresponds to guest physical address zero. Use of mmap() on a VM fd
  85. is discouraged if userspace memory allocation (KVM_CAP_USER_MEMORY) is
  86. available.
  87. You most certainly want to use 0 as machine type.
  88. In order to create user controlled virtual machines on S390, check
  89. KVM_CAP_S390_UCONTROL and use the flag KVM_VM_S390_UCONTROL as
  90. privileged user (CAP_SYS_ADMIN).
  91. 4.3 KVM_GET_MSR_INDEX_LIST
  92. Capability: basic
  93. Architectures: x86
  94. Type: system
  95. Parameters: struct kvm_msr_list (in/out)
  96. Returns: 0 on success; -1 on error
  97. Errors:
  98. E2BIG: the msr index list is to be to fit in the array specified by
  99. the user.
  100. struct kvm_msr_list {
  101. __u32 nmsrs; /* number of msrs in entries */
  102. __u32 indices[0];
  103. };
  104. This ioctl returns the guest msrs that are supported. The list varies
  105. by kvm version and host processor, but does not change otherwise. The
  106. user fills in the size of the indices array in nmsrs, and in return
  107. kvm adjusts nmsrs to reflect the actual number of msrs and fills in
  108. the indices array with their numbers.
  109. Note: if kvm indicates supports MCE (KVM_CAP_MCE), then the MCE bank MSRs are
  110. not returned in the MSR list, as different vcpus can have a different number
  111. of banks, as set via the KVM_X86_SETUP_MCE ioctl.
  112. 4.4 KVM_CHECK_EXTENSION
  113. Capability: basic, KVM_CAP_CHECK_EXTENSION_VM for vm ioctl
  114. Architectures: all
  115. Type: system ioctl, vm ioctl
  116. Parameters: extension identifier (KVM_CAP_*)
  117. Returns: 0 if unsupported; 1 (or some other positive integer) if supported
  118. The API allows the application to query about extensions to the core
  119. kvm API. Userspace passes an extension identifier (an integer) and
  120. receives an integer that describes the extension availability.
  121. Generally 0 means no and 1 means yes, but some extensions may report
  122. additional information in the integer return value.
  123. Based on their initialization different VMs may have different capabilities.
  124. It is thus encouraged to use the vm ioctl to query for capabilities (available
  125. with KVM_CAP_CHECK_EXTENSION_VM on the vm fd)
  126. 4.5 KVM_GET_VCPU_MMAP_SIZE
  127. Capability: basic
  128. Architectures: all
  129. Type: system ioctl
  130. Parameters: none
  131. Returns: size of vcpu mmap area, in bytes
  132. The KVM_RUN ioctl (cf.) communicates with userspace via a shared
  133. memory region. This ioctl returns the size of that region. See the
  134. KVM_RUN documentation for details.
  135. 4.6 KVM_SET_MEMORY_REGION
  136. Capability: basic
  137. Architectures: all
  138. Type: vm ioctl
  139. Parameters: struct kvm_memory_region (in)
  140. Returns: 0 on success, -1 on error
  141. This ioctl is obsolete and has been removed.
  142. 4.7 KVM_CREATE_VCPU
  143. Capability: basic
  144. Architectures: all
  145. Type: vm ioctl
  146. Parameters: vcpu id (apic id on x86)
  147. Returns: vcpu fd on success, -1 on error
  148. This API adds a vcpu to a virtual machine. No more than max_vcpus may be added.
  149. The vcpu id is an integer in the range [0, max_vcpu_id).
  150. The recommended max_vcpus value can be retrieved using the KVM_CAP_NR_VCPUS of
  151. the KVM_CHECK_EXTENSION ioctl() at run-time.
  152. The maximum possible value for max_vcpus can be retrieved using the
  153. KVM_CAP_MAX_VCPUS of the KVM_CHECK_EXTENSION ioctl() at run-time.
  154. If the KVM_CAP_NR_VCPUS does not exist, you should assume that max_vcpus is 4
  155. cpus max.
  156. If the KVM_CAP_MAX_VCPUS does not exist, you should assume that max_vcpus is
  157. same as the value returned from KVM_CAP_NR_VCPUS.
  158. The maximum possible value for max_vcpu_id can be retrieved using the
  159. KVM_CAP_MAX_VCPU_ID of the KVM_CHECK_EXTENSION ioctl() at run-time.
  160. If the KVM_CAP_MAX_VCPU_ID does not exist, you should assume that max_vcpu_id
  161. is the same as the value returned from KVM_CAP_MAX_VCPUS.
  162. On powerpc using book3s_hv mode, the vcpus are mapped onto virtual
  163. threads in one or more virtual CPU cores. (This is because the
  164. hardware requires all the hardware threads in a CPU core to be in the
  165. same partition.) The KVM_CAP_PPC_SMT capability indicates the number
  166. of vcpus per virtual core (vcore). The vcore id is obtained by
  167. dividing the vcpu id by the number of vcpus per vcore. The vcpus in a
  168. given vcore will always be in the same physical core as each other
  169. (though that might be a different physical core from time to time).
  170. Userspace can control the threading (SMT) mode of the guest by its
  171. allocation of vcpu ids. For example, if userspace wants
  172. single-threaded guest vcpus, it should make all vcpu ids be a multiple
  173. of the number of vcpus per vcore.
  174. For virtual cpus that have been created with S390 user controlled virtual
  175. machines, the resulting vcpu fd can be memory mapped at page offset
  176. KVM_S390_SIE_PAGE_OFFSET in order to obtain a memory map of the virtual
  177. cpu's hardware control block.
  178. 4.8 KVM_GET_DIRTY_LOG (vm ioctl)
  179. Capability: basic
  180. Architectures: x86
  181. Type: vm ioctl
  182. Parameters: struct kvm_dirty_log (in/out)
  183. Returns: 0 on success, -1 on error
  184. /* for KVM_GET_DIRTY_LOG */
  185. struct kvm_dirty_log {
  186. __u32 slot;
  187. __u32 padding;
  188. union {
  189. void __user *dirty_bitmap; /* one bit per page */
  190. __u64 padding;
  191. };
  192. };
  193. Given a memory slot, return a bitmap containing any pages dirtied
  194. since the last call to this ioctl. Bit 0 is the first page in the
  195. memory slot. Ensure the entire structure is cleared to avoid padding
  196. issues.
  197. If KVM_CAP_MULTI_ADDRESS_SPACE is available, bits 16-31 specifies
  198. the address space for which you want to return the dirty bitmap.
  199. They must be less than the value that KVM_CHECK_EXTENSION returns for
  200. the KVM_CAP_MULTI_ADDRESS_SPACE capability.
  201. 4.9 KVM_SET_MEMORY_ALIAS
  202. Capability: basic
  203. Architectures: x86
  204. Type: vm ioctl
  205. Parameters: struct kvm_memory_alias (in)
  206. Returns: 0 (success), -1 (error)
  207. This ioctl is obsolete and has been removed.
  208. 4.10 KVM_RUN
  209. Capability: basic
  210. Architectures: all
  211. Type: vcpu ioctl
  212. Parameters: none
  213. Returns: 0 on success, -1 on error
  214. Errors:
  215. EINTR: an unmasked signal is pending
  216. This ioctl is used to run a guest virtual cpu. While there are no
  217. explicit parameters, there is an implicit parameter block that can be
  218. obtained by mmap()ing the vcpu fd at offset 0, with the size given by
  219. KVM_GET_VCPU_MMAP_SIZE. The parameter block is formatted as a 'struct
  220. kvm_run' (see below).
  221. 4.11 KVM_GET_REGS
  222. Capability: basic
  223. Architectures: all except ARM, arm64
  224. Type: vcpu ioctl
  225. Parameters: struct kvm_regs (out)
  226. Returns: 0 on success, -1 on error
  227. Reads the general purpose registers from the vcpu.
  228. /* x86 */
  229. struct kvm_regs {
  230. /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
  231. __u64 rax, rbx, rcx, rdx;
  232. __u64 rsi, rdi, rsp, rbp;
  233. __u64 r8, r9, r10, r11;
  234. __u64 r12, r13, r14, r15;
  235. __u64 rip, rflags;
  236. };
  237. /* mips */
  238. struct kvm_regs {
  239. /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
  240. __u64 gpr[32];
  241. __u64 hi;
  242. __u64 lo;
  243. __u64 pc;
  244. };
  245. 4.12 KVM_SET_REGS
  246. Capability: basic
  247. Architectures: all except ARM, arm64
  248. Type: vcpu ioctl
  249. Parameters: struct kvm_regs (in)
  250. Returns: 0 on success, -1 on error
  251. Writes the general purpose registers into the vcpu.
  252. See KVM_GET_REGS for the data structure.
  253. 4.13 KVM_GET_SREGS
  254. Capability: basic
  255. Architectures: x86, ppc
  256. Type: vcpu ioctl
  257. Parameters: struct kvm_sregs (out)
  258. Returns: 0 on success, -1 on error
  259. Reads special registers from the vcpu.
  260. /* x86 */
  261. struct kvm_sregs {
  262. struct kvm_segment cs, ds, es, fs, gs, ss;
  263. struct kvm_segment tr, ldt;
  264. struct kvm_dtable gdt, idt;
  265. __u64 cr0, cr2, cr3, cr4, cr8;
  266. __u64 efer;
  267. __u64 apic_base;
  268. __u64 interrupt_bitmap[(KVM_NR_INTERRUPTS + 63) / 64];
  269. };
  270. /* ppc -- see arch/powerpc/include/uapi/asm/kvm.h */
  271. interrupt_bitmap is a bitmap of pending external interrupts. At most
  272. one bit may be set. This interrupt has been acknowledged by the APIC
  273. but not yet injected into the cpu core.
  274. 4.14 KVM_SET_SREGS
  275. Capability: basic
  276. Architectures: x86, ppc
  277. Type: vcpu ioctl
  278. Parameters: struct kvm_sregs (in)
  279. Returns: 0 on success, -1 on error
  280. Writes special registers into the vcpu. See KVM_GET_SREGS for the
  281. data structures.
  282. 4.15 KVM_TRANSLATE
  283. Capability: basic
  284. Architectures: x86
  285. Type: vcpu ioctl
  286. Parameters: struct kvm_translation (in/out)
  287. Returns: 0 on success, -1 on error
  288. Translates a virtual address according to the vcpu's current address
  289. translation mode.
  290. struct kvm_translation {
  291. /* in */
  292. __u64 linear_address;
  293. /* out */
  294. __u64 physical_address;
  295. __u8 valid;
  296. __u8 writeable;
  297. __u8 usermode;
  298. __u8 pad[5];
  299. };
  300. 4.16 KVM_INTERRUPT
  301. Capability: basic
  302. Architectures: x86, ppc, mips
  303. Type: vcpu ioctl
  304. Parameters: struct kvm_interrupt (in)
  305. Returns: 0 on success, negative on failure.
  306. Queues a hardware interrupt vector to be injected.
  307. /* for KVM_INTERRUPT */
  308. struct kvm_interrupt {
  309. /* in */
  310. __u32 irq;
  311. };
  312. X86:
  313. Returns: 0 on success,
  314. -EEXIST if an interrupt is already enqueued
  315. -EINVAL the the irq number is invalid
  316. -ENXIO if the PIC is in the kernel
  317. -EFAULT if the pointer is invalid
  318. Note 'irq' is an interrupt vector, not an interrupt pin or line. This
  319. ioctl is useful if the in-kernel PIC is not used.
  320. PPC:
  321. Queues an external interrupt to be injected. This ioctl is overleaded
  322. with 3 different irq values:
  323. a) KVM_INTERRUPT_SET
  324. This injects an edge type external interrupt into the guest once it's ready
  325. to receive interrupts. When injected, the interrupt is done.
  326. b) KVM_INTERRUPT_UNSET
  327. This unsets any pending interrupt.
  328. Only available with KVM_CAP_PPC_UNSET_IRQ.
  329. c) KVM_INTERRUPT_SET_LEVEL
  330. This injects a level type external interrupt into the guest context. The
  331. interrupt stays pending until a specific ioctl with KVM_INTERRUPT_UNSET
  332. is triggered.
  333. Only available with KVM_CAP_PPC_IRQ_LEVEL.
  334. Note that any value for 'irq' other than the ones stated above is invalid
  335. and incurs unexpected behavior.
  336. MIPS:
  337. Queues an external interrupt to be injected into the virtual CPU. A negative
  338. interrupt number dequeues the interrupt.
  339. 4.17 KVM_DEBUG_GUEST
  340. Capability: basic
  341. Architectures: none
  342. Type: vcpu ioctl
  343. Parameters: none)
  344. Returns: -1 on error
  345. Support for this has been removed. Use KVM_SET_GUEST_DEBUG instead.
  346. 4.18 KVM_GET_MSRS
  347. Capability: basic
  348. Architectures: x86
  349. Type: vcpu ioctl
  350. Parameters: struct kvm_msrs (in/out)
  351. Returns: 0 on success, -1 on error
  352. Reads model-specific registers from the vcpu. Supported msr indices can
  353. be obtained using KVM_GET_MSR_INDEX_LIST.
  354. struct kvm_msrs {
  355. __u32 nmsrs; /* number of msrs in entries */
  356. __u32 pad;
  357. struct kvm_msr_entry entries[0];
  358. };
  359. struct kvm_msr_entry {
  360. __u32 index;
  361. __u32 reserved;
  362. __u64 data;
  363. };
  364. Application code should set the 'nmsrs' member (which indicates the
  365. size of the entries array) and the 'index' member of each array entry.
  366. kvm will fill in the 'data' member.
  367. 4.19 KVM_SET_MSRS
  368. Capability: basic
  369. Architectures: x86
  370. Type: vcpu ioctl
  371. Parameters: struct kvm_msrs (in)
  372. Returns: 0 on success, -1 on error
  373. Writes model-specific registers to the vcpu. See KVM_GET_MSRS for the
  374. data structures.
  375. Application code should set the 'nmsrs' member (which indicates the
  376. size of the entries array), and the 'index' and 'data' members of each
  377. array entry.
  378. 4.20 KVM_SET_CPUID
  379. Capability: basic
  380. Architectures: x86
  381. Type: vcpu ioctl
  382. Parameters: struct kvm_cpuid (in)
  383. Returns: 0 on success, -1 on error
  384. Defines the vcpu responses to the cpuid instruction. Applications
  385. should use the KVM_SET_CPUID2 ioctl if available.
  386. struct kvm_cpuid_entry {
  387. __u32 function;
  388. __u32 eax;
  389. __u32 ebx;
  390. __u32 ecx;
  391. __u32 edx;
  392. __u32 padding;
  393. };
  394. /* for KVM_SET_CPUID */
  395. struct kvm_cpuid {
  396. __u32 nent;
  397. __u32 padding;
  398. struct kvm_cpuid_entry entries[0];
  399. };
  400. 4.21 KVM_SET_SIGNAL_MASK
  401. Capability: basic
  402. Architectures: all
  403. Type: vcpu ioctl
  404. Parameters: struct kvm_signal_mask (in)
  405. Returns: 0 on success, -1 on error
  406. Defines which signals are blocked during execution of KVM_RUN. This
  407. signal mask temporarily overrides the threads signal mask. Any
  408. unblocked signal received (except SIGKILL and SIGSTOP, which retain
  409. their traditional behaviour) will cause KVM_RUN to return with -EINTR.
  410. Note the signal will only be delivered if not blocked by the original
  411. signal mask.
  412. /* for KVM_SET_SIGNAL_MASK */
  413. struct kvm_signal_mask {
  414. __u32 len;
  415. __u8 sigset[0];
  416. };
  417. 4.22 KVM_GET_FPU
  418. Capability: basic
  419. Architectures: x86
  420. Type: vcpu ioctl
  421. Parameters: struct kvm_fpu (out)
  422. Returns: 0 on success, -1 on error
  423. Reads the floating point state from the vcpu.
  424. /* for KVM_GET_FPU and KVM_SET_FPU */
  425. struct kvm_fpu {
  426. __u8 fpr[8][16];
  427. __u16 fcw;
  428. __u16 fsw;
  429. __u8 ftwx; /* in fxsave format */
  430. __u8 pad1;
  431. __u16 last_opcode;
  432. __u64 last_ip;
  433. __u64 last_dp;
  434. __u8 xmm[16][16];
  435. __u32 mxcsr;
  436. __u32 pad2;
  437. };
  438. 4.23 KVM_SET_FPU
  439. Capability: basic
  440. Architectures: x86
  441. Type: vcpu ioctl
  442. Parameters: struct kvm_fpu (in)
  443. Returns: 0 on success, -1 on error
  444. Writes the floating point state to the vcpu.
  445. /* for KVM_GET_FPU and KVM_SET_FPU */
  446. struct kvm_fpu {
  447. __u8 fpr[8][16];
  448. __u16 fcw;
  449. __u16 fsw;
  450. __u8 ftwx; /* in fxsave format */
  451. __u8 pad1;
  452. __u16 last_opcode;
  453. __u64 last_ip;
  454. __u64 last_dp;
  455. __u8 xmm[16][16];
  456. __u32 mxcsr;
  457. __u32 pad2;
  458. };
  459. 4.24 KVM_CREATE_IRQCHIP
  460. Capability: KVM_CAP_IRQCHIP, KVM_CAP_S390_IRQCHIP (s390)
  461. Architectures: x86, ARM, arm64, s390
  462. Type: vm ioctl
  463. Parameters: none
  464. Returns: 0 on success, -1 on error
  465. Creates an interrupt controller model in the kernel.
  466. On x86, creates a virtual ioapic, a virtual PIC (two PICs, nested), and sets up
  467. future vcpus to have a local APIC. IRQ routing for GSIs 0-15 is set to both
  468. PIC and IOAPIC; GSI 16-23 only go to the IOAPIC.
  469. On ARM/arm64, a GICv2 is created. Any other GIC versions require the usage of
  470. KVM_CREATE_DEVICE, which also supports creating a GICv2. Using
  471. KVM_CREATE_DEVICE is preferred over KVM_CREATE_IRQCHIP for GICv2.
  472. On s390, a dummy irq routing table is created.
  473. Note that on s390 the KVM_CAP_S390_IRQCHIP vm capability needs to be enabled
  474. before KVM_CREATE_IRQCHIP can be used.
  475. 4.25 KVM_IRQ_LINE
  476. Capability: KVM_CAP_IRQCHIP
  477. Architectures: x86, arm, arm64
  478. Type: vm ioctl
  479. Parameters: struct kvm_irq_level
  480. Returns: 0 on success, -1 on error
  481. Sets the level of a GSI input to the interrupt controller model in the kernel.
  482. On some architectures it is required that an interrupt controller model has
  483. been previously created with KVM_CREATE_IRQCHIP. Note that edge-triggered
  484. interrupts require the level to be set to 1 and then back to 0.
  485. On real hardware, interrupt pins can be active-low or active-high. This
  486. does not matter for the level field of struct kvm_irq_level: 1 always
  487. means active (asserted), 0 means inactive (deasserted).
  488. x86 allows the operating system to program the interrupt polarity
  489. (active-low/active-high) for level-triggered interrupts, and KVM used
  490. to consider the polarity. However, due to bitrot in the handling of
  491. active-low interrupts, the above convention is now valid on x86 too.
  492. This is signaled by KVM_CAP_X86_IOAPIC_POLARITY_IGNORED. Userspace
  493. should not present interrupts to the guest as active-low unless this
  494. capability is present (or unless it is not using the in-kernel irqchip,
  495. of course).
  496. ARM/arm64 can signal an interrupt either at the CPU level, or at the
  497. in-kernel irqchip (GIC), and for in-kernel irqchip can tell the GIC to
  498. use PPIs designated for specific cpus. The irq field is interpreted
  499. like this:
  500.  bits: | 31 ... 24 | 23 ... 16 | 15 ... 0 |
  501. field: | irq_type | vcpu_index | irq_id |
  502. The irq_type field has the following values:
  503. - irq_type[0]: out-of-kernel GIC: irq_id 0 is IRQ, irq_id 1 is FIQ
  504. - irq_type[1]: in-kernel GIC: SPI, irq_id between 32 and 1019 (incl.)
  505. (the vcpu_index field is ignored)
  506. - irq_type[2]: in-kernel GIC: PPI, irq_id between 16 and 31 (incl.)
  507. (The irq_id field thus corresponds nicely to the IRQ ID in the ARM GIC specs)
  508. In both cases, level is used to assert/deassert the line.
  509. struct kvm_irq_level {
  510. union {
  511. __u32 irq; /* GSI */
  512. __s32 status; /* not used for KVM_IRQ_LEVEL */
  513. };
  514. __u32 level; /* 0 or 1 */
  515. };
  516. 4.26 KVM_GET_IRQCHIP
  517. Capability: KVM_CAP_IRQCHIP
  518. Architectures: x86
  519. Type: vm ioctl
  520. Parameters: struct kvm_irqchip (in/out)
  521. Returns: 0 on success, -1 on error
  522. Reads the state of a kernel interrupt controller created with
  523. KVM_CREATE_IRQCHIP into a buffer provided by the caller.
  524. struct kvm_irqchip {
  525. __u32 chip_id; /* 0 = PIC1, 1 = PIC2, 2 = IOAPIC */
  526. __u32 pad;
  527. union {
  528. char dummy[512]; /* reserving space */
  529. struct kvm_pic_state pic;
  530. struct kvm_ioapic_state ioapic;
  531. } chip;
  532. };
  533. 4.27 KVM_SET_IRQCHIP
  534. Capability: KVM_CAP_IRQCHIP
  535. Architectures: x86
  536. Type: vm ioctl
  537. Parameters: struct kvm_irqchip (in)
  538. Returns: 0 on success, -1 on error
  539. Sets the state of a kernel interrupt controller created with
  540. KVM_CREATE_IRQCHIP from a buffer provided by the caller.
  541. struct kvm_irqchip {
  542. __u32 chip_id; /* 0 = PIC1, 1 = PIC2, 2 = IOAPIC */
  543. __u32 pad;
  544. union {
  545. char dummy[512]; /* reserving space */
  546. struct kvm_pic_state pic;
  547. struct kvm_ioapic_state ioapic;
  548. } chip;
  549. };
  550. 4.28 KVM_XEN_HVM_CONFIG
  551. Capability: KVM_CAP_XEN_HVM
  552. Architectures: x86
  553. Type: vm ioctl
  554. Parameters: struct kvm_xen_hvm_config (in)
  555. Returns: 0 on success, -1 on error
  556. Sets the MSR that the Xen HVM guest uses to initialize its hypercall
  557. page, and provides the starting address and size of the hypercall
  558. blobs in userspace. When the guest writes the MSR, kvm copies one
  559. page of a blob (32- or 64-bit, depending on the vcpu mode) to guest
  560. memory.
  561. struct kvm_xen_hvm_config {
  562. __u32 flags;
  563. __u32 msr;
  564. __u64 blob_addr_32;
  565. __u64 blob_addr_64;
  566. __u8 blob_size_32;
  567. __u8 blob_size_64;
  568. __u8 pad2[30];
  569. };
  570. 4.29 KVM_GET_CLOCK
  571. Capability: KVM_CAP_ADJUST_CLOCK
  572. Architectures: x86
  573. Type: vm ioctl
  574. Parameters: struct kvm_clock_data (out)
  575. Returns: 0 on success, -1 on error
  576. Gets the current timestamp of kvmclock as seen by the current guest. In
  577. conjunction with KVM_SET_CLOCK, it is used to ensure monotonicity on scenarios
  578. such as migration.
  579. When KVM_CAP_ADJUST_CLOCK is passed to KVM_CHECK_EXTENSION, it returns the
  580. set of bits that KVM can return in struct kvm_clock_data's flag member.
  581. The only flag defined now is KVM_CLOCK_TSC_STABLE. If set, the returned
  582. value is the exact kvmclock value seen by all VCPUs at the instant
  583. when KVM_GET_CLOCK was called. If clear, the returned value is simply
  584. CLOCK_MONOTONIC plus a constant offset; the offset can be modified
  585. with KVM_SET_CLOCK. KVM will try to make all VCPUs follow this clock,
  586. but the exact value read by each VCPU could differ, because the host
  587. TSC is not stable.
  588. struct kvm_clock_data {
  589. __u64 clock; /* kvmclock current value */
  590. __u32 flags;
  591. __u32 pad[9];
  592. };
  593. 4.30 KVM_SET_CLOCK
  594. Capability: KVM_CAP_ADJUST_CLOCK
  595. Architectures: x86
  596. Type: vm ioctl
  597. Parameters: struct kvm_clock_data (in)
  598. Returns: 0 on success, -1 on error
  599. Sets the current timestamp of kvmclock to the value specified in its parameter.
  600. In conjunction with KVM_GET_CLOCK, it is used to ensure monotonicity on scenarios
  601. such as migration.
  602. struct kvm_clock_data {
  603. __u64 clock; /* kvmclock current value */
  604. __u32 flags;
  605. __u32 pad[9];
  606. };
  607. 4.31 KVM_GET_VCPU_EVENTS
  608. Capability: KVM_CAP_VCPU_EVENTS
  609. Extended by: KVM_CAP_INTR_SHADOW
  610. Architectures: x86
  611. Type: vm ioctl
  612. Parameters: struct kvm_vcpu_event (out)
  613. Returns: 0 on success, -1 on error
  614. Gets currently pending exceptions, interrupts, and NMIs as well as related
  615. states of the vcpu.
  616. struct kvm_vcpu_events {
  617. struct {
  618. __u8 injected;
  619. __u8 nr;
  620. __u8 has_error_code;
  621. __u8 pad;
  622. __u32 error_code;
  623. } exception;
  624. struct {
  625. __u8 injected;
  626. __u8 nr;
  627. __u8 soft;
  628. __u8 shadow;
  629. } interrupt;
  630. struct {
  631. __u8 injected;
  632. __u8 pending;
  633. __u8 masked;
  634. __u8 pad;
  635. } nmi;
  636. __u32 sipi_vector;
  637. __u32 flags;
  638. struct {
  639. __u8 smm;
  640. __u8 pending;
  641. __u8 smm_inside_nmi;
  642. __u8 latched_init;
  643. } smi;
  644. };
  645. Only two fields are defined in the flags field:
  646. - KVM_VCPUEVENT_VALID_SHADOW may be set in the flags field to signal that
  647. interrupt.shadow contains a valid state.
  648. - KVM_VCPUEVENT_VALID_SMM may be set in the flags field to signal that
  649. smi contains a valid state.
  650. 4.32 KVM_SET_VCPU_EVENTS
  651. Capability: KVM_CAP_VCPU_EVENTS
  652. Extended by: KVM_CAP_INTR_SHADOW
  653. Architectures: x86
  654. Type: vm ioctl
  655. Parameters: struct kvm_vcpu_event (in)
  656. Returns: 0 on success, -1 on error
  657. Set pending exceptions, interrupts, and NMIs as well as related states of the
  658. vcpu.
  659. See KVM_GET_VCPU_EVENTS for the data structure.
  660. Fields that may be modified asynchronously by running VCPUs can be excluded
  661. from the update. These fields are nmi.pending, sipi_vector, smi.smm,
  662. smi.pending. Keep the corresponding bits in the flags field cleared to
  663. suppress overwriting the current in-kernel state. The bits are:
  664. KVM_VCPUEVENT_VALID_NMI_PENDING - transfer nmi.pending to the kernel
  665. KVM_VCPUEVENT_VALID_SIPI_VECTOR - transfer sipi_vector
  666. KVM_VCPUEVENT_VALID_SMM - transfer the smi sub-struct.
  667. If KVM_CAP_INTR_SHADOW is available, KVM_VCPUEVENT_VALID_SHADOW can be set in
  668. the flags field to signal that interrupt.shadow contains a valid state and
  669. shall be written into the VCPU.
  670. KVM_VCPUEVENT_VALID_SMM can only be set if KVM_CAP_X86_SMM is available.
  671. 4.33 KVM_GET_DEBUGREGS
  672. Capability: KVM_CAP_DEBUGREGS
  673. Architectures: x86
  674. Type: vm ioctl
  675. Parameters: struct kvm_debugregs (out)
  676. Returns: 0 on success, -1 on error
  677. Reads debug registers from the vcpu.
  678. struct kvm_debugregs {
  679. __u64 db[4];
  680. __u64 dr6;
  681. __u64 dr7;
  682. __u64 flags;
  683. __u64 reserved[9];
  684. };
  685. 4.34 KVM_SET_DEBUGREGS
  686. Capability: KVM_CAP_DEBUGREGS
  687. Architectures: x86
  688. Type: vm ioctl
  689. Parameters: struct kvm_debugregs (in)
  690. Returns: 0 on success, -1 on error
  691. Writes debug registers into the vcpu.
  692. See KVM_GET_DEBUGREGS for the data structure. The flags field is unused
  693. yet and must be cleared on entry.
  694. 4.35 KVM_SET_USER_MEMORY_REGION
  695. Capability: KVM_CAP_USER_MEM
  696. Architectures: all
  697. Type: vm ioctl
  698. Parameters: struct kvm_userspace_memory_region (in)
  699. Returns: 0 on success, -1 on error
  700. struct kvm_userspace_memory_region {
  701. __u32 slot;
  702. __u32 flags;
  703. __u64 guest_phys_addr;
  704. __u64 memory_size; /* bytes */
  705. __u64 userspace_addr; /* start of the userspace allocated memory */
  706. };
  707. /* for kvm_memory_region::flags */
  708. #define KVM_MEM_LOG_DIRTY_PAGES (1UL << 0)
  709. #define KVM_MEM_READONLY (1UL << 1)
  710. This ioctl allows the user to create or modify a guest physical memory
  711. slot. When changing an existing slot, it may be moved in the guest
  712. physical memory space, or its flags may be modified. It may not be
  713. resized. Slots may not overlap in guest physical address space.
  714. If KVM_CAP_MULTI_ADDRESS_SPACE is available, bits 16-31 of "slot"
  715. specifies the address space which is being modified. They must be
  716. less than the value that KVM_CHECK_EXTENSION returns for the
  717. KVM_CAP_MULTI_ADDRESS_SPACE capability. Slots in separate address spaces
  718. are unrelated; the restriction on overlapping slots only applies within
  719. each address space.
  720. Memory for the region is taken starting at the address denoted by the
  721. field userspace_addr, which must point at user addressable memory for
  722. the entire memory slot size. Any object may back this memory, including
  723. anonymous memory, ordinary files, and hugetlbfs.
  724. It is recommended that the lower 21 bits of guest_phys_addr and userspace_addr
  725. be identical. This allows large pages in the guest to be backed by large
  726. pages in the host.
  727. The flags field supports two flags: KVM_MEM_LOG_DIRTY_PAGES and
  728. KVM_MEM_READONLY. The former can be set to instruct KVM to keep track of
  729. writes to memory within the slot. See KVM_GET_DIRTY_LOG ioctl to know how to
  730. use it. The latter can be set, if KVM_CAP_READONLY_MEM capability allows it,
  731. to make a new slot read-only. In this case, writes to this memory will be
  732. posted to userspace as KVM_EXIT_MMIO exits.
  733. When the KVM_CAP_SYNC_MMU capability is available, changes in the backing of
  734. the memory region are automatically reflected into the guest. For example, an
  735. mmap() that affects the region will be made visible immediately. Another
  736. example is madvise(MADV_DROP).
  737. It is recommended to use this API instead of the KVM_SET_MEMORY_REGION ioctl.
  738. The KVM_SET_MEMORY_REGION does not allow fine grained control over memory
  739. allocation and is deprecated.
  740. 4.36 KVM_SET_TSS_ADDR
  741. Capability: KVM_CAP_SET_TSS_ADDR
  742. Architectures: x86
  743. Type: vm ioctl
  744. Parameters: unsigned long tss_address (in)
  745. Returns: 0 on success, -1 on error
  746. This ioctl defines the physical address of a three-page region in the guest
  747. physical address space. The region must be within the first 4GB of the
  748. guest physical address space and must not conflict with any memory slot
  749. or any mmio address. The guest may malfunction if it accesses this memory
  750. region.
  751. This ioctl is required on Intel-based hosts. This is needed on Intel hardware
  752. because of a quirk in the virtualization implementation (see the internals
  753. documentation when it pops into existence).
  754. 4.37 KVM_ENABLE_CAP
  755. Capability: KVM_CAP_ENABLE_CAP, KVM_CAP_ENABLE_CAP_VM
  756. Architectures: x86 (only KVM_CAP_ENABLE_CAP_VM),
  757. mips (only KVM_CAP_ENABLE_CAP), ppc, s390
  758. Type: vcpu ioctl, vm ioctl (with KVM_CAP_ENABLE_CAP_VM)
  759. Parameters: struct kvm_enable_cap (in)
  760. Returns: 0 on success; -1 on error
  761. +Not all extensions are enabled by default. Using this ioctl the application
  762. can enable an extension, making it available to the guest.
  763. On systems that do not support this ioctl, it always fails. On systems that
  764. do support it, it only works for extensions that are supported for enablement.
  765. To check if a capability can be enabled, the KVM_CHECK_EXTENSION ioctl should
  766. be used.
  767. struct kvm_enable_cap {
  768. /* in */
  769. __u32 cap;
  770. The capability that is supposed to get enabled.
  771. __u32 flags;
  772. A bitfield indicating future enhancements. Has to be 0 for now.
  773. __u64 args[4];
  774. Arguments for enabling a feature. If a feature needs initial values to
  775. function properly, this is the place to put them.
  776. __u8 pad[64];
  777. };
  778. The vcpu ioctl should be used for vcpu-specific capabilities, the vm ioctl
  779. for vm-wide capabilities.
  780. 4.38 KVM_GET_MP_STATE
  781. Capability: KVM_CAP_MP_STATE
  782. Architectures: x86, s390, arm, arm64
  783. Type: vcpu ioctl
  784. Parameters: struct kvm_mp_state (out)
  785. Returns: 0 on success; -1 on error
  786. struct kvm_mp_state {
  787. __u32 mp_state;
  788. };
  789. Returns the vcpu's current "multiprocessing state" (though also valid on
  790. uniprocessor guests).
  791. Possible values are:
  792. - KVM_MP_STATE_RUNNABLE: the vcpu is currently running [x86,arm/arm64]
  793. - KVM_MP_STATE_UNINITIALIZED: the vcpu is an application processor (AP)
  794. which has not yet received an INIT signal [x86]
  795. - KVM_MP_STATE_INIT_RECEIVED: the vcpu has received an INIT signal, and is
  796. now ready for a SIPI [x86]
  797. - KVM_MP_STATE_HALTED: the vcpu has executed a HLT instruction and
  798. is waiting for an interrupt [x86]
  799. - KVM_MP_STATE_SIPI_RECEIVED: the vcpu has just received a SIPI (vector
  800. accessible via KVM_GET_VCPU_EVENTS) [x86]
  801. - KVM_MP_STATE_STOPPED: the vcpu is stopped [s390,arm/arm64]
  802. - KVM_MP_STATE_CHECK_STOP: the vcpu is in a special error state [s390]
  803. - KVM_MP_STATE_OPERATING: the vcpu is operating (running or halted)
  804. [s390]
  805. - KVM_MP_STATE_LOAD: the vcpu is in a special load/startup state
  806. [s390]
  807. On x86, this ioctl is only useful after KVM_CREATE_IRQCHIP. Without an
  808. in-kernel irqchip, the multiprocessing state must be maintained by userspace on
  809. these architectures.
  810. For arm/arm64:
  811. The only states that are valid are KVM_MP_STATE_STOPPED and
  812. KVM_MP_STATE_RUNNABLE which reflect if the vcpu is paused or not.
  813. 4.39 KVM_SET_MP_STATE
  814. Capability: KVM_CAP_MP_STATE
  815. Architectures: x86, s390, arm, arm64
  816. Type: vcpu ioctl
  817. Parameters: struct kvm_mp_state (in)
  818. Returns: 0 on success; -1 on error
  819. Sets the vcpu's current "multiprocessing state"; see KVM_GET_MP_STATE for
  820. arguments.
  821. On x86, this ioctl is only useful after KVM_CREATE_IRQCHIP. Without an
  822. in-kernel irqchip, the multiprocessing state must be maintained by userspace on
  823. these architectures.
  824. For arm/arm64:
  825. The only states that are valid are KVM_MP_STATE_STOPPED and
  826. KVM_MP_STATE_RUNNABLE which reflect if the vcpu should be paused or not.
  827. 4.40 KVM_SET_IDENTITY_MAP_ADDR
  828. Capability: KVM_CAP_SET_IDENTITY_MAP_ADDR
  829. Architectures: x86
  830. Type: vm ioctl
  831. Parameters: unsigned long identity (in)
  832. Returns: 0 on success, -1 on error
  833. This ioctl defines the physical address of a one-page region in the guest
  834. physical address space. The region must be within the first 4GB of the
  835. guest physical address space and must not conflict with any memory slot
  836. or any mmio address. The guest may malfunction if it accesses this memory
  837. region.
  838. This ioctl is required on Intel-based hosts. This is needed on Intel hardware
  839. because of a quirk in the virtualization implementation (see the internals
  840. documentation when it pops into existence).
  841. 4.41 KVM_SET_BOOT_CPU_ID
  842. Capability: KVM_CAP_SET_BOOT_CPU_ID
  843. Architectures: x86
  844. Type: vm ioctl
  845. Parameters: unsigned long vcpu_id
  846. Returns: 0 on success, -1 on error
  847. Define which vcpu is the Bootstrap Processor (BSP). Values are the same
  848. as the vcpu id in KVM_CREATE_VCPU. If this ioctl is not called, the default
  849. is vcpu 0.
  850. 4.42 KVM_GET_XSAVE
  851. Capability: KVM_CAP_XSAVE
  852. Architectures: x86
  853. Type: vcpu ioctl
  854. Parameters: struct kvm_xsave (out)
  855. Returns: 0 on success, -1 on error
  856. struct kvm_xsave {
  857. __u32 region[1024];
  858. };
  859. This ioctl would copy current vcpu's xsave struct to the userspace.
  860. 4.43 KVM_SET_XSAVE
  861. Capability: KVM_CAP_XSAVE
  862. Architectures: x86
  863. Type: vcpu ioctl
  864. Parameters: struct kvm_xsave (in)
  865. Returns: 0 on success, -1 on error
  866. struct kvm_xsave {
  867. __u32 region[1024];
  868. };
  869. This ioctl would copy userspace's xsave struct to the kernel.
  870. 4.44 KVM_GET_XCRS
  871. Capability: KVM_CAP_XCRS
  872. Architectures: x86
  873. Type: vcpu ioctl
  874. Parameters: struct kvm_xcrs (out)
  875. Returns: 0 on success, -1 on error
  876. struct kvm_xcr {
  877. __u32 xcr;
  878. __u32 reserved;
  879. __u64 value;
  880. };
  881. struct kvm_xcrs {
  882. __u32 nr_xcrs;
  883. __u32 flags;
  884. struct kvm_xcr xcrs[KVM_MAX_XCRS];
  885. __u64 padding[16];
  886. };
  887. This ioctl would copy current vcpu's xcrs to the userspace.
  888. 4.45 KVM_SET_XCRS
  889. Capability: KVM_CAP_XCRS
  890. Architectures: x86
  891. Type: vcpu ioctl
  892. Parameters: struct kvm_xcrs (in)
  893. Returns: 0 on success, -1 on error
  894. struct kvm_xcr {
  895. __u32 xcr;
  896. __u32 reserved;
  897. __u64 value;
  898. };
  899. struct kvm_xcrs {
  900. __u32 nr_xcrs;
  901. __u32 flags;
  902. struct kvm_xcr xcrs[KVM_MAX_XCRS];
  903. __u64 padding[16];
  904. };
  905. This ioctl would set vcpu's xcr to the value userspace specified.
  906. 4.46 KVM_GET_SUPPORTED_CPUID
  907. Capability: KVM_CAP_EXT_CPUID
  908. Architectures: x86
  909. Type: system ioctl
  910. Parameters: struct kvm_cpuid2 (in/out)
  911. Returns: 0 on success, -1 on error
  912. struct kvm_cpuid2 {
  913. __u32 nent;
  914. __u32 padding;
  915. struct kvm_cpuid_entry2 entries[0];
  916. };
  917. #define KVM_CPUID_FLAG_SIGNIFCANT_INDEX BIT(0)
  918. #define KVM_CPUID_FLAG_STATEFUL_FUNC BIT(1)
  919. #define KVM_CPUID_FLAG_STATE_READ_NEXT BIT(2)
  920. struct kvm_cpuid_entry2 {
  921. __u32 function;
  922. __u32 index;
  923. __u32 flags;
  924. __u32 eax;
  925. __u32 ebx;
  926. __u32 ecx;
  927. __u32 edx;
  928. __u32 padding[3];
  929. };
  930. This ioctl returns x86 cpuid features which are supported by both the hardware
  931. and kvm. Userspace can use the information returned by this ioctl to
  932. construct cpuid information (for KVM_SET_CPUID2) that is consistent with
  933. hardware, kernel, and userspace capabilities, and with user requirements (for
  934. example, the user may wish to constrain cpuid to emulate older hardware,
  935. or for feature consistency across a cluster).
  936. Userspace invokes KVM_GET_SUPPORTED_CPUID by passing a kvm_cpuid2 structure
  937. with the 'nent' field indicating the number of entries in the variable-size
  938. array 'entries'. If the number of entries is too low to describe the cpu
  939. capabilities, an error (E2BIG) is returned. If the number is too high,
  940. the 'nent' field is adjusted and an error (ENOMEM) is returned. If the
  941. number is just right, the 'nent' field is adjusted to the number of valid
  942. entries in the 'entries' array, which is then filled.
  943. The entries returned are the host cpuid as returned by the cpuid instruction,
  944. with unknown or unsupported features masked out. Some features (for example,
  945. x2apic), may not be present in the host cpu, but are exposed by kvm if it can
  946. emulate them efficiently. The fields in each entry are defined as follows:
  947. function: the eax value used to obtain the entry
  948. index: the ecx value used to obtain the entry (for entries that are
  949. affected by ecx)
  950. flags: an OR of zero or more of the following:
  951. KVM_CPUID_FLAG_SIGNIFCANT_INDEX:
  952. if the index field is valid
  953. KVM_CPUID_FLAG_STATEFUL_FUNC:
  954. if cpuid for this function returns different values for successive
  955. invocations; there will be several entries with the same function,
  956. all with this flag set
  957. KVM_CPUID_FLAG_STATE_READ_NEXT:
  958. for KVM_CPUID_FLAG_STATEFUL_FUNC entries, set if this entry is
  959. the first entry to be read by a cpu
  960. eax, ebx, ecx, edx: the values returned by the cpuid instruction for
  961. this function/index combination
  962. The TSC deadline timer feature (CPUID leaf 1, ecx[24]) is always returned
  963. as false, since the feature depends on KVM_CREATE_IRQCHIP for local APIC
  964. support. Instead it is reported via
  965. ioctl(KVM_CHECK_EXTENSION, KVM_CAP_TSC_DEADLINE_TIMER)
  966. if that returns true and you use KVM_CREATE_IRQCHIP, or if you emulate the
  967. feature in userspace, then you can enable the feature for KVM_SET_CPUID2.
  968. 4.47 KVM_PPC_GET_PVINFO
  969. Capability: KVM_CAP_PPC_GET_PVINFO
  970. Architectures: ppc
  971. Type: vm ioctl
  972. Parameters: struct kvm_ppc_pvinfo (out)
  973. Returns: 0 on success, !0 on error
  974. struct kvm_ppc_pvinfo {
  975. __u32 flags;
  976. __u32 hcall[4];
  977. __u8 pad[108];
  978. };
  979. This ioctl fetches PV specific information that need to be passed to the guest
  980. using the device tree or other means from vm context.
  981. The hcall array defines 4 instructions that make up a hypercall.
  982. If any additional field gets added to this structure later on, a bit for that
  983. additional piece of information will be set in the flags bitmap.
  984. The flags bitmap is defined as:
  985. /* the host supports the ePAPR idle hcall
  986. #define KVM_PPC_PVINFO_FLAGS_EV_IDLE (1<<0)
  987. 4.48 KVM_ASSIGN_PCI_DEVICE (deprecated)
  988. Capability: none
  989. Architectures: x86
  990. Type: vm ioctl
  991. Parameters: struct kvm_assigned_pci_dev (in)
  992. Returns: 0 on success, -1 on error
  993. Assigns a host PCI device to the VM.
  994. struct kvm_assigned_pci_dev {
  995. __u32 assigned_dev_id;
  996. __u32 busnr;
  997. __u32 devfn;
  998. __u32 flags;
  999. __u32 segnr;
  1000. union {
  1001. __u32 reserved[11];
  1002. };
  1003. };
  1004. The PCI device is specified by the triple segnr, busnr, and devfn.
  1005. Identification in succeeding service requests is done via assigned_dev_id. The
  1006. following flags are specified:
  1007. /* Depends on KVM_CAP_IOMMU */
  1008. #define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0)
  1009. /* The following two depend on KVM_CAP_PCI_2_3 */
  1010. #define KVM_DEV_ASSIGN_PCI_2_3 (1 << 1)
  1011. #define KVM_DEV_ASSIGN_MASK_INTX (1 << 2)
  1012. If KVM_DEV_ASSIGN_PCI_2_3 is set, the kernel will manage legacy INTx interrupts
  1013. via the PCI-2.3-compliant device-level mask, thus enable IRQ sharing with other
  1014. assigned devices or host devices. KVM_DEV_ASSIGN_MASK_INTX specifies the
  1015. guest's view on the INTx mask, see KVM_ASSIGN_SET_INTX_MASK for details.
  1016. The KVM_DEV_ASSIGN_ENABLE_IOMMU flag is a mandatory option to ensure
  1017. isolation of the device. Usages not specifying this flag are deprecated.
  1018. Only PCI header type 0 devices with PCI BAR resources are supported by
  1019. device assignment. The user requesting this ioctl must have read/write
  1020. access to the PCI sysfs resource files associated with the device.
  1021. Errors:
  1022. ENOTTY: kernel does not support this ioctl
  1023. Other error conditions may be defined by individual device types or
  1024. have their standard meanings.
  1025. 4.49 KVM_DEASSIGN_PCI_DEVICE (deprecated)
  1026. Capability: none
  1027. Architectures: x86
  1028. Type: vm ioctl
  1029. Parameters: struct kvm_assigned_pci_dev (in)
  1030. Returns: 0 on success, -1 on error
  1031. Ends PCI device assignment, releasing all associated resources.
  1032. See KVM_ASSIGN_PCI_DEVICE for the data structure. Only assigned_dev_id is
  1033. used in kvm_assigned_pci_dev to identify the device.
  1034. Errors:
  1035. ENOTTY: kernel does not support this ioctl
  1036. Other error conditions may be defined by individual device types or
  1037. have their standard meanings.
  1038. 4.50 KVM_ASSIGN_DEV_IRQ (deprecated)
  1039. Capability: KVM_CAP_ASSIGN_DEV_IRQ
  1040. Architectures: x86
  1041. Type: vm ioctl
  1042. Parameters: struct kvm_assigned_irq (in)
  1043. Returns: 0 on success, -1 on error
  1044. Assigns an IRQ to a passed-through device.
  1045. struct kvm_assigned_irq {
  1046. __u32 assigned_dev_id;
  1047. __u32 host_irq; /* ignored (legacy field) */
  1048. __u32 guest_irq;
  1049. __u32 flags;
  1050. union {
  1051. __u32 reserved[12];
  1052. };
  1053. };
  1054. The following flags are defined:
  1055. #define KVM_DEV_IRQ_HOST_INTX (1 << 0)
  1056. #define KVM_DEV_IRQ_HOST_MSI (1 << 1)
  1057. #define KVM_DEV_IRQ_HOST_MSIX (1 << 2)
  1058. #define KVM_DEV_IRQ_GUEST_INTX (1 << 8)
  1059. #define KVM_DEV_IRQ_GUEST_MSI (1 << 9)
  1060. #define KVM_DEV_IRQ_GUEST_MSIX (1 << 10)
  1061. It is not valid to specify multiple types per host or guest IRQ. However, the
  1062. IRQ type of host and guest can differ or can even be null.
  1063. Errors:
  1064. ENOTTY: kernel does not support this ioctl
  1065. Other error conditions may be defined by individual device types or
  1066. have their standard meanings.
  1067. 4.51 KVM_DEASSIGN_DEV_IRQ (deprecated)
  1068. Capability: KVM_CAP_ASSIGN_DEV_IRQ
  1069. Architectures: x86
  1070. Type: vm ioctl
  1071. Parameters: struct kvm_assigned_irq (in)
  1072. Returns: 0 on success, -1 on error
  1073. Ends an IRQ assignment to a passed-through device.
  1074. See KVM_ASSIGN_DEV_IRQ for the data structure. The target device is specified
  1075. by assigned_dev_id, flags must correspond to the IRQ type specified on
  1076. KVM_ASSIGN_DEV_IRQ. Partial deassignment of host or guest IRQ is allowed.
  1077. 4.52 KVM_SET_GSI_ROUTING
  1078. Capability: KVM_CAP_IRQ_ROUTING
  1079. Architectures: x86 s390 arm arm64
  1080. Type: vm ioctl
  1081. Parameters: struct kvm_irq_routing (in)
  1082. Returns: 0 on success, -1 on error
  1083. Sets the GSI routing table entries, overwriting any previously set entries.
  1084. On arm/arm64, GSI routing has the following limitation:
  1085. - GSI routing does not apply to KVM_IRQ_LINE but only to KVM_IRQFD.
  1086. struct kvm_irq_routing {
  1087. __u32 nr;
  1088. __u32 flags;
  1089. struct kvm_irq_routing_entry entries[0];
  1090. };
  1091. No flags are specified so far, the corresponding field must be set to zero.
  1092. struct kvm_irq_routing_entry {
  1093. __u32 gsi;
  1094. __u32 type;
  1095. __u32 flags;
  1096. __u32 pad;
  1097. union {
  1098. struct kvm_irq_routing_irqchip irqchip;
  1099. struct kvm_irq_routing_msi msi;
  1100. struct kvm_irq_routing_s390_adapter adapter;
  1101. struct kvm_irq_routing_hv_sint hv_sint;
  1102. __u32 pad[8];
  1103. } u;
  1104. };
  1105. /* gsi routing entry types */
  1106. #define KVM_IRQ_ROUTING_IRQCHIP 1
  1107. #define KVM_IRQ_ROUTING_MSI 2
  1108. #define KVM_IRQ_ROUTING_S390_ADAPTER 3
  1109. #define KVM_IRQ_ROUTING_HV_SINT 4
  1110. flags:
  1111. - KVM_MSI_VALID_DEVID: used along with KVM_IRQ_ROUTING_MSI routing entry
  1112. type, specifies that the devid field contains a valid value. The per-VM
  1113. KVM_CAP_MSI_DEVID capability advertises the requirement to provide
  1114. the device ID. If this capability is not available, userspace should
  1115. never set the KVM_MSI_VALID_DEVID flag as the ioctl might fail.
  1116. - zero otherwise
  1117. struct kvm_irq_routing_irqchip {
  1118. __u32 irqchip;
  1119. __u32 pin;
  1120. };
  1121. struct kvm_irq_routing_msi {
  1122. __u32 address_lo;
  1123. __u32 address_hi;
  1124. __u32 data;
  1125. union {
  1126. __u32 pad;
  1127. __u32 devid;
  1128. };
  1129. };
  1130. If KVM_MSI_VALID_DEVID is set, devid contains a unique device identifier
  1131. for the device that wrote the MSI message. For PCI, this is usually a
  1132. BFD identifier in the lower 16 bits.
  1133. On x86, address_hi is ignored unless the KVM_X2APIC_API_USE_32BIT_IDS
  1134. feature of KVM_CAP_X2APIC_API capability is enabled. If it is enabled,
  1135. address_hi bits 31-8 provide bits 31-8 of the destination id. Bits 7-0 of
  1136. address_hi must be zero.
  1137. struct kvm_irq_routing_s390_adapter {
  1138. __u64 ind_addr;
  1139. __u64 summary_addr;
  1140. __u64 ind_offset;
  1141. __u32 summary_offset;
  1142. __u32 adapter_id;
  1143. };
  1144. struct kvm_irq_routing_hv_sint {
  1145. __u32 vcpu;
  1146. __u32 sint;
  1147. };
  1148. 4.53 KVM_ASSIGN_SET_MSIX_NR (deprecated)
  1149. Capability: none
  1150. Architectures: x86
  1151. Type: vm ioctl
  1152. Parameters: struct kvm_assigned_msix_nr (in)
  1153. Returns: 0 on success, -1 on error
  1154. Set the number of MSI-X interrupts for an assigned device. The number is
  1155. reset again by terminating the MSI-X assignment of the device via
  1156. KVM_DEASSIGN_DEV_IRQ. Calling this service more than once at any earlier
  1157. point will fail.
  1158. struct kvm_assigned_msix_nr {
  1159. __u32 assigned_dev_id;
  1160. __u16 entry_nr;
  1161. __u16 padding;
  1162. };
  1163. #define KVM_MAX_MSIX_PER_DEV 256
  1164. 4.54 KVM_ASSIGN_SET_MSIX_ENTRY (deprecated)
  1165. Capability: none
  1166. Architectures: x86
  1167. Type: vm ioctl
  1168. Parameters: struct kvm_assigned_msix_entry (in)
  1169. Returns: 0 on success, -1 on error
  1170. Specifies the routing of an MSI-X assigned device interrupt to a GSI. Setting
  1171. the GSI vector to zero means disabling the interrupt.
  1172. struct kvm_assigned_msix_entry {
  1173. __u32 assigned_dev_id;
  1174. __u32 gsi;
  1175. __u16 entry; /* The index of entry in the MSI-X table */
  1176. __u16 padding[3];
  1177. };
  1178. Errors:
  1179. ENOTTY: kernel does not support this ioctl
  1180. Other error conditions may be defined by individual device types or
  1181. have their standard meanings.
  1182. 4.55 KVM_SET_TSC_KHZ
  1183. Capability: KVM_CAP_TSC_CONTROL
  1184. Architectures: x86
  1185. Type: vcpu ioctl
  1186. Parameters: virtual tsc_khz
  1187. Returns: 0 on success, -1 on error
  1188. Specifies the tsc frequency for the virtual machine. The unit of the
  1189. frequency is KHz.
  1190. 4.56 KVM_GET_TSC_KHZ
  1191. Capability: KVM_CAP_GET_TSC_KHZ
  1192. Architectures: x86
  1193. Type: vcpu ioctl
  1194. Parameters: none
  1195. Returns: virtual tsc-khz on success, negative value on error
  1196. Returns the tsc frequency of the guest. The unit of the return value is
  1197. KHz. If the host has unstable tsc this ioctl returns -EIO instead as an
  1198. error.
  1199. 4.57 KVM_GET_LAPIC
  1200. Capability: KVM_CAP_IRQCHIP
  1201. Architectures: x86
  1202. Type: vcpu ioctl
  1203. Parameters: struct kvm_lapic_state (out)
  1204. Returns: 0 on success, -1 on error
  1205. #define KVM_APIC_REG_SIZE 0x400
  1206. struct kvm_lapic_state {
  1207. char regs[KVM_APIC_REG_SIZE];
  1208. };
  1209. Reads the Local APIC registers and copies them into the input argument. The
  1210. data format and layout are the same as documented in the architecture manual.
  1211. If KVM_X2APIC_API_USE_32BIT_IDS feature of KVM_CAP_X2APIC_API is
  1212. enabled, then the format of APIC_ID register depends on the APIC mode
  1213. (reported by MSR_IA32_APICBASE) of its VCPU. x2APIC stores APIC ID in
  1214. the APIC_ID register (bytes 32-35). xAPIC only allows an 8-bit APIC ID
  1215. which is stored in bits 31-24 of the APIC register, or equivalently in
  1216. byte 35 of struct kvm_lapic_state's regs field. KVM_GET_LAPIC must then
  1217. be called after MSR_IA32_APICBASE has been set with KVM_SET_MSR.
  1218. If KVM_X2APIC_API_USE_32BIT_IDS feature is disabled, struct kvm_lapic_state
  1219. always uses xAPIC format.
  1220. 4.58 KVM_SET_LAPIC
  1221. Capability: KVM_CAP_IRQCHIP
  1222. Architectures: x86
  1223. Type: vcpu ioctl
  1224. Parameters: struct kvm_lapic_state (in)
  1225. Returns: 0 on success, -1 on error
  1226. #define KVM_APIC_REG_SIZE 0x400
  1227. struct kvm_lapic_state {
  1228. char regs[KVM_APIC_REG_SIZE];
  1229. };
  1230. Copies the input argument into the Local APIC registers. The data format
  1231. and layout are the same as documented in the architecture manual.
  1232. The format of the APIC ID register (bytes 32-35 of struct kvm_lapic_state's
  1233. regs field) depends on the state of the KVM_CAP_X2APIC_API capability.
  1234. See the note in KVM_GET_LAPIC.
  1235. 4.59 KVM_IOEVENTFD
  1236. Capability: KVM_CAP_IOEVENTFD
  1237. Architectures: all
  1238. Type: vm ioctl
  1239. Parameters: struct kvm_ioeventfd (in)
  1240. Returns: 0 on success, !0 on error
  1241. This ioctl attaches or detaches an ioeventfd to a legal pio/mmio address
  1242. within the guest. A guest write in the registered address will signal the
  1243. provided event instead of triggering an exit.
  1244. struct kvm_ioeventfd {
  1245. __u64 datamatch;
  1246. __u64 addr; /* legal pio/mmio address */
  1247. __u32 len; /* 0, 1, 2, 4, or 8 bytes */
  1248. __s32 fd;
  1249. __u32 flags;
  1250. __u8 pad[36];
  1251. };
  1252. For the special case of virtio-ccw devices on s390, the ioevent is matched
  1253. to a subchannel/virtqueue tuple instead.
  1254. The following flags are defined:
  1255. #define KVM_IOEVENTFD_FLAG_DATAMATCH (1 << kvm_ioeventfd_flag_nr_datamatch)
  1256. #define KVM_IOEVENTFD_FLAG_PIO (1 << kvm_ioeventfd_flag_nr_pio)
  1257. #define KVM_IOEVENTFD_FLAG_DEASSIGN (1 << kvm_ioeventfd_flag_nr_deassign)
  1258. #define KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY \
  1259. (1 << kvm_ioeventfd_flag_nr_virtio_ccw_notify)
  1260. If datamatch flag is set, the event will be signaled only if the written value
  1261. to the registered address is equal to datamatch in struct kvm_ioeventfd.
  1262. For virtio-ccw devices, addr contains the subchannel id and datamatch the
  1263. virtqueue index.
  1264. With KVM_CAP_IOEVENTFD_ANY_LENGTH, a zero length ioeventfd is allowed, and
  1265. the kernel will ignore the length of guest write and may get a faster vmexit.
  1266. The speedup may only apply to specific architectures, but the ioeventfd will
  1267. work anyway.
  1268. 4.60 KVM_DIRTY_TLB
  1269. Capability: KVM_CAP_SW_TLB
  1270. Architectures: ppc
  1271. Type: vcpu ioctl
  1272. Parameters: struct kvm_dirty_tlb (in)
  1273. Returns: 0 on success, -1 on error
  1274. struct kvm_dirty_tlb {
  1275. __u64 bitmap;
  1276. __u32 num_dirty;
  1277. };
  1278. This must be called whenever userspace has changed an entry in the shared
  1279. TLB, prior to calling KVM_RUN on the associated vcpu.
  1280. The "bitmap" field is the userspace address of an array. This array
  1281. consists of a number of bits, equal to the total number of TLB entries as
  1282. determined by the last successful call to KVM_CONFIG_TLB, rounded up to the
  1283. nearest multiple of 64.
  1284. Each bit corresponds to one TLB entry, ordered the same as in the shared TLB
  1285. array.
  1286. The array is little-endian: the bit 0 is the least significant bit of the
  1287. first byte, bit 8 is the least significant bit of the second byte, etc.
  1288. This avoids any complications with differing word sizes.
  1289. The "num_dirty" field is a performance hint for KVM to determine whether it
  1290. should skip processing the bitmap and just invalidate everything. It must
  1291. be set to the number of set bits in the bitmap.
  1292. 4.61 KVM_ASSIGN_SET_INTX_MASK (deprecated)
  1293. Capability: KVM_CAP_PCI_2_3
  1294. Architectures: x86
  1295. Type: vm ioctl
  1296. Parameters: struct kvm_assigned_pci_dev (in)
  1297. Returns: 0 on success, -1 on error
  1298. Allows userspace to mask PCI INTx interrupts from the assigned device. The
  1299. kernel will not deliver INTx interrupts to the guest between setting and
  1300. clearing of KVM_ASSIGN_SET_INTX_MASK via this interface. This enables use of
  1301. and emulation of PCI 2.3 INTx disable command register behavior.
  1302. This may be used for both PCI 2.3 devices supporting INTx disable natively and
  1303. older devices lacking this support. Userspace is responsible for emulating the
  1304. read value of the INTx disable bit in the guest visible PCI command register.
  1305. When modifying the INTx disable state, userspace should precede updating the
  1306. physical device command register by calling this ioctl to inform the kernel of
  1307. the new intended INTx mask state.
  1308. Note that the kernel uses the device INTx disable bit to internally manage the
  1309. device interrupt state for PCI 2.3 devices. Reads of this register may
  1310. therefore not match the expected value. Writes should always use the guest
  1311. intended INTx disable value rather than attempting to read-copy-update the
  1312. current physical device state. Races between user and kernel updates to the
  1313. INTx disable bit are handled lazily in the kernel. It's possible the device
  1314. may generate unintended interrupts, but they will not be injected into the
  1315. guest.
  1316. See KVM_ASSIGN_DEV_IRQ for the data structure. The target device is specified
  1317. by assigned_dev_id. In the flags field, only KVM_DEV_ASSIGN_MASK_INTX is
  1318. evaluated.
  1319. 4.62 KVM_CREATE_SPAPR_TCE
  1320. Capability: KVM_CAP_SPAPR_TCE
  1321. Architectures: powerpc
  1322. Type: vm ioctl
  1323. Parameters: struct kvm_create_spapr_tce (in)
  1324. Returns: file descriptor for manipulating the created TCE table
  1325. This creates a virtual TCE (translation control entry) table, which
  1326. is an IOMMU for PAPR-style virtual I/O. It is used to translate
  1327. logical addresses used in virtual I/O into guest physical addresses,
  1328. and provides a scatter/gather capability for PAPR virtual I/O.
  1329. /* for KVM_CAP_SPAPR_TCE */
  1330. struct kvm_create_spapr_tce {
  1331. __u64 liobn;
  1332. __u32 window_size;
  1333. };
  1334. The liobn field gives the logical IO bus number for which to create a
  1335. TCE table. The window_size field specifies the size of the DMA window
  1336. which this TCE table will translate - the table will contain one 64
  1337. bit TCE entry for every 4kiB of the DMA window.
  1338. When the guest issues an H_PUT_TCE hcall on a liobn for which a TCE
  1339. table has been created using this ioctl(), the kernel will handle it
  1340. in real mode, updating the TCE table. H_PUT_TCE calls for other
  1341. liobns will cause a vm exit and must be handled by userspace.
  1342. The return value is a file descriptor which can be passed to mmap(2)
  1343. to map the created TCE table into userspace. This lets userspace read
  1344. the entries written by kernel-handled H_PUT_TCE calls, and also lets
  1345. userspace update the TCE table directly which is useful in some
  1346. circumstances.
  1347. 4.63 KVM_ALLOCATE_RMA
  1348. Capability: KVM_CAP_PPC_RMA
  1349. Architectures: powerpc
  1350. Type: vm ioctl
  1351. Parameters: struct kvm_allocate_rma (out)
  1352. Returns: file descriptor for mapping the allocated RMA
  1353. This allocates a Real Mode Area (RMA) from the pool allocated at boot
  1354. time by the kernel. An RMA is a physically-contiguous, aligned region
  1355. of memory used on older POWER processors to provide the memory which
  1356. will be accessed by real-mode (MMU off) accesses in a KVM guest.
  1357. POWER processors support a set of sizes for the RMA that usually
  1358. includes 64MB, 128MB, 256MB and some larger powers of two.
  1359. /* for KVM_ALLOCATE_RMA */
  1360. struct kvm_allocate_rma {
  1361. __u64 rma_size;
  1362. };
  1363. The return value is a file descriptor which can be passed to mmap(2)
  1364. to map the allocated RMA into userspace. The mapped area can then be
  1365. passed to the KVM_SET_USER_MEMORY_REGION ioctl to establish it as the
  1366. RMA for a virtual machine. The size of the RMA in bytes (which is
  1367. fixed at host kernel boot time) is returned in the rma_size field of
  1368. the argument structure.
  1369. The KVM_CAP_PPC_RMA capability is 1 or 2 if the KVM_ALLOCATE_RMA ioctl
  1370. is supported; 2 if the processor requires all virtual machines to have
  1371. an RMA, or 1 if the processor can use an RMA but doesn't require it,
  1372. because it supports the Virtual RMA (VRMA) facility.
  1373. 4.64 KVM_NMI
  1374. Capability: KVM_CAP_USER_NMI
  1375. Architectures: x86
  1376. Type: vcpu ioctl
  1377. Parameters: none
  1378. Returns: 0 on success, -1 on error
  1379. Queues an NMI on the thread's vcpu. Note this is well defined only
  1380. when KVM_CREATE_IRQCHIP has not been called, since this is an interface
  1381. between the virtual cpu core and virtual local APIC. After KVM_CREATE_IRQCHIP
  1382. has been called, this interface is completely emulated within the kernel.
  1383. To use this to emulate the LINT1 input with KVM_CREATE_IRQCHIP, use the
  1384. following algorithm:
  1385. - pause the vcpu
  1386. - read the local APIC's state (KVM_GET_LAPIC)
  1387. - check whether changing LINT1 will queue an NMI (see the LVT entry for LINT1)
  1388. - if so, issue KVM_NMI
  1389. - resume the vcpu
  1390. Some guests configure the LINT1 NMI input to cause a panic, aiding in
  1391. debugging.
  1392. 4.65 KVM_S390_UCAS_MAP
  1393. Capability: KVM_CAP_S390_UCONTROL
  1394. Architectures: s390
  1395. Type: vcpu ioctl
  1396. Parameters: struct kvm_s390_ucas_mapping (in)
  1397. Returns: 0 in case of success
  1398. The parameter is defined like this:
  1399. struct kvm_s390_ucas_mapping {
  1400. __u64 user_addr;
  1401. __u64 vcpu_addr;
  1402. __u64 length;
  1403. };
  1404. This ioctl maps the memory at "user_addr" with the length "length" to
  1405. the vcpu's address space starting at "vcpu_addr". All parameters need to
  1406. be aligned by 1 megabyte.
  1407. 4.66 KVM_S390_UCAS_UNMAP
  1408. Capability: KVM_CAP_S390_UCONTROL
  1409. Architectures: s390
  1410. Type: vcpu ioctl
  1411. Parameters: struct kvm_s390_ucas_mapping (in)
  1412. Returns: 0 in case of success
  1413. The parameter is defined like this:
  1414. struct kvm_s390_ucas_mapping {
  1415. __u64 user_addr;
  1416. __u64 vcpu_addr;
  1417. __u64 length;
  1418. };
  1419. This ioctl unmaps the memory in the vcpu's address space starting at
  1420. "vcpu_addr" with the length "length". The field "user_addr" is ignored.
  1421. All parameters need to be aligned by 1 megabyte.
  1422. 4.67 KVM_S390_VCPU_FAULT
  1423. Capability: KVM_CAP_S390_UCONTROL
  1424. Architectures: s390
  1425. Type: vcpu ioctl
  1426. Parameters: vcpu absolute address (in)
  1427. Returns: 0 in case of success
  1428. This call creates a page table entry on the virtual cpu's address space
  1429. (for user controlled virtual machines) or the virtual machine's address
  1430. space (for regular virtual machines). This only works for minor faults,
  1431. thus it's recommended to access subject memory page via the user page
  1432. table upfront. This is useful to handle validity intercepts for user
  1433. controlled virtual machines to fault in the virtual cpu's lowcore pages
  1434. prior to calling the KVM_RUN ioctl.
  1435. 4.68 KVM_SET_ONE_REG
  1436. Capability: KVM_CAP_ONE_REG
  1437. Architectures: all
  1438. Type: vcpu ioctl
  1439. Parameters: struct kvm_one_reg (in)
  1440. Returns: 0 on success, negative value on failure
  1441. struct kvm_one_reg {
  1442. __u64 id;
  1443. __u64 addr;
  1444. };
  1445. Using this ioctl, a single vcpu register can be set to a specific value
  1446. defined by user space with the passed in struct kvm_one_reg, where id
  1447. refers to the register identifier as described below and addr is a pointer
  1448. to a variable with the respective size. There can be architecture agnostic
  1449. and architecture specific registers. Each have their own range of operation
  1450. and their own constants and width. To keep track of the implemented
  1451. registers, find a list below:
  1452. Arch | Register | Width (bits)
  1453. | |
  1454. PPC | KVM_REG_PPC_HIOR | 64
  1455. PPC | KVM_REG_PPC_IAC1 | 64
  1456. PPC | KVM_REG_PPC_IAC2 | 64
  1457. PPC | KVM_REG_PPC_IAC3 | 64
  1458. PPC | KVM_REG_PPC_IAC4 | 64
  1459. PPC | KVM_REG_PPC_DAC1 | 64
  1460. PPC | KVM_REG_PPC_DAC2 | 64
  1461. PPC | KVM_REG_PPC_DABR | 64
  1462. PPC | KVM_REG_PPC_DSCR | 64
  1463. PPC | KVM_REG_PPC_PURR | 64
  1464. PPC | KVM_REG_PPC_SPURR | 64
  1465. PPC | KVM_REG_PPC_DAR | 64
  1466. PPC | KVM_REG_PPC_DSISR | 32
  1467. PPC | KVM_REG_PPC_AMR | 64
  1468. PPC | KVM_REG_PPC_UAMOR | 64
  1469. PPC | KVM_REG_PPC_MMCR0 | 64
  1470. PPC | KVM_REG_PPC_MMCR1 | 64
  1471. PPC | KVM_REG_PPC_MMCRA | 64
  1472. PPC | KVM_REG_PPC_MMCR2 | 64
  1473. PPC | KVM_REG_PPC_MMCRS | 64
  1474. PPC | KVM_REG_PPC_SIAR | 64
  1475. PPC | KVM_REG_PPC_SDAR | 64
  1476. PPC | KVM_REG_PPC_SIER | 64
  1477. PPC | KVM_REG_PPC_PMC1 | 32
  1478. PPC | KVM_REG_PPC_PMC2 | 32
  1479. PPC | KVM_REG_PPC_PMC3 | 32
  1480. PPC | KVM_REG_PPC_PMC4 | 32
  1481. PPC | KVM_REG_PPC_PMC5 | 32
  1482. PPC | KVM_REG_PPC_PMC6 | 32
  1483. PPC | KVM_REG_PPC_PMC7 | 32
  1484. PPC | KVM_REG_PPC_PMC8 | 32
  1485. PPC | KVM_REG_PPC_FPR0 | 64
  1486. ...
  1487. PPC | KVM_REG_PPC_FPR31 | 64
  1488. PPC | KVM_REG_PPC_VR0 | 128
  1489. ...
  1490. PPC | KVM_REG_PPC_VR31 | 128
  1491. PPC | KVM_REG_PPC_VSR0 | 128
  1492. ...
  1493. PPC | KVM_REG_PPC_VSR31 | 128
  1494. PPC | KVM_REG_PPC_FPSCR | 64
  1495. PPC | KVM_REG_PPC_VSCR | 32
  1496. PPC | KVM_REG_PPC_VPA_ADDR | 64
  1497. PPC | KVM_REG_PPC_VPA_SLB | 128
  1498. PPC | KVM_REG_PPC_VPA_DTL | 128
  1499. PPC | KVM_REG_PPC_EPCR | 32
  1500. PPC | KVM_REG_PPC_EPR | 32
  1501. PPC | KVM_REG_PPC_TCR | 32
  1502. PPC | KVM_REG_PPC_TSR | 32
  1503. PPC | KVM_REG_PPC_OR_TSR | 32
  1504. PPC | KVM_REG_PPC_CLEAR_TSR | 32
  1505. PPC | KVM_REG_PPC_MAS0 | 32
  1506. PPC | KVM_REG_PPC_MAS1 | 32
  1507. PPC | KVM_REG_PPC_MAS2 | 64
  1508. PPC | KVM_REG_PPC_MAS7_3 | 64
  1509. PPC | KVM_REG_PPC_MAS4 | 32
  1510. PPC | KVM_REG_PPC_MAS6 | 32
  1511. PPC | KVM_REG_PPC_MMUCFG | 32
  1512. PPC | KVM_REG_PPC_TLB0CFG | 32
  1513. PPC | KVM_REG_PPC_TLB1CFG | 32
  1514. PPC | KVM_REG_PPC_TLB2CFG | 32
  1515. PPC | KVM_REG_PPC_TLB3CFG | 32
  1516. PPC | KVM_REG_PPC_TLB0PS | 32
  1517. PPC | KVM_REG_PPC_TLB1PS | 32
  1518. PPC | KVM_REG_PPC_TLB2PS | 32
  1519. PPC | KVM_REG_PPC_TLB3PS | 32
  1520. PPC | KVM_REG_PPC_EPTCFG | 32
  1521. PPC | KVM_REG_PPC_ICP_STATE | 64
  1522. PPC | KVM_REG_PPC_TB_OFFSET | 64
  1523. PPC | KVM_REG_PPC_SPMC1 | 32
  1524. PPC | KVM_REG_PPC_SPMC2 | 32
  1525. PPC | KVM_REG_PPC_IAMR | 64
  1526. PPC | KVM_REG_PPC_TFHAR | 64
  1527. PPC | KVM_REG_PPC_TFIAR | 64
  1528. PPC | KVM_REG_PPC_TEXASR | 64
  1529. PPC | KVM_REG_PPC_FSCR | 64
  1530. PPC | KVM_REG_PPC_PSPB | 32
  1531. PPC | KVM_REG_PPC_EBBHR | 64
  1532. PPC | KVM_REG_PPC_EBBRR | 64
  1533. PPC | KVM_REG_PPC_BESCR | 64
  1534. PPC | KVM_REG_PPC_TAR | 64
  1535. PPC | KVM_REG_PPC_DPDES | 64
  1536. PPC | KVM_REG_PPC_DAWR | 64
  1537. PPC | KVM_REG_PPC_DAWRX | 64
  1538. PPC | KVM_REG_PPC_CIABR | 64
  1539. PPC | KVM_REG_PPC_IC | 64
  1540. PPC | KVM_REG_PPC_VTB | 64
  1541. PPC | KVM_REG_PPC_CSIGR | 64
  1542. PPC | KVM_REG_PPC_TACR | 64
  1543. PPC | KVM_REG_PPC_TCSCR | 64
  1544. PPC | KVM_REG_PPC_PID | 64
  1545. PPC | KVM_REG_PPC_ACOP | 64
  1546. PPC | KVM_REG_PPC_VRSAVE | 32
  1547. PPC | KVM_REG_PPC_LPCR | 32
  1548. PPC | KVM_REG_PPC_LPCR_64 | 64
  1549. PPC | KVM_REG_PPC_PPR | 64
  1550. PPC | KVM_REG_PPC_ARCH_COMPAT | 32
  1551. PPC | KVM_REG_PPC_DABRX | 32
  1552. PPC | KVM_REG_PPC_WORT | 64
  1553. PPC | KVM_REG_PPC_SPRG9 | 64
  1554. PPC | KVM_REG_PPC_DBSR | 32
  1555. PPC | KVM_REG_PPC_TM_GPR0 | 64
  1556. ...
  1557. PPC | KVM_REG_PPC_TM_GPR31 | 64
  1558. PPC | KVM_REG_PPC_TM_VSR0 | 128
  1559. ...
  1560. PPC | KVM_REG_PPC_TM_VSR63 | 128
  1561. PPC | KVM_REG_PPC_TM_CR | 64
  1562. PPC | KVM_REG_PPC_TM_LR | 64
  1563. PPC | KVM_REG_PPC_TM_CTR | 64
  1564. PPC | KVM_REG_PPC_TM_FPSCR | 64
  1565. PPC | KVM_REG_PPC_TM_AMR | 64
  1566. PPC | KVM_REG_PPC_TM_PPR | 64
  1567. PPC | KVM_REG_PPC_TM_VRSAVE | 64
  1568. PPC | KVM_REG_PPC_TM_VSCR | 32
  1569. PPC | KVM_REG_PPC_TM_DSCR | 64
  1570. PPC | KVM_REG_PPC_TM_TAR | 64
  1571. PPC | KVM_REG_PPC_TM_XER | 64
  1572. | |
  1573. MIPS | KVM_REG_MIPS_R0 | 64
  1574. ...
  1575. MIPS | KVM_REG_MIPS_R31 | 64
  1576. MIPS | KVM_REG_MIPS_HI | 64
  1577. MIPS | KVM_REG_MIPS_LO | 64
  1578. MIPS | KVM_REG_MIPS_PC | 64
  1579. MIPS | KVM_REG_MIPS_CP0_INDEX | 32
  1580. MIPS | KVM_REG_MIPS_CP0_CONTEXT | 64
  1581. MIPS | KVM_REG_MIPS_CP0_USERLOCAL | 64
  1582. MIPS | KVM_REG_MIPS_CP0_PAGEMASK | 32
  1583. MIPS | KVM_REG_MIPS_CP0_WIRED | 32
  1584. MIPS | KVM_REG_MIPS_CP0_HWRENA | 32
  1585. MIPS | KVM_REG_MIPS_CP0_BADVADDR | 64
  1586. MIPS | KVM_REG_MIPS_CP0_COUNT | 32
  1587. MIPS | KVM_REG_MIPS_CP0_ENTRYHI | 64
  1588. MIPS | KVM_REG_MIPS_CP0_COMPARE | 32
  1589. MIPS | KVM_REG_MIPS_CP0_STATUS | 32
  1590. MIPS | KVM_REG_MIPS_CP0_CAUSE | 32
  1591. MIPS | KVM_REG_MIPS_CP0_EPC | 64
  1592. MIPS | KVM_REG_MIPS_CP0_PRID | 32
  1593. MIPS | KVM_REG_MIPS_CP0_CONFIG | 32
  1594. MIPS | KVM_REG_MIPS_CP0_CONFIG1 | 32
  1595. MIPS | KVM_REG_MIPS_CP0_CONFIG2 | 32
  1596. MIPS | KVM_REG_MIPS_CP0_CONFIG3 | 32
  1597. MIPS | KVM_REG_MIPS_CP0_CONFIG4 | 32
  1598. MIPS | KVM_REG_MIPS_CP0_CONFIG5 | 32
  1599. MIPS | KVM_REG_MIPS_CP0_CONFIG7 | 32
  1600. MIPS | KVM_REG_MIPS_CP0_ERROREPC | 64
  1601. MIPS | KVM_REG_MIPS_CP0_KSCRATCH1 | 64
  1602. MIPS | KVM_REG_MIPS_CP0_KSCRATCH2 | 64
  1603. MIPS | KVM_REG_MIPS_CP0_KSCRATCH3 | 64
  1604. MIPS | KVM_REG_MIPS_CP0_KSCRATCH4 | 64
  1605. MIPS | KVM_REG_MIPS_CP0_KSCRATCH5 | 64
  1606. MIPS | KVM_REG_MIPS_CP0_KSCRATCH6 | 64
  1607. MIPS | KVM_REG_MIPS_COUNT_CTL | 64
  1608. MIPS | KVM_REG_MIPS_COUNT_RESUME | 64
  1609. MIPS | KVM_REG_MIPS_COUNT_HZ | 64
  1610. MIPS | KVM_REG_MIPS_FPR_32(0..31) | 32
  1611. MIPS | KVM_REG_MIPS_FPR_64(0..31) | 64
  1612. MIPS | KVM_REG_MIPS_VEC_128(0..31) | 128
  1613. MIPS | KVM_REG_MIPS_FCR_IR | 32
  1614. MIPS | KVM_REG_MIPS_FCR_CSR | 32
  1615. MIPS | KVM_REG_MIPS_MSA_IR | 32
  1616. MIPS | KVM_REG_MIPS_MSA_CSR | 32
  1617. ARM registers are mapped using the lower 32 bits. The upper 16 of that
  1618. is the register group type, or coprocessor number:
  1619. ARM core registers have the following id bit patterns:
  1620. 0x4020 0000 0010 <index into the kvm_regs struct:16>
  1621. ARM 32-bit CP15 registers have the following id bit patterns:
  1622. 0x4020 0000 000F <zero:1> <crn:4> <crm:4> <opc1:4> <opc2:3>
  1623. ARM 64-bit CP15 registers have the following id bit patterns:
  1624. 0x4030 0000 000F <zero:1> <zero:4> <crm:4> <opc1:4> <zero:3>
  1625. ARM CCSIDR registers are demultiplexed by CSSELR value:
  1626. 0x4020 0000 0011 00 <csselr:8>
  1627. ARM 32-bit VFP control registers have the following id bit patterns:
  1628. 0x4020 0000 0012 1 <regno:12>
  1629. ARM 64-bit FP registers have the following id bit patterns:
  1630. 0x4030 0000 0012 0 <regno:12>
  1631. arm64 registers are mapped using the lower 32 bits. The upper 16 of
  1632. that is the register group type, or coprocessor number:
  1633. arm64 core/FP-SIMD registers have the following id bit patterns. Note
  1634. that the size of the access is variable, as the kvm_regs structure
  1635. contains elements ranging from 32 to 128 bits. The index is a 32bit
  1636. value in the kvm_regs structure seen as a 32bit array.
  1637. 0x60x0 0000 0010 <index into the kvm_regs struct:16>
  1638. arm64 CCSIDR registers are demultiplexed by CSSELR value:
  1639. 0x6020 0000 0011 00 <csselr:8>
  1640. arm64 system registers have the following id bit patterns:
  1641. 0x6030 0000 0013 <op0:2> <op1:3> <crn:4> <crm:4> <op2:3>
  1642. MIPS registers are mapped using the lower 32 bits. The upper 16 of that is
  1643. the register group type:
  1644. MIPS core registers (see above) have the following id bit patterns:
  1645. 0x7030 0000 0000 <reg:16>
  1646. MIPS CP0 registers (see KVM_REG_MIPS_CP0_* above) have the following id bit
  1647. patterns depending on whether they're 32-bit or 64-bit registers:
  1648. 0x7020 0000 0001 00 <reg:5> <sel:3> (32-bit)
  1649. 0x7030 0000 0001 00 <reg:5> <sel:3> (64-bit)
  1650. MIPS KVM control registers (see above) have the following id bit patterns:
  1651. 0x7030 0000 0002 <reg:16>
  1652. MIPS FPU registers (see KVM_REG_MIPS_FPR_{32,64}() above) have the following
  1653. id bit patterns depending on the size of the register being accessed. They are
  1654. always accessed according to the current guest FPU mode (Status.FR and
  1655. Config5.FRE), i.e. as the guest would see them, and they become unpredictable
  1656. if the guest FPU mode is changed. MIPS SIMD Architecture (MSA) vector
  1657. registers (see KVM_REG_MIPS_VEC_128() above) have similar patterns as they
  1658. overlap the FPU registers:
  1659. 0x7020 0000 0003 00 <0:3> <reg:5> (32-bit FPU registers)
  1660. 0x7030 0000 0003 00 <0:3> <reg:5> (64-bit FPU registers)
  1661. 0x7040 0000 0003 00 <0:3> <reg:5> (128-bit MSA vector registers)
  1662. MIPS FPU control registers (see KVM_REG_MIPS_FCR_{IR,CSR} above) have the
  1663. following id bit patterns:
  1664. 0x7020 0000 0003 01 <0:3> <reg:5>
  1665. MIPS MSA control registers (see KVM_REG_MIPS_MSA_{IR,CSR} above) have the
  1666. following id bit patterns:
  1667. 0x7020 0000 0003 02 <0:3> <reg:5>
  1668. 4.69 KVM_GET_ONE_REG
  1669. Capability: KVM_CAP_ONE_REG
  1670. Architectures: all
  1671. Type: vcpu ioctl
  1672. Parameters: struct kvm_one_reg (in and out)
  1673. Returns: 0 on success, negative value on failure
  1674. This ioctl allows to receive the value of a single register implemented
  1675. in a vcpu. The register to read is indicated by the "id" field of the
  1676. kvm_one_reg struct passed in. On success, the register value can be found
  1677. at the memory location pointed to by "addr".
  1678. The list of registers accessible using this interface is identical to the
  1679. list in 4.68.
  1680. 4.70 KVM_KVMCLOCK_CTRL
  1681. Capability: KVM_CAP_KVMCLOCK_CTRL
  1682. Architectures: Any that implement pvclocks (currently x86 only)
  1683. Type: vcpu ioctl
  1684. Parameters: None
  1685. Returns: 0 on success, -1 on error
  1686. This signals to the host kernel that the specified guest is being paused by
  1687. userspace. The host will set a flag in the pvclock structure that is checked
  1688. from the soft lockup watchdog. The flag is part of the pvclock structure that
  1689. is shared between guest and host, specifically the second bit of the flags
  1690. field of the pvclock_vcpu_time_info structure. It will be set exclusively by
  1691. the host and read/cleared exclusively by the guest. The guest operation of
  1692. checking and clearing the flag must an atomic operation so
  1693. load-link/store-conditional, or equivalent must be used. There are two cases
  1694. where the guest will clear the flag: when the soft lockup watchdog timer resets
  1695. itself or when a soft lockup is detected. This ioctl can be called any time
  1696. after pausing the vcpu, but before it is resumed.
  1697. 4.71 KVM_SIGNAL_MSI
  1698. Capability: KVM_CAP_SIGNAL_MSI
  1699. Architectures: x86 arm64
  1700. Type: vm ioctl
  1701. Parameters: struct kvm_msi (in)
  1702. Returns: >0 on delivery, 0 if guest blocked the MSI, and -1 on error
  1703. Directly inject a MSI message. Only valid with in-kernel irqchip that handles
  1704. MSI messages.
  1705. struct kvm_msi {
  1706. __u32 address_lo;
  1707. __u32 address_hi;
  1708. __u32 data;
  1709. __u32 flags;
  1710. __u32 devid;
  1711. __u8 pad[12];
  1712. };
  1713. flags: KVM_MSI_VALID_DEVID: devid contains a valid value. The per-VM
  1714. KVM_CAP_MSI_DEVID capability advertises the requirement to provide
  1715. the device ID. If this capability is not available, userspace
  1716. should never set the KVM_MSI_VALID_DEVID flag as the ioctl might fail.
  1717. If KVM_MSI_VALID_DEVID is set, devid contains a unique device identifier
  1718. for the device that wrote the MSI message. For PCI, this is usually a
  1719. BFD identifier in the lower 16 bits.
  1720. On x86, address_hi is ignored unless the KVM_X2APIC_API_USE_32BIT_IDS
  1721. feature of KVM_CAP_X2APIC_API capability is enabled. If it is enabled,
  1722. address_hi bits 31-8 provide bits 31-8 of the destination id. Bits 7-0 of
  1723. address_hi must be zero.
  1724. 4.71 KVM_CREATE_PIT2
  1725. Capability: KVM_CAP_PIT2
  1726. Architectures: x86
  1727. Type: vm ioctl
  1728. Parameters: struct kvm_pit_config (in)
  1729. Returns: 0 on success, -1 on error
  1730. Creates an in-kernel device model for the i8254 PIT. This call is only valid
  1731. after enabling in-kernel irqchip support via KVM_CREATE_IRQCHIP. The following
  1732. parameters have to be passed:
  1733. struct kvm_pit_config {
  1734. __u32 flags;
  1735. __u32 pad[15];
  1736. };
  1737. Valid flags are:
  1738. #define KVM_PIT_SPEAKER_DUMMY 1 /* emulate speaker port stub */
  1739. PIT timer interrupts may use a per-VM kernel thread for injection. If it
  1740. exists, this thread will have a name of the following pattern:
  1741. kvm-pit/<owner-process-pid>
  1742. When running a guest with elevated priorities, the scheduling parameters of
  1743. this thread may have to be adjusted accordingly.
  1744. This IOCTL replaces the obsolete KVM_CREATE_PIT.
  1745. 4.72 KVM_GET_PIT2
  1746. Capability: KVM_CAP_PIT_STATE2
  1747. Architectures: x86
  1748. Type: vm ioctl
  1749. Parameters: struct kvm_pit_state2 (out)
  1750. Returns: 0 on success, -1 on error
  1751. Retrieves the state of the in-kernel PIT model. Only valid after
  1752. KVM_CREATE_PIT2. The state is returned in the following structure:
  1753. struct kvm_pit_state2 {
  1754. struct kvm_pit_channel_state channels[3];
  1755. __u32 flags;
  1756. __u32 reserved[9];
  1757. };
  1758. Valid flags are:
  1759. /* disable PIT in HPET legacy mode */
  1760. #define KVM_PIT_FLAGS_HPET_LEGACY 0x00000001
  1761. This IOCTL replaces the obsolete KVM_GET_PIT.
  1762. 4.73 KVM_SET_PIT2
  1763. Capability: KVM_CAP_PIT_STATE2
  1764. Architectures: x86
  1765. Type: vm ioctl
  1766. Parameters: struct kvm_pit_state2 (in)
  1767. Returns: 0 on success, -1 on error
  1768. Sets the state of the in-kernel PIT model. Only valid after KVM_CREATE_PIT2.
  1769. See KVM_GET_PIT2 for details on struct kvm_pit_state2.
  1770. This IOCTL replaces the obsolete KVM_SET_PIT.
  1771. 4.74 KVM_PPC_GET_SMMU_INFO
  1772. Capability: KVM_CAP_PPC_GET_SMMU_INFO
  1773. Architectures: powerpc
  1774. Type: vm ioctl
  1775. Parameters: None
  1776. Returns: 0 on success, -1 on error
  1777. This populates and returns a structure describing the features of
  1778. the "Server" class MMU emulation supported by KVM.
  1779. This can in turn be used by userspace to generate the appropriate
  1780. device-tree properties for the guest operating system.
  1781. The structure contains some global information, followed by an
  1782. array of supported segment page sizes:
  1783. struct kvm_ppc_smmu_info {
  1784. __u64 flags;
  1785. __u32 slb_size;
  1786. __u32 pad;
  1787. struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ];
  1788. };
  1789. The supported flags are:
  1790. - KVM_PPC_PAGE_SIZES_REAL:
  1791. When that flag is set, guest page sizes must "fit" the backing
  1792. store page sizes. When not set, any page size in the list can
  1793. be used regardless of how they are backed by userspace.
  1794. - KVM_PPC_1T_SEGMENTS
  1795. The emulated MMU supports 1T segments in addition to the
  1796. standard 256M ones.
  1797. The "slb_size" field indicates how many SLB entries are supported
  1798. The "sps" array contains 8 entries indicating the supported base
  1799. page sizes for a segment in increasing order. Each entry is defined
  1800. as follow:
  1801. struct kvm_ppc_one_seg_page_size {
  1802. __u32 page_shift; /* Base page shift of segment (or 0) */
  1803. __u32 slb_enc; /* SLB encoding for BookS */
  1804. struct kvm_ppc_one_page_size enc[KVM_PPC_PAGE_SIZES_MAX_SZ];
  1805. };
  1806. An entry with a "page_shift" of 0 is unused. Because the array is
  1807. organized in increasing order, a lookup can stop when encoutering
  1808. such an entry.
  1809. The "slb_enc" field provides the encoding to use in the SLB for the
  1810. page size. The bits are in positions such as the value can directly
  1811. be OR'ed into the "vsid" argument of the slbmte instruction.
  1812. The "enc" array is a list which for each of those segment base page
  1813. size provides the list of supported actual page sizes (which can be
  1814. only larger or equal to the base page size), along with the
  1815. corresponding encoding in the hash PTE. Similarly, the array is
  1816. 8 entries sorted by increasing sizes and an entry with a "0" shift
  1817. is an empty entry and a terminator:
  1818. struct kvm_ppc_one_page_size {
  1819. __u32 page_shift; /* Page shift (or 0) */
  1820. __u32 pte_enc; /* Encoding in the HPTE (>>12) */
  1821. };
  1822. The "pte_enc" field provides a value that can OR'ed into the hash
  1823. PTE's RPN field (ie, it needs to be shifted left by 12 to OR it
  1824. into the hash PTE second double word).
  1825. 4.75 KVM_IRQFD
  1826. Capability: KVM_CAP_IRQFD
  1827. Architectures: x86 s390 arm arm64
  1828. Type: vm ioctl
  1829. Parameters: struct kvm_irqfd (in)
  1830. Returns: 0 on success, -1 on error
  1831. Allows setting an eventfd to directly trigger a guest interrupt.
  1832. kvm_irqfd.fd specifies the file descriptor to use as the eventfd and
  1833. kvm_irqfd.gsi specifies the irqchip pin toggled by this event. When
  1834. an event is triggered on the eventfd, an interrupt is injected into
  1835. the guest using the specified gsi pin. The irqfd is removed using
  1836. the KVM_IRQFD_FLAG_DEASSIGN flag, specifying both kvm_irqfd.fd
  1837. and kvm_irqfd.gsi.
  1838. With KVM_CAP_IRQFD_RESAMPLE, KVM_IRQFD supports a de-assert and notify
  1839. mechanism allowing emulation of level-triggered, irqfd-based
  1840. interrupts. When KVM_IRQFD_FLAG_RESAMPLE is set the user must pass an
  1841. additional eventfd in the kvm_irqfd.resamplefd field. When operating
  1842. in resample mode, posting of an interrupt through kvm_irq.fd asserts
  1843. the specified gsi in the irqchip. When the irqchip is resampled, such
  1844. as from an EOI, the gsi is de-asserted and the user is notified via
  1845. kvm_irqfd.resamplefd. It is the user's responsibility to re-queue
  1846. the interrupt if the device making use of it still requires service.
  1847. Note that closing the resamplefd is not sufficient to disable the
  1848. irqfd. The KVM_IRQFD_FLAG_RESAMPLE is only necessary on assignment
  1849. and need not be specified with KVM_IRQFD_FLAG_DEASSIGN.
  1850. On arm/arm64, gsi routing being supported, the following can happen:
  1851. - in case no routing entry is associated to this gsi, injection fails
  1852. - in case the gsi is associated to an irqchip routing entry,
  1853. irqchip.pin + 32 corresponds to the injected SPI ID.
  1854. - in case the gsi is associated to an MSI routing entry, the MSI
  1855. message and device ID are translated into an LPI (support restricted
  1856. to GICv3 ITS in-kernel emulation).
  1857. 4.76 KVM_PPC_ALLOCATE_HTAB
  1858. Capability: KVM_CAP_PPC_ALLOC_HTAB
  1859. Architectures: powerpc
  1860. Type: vm ioctl
  1861. Parameters: Pointer to u32 containing hash table order (in/out)
  1862. Returns: 0 on success, -1 on error
  1863. This requests the host kernel to allocate an MMU hash table for a
  1864. guest using the PAPR paravirtualization interface. This only does
  1865. anything if the kernel is configured to use the Book 3S HV style of
  1866. virtualization. Otherwise the capability doesn't exist and the ioctl
  1867. returns an ENOTTY error. The rest of this description assumes Book 3S
  1868. HV.
  1869. There must be no vcpus running when this ioctl is called; if there
  1870. are, it will do nothing and return an EBUSY error.
  1871. The parameter is a pointer to a 32-bit unsigned integer variable
  1872. containing the order (log base 2) of the desired size of the hash
  1873. table, which must be between 18 and 46. On successful return from the
  1874. ioctl, it will have been updated with the order of the hash table that
  1875. was allocated.
  1876. If no hash table has been allocated when any vcpu is asked to run
  1877. (with the KVM_RUN ioctl), the host kernel will allocate a
  1878. default-sized hash table (16 MB).
  1879. If this ioctl is called when a hash table has already been allocated,
  1880. the kernel will clear out the existing hash table (zero all HPTEs) and
  1881. return the hash table order in the parameter. (If the guest is using
  1882. the virtualized real-mode area (VRMA) facility, the kernel will
  1883. re-create the VMRA HPTEs on the next KVM_RUN of any vcpu.)
  1884. 4.77 KVM_S390_INTERRUPT
  1885. Capability: basic
  1886. Architectures: s390
  1887. Type: vm ioctl, vcpu ioctl
  1888. Parameters: struct kvm_s390_interrupt (in)
  1889. Returns: 0 on success, -1 on error
  1890. Allows to inject an interrupt to the guest. Interrupts can be floating
  1891. (vm ioctl) or per cpu (vcpu ioctl), depending on the interrupt type.
  1892. Interrupt parameters are passed via kvm_s390_interrupt:
  1893. struct kvm_s390_interrupt {
  1894. __u32 type;
  1895. __u32 parm;
  1896. __u64 parm64;
  1897. };
  1898. type can be one of the following:
  1899. KVM_S390_SIGP_STOP (vcpu) - sigp stop; optional flags in parm
  1900. KVM_S390_PROGRAM_INT (vcpu) - program check; code in parm
  1901. KVM_S390_SIGP_SET_PREFIX (vcpu) - sigp set prefix; prefix address in parm
  1902. KVM_S390_RESTART (vcpu) - restart
  1903. KVM_S390_INT_CLOCK_COMP (vcpu) - clock comparator interrupt
  1904. KVM_S390_INT_CPU_TIMER (vcpu) - CPU timer interrupt
  1905. KVM_S390_INT_VIRTIO (vm) - virtio external interrupt; external interrupt
  1906. parameters in parm and parm64
  1907. KVM_S390_INT_SERVICE (vm) - sclp external interrupt; sclp parameter in parm
  1908. KVM_S390_INT_EMERGENCY (vcpu) - sigp emergency; source cpu in parm
  1909. KVM_S390_INT_EXTERNAL_CALL (vcpu) - sigp external call; source cpu in parm
  1910. KVM_S390_INT_IO(ai,cssid,ssid,schid) (vm) - compound value to indicate an
  1911. I/O interrupt (ai - adapter interrupt; cssid,ssid,schid - subchannel);
  1912. I/O interruption parameters in parm (subchannel) and parm64 (intparm,
  1913. interruption subclass)
  1914. KVM_S390_MCHK (vm, vcpu) - machine check interrupt; cr 14 bits in parm,
  1915. machine check interrupt code in parm64 (note that
  1916. machine checks needing further payload are not
  1917. supported by this ioctl)
  1918. Note that the vcpu ioctl is asynchronous to vcpu execution.
  1919. 4.78 KVM_PPC_GET_HTAB_FD
  1920. Capability: KVM_CAP_PPC_HTAB_FD
  1921. Architectures: powerpc
  1922. Type: vm ioctl
  1923. Parameters: Pointer to struct kvm_get_htab_fd (in)
  1924. Returns: file descriptor number (>= 0) on success, -1 on error
  1925. This returns a file descriptor that can be used either to read out the
  1926. entries in the guest's hashed page table (HPT), or to write entries to
  1927. initialize the HPT. The returned fd can only be written to if the
  1928. KVM_GET_HTAB_WRITE bit is set in the flags field of the argument, and
  1929. can only be read if that bit is clear. The argument struct looks like
  1930. this:
  1931. /* For KVM_PPC_GET_HTAB_FD */
  1932. struct kvm_get_htab_fd {
  1933. __u64 flags;
  1934. __u64 start_index;
  1935. __u64 reserved[2];
  1936. };
  1937. /* Values for kvm_get_htab_fd.flags */
  1938. #define KVM_GET_HTAB_BOLTED_ONLY ((__u64)0x1)
  1939. #define KVM_GET_HTAB_WRITE ((__u64)0x2)
  1940. The `start_index' field gives the index in the HPT of the entry at
  1941. which to start reading. It is ignored when writing.
  1942. Reads on the fd will initially supply information about all
  1943. "interesting" HPT entries. Interesting entries are those with the
  1944. bolted bit set, if the KVM_GET_HTAB_BOLTED_ONLY bit is set, otherwise
  1945. all entries. When the end of the HPT is reached, the read() will
  1946. return. If read() is called again on the fd, it will start again from
  1947. the beginning of the HPT, but will only return HPT entries that have
  1948. changed since they were last read.
  1949. Data read or written is structured as a header (8 bytes) followed by a
  1950. series of valid HPT entries (16 bytes) each. The header indicates how
  1951. many valid HPT entries there are and how many invalid entries follow
  1952. the valid entries. The invalid entries are not represented explicitly
  1953. in the stream. The header format is:
  1954. struct kvm_get_htab_header {
  1955. __u32 index;
  1956. __u16 n_valid;
  1957. __u16 n_invalid;
  1958. };
  1959. Writes to the fd create HPT entries starting at the index given in the
  1960. header; first `n_valid' valid entries with contents from the data
  1961. written, then `n_invalid' invalid entries, invalidating any previously
  1962. valid entries found.
  1963. 4.79 KVM_CREATE_DEVICE
  1964. Capability: KVM_CAP_DEVICE_CTRL
  1965. Type: vm ioctl
  1966. Parameters: struct kvm_create_device (in/out)
  1967. Returns: 0 on success, -1 on error
  1968. Errors:
  1969. ENODEV: The device type is unknown or unsupported
  1970. EEXIST: Device already created, and this type of device may not
  1971. be instantiated multiple times
  1972. Other error conditions may be defined by individual device types or
  1973. have their standard meanings.
  1974. Creates an emulated device in the kernel. The file descriptor returned
  1975. in fd can be used with KVM_SET/GET/HAS_DEVICE_ATTR.
  1976. If the KVM_CREATE_DEVICE_TEST flag is set, only test whether the
  1977. device type is supported (not necessarily whether it can be created
  1978. in the current vm).
  1979. Individual devices should not define flags. Attributes should be used
  1980. for specifying any behavior that is not implied by the device type
  1981. number.
  1982. struct kvm_create_device {
  1983. __u32 type; /* in: KVM_DEV_TYPE_xxx */
  1984. __u32 fd; /* out: device handle */
  1985. __u32 flags; /* in: KVM_CREATE_DEVICE_xxx */
  1986. };
  1987. 4.80 KVM_SET_DEVICE_ATTR/KVM_GET_DEVICE_ATTR
  1988. Capability: KVM_CAP_DEVICE_CTRL, KVM_CAP_VM_ATTRIBUTES for vm device,
  1989. KVM_CAP_VCPU_ATTRIBUTES for vcpu device
  1990. Type: device ioctl, vm ioctl, vcpu ioctl
  1991. Parameters: struct kvm_device_attr
  1992. Returns: 0 on success, -1 on error
  1993. Errors:
  1994. ENXIO: The group or attribute is unknown/unsupported for this device
  1995. or hardware support is missing.
  1996. EPERM: The attribute cannot (currently) be accessed this way
  1997. (e.g. read-only attribute, or attribute that only makes
  1998. sense when the device is in a different state)
  1999. Other error conditions may be defined by individual device types.
  2000. Gets/sets a specified piece of device configuration and/or state. The
  2001. semantics are device-specific. See individual device documentation in
  2002. the "devices" directory. As with ONE_REG, the size of the data
  2003. transferred is defined by the particular attribute.
  2004. struct kvm_device_attr {
  2005. __u32 flags; /* no flags currently defined */
  2006. __u32 group; /* device-defined */
  2007. __u64 attr; /* group-defined */
  2008. __u64 addr; /* userspace address of attr data */
  2009. };
  2010. 4.81 KVM_HAS_DEVICE_ATTR
  2011. Capability: KVM_CAP_DEVICE_CTRL, KVM_CAP_VM_ATTRIBUTES for vm device,
  2012. KVM_CAP_VCPU_ATTRIBUTES for vcpu device
  2013. Type: device ioctl, vm ioctl, vcpu ioctl
  2014. Parameters: struct kvm_device_attr
  2015. Returns: 0 on success, -1 on error
  2016. Errors:
  2017. ENXIO: The group or attribute is unknown/unsupported for this device
  2018. or hardware support is missing.
  2019. Tests whether a device supports a particular attribute. A successful
  2020. return indicates the attribute is implemented. It does not necessarily
  2021. indicate that the attribute can be read or written in the device's
  2022. current state. "addr" is ignored.
  2023. 4.82 KVM_ARM_VCPU_INIT
  2024. Capability: basic
  2025. Architectures: arm, arm64
  2026. Type: vcpu ioctl
  2027. Parameters: struct kvm_vcpu_init (in)
  2028. Returns: 0 on success; -1 on error
  2029. Errors:
  2030.  EINVAL:    the target is unknown, or the combination of features is invalid.
  2031.  ENOENT:    a features bit specified is unknown.
  2032. This tells KVM what type of CPU to present to the guest, and what
  2033. optional features it should have.  This will cause a reset of the cpu
  2034. registers to their initial values.  If this is not called, KVM_RUN will
  2035. return ENOEXEC for that vcpu.
  2036. Note that because some registers reflect machine topology, all vcpus
  2037. should be created before this ioctl is invoked.
  2038. Userspace can call this function multiple times for a given vcpu, including
  2039. after the vcpu has been run. This will reset the vcpu to its initial
  2040. state. All calls to this function after the initial call must use the same
  2041. target and same set of feature flags, otherwise EINVAL will be returned.
  2042. Possible features:
  2043. - KVM_ARM_VCPU_POWER_OFF: Starts the CPU in a power-off state.
  2044. Depends on KVM_CAP_ARM_PSCI. If not set, the CPU will be powered on
  2045. and execute guest code when KVM_RUN is called.
  2046. - KVM_ARM_VCPU_EL1_32BIT: Starts the CPU in a 32bit mode.
  2047. Depends on KVM_CAP_ARM_EL1_32BIT (arm64 only).
  2048. - KVM_ARM_VCPU_PSCI_0_2: Emulate PSCI v0.2 for the CPU.
  2049. Depends on KVM_CAP_ARM_PSCI_0_2.
  2050. - KVM_ARM_VCPU_PMU_V3: Emulate PMUv3 for the CPU.
  2051. Depends on KVM_CAP_ARM_PMU_V3.
  2052. 4.83 KVM_ARM_PREFERRED_TARGET
  2053. Capability: basic
  2054. Architectures: arm, arm64
  2055. Type: vm ioctl
  2056. Parameters: struct struct kvm_vcpu_init (out)
  2057. Returns: 0 on success; -1 on error
  2058. Errors:
  2059. ENODEV: no preferred target available for the host
  2060. This queries KVM for preferred CPU target type which can be emulated
  2061. by KVM on underlying host.
  2062. The ioctl returns struct kvm_vcpu_init instance containing information
  2063. about preferred CPU target type and recommended features for it. The
  2064. kvm_vcpu_init->features bitmap returned will have feature bits set if
  2065. the preferred target recommends setting these features, but this is
  2066. not mandatory.
  2067. The information returned by this ioctl can be used to prepare an instance
  2068. of struct kvm_vcpu_init for KVM_ARM_VCPU_INIT ioctl which will result in
  2069. in VCPU matching underlying host.
  2070. 4.84 KVM_GET_REG_LIST
  2071. Capability: basic
  2072. Architectures: arm, arm64, mips
  2073. Type: vcpu ioctl
  2074. Parameters: struct kvm_reg_list (in/out)
  2075. Returns: 0 on success; -1 on error
  2076. Errors:
  2077.  E2BIG:     the reg index list is too big to fit in the array specified by
  2078.             the user (the number required will be written into n).
  2079. struct kvm_reg_list {
  2080. __u64 n; /* number of registers in reg[] */
  2081. __u64 reg[0];
  2082. };
  2083. This ioctl returns the guest registers that are supported for the
  2084. KVM_GET_ONE_REG/KVM_SET_ONE_REG calls.
  2085. 4.85 KVM_ARM_SET_DEVICE_ADDR (deprecated)
  2086. Capability: KVM_CAP_ARM_SET_DEVICE_ADDR
  2087. Architectures: arm, arm64
  2088. Type: vm ioctl
  2089. Parameters: struct kvm_arm_device_address (in)
  2090. Returns: 0 on success, -1 on error
  2091. Errors:
  2092. ENODEV: The device id is unknown
  2093. ENXIO: Device not supported on current system
  2094. EEXIST: Address already set
  2095. E2BIG: Address outside guest physical address space
  2096. EBUSY: Address overlaps with other device range
  2097. struct kvm_arm_device_addr {
  2098. __u64 id;
  2099. __u64 addr;
  2100. };
  2101. Specify a device address in the guest's physical address space where guests
  2102. can access emulated or directly exposed devices, which the host kernel needs
  2103. to know about. The id field is an architecture specific identifier for a
  2104. specific device.
  2105. ARM/arm64 divides the id field into two parts, a device id and an
  2106. address type id specific to the individual device.
  2107.  bits: | 63 ... 32 | 31 ... 16 | 15 ... 0 |
  2108. field: | 0x00000000 | device id | addr type id |
  2109. ARM/arm64 currently only require this when using the in-kernel GIC
  2110. support for the hardware VGIC features, using KVM_ARM_DEVICE_VGIC_V2
  2111. as the device id. When setting the base address for the guest's
  2112. mapping of the VGIC virtual CPU and distributor interface, the ioctl
  2113. must be called after calling KVM_CREATE_IRQCHIP, but before calling
  2114. KVM_RUN on any of the VCPUs. Calling this ioctl twice for any of the
  2115. base addresses will return -EEXIST.
  2116. Note, this IOCTL is deprecated and the more flexible SET/GET_DEVICE_ATTR API
  2117. should be used instead.
  2118. 4.86 KVM_PPC_RTAS_DEFINE_TOKEN
  2119. Capability: KVM_CAP_PPC_RTAS
  2120. Architectures: ppc
  2121. Type: vm ioctl
  2122. Parameters: struct kvm_rtas_token_args
  2123. Returns: 0 on success, -1 on error
  2124. Defines a token value for a RTAS (Run Time Abstraction Services)
  2125. service in order to allow it to be handled in the kernel. The
  2126. argument struct gives the name of the service, which must be the name
  2127. of a service that has a kernel-side implementation. If the token
  2128. value is non-zero, it will be associated with that service, and
  2129. subsequent RTAS calls by the guest specifying that token will be
  2130. handled by the kernel. If the token value is 0, then any token
  2131. associated with the service will be forgotten, and subsequent RTAS
  2132. calls by the guest for that service will be passed to userspace to be
  2133. handled.
  2134. 4.87 KVM_SET_GUEST_DEBUG
  2135. Capability: KVM_CAP_SET_GUEST_DEBUG
  2136. Architectures: x86, s390, ppc, arm64
  2137. Type: vcpu ioctl
  2138. Parameters: struct kvm_guest_debug (in)
  2139. Returns: 0 on success; -1 on error
  2140. struct kvm_guest_debug {
  2141. __u32 control;
  2142. __u32 pad;
  2143. struct kvm_guest_debug_arch arch;
  2144. };
  2145. Set up the processor specific debug registers and configure vcpu for
  2146. handling guest debug events. There are two parts to the structure, the
  2147. first a control bitfield indicates the type of debug events to handle
  2148. when running. Common control bits are:
  2149. - KVM_GUESTDBG_ENABLE: guest debugging is enabled
  2150. - KVM_GUESTDBG_SINGLESTEP: the next run should single-step
  2151. The top 16 bits of the control field are architecture specific control
  2152. flags which can include the following:
  2153. - KVM_GUESTDBG_USE_SW_BP: using software breakpoints [x86, arm64]
  2154. - KVM_GUESTDBG_USE_HW_BP: using hardware breakpoints [x86, s390, arm64]
  2155. - KVM_GUESTDBG_INJECT_DB: inject DB type exception [x86]
  2156. - KVM_GUESTDBG_INJECT_BP: inject BP type exception [x86]
  2157. - KVM_GUESTDBG_EXIT_PENDING: trigger an immediate guest exit [s390]
  2158. For example KVM_GUESTDBG_USE_SW_BP indicates that software breakpoints
  2159. are enabled in memory so we need to ensure breakpoint exceptions are
  2160. correctly trapped and the KVM run loop exits at the breakpoint and not
  2161. running off into the normal guest vector. For KVM_GUESTDBG_USE_HW_BP
  2162. we need to ensure the guest vCPUs architecture specific registers are
  2163. updated to the correct (supplied) values.
  2164. The second part of the structure is architecture specific and
  2165. typically contains a set of debug registers.
  2166. For arm64 the number of debug registers is implementation defined and
  2167. can be determined by querying the KVM_CAP_GUEST_DEBUG_HW_BPS and
  2168. KVM_CAP_GUEST_DEBUG_HW_WPS capabilities which return a positive number
  2169. indicating the number of supported registers.
  2170. When debug events exit the main run loop with the reason
  2171. KVM_EXIT_DEBUG with the kvm_debug_exit_arch part of the kvm_run
  2172. structure containing architecture specific debug information.
  2173. 4.88 KVM_GET_EMULATED_CPUID
  2174. Capability: KVM_CAP_EXT_EMUL_CPUID
  2175. Architectures: x86
  2176. Type: system ioctl
  2177. Parameters: struct kvm_cpuid2 (in/out)
  2178. Returns: 0 on success, -1 on error
  2179. struct kvm_cpuid2 {
  2180. __u32 nent;
  2181. __u32 flags;
  2182. struct kvm_cpuid_entry2 entries[0];
  2183. };
  2184. The member 'flags' is used for passing flags from userspace.
  2185. #define KVM_CPUID_FLAG_SIGNIFCANT_INDEX BIT(0)
  2186. #define KVM_CPUID_FLAG_STATEFUL_FUNC BIT(1)
  2187. #define KVM_CPUID_FLAG_STATE_READ_NEXT BIT(2)
  2188. struct kvm_cpuid_entry2 {
  2189. __u32 function;
  2190. __u32 index;
  2191. __u32 flags;
  2192. __u32 eax;
  2193. __u32 ebx;
  2194. __u32 ecx;
  2195. __u32 edx;
  2196. __u32 padding[3];
  2197. };
  2198. This ioctl returns x86 cpuid features which are emulated by
  2199. kvm.Userspace can use the information returned by this ioctl to query
  2200. which features are emulated by kvm instead of being present natively.
  2201. Userspace invokes KVM_GET_EMULATED_CPUID by passing a kvm_cpuid2
  2202. structure with the 'nent' field indicating the number of entries in
  2203. the variable-size array 'entries'. If the number of entries is too low
  2204. to describe the cpu capabilities, an error (E2BIG) is returned. If the
  2205. number is too high, the 'nent' field is adjusted and an error (ENOMEM)
  2206. is returned. If the number is just right, the 'nent' field is adjusted
  2207. to the number of valid entries in the 'entries' array, which is then
  2208. filled.
  2209. The entries returned are the set CPUID bits of the respective features
  2210. which kvm emulates, as returned by the CPUID instruction, with unknown
  2211. or unsupported feature bits cleared.
  2212. Features like x2apic, for example, may not be present in the host cpu
  2213. but are exposed by kvm in KVM_GET_SUPPORTED_CPUID because they can be
  2214. emulated efficiently and thus not included here.
  2215. The fields in each entry are defined as follows:
  2216. function: the eax value used to obtain the entry
  2217. index: the ecx value used to obtain the entry (for entries that are
  2218. affected by ecx)
  2219. flags: an OR of zero or more of the following:
  2220. KVM_CPUID_FLAG_SIGNIFCANT_INDEX:
  2221. if the index field is valid
  2222. KVM_CPUID_FLAG_STATEFUL_FUNC:
  2223. if cpuid for this function returns different values for successive
  2224. invocations; there will be several entries with the same function,
  2225. all with this flag set
  2226. KVM_CPUID_FLAG_STATE_READ_NEXT:
  2227. for KVM_CPUID_FLAG_STATEFUL_FUNC entries, set if this entry is
  2228. the first entry to be read by a cpu
  2229. eax, ebx, ecx, edx: the values returned by the cpuid instruction for
  2230. this function/index combination
  2231. 4.89 KVM_S390_MEM_OP
  2232. Capability: KVM_CAP_S390_MEM_OP
  2233. Architectures: s390
  2234. Type: vcpu ioctl
  2235. Parameters: struct kvm_s390_mem_op (in)
  2236. Returns: = 0 on success,
  2237. < 0 on generic error (e.g. -EFAULT or -ENOMEM),
  2238. > 0 if an exception occurred while walking the page tables
  2239. Read or write data from/to the logical (virtual) memory of a VCPU.
  2240. Parameters are specified via the following structure:
  2241. struct kvm_s390_mem_op {
  2242. __u64 gaddr; /* the guest address */
  2243. __u64 flags; /* flags */
  2244. __u32 size; /* amount of bytes */
  2245. __u32 op; /* type of operation */
  2246. __u64 buf; /* buffer in userspace */
  2247. __u8 ar; /* the access register number */
  2248. __u8 reserved[31]; /* should be set to 0 */
  2249. };
  2250. The type of operation is specified in the "op" field. It is either
  2251. KVM_S390_MEMOP_LOGICAL_READ for reading from logical memory space or
  2252. KVM_S390_MEMOP_LOGICAL_WRITE for writing to logical memory space. The
  2253. KVM_S390_MEMOP_F_CHECK_ONLY flag can be set in the "flags" field to check
  2254. whether the corresponding memory access would create an access exception
  2255. (without touching the data in the memory at the destination). In case an
  2256. access exception occurred while walking the MMU tables of the guest, the
  2257. ioctl returns a positive error number to indicate the type of exception.
  2258. This exception is also raised directly at the corresponding VCPU if the
  2259. flag KVM_S390_MEMOP_F_INJECT_EXCEPTION is set in the "flags" field.
  2260. The start address of the memory region has to be specified in the "gaddr"
  2261. field, and the length of the region in the "size" field. "buf" is the buffer
  2262. supplied by the userspace application where the read data should be written
  2263. to for KVM_S390_MEMOP_LOGICAL_READ, or where the data that should be written
  2264. is stored for a KVM_S390_MEMOP_LOGICAL_WRITE. "buf" is unused and can be NULL
  2265. when KVM_S390_MEMOP_F_CHECK_ONLY is specified. "ar" designates the access
  2266. register number to be used.
  2267. The "reserved" field is meant for future extensions. It is not used by
  2268. KVM with the currently defined set of flags.
  2269. 4.90 KVM_S390_GET_SKEYS
  2270. Capability: KVM_CAP_S390_SKEYS
  2271. Architectures: s390
  2272. Type: vm ioctl
  2273. Parameters: struct kvm_s390_skeys
  2274. Returns: 0 on success, KVM_S390_GET_KEYS_NONE if guest is not using storage
  2275. keys, negative value on error
  2276. This ioctl is used to get guest storage key values on the s390
  2277. architecture. The ioctl takes parameters via the kvm_s390_skeys struct.
  2278. struct kvm_s390_skeys {
  2279. __u64 start_gfn;
  2280. __u64 count;
  2281. __u64 skeydata_addr;
  2282. __u32 flags;
  2283. __u32 reserved[9];
  2284. };
  2285. The start_gfn field is the number of the first guest frame whose storage keys
  2286. you want to get.
  2287. The count field is the number of consecutive frames (starting from start_gfn)
  2288. whose storage keys to get. The count field must be at least 1 and the maximum
  2289. allowed value is defined as KVM_S390_SKEYS_ALLOC_MAX. Values outside this range
  2290. will cause the ioctl to return -EINVAL.
  2291. The skeydata_addr field is the address to a buffer large enough to hold count
  2292. bytes. This buffer will be filled with storage key data by the ioctl.
  2293. 4.91 KVM_S390_SET_SKEYS
  2294. Capability: KVM_CAP_S390_SKEYS
  2295. Architectures: s390
  2296. Type: vm ioctl
  2297. Parameters: struct kvm_s390_skeys
  2298. Returns: 0 on success, negative value on error
  2299. This ioctl is used to set guest storage key values on the s390
  2300. architecture. The ioctl takes parameters via the kvm_s390_skeys struct.
  2301. See section on KVM_S390_GET_SKEYS for struct definition.
  2302. The start_gfn field is the number of the first guest frame whose storage keys
  2303. you want to set.
  2304. The count field is the number of consecutive frames (starting from start_gfn)
  2305. whose storage keys to get. The count field must be at least 1 and the maximum
  2306. allowed value is defined as KVM_S390_SKEYS_ALLOC_MAX. Values outside this range
  2307. will cause the ioctl to return -EINVAL.
  2308. The skeydata_addr field is the address to a buffer containing count bytes of
  2309. storage keys. Each byte in the buffer will be set as the storage key for a
  2310. single frame starting at start_gfn for count frames.
  2311. Note: If any architecturally invalid key value is found in the given data then
  2312. the ioctl will return -EINVAL.
  2313. 4.92 KVM_S390_IRQ
  2314. Capability: KVM_CAP_S390_INJECT_IRQ
  2315. Architectures: s390
  2316. Type: vcpu ioctl
  2317. Parameters: struct kvm_s390_irq (in)
  2318. Returns: 0 on success, -1 on error
  2319. Errors:
  2320. EINVAL: interrupt type is invalid
  2321. type is KVM_S390_SIGP_STOP and flag parameter is invalid value
  2322. type is KVM_S390_INT_EXTERNAL_CALL and code is bigger
  2323. than the maximum of VCPUs
  2324. EBUSY: type is KVM_S390_SIGP_SET_PREFIX and vcpu is not stopped
  2325. type is KVM_S390_SIGP_STOP and a stop irq is already pending
  2326. type is KVM_S390_INT_EXTERNAL_CALL and an external call interrupt
  2327. is already pending
  2328. Allows to inject an interrupt to the guest.
  2329. Using struct kvm_s390_irq as a parameter allows
  2330. to inject additional payload which is not
  2331. possible via KVM_S390_INTERRUPT.
  2332. Interrupt parameters are passed via kvm_s390_irq:
  2333. struct kvm_s390_irq {
  2334. __u64 type;
  2335. union {
  2336. struct kvm_s390_io_info io;
  2337. struct kvm_s390_ext_info ext;
  2338. struct kvm_s390_pgm_info pgm;
  2339. struct kvm_s390_emerg_info emerg;
  2340. struct kvm_s390_extcall_info extcall;
  2341. struct kvm_s390_prefix_info prefix;
  2342. struct kvm_s390_stop_info stop;
  2343. struct kvm_s390_mchk_info mchk;
  2344. char reserved[64];
  2345. } u;
  2346. };
  2347. type can be one of the following:
  2348. KVM_S390_SIGP_STOP - sigp stop; parameter in .stop
  2349. KVM_S390_PROGRAM_INT - program check; parameters in .pgm
  2350. KVM_S390_SIGP_SET_PREFIX - sigp set prefix; parameters in .prefix
  2351. KVM_S390_RESTART - restart; no parameters
  2352. KVM_S390_INT_CLOCK_COMP - clock comparator interrupt; no parameters
  2353. KVM_S390_INT_CPU_TIMER - CPU timer interrupt; no parameters
  2354. KVM_S390_INT_EMERGENCY - sigp emergency; parameters in .emerg
  2355. KVM_S390_INT_EXTERNAL_CALL - sigp external call; parameters in .extcall
  2356. KVM_S390_MCHK - machine check interrupt; parameters in .mchk
  2357. Note that the vcpu ioctl is asynchronous to vcpu execution.
  2358. 4.94 KVM_S390_GET_IRQ_STATE
  2359. Capability: KVM_CAP_S390_IRQ_STATE
  2360. Architectures: s390
  2361. Type: vcpu ioctl
  2362. Parameters: struct kvm_s390_irq_state (out)
  2363. Returns: >= number of bytes copied into buffer,
  2364. -EINVAL if buffer size is 0,
  2365. -ENOBUFS if buffer size is too small to fit all pending interrupts,
  2366. -EFAULT if the buffer address was invalid
  2367. This ioctl allows userspace to retrieve the complete state of all currently
  2368. pending interrupts in a single buffer. Use cases include migration
  2369. and introspection. The parameter structure contains the address of a
  2370. userspace buffer and its length:
  2371. struct kvm_s390_irq_state {
  2372. __u64 buf;
  2373. __u32 flags;
  2374. __u32 len;
  2375. __u32 reserved[4];
  2376. };
  2377. Userspace passes in the above struct and for each pending interrupt a
  2378. struct kvm_s390_irq is copied to the provided buffer.
  2379. If -ENOBUFS is returned the buffer provided was too small and userspace
  2380. may retry with a bigger buffer.
  2381. 4.95 KVM_S390_SET_IRQ_STATE
  2382. Capability: KVM_CAP_S390_IRQ_STATE
  2383. Architectures: s390
  2384. Type: vcpu ioctl
  2385. Parameters: struct kvm_s390_irq_state (in)
  2386. Returns: 0 on success,
  2387. -EFAULT if the buffer address was invalid,
  2388. -EINVAL for an invalid buffer length (see below),
  2389. -EBUSY if there were already interrupts pending,
  2390. errors occurring when actually injecting the
  2391. interrupt. See KVM_S390_IRQ.
  2392. This ioctl allows userspace to set the complete state of all cpu-local
  2393. interrupts currently pending for the vcpu. It is intended for restoring
  2394. interrupt state after a migration. The input parameter is a userspace buffer
  2395. containing a struct kvm_s390_irq_state:
  2396. struct kvm_s390_irq_state {
  2397. __u64 buf;
  2398. __u32 len;
  2399. __u32 pad;
  2400. };
  2401. The userspace memory referenced by buf contains a struct kvm_s390_irq
  2402. for each interrupt to be injected into the guest.
  2403. If one of the interrupts could not be injected for some reason the
  2404. ioctl aborts.
  2405. len must be a multiple of sizeof(struct kvm_s390_irq). It must be > 0
  2406. and it must not exceed (max_vcpus + 32) * sizeof(struct kvm_s390_irq),
  2407. which is the maximum number of possibly pending cpu-local interrupts.
  2408. 4.96 KVM_SMI
  2409. Capability: KVM_CAP_X86_SMM
  2410. Architectures: x86
  2411. Type: vcpu ioctl
  2412. Parameters: none
  2413. Returns: 0 on success, -1 on error
  2414. Queues an SMI on the thread's vcpu.
  2415. 4.97 KVM_CAP_PPC_MULTITCE
  2416. Capability: KVM_CAP_PPC_MULTITCE
  2417. Architectures: ppc
  2418. Type: vm
  2419. This capability means the kernel is capable of handling hypercalls
  2420. H_PUT_TCE_INDIRECT and H_STUFF_TCE without passing those into the user
  2421. space. This significantly accelerates DMA operations for PPC KVM guests.
  2422. User space should expect that its handlers for these hypercalls
  2423. are not going to be called if user space previously registered LIOBN
  2424. in KVM (via KVM_CREATE_SPAPR_TCE or similar calls).
  2425. In order to enable H_PUT_TCE_INDIRECT and H_STUFF_TCE use in the guest,
  2426. user space might have to advertise it for the guest. For example,
  2427. IBM pSeries (sPAPR) guest starts using them if "hcall-multi-tce" is
  2428. present in the "ibm,hypertas-functions" device-tree property.
  2429. The hypercalls mentioned above may or may not be processed successfully
  2430. in the kernel based fast path. If they can not be handled by the kernel,
  2431. they will get passed on to user space. So user space still has to have
  2432. an implementation for these despite the in kernel acceleration.
  2433. This capability is always enabled.
  2434. 4.98 KVM_CREATE_SPAPR_TCE_64
  2435. Capability: KVM_CAP_SPAPR_TCE_64
  2436. Architectures: powerpc
  2437. Type: vm ioctl
  2438. Parameters: struct kvm_create_spapr_tce_64 (in)
  2439. Returns: file descriptor for manipulating the created TCE table
  2440. This is an extension for KVM_CAP_SPAPR_TCE which only supports 32bit
  2441. windows, described in 4.62 KVM_CREATE_SPAPR_TCE
  2442. This capability uses extended struct in ioctl interface:
  2443. /* for KVM_CAP_SPAPR_TCE_64 */
  2444. struct kvm_create_spapr_tce_64 {
  2445. __u64 liobn;
  2446. __u32 page_shift;
  2447. __u32 flags;
  2448. __u64 offset; /* in pages */
  2449. __u64 size; /* in pages */
  2450. };
  2451. The aim of extension is to support an additional bigger DMA window with
  2452. a variable page size.
  2453. KVM_CREATE_SPAPR_TCE_64 receives a 64bit window size, an IOMMU page shift and
  2454. a bus offset of the corresponding DMA window, @size and @offset are numbers
  2455. of IOMMU pages.
  2456. @flags are not used at the moment.
  2457. The rest of functionality is identical to KVM_CREATE_SPAPR_TCE.
  2458. 4.98 KVM_REINJECT_CONTROL
  2459. Capability: KVM_CAP_REINJECT_CONTROL
  2460. Architectures: x86
  2461. Type: vm ioctl
  2462. Parameters: struct kvm_reinject_control (in)
  2463. Returns: 0 on success,
  2464. -EFAULT if struct kvm_reinject_control cannot be read,
  2465. -ENXIO if KVM_CREATE_PIT or KVM_CREATE_PIT2 didn't succeed earlier.
  2466. i8254 (PIT) has two modes, reinject and !reinject. The default is reinject,
  2467. where KVM queues elapsed i8254 ticks and monitors completion of interrupt from
  2468. vector(s) that i8254 injects. Reinject mode dequeues a tick and injects its
  2469. interrupt whenever there isn't a pending interrupt from i8254.
  2470. !reinject mode injects an interrupt as soon as a tick arrives.
  2471. struct kvm_reinject_control {
  2472. __u8 pit_reinject;
  2473. __u8 reserved[31];
  2474. };
  2475. pit_reinject = 0 (!reinject mode) is recommended, unless running an old
  2476. operating system that uses the PIT for timing (e.g. Linux 2.4.x).
  2477. 5. The kvm_run structure
  2478. ------------------------
  2479. Application code obtains a pointer to the kvm_run structure by
  2480. mmap()ing a vcpu fd. From that point, application code can control
  2481. execution by changing fields in kvm_run prior to calling the KVM_RUN
  2482. ioctl, and obtain information about the reason KVM_RUN returned by
  2483. looking up structure members.
  2484. struct kvm_run {
  2485. /* in */
  2486. __u8 request_interrupt_window;
  2487. Request that KVM_RUN return when it becomes possible to inject external
  2488. interrupts into the guest. Useful in conjunction with KVM_INTERRUPT.
  2489. __u8 padding1[7];
  2490. /* out */
  2491. __u32 exit_reason;
  2492. When KVM_RUN has returned successfully (return value 0), this informs
  2493. application code why KVM_RUN has returned. Allowable values for this
  2494. field are detailed below.
  2495. __u8 ready_for_interrupt_injection;
  2496. If request_interrupt_window has been specified, this field indicates
  2497. an interrupt can be injected now with KVM_INTERRUPT.
  2498. __u8 if_flag;
  2499. The value of the current interrupt flag. Only valid if in-kernel
  2500. local APIC is not used.
  2501. __u16 flags;
  2502. More architecture-specific flags detailing state of the VCPU that may
  2503. affect the device's behavior. The only currently defined flag is
  2504. KVM_RUN_X86_SMM, which is valid on x86 machines and is set if the
  2505. VCPU is in system management mode.
  2506. /* in (pre_kvm_run), out (post_kvm_run) */
  2507. __u64 cr8;
  2508. The value of the cr8 register. Only valid if in-kernel local APIC is
  2509. not used. Both input and output.
  2510. __u64 apic_base;
  2511. The value of the APIC BASE msr. Only valid if in-kernel local
  2512. APIC is not used. Both input and output.
  2513. union {
  2514. /* KVM_EXIT_UNKNOWN */
  2515. struct {
  2516. __u64 hardware_exit_reason;
  2517. } hw;
  2518. If exit_reason is KVM_EXIT_UNKNOWN, the vcpu has exited due to unknown
  2519. reasons. Further architecture-specific information is available in
  2520. hardware_exit_reason.
  2521. /* KVM_EXIT_FAIL_ENTRY */
  2522. struct {
  2523. __u64 hardware_entry_failure_reason;
  2524. } fail_entry;
  2525. If exit_reason is KVM_EXIT_FAIL_ENTRY, the vcpu could not be run due
  2526. to unknown reasons. Further architecture-specific information is
  2527. available in hardware_entry_failure_reason.
  2528. /* KVM_EXIT_EXCEPTION */
  2529. struct {
  2530. __u32 exception;
  2531. __u32 error_code;
  2532. } ex;
  2533. Unused.
  2534. /* KVM_EXIT_IO */
  2535. struct {
  2536. #define KVM_EXIT_IO_IN 0
  2537. #define KVM_EXIT_IO_OUT 1
  2538. __u8 direction;
  2539. __u8 size; /* bytes */
  2540. __u16 port;
  2541. __u32 count;
  2542. __u64 data_offset; /* relative to kvm_run start */
  2543. } io;
  2544. If exit_reason is KVM_EXIT_IO, then the vcpu has
  2545. executed a port I/O instruction which could not be satisfied by kvm.
  2546. data_offset describes where the data is located (KVM_EXIT_IO_OUT) or
  2547. where kvm expects application code to place the data for the next
  2548. KVM_RUN invocation (KVM_EXIT_IO_IN). Data format is a packed array.
  2549. /* KVM_EXIT_DEBUG */
  2550. struct {
  2551. struct kvm_debug_exit_arch arch;
  2552. } debug;
  2553. If the exit_reason is KVM_EXIT_DEBUG, then a vcpu is processing a debug event
  2554. for which architecture specific information is returned.
  2555. /* KVM_EXIT_MMIO */
  2556. struct {
  2557. __u64 phys_addr;
  2558. __u8 data[8];
  2559. __u32 len;
  2560. __u8 is_write;
  2561. } mmio;
  2562. If exit_reason is KVM_EXIT_MMIO, then the vcpu has
  2563. executed a memory-mapped I/O instruction which could not be satisfied
  2564. by kvm. The 'data' member contains the written data if 'is_write' is
  2565. true, and should be filled by application code otherwise.
  2566. The 'data' member contains, in its first 'len' bytes, the value as it would
  2567. appear if the VCPU performed a load or store of the appropriate width directly
  2568. to the byte array.
  2569. NOTE: For KVM_EXIT_IO, KVM_EXIT_MMIO, KVM_EXIT_OSI, KVM_EXIT_PAPR and
  2570. KVM_EXIT_EPR the corresponding
  2571. operations are complete (and guest state is consistent) only after userspace
  2572. has re-entered the kernel with KVM_RUN. The kernel side will first finish
  2573. incomplete operations and then check for pending signals. Userspace
  2574. can re-enter the guest with an unmasked signal pending to complete
  2575. pending operations.
  2576. /* KVM_EXIT_HYPERCALL */
  2577. struct {
  2578. __u64 nr;
  2579. __u64 args[6];
  2580. __u64 ret;
  2581. __u32 longmode;
  2582. __u32 pad;
  2583. } hypercall;
  2584. Unused. This was once used for 'hypercall to userspace'. To implement
  2585. such functionality, use KVM_EXIT_IO (x86) or KVM_EXIT_MMIO (all except s390).
  2586. Note KVM_EXIT_IO is significantly faster than KVM_EXIT_MMIO.
  2587. /* KVM_EXIT_TPR_ACCESS */
  2588. struct {
  2589. __u64 rip;
  2590. __u32 is_write;
  2591. __u32 pad;
  2592. } tpr_access;
  2593. To be documented (KVM_TPR_ACCESS_REPORTING).
  2594. /* KVM_EXIT_S390_SIEIC */
  2595. struct {
  2596. __u8 icptcode;
  2597. __u64 mask; /* psw upper half */
  2598. __u64 addr; /* psw lower half */
  2599. __u16 ipa;
  2600. __u32 ipb;
  2601. } s390_sieic;
  2602. s390 specific.
  2603. /* KVM_EXIT_S390_RESET */
  2604. #define KVM_S390_RESET_POR 1
  2605. #define KVM_S390_RESET_CLEAR 2
  2606. #define KVM_S390_RESET_SUBSYSTEM 4
  2607. #define KVM_S390_RESET_CPU_INIT 8
  2608. #define KVM_S390_RESET_IPL 16
  2609. __u64 s390_reset_flags;
  2610. s390 specific.
  2611. /* KVM_EXIT_S390_UCONTROL */
  2612. struct {
  2613. __u64 trans_exc_code;
  2614. __u32 pgm_code;
  2615. } s390_ucontrol;
  2616. s390 specific. A page fault has occurred for a user controlled virtual
  2617. machine (KVM_VM_S390_UNCONTROL) on it's host page table that cannot be
  2618. resolved by the kernel.
  2619. The program code and the translation exception code that were placed
  2620. in the cpu's lowcore are presented here as defined by the z Architecture
  2621. Principles of Operation Book in the Chapter for Dynamic Address Translation
  2622. (DAT)
  2623. /* KVM_EXIT_DCR */
  2624. struct {
  2625. __u32 dcrn;
  2626. __u32 data;
  2627. __u8 is_write;
  2628. } dcr;
  2629. Deprecated - was used for 440 KVM.
  2630. /* KVM_EXIT_OSI */
  2631. struct {
  2632. __u64 gprs[32];
  2633. } osi;
  2634. MOL uses a special hypercall interface it calls 'OSI'. To enable it, we catch
  2635. hypercalls and exit with this exit struct that contains all the guest gprs.
  2636. If exit_reason is KVM_EXIT_OSI, then the vcpu has triggered such a hypercall.
  2637. Userspace can now handle the hypercall and when it's done modify the gprs as
  2638. necessary. Upon guest entry all guest GPRs will then be replaced by the values
  2639. in this struct.
  2640. /* KVM_EXIT_PAPR_HCALL */
  2641. struct {
  2642. __u64 nr;
  2643. __u64 ret;
  2644. __u64 args[9];
  2645. } papr_hcall;
  2646. This is used on 64-bit PowerPC when emulating a pSeries partition,
  2647. e.g. with the 'pseries' machine type in qemu. It occurs when the
  2648. guest does a hypercall using the 'sc 1' instruction. The 'nr' field
  2649. contains the hypercall number (from the guest R3), and 'args' contains
  2650. the arguments (from the guest R4 - R12). Userspace should put the
  2651. return code in 'ret' and any extra returned values in args[].
  2652. The possible hypercalls are defined in the Power Architecture Platform
  2653. Requirements (PAPR) document available from www.power.org (free
  2654. developer registration required to access it).
  2655. /* KVM_EXIT_S390_TSCH */
  2656. struct {
  2657. __u16 subchannel_id;
  2658. __u16 subchannel_nr;
  2659. __u32 io_int_parm;
  2660. __u32 io_int_word;
  2661. __u32 ipb;
  2662. __u8 dequeued;
  2663. } s390_tsch;
  2664. s390 specific. This exit occurs when KVM_CAP_S390_CSS_SUPPORT has been enabled
  2665. and TEST SUBCHANNEL was intercepted. If dequeued is set, a pending I/O
  2666. interrupt for the target subchannel has been dequeued and subchannel_id,
  2667. subchannel_nr, io_int_parm and io_int_word contain the parameters for that
  2668. interrupt. ipb is needed for instruction parameter decoding.
  2669. /* KVM_EXIT_EPR */
  2670. struct {
  2671. __u32 epr;
  2672. } epr;
  2673. On FSL BookE PowerPC chips, the interrupt controller has a fast patch
  2674. interrupt acknowledge path to the core. When the core successfully
  2675. delivers an interrupt, it automatically populates the EPR register with
  2676. the interrupt vector number and acknowledges the interrupt inside
  2677. the interrupt controller.
  2678. In case the interrupt controller lives in user space, we need to do
  2679. the interrupt acknowledge cycle through it to fetch the next to be
  2680. delivered interrupt vector using this exit.
  2681. It gets triggered whenever both KVM_CAP_PPC_EPR are enabled and an
  2682. external interrupt has just been delivered into the guest. User space
  2683. should put the acknowledged interrupt vector into the 'epr' field.
  2684. /* KVM_EXIT_SYSTEM_EVENT */
  2685. struct {
  2686. #define KVM_SYSTEM_EVENT_SHUTDOWN 1
  2687. #define KVM_SYSTEM_EVENT_RESET 2
  2688. #define KVM_SYSTEM_EVENT_CRASH 3
  2689. __u32 type;
  2690. __u64 flags;
  2691. } system_event;
  2692. If exit_reason is KVM_EXIT_SYSTEM_EVENT then the vcpu has triggered
  2693. a system-level event using some architecture specific mechanism (hypercall
  2694. or some special instruction). In case of ARM/ARM64, this is triggered using
  2695. HVC instruction based PSCI call from the vcpu. The 'type' field describes
  2696. the system-level event type. The 'flags' field describes architecture
  2697. specific flags for the system-level event.
  2698. Valid values for 'type' are:
  2699. KVM_SYSTEM_EVENT_SHUTDOWN -- the guest has requested a shutdown of the
  2700. VM. Userspace is not obliged to honour this, and if it does honour
  2701. this does not need to destroy the VM synchronously (ie it may call
  2702. KVM_RUN again before shutdown finally occurs).
  2703. KVM_SYSTEM_EVENT_RESET -- the guest has requested a reset of the VM.
  2704. As with SHUTDOWN, userspace can choose to ignore the request, or
  2705. to schedule the reset to occur in the future and may call KVM_RUN again.
  2706. KVM_SYSTEM_EVENT_CRASH -- the guest crash occurred and the guest
  2707. has requested a crash condition maintenance. Userspace can choose
  2708. to ignore the request, or to gather VM memory core dump and/or
  2709. reset/shutdown of the VM.
  2710. /* KVM_EXIT_IOAPIC_EOI */
  2711. struct {
  2712. __u8 vector;
  2713. } eoi;
  2714. Indicates that the VCPU's in-kernel local APIC received an EOI for a
  2715. level-triggered IOAPIC interrupt. This exit only triggers when the
  2716. IOAPIC is implemented in userspace (i.e. KVM_CAP_SPLIT_IRQCHIP is enabled);
  2717. the userspace IOAPIC should process the EOI and retrigger the interrupt if
  2718. it is still asserted. Vector is the LAPIC interrupt vector for which the
  2719. EOI was received.
  2720. struct kvm_hyperv_exit {
  2721. #define KVM_EXIT_HYPERV_SYNIC 1
  2722. #define KVM_EXIT_HYPERV_HCALL 2
  2723. __u32 type;
  2724. union {
  2725. struct {
  2726. __u32 msr;
  2727. __u64 control;
  2728. __u64 evt_page;
  2729. __u64 msg_page;
  2730. } synic;
  2731. struct {
  2732. __u64 input;
  2733. __u64 result;
  2734. __u64 params[2];
  2735. } hcall;
  2736. } u;
  2737. };
  2738. /* KVM_EXIT_HYPERV */
  2739. struct kvm_hyperv_exit hyperv;
  2740. Indicates that the VCPU exits into userspace to process some tasks
  2741. related to Hyper-V emulation.
  2742. Valid values for 'type' are:
  2743. KVM_EXIT_HYPERV_SYNIC -- synchronously notify user-space about
  2744. Hyper-V SynIC state change. Notification is used to remap SynIC
  2745. event/message pages and to enable/disable SynIC messages/events processing
  2746. in userspace.
  2747. /* Fix the size of the union. */
  2748. char padding[256];
  2749. };
  2750. /*
  2751. * shared registers between kvm and userspace.
  2752. * kvm_valid_regs specifies the register classes set by the host
  2753. * kvm_dirty_regs specified the register classes dirtied by userspace
  2754. * struct kvm_sync_regs is architecture specific, as well as the
  2755. * bits for kvm_valid_regs and kvm_dirty_regs
  2756. */
  2757. __u64 kvm_valid_regs;
  2758. __u64 kvm_dirty_regs;
  2759. union {
  2760. struct kvm_sync_regs regs;
  2761. char padding[1024];
  2762. } s;
  2763. If KVM_CAP_SYNC_REGS is defined, these fields allow userspace to access
  2764. certain guest registers without having to call SET/GET_*REGS. Thus we can
  2765. avoid some system call overhead if userspace has to handle the exit.
  2766. Userspace can query the validity of the structure by checking
  2767. kvm_valid_regs for specific bits. These bits are architecture specific
  2768. and usually define the validity of a groups of registers. (e.g. one bit
  2769. for general purpose registers)
  2770. Please note that the kernel is allowed to use the kvm_run structure as the
  2771. primary storage for certain register types. Therefore, the kernel may use the
  2772. values in kvm_run even if the corresponding bit in kvm_dirty_regs is not set.
  2773. };
  2774. 6. Capabilities that can be enabled on vCPUs
  2775. --------------------------------------------
  2776. There are certain capabilities that change the behavior of the virtual CPU or
  2777. the virtual machine when enabled. To enable them, please see section 4.37.
  2778. Below you can find a list of capabilities and what their effect on the vCPU or
  2779. the virtual machine is when enabling them.
  2780. The following information is provided along with the description:
  2781. Architectures: which instruction set architectures provide this ioctl.
  2782. x86 includes both i386 and x86_64.
  2783. Target: whether this is a per-vcpu or per-vm capability.
  2784. Parameters: what parameters are accepted by the capability.
  2785. Returns: the return value. General error numbers (EBADF, ENOMEM, EINVAL)
  2786. are not detailed, but errors with specific meanings are.
  2787. 6.1 KVM_CAP_PPC_OSI
  2788. Architectures: ppc
  2789. Target: vcpu
  2790. Parameters: none
  2791. Returns: 0 on success; -1 on error
  2792. This capability enables interception of OSI hypercalls that otherwise would
  2793. be treated as normal system calls to be injected into the guest. OSI hypercalls
  2794. were invented by Mac-on-Linux to have a standardized communication mechanism
  2795. between the guest and the host.
  2796. When this capability is enabled, KVM_EXIT_OSI can occur.
  2797. 6.2 KVM_CAP_PPC_PAPR
  2798. Architectures: ppc
  2799. Target: vcpu
  2800. Parameters: none
  2801. Returns: 0 on success; -1 on error
  2802. This capability enables interception of PAPR hypercalls. PAPR hypercalls are
  2803. done using the hypercall instruction "sc 1".
  2804. It also sets the guest privilege level to "supervisor" mode. Usually the guest
  2805. runs in "hypervisor" privilege mode with a few missing features.
  2806. In addition to the above, it changes the semantics of SDR1. In this mode, the
  2807. HTAB address part of SDR1 contains an HVA instead of a GPA, as PAPR keeps the
  2808. HTAB invisible to the guest.
  2809. When this capability is enabled, KVM_EXIT_PAPR_HCALL can occur.
  2810. 6.3 KVM_CAP_SW_TLB
  2811. Architectures: ppc
  2812. Target: vcpu
  2813. Parameters: args[0] is the address of a struct kvm_config_tlb
  2814. Returns: 0 on success; -1 on error
  2815. struct kvm_config_tlb {
  2816. __u64 params;
  2817. __u64 array;
  2818. __u32 mmu_type;
  2819. __u32 array_len;
  2820. };
  2821. Configures the virtual CPU's TLB array, establishing a shared memory area
  2822. between userspace and KVM. The "params" and "array" fields are userspace
  2823. addresses of mmu-type-specific data structures. The "array_len" field is an
  2824. safety mechanism, and should be set to the size in bytes of the memory that
  2825. userspace has reserved for the array. It must be at least the size dictated
  2826. by "mmu_type" and "params".
  2827. While KVM_RUN is active, the shared region is under control of KVM. Its
  2828. contents are undefined, and any modification by userspace results in
  2829. boundedly undefined behavior.
  2830. On return from KVM_RUN, the shared region will reflect the current state of
  2831. the guest's TLB. If userspace makes any changes, it must call KVM_DIRTY_TLB
  2832. to tell KVM which entries have been changed, prior to calling KVM_RUN again
  2833. on this vcpu.
  2834. For mmu types KVM_MMU_FSL_BOOKE_NOHV and KVM_MMU_FSL_BOOKE_HV:
  2835. - The "params" field is of type "struct kvm_book3e_206_tlb_params".
  2836. - The "array" field points to an array of type "struct
  2837. kvm_book3e_206_tlb_entry".
  2838. - The array consists of all entries in the first TLB, followed by all
  2839. entries in the second TLB.
  2840. - Within a TLB, entries are ordered first by increasing set number. Within a
  2841. set, entries are ordered by way (increasing ESEL).
  2842. - The hash for determining set number in TLB0 is: (MAS2 >> 12) & (num_sets - 1)
  2843. where "num_sets" is the tlb_sizes[] value divided by the tlb_ways[] value.
  2844. - The tsize field of mas1 shall be set to 4K on TLB0, even though the
  2845. hardware ignores this value for TLB0.
  2846. 6.4 KVM_CAP_S390_CSS_SUPPORT
  2847. Architectures: s390
  2848. Target: vcpu
  2849. Parameters: none
  2850. Returns: 0 on success; -1 on error
  2851. This capability enables support for handling of channel I/O instructions.
  2852. TEST PENDING INTERRUPTION and the interrupt portion of TEST SUBCHANNEL are
  2853. handled in-kernel, while the other I/O instructions are passed to userspace.
  2854. When this capability is enabled, KVM_EXIT_S390_TSCH will occur on TEST
  2855. SUBCHANNEL intercepts.
  2856. Note that even though this capability is enabled per-vcpu, the complete
  2857. virtual machine is affected.
  2858. 6.5 KVM_CAP_PPC_EPR
  2859. Architectures: ppc
  2860. Target: vcpu
  2861. Parameters: args[0] defines whether the proxy facility is active
  2862. Returns: 0 on success; -1 on error
  2863. This capability enables or disables the delivery of interrupts through the
  2864. external proxy facility.
  2865. When enabled (args[0] != 0), every time the guest gets an external interrupt
  2866. delivered, it automatically exits into user space with a KVM_EXIT_EPR exit
  2867. to receive the topmost interrupt vector.
  2868. When disabled (args[0] == 0), behavior is as if this facility is unsupported.
  2869. When this capability is enabled, KVM_EXIT_EPR can occur.
  2870. 6.6 KVM_CAP_IRQ_MPIC
  2871. Architectures: ppc
  2872. Parameters: args[0] is the MPIC device fd
  2873. args[1] is the MPIC CPU number for this vcpu
  2874. This capability connects the vcpu to an in-kernel MPIC device.
  2875. 6.7 KVM_CAP_IRQ_XICS
  2876. Architectures: ppc
  2877. Target: vcpu
  2878. Parameters: args[0] is the XICS device fd
  2879. args[1] is the XICS CPU number (server ID) for this vcpu
  2880. This capability connects the vcpu to an in-kernel XICS device.
  2881. 6.8 KVM_CAP_S390_IRQCHIP
  2882. Architectures: s390
  2883. Target: vm
  2884. Parameters: none
  2885. This capability enables the in-kernel irqchip for s390. Please refer to
  2886. "4.24 KVM_CREATE_IRQCHIP" for details.
  2887. 6.9 KVM_CAP_MIPS_FPU
  2888. Architectures: mips
  2889. Target: vcpu
  2890. Parameters: args[0] is reserved for future use (should be 0).
  2891. This capability allows the use of the host Floating Point Unit by the guest. It
  2892. allows the Config1.FP bit to be set to enable the FPU in the guest. Once this is
  2893. done the KVM_REG_MIPS_FPR_* and KVM_REG_MIPS_FCR_* registers can be accessed
  2894. (depending on the current guest FPU register mode), and the Status.FR,
  2895. Config5.FRE bits are accessible via the KVM API and also from the guest,
  2896. depending on them being supported by the FPU.
  2897. 6.10 KVM_CAP_MIPS_MSA
  2898. Architectures: mips
  2899. Target: vcpu
  2900. Parameters: args[0] is reserved for future use (should be 0).
  2901. This capability allows the use of the MIPS SIMD Architecture (MSA) by the guest.
  2902. It allows the Config3.MSAP bit to be set to enable the use of MSA by the guest.
  2903. Once this is done the KVM_REG_MIPS_VEC_* and KVM_REG_MIPS_MSA_* registers can be
  2904. accessed, and the Config5.MSAEn bit is accessible via the KVM API and also from
  2905. the guest.
  2906. 7. Capabilities that can be enabled on VMs
  2907. ------------------------------------------
  2908. There are certain capabilities that change the behavior of the virtual
  2909. machine when enabled. To enable them, please see section 4.37. Below
  2910. you can find a list of capabilities and what their effect on the VM
  2911. is when enabling them.
  2912. The following information is provided along with the description:
  2913. Architectures: which instruction set architectures provide this ioctl.
  2914. x86 includes both i386 and x86_64.
  2915. Parameters: what parameters are accepted by the capability.
  2916. Returns: the return value. General error numbers (EBADF, ENOMEM, EINVAL)
  2917. are not detailed, but errors with specific meanings are.
  2918. 7.1 KVM_CAP_PPC_ENABLE_HCALL
  2919. Architectures: ppc
  2920. Parameters: args[0] is the sPAPR hcall number
  2921. args[1] is 0 to disable, 1 to enable in-kernel handling
  2922. This capability controls whether individual sPAPR hypercalls (hcalls)
  2923. get handled by the kernel or not. Enabling or disabling in-kernel
  2924. handling of an hcall is effective across the VM. On creation, an
  2925. initial set of hcalls are enabled for in-kernel handling, which
  2926. consists of those hcalls for which in-kernel handlers were implemented
  2927. before this capability was implemented. If disabled, the kernel will
  2928. not to attempt to handle the hcall, but will always exit to userspace
  2929. to handle it. Note that it may not make sense to enable some and
  2930. disable others of a group of related hcalls, but KVM does not prevent
  2931. userspace from doing that.
  2932. If the hcall number specified is not one that has an in-kernel
  2933. implementation, the KVM_ENABLE_CAP ioctl will fail with an EINVAL
  2934. error.
  2935. 7.2 KVM_CAP_S390_USER_SIGP
  2936. Architectures: s390
  2937. Parameters: none
  2938. This capability controls which SIGP orders will be handled completely in user
  2939. space. With this capability enabled, all fast orders will be handled completely
  2940. in the kernel:
  2941. - SENSE
  2942. - SENSE RUNNING
  2943. - EXTERNAL CALL
  2944. - EMERGENCY SIGNAL
  2945. - CONDITIONAL EMERGENCY SIGNAL
  2946. All other orders will be handled completely in user space.
  2947. Only privileged operation exceptions will be checked for in the kernel (or even
  2948. in the hardware prior to interception). If this capability is not enabled, the
  2949. old way of handling SIGP orders is used (partially in kernel and user space).
  2950. 7.3 KVM_CAP_S390_VECTOR_REGISTERS
  2951. Architectures: s390
  2952. Parameters: none
  2953. Returns: 0 on success, negative value on error
  2954. Allows use of the vector registers introduced with z13 processor, and
  2955. provides for the synchronization between host and user space. Will
  2956. return -EINVAL if the machine does not support vectors.
  2957. 7.4 KVM_CAP_S390_USER_STSI
  2958. Architectures: s390
  2959. Parameters: none
  2960. This capability allows post-handlers for the STSI instruction. After
  2961. initial handling in the kernel, KVM exits to user space with
  2962. KVM_EXIT_S390_STSI to allow user space to insert further data.
  2963. Before exiting to userspace, kvm handlers should fill in s390_stsi field of
  2964. vcpu->run:
  2965. struct {
  2966. __u64 addr;
  2967. __u8 ar;
  2968. __u8 reserved;
  2969. __u8 fc;
  2970. __u8 sel1;
  2971. __u16 sel2;
  2972. } s390_stsi;
  2973. @addr - guest address of STSI SYSIB
  2974. @fc - function code
  2975. @sel1 - selector 1
  2976. @sel2 - selector 2
  2977. @ar - access register number
  2978. KVM handlers should exit to userspace with rc = -EREMOTE.
  2979. 7.5 KVM_CAP_SPLIT_IRQCHIP
  2980. Architectures: x86
  2981. Parameters: args[0] - number of routes reserved for userspace IOAPICs
  2982. Returns: 0 on success, -1 on error
  2983. Create a local apic for each processor in the kernel. This can be used
  2984. instead of KVM_CREATE_IRQCHIP if the userspace VMM wishes to emulate the
  2985. IOAPIC and PIC (and also the PIT, even though this has to be enabled
  2986. separately).
  2987. This capability also enables in kernel routing of interrupt requests;
  2988. when KVM_CAP_SPLIT_IRQCHIP only routes of KVM_IRQ_ROUTING_MSI type are
  2989. used in the IRQ routing table. The first args[0] MSI routes are reserved
  2990. for the IOAPIC pins. Whenever the LAPIC receives an EOI for these routes,
  2991. a KVM_EXIT_IOAPIC_EOI vmexit will be reported to userspace.
  2992. Fails if VCPU has already been created, or if the irqchip is already in the
  2993. kernel (i.e. KVM_CREATE_IRQCHIP has already been called).
  2994. 7.6 KVM_CAP_S390_RI
  2995. Architectures: s390
  2996. Parameters: none
  2997. Allows use of runtime-instrumentation introduced with zEC12 processor.
  2998. Will return -EINVAL if the machine does not support runtime-instrumentation.
  2999. Will return -EBUSY if a VCPU has already been created.
  3000. 7.7 KVM_CAP_X2APIC_API
  3001. Architectures: x86
  3002. Parameters: args[0] - features that should be enabled
  3003. Returns: 0 on success, -EINVAL when args[0] contains invalid features
  3004. Valid feature flags in args[0] are
  3005. #define KVM_X2APIC_API_USE_32BIT_IDS (1ULL << 0)
  3006. #define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK (1ULL << 1)
  3007. Enabling KVM_X2APIC_API_USE_32BIT_IDS changes the behavior of
  3008. KVM_SET_GSI_ROUTING, KVM_SIGNAL_MSI, KVM_SET_LAPIC, and KVM_GET_LAPIC,
  3009. allowing the use of 32-bit APIC IDs. See KVM_CAP_X2APIC_API in their
  3010. respective sections.
  3011. KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK must be enabled for x2APIC to work
  3012. in logical mode or with more than 255 VCPUs. Otherwise, KVM treats 0xff
  3013. as a broadcast even in x2APIC mode in order to support physical x2APIC
  3014. without interrupt remapping. This is undesirable in logical mode,
  3015. where 0xff represents CPUs 0-7 in cluster 0.
  3016. 7.8 KVM_CAP_S390_USER_INSTR0
  3017. Architectures: s390
  3018. Parameters: none
  3019. With this capability enabled, all illegal instructions 0x0000 (2 bytes) will
  3020. be intercepted and forwarded to user space. User space can use this
  3021. mechanism e.g. to realize 2-byte software breakpoints. The kernel will
  3022. not inject an operating exception for these instructions, user space has
  3023. to take care of that.
  3024. This capability can be enabled dynamically even if VCPUs were already
  3025. created and are running.
  3026. 8. Other capabilities.
  3027. ----------------------
  3028. This section lists capabilities that give information about other
  3029. features of the KVM implementation.
  3030. 8.1 KVM_CAP_PPC_HWRNG
  3031. Architectures: ppc
  3032. This capability, if KVM_CHECK_EXTENSION indicates that it is
  3033. available, means that that the kernel has an implementation of the
  3034. H_RANDOM hypercall backed by a hardware random-number generator.
  3035. If present, the kernel H_RANDOM handler can be enabled for guest use
  3036. with the KVM_CAP_PPC_ENABLE_HCALL capability.
  3037. 8.2 KVM_CAP_HYPERV_SYNIC
  3038. Architectures: x86
  3039. This capability, if KVM_CHECK_EXTENSION indicates that it is
  3040. available, means that that the kernel has an implementation of the
  3041. Hyper-V Synthetic interrupt controller(SynIC). Hyper-V SynIC is
  3042. used to support Windows Hyper-V based guest paravirt drivers(VMBus).
  3043. In order to use SynIC, it has to be activated by setting this
  3044. capability via KVM_ENABLE_CAP ioctl on the vcpu fd. Note that this
  3045. will disable the use of APIC hardware virtualization even if supported
  3046. by the CPU, as it's incompatible with SynIC auto-EOI behavior.