api.txt 127 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950
  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. ARM firmware pseudo-registers have the following bit pattern:
  1632. 0x4030 0000 0014 <regno:16>
  1633. arm64 registers are mapped using the lower 32 bits. The upper 16 of
  1634. that is the register group type, or coprocessor number:
  1635. arm64 core/FP-SIMD registers have the following id bit patterns. Note
  1636. that the size of the access is variable, as the kvm_regs structure
  1637. contains elements ranging from 32 to 128 bits. The index is a 32bit
  1638. value in the kvm_regs structure seen as a 32bit array.
  1639. 0x60x0 0000 0010 <index into the kvm_regs struct:16>
  1640. arm64 CCSIDR registers are demultiplexed by CSSELR value:
  1641. 0x6020 0000 0011 00 <csselr:8>
  1642. arm64 system registers have the following id bit patterns:
  1643. 0x6030 0000 0013 <op0:2> <op1:3> <crn:4> <crm:4> <op2:3>
  1644. arm64 firmware pseudo-registers have the following bit pattern:
  1645. 0x6030 0000 0014 <regno:16>
  1646. MIPS registers are mapped using the lower 32 bits. The upper 16 of that is
  1647. the register group type:
  1648. MIPS core registers (see above) have the following id bit patterns:
  1649. 0x7030 0000 0000 <reg:16>
  1650. MIPS CP0 registers (see KVM_REG_MIPS_CP0_* above) have the following id bit
  1651. patterns depending on whether they're 32-bit or 64-bit registers:
  1652. 0x7020 0000 0001 00 <reg:5> <sel:3> (32-bit)
  1653. 0x7030 0000 0001 00 <reg:5> <sel:3> (64-bit)
  1654. MIPS KVM control registers (see above) have the following id bit patterns:
  1655. 0x7030 0000 0002 <reg:16>
  1656. MIPS FPU registers (see KVM_REG_MIPS_FPR_{32,64}() above) have the following
  1657. id bit patterns depending on the size of the register being accessed. They are
  1658. always accessed according to the current guest FPU mode (Status.FR and
  1659. Config5.FRE), i.e. as the guest would see them, and they become unpredictable
  1660. if the guest FPU mode is changed. MIPS SIMD Architecture (MSA) vector
  1661. registers (see KVM_REG_MIPS_VEC_128() above) have similar patterns as they
  1662. overlap the FPU registers:
  1663. 0x7020 0000 0003 00 <0:3> <reg:5> (32-bit FPU registers)
  1664. 0x7030 0000 0003 00 <0:3> <reg:5> (64-bit FPU registers)
  1665. 0x7040 0000 0003 00 <0:3> <reg:5> (128-bit MSA vector registers)
  1666. MIPS FPU control registers (see KVM_REG_MIPS_FCR_{IR,CSR} above) have the
  1667. following id bit patterns:
  1668. 0x7020 0000 0003 01 <0:3> <reg:5>
  1669. MIPS MSA control registers (see KVM_REG_MIPS_MSA_{IR,CSR} above) have the
  1670. following id bit patterns:
  1671. 0x7020 0000 0003 02 <0:3> <reg:5>
  1672. 4.69 KVM_GET_ONE_REG
  1673. Capability: KVM_CAP_ONE_REG
  1674. Architectures: all
  1675. Type: vcpu ioctl
  1676. Parameters: struct kvm_one_reg (in and out)
  1677. Returns: 0 on success, negative value on failure
  1678. This ioctl allows to receive the value of a single register implemented
  1679. in a vcpu. The register to read is indicated by the "id" field of the
  1680. kvm_one_reg struct passed in. On success, the register value can be found
  1681. at the memory location pointed to by "addr".
  1682. The list of registers accessible using this interface is identical to the
  1683. list in 4.68.
  1684. 4.70 KVM_KVMCLOCK_CTRL
  1685. Capability: KVM_CAP_KVMCLOCK_CTRL
  1686. Architectures: Any that implement pvclocks (currently x86 only)
  1687. Type: vcpu ioctl
  1688. Parameters: None
  1689. Returns: 0 on success, -1 on error
  1690. This signals to the host kernel that the specified guest is being paused by
  1691. userspace. The host will set a flag in the pvclock structure that is checked
  1692. from the soft lockup watchdog. The flag is part of the pvclock structure that
  1693. is shared between guest and host, specifically the second bit of the flags
  1694. field of the pvclock_vcpu_time_info structure. It will be set exclusively by
  1695. the host and read/cleared exclusively by the guest. The guest operation of
  1696. checking and clearing the flag must an atomic operation so
  1697. load-link/store-conditional, or equivalent must be used. There are two cases
  1698. where the guest will clear the flag: when the soft lockup watchdog timer resets
  1699. itself or when a soft lockup is detected. This ioctl can be called any time
  1700. after pausing the vcpu, but before it is resumed.
  1701. 4.71 KVM_SIGNAL_MSI
  1702. Capability: KVM_CAP_SIGNAL_MSI
  1703. Architectures: x86 arm64
  1704. Type: vm ioctl
  1705. Parameters: struct kvm_msi (in)
  1706. Returns: >0 on delivery, 0 if guest blocked the MSI, and -1 on error
  1707. Directly inject a MSI message. Only valid with in-kernel irqchip that handles
  1708. MSI messages.
  1709. struct kvm_msi {
  1710. __u32 address_lo;
  1711. __u32 address_hi;
  1712. __u32 data;
  1713. __u32 flags;
  1714. __u32 devid;
  1715. __u8 pad[12];
  1716. };
  1717. flags: KVM_MSI_VALID_DEVID: devid contains a valid value. The per-VM
  1718. KVM_CAP_MSI_DEVID capability advertises the requirement to provide
  1719. the device ID. If this capability is not available, userspace
  1720. should never set the KVM_MSI_VALID_DEVID flag as the ioctl might fail.
  1721. If KVM_MSI_VALID_DEVID is set, devid contains a unique device identifier
  1722. for the device that wrote the MSI message. For PCI, this is usually a
  1723. BFD identifier in the lower 16 bits.
  1724. On x86, address_hi is ignored unless the KVM_X2APIC_API_USE_32BIT_IDS
  1725. feature of KVM_CAP_X2APIC_API capability is enabled. If it is enabled,
  1726. address_hi bits 31-8 provide bits 31-8 of the destination id. Bits 7-0 of
  1727. address_hi must be zero.
  1728. 4.71 KVM_CREATE_PIT2
  1729. Capability: KVM_CAP_PIT2
  1730. Architectures: x86
  1731. Type: vm ioctl
  1732. Parameters: struct kvm_pit_config (in)
  1733. Returns: 0 on success, -1 on error
  1734. Creates an in-kernel device model for the i8254 PIT. This call is only valid
  1735. after enabling in-kernel irqchip support via KVM_CREATE_IRQCHIP. The following
  1736. parameters have to be passed:
  1737. struct kvm_pit_config {
  1738. __u32 flags;
  1739. __u32 pad[15];
  1740. };
  1741. Valid flags are:
  1742. #define KVM_PIT_SPEAKER_DUMMY 1 /* emulate speaker port stub */
  1743. PIT timer interrupts may use a per-VM kernel thread for injection. If it
  1744. exists, this thread will have a name of the following pattern:
  1745. kvm-pit/<owner-process-pid>
  1746. When running a guest with elevated priorities, the scheduling parameters of
  1747. this thread may have to be adjusted accordingly.
  1748. This IOCTL replaces the obsolete KVM_CREATE_PIT.
  1749. 4.72 KVM_GET_PIT2
  1750. Capability: KVM_CAP_PIT_STATE2
  1751. Architectures: x86
  1752. Type: vm ioctl
  1753. Parameters: struct kvm_pit_state2 (out)
  1754. Returns: 0 on success, -1 on error
  1755. Retrieves the state of the in-kernel PIT model. Only valid after
  1756. KVM_CREATE_PIT2. The state is returned in the following structure:
  1757. struct kvm_pit_state2 {
  1758. struct kvm_pit_channel_state channels[3];
  1759. __u32 flags;
  1760. __u32 reserved[9];
  1761. };
  1762. Valid flags are:
  1763. /* disable PIT in HPET legacy mode */
  1764. #define KVM_PIT_FLAGS_HPET_LEGACY 0x00000001
  1765. This IOCTL replaces the obsolete KVM_GET_PIT.
  1766. 4.73 KVM_SET_PIT2
  1767. Capability: KVM_CAP_PIT_STATE2
  1768. Architectures: x86
  1769. Type: vm ioctl
  1770. Parameters: struct kvm_pit_state2 (in)
  1771. Returns: 0 on success, -1 on error
  1772. Sets the state of the in-kernel PIT model. Only valid after KVM_CREATE_PIT2.
  1773. See KVM_GET_PIT2 for details on struct kvm_pit_state2.
  1774. This IOCTL replaces the obsolete KVM_SET_PIT.
  1775. 4.74 KVM_PPC_GET_SMMU_INFO
  1776. Capability: KVM_CAP_PPC_GET_SMMU_INFO
  1777. Architectures: powerpc
  1778. Type: vm ioctl
  1779. Parameters: None
  1780. Returns: 0 on success, -1 on error
  1781. This populates and returns a structure describing the features of
  1782. the "Server" class MMU emulation supported by KVM.
  1783. This can in turn be used by userspace to generate the appropriate
  1784. device-tree properties for the guest operating system.
  1785. The structure contains some global information, followed by an
  1786. array of supported segment page sizes:
  1787. struct kvm_ppc_smmu_info {
  1788. __u64 flags;
  1789. __u32 slb_size;
  1790. __u32 pad;
  1791. struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ];
  1792. };
  1793. The supported flags are:
  1794. - KVM_PPC_PAGE_SIZES_REAL:
  1795. When that flag is set, guest page sizes must "fit" the backing
  1796. store page sizes. When not set, any page size in the list can
  1797. be used regardless of how they are backed by userspace.
  1798. - KVM_PPC_1T_SEGMENTS
  1799. The emulated MMU supports 1T segments in addition to the
  1800. standard 256M ones.
  1801. The "slb_size" field indicates how many SLB entries are supported
  1802. The "sps" array contains 8 entries indicating the supported base
  1803. page sizes for a segment in increasing order. Each entry is defined
  1804. as follow:
  1805. struct kvm_ppc_one_seg_page_size {
  1806. __u32 page_shift; /* Base page shift of segment (or 0) */
  1807. __u32 slb_enc; /* SLB encoding for BookS */
  1808. struct kvm_ppc_one_page_size enc[KVM_PPC_PAGE_SIZES_MAX_SZ];
  1809. };
  1810. An entry with a "page_shift" of 0 is unused. Because the array is
  1811. organized in increasing order, a lookup can stop when encoutering
  1812. such an entry.
  1813. The "slb_enc" field provides the encoding to use in the SLB for the
  1814. page size. The bits are in positions such as the value can directly
  1815. be OR'ed into the "vsid" argument of the slbmte instruction.
  1816. The "enc" array is a list which for each of those segment base page
  1817. size provides the list of supported actual page sizes (which can be
  1818. only larger or equal to the base page size), along with the
  1819. corresponding encoding in the hash PTE. Similarly, the array is
  1820. 8 entries sorted by increasing sizes and an entry with a "0" shift
  1821. is an empty entry and a terminator:
  1822. struct kvm_ppc_one_page_size {
  1823. __u32 page_shift; /* Page shift (or 0) */
  1824. __u32 pte_enc; /* Encoding in the HPTE (>>12) */
  1825. };
  1826. The "pte_enc" field provides a value that can OR'ed into the hash
  1827. PTE's RPN field (ie, it needs to be shifted left by 12 to OR it
  1828. into the hash PTE second double word).
  1829. 4.75 KVM_IRQFD
  1830. Capability: KVM_CAP_IRQFD
  1831. Architectures: x86 s390 arm arm64
  1832. Type: vm ioctl
  1833. Parameters: struct kvm_irqfd (in)
  1834. Returns: 0 on success, -1 on error
  1835. Allows setting an eventfd to directly trigger a guest interrupt.
  1836. kvm_irqfd.fd specifies the file descriptor to use as the eventfd and
  1837. kvm_irqfd.gsi specifies the irqchip pin toggled by this event. When
  1838. an event is triggered on the eventfd, an interrupt is injected into
  1839. the guest using the specified gsi pin. The irqfd is removed using
  1840. the KVM_IRQFD_FLAG_DEASSIGN flag, specifying both kvm_irqfd.fd
  1841. and kvm_irqfd.gsi.
  1842. With KVM_CAP_IRQFD_RESAMPLE, KVM_IRQFD supports a de-assert and notify
  1843. mechanism allowing emulation of level-triggered, irqfd-based
  1844. interrupts. When KVM_IRQFD_FLAG_RESAMPLE is set the user must pass an
  1845. additional eventfd in the kvm_irqfd.resamplefd field. When operating
  1846. in resample mode, posting of an interrupt through kvm_irq.fd asserts
  1847. the specified gsi in the irqchip. When the irqchip is resampled, such
  1848. as from an EOI, the gsi is de-asserted and the user is notified via
  1849. kvm_irqfd.resamplefd. It is the user's responsibility to re-queue
  1850. the interrupt if the device making use of it still requires service.
  1851. Note that closing the resamplefd is not sufficient to disable the
  1852. irqfd. The KVM_IRQFD_FLAG_RESAMPLE is only necessary on assignment
  1853. and need not be specified with KVM_IRQFD_FLAG_DEASSIGN.
  1854. On arm/arm64, gsi routing being supported, the following can happen:
  1855. - in case no routing entry is associated to this gsi, injection fails
  1856. - in case the gsi is associated to an irqchip routing entry,
  1857. irqchip.pin + 32 corresponds to the injected SPI ID.
  1858. - in case the gsi is associated to an MSI routing entry, the MSI
  1859. message and device ID are translated into an LPI (support restricted
  1860. to GICv3 ITS in-kernel emulation).
  1861. 4.76 KVM_PPC_ALLOCATE_HTAB
  1862. Capability: KVM_CAP_PPC_ALLOC_HTAB
  1863. Architectures: powerpc
  1864. Type: vm ioctl
  1865. Parameters: Pointer to u32 containing hash table order (in/out)
  1866. Returns: 0 on success, -1 on error
  1867. This requests the host kernel to allocate an MMU hash table for a
  1868. guest using the PAPR paravirtualization interface. This only does
  1869. anything if the kernel is configured to use the Book 3S HV style of
  1870. virtualization. Otherwise the capability doesn't exist and the ioctl
  1871. returns an ENOTTY error. The rest of this description assumes Book 3S
  1872. HV.
  1873. There must be no vcpus running when this ioctl is called; if there
  1874. are, it will do nothing and return an EBUSY error.
  1875. The parameter is a pointer to a 32-bit unsigned integer variable
  1876. containing the order (log base 2) of the desired size of the hash
  1877. table, which must be between 18 and 46. On successful return from the
  1878. ioctl, it will have been updated with the order of the hash table that
  1879. was allocated.
  1880. If no hash table has been allocated when any vcpu is asked to run
  1881. (with the KVM_RUN ioctl), the host kernel will allocate a
  1882. default-sized hash table (16 MB).
  1883. If this ioctl is called when a hash table has already been allocated,
  1884. the kernel will clear out the existing hash table (zero all HPTEs) and
  1885. return the hash table order in the parameter. (If the guest is using
  1886. the virtualized real-mode area (VRMA) facility, the kernel will
  1887. re-create the VMRA HPTEs on the next KVM_RUN of any vcpu.)
  1888. 4.77 KVM_S390_INTERRUPT
  1889. Capability: basic
  1890. Architectures: s390
  1891. Type: vm ioctl, vcpu ioctl
  1892. Parameters: struct kvm_s390_interrupt (in)
  1893. Returns: 0 on success, -1 on error
  1894. Allows to inject an interrupt to the guest. Interrupts can be floating
  1895. (vm ioctl) or per cpu (vcpu ioctl), depending on the interrupt type.
  1896. Interrupt parameters are passed via kvm_s390_interrupt:
  1897. struct kvm_s390_interrupt {
  1898. __u32 type;
  1899. __u32 parm;
  1900. __u64 parm64;
  1901. };
  1902. type can be one of the following:
  1903. KVM_S390_SIGP_STOP (vcpu) - sigp stop; optional flags in parm
  1904. KVM_S390_PROGRAM_INT (vcpu) - program check; code in parm
  1905. KVM_S390_SIGP_SET_PREFIX (vcpu) - sigp set prefix; prefix address in parm
  1906. KVM_S390_RESTART (vcpu) - restart
  1907. KVM_S390_INT_CLOCK_COMP (vcpu) - clock comparator interrupt
  1908. KVM_S390_INT_CPU_TIMER (vcpu) - CPU timer interrupt
  1909. KVM_S390_INT_VIRTIO (vm) - virtio external interrupt; external interrupt
  1910. parameters in parm and parm64
  1911. KVM_S390_INT_SERVICE (vm) - sclp external interrupt; sclp parameter in parm
  1912. KVM_S390_INT_EMERGENCY (vcpu) - sigp emergency; source cpu in parm
  1913. KVM_S390_INT_EXTERNAL_CALL (vcpu) - sigp external call; source cpu in parm
  1914. KVM_S390_INT_IO(ai,cssid,ssid,schid) (vm) - compound value to indicate an
  1915. I/O interrupt (ai - adapter interrupt; cssid,ssid,schid - subchannel);
  1916. I/O interruption parameters in parm (subchannel) and parm64 (intparm,
  1917. interruption subclass)
  1918. KVM_S390_MCHK (vm, vcpu) - machine check interrupt; cr 14 bits in parm,
  1919. machine check interrupt code in parm64 (note that
  1920. machine checks needing further payload are not
  1921. supported by this ioctl)
  1922. Note that the vcpu ioctl is asynchronous to vcpu execution.
  1923. 4.78 KVM_PPC_GET_HTAB_FD
  1924. Capability: KVM_CAP_PPC_HTAB_FD
  1925. Architectures: powerpc
  1926. Type: vm ioctl
  1927. Parameters: Pointer to struct kvm_get_htab_fd (in)
  1928. Returns: file descriptor number (>= 0) on success, -1 on error
  1929. This returns a file descriptor that can be used either to read out the
  1930. entries in the guest's hashed page table (HPT), or to write entries to
  1931. initialize the HPT. The returned fd can only be written to if the
  1932. KVM_GET_HTAB_WRITE bit is set in the flags field of the argument, and
  1933. can only be read if that bit is clear. The argument struct looks like
  1934. this:
  1935. /* For KVM_PPC_GET_HTAB_FD */
  1936. struct kvm_get_htab_fd {
  1937. __u64 flags;
  1938. __u64 start_index;
  1939. __u64 reserved[2];
  1940. };
  1941. /* Values for kvm_get_htab_fd.flags */
  1942. #define KVM_GET_HTAB_BOLTED_ONLY ((__u64)0x1)
  1943. #define KVM_GET_HTAB_WRITE ((__u64)0x2)
  1944. The `start_index' field gives the index in the HPT of the entry at
  1945. which to start reading. It is ignored when writing.
  1946. Reads on the fd will initially supply information about all
  1947. "interesting" HPT entries. Interesting entries are those with the
  1948. bolted bit set, if the KVM_GET_HTAB_BOLTED_ONLY bit is set, otherwise
  1949. all entries. When the end of the HPT is reached, the read() will
  1950. return. If read() is called again on the fd, it will start again from
  1951. the beginning of the HPT, but will only return HPT entries that have
  1952. changed since they were last read.
  1953. Data read or written is structured as a header (8 bytes) followed by a
  1954. series of valid HPT entries (16 bytes) each. The header indicates how
  1955. many valid HPT entries there are and how many invalid entries follow
  1956. the valid entries. The invalid entries are not represented explicitly
  1957. in the stream. The header format is:
  1958. struct kvm_get_htab_header {
  1959. __u32 index;
  1960. __u16 n_valid;
  1961. __u16 n_invalid;
  1962. };
  1963. Writes to the fd create HPT entries starting at the index given in the
  1964. header; first `n_valid' valid entries with contents from the data
  1965. written, then `n_invalid' invalid entries, invalidating any previously
  1966. valid entries found.
  1967. 4.79 KVM_CREATE_DEVICE
  1968. Capability: KVM_CAP_DEVICE_CTRL
  1969. Type: vm ioctl
  1970. Parameters: struct kvm_create_device (in/out)
  1971. Returns: 0 on success, -1 on error
  1972. Errors:
  1973. ENODEV: The device type is unknown or unsupported
  1974. EEXIST: Device already created, and this type of device may not
  1975. be instantiated multiple times
  1976. Other error conditions may be defined by individual device types or
  1977. have their standard meanings.
  1978. Creates an emulated device in the kernel. The file descriptor returned
  1979. in fd can be used with KVM_SET/GET/HAS_DEVICE_ATTR.
  1980. If the KVM_CREATE_DEVICE_TEST flag is set, only test whether the
  1981. device type is supported (not necessarily whether it can be created
  1982. in the current vm).
  1983. Individual devices should not define flags. Attributes should be used
  1984. for specifying any behavior that is not implied by the device type
  1985. number.
  1986. struct kvm_create_device {
  1987. __u32 type; /* in: KVM_DEV_TYPE_xxx */
  1988. __u32 fd; /* out: device handle */
  1989. __u32 flags; /* in: KVM_CREATE_DEVICE_xxx */
  1990. };
  1991. 4.80 KVM_SET_DEVICE_ATTR/KVM_GET_DEVICE_ATTR
  1992. Capability: KVM_CAP_DEVICE_CTRL, KVM_CAP_VM_ATTRIBUTES for vm device,
  1993. KVM_CAP_VCPU_ATTRIBUTES for vcpu device
  1994. Type: device ioctl, vm ioctl, vcpu ioctl
  1995. Parameters: struct kvm_device_attr
  1996. Returns: 0 on success, -1 on error
  1997. Errors:
  1998. ENXIO: The group or attribute is unknown/unsupported for this device
  1999. or hardware support is missing.
  2000. EPERM: The attribute cannot (currently) be accessed this way
  2001. (e.g. read-only attribute, or attribute that only makes
  2002. sense when the device is in a different state)
  2003. Other error conditions may be defined by individual device types.
  2004. Gets/sets a specified piece of device configuration and/or state. The
  2005. semantics are device-specific. See individual device documentation in
  2006. the "devices" directory. As with ONE_REG, the size of the data
  2007. transferred is defined by the particular attribute.
  2008. struct kvm_device_attr {
  2009. __u32 flags; /* no flags currently defined */
  2010. __u32 group; /* device-defined */
  2011. __u64 attr; /* group-defined */
  2012. __u64 addr; /* userspace address of attr data */
  2013. };
  2014. 4.81 KVM_HAS_DEVICE_ATTR
  2015. Capability: KVM_CAP_DEVICE_CTRL, KVM_CAP_VM_ATTRIBUTES for vm device,
  2016. KVM_CAP_VCPU_ATTRIBUTES for vcpu device
  2017. Type: device ioctl, vm ioctl, vcpu ioctl
  2018. Parameters: struct kvm_device_attr
  2019. Returns: 0 on success, -1 on error
  2020. Errors:
  2021. ENXIO: The group or attribute is unknown/unsupported for this device
  2022. or hardware support is missing.
  2023. Tests whether a device supports a particular attribute. A successful
  2024. return indicates the attribute is implemented. It does not necessarily
  2025. indicate that the attribute can be read or written in the device's
  2026. current state. "addr" is ignored.
  2027. 4.82 KVM_ARM_VCPU_INIT
  2028. Capability: basic
  2029. Architectures: arm, arm64
  2030. Type: vcpu ioctl
  2031. Parameters: struct kvm_vcpu_init (in)
  2032. Returns: 0 on success; -1 on error
  2033. Errors:
  2034.  EINVAL:    the target is unknown, or the combination of features is invalid.
  2035.  ENOENT:    a features bit specified is unknown.
  2036. This tells KVM what type of CPU to present to the guest, and what
  2037. optional features it should have.  This will cause a reset of the cpu
  2038. registers to their initial values.  If this is not called, KVM_RUN will
  2039. return ENOEXEC for that vcpu.
  2040. Note that because some registers reflect machine topology, all vcpus
  2041. should be created before this ioctl is invoked.
  2042. Userspace can call this function multiple times for a given vcpu, including
  2043. after the vcpu has been run. This will reset the vcpu to its initial
  2044. state. All calls to this function after the initial call must use the same
  2045. target and same set of feature flags, otherwise EINVAL will be returned.
  2046. Possible features:
  2047. - KVM_ARM_VCPU_POWER_OFF: Starts the CPU in a power-off state.
  2048. Depends on KVM_CAP_ARM_PSCI. If not set, the CPU will be powered on
  2049. and execute guest code when KVM_RUN is called.
  2050. - KVM_ARM_VCPU_EL1_32BIT: Starts the CPU in a 32bit mode.
  2051. Depends on KVM_CAP_ARM_EL1_32BIT (arm64 only).
  2052. - KVM_ARM_VCPU_PSCI_0_2: Emulate PSCI v0.2 (or a future revision
  2053. backward compatible with v0.2) for the CPU.
  2054. Depends on KVM_CAP_ARM_PSCI_0_2.
  2055. - KVM_ARM_VCPU_PMU_V3: Emulate PMUv3 for the CPU.
  2056. Depends on KVM_CAP_ARM_PMU_V3.
  2057. 4.83 KVM_ARM_PREFERRED_TARGET
  2058. Capability: basic
  2059. Architectures: arm, arm64
  2060. Type: vm ioctl
  2061. Parameters: struct struct kvm_vcpu_init (out)
  2062. Returns: 0 on success; -1 on error
  2063. Errors:
  2064. ENODEV: no preferred target available for the host
  2065. This queries KVM for preferred CPU target type which can be emulated
  2066. by KVM on underlying host.
  2067. The ioctl returns struct kvm_vcpu_init instance containing information
  2068. about preferred CPU target type and recommended features for it. The
  2069. kvm_vcpu_init->features bitmap returned will have feature bits set if
  2070. the preferred target recommends setting these features, but this is
  2071. not mandatory.
  2072. The information returned by this ioctl can be used to prepare an instance
  2073. of struct kvm_vcpu_init for KVM_ARM_VCPU_INIT ioctl which will result in
  2074. in VCPU matching underlying host.
  2075. 4.84 KVM_GET_REG_LIST
  2076. Capability: basic
  2077. Architectures: arm, arm64, mips
  2078. Type: vcpu ioctl
  2079. Parameters: struct kvm_reg_list (in/out)
  2080. Returns: 0 on success; -1 on error
  2081. Errors:
  2082.  E2BIG:     the reg index list is too big to fit in the array specified by
  2083.             the user (the number required will be written into n).
  2084. struct kvm_reg_list {
  2085. __u64 n; /* number of registers in reg[] */
  2086. __u64 reg[0];
  2087. };
  2088. This ioctl returns the guest registers that are supported for the
  2089. KVM_GET_ONE_REG/KVM_SET_ONE_REG calls.
  2090. 4.85 KVM_ARM_SET_DEVICE_ADDR (deprecated)
  2091. Capability: KVM_CAP_ARM_SET_DEVICE_ADDR
  2092. Architectures: arm, arm64
  2093. Type: vm ioctl
  2094. Parameters: struct kvm_arm_device_address (in)
  2095. Returns: 0 on success, -1 on error
  2096. Errors:
  2097. ENODEV: The device id is unknown
  2098. ENXIO: Device not supported on current system
  2099. EEXIST: Address already set
  2100. E2BIG: Address outside guest physical address space
  2101. EBUSY: Address overlaps with other device range
  2102. struct kvm_arm_device_addr {
  2103. __u64 id;
  2104. __u64 addr;
  2105. };
  2106. Specify a device address in the guest's physical address space where guests
  2107. can access emulated or directly exposed devices, which the host kernel needs
  2108. to know about. The id field is an architecture specific identifier for a
  2109. specific device.
  2110. ARM/arm64 divides the id field into two parts, a device id and an
  2111. address type id specific to the individual device.
  2112.  bits: | 63 ... 32 | 31 ... 16 | 15 ... 0 |
  2113. field: | 0x00000000 | device id | addr type id |
  2114. ARM/arm64 currently only require this when using the in-kernel GIC
  2115. support for the hardware VGIC features, using KVM_ARM_DEVICE_VGIC_V2
  2116. as the device id. When setting the base address for the guest's
  2117. mapping of the VGIC virtual CPU and distributor interface, the ioctl
  2118. must be called after calling KVM_CREATE_IRQCHIP, but before calling
  2119. KVM_RUN on any of the VCPUs. Calling this ioctl twice for any of the
  2120. base addresses will return -EEXIST.
  2121. Note, this IOCTL is deprecated and the more flexible SET/GET_DEVICE_ATTR API
  2122. should be used instead.
  2123. 4.86 KVM_PPC_RTAS_DEFINE_TOKEN
  2124. Capability: KVM_CAP_PPC_RTAS
  2125. Architectures: ppc
  2126. Type: vm ioctl
  2127. Parameters: struct kvm_rtas_token_args
  2128. Returns: 0 on success, -1 on error
  2129. Defines a token value for a RTAS (Run Time Abstraction Services)
  2130. service in order to allow it to be handled in the kernel. The
  2131. argument struct gives the name of the service, which must be the name
  2132. of a service that has a kernel-side implementation. If the token
  2133. value is non-zero, it will be associated with that service, and
  2134. subsequent RTAS calls by the guest specifying that token will be
  2135. handled by the kernel. If the token value is 0, then any token
  2136. associated with the service will be forgotten, and subsequent RTAS
  2137. calls by the guest for that service will be passed to userspace to be
  2138. handled.
  2139. 4.87 KVM_SET_GUEST_DEBUG
  2140. Capability: KVM_CAP_SET_GUEST_DEBUG
  2141. Architectures: x86, s390, ppc, arm64
  2142. Type: vcpu ioctl
  2143. Parameters: struct kvm_guest_debug (in)
  2144. Returns: 0 on success; -1 on error
  2145. struct kvm_guest_debug {
  2146. __u32 control;
  2147. __u32 pad;
  2148. struct kvm_guest_debug_arch arch;
  2149. };
  2150. Set up the processor specific debug registers and configure vcpu for
  2151. handling guest debug events. There are two parts to the structure, the
  2152. first a control bitfield indicates the type of debug events to handle
  2153. when running. Common control bits are:
  2154. - KVM_GUESTDBG_ENABLE: guest debugging is enabled
  2155. - KVM_GUESTDBG_SINGLESTEP: the next run should single-step
  2156. The top 16 bits of the control field are architecture specific control
  2157. flags which can include the following:
  2158. - KVM_GUESTDBG_USE_SW_BP: using software breakpoints [x86, arm64]
  2159. - KVM_GUESTDBG_USE_HW_BP: using hardware breakpoints [x86, s390, arm64]
  2160. - KVM_GUESTDBG_INJECT_DB: inject DB type exception [x86]
  2161. - KVM_GUESTDBG_INJECT_BP: inject BP type exception [x86]
  2162. - KVM_GUESTDBG_EXIT_PENDING: trigger an immediate guest exit [s390]
  2163. For example KVM_GUESTDBG_USE_SW_BP indicates that software breakpoints
  2164. are enabled in memory so we need to ensure breakpoint exceptions are
  2165. correctly trapped and the KVM run loop exits at the breakpoint and not
  2166. running off into the normal guest vector. For KVM_GUESTDBG_USE_HW_BP
  2167. we need to ensure the guest vCPUs architecture specific registers are
  2168. updated to the correct (supplied) values.
  2169. The second part of the structure is architecture specific and
  2170. typically contains a set of debug registers.
  2171. For arm64 the number of debug registers is implementation defined and
  2172. can be determined by querying the KVM_CAP_GUEST_DEBUG_HW_BPS and
  2173. KVM_CAP_GUEST_DEBUG_HW_WPS capabilities which return a positive number
  2174. indicating the number of supported registers.
  2175. When debug events exit the main run loop with the reason
  2176. KVM_EXIT_DEBUG with the kvm_debug_exit_arch part of the kvm_run
  2177. structure containing architecture specific debug information.
  2178. 4.88 KVM_GET_EMULATED_CPUID
  2179. Capability: KVM_CAP_EXT_EMUL_CPUID
  2180. Architectures: x86
  2181. Type: system ioctl
  2182. Parameters: struct kvm_cpuid2 (in/out)
  2183. Returns: 0 on success, -1 on error
  2184. struct kvm_cpuid2 {
  2185. __u32 nent;
  2186. __u32 flags;
  2187. struct kvm_cpuid_entry2 entries[0];
  2188. };
  2189. The member 'flags' is used for passing flags from userspace.
  2190. #define KVM_CPUID_FLAG_SIGNIFCANT_INDEX BIT(0)
  2191. #define KVM_CPUID_FLAG_STATEFUL_FUNC BIT(1)
  2192. #define KVM_CPUID_FLAG_STATE_READ_NEXT BIT(2)
  2193. struct kvm_cpuid_entry2 {
  2194. __u32 function;
  2195. __u32 index;
  2196. __u32 flags;
  2197. __u32 eax;
  2198. __u32 ebx;
  2199. __u32 ecx;
  2200. __u32 edx;
  2201. __u32 padding[3];
  2202. };
  2203. This ioctl returns x86 cpuid features which are emulated by
  2204. kvm.Userspace can use the information returned by this ioctl to query
  2205. which features are emulated by kvm instead of being present natively.
  2206. Userspace invokes KVM_GET_EMULATED_CPUID by passing a kvm_cpuid2
  2207. structure with the 'nent' field indicating the number of entries in
  2208. the variable-size array 'entries'. If the number of entries is too low
  2209. to describe the cpu capabilities, an error (E2BIG) is returned. If the
  2210. number is too high, the 'nent' field is adjusted and an error (ENOMEM)
  2211. is returned. If the number is just right, the 'nent' field is adjusted
  2212. to the number of valid entries in the 'entries' array, which is then
  2213. filled.
  2214. The entries returned are the set CPUID bits of the respective features
  2215. which kvm emulates, as returned by the CPUID instruction, with unknown
  2216. or unsupported feature bits cleared.
  2217. Features like x2apic, for example, may not be present in the host cpu
  2218. but are exposed by kvm in KVM_GET_SUPPORTED_CPUID because they can be
  2219. emulated efficiently and thus not included here.
  2220. The fields in each entry are defined as follows:
  2221. function: the eax value used to obtain the entry
  2222. index: the ecx value used to obtain the entry (for entries that are
  2223. affected by ecx)
  2224. flags: an OR of zero or more of the following:
  2225. KVM_CPUID_FLAG_SIGNIFCANT_INDEX:
  2226. if the index field is valid
  2227. KVM_CPUID_FLAG_STATEFUL_FUNC:
  2228. if cpuid for this function returns different values for successive
  2229. invocations; there will be several entries with the same function,
  2230. all with this flag set
  2231. KVM_CPUID_FLAG_STATE_READ_NEXT:
  2232. for KVM_CPUID_FLAG_STATEFUL_FUNC entries, set if this entry is
  2233. the first entry to be read by a cpu
  2234. eax, ebx, ecx, edx: the values returned by the cpuid instruction for
  2235. this function/index combination
  2236. 4.89 KVM_S390_MEM_OP
  2237. Capability: KVM_CAP_S390_MEM_OP
  2238. Architectures: s390
  2239. Type: vcpu ioctl
  2240. Parameters: struct kvm_s390_mem_op (in)
  2241. Returns: = 0 on success,
  2242. < 0 on generic error (e.g. -EFAULT or -ENOMEM),
  2243. > 0 if an exception occurred while walking the page tables
  2244. Read or write data from/to the logical (virtual) memory of a VCPU.
  2245. Parameters are specified via the following structure:
  2246. struct kvm_s390_mem_op {
  2247. __u64 gaddr; /* the guest address */
  2248. __u64 flags; /* flags */
  2249. __u32 size; /* amount of bytes */
  2250. __u32 op; /* type of operation */
  2251. __u64 buf; /* buffer in userspace */
  2252. __u8 ar; /* the access register number */
  2253. __u8 reserved[31]; /* should be set to 0 */
  2254. };
  2255. The type of operation is specified in the "op" field. It is either
  2256. KVM_S390_MEMOP_LOGICAL_READ for reading from logical memory space or
  2257. KVM_S390_MEMOP_LOGICAL_WRITE for writing to logical memory space. The
  2258. KVM_S390_MEMOP_F_CHECK_ONLY flag can be set in the "flags" field to check
  2259. whether the corresponding memory access would create an access exception
  2260. (without touching the data in the memory at the destination). In case an
  2261. access exception occurred while walking the MMU tables of the guest, the
  2262. ioctl returns a positive error number to indicate the type of exception.
  2263. This exception is also raised directly at the corresponding VCPU if the
  2264. flag KVM_S390_MEMOP_F_INJECT_EXCEPTION is set in the "flags" field.
  2265. The start address of the memory region has to be specified in the "gaddr"
  2266. field, and the length of the region in the "size" field. "buf" is the buffer
  2267. supplied by the userspace application where the read data should be written
  2268. to for KVM_S390_MEMOP_LOGICAL_READ, or where the data that should be written
  2269. is stored for a KVM_S390_MEMOP_LOGICAL_WRITE. "buf" is unused and can be NULL
  2270. when KVM_S390_MEMOP_F_CHECK_ONLY is specified. "ar" designates the access
  2271. register number to be used.
  2272. The "reserved" field is meant for future extensions. It is not used by
  2273. KVM with the currently defined set of flags.
  2274. 4.90 KVM_S390_GET_SKEYS
  2275. Capability: KVM_CAP_S390_SKEYS
  2276. Architectures: s390
  2277. Type: vm ioctl
  2278. Parameters: struct kvm_s390_skeys
  2279. Returns: 0 on success, KVM_S390_GET_KEYS_NONE if guest is not using storage
  2280. keys, negative value on error
  2281. This ioctl is used to get guest storage key values on the s390
  2282. architecture. The ioctl takes parameters via the kvm_s390_skeys struct.
  2283. struct kvm_s390_skeys {
  2284. __u64 start_gfn;
  2285. __u64 count;
  2286. __u64 skeydata_addr;
  2287. __u32 flags;
  2288. __u32 reserved[9];
  2289. };
  2290. The start_gfn field is the number of the first guest frame whose storage keys
  2291. you want to get.
  2292. The count field is the number of consecutive frames (starting from start_gfn)
  2293. whose storage keys to get. The count field must be at least 1 and the maximum
  2294. allowed value is defined as KVM_S390_SKEYS_ALLOC_MAX. Values outside this range
  2295. will cause the ioctl to return -EINVAL.
  2296. The skeydata_addr field is the address to a buffer large enough to hold count
  2297. bytes. This buffer will be filled with storage key data by the ioctl.
  2298. 4.91 KVM_S390_SET_SKEYS
  2299. Capability: KVM_CAP_S390_SKEYS
  2300. Architectures: s390
  2301. Type: vm ioctl
  2302. Parameters: struct kvm_s390_skeys
  2303. Returns: 0 on success, negative value on error
  2304. This ioctl is used to set guest storage key values on the s390
  2305. architecture. The ioctl takes parameters via the kvm_s390_skeys struct.
  2306. See section on KVM_S390_GET_SKEYS for struct definition.
  2307. The start_gfn field is the number of the first guest frame whose storage keys
  2308. you want to set.
  2309. The count field is the number of consecutive frames (starting from start_gfn)
  2310. whose storage keys to get. The count field must be at least 1 and the maximum
  2311. allowed value is defined as KVM_S390_SKEYS_ALLOC_MAX. Values outside this range
  2312. will cause the ioctl to return -EINVAL.
  2313. The skeydata_addr field is the address to a buffer containing count bytes of
  2314. storage keys. Each byte in the buffer will be set as the storage key for a
  2315. single frame starting at start_gfn for count frames.
  2316. Note: If any architecturally invalid key value is found in the given data then
  2317. the ioctl will return -EINVAL.
  2318. 4.92 KVM_S390_IRQ
  2319. Capability: KVM_CAP_S390_INJECT_IRQ
  2320. Architectures: s390
  2321. Type: vcpu ioctl
  2322. Parameters: struct kvm_s390_irq (in)
  2323. Returns: 0 on success, -1 on error
  2324. Errors:
  2325. EINVAL: interrupt type is invalid
  2326. type is KVM_S390_SIGP_STOP and flag parameter is invalid value
  2327. type is KVM_S390_INT_EXTERNAL_CALL and code is bigger
  2328. than the maximum of VCPUs
  2329. EBUSY: type is KVM_S390_SIGP_SET_PREFIX and vcpu is not stopped
  2330. type is KVM_S390_SIGP_STOP and a stop irq is already pending
  2331. type is KVM_S390_INT_EXTERNAL_CALL and an external call interrupt
  2332. is already pending
  2333. Allows to inject an interrupt to the guest.
  2334. Using struct kvm_s390_irq as a parameter allows
  2335. to inject additional payload which is not
  2336. possible via KVM_S390_INTERRUPT.
  2337. Interrupt parameters are passed via kvm_s390_irq:
  2338. struct kvm_s390_irq {
  2339. __u64 type;
  2340. union {
  2341. struct kvm_s390_io_info io;
  2342. struct kvm_s390_ext_info ext;
  2343. struct kvm_s390_pgm_info pgm;
  2344. struct kvm_s390_emerg_info emerg;
  2345. struct kvm_s390_extcall_info extcall;
  2346. struct kvm_s390_prefix_info prefix;
  2347. struct kvm_s390_stop_info stop;
  2348. struct kvm_s390_mchk_info mchk;
  2349. char reserved[64];
  2350. } u;
  2351. };
  2352. type can be one of the following:
  2353. KVM_S390_SIGP_STOP - sigp stop; parameter in .stop
  2354. KVM_S390_PROGRAM_INT - program check; parameters in .pgm
  2355. KVM_S390_SIGP_SET_PREFIX - sigp set prefix; parameters in .prefix
  2356. KVM_S390_RESTART - restart; no parameters
  2357. KVM_S390_INT_CLOCK_COMP - clock comparator interrupt; no parameters
  2358. KVM_S390_INT_CPU_TIMER - CPU timer interrupt; no parameters
  2359. KVM_S390_INT_EMERGENCY - sigp emergency; parameters in .emerg
  2360. KVM_S390_INT_EXTERNAL_CALL - sigp external call; parameters in .extcall
  2361. KVM_S390_MCHK - machine check interrupt; parameters in .mchk
  2362. Note that the vcpu ioctl is asynchronous to vcpu execution.
  2363. 4.94 KVM_S390_GET_IRQ_STATE
  2364. Capability: KVM_CAP_S390_IRQ_STATE
  2365. Architectures: s390
  2366. Type: vcpu ioctl
  2367. Parameters: struct kvm_s390_irq_state (out)
  2368. Returns: >= number of bytes copied into buffer,
  2369. -EINVAL if buffer size is 0,
  2370. -ENOBUFS if buffer size is too small to fit all pending interrupts,
  2371. -EFAULT if the buffer address was invalid
  2372. This ioctl allows userspace to retrieve the complete state of all currently
  2373. pending interrupts in a single buffer. Use cases include migration
  2374. and introspection. The parameter structure contains the address of a
  2375. userspace buffer and its length:
  2376. struct kvm_s390_irq_state {
  2377. __u64 buf;
  2378. __u32 flags;
  2379. __u32 len;
  2380. __u32 reserved[4];
  2381. };
  2382. Userspace passes in the above struct and for each pending interrupt a
  2383. struct kvm_s390_irq is copied to the provided buffer.
  2384. If -ENOBUFS is returned the buffer provided was too small and userspace
  2385. may retry with a bigger buffer.
  2386. 4.95 KVM_S390_SET_IRQ_STATE
  2387. Capability: KVM_CAP_S390_IRQ_STATE
  2388. Architectures: s390
  2389. Type: vcpu ioctl
  2390. Parameters: struct kvm_s390_irq_state (in)
  2391. Returns: 0 on success,
  2392. -EFAULT if the buffer address was invalid,
  2393. -EINVAL for an invalid buffer length (see below),
  2394. -EBUSY if there were already interrupts pending,
  2395. errors occurring when actually injecting the
  2396. interrupt. See KVM_S390_IRQ.
  2397. This ioctl allows userspace to set the complete state of all cpu-local
  2398. interrupts currently pending for the vcpu. It is intended for restoring
  2399. interrupt state after a migration. The input parameter is a userspace buffer
  2400. containing a struct kvm_s390_irq_state:
  2401. struct kvm_s390_irq_state {
  2402. __u64 buf;
  2403. __u32 len;
  2404. __u32 pad;
  2405. };
  2406. The userspace memory referenced by buf contains a struct kvm_s390_irq
  2407. for each interrupt to be injected into the guest.
  2408. If one of the interrupts could not be injected for some reason the
  2409. ioctl aborts.
  2410. len must be a multiple of sizeof(struct kvm_s390_irq). It must be > 0
  2411. and it must not exceed (max_vcpus + 32) * sizeof(struct kvm_s390_irq),
  2412. which is the maximum number of possibly pending cpu-local interrupts.
  2413. 4.96 KVM_SMI
  2414. Capability: KVM_CAP_X86_SMM
  2415. Architectures: x86
  2416. Type: vcpu ioctl
  2417. Parameters: none
  2418. Returns: 0 on success, -1 on error
  2419. Queues an SMI on the thread's vcpu.
  2420. 4.97 KVM_CAP_PPC_MULTITCE
  2421. Capability: KVM_CAP_PPC_MULTITCE
  2422. Architectures: ppc
  2423. Type: vm
  2424. This capability means the kernel is capable of handling hypercalls
  2425. H_PUT_TCE_INDIRECT and H_STUFF_TCE without passing those into the user
  2426. space. This significantly accelerates DMA operations for PPC KVM guests.
  2427. User space should expect that its handlers for these hypercalls
  2428. are not going to be called if user space previously registered LIOBN
  2429. in KVM (via KVM_CREATE_SPAPR_TCE or similar calls).
  2430. In order to enable H_PUT_TCE_INDIRECT and H_STUFF_TCE use in the guest,
  2431. user space might have to advertise it for the guest. For example,
  2432. IBM pSeries (sPAPR) guest starts using them if "hcall-multi-tce" is
  2433. present in the "ibm,hypertas-functions" device-tree property.
  2434. The hypercalls mentioned above may or may not be processed successfully
  2435. in the kernel based fast path. If they can not be handled by the kernel,
  2436. they will get passed on to user space. So user space still has to have
  2437. an implementation for these despite the in kernel acceleration.
  2438. This capability is always enabled.
  2439. 4.98 KVM_CREATE_SPAPR_TCE_64
  2440. Capability: KVM_CAP_SPAPR_TCE_64
  2441. Architectures: powerpc
  2442. Type: vm ioctl
  2443. Parameters: struct kvm_create_spapr_tce_64 (in)
  2444. Returns: file descriptor for manipulating the created TCE table
  2445. This is an extension for KVM_CAP_SPAPR_TCE which only supports 32bit
  2446. windows, described in 4.62 KVM_CREATE_SPAPR_TCE
  2447. This capability uses extended struct in ioctl interface:
  2448. /* for KVM_CAP_SPAPR_TCE_64 */
  2449. struct kvm_create_spapr_tce_64 {
  2450. __u64 liobn;
  2451. __u32 page_shift;
  2452. __u32 flags;
  2453. __u64 offset; /* in pages */
  2454. __u64 size; /* in pages */
  2455. };
  2456. The aim of extension is to support an additional bigger DMA window with
  2457. a variable page size.
  2458. KVM_CREATE_SPAPR_TCE_64 receives a 64bit window size, an IOMMU page shift and
  2459. a bus offset of the corresponding DMA window, @size and @offset are numbers
  2460. of IOMMU pages.
  2461. @flags are not used at the moment.
  2462. The rest of functionality is identical to KVM_CREATE_SPAPR_TCE.
  2463. 4.98 KVM_REINJECT_CONTROL
  2464. Capability: KVM_CAP_REINJECT_CONTROL
  2465. Architectures: x86
  2466. Type: vm ioctl
  2467. Parameters: struct kvm_reinject_control (in)
  2468. Returns: 0 on success,
  2469. -EFAULT if struct kvm_reinject_control cannot be read,
  2470. -ENXIO if KVM_CREATE_PIT or KVM_CREATE_PIT2 didn't succeed earlier.
  2471. i8254 (PIT) has two modes, reinject and !reinject. The default is reinject,
  2472. where KVM queues elapsed i8254 ticks and monitors completion of interrupt from
  2473. vector(s) that i8254 injects. Reinject mode dequeues a tick and injects its
  2474. interrupt whenever there isn't a pending interrupt from i8254.
  2475. !reinject mode injects an interrupt as soon as a tick arrives.
  2476. struct kvm_reinject_control {
  2477. __u8 pit_reinject;
  2478. __u8 reserved[31];
  2479. };
  2480. pit_reinject = 0 (!reinject mode) is recommended, unless running an old
  2481. operating system that uses the PIT for timing (e.g. Linux 2.4.x).
  2482. 5. The kvm_run structure
  2483. ------------------------
  2484. Application code obtains a pointer to the kvm_run structure by
  2485. mmap()ing a vcpu fd. From that point, application code can control
  2486. execution by changing fields in kvm_run prior to calling the KVM_RUN
  2487. ioctl, and obtain information about the reason KVM_RUN returned by
  2488. looking up structure members.
  2489. struct kvm_run {
  2490. /* in */
  2491. __u8 request_interrupt_window;
  2492. Request that KVM_RUN return when it becomes possible to inject external
  2493. interrupts into the guest. Useful in conjunction with KVM_INTERRUPT.
  2494. __u8 padding1[7];
  2495. /* out */
  2496. __u32 exit_reason;
  2497. When KVM_RUN has returned successfully (return value 0), this informs
  2498. application code why KVM_RUN has returned. Allowable values for this
  2499. field are detailed below.
  2500. __u8 ready_for_interrupt_injection;
  2501. If request_interrupt_window has been specified, this field indicates
  2502. an interrupt can be injected now with KVM_INTERRUPT.
  2503. __u8 if_flag;
  2504. The value of the current interrupt flag. Only valid if in-kernel
  2505. local APIC is not used.
  2506. __u16 flags;
  2507. More architecture-specific flags detailing state of the VCPU that may
  2508. affect the device's behavior. The only currently defined flag is
  2509. KVM_RUN_X86_SMM, which is valid on x86 machines and is set if the
  2510. VCPU is in system management mode.
  2511. /* in (pre_kvm_run), out (post_kvm_run) */
  2512. __u64 cr8;
  2513. The value of the cr8 register. Only valid if in-kernel local APIC is
  2514. not used. Both input and output.
  2515. __u64 apic_base;
  2516. The value of the APIC BASE msr. Only valid if in-kernel local
  2517. APIC is not used. Both input and output.
  2518. union {
  2519. /* KVM_EXIT_UNKNOWN */
  2520. struct {
  2521. __u64 hardware_exit_reason;
  2522. } hw;
  2523. If exit_reason is KVM_EXIT_UNKNOWN, the vcpu has exited due to unknown
  2524. reasons. Further architecture-specific information is available in
  2525. hardware_exit_reason.
  2526. /* KVM_EXIT_FAIL_ENTRY */
  2527. struct {
  2528. __u64 hardware_entry_failure_reason;
  2529. } fail_entry;
  2530. If exit_reason is KVM_EXIT_FAIL_ENTRY, the vcpu could not be run due
  2531. to unknown reasons. Further architecture-specific information is
  2532. available in hardware_entry_failure_reason.
  2533. /* KVM_EXIT_EXCEPTION */
  2534. struct {
  2535. __u32 exception;
  2536. __u32 error_code;
  2537. } ex;
  2538. Unused.
  2539. /* KVM_EXIT_IO */
  2540. struct {
  2541. #define KVM_EXIT_IO_IN 0
  2542. #define KVM_EXIT_IO_OUT 1
  2543. __u8 direction;
  2544. __u8 size; /* bytes */
  2545. __u16 port;
  2546. __u32 count;
  2547. __u64 data_offset; /* relative to kvm_run start */
  2548. } io;
  2549. If exit_reason is KVM_EXIT_IO, then the vcpu has
  2550. executed a port I/O instruction which could not be satisfied by kvm.
  2551. data_offset describes where the data is located (KVM_EXIT_IO_OUT) or
  2552. where kvm expects application code to place the data for the next
  2553. KVM_RUN invocation (KVM_EXIT_IO_IN). Data format is a packed array.
  2554. /* KVM_EXIT_DEBUG */
  2555. struct {
  2556. struct kvm_debug_exit_arch arch;
  2557. } debug;
  2558. If the exit_reason is KVM_EXIT_DEBUG, then a vcpu is processing a debug event
  2559. for which architecture specific information is returned.
  2560. /* KVM_EXIT_MMIO */
  2561. struct {
  2562. __u64 phys_addr;
  2563. __u8 data[8];
  2564. __u32 len;
  2565. __u8 is_write;
  2566. } mmio;
  2567. If exit_reason is KVM_EXIT_MMIO, then the vcpu has
  2568. executed a memory-mapped I/O instruction which could not be satisfied
  2569. by kvm. The 'data' member contains the written data if 'is_write' is
  2570. true, and should be filled by application code otherwise.
  2571. The 'data' member contains, in its first 'len' bytes, the value as it would
  2572. appear if the VCPU performed a load or store of the appropriate width directly
  2573. to the byte array.
  2574. NOTE: For KVM_EXIT_IO, KVM_EXIT_MMIO, KVM_EXIT_OSI, KVM_EXIT_PAPR and
  2575. KVM_EXIT_EPR the corresponding
  2576. operations are complete (and guest state is consistent) only after userspace
  2577. has re-entered the kernel with KVM_RUN. The kernel side will first finish
  2578. incomplete operations and then check for pending signals. Userspace
  2579. can re-enter the guest with an unmasked signal pending to complete
  2580. pending operations.
  2581. /* KVM_EXIT_HYPERCALL */
  2582. struct {
  2583. __u64 nr;
  2584. __u64 args[6];
  2585. __u64 ret;
  2586. __u32 longmode;
  2587. __u32 pad;
  2588. } hypercall;
  2589. Unused. This was once used for 'hypercall to userspace'. To implement
  2590. such functionality, use KVM_EXIT_IO (x86) or KVM_EXIT_MMIO (all except s390).
  2591. Note KVM_EXIT_IO is significantly faster than KVM_EXIT_MMIO.
  2592. /* KVM_EXIT_TPR_ACCESS */
  2593. struct {
  2594. __u64 rip;
  2595. __u32 is_write;
  2596. __u32 pad;
  2597. } tpr_access;
  2598. To be documented (KVM_TPR_ACCESS_REPORTING).
  2599. /* KVM_EXIT_S390_SIEIC */
  2600. struct {
  2601. __u8 icptcode;
  2602. __u64 mask; /* psw upper half */
  2603. __u64 addr; /* psw lower half */
  2604. __u16 ipa;
  2605. __u32 ipb;
  2606. } s390_sieic;
  2607. s390 specific.
  2608. /* KVM_EXIT_S390_RESET */
  2609. #define KVM_S390_RESET_POR 1
  2610. #define KVM_S390_RESET_CLEAR 2
  2611. #define KVM_S390_RESET_SUBSYSTEM 4
  2612. #define KVM_S390_RESET_CPU_INIT 8
  2613. #define KVM_S390_RESET_IPL 16
  2614. __u64 s390_reset_flags;
  2615. s390 specific.
  2616. /* KVM_EXIT_S390_UCONTROL */
  2617. struct {
  2618. __u64 trans_exc_code;
  2619. __u32 pgm_code;
  2620. } s390_ucontrol;
  2621. s390 specific. A page fault has occurred for a user controlled virtual
  2622. machine (KVM_VM_S390_UNCONTROL) on it's host page table that cannot be
  2623. resolved by the kernel.
  2624. The program code and the translation exception code that were placed
  2625. in the cpu's lowcore are presented here as defined by the z Architecture
  2626. Principles of Operation Book in the Chapter for Dynamic Address Translation
  2627. (DAT)
  2628. /* KVM_EXIT_DCR */
  2629. struct {
  2630. __u32 dcrn;
  2631. __u32 data;
  2632. __u8 is_write;
  2633. } dcr;
  2634. Deprecated - was used for 440 KVM.
  2635. /* KVM_EXIT_OSI */
  2636. struct {
  2637. __u64 gprs[32];
  2638. } osi;
  2639. MOL uses a special hypercall interface it calls 'OSI'. To enable it, we catch
  2640. hypercalls and exit with this exit struct that contains all the guest gprs.
  2641. If exit_reason is KVM_EXIT_OSI, then the vcpu has triggered such a hypercall.
  2642. Userspace can now handle the hypercall and when it's done modify the gprs as
  2643. necessary. Upon guest entry all guest GPRs will then be replaced by the values
  2644. in this struct.
  2645. /* KVM_EXIT_PAPR_HCALL */
  2646. struct {
  2647. __u64 nr;
  2648. __u64 ret;
  2649. __u64 args[9];
  2650. } papr_hcall;
  2651. This is used on 64-bit PowerPC when emulating a pSeries partition,
  2652. e.g. with the 'pseries' machine type in qemu. It occurs when the
  2653. guest does a hypercall using the 'sc 1' instruction. The 'nr' field
  2654. contains the hypercall number (from the guest R3), and 'args' contains
  2655. the arguments (from the guest R4 - R12). Userspace should put the
  2656. return code in 'ret' and any extra returned values in args[].
  2657. The possible hypercalls are defined in the Power Architecture Platform
  2658. Requirements (PAPR) document available from www.power.org (free
  2659. developer registration required to access it).
  2660. /* KVM_EXIT_S390_TSCH */
  2661. struct {
  2662. __u16 subchannel_id;
  2663. __u16 subchannel_nr;
  2664. __u32 io_int_parm;
  2665. __u32 io_int_word;
  2666. __u32 ipb;
  2667. __u8 dequeued;
  2668. } s390_tsch;
  2669. s390 specific. This exit occurs when KVM_CAP_S390_CSS_SUPPORT has been enabled
  2670. and TEST SUBCHANNEL was intercepted. If dequeued is set, a pending I/O
  2671. interrupt for the target subchannel has been dequeued and subchannel_id,
  2672. subchannel_nr, io_int_parm and io_int_word contain the parameters for that
  2673. interrupt. ipb is needed for instruction parameter decoding.
  2674. /* KVM_EXIT_EPR */
  2675. struct {
  2676. __u32 epr;
  2677. } epr;
  2678. On FSL BookE PowerPC chips, the interrupt controller has a fast patch
  2679. interrupt acknowledge path to the core. When the core successfully
  2680. delivers an interrupt, it automatically populates the EPR register with
  2681. the interrupt vector number and acknowledges the interrupt inside
  2682. the interrupt controller.
  2683. In case the interrupt controller lives in user space, we need to do
  2684. the interrupt acknowledge cycle through it to fetch the next to be
  2685. delivered interrupt vector using this exit.
  2686. It gets triggered whenever both KVM_CAP_PPC_EPR are enabled and an
  2687. external interrupt has just been delivered into the guest. User space
  2688. should put the acknowledged interrupt vector into the 'epr' field.
  2689. /* KVM_EXIT_SYSTEM_EVENT */
  2690. struct {
  2691. #define KVM_SYSTEM_EVENT_SHUTDOWN 1
  2692. #define KVM_SYSTEM_EVENT_RESET 2
  2693. #define KVM_SYSTEM_EVENT_CRASH 3
  2694. __u32 type;
  2695. __u64 flags;
  2696. } system_event;
  2697. If exit_reason is KVM_EXIT_SYSTEM_EVENT then the vcpu has triggered
  2698. a system-level event using some architecture specific mechanism (hypercall
  2699. or some special instruction). In case of ARM/ARM64, this is triggered using
  2700. HVC instruction based PSCI call from the vcpu. The 'type' field describes
  2701. the system-level event type. The 'flags' field describes architecture
  2702. specific flags for the system-level event.
  2703. Valid values for 'type' are:
  2704. KVM_SYSTEM_EVENT_SHUTDOWN -- the guest has requested a shutdown of the
  2705. VM. Userspace is not obliged to honour this, and if it does honour
  2706. this does not need to destroy the VM synchronously (ie it may call
  2707. KVM_RUN again before shutdown finally occurs).
  2708. KVM_SYSTEM_EVENT_RESET -- the guest has requested a reset of the VM.
  2709. As with SHUTDOWN, userspace can choose to ignore the request, or
  2710. to schedule the reset to occur in the future and may call KVM_RUN again.
  2711. KVM_SYSTEM_EVENT_CRASH -- the guest crash occurred and the guest
  2712. has requested a crash condition maintenance. Userspace can choose
  2713. to ignore the request, or to gather VM memory core dump and/or
  2714. reset/shutdown of the VM.
  2715. /* KVM_EXIT_IOAPIC_EOI */
  2716. struct {
  2717. __u8 vector;
  2718. } eoi;
  2719. Indicates that the VCPU's in-kernel local APIC received an EOI for a
  2720. level-triggered IOAPIC interrupt. This exit only triggers when the
  2721. IOAPIC is implemented in userspace (i.e. KVM_CAP_SPLIT_IRQCHIP is enabled);
  2722. the userspace IOAPIC should process the EOI and retrigger the interrupt if
  2723. it is still asserted. Vector is the LAPIC interrupt vector for which the
  2724. EOI was received.
  2725. struct kvm_hyperv_exit {
  2726. #define KVM_EXIT_HYPERV_SYNIC 1
  2727. #define KVM_EXIT_HYPERV_HCALL 2
  2728. __u32 type;
  2729. union {
  2730. struct {
  2731. __u32 msr;
  2732. __u64 control;
  2733. __u64 evt_page;
  2734. __u64 msg_page;
  2735. } synic;
  2736. struct {
  2737. __u64 input;
  2738. __u64 result;
  2739. __u64 params[2];
  2740. } hcall;
  2741. } u;
  2742. };
  2743. /* KVM_EXIT_HYPERV */
  2744. struct kvm_hyperv_exit hyperv;
  2745. Indicates that the VCPU exits into userspace to process some tasks
  2746. related to Hyper-V emulation.
  2747. Valid values for 'type' are:
  2748. KVM_EXIT_HYPERV_SYNIC -- synchronously notify user-space about
  2749. Hyper-V SynIC state change. Notification is used to remap SynIC
  2750. event/message pages and to enable/disable SynIC messages/events processing
  2751. in userspace.
  2752. /* Fix the size of the union. */
  2753. char padding[256];
  2754. };
  2755. /*
  2756. * shared registers between kvm and userspace.
  2757. * kvm_valid_regs specifies the register classes set by the host
  2758. * kvm_dirty_regs specified the register classes dirtied by userspace
  2759. * struct kvm_sync_regs is architecture specific, as well as the
  2760. * bits for kvm_valid_regs and kvm_dirty_regs
  2761. */
  2762. __u64 kvm_valid_regs;
  2763. __u64 kvm_dirty_regs;
  2764. union {
  2765. struct kvm_sync_regs regs;
  2766. char padding[1024];
  2767. } s;
  2768. If KVM_CAP_SYNC_REGS is defined, these fields allow userspace to access
  2769. certain guest registers without having to call SET/GET_*REGS. Thus we can
  2770. avoid some system call overhead if userspace has to handle the exit.
  2771. Userspace can query the validity of the structure by checking
  2772. kvm_valid_regs for specific bits. These bits are architecture specific
  2773. and usually define the validity of a groups of registers. (e.g. one bit
  2774. for general purpose registers)
  2775. Please note that the kernel is allowed to use the kvm_run structure as the
  2776. primary storage for certain register types. Therefore, the kernel may use the
  2777. values in kvm_run even if the corresponding bit in kvm_dirty_regs is not set.
  2778. };
  2779. 6. Capabilities that can be enabled on vCPUs
  2780. --------------------------------------------
  2781. There are certain capabilities that change the behavior of the virtual CPU or
  2782. the virtual machine when enabled. To enable them, please see section 4.37.
  2783. Below you can find a list of capabilities and what their effect on the vCPU or
  2784. the virtual machine is when enabling them.
  2785. The following information is provided along with the description:
  2786. Architectures: which instruction set architectures provide this ioctl.
  2787. x86 includes both i386 and x86_64.
  2788. Target: whether this is a per-vcpu or per-vm capability.
  2789. Parameters: what parameters are accepted by the capability.
  2790. Returns: the return value. General error numbers (EBADF, ENOMEM, EINVAL)
  2791. are not detailed, but errors with specific meanings are.
  2792. 6.1 KVM_CAP_PPC_OSI
  2793. Architectures: ppc
  2794. Target: vcpu
  2795. Parameters: none
  2796. Returns: 0 on success; -1 on error
  2797. This capability enables interception of OSI hypercalls that otherwise would
  2798. be treated as normal system calls to be injected into the guest. OSI hypercalls
  2799. were invented by Mac-on-Linux to have a standardized communication mechanism
  2800. between the guest and the host.
  2801. When this capability is enabled, KVM_EXIT_OSI can occur.
  2802. 6.2 KVM_CAP_PPC_PAPR
  2803. Architectures: ppc
  2804. Target: vcpu
  2805. Parameters: none
  2806. Returns: 0 on success; -1 on error
  2807. This capability enables interception of PAPR hypercalls. PAPR hypercalls are
  2808. done using the hypercall instruction "sc 1".
  2809. It also sets the guest privilege level to "supervisor" mode. Usually the guest
  2810. runs in "hypervisor" privilege mode with a few missing features.
  2811. In addition to the above, it changes the semantics of SDR1. In this mode, the
  2812. HTAB address part of SDR1 contains an HVA instead of a GPA, as PAPR keeps the
  2813. HTAB invisible to the guest.
  2814. When this capability is enabled, KVM_EXIT_PAPR_HCALL can occur.
  2815. 6.3 KVM_CAP_SW_TLB
  2816. Architectures: ppc
  2817. Target: vcpu
  2818. Parameters: args[0] is the address of a struct kvm_config_tlb
  2819. Returns: 0 on success; -1 on error
  2820. struct kvm_config_tlb {
  2821. __u64 params;
  2822. __u64 array;
  2823. __u32 mmu_type;
  2824. __u32 array_len;
  2825. };
  2826. Configures the virtual CPU's TLB array, establishing a shared memory area
  2827. between userspace and KVM. The "params" and "array" fields are userspace
  2828. addresses of mmu-type-specific data structures. The "array_len" field is an
  2829. safety mechanism, and should be set to the size in bytes of the memory that
  2830. userspace has reserved for the array. It must be at least the size dictated
  2831. by "mmu_type" and "params".
  2832. While KVM_RUN is active, the shared region is under control of KVM. Its
  2833. contents are undefined, and any modification by userspace results in
  2834. boundedly undefined behavior.
  2835. On return from KVM_RUN, the shared region will reflect the current state of
  2836. the guest's TLB. If userspace makes any changes, it must call KVM_DIRTY_TLB
  2837. to tell KVM which entries have been changed, prior to calling KVM_RUN again
  2838. on this vcpu.
  2839. For mmu types KVM_MMU_FSL_BOOKE_NOHV and KVM_MMU_FSL_BOOKE_HV:
  2840. - The "params" field is of type "struct kvm_book3e_206_tlb_params".
  2841. - The "array" field points to an array of type "struct
  2842. kvm_book3e_206_tlb_entry".
  2843. - The array consists of all entries in the first TLB, followed by all
  2844. entries in the second TLB.
  2845. - Within a TLB, entries are ordered first by increasing set number. Within a
  2846. set, entries are ordered by way (increasing ESEL).
  2847. - The hash for determining set number in TLB0 is: (MAS2 >> 12) & (num_sets - 1)
  2848. where "num_sets" is the tlb_sizes[] value divided by the tlb_ways[] value.
  2849. - The tsize field of mas1 shall be set to 4K on TLB0, even though the
  2850. hardware ignores this value for TLB0.
  2851. 6.4 KVM_CAP_S390_CSS_SUPPORT
  2852. Architectures: s390
  2853. Target: vcpu
  2854. Parameters: none
  2855. Returns: 0 on success; -1 on error
  2856. This capability enables support for handling of channel I/O instructions.
  2857. TEST PENDING INTERRUPTION and the interrupt portion of TEST SUBCHANNEL are
  2858. handled in-kernel, while the other I/O instructions are passed to userspace.
  2859. When this capability is enabled, KVM_EXIT_S390_TSCH will occur on TEST
  2860. SUBCHANNEL intercepts.
  2861. Note that even though this capability is enabled per-vcpu, the complete
  2862. virtual machine is affected.
  2863. 6.5 KVM_CAP_PPC_EPR
  2864. Architectures: ppc
  2865. Target: vcpu
  2866. Parameters: args[0] defines whether the proxy facility is active
  2867. Returns: 0 on success; -1 on error
  2868. This capability enables or disables the delivery of interrupts through the
  2869. external proxy facility.
  2870. When enabled (args[0] != 0), every time the guest gets an external interrupt
  2871. delivered, it automatically exits into user space with a KVM_EXIT_EPR exit
  2872. to receive the topmost interrupt vector.
  2873. When disabled (args[0] == 0), behavior is as if this facility is unsupported.
  2874. When this capability is enabled, KVM_EXIT_EPR can occur.
  2875. 6.6 KVM_CAP_IRQ_MPIC
  2876. Architectures: ppc
  2877. Parameters: args[0] is the MPIC device fd
  2878. args[1] is the MPIC CPU number for this vcpu
  2879. This capability connects the vcpu to an in-kernel MPIC device.
  2880. 6.7 KVM_CAP_IRQ_XICS
  2881. Architectures: ppc
  2882. Target: vcpu
  2883. Parameters: args[0] is the XICS device fd
  2884. args[1] is the XICS CPU number (server ID) for this vcpu
  2885. This capability connects the vcpu to an in-kernel XICS device.
  2886. 6.8 KVM_CAP_S390_IRQCHIP
  2887. Architectures: s390
  2888. Target: vm
  2889. Parameters: none
  2890. This capability enables the in-kernel irqchip for s390. Please refer to
  2891. "4.24 KVM_CREATE_IRQCHIP" for details.
  2892. 6.9 KVM_CAP_MIPS_FPU
  2893. Architectures: mips
  2894. Target: vcpu
  2895. Parameters: args[0] is reserved for future use (should be 0).
  2896. This capability allows the use of the host Floating Point Unit by the guest. It
  2897. allows the Config1.FP bit to be set to enable the FPU in the guest. Once this is
  2898. done the KVM_REG_MIPS_FPR_* and KVM_REG_MIPS_FCR_* registers can be accessed
  2899. (depending on the current guest FPU register mode), and the Status.FR,
  2900. Config5.FRE bits are accessible via the KVM API and also from the guest,
  2901. depending on them being supported by the FPU.
  2902. 6.10 KVM_CAP_MIPS_MSA
  2903. Architectures: mips
  2904. Target: vcpu
  2905. Parameters: args[0] is reserved for future use (should be 0).
  2906. This capability allows the use of the MIPS SIMD Architecture (MSA) by the guest.
  2907. It allows the Config3.MSAP bit to be set to enable the use of MSA by the guest.
  2908. Once this is done the KVM_REG_MIPS_VEC_* and KVM_REG_MIPS_MSA_* registers can be
  2909. accessed, and the Config5.MSAEn bit is accessible via the KVM API and also from
  2910. the guest.
  2911. 7. Capabilities that can be enabled on VMs
  2912. ------------------------------------------
  2913. There are certain capabilities that change the behavior of the virtual
  2914. machine when enabled. To enable them, please see section 4.37. Below
  2915. you can find a list of capabilities and what their effect on the VM
  2916. is when enabling them.
  2917. The following information is provided along with the description:
  2918. Architectures: which instruction set architectures provide this ioctl.
  2919. x86 includes both i386 and x86_64.
  2920. Parameters: what parameters are accepted by the capability.
  2921. Returns: the return value. General error numbers (EBADF, ENOMEM, EINVAL)
  2922. are not detailed, but errors with specific meanings are.
  2923. 7.1 KVM_CAP_PPC_ENABLE_HCALL
  2924. Architectures: ppc
  2925. Parameters: args[0] is the sPAPR hcall number
  2926. args[1] is 0 to disable, 1 to enable in-kernel handling
  2927. This capability controls whether individual sPAPR hypercalls (hcalls)
  2928. get handled by the kernel or not. Enabling or disabling in-kernel
  2929. handling of an hcall is effective across the VM. On creation, an
  2930. initial set of hcalls are enabled for in-kernel handling, which
  2931. consists of those hcalls for which in-kernel handlers were implemented
  2932. before this capability was implemented. If disabled, the kernel will
  2933. not to attempt to handle the hcall, but will always exit to userspace
  2934. to handle it. Note that it may not make sense to enable some and
  2935. disable others of a group of related hcalls, but KVM does not prevent
  2936. userspace from doing that.
  2937. If the hcall number specified is not one that has an in-kernel
  2938. implementation, the KVM_ENABLE_CAP ioctl will fail with an EINVAL
  2939. error.
  2940. 7.2 KVM_CAP_S390_USER_SIGP
  2941. Architectures: s390
  2942. Parameters: none
  2943. This capability controls which SIGP orders will be handled completely in user
  2944. space. With this capability enabled, all fast orders will be handled completely
  2945. in the kernel:
  2946. - SENSE
  2947. - SENSE RUNNING
  2948. - EXTERNAL CALL
  2949. - EMERGENCY SIGNAL
  2950. - CONDITIONAL EMERGENCY SIGNAL
  2951. All other orders will be handled completely in user space.
  2952. Only privileged operation exceptions will be checked for in the kernel (or even
  2953. in the hardware prior to interception). If this capability is not enabled, the
  2954. old way of handling SIGP orders is used (partially in kernel and user space).
  2955. 7.3 KVM_CAP_S390_VECTOR_REGISTERS
  2956. Architectures: s390
  2957. Parameters: none
  2958. Returns: 0 on success, negative value on error
  2959. Allows use of the vector registers introduced with z13 processor, and
  2960. provides for the synchronization between host and user space. Will
  2961. return -EINVAL if the machine does not support vectors.
  2962. 7.4 KVM_CAP_S390_USER_STSI
  2963. Architectures: s390
  2964. Parameters: none
  2965. This capability allows post-handlers for the STSI instruction. After
  2966. initial handling in the kernel, KVM exits to user space with
  2967. KVM_EXIT_S390_STSI to allow user space to insert further data.
  2968. Before exiting to userspace, kvm handlers should fill in s390_stsi field of
  2969. vcpu->run:
  2970. struct {
  2971. __u64 addr;
  2972. __u8 ar;
  2973. __u8 reserved;
  2974. __u8 fc;
  2975. __u8 sel1;
  2976. __u16 sel2;
  2977. } s390_stsi;
  2978. @addr - guest address of STSI SYSIB
  2979. @fc - function code
  2980. @sel1 - selector 1
  2981. @sel2 - selector 2
  2982. @ar - access register number
  2983. KVM handlers should exit to userspace with rc = -EREMOTE.
  2984. 7.5 KVM_CAP_SPLIT_IRQCHIP
  2985. Architectures: x86
  2986. Parameters: args[0] - number of routes reserved for userspace IOAPICs
  2987. Returns: 0 on success, -1 on error
  2988. Create a local apic for each processor in the kernel. This can be used
  2989. instead of KVM_CREATE_IRQCHIP if the userspace VMM wishes to emulate the
  2990. IOAPIC and PIC (and also the PIT, even though this has to be enabled
  2991. separately).
  2992. This capability also enables in kernel routing of interrupt requests;
  2993. when KVM_CAP_SPLIT_IRQCHIP only routes of KVM_IRQ_ROUTING_MSI type are
  2994. used in the IRQ routing table. The first args[0] MSI routes are reserved
  2995. for the IOAPIC pins. Whenever the LAPIC receives an EOI for these routes,
  2996. a KVM_EXIT_IOAPIC_EOI vmexit will be reported to userspace.
  2997. Fails if VCPU has already been created, or if the irqchip is already in the
  2998. kernel (i.e. KVM_CREATE_IRQCHIP has already been called).
  2999. 7.6 KVM_CAP_S390_RI
  3000. Architectures: s390
  3001. Parameters: none
  3002. Allows use of runtime-instrumentation introduced with zEC12 processor.
  3003. Will return -EINVAL if the machine does not support runtime-instrumentation.
  3004. Will return -EBUSY if a VCPU has already been created.
  3005. 7.7 KVM_CAP_X2APIC_API
  3006. Architectures: x86
  3007. Parameters: args[0] - features that should be enabled
  3008. Returns: 0 on success, -EINVAL when args[0] contains invalid features
  3009. Valid feature flags in args[0] are
  3010. #define KVM_X2APIC_API_USE_32BIT_IDS (1ULL << 0)
  3011. #define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK (1ULL << 1)
  3012. Enabling KVM_X2APIC_API_USE_32BIT_IDS changes the behavior of
  3013. KVM_SET_GSI_ROUTING, KVM_SIGNAL_MSI, KVM_SET_LAPIC, and KVM_GET_LAPIC,
  3014. allowing the use of 32-bit APIC IDs. See KVM_CAP_X2APIC_API in their
  3015. respective sections.
  3016. KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK must be enabled for x2APIC to work
  3017. in logical mode or with more than 255 VCPUs. Otherwise, KVM treats 0xff
  3018. as a broadcast even in x2APIC mode in order to support physical x2APIC
  3019. without interrupt remapping. This is undesirable in logical mode,
  3020. where 0xff represents CPUs 0-7 in cluster 0.
  3021. 7.8 KVM_CAP_S390_USER_INSTR0
  3022. Architectures: s390
  3023. Parameters: none
  3024. With this capability enabled, all illegal instructions 0x0000 (2 bytes) will
  3025. be intercepted and forwarded to user space. User space can use this
  3026. mechanism e.g. to realize 2-byte software breakpoints. The kernel will
  3027. not inject an operating exception for these instructions, user space has
  3028. to take care of that.
  3029. This capability can be enabled dynamically even if VCPUs were already
  3030. created and are running.
  3031. 8. Other capabilities.
  3032. ----------------------
  3033. This section lists capabilities that give information about other
  3034. features of the KVM implementation.
  3035. 8.1 KVM_CAP_PPC_HWRNG
  3036. Architectures: ppc
  3037. This capability, if KVM_CHECK_EXTENSION indicates that it is
  3038. available, means that that the kernel has an implementation of the
  3039. H_RANDOM hypercall backed by a hardware random-number generator.
  3040. If present, the kernel H_RANDOM handler can be enabled for guest use
  3041. with the KVM_CAP_PPC_ENABLE_HCALL capability.
  3042. 8.2 KVM_CAP_HYPERV_SYNIC
  3043. Architectures: x86
  3044. This capability, if KVM_CHECK_EXTENSION indicates that it is
  3045. available, means that that the kernel has an implementation of the
  3046. Hyper-V Synthetic interrupt controller(SynIC). Hyper-V SynIC is
  3047. used to support Windows Hyper-V based guest paravirt drivers(VMBus).
  3048. In order to use SynIC, it has to be activated by setting this
  3049. capability via KVM_ENABLE_CAP ioctl on the vcpu fd. Note that this
  3050. will disable the use of APIC hardware virtualization even if supported
  3051. by the CPU, as it's incompatible with SynIC auto-EOI behavior.